agentfootprint 2.11.1 → 2.11.2

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.
Files changed (67) hide show
  1. package/dist/core/Agent.js +81 -1238
  2. package/dist/core/Agent.js.map +1 -1
  3. package/dist/core/agent/AgentBuilder.js +489 -0
  4. package/dist/core/agent/AgentBuilder.js.map +1 -0
  5. package/dist/core/agent/buildAgentChart.js +227 -0
  6. package/dist/core/agent/buildAgentChart.js.map +1 -0
  7. package/dist/core/agent/buildToolRegistry.js +115 -0
  8. package/dist/core/agent/buildToolRegistry.js.map +1 -0
  9. package/dist/core/agent/stages/breakFinal.js +28 -0
  10. package/dist/core/agent/stages/breakFinal.js.map +1 -0
  11. package/dist/core/agent/stages/callLLM.js +129 -0
  12. package/dist/core/agent/stages/callLLM.js.map +1 -0
  13. package/dist/core/agent/stages/iterationStart.js +24 -0
  14. package/dist/core/agent/stages/iterationStart.js.map +1 -0
  15. package/dist/core/agent/stages/prepareFinal.js +45 -0
  16. package/dist/core/agent/stages/prepareFinal.js.map +1 -0
  17. package/dist/core/agent/stages/route.js +36 -0
  18. package/dist/core/agent/stages/route.js.map +1 -0
  19. package/dist/core/agent/stages/seed.js +95 -0
  20. package/dist/core/agent/stages/seed.js.map +1 -0
  21. package/dist/core/agent/stages/toolCalls.js +250 -0
  22. package/dist/core/agent/stages/toolCalls.js.map +1 -0
  23. package/dist/esm/core/Agent.js +83 -1239
  24. package/dist/esm/core/Agent.js.map +1 -1
  25. package/dist/esm/core/agent/AgentBuilder.js +485 -0
  26. package/dist/esm/core/agent/AgentBuilder.js.map +1 -0
  27. package/dist/esm/core/agent/buildAgentChart.js +223 -0
  28. package/dist/esm/core/agent/buildAgentChart.js.map +1 -0
  29. package/dist/esm/core/agent/buildToolRegistry.js +111 -0
  30. package/dist/esm/core/agent/buildToolRegistry.js.map +1 -0
  31. package/dist/esm/core/agent/stages/breakFinal.js +24 -0
  32. package/dist/esm/core/agent/stages/breakFinal.js.map +1 -0
  33. package/dist/esm/core/agent/stages/callLLM.js +125 -0
  34. package/dist/esm/core/agent/stages/callLLM.js.map +1 -0
  35. package/dist/esm/core/agent/stages/iterationStart.js +20 -0
  36. package/dist/esm/core/agent/stages/iterationStart.js.map +1 -0
  37. package/dist/esm/core/agent/stages/prepareFinal.js +41 -0
  38. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -0
  39. package/dist/esm/core/agent/stages/route.js +32 -0
  40. package/dist/esm/core/agent/stages/route.js.map +1 -0
  41. package/dist/esm/core/agent/stages/seed.js +91 -0
  42. package/dist/esm/core/agent/stages/seed.js.map +1 -0
  43. package/dist/esm/core/agent/stages/toolCalls.js +246 -0
  44. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -0
  45. package/dist/types/core/Agent.d.ts +5 -333
  46. package/dist/types/core/Agent.d.ts.map +1 -1
  47. package/dist/types/core/agent/AgentBuilder.d.ts +348 -0
  48. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -0
  49. package/dist/types/core/agent/buildAgentChart.d.ts +74 -0
  50. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -0
  51. package/dist/types/core/agent/buildToolRegistry.d.ts +62 -0
  52. package/dist/types/core/agent/buildToolRegistry.d.ts.map +1 -0
  53. package/dist/types/core/agent/stages/breakFinal.d.ts +23 -0
  54. package/dist/types/core/agent/stages/breakFinal.d.ts.map +1 -0
  55. package/dist/types/core/agent/stages/callLLM.d.ts +54 -0
  56. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -0
  57. package/dist/types/core/agent/stages/iterationStart.d.ts +16 -0
  58. package/dist/types/core/agent/stages/iterationStart.d.ts.map +1 -0
  59. package/dist/types/core/agent/stages/prepareFinal.d.ts +20 -0
  60. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -0
  61. package/dist/types/core/agent/stages/route.d.ts +19 -0
  62. package/dist/types/core/agent/stages/route.d.ts.map +1 -0
  63. package/dist/types/core/agent/stages/seed.d.ts +54 -0
  64. package/dist/types/core/agent/stages/seed.d.ts.map +1 -0
  65. package/dist/types/core/agent/stages/toolCalls.d.ts +50 -0
  66. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -0
  67. package/package.json +1 -1
@@ -0,0 +1,91 @@
1
+ /**
2
+ * seed — initial stage of the agent's chart. Initializes every mutable
3
+ * field of `AgentState` from the consumer's input.
4
+ *
5
+ * Runs once per `agent.run({ input })`. The chart is built once at
6
+ * Agent construction, so seed has access to BOTH:
7
+ *
8
+ * • CHART-BUILD-TIME constants (maxIterations, cachingDisabled,
9
+ * toolSchemas) — passed as direct values to the factory.
10
+ * • PER-RUN MUTABLE state (pendingResumeHistory from
11
+ * resumeOnError(), currentRunContext.runId set per run) —
12
+ * passed as accessor closures over the Agent instance, since
13
+ * these change between consecutive `agent.run()` invocations.
14
+ *
15
+ * The accessor pattern keeps `seed` decoupled from the Agent class
16
+ * while preserving the per-run mutability the resume + identity
17
+ * features need.
18
+ */
19
+ import { typedEmit } from '../../../recorders/core/typedEmit.js';
20
+ /**
21
+ * Build the seed stage function for an Agent instance. Captures both
22
+ * the chart-build-time constants and the per-run mutable accessors
23
+ * via the deps object.
24
+ */
25
+ export function buildSeedStage(deps) {
26
+ return (scope) => {
27
+ const args = scope.$getArgs();
28
+ scope.userMessage = args.message;
29
+ // If `resumeOnError(...)` set the side channel, restore the
30
+ // checkpointed conversation history. The next iteration sees
31
+ // the prior messages and continues from the failure point.
32
+ // Always clear the field after reading so subsequent runs
33
+ // (without resumeOnError) start fresh.
34
+ const resumeHistory = deps.consumePendingResumeHistory();
35
+ if (resumeHistory && resumeHistory.length > 0) {
36
+ scope.history = [...resumeHistory];
37
+ }
38
+ else {
39
+ scope.history = [{ role: 'user', content: args.message }];
40
+ }
41
+ // Default identity uses the runId so multi-run isolation works
42
+ // without consumer changes; explicit identity (multi-tenant)
43
+ // overrides via `agent.run({ identity })`.
44
+ scope.runIdentity = args.identity ?? {
45
+ conversationId: deps.getCurrentRunId() ?? 'default',
46
+ };
47
+ scope.newMessages = [];
48
+ scope.turnNumber = 1;
49
+ // Permissive default — explicit cap will land when PricingTable
50
+ // gets a context-window field. Memory pickByBudget treats anything
51
+ // ≥ minimumTokens as "fits", so this just enables the budget path.
52
+ scope.contextTokensRemaining = 32_000;
53
+ scope.iteration = 1;
54
+ scope.maxIterations = deps.maxIterations;
55
+ scope.finalContent = '';
56
+ scope.totalInputTokens = 0;
57
+ scope.totalOutputTokens = 0;
58
+ scope.turnStartMs = Date.now();
59
+ scope.systemPromptInjections = [];
60
+ scope.messagesInjections = [];
61
+ scope.toolsInjections = [];
62
+ scope.llmLatestContent = '';
63
+ scope.llmLatestToolCalls = [];
64
+ scope.pausedToolCallId = '';
65
+ scope.pausedToolName = '';
66
+ scope.pausedToolStartMs = 0;
67
+ scope.cumTokensInput = 0;
68
+ scope.cumTokensOutput = 0;
69
+ scope.cumEstimatedUsd = 0;
70
+ scope.costBudgetHit = false;
71
+ scope.activeInjections = [];
72
+ scope.activatedInjectionIds = [];
73
+ scope.dynamicToolSchemas = deps.toolSchemas;
74
+ // Cache layer state (v2.6) — initialized to inert defaults.
75
+ // CacheDecision subflow populates `cacheMarkers` per iteration;
76
+ // UpdateSkillHistory + CacheGate consume `cachingDisabled`,
77
+ // `recentHitRate`, `skillHistory`. Empty defaults mean the
78
+ // CacheGate falls through to 'apply-markers' on iter 1 (no
79
+ // history yet → no churn detected; recentHitRate undefined →
80
+ // hit-rate floor doesn't fire).
81
+ scope.cacheMarkers = [];
82
+ scope.cachingDisabled = deps.cachingDisabled;
83
+ scope.recentHitRate = undefined;
84
+ scope.skillHistory = [];
85
+ typedEmit(scope, 'agentfootprint.agent.turn_start', {
86
+ turnIndex: 0,
87
+ userPrompt: args.message,
88
+ });
89
+ };
90
+ }
91
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../../../../src/core/agent/stages/seed.ts"],"names":[],"mappings":"AAAA;;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/**
2
+ * toolCalls — pausable handler for executing the LLM-requested tool
3
+ * calls in the agent's ReAct loop.
4
+ *
5
+ * • `execute` iterates `scope.llmLatestToolCalls`, dispatches each
6
+ * tool, appends results to scope.history, and increments
7
+ * `scope.iteration`. If a tool throws `PauseRequest` (via
8
+ * `pauseHere()`), commits partial state and returns the pause
9
+ * payload so footprintjs captures a checkpoint.
10
+ * • `resume` runs after the consumer supplies the human's answer.
11
+ * Treats that answer as the paused tool's result, appends to
12
+ * history, then continues the ReAct iteration loop.
13
+ *
14
+ * Dispatch resolution order:
15
+ * 1. Static registry built at chart-build time (registryByName).
16
+ * 2. External `ToolProvider.list(ctx).find(...)` if a `.toolProvider()`
17
+ * was wired and the tool isn't in the static registry.
18
+ *
19
+ * Permission gate (when `permissionChecker` is configured) runs BEFORE
20
+ * `tool.execute`. Deny → tool not executed; result is a synthetic
21
+ * denial string. Allow / gate_open → execution proceeds.
22
+ *
23
+ * `read_skill` is the auto-attached activation tool — when the LLM
24
+ * calls it with a valid Skill id, the next InjectionEngine pass
25
+ * activates that Skill (lifetime: turn).
26
+ */
27
+ import { typedEmit } from '../../../recorders/core/typedEmit.js';
28
+ import { isPauseRequest } from '../../pause.js';
29
+ import { safeStringify } from '../validators.js';
30
+ /**
31
+ * Build the pausable tool-call handler for the agent's chart.
32
+ */
33
+ export function buildToolCallsHandler(deps) {
34
+ const { registryByName, externalToolProvider, permissionChecker } = deps;
35
+ return {
36
+ execute: async (scope) => {
37
+ const toolCalls = scope.llmLatestToolCalls;
38
+ const iteration = scope.iteration;
39
+ const newHistory = [...scope.history];
40
+ // ALWAYS push the assistant turn when there are tool calls — even
41
+ // if the content was empty — so providers (Anthropic, OpenAI) can
42
+ // round-trip the tool_use blocks via `LLMMessage.toolCalls`.
43
+ // Without this, the next iteration's request lacks the assistant
44
+ // turn that initiated the tool call, and the API rejects the
45
+ // following tool_result with "preceding tool_use missing".
46
+ if (scope.llmLatestContent || toolCalls.length > 0) {
47
+ newHistory.push({
48
+ role: 'assistant',
49
+ content: scope.llmLatestContent ?? '',
50
+ ...(toolCalls.length > 0 && { toolCalls }),
51
+ });
52
+ }
53
+ // Resolve a tool by name, consulting the external ToolProvider
54
+ // if one was wired via `.toolProvider()` and the static
55
+ // registry doesn't carry the tool. The provider sees the same
56
+ // ctx the Tools slot used, so dispatch + visibility stay
57
+ // consistent within the iteration.
58
+ const lookupTool = (toolName) => {
59
+ const fromRegistry = registryByName.get(toolName);
60
+ if (fromRegistry)
61
+ return fromRegistry;
62
+ if (!externalToolProvider)
63
+ return undefined;
64
+ const activatedIds = scope.activatedInjectionIds ?? [];
65
+ const identity = scope.runIdentity;
66
+ const ctx = {
67
+ iteration: scope.iteration,
68
+ ...(activatedIds.length > 0 && {
69
+ activeSkillId: activatedIds[activatedIds.length - 1],
70
+ }),
71
+ ...(identity && { identity }),
72
+ };
73
+ const visible = externalToolProvider.list(ctx);
74
+ return visible.find((t) => t.schema.name === toolName);
75
+ };
76
+ for (const tc of toolCalls) {
77
+ const tool = lookupTool(tc.name);
78
+ typedEmit(scope, 'agentfootprint.stream.tool_start', {
79
+ toolName: tc.name,
80
+ toolCallId: tc.id,
81
+ args: tc.args,
82
+ ...(toolCalls.length > 1 && { parallelCount: toolCalls.length }),
83
+ });
84
+ const startMs = Date.now();
85
+ let result;
86
+ let error;
87
+ // Permission gate — when a checker is configured, evaluate BEFORE
88
+ // executing the tool. Emits `permission.check` with the decision.
89
+ // On 'deny', the tool is not executed and its result is a
90
+ // synthetic denial string; on 'allow'/'gate_open', execution
91
+ // proceeds normally (the gate is informational — the consumer's
92
+ // checker is responsible for any gate-open side effects).
93
+ let denied = false;
94
+ if (permissionChecker) {
95
+ try {
96
+ const decision = await permissionChecker.check({
97
+ capability: 'tool_call',
98
+ actor: 'agent',
99
+ target: tc.name,
100
+ context: tc.args,
101
+ });
102
+ typedEmit(scope, 'agentfootprint.permission.check', {
103
+ capability: 'tool_call',
104
+ actor: 'agent',
105
+ target: tc.name,
106
+ result: decision.result,
107
+ ...(decision.policyRuleId !== undefined && { policyRuleId: decision.policyRuleId }),
108
+ ...(decision.rationale !== undefined && { rationale: decision.rationale }),
109
+ });
110
+ if (decision.result === 'deny') {
111
+ denied = true;
112
+ result = `[permission denied: ${decision.rationale ?? 'policy'}]`;
113
+ }
114
+ }
115
+ catch (permErr) {
116
+ // A checker that throws is treated as deny-by-default. The
117
+ // denial message records the thrown error so consumers can
118
+ // debug policy-adapter failures without losing the run.
119
+ denied = true;
120
+ const msg = permErr instanceof Error ? permErr.message : String(permErr);
121
+ typedEmit(scope, 'agentfootprint.permission.check', {
122
+ capability: 'tool_call',
123
+ actor: 'agent',
124
+ target: tc.name,
125
+ result: 'deny',
126
+ rationale: `permission-checker threw: ${msg}`,
127
+ });
128
+ result = `[permission denied: checker error: ${msg}]`;
129
+ }
130
+ }
131
+ if (!denied) {
132
+ try {
133
+ if (!tool)
134
+ throw new Error(`Unknown tool: ${tc.name}`);
135
+ result = await tool.execute(tc.args, {
136
+ toolCallId: tc.id,
137
+ iteration,
138
+ });
139
+ }
140
+ catch (err) {
141
+ if (isPauseRequest(err)) {
142
+ // Commit partial state so resume() can find history intact.
143
+ scope.history = newHistory;
144
+ scope.pausedToolCallId = tc.id;
145
+ scope.pausedToolName = tc.name;
146
+ scope.pausedToolStartMs = startMs;
147
+ // Returning a defined value triggers footprintjs pause —
148
+ // the returned object becomes the checkpoint's pauseData.
149
+ return {
150
+ toolCallId: tc.id,
151
+ toolName: tc.name,
152
+ ...(typeof err.data === 'object' && err.data !== null
153
+ ? err.data
154
+ : { data: err.data }),
155
+ };
156
+ }
157
+ error = true;
158
+ result = err instanceof Error ? err.message : String(err);
159
+ }
160
+ }
161
+ const durationMs = Date.now() - startMs;
162
+ typedEmit(scope, 'agentfootprint.stream.tool_end', {
163
+ toolCallId: tc.id,
164
+ result,
165
+ durationMs,
166
+ ...(error === true && { error: true }),
167
+ });
168
+ const resultStr = typeof result === 'string' ? result : safeStringify(result);
169
+ newHistory.push({
170
+ role: 'tool',
171
+ content: resultStr,
172
+ toolCallId: tc.id,
173
+ toolName: tc.name,
174
+ });
175
+ // ── Dynamic ReAct wiring ───────────────────────────────
176
+ //
177
+ // (1) `lastToolResult` drives `on-tool-return` Injection
178
+ // triggers — the InjectionEngine's NEXT pass will see
179
+ // this and activate any matching Instructions.
180
+ scope.lastToolResult = { toolName: tc.name, result: resultStr };
181
+ // (2) `read_skill` is the auto-attached activation tool.
182
+ // When the LLM calls it with a valid Skill id, append
183
+ // to `activatedInjectionIds` so the InjectionEngine's
184
+ // NEXT pass activates that Skill (lifetime: turn — stays
185
+ // active until the turn ends).
186
+ if (tc.name === 'read_skill' && !error && !denied) {
187
+ const requestedId = tc.args.id;
188
+ if (typeof requestedId === 'string' && requestedId.length > 0) {
189
+ const current = scope.activatedInjectionIds;
190
+ if (!current.includes(requestedId)) {
191
+ scope.activatedInjectionIds = [...current, requestedId];
192
+ }
193
+ }
194
+ }
195
+ }
196
+ scope.history = newHistory;
197
+ typedEmit(scope, 'agentfootprint.agent.iteration_end', {
198
+ turnIndex: 0,
199
+ iterIndex: iteration,
200
+ toolCallCount: toolCalls.length,
201
+ history: scope.history,
202
+ });
203
+ scope.iteration = iteration + 1;
204
+ return undefined; // explicit: no pause, flow continues to loopTo
205
+ },
206
+ resume: (scope, input) => {
207
+ // Consumer-supplied resume input becomes the paused tool's result.
208
+ // The subflow's pre-pause scope is restored automatically by
209
+ // footprintjs 4.17.0 via `checkpoint.subflowStates`, so
210
+ // `scope.history` and `scope.pausedToolCallId` read back cleanly
211
+ // across same-executor AND cross-executor resume.
212
+ const toolCallId = scope.pausedToolCallId;
213
+ const toolName = scope.pausedToolName;
214
+ const startMs = scope.pausedToolStartMs;
215
+ const resultStr = typeof input === 'string' ? input : safeStringify(input);
216
+ const newHistory = [
217
+ ...scope.history,
218
+ {
219
+ role: 'tool',
220
+ content: resultStr,
221
+ toolCallId,
222
+ toolName,
223
+ },
224
+ ];
225
+ scope.history = newHistory;
226
+ typedEmit(scope, 'agentfootprint.stream.tool_end', {
227
+ toolCallId,
228
+ result: input,
229
+ durationMs: Date.now() - startMs,
230
+ });
231
+ const iteration = scope.iteration;
232
+ typedEmit(scope, 'agentfootprint.agent.iteration_end', {
233
+ turnIndex: 0,
234
+ iterIndex: iteration,
235
+ toolCallCount: 1,
236
+ history: scope.history,
237
+ });
238
+ scope.iteration = iteration + 1;
239
+ // Clear pause checkpoint fields.
240
+ scope.pausedToolCallId = '';
241
+ scope.pausedToolName = '';
242
+ scope.pausedToolStartMs = 0;
243
+ },
244
+ };
245
+ }
246
+ //# sourceMappingURL=toolCalls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolCalls.js","sourceRoot":"","sources":["../../../../../src/core/agent/stages/toolCalls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAkBjD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAA0B;IAE1B,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAEzE,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACvB,MAAM,SAAS,GAAG,KAAK,CAAC,kBAIrB,CAAC;YACJ,MAAM,SAAS,GAAG,KAAK,CAAC,SAAmB,CAAC;YAC5C,MAAM,UAAU,GAAiB,CAAC,GAAI,KAAK,CAAC,OAAiC,CAAC,CAAC;YAC/E,kEAAkE;YAClE,kEAAkE;YAClE,6DAA6D;YAC7D,iEAAiE;YACjE,6DAA6D;YAC7D,2DAA2D;YAC3D,IAAI,KAAK,CAAC,gBAAgB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnD,UAAU,CAAC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