agentfootprint 2.3.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 +293 -247
- 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 +493 -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 +492 -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 +181 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.js.map +1 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js +35 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.js +9 -1
- 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 +57 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/SkillRegistry.js +185 -0
- package/dist/lib/injection-engine/SkillRegistry.js.map +1 -0
- package/dist/lib/injection-engine/factories/defineSkill.js +37 -1
- package/dist/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/lib/injection-engine/index.js +14 -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 +216 -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 +148 -0
- package/dist/types/lib/injection-engine/SkillRegistry.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts +99 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +5 -2
- 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 +28 -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 +62 -9
- package/README.proposed.md +0 -258
- package/dist/instructions.js +0 -21
- package/dist/instructions.js.map +0 -1
- package/dist/lib/instructions/defineInstruction.js +0 -35
- package/dist/lib/instructions/defineInstruction.js.map +0 -1
- package/dist/lib/instructions/evaluator.js +0 -38
- package/dist/lib/instructions/evaluator.js.map +0 -1
- package/dist/lib/instructions/index.js +0 -48
- package/dist/lib/instructions/index.js.map +0 -1
- package/dist/lib/instructions/types.js +0 -22
- package/dist/lib/instructions/types.js.map +0 -1
- package/dist/memory/conversationHelpers.js +0 -39
- package/dist/memory/conversationHelpers.js.map +0 -1
- package/dist/types/instructions.d.ts +0 -5
- package/dist/types/instructions.d.ts.map +0 -1
- package/dist/types/lib/instructions/defineInstruction.d.ts +0 -22
- package/dist/types/lib/instructions/defineInstruction.d.ts.map +0 -1
- package/dist/types/lib/instructions/evaluator.d.ts +0 -11
- package/dist/types/lib/instructions/evaluator.d.ts.map +0 -1
- package/dist/types/lib/instructions/index.d.ts +0 -44
- package/dist/types/lib/instructions/index.d.ts.map +0 -1
- package/dist/types/lib/instructions/types.d.ts +0 -100
- package/dist/types/lib/instructions/types.d.ts.map +0 -1
- package/dist/types/memory/conversationHelpers.d.ts +0 -19
- package/dist/types/memory/conversationHelpers.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentfootprint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sanjay Krishna Anbalagan",
|
|
@@ -52,10 +52,14 @@
|
|
|
52
52
|
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
53
53
|
"watch": "tsc -w",
|
|
54
54
|
"test": "vitest run",
|
|
55
|
+
"test:coverage": "vitest run --coverage",
|
|
55
56
|
"test:examples": "tsc -p examples/tsconfig.json && bash scripts/run-all-examples.sh",
|
|
56
57
|
"test:examples:typecheck": "tsc -p examples/tsconfig.json",
|
|
58
|
+
"examples:readme": "node scripts/generate-examples-readme.mjs",
|
|
59
|
+
"examples:readme:check": "node scripts/generate-examples-readme.mjs --check",
|
|
57
60
|
"example": "TSX_TSCONFIG_PATH=examples/runtime.tsconfig.json npx --yes tsx",
|
|
58
61
|
"test:watch": "vitest --watch",
|
|
62
|
+
"docs:api": "typedoc",
|
|
59
63
|
"lint": "eslint 'src/**/*.ts' 'test/**/*.ts' --ext .ts",
|
|
60
64
|
"lint:fix": "eslint 'src/**/*.ts' 'test/**/*.ts' --ext .ts --fix",
|
|
61
65
|
"format": "prettier --config .prettierrc.js --list-different 'src/**/*.ts' 'test/**/*.ts'",
|
|
@@ -95,6 +99,16 @@
|
|
|
95
99
|
"import": "./dist/esm/providers.js",
|
|
96
100
|
"require": "./dist/providers.js"
|
|
97
101
|
},
|
|
102
|
+
"./llm-providers": {
|
|
103
|
+
"types": "./dist/types/llm-providers.d.ts",
|
|
104
|
+
"import": "./dist/esm/llm-providers.js",
|
|
105
|
+
"require": "./dist/llm-providers.js"
|
|
106
|
+
},
|
|
107
|
+
"./memory-providers": {
|
|
108
|
+
"types": "./dist/types/memory-providers.d.ts",
|
|
109
|
+
"import": "./dist/esm/memory-providers.js",
|
|
110
|
+
"require": "./dist/memory-providers.js"
|
|
111
|
+
},
|
|
98
112
|
"./observe": {
|
|
99
113
|
"types": "./dist/types/observe.d.ts",
|
|
100
114
|
"import": "./dist/esm/observe.js",
|
|
@@ -124,29 +138,68 @@
|
|
|
124
138
|
"types": "./dist/types/adapters/memory/agentcore.d.ts",
|
|
125
139
|
"import": "./dist/esm/adapters/memory/agentcore.js",
|
|
126
140
|
"require": "./dist/adapters/memory/agentcore.js"
|
|
141
|
+
},
|
|
142
|
+
"./tool-providers": {
|
|
143
|
+
"types": "./dist/types/tool-providers/index.d.ts",
|
|
144
|
+
"import": "./dist/esm/tool-providers/index.js",
|
|
145
|
+
"require": "./dist/tool-providers/index.js"
|
|
146
|
+
},
|
|
147
|
+
"./security": {
|
|
148
|
+
"types": "./dist/types/security/index.d.ts",
|
|
149
|
+
"import": "./dist/esm/security/index.js",
|
|
150
|
+
"require": "./dist/security/index.js"
|
|
151
|
+
},
|
|
152
|
+
"./locales": {
|
|
153
|
+
"types": "./dist/types/locales/index.d.ts",
|
|
154
|
+
"import": "./dist/esm/locales/index.js",
|
|
155
|
+
"require": "./dist/locales/index.js"
|
|
127
156
|
}
|
|
128
157
|
},
|
|
129
158
|
"sideEffects": false,
|
|
130
159
|
"peerDependencies": {
|
|
131
|
-
"footprintjs": ">=4.14.0"
|
|
160
|
+
"footprintjs": ">=4.14.0",
|
|
161
|
+
"@anthropic-ai/sdk": "*",
|
|
162
|
+
"openai": "*",
|
|
163
|
+
"@aws-sdk/client-bedrock-runtime": "*",
|
|
164
|
+
"@aws-sdk/client-bedrock-agent-runtime": "*",
|
|
165
|
+
"@modelcontextprotocol/sdk": "*",
|
|
166
|
+
"ioredis": "*",
|
|
167
|
+
"zod": "*"
|
|
132
168
|
},
|
|
133
169
|
"peerDependenciesMeta": {
|
|
134
|
-
"@anthropic-ai/sdk": {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
170
|
+
"@anthropic-ai/sdk": {
|
|
171
|
+
"optional": true
|
|
172
|
+
},
|
|
173
|
+
"openai": {
|
|
174
|
+
"optional": true
|
|
175
|
+
},
|
|
176
|
+
"@aws-sdk/client-bedrock-runtime": {
|
|
177
|
+
"optional": true
|
|
178
|
+
},
|
|
179
|
+
"@aws-sdk/client-bedrock-agent-runtime": {
|
|
180
|
+
"optional": true
|
|
181
|
+
},
|
|
182
|
+
"@modelcontextprotocol/sdk": {
|
|
183
|
+
"optional": true
|
|
184
|
+
},
|
|
185
|
+
"ioredis": {
|
|
186
|
+
"optional": true
|
|
187
|
+
},
|
|
188
|
+
"zod": {
|
|
189
|
+
"optional": true
|
|
190
|
+
}
|
|
141
191
|
},
|
|
142
192
|
"devDependencies": {
|
|
143
193
|
"@types/node": "^25.5.2",
|
|
144
194
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
145
195
|
"@typescript-eslint/parser": "^5.61.0",
|
|
196
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
146
197
|
"eslint": "^8.44.0",
|
|
147
198
|
"eslint-config-prettier": "^6.15.0",
|
|
148
199
|
"footprintjs": "^4.14.0",
|
|
149
200
|
"prettier": "^2.8.1",
|
|
201
|
+
"typedoc": "^0.28.19",
|
|
202
|
+
"typedoc-plugin-markdown": "^4.11.0",
|
|
150
203
|
"typescript": "~5.4.5",
|
|
151
204
|
"vitest": "^4.1.5",
|
|
152
205
|
"zod": "^3.25.76"
|
package/README.proposed.md
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<h1 align="center">agentfootprint</h1>
|
|
3
|
-
<p align="center">
|
|
4
|
-
<strong>Build agents whose every decision, tool call, and memory write is a typed event<br>you can replay and audit — same day, or six months later.</strong>
|
|
5
|
-
</p>
|
|
6
|
-
</p>
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<a href="https://github.com/footprintjs/agentfootprint/actions"><img src="https://github.com/footprintjs/agentfootprint/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
10
|
-
<a href="https://www.npmjs.com/package/agentfootprint"><img src="https://img.shields.io/npm/v/agentfootprint.svg?style=flat" alt="npm version"></a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/agentfootprint"><img src="https://img.shields.io/npm/dm/agentfootprint.svg" alt="Downloads"></a>
|
|
12
|
-
<a href="https://github.com/footprintjs/agentfootprint/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT"></a>
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<br>
|
|
16
|
-
|
|
17
|
-
<!-- ┌────────────────────────────────────────────────────────────────┐
|
|
18
|
-
│ 📹 30-second demo video goes here. │
|
|
19
|
-
│ Embed: GitHub-hosted MP4 or Loom thumbnail. │
|
|
20
|
-
│ Content: paste a trace into the viewer → drag the │
|
|
21
|
-
│ time-travel slider → every step is there. │
|
|
22
|
-
│ This is the single most important asset on this page. │
|
|
23
|
-
└────────────────────────────────────────────────────────────────┘ -->
|
|
24
|
-
|
|
25
|
-
> **Try it without installing anything →** [Open the live trace viewer](https://footprintjs.github.io/agent-playground/#/viewer), paste the [sample trace](./examples/sample-trace.json), drag the slider. You'll see what your agent did, not what it logged.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## In 30 seconds
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install agentfootprint footprintjs
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { Agent, defineTool, mock } from 'agentfootprint';
|
|
37
|
-
|
|
38
|
-
const weather = defineTool({
|
|
39
|
-
name: 'weather',
|
|
40
|
-
description: 'Get current weather for a city.',
|
|
41
|
-
inputSchema: {
|
|
42
|
-
type: 'object',
|
|
43
|
-
properties: { city: { type: 'string' } },
|
|
44
|
-
required: ['city'],
|
|
45
|
-
},
|
|
46
|
-
execute: async ({ city }: { city: string }) => `${city}: 72°F, sunny`,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const agent = Agent.create({
|
|
50
|
-
provider: mock({ reply: 'Paris is 72°F and sunny.' }), // ← no API key
|
|
51
|
-
model: 'mock',
|
|
52
|
-
})
|
|
53
|
-
.system('You answer weather questions using the weather tool.')
|
|
54
|
-
.tool(weather)
|
|
55
|
-
.build();
|
|
56
|
-
|
|
57
|
-
const result = await agent.run({ message: 'Weather in Paris?' });
|
|
58
|
-
console.log(result); // → "Paris is 72°F and sunny."
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
That runs offline, deterministically, in <100ms, with no API key. Swap `mock(...)` for `anthropic(...)` / `openai(...)` / `bedrock(...)` / `ollama(...)` for production. Nothing else changes.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## The model in your head
|
|
66
|
-
|
|
67
|
-
Every LLM call has three slots. **Every "agent feature" — Skill, Steering doc, Instruction, Fact, Memory replay, RAG chunk — is content flowing into one of them, under one of four triggers.**
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
┌─────────────────────────────────────┐
|
|
71
|
-
│ │
|
|
72
|
-
│ Your LLM call has 3 slots: │
|
|
73
|
-
│ │
|
|
74
|
-
│ system messages tools │
|
|
75
|
-
│ ▲ ▲ ▲ │
|
|
76
|
-
└───────┼──────────┼──────────┼───────┘
|
|
77
|
-
│ │ │
|
|
78
|
-
│ one │ one │
|
|
79
|
-
│ Injection│ Injection│
|
|
80
|
-
│ fires… │ fires… │
|
|
81
|
-
│ │ │
|
|
82
|
-
┌──────────────┴────┐ ┌──┴───┐ ┌──┴────┐
|
|
83
|
-
│ defineSkill │ │ ... │ │ ... │
|
|
84
|
-
│ defineSteering │ │ │ │ │
|
|
85
|
-
│ defineInstruction │ │ │ │ │
|
|
86
|
-
│ defineFact │ │ │ │ │
|
|
87
|
-
│ defineMemory(read) │ │ │ │ │
|
|
88
|
-
│ defineRAG (v2.1) │ │ │ │ │
|
|
89
|
-
│ …your next idea │ │ │ │ │
|
|
90
|
-
└────────────────────┘ └──────┘ └───────┘
|
|
91
|
-
▲
|
|
92
|
-
…under one of:
|
|
93
|
-
always · rule · on-tool-return · llm-activated
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**There's no fourth slot.** There won't be. Every named pattern in the agent literature — Reflexion, Tree-of-Thoughts, Skills, RAG, Constitutional AI — reduces to *which slot* + *which trigger*. You learn one model; the field's growth lands as new factories on the same primitive.
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## What you can build
|
|
101
|
-
|
|
102
|
-
Three example shapes, all runnable end-to-end with `npm run example examples/<file>.ts`.
|
|
103
|
-
|
|
104
|
-
### Customer support agent (with skills, memory, and audit trail)
|
|
105
|
-
|
|
106
|
-
A support agent that activates a "billing" skill when needed, remembers the customer across sessions, and produces an audit-grade trace.
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
const agent = Agent.create({ provider: anthropic(...), model: 'claude-sonnet-4-5-20250929' })
|
|
110
|
-
.system('You are a friendly support assistant.')
|
|
111
|
-
.skill(billingSkill) // LLM activates with read_skill('billing')
|
|
112
|
-
.steering(toneGuidelines) // always-on
|
|
113
|
-
.memory(conversationMemory) // remembers across .run() calls
|
|
114
|
-
.build();
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
→ [`examples/context-engineering/06-mixed-flavors.ts`](examples/context-engineering/06-mixed-flavors.ts)
|
|
118
|
-
|
|
119
|
-
### Research pipeline (multi-agent, fan-out + merge)
|
|
120
|
-
|
|
121
|
-
Three perspectives explore in parallel; an LLM merges their findings.
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
const research = Parallel.create()
|
|
125
|
-
.branch(optimist).branch(skeptic).branch(historian)
|
|
126
|
-
.merge(synthesizer)
|
|
127
|
-
.build();
|
|
128
|
-
|
|
129
|
-
await research.run({ message: 'Should we adopt microservices?' });
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
→ [`examples/patterns/05-tot.ts`](examples/patterns/05-tot.ts) (Tree-of-Thoughts) · [`examples/patterns/01-self-consistency.ts`](examples/patterns/01-self-consistency.ts)
|
|
133
|
-
|
|
134
|
-
### Streaming chat agent (token-by-token to a browser)
|
|
135
|
-
|
|
136
|
-
<!-- ┌────────────────────────────────────────────────────────────────┐
|
|
137
|
-
│ 📹 Streaming demo clip here. │
|
|
138
|
-
│ A short loop: user types → token-by-token streaming → │
|
|
139
|
-
│ tool call appears mid-stream → final answer. │
|
|
140
|
-
│ Demonstrates `provider.stream()` + SSE bridge. │
|
|
141
|
-
└────────────────────────────────────────────────────────────────┘ -->
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
agent.on('agentfootprint.stream.token', (e) => res.write(e.payload.content));
|
|
145
|
-
agent.on('agentfootprint.stream.tool_start', (e) => res.write(`\n→ calling ${e.payload.toolName}...\n`));
|
|
146
|
-
await agent.run({ message: userInput });
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
→ [`docs-site/guides/streaming/`](docs-site/src/content/docs/guides/streaming.mdx)
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## The differentiator
|
|
154
|
-
|
|
155
|
-
Agent frameworks are a crowded shelf. Two things in here are not on the rest of that shelf.
|
|
156
|
-
|
|
157
|
-
### 1. Causal memory — replay *why*, not just *what*
|
|
158
|
-
|
|
159
|
-
Other libraries' memory remembers what was said. **agentfootprint's `defineMemory({ type: CAUSAL })` remembers the decision evidence** — every `decide()` and `select()` value the agent's flowchart captured during the run. New questions cosine-match against past queries, inject the prior decision evidence, and the LLM answers from *exact past facts* — not reconstruction.
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
const causal = defineMemory({
|
|
163
|
-
id: 'causal',
|
|
164
|
-
type: MEMORY_TYPES.CAUSAL,
|
|
165
|
-
strategy: { kind: MEMORY_STRATEGIES.TOP_K, topK: 1, threshold: 0.7, embedder },
|
|
166
|
-
store,
|
|
167
|
-
projection: SNAPSHOT_PROJECTIONS.DECISIONS, // inject "why" only, not "what"
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Monday: agent decides loan #42 should be rejected (creditScore=580, threshold=600)
|
|
171
|
-
// Friday: user asks "Why was my application rejected?"
|
|
172
|
-
// → Causal memory loads the exact decision evidence from Monday.
|
|
173
|
-
// → LLM answers from the SOURCE, not from memory of memory.
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
→ [`examples/memory/06-causal-snapshot.ts`](examples/memory/06-causal-snapshot.ts) — runs end-to-end with mock embedder, ~50 lines.
|
|
177
|
-
|
|
178
|
-
The same snapshot data shape becomes RL/SFT/DPO training data in v2.3+. Every successful production run becomes a labeled trajectory.
|
|
179
|
-
|
|
180
|
-
### 2. Trace export → trace replay
|
|
181
|
-
|
|
182
|
-
Every run exports as one JSON blob. Paste it into the viewer six months later, on a different machine. Every decision, every tool call, every memory write is on a draggable time-travel slider. **No log parsing. No reconstruction. The trace IS the evidence.**
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
const trace = exportTrace(agent); // serialize
|
|
186
|
-
fs.writeFileSync('incident-2026-04-29.json', trace); // archive
|
|
187
|
-
|
|
188
|
-
// Later — different team, different machine
|
|
189
|
-
<TraceViewer trace={JSON.parse(fs.readFileSync('incident-2026-04-29.json'))} />
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
That round-trip is the difference between "we shipped an agent and hope it's working" and "we can audit any production decision after the fact."
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## Mocks first, prod second
|
|
197
|
-
|
|
198
|
-
Generative AI development is expensive when every iteration hits a paid API. agentfootprint is designed so you build the entire app — agent, context engineering, memory, RAG — against in-memory mocks, prove the logic end-to-end with **zero API cost**, then swap real infrastructure in one boundary at a time.
|
|
199
|
-
|
|
200
|
-
| Boundary | Dev (mock) | Prod (swap one line) |
|
|
201
|
-
|---|---|---|
|
|
202
|
-
| LLM provider | `mock({ reply })` | `anthropic()` · `openai()` · `bedrock()` · `ollama()` |
|
|
203
|
-
| Embedder | `mockEmbedder()` | OpenAI / Cohere / Bedrock embedder |
|
|
204
|
-
| Memory store | `InMemoryStore` | Redis · DynamoDB · Postgres · Pinecone |
|
|
205
|
-
| MCP server | `mcpClient({ _client })` | `mcpClient({ transport })` |
|
|
206
|
-
| Tool execution | inline closure | real implementation |
|
|
207
|
-
|
|
208
|
-
The flowchart, recorders, narrative, and tests don't change between dev and prod. **Ship the patterns first; pay for tokens last.**
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Pick your starting door
|
|
213
|
-
|
|
214
|
-
| If you are... | Start here |
|
|
215
|
-
|---|---|
|
|
216
|
-
| 🎓 **New to agents** — never built one before | [5-minute Quick Start](https://footprintjs.github.io/agentfootprint/getting-started/quick-start/) → first agent runs offline |
|
|
217
|
-
| 🛠️ **A LangChain / CrewAI / LangGraph user** | [Migration sketch](https://footprintjs.github.io/agentfootprint/getting-started/vs/) — same patterns, fewer classes |
|
|
218
|
-
| 🏗️ **Architecting an enterprise rollout** | [Production guide](https://footprintjs.github.io/agentfootprint/guides/deployment/) — multi-tenant identity, audit trails, redaction, OTel |
|
|
219
|
-
| 🔬 **Researcher / extending the framework** | [Extension guide](https://footprintjs.github.io/agentfootprint/contributing/extension-guide/) — add a new flavor in 50 lines |
|
|
220
|
-
|
|
221
|
-
Every code snippet on the docs site is a real, runnable file in [`examples/`](examples/) — every example is also an end-to-end test in CI. There is no docs-only code in this repo.
|
|
222
|
-
|
|
223
|
-
---
|
|
224
|
-
|
|
225
|
-
## What ships today (v2.0)
|
|
226
|
-
|
|
227
|
-
- **2 primitives** — `LLMCall`, `Agent` (the ReAct loop)
|
|
228
|
-
- **4 compositions** — `Sequence`, `Parallel`, `Conditional`, `Loop`
|
|
229
|
-
- **6 LLM providers** — Anthropic · OpenAI · Bedrock · Ollama · Browser-Anthropic · Browser-OpenAI · Mock
|
|
230
|
-
- **One Injection primitive** — `defineSkill` / `defineSteering` / `defineInstruction` / `defineFact` (one engine, four typed factories, all reduce to `{ trigger, slot }`)
|
|
231
|
-
- **One Memory factory** — `defineMemory({ type, strategy, store })` — 4 types × 7 strategies including **Causal**
|
|
232
|
-
- **47 typed observability events** across 13 domains — context · stream · agent · cost · skill · permission · eval · memory · …
|
|
233
|
-
- **Pause / resume** — JSON-serializable checkpoints; pause via `askHuman`/`pauseHere`, resume hours later on a different server
|
|
234
|
-
- **Resilience** — `withRetry`, `withFallback`, `resilientProvider`
|
|
235
|
-
- **AI-coding-tool support** — bundled instructions for Claude Code · Cursor · Windsurf · Cline · Kiro · Copilot
|
|
236
|
-
- **33 runnable examples** organized by DNA layer (core · core-flow · patterns · context-engineering · memory · features)
|
|
237
|
-
|
|
238
|
-
## What's next (clearly marked roadmap)
|
|
239
|
-
|
|
240
|
-
| Release | Focus |
|
|
241
|
-
|---|---|
|
|
242
|
-
| v2.1 ✓ | RAG flavor (`defineRAG`) — *shipped* |
|
|
243
|
-
| v2.2 | MCP integration (`mcpClient`) ✓ · Redis adapter · CircuitBreaker · 3-tier output fallback |
|
|
244
|
-
| v2.3 | Governance (`Policy`, `BudgetTracker`) · DynamoDB / Postgres / Pinecone adapters |
|
|
245
|
-
| v2.4 | Causal training-data exports — `causalMemory.exportForTraining({ format: 'sft' \| 'dpo' \| 'process' })` |
|
|
246
|
-
| v2.5+ | Deep Agents (planning-before-execution) · A2A protocol · Lens UI deep-link |
|
|
247
|
-
|
|
248
|
-
Roadmap items are *not* claims about the current API. If a feature isn't in `npm install agentfootprint` today, it's listed here, not in the documentation.
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
## Built on
|
|
253
|
-
|
|
254
|
-
[footprintjs](https://github.com/footprintjs/footPrint) — the flowchart pattern for backend code. The decision-evidence capture, narrative recording, and time-travel checkpointing this library uses are footprintjs primitives. You don't need to learn footprintjs to use agentfootprint, but if you want to build your own primitives at this depth, [start there](https://footprintjs.github.io/footPrint/).
|
|
255
|
-
|
|
256
|
-
## License
|
|
257
|
-
|
|
258
|
-
[MIT](./LICENSE) © [Sanjay Krishna Anbalagan](https://github.com/sanjay1909)
|
package/dist/instructions.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* agentfootprint/instructions — public re-export for the Instructions subsystem.
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
__exportStar(require("./lib/instructions/index.js"), exports);
|
|
21
|
-
//# sourceMappingURL=instructions.js.map
|
package/dist/instructions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,8DAA4C"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* defineInstruction — ergonomic builder for `Instruction`.
|
|
4
|
-
*
|
|
5
|
-
* Pattern: Builder pattern (GoF) for the Strategy interface.
|
|
6
|
-
* Role: Public surface — used by consumers to declare instructions.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import { defineInstruction } from 'agentfootprint';
|
|
10
|
-
* import type { InstructionContext } from 'agentfootprint';
|
|
11
|
-
*
|
|
12
|
-
* const refundEmpathy = defineInstruction({
|
|
13
|
-
* id: 'refund-empathy',
|
|
14
|
-
* description: 'Calm tone for refund denials.',
|
|
15
|
-
* activeWhen: (ctx) => ctx.lastToolResult?.toolName === 'check_refund'
|
|
16
|
-
* && ctx.lastToolResult.result.includes('denied'),
|
|
17
|
-
* prompt: 'Be empathetic. Do NOT promise refund reversal.',
|
|
18
|
-
* });
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.defineInstruction = void 0;
|
|
22
|
-
function defineInstruction(options) {
|
|
23
|
-
if (!options.id || options.id.trim().length === 0) {
|
|
24
|
-
throw new Error('defineInstruction: `id` is required and must be non-empty.');
|
|
25
|
-
}
|
|
26
|
-
if (options.prompt === undefined
|
|
27
|
-
&& (!options.tools || options.tools.length === 0)) {
|
|
28
|
-
throw new Error(`defineInstruction(${options.id}): instruction must declare at least one of \`prompt\` or \`tools\`.`);
|
|
29
|
-
}
|
|
30
|
-
// Freeze for consumer protection — instructions should be immutable
|
|
31
|
-
// after construction so the agent can cache evaluations.
|
|
32
|
-
return Object.freeze({ ...options });
|
|
33
|
-
}
|
|
34
|
-
exports.defineInstruction = defineInstruction;
|
|
35
|
-
//# sourceMappingURL=defineInstruction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../src/lib/instructions/defineInstruction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAMH,SAAgB,iBAAiB,CAAC,OAAiC;IACjE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,IACE,OAAO,CAAC,MAAM,KAAK,SAAS;WACzB,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,EACjD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,qBAAqB,OAAO,CAAC,EAAE,sEAAsE,CACtG,CAAC;IACJ,CAAC;IACD,oEAAoE;IACpE,yDAAyD;IACzD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,CAAgB,CAAC;AACtD,CAAC;AAfD,8CAeC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Instruction evaluator — runs the `activeWhen` predicates and
|
|
4
|
-
* returns the active set + any skipped predicates.
|
|
5
|
-
*
|
|
6
|
-
* Pattern: Pure function. Stateless.
|
|
7
|
-
* Role: Internal helper used by Agent during pre-LLM stage.
|
|
8
|
-
* Emits: N/A — caller handles emit + observability.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.evaluateInstructions = void 0;
|
|
12
|
-
function evaluateInstructions(instructions, ctx) {
|
|
13
|
-
const active = [];
|
|
14
|
-
const skipped = [];
|
|
15
|
-
for (const inst of instructions) {
|
|
16
|
-
if (!inst.activeWhen) {
|
|
17
|
-
// No predicate → always active (unconditional injection).
|
|
18
|
-
active.push(inst);
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
let matched = false;
|
|
22
|
-
try {
|
|
23
|
-
matched = inst.activeWhen(ctx);
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
skipped.push({
|
|
27
|
-
id: inst.id,
|
|
28
|
-
error: err instanceof Error ? err.message : String(err),
|
|
29
|
-
});
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (matched)
|
|
33
|
-
active.push(inst);
|
|
34
|
-
}
|
|
35
|
-
return { active, skipped };
|
|
36
|
-
}
|
|
37
|
-
exports.evaluateInstructions = evaluateInstructions;
|
|
38
|
-
//# sourceMappingURL=evaluator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../src/lib/instructions/evaluator.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAQH,SAAgB,oBAAoB,CAClC,YAAoC,EACpC,GAAuB;IAEvB,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,OAAO,GAAoC,EAAE,CAAC;IAEpD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,0DAA0D;YAC1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,SAAS;QACX,CAAC;QACD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AA3BD,oDA2BC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Instructions — declarative rule-based system-prompt injection.
|
|
4
|
-
*
|
|
5
|
-
* Public API for the v2 Instructions subsystem. See `types.ts` for the
|
|
6
|
-
* full interface + the unified context-engineering model placement.
|
|
7
|
-
*
|
|
8
|
-
* ─── 7-panel design review (2026-04-28) ─────────────────────────────
|
|
9
|
-
*
|
|
10
|
-
* LLM-AI system design ✓ Maps cleanly to the unified context-
|
|
11
|
-
* engineering model: slot=system-prompt
|
|
12
|
-
* (+optional tools), role=system, timing=
|
|
13
|
-
* per-iteration, decision=rule.
|
|
14
|
-
* Performance ✓ Predicates run once per iteration (not
|
|
15
|
-
* per token / per event). O(N) in number
|
|
16
|
-
* of instructions; typical N ≤ 20.
|
|
17
|
-
* Scalability ✓ Stateless evaluator; many concurrent
|
|
18
|
-
* agents share the same instruction list
|
|
19
|
-
* via Object.freeze.
|
|
20
|
-
* Research alignment ✓ Mirrors v1 AgentInstruction's `activeWhen`
|
|
21
|
-
* shape (origin/main `c6e11d0`) but drops
|
|
22
|
-
* `onToolResult`, `safety`, decision-scope
|
|
23
|
-
* wrapping for v2 simplicity. Equivalent
|
|
24
|
-
* tool-result-driven behavior is expressed
|
|
25
|
-
* via `activeWhen: (ctx) =>
|
|
26
|
-
* ctx.lastToolResult?.toolName === 'X'`.
|
|
27
|
-
* Flexibility ✓ Same Instruction can be active across
|
|
28
|
-
* multiple iterations; can inject tools
|
|
29
|
-
* in addition to prompt; predicates can
|
|
30
|
-
* inspect history + last tool result.
|
|
31
|
-
* Abstraction-modular ✓ Three small files: types, builder,
|
|
32
|
-
* evaluator. Agent integration is one
|
|
33
|
-
* call into `evaluateInstructions()`.
|
|
34
|
-
* Software engineering ✓ Predicate errors are caught + surfaced
|
|
35
|
-
* (no crash). Frozen instructions prevent
|
|
36
|
-
* mutation. 7-pattern test coverage.
|
|
37
|
-
*
|
|
38
|
-
* ─── 7-pattern test coverage ────────────────────────────────────────
|
|
39
|
-
*
|
|
40
|
-
* See `test/lib/instructions/*.test.ts`.
|
|
41
|
-
*/
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.evaluateInstructions = exports.defineInstruction = void 0;
|
|
44
|
-
var defineInstruction_js_1 = require("./defineInstruction.js");
|
|
45
|
-
Object.defineProperty(exports, "defineInstruction", { enumerable: true, get: function () { return defineInstruction_js_1.defineInstruction; } });
|
|
46
|
-
var evaluator_js_1 = require("./evaluator.js");
|
|
47
|
-
Object.defineProperty(exports, "evaluateInstructions", { enumerable: true, get: function () { return evaluator_js_1.evaluateInstructions; } });
|
|
48
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/instructions/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;;AAEH,+DAGgC;AAF9B,yHAAA,iBAAiB,OAAA;AAInB,+CAEwB;AADtB,oHAAA,oBAAoB,OAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Instructions — types.
|
|
4
|
-
*
|
|
5
|
-
* An Instruction is a declarative rule for conditional system-prompt
|
|
6
|
-
* injection. The agent evaluates each Instruction's `activeWhen`
|
|
7
|
-
* predicate at the start of every iteration; matching instructions'
|
|
8
|
-
* `prompt` text is prepended to the system prompt for that iteration.
|
|
9
|
-
*
|
|
10
|
-
* This is the rule-based flavor of the unified context-engineering
|
|
11
|
-
* model: slot=system-prompt, role=system, timing=per-iteration,
|
|
12
|
-
* decision=rule. (Compare with Skills: timing=on-activation,
|
|
13
|
-
* decision=LLM-guided.)
|
|
14
|
-
*
|
|
15
|
-
* Pattern: Strategy (GoF) — each Instruction is a strategy for
|
|
16
|
-
* "should I add this prompt to the next iteration?"
|
|
17
|
-
* Role: Consumer-facing shape. Agent.create(...).instruction(...).
|
|
18
|
-
* Emits: `agentfootprint.context.injected` with source='instruction'
|
|
19
|
-
* when an instruction activates.
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/instructions/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Pure functions for conversation message management.
|
|
4
|
-
* No state — just transformations on message arrays.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createToolResults = exports.lastMessageHasToolCalls = exports.lastAssistantMessage = exports.lastMessage = exports.appendMessage = void 0;
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
/** Append a message to the conversation. Returns new array. */
|
|
10
|
-
function appendMessage(messages, message) {
|
|
11
|
-
return [...messages, message];
|
|
12
|
-
}
|
|
13
|
-
exports.appendMessage = appendMessage;
|
|
14
|
-
/** Get the last message in the conversation. */
|
|
15
|
-
function lastMessage(messages) {
|
|
16
|
-
return messages[messages.length - 1];
|
|
17
|
-
}
|
|
18
|
-
exports.lastMessage = lastMessage;
|
|
19
|
-
/** Get the last assistant message. */
|
|
20
|
-
function lastAssistantMessage(messages) {
|
|
21
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
22
|
-
if (messages[i].role === 'assistant')
|
|
23
|
-
return messages[i];
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
exports.lastAssistantMessage = lastAssistantMessage;
|
|
28
|
-
/** Check if the last assistant message has tool calls. */
|
|
29
|
-
function lastMessageHasToolCalls(messages) {
|
|
30
|
-
const last = lastAssistantMessage(messages);
|
|
31
|
-
return last ? (0, types_1.hasToolCalls)(last) : false;
|
|
32
|
-
}
|
|
33
|
-
exports.lastMessageHasToolCalls = lastMessageHasToolCalls;
|
|
34
|
-
/** Create tool result messages from a map of tool call ID → result. */
|
|
35
|
-
function createToolResults(results) {
|
|
36
|
-
return results.map((r) => (0, types_1.toolResultMessage)(r.content, r.toolCallId));
|
|
37
|
-
}
|
|
38
|
-
exports.createToolResults = createToolResults;
|
|
39
|
-
//# sourceMappingURL=conversationHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversationHelpers.js","sourceRoot":"","sources":["../../src/memory/conversationHelpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,oCAA2D;AAE3D,+DAA+D;AAC/D,SAAgB,aAAa,CAAC,QAAmB,EAAE,OAAgB;IACjE,OAAO,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAFD,sCAEC;AAED,gDAAgD;AAChD,SAAgB,WAAW,CAAC,QAAmB;IAC7C,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,kCAEC;AAED,sCAAsC;AACtC,SAAgB,oBAAoB,CAAC,QAAmB;IACtD,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,QAAQ,CAAC,CAAC,CAAqB,CAAC;IAC/E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AALD,oDAKC;AAED,0DAA0D;AAC1D,SAAgB,uBAAuB,CAAC,QAAmB;IACzD,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,CAAC,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3C,CAAC;AAHD,0DAGC;AAED,uEAAuE;AACvE,SAAgB,iBAAiB,CAC/B,OAAuD;IAEvD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,yBAAiB,EAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AACxE,CAAC;AAJD,8CAIC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/instructions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* defineInstruction — ergonomic builder for `Instruction`.
|
|
3
|
-
*
|
|
4
|
-
* Pattern: Builder pattern (GoF) for the Strategy interface.
|
|
5
|
-
* Role: Public surface — used by consumers to declare instructions.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* import { defineInstruction } from 'agentfootprint';
|
|
9
|
-
* import type { InstructionContext } from 'agentfootprint';
|
|
10
|
-
*
|
|
11
|
-
* const refundEmpathy = defineInstruction({
|
|
12
|
-
* id: 'refund-empathy',
|
|
13
|
-
* description: 'Calm tone for refund denials.',
|
|
14
|
-
* activeWhen: (ctx) => ctx.lastToolResult?.toolName === 'check_refund'
|
|
15
|
-
* && ctx.lastToolResult.result.includes('denied'),
|
|
16
|
-
* prompt: 'Be empathetic. Do NOT promise refund reversal.',
|
|
17
|
-
* });
|
|
18
|
-
*/
|
|
19
|
-
import type { Instruction } from './types.js';
|
|
20
|
-
export type DefineInstructionOptions = Instruction;
|
|
21
|
-
export declare function defineInstruction(options: DefineInstructionOptions): Instruction;
|
|
22
|
-
//# sourceMappingURL=defineInstruction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineInstruction.d.ts","sourceRoot":"","sources":["../../../../src/lib/instructions/defineInstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEnD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CAehF"}
|