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,348 @@
1
+ /**
2
+ * AgentBuilder — fluent builder for Agent. Extracted from Agent.ts in
3
+ * v2.11.2 as part of the core/agent decomposition. Same surface, same
4
+ * behavior; just lives in its own file for readability.
5
+ *
6
+ * Re-exported by Agent.ts so external consumers importing
7
+ * `AgentBuilder` from `'../core/Agent.js'` continue to work.
8
+ */
9
+ import { type OutputSchemaOptions, type OutputSchemaParser } from '../outputSchema.js';
10
+ import { type OutputFallbackOptions } from '../outputFallback.js';
11
+ import type { CachePolicy } from '../../cache/types.js';
12
+ import type { Injection } from '../../lib/injection-engine/types.js';
13
+ import type { MemoryDefinition } from '../../memory/define.types.js';
14
+ import type { Tool } from '../tools.js';
15
+ import type { ToolProvider } from '../../tool-providers/types.js';
16
+ import { Agent } from '../Agent.js';
17
+ import type { AgentOptions } from './types.js';
18
+ /**
19
+ * Fluent builder. `tool()` accepts any Tool<TArgs, TResult> and registers
20
+ * it by its schema.name. Duplicate names throw at build time.
21
+ */
22
+ export declare class AgentBuilder {
23
+ private readonly opts;
24
+ private systemPromptValue;
25
+ /**
26
+ * Cache policy for the base system prompt. Set via the optional
27
+ * 2nd argument to `.system(text, { cache })`. Default `'always'` —
28
+ * the base prompt is stable per-turn and an ideal cache anchor.
29
+ */
30
+ private systemPromptCachePolicy;
31
+ /**
32
+ * Global cache kill switch. Set via `Agent.create({ caching: 'off' })`
33
+ * (handled in `AgentOptions` propagation). Defaults to `false`
34
+ * (caching enabled). When `true`, the CacheGate decider routes to
35
+ * `'no-markers'` every iteration regardless of other rules.
36
+ */
37
+ private cachingDisabledValue;
38
+ /**
39
+ * Optional explicit CacheStrategy override. Default: undefined,
40
+ * which means the agent auto-resolves from
41
+ * `getDefaultCacheStrategy(provider.name)` at construction. Power
42
+ * users override here for custom backends or test mocks.
43
+ */
44
+ private cacheStrategyOverride?;
45
+ private readonly registry;
46
+ private readonly injectionList;
47
+ private readonly memoryList;
48
+ /**
49
+ * Optional terminal contract — see `outputSchema()`. Stored on the
50
+ * builder, propagated to the Agent at `.build()` time.
51
+ */
52
+ private outputSchemaParser?;
53
+ /** 3-tier output fallback chain — set via `.outputFallback({...})`.
54
+ * Optional; absent = current throw-on-validation-failure behavior. */
55
+ private outputFallbackCfg?;
56
+ /**
57
+ * Optional `ToolProvider` set via `.toolProvider()`. Propagated to
58
+ * the Agent's Tools slot subflow + tool-call dispatcher; consulted
59
+ * per iteration so dynamic chains (`gatedTools`, `skillScopedTools`)
60
+ * react to current activation state.
61
+ */
62
+ private toolProviderRef?;
63
+ /**
64
+ * Optional override for `AgentOptions.maxIterations`. When set via
65
+ * the `.maxIterations()` builder method, takes precedence over the
66
+ * value passed to `Agent.create({ maxIterations })`.
67
+ */
68
+ private maxIterationsOverride?;
69
+ /**
70
+ * Recorders collected via `.recorder()`. Attached to the built Agent
71
+ * before `build()` returns (each via `agent.attach(rec)`).
72
+ */
73
+ private readonly recorderList;
74
+ private appNameValue;
75
+ private commentaryOverrides;
76
+ private thinkingOverrides;
77
+ constructor(opts: AgentOptions);
78
+ /**
79
+ * Set the base system prompt.
80
+ *
81
+ * @param prompt - The system prompt text. Stable per-turn.
82
+ * @param options - Optional config. `cache` controls how the
83
+ * CacheDecision subflow treats this prompt block:
84
+ * - `'always'` (default) — cache the base prompt as a stable
85
+ * prefix anchor. Highest cache-hit rate; recommended for
86
+ * production agents whose system prompt rarely changes.
87
+ * - `'never'` — skip caching. Use if the prompt contains volatile
88
+ * content (timestamps, per-request user IDs).
89
+ * - `'while-active'` — semantically equivalent to `'always'` for
90
+ * the base prompt (it's always active by definition).
91
+ * - `{ until }` — conditional invalidation (e.g., flush after iter 5).
92
+ */
93
+ system(prompt: string, options?: {
94
+ readonly cache?: CachePolicy;
95
+ }): this;
96
+ tool<TArgs, TResult>(tool: Tool<TArgs, TResult>): this;
97
+ /**
98
+ * Register many tools at once. Convenience for tool sources that
99
+ * return a list (e.g., `await mcpClient(...).tools()`). Each tool
100
+ * is registered via `.tool()` so duplicate-name validation still
101
+ * fires per-entry.
102
+ */
103
+ tools(tools: ReadonlyArray<Tool>): this;
104
+ /**
105
+ * Wire a chainable `ToolProvider` (from `agentfootprint/tool-providers`)
106
+ * as the agent's per-iteration tool source.
107
+ *
108
+ * The provider is consulted EVERY iteration via `provider.list(ctx)`
109
+ * with `ctx = { iteration, activeSkillId, identity }`. Tools the
110
+ * provider emits flow into the Tools slot alongside any static
111
+ * tools registered via `.tool()` / `.tools()`. The tool-call
112
+ * dispatcher also consults the provider so dynamic chains
113
+ * (`gatedTools`, `skillScopedTools`) dispatch correctly when their
114
+ * visible-set changes mid-turn.
115
+ *
116
+ * Throws if called more than once on the same builder (avoids
117
+ * silent override surprises).
118
+ *
119
+ * @example Permission-gated baseline
120
+ * import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
121
+ * import { PermissionPolicy } from 'agentfootprint/security';
122
+ *
123
+ * const policy = PermissionPolicy.fromRoles({
124
+ * readonly: ['lookup', 'list_skills', 'read_skill'],
125
+ * admin: ['lookup', 'list_skills', 'read_skill', 'delete'],
126
+ * }, 'readonly');
127
+ *
128
+ * const provider = gatedTools(
129
+ * staticTools(allTools),
130
+ * (toolName) => policy.isAllowed(toolName),
131
+ * );
132
+ *
133
+ * const agent = Agent.create({ provider: llm, model })
134
+ * .system('You answer.')
135
+ * .toolProvider(provider)
136
+ * .build();
137
+ */
138
+ toolProvider(provider: ToolProvider): this;
139
+ /**
140
+ * Override the ReAct iteration cap set via `Agent.create({
141
+ * maxIterations })`. Convenience for builder-style code that prefers
142
+ * fluent setters over constructor opts. Last call wins.
143
+ *
144
+ * Throws if `n` is not a positive integer or exceeds the hard cap
145
+ * (`clampIterations`'s upper bound).
146
+ */
147
+ maxIterations(n: number): this;
148
+ /**
149
+ * Attach a footprintjs `CombinedRecorder` to the built Agent. Wired
150
+ * via `agent.attach(rec)` immediately after construction, so the
151
+ * recorder sees every event from the very first run.
152
+ *
153
+ * Equivalent to calling `agent.attach(rec)` post-build; the builder
154
+ * method is a convenience for codebases that prefer fully-fluent
155
+ * agent assembly. Multiple recorders are supported (each gets its
156
+ * own `attach()` call).
157
+ */
158
+ recorder(rec: import('footprintjs').CombinedRecorder): this;
159
+ /**
160
+ * Set the agent's display name — substituted as `{{appName}}` in
161
+ * commentary + thinking templates. Same place to brand a tenant
162
+ * ("Acme Bot"), distinguish multi-agent roles ("Triage" vs
163
+ * "Reviewer"), or localize ("Asistente"). Default: `'Chatbot'`.
164
+ */
165
+ appName(name: string): this;
166
+ /**
167
+ * Override agentfootprint's bundled commentary templates. Spread on
168
+ * top of `defaultCommentaryTemplates`; missing keys fall back. Same
169
+ * `Record<string, string>` shape with `{{vars}}` substitution as
170
+ * the bundled defaults — see `defaultCommentaryTemplates` for the
171
+ * full key list.
172
+ *
173
+ * Use cases: i18n (`'agent.turn_start': 'El usuario...'`), brand
174
+ * voice ("You: {{userPrompt}}"), per-tenant customization.
175
+ */
176
+ commentaryTemplates(templates: Readonly<Record<string, string>>): this;
177
+ /**
178
+ * Override agentfootprint's bundled thinking templates. Same
179
+ * contract shape as commentary; different vocabulary — first-person
180
+ * status the chat bubble shows mid-call. Per-tool overrides go via
181
+ * `tool.<toolName>` keys (e.g., `'tool.weather': 'Looking up the
182
+ * weather…'`). See `defaultThinkingTemplates` for the full key list.
183
+ */
184
+ thinkingTemplates(templates: Readonly<Record<string, string>>): this;
185
+ /**
186
+ * Register any `Injection`. Use this for power-user / custom flavors;
187
+ * for built-in flavors use the typed sugar (`.skill`, `.steering`,
188
+ * `.instruction`, `.fact`).
189
+ */
190
+ injection(injection: Injection): this;
191
+ /**
192
+ * Register a Skill — LLM-activated, system-prompt + tools.
193
+ * Auto-attaches the `read_skill` activation tool to the agent.
194
+ * Skill stays active for the rest of the turn once activated.
195
+ */
196
+ skill(injection: Injection): this;
197
+ /**
198
+ * Bulk-register every Skill in a `SkillRegistry`. Use for shared
199
+ * skill catalogs across multiple Agents — register skills once on
200
+ * the registry; attach the same registry to every consumer Agent.
201
+ *
202
+ * @example
203
+ * const registry = new SkillRegistry();
204
+ * registry.register(billingSkill).register(refundSkill);
205
+ * const supportAgent = Agent.create({ provider }).skills(registry).build();
206
+ * const escalationAgent = Agent.create({ provider }).skills(registry).build();
207
+ */
208
+ skills(registry: {
209
+ list(): readonly Injection[];
210
+ }): this;
211
+ /**
212
+ * Register a Steering doc — always-on system-prompt rule.
213
+ * Use for invariant guidance: output format, persona, safety policies.
214
+ */
215
+ steering(injection: Injection): this;
216
+ /**
217
+ * Register an Instruction — rule-based system-prompt guidance.
218
+ * Predicate runs each iteration. Use for context-dependent rules
219
+ * including the "Dynamic ReAct" `on-tool-return` pattern.
220
+ */
221
+ instruction(injection: Injection): this;
222
+ /**
223
+ * Bulk-register many instructions at once. Convenience for consumer
224
+ * code that organizes its instruction set in a flat array (`const
225
+ * instructions = [outputFormat, dataRouting, ...]`). Each element
226
+ * is registered via `.instruction()` so duplicate-id checks still
227
+ * fire per-entry.
228
+ */
229
+ instructions(injections: ReadonlyArray<Injection>): this;
230
+ /**
231
+ * Register a Fact — developer-supplied data the LLM should see.
232
+ * User profile, env info, computed summary, current time, …
233
+ * Distinct from Skills (LLM-activated guidance) and Steering
234
+ * (always-on rules) in INTENT — the engine treats them all alike.
235
+ */
236
+ fact(injection: Injection): this;
237
+ /**
238
+ * Register a Memory subsystem — load/persist conversation context,
239
+ * facts, narrative beats, or causal snapshots across runs.
240
+ *
241
+ * The `MemoryDefinition` is produced by `defineMemory({ type, strategy,
242
+ * store })`. Multiple memories layer cleanly via per-id scope keys
243
+ * (`memoryInjection_${id}`):
244
+ *
245
+ * ```ts
246
+ * Agent.create({ provider })
247
+ * .memory(defineMemory({ id: 'short', type: MEMORY_TYPES.EPISODIC,
248
+ * strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 },
249
+ * store }))
250
+ * .memory(defineMemory({ id: 'facts', type: MEMORY_TYPES.SEMANTIC,
251
+ * strategy: { kind: MEMORY_STRATEGIES.EXTRACT,
252
+ * extractor: 'pattern' }, store }))
253
+ * .build();
254
+ * ```
255
+ *
256
+ * The READ subflow runs at the configured `timing` (default
257
+ * `MEMORY_TIMING.TURN_START`) and writes its formatted output to the
258
+ * `memoryInjection_${id}` scope key for the slot subflows to consume.
259
+ */
260
+ memory(definition: MemoryDefinition): this;
261
+ /**
262
+ * Register a RAG retriever — semantic search over a vector-indexed
263
+ * corpus. Identical plumbing to `.memory()` (RAG resolves to a
264
+ * `MemoryDefinition` produced by `defineRAG()`); this alias exists
265
+ * so the consumer's intent reads clearly:
266
+ *
267
+ * ```ts
268
+ * agent
269
+ * .memory(shortTermConversation) // remembers what the USER said
270
+ * .rag(productDocs) // retrieves what the CORPUS says
271
+ * .build();
272
+ * ```
273
+ *
274
+ * Both end up as memory subflows, but the alias separates "user
275
+ * conversation memory" from "document corpus retrieval" in code
276
+ * intent, ids, and Lens chips.
277
+ */
278
+ rag(definition: MemoryDefinition): this;
279
+ /**
280
+ * Declarative terminal contract. The agent's final answer must be
281
+ * JSON matching `parser`. Auto-injects a system-prompt instruction
282
+ * telling the LLM the shape, and exposes `agent.runTyped()` /
283
+ * `agent.parseOutput()` for parse + validate at the call site.
284
+ *
285
+ * The `parser` is duck-typed: any object with a `parse(unknown): T`
286
+ * method works (Zod, Valibot, ArkType, hand-written). The optional
287
+ * `description` field on the parser drives the auto-generated
288
+ * instruction; consumers can also override via `opts.instruction`.
289
+ *
290
+ * Throws if called more than once on the same builder (avoids
291
+ * silent override surprises).
292
+ *
293
+ * @param parser Validation strategy that throws on shape failure.
294
+ * @param opts Optional `{ name, instruction }` to customize.
295
+ *
296
+ * @example
297
+ * import { z } from 'zod';
298
+ * const Output = z.object({
299
+ * status: z.enum(['ok', 'err']),
300
+ * items: z.array(z.string()),
301
+ * }).describe('A status enum + an array of strings.');
302
+ *
303
+ * const agent = Agent.create({...})
304
+ * .outputSchema(Output)
305
+ * .build();
306
+ *
307
+ * const typed = await agent.runTyped({ message: '...' });
308
+ * typed.status; // narrowed to 'ok' | 'err'
309
+ */
310
+ outputSchema<T>(parser: OutputSchemaParser<T>, opts?: OutputSchemaOptions): this;
311
+ /**
312
+ * 3-tier degradation for output-schema validation failures. Pairs
313
+ * with `.outputSchema()` — calling `.outputFallback()` without an
314
+ * `outputSchema` first throws (the fallback has nothing to validate).
315
+ *
316
+ * Three tiers:
317
+ *
318
+ * 1. **Primary** — LLM emitted schema-valid JSON. Caller gets it.
319
+ * 2. **Fallback** — `OutputSchemaError` thrown. The async
320
+ * `fallback(error, raw)` runs; its return is re-validated.
321
+ * 3. **Canned** — static safety-net value. NEVER throws when set.
322
+ *
323
+ * `canned` is validated against the schema at builder time —
324
+ * fail-fast on misconfig (a `canned` that doesn't validate would
325
+ * defeat the fail-open guarantee).
326
+ *
327
+ * Two typed events fire on tier transitions for observability:
328
+ * - `agentfootprint.resilience.output_fallback_triggered`
329
+ * - `agentfootprint.resilience.output_canned_used`
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * import { z } from 'zod';
334
+ * const Refund = z.object({ amount: z.number(), reason: z.string() });
335
+ *
336
+ * const agent = Agent.create({...})
337
+ * .outputSchema(Refund)
338
+ * .outputFallback({
339
+ * fallback: async (err, raw) => ({ amount: 0, reason: 'manual review' }),
340
+ * canned: { amount: 0, reason: 'unable to process' },
341
+ * })
342
+ * .build();
343
+ * ```
344
+ */
345
+ outputFallback<T>(options: OutputFallbackOptions<T>): this;
346
+ build(): Agent;
347
+ }
348
+ //# sourceMappingURL=AgentBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/AgentBuilder.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * buildAgentChart — assemble the agent's full footprintjs FlowChart
3
+ * from stage functions + slot subflows + memory wiring.
4
+ *
5
+ * This is the "chart composition" that used to live inline in
6
+ * `Agent.buildChart()`. Extracted for v2.11.2 so:
7
+ *
8
+ * 1. Agent.ts focuses on Agent class lifecycle (constructor, run,
9
+ * attach, getSpec) instead of chart wiring details.
10
+ * 2. The reliability gate chart (v2.11.x) wires into ONE focused
11
+ * file rather than surgically into Agent.ts's 250-line composition
12
+ * block.
13
+ * 3. The composition is independently readable + reviewable —
14
+ * consumers building custom agent shapes have a reference.
15
+ *
16
+ * Chart shape:
17
+ *
18
+ * Seed
19
+ * → [memory READ subflows for each .memory()]
20
+ * → InjectionEngine (subflow)
21
+ * → SystemPrompt (slot subflow)
22
+ * → Messages (slot subflow)
23
+ * → Tools (slot subflow)
24
+ * → CacheDecision (subflow)
25
+ * → UpdateSkillHistory
26
+ * → CacheGate (decider) → ApplyMarkers / SkipCaching
27
+ * → IterationStart
28
+ * → CallLLM
29
+ * → Route (decider) → tool-calls (pausable) / final (subflow)
30
+ * |
31
+ * ┌────── PrepareFinal ▼
32
+ * ├──── [memory WRITE subflows]
33
+ * └──── BreakFinal ($break)
34
+ * loopTo(InjectionEngine)
35
+ *
36
+ * (When v2.11.x reliability is configured, the reliability gate chart
37
+ * mounts as a subflow between IterationStart and CallLLM with a
38
+ * TranslateFailFast stage after it. Lands in the next commit.)
39
+ */
40
+ import type { FlowChart } from 'footprintjs';
41
+ import type { CachePolicy } from '../../cache/types.js';
42
+ import type { MemoryDefinition } from '../../memory/define.types.js';
43
+ /**
44
+ * Stage handlers + slot subflows the chart composer needs. Mostly
45
+ * passed through verbatim from Agent.buildChart() — the chart shape
46
+ * is identical to what was inline before.
47
+ */
48
+ export interface AgentChartDeps {
49
+ /** Memory READ/WRITE pipeline definitions (one per `.memory()`). */
50
+ readonly memories: readonly MemoryDefinition[];
51
+ /** Cache policy for the system-prompt slot, threaded into
52
+ * CacheDecision's inputMapper so its decision rules can match. */
53
+ readonly systemPromptCachePolicy: CachePolicy;
54
+ /** Hard ReAct iteration cap, threaded into CacheDecision's
55
+ * inputMapper for max-iteration policies. */
56
+ readonly maxIterations: number;
57
+ readonly seed: (scope: never) => void;
58
+ readonly iterationStart: (scope: never) => void;
59
+ readonly callLLM: (scope: never) => Promise<void>;
60
+ readonly routeDecider: (scope: never) => 'tool-calls' | 'final';
61
+ readonly toolCallsHandler: import('footprintjs').PausableHandler<never>;
62
+ readonly injectionEngineSubflow: FlowChart;
63
+ readonly systemPromptSubflow: FlowChart;
64
+ readonly messagesSubflow: FlowChart;
65
+ readonly toolsSubflow: FlowChart;
66
+ readonly cacheDecisionSubflow: FlowChart;
67
+ readonly updateSkillHistoryStage: (scope: never) => void;
68
+ readonly cacheGateDecide: (scope: never) => unknown;
69
+ }
70
+ /**
71
+ * Build the agent's complete FlowChart from the supplied deps.
72
+ */
73
+ export declare function buildAgentChart(deps: AgentChartDeps): FlowChart;
74
+ //# sourceMappingURL=buildAgentChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAQrE;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAE/C;uEACmE;IACnE,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC;IAE9C;kDAC8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAG/B,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,YAAY,GAAG,OAAO,CAAC;IAChE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,aAAa,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAGxE,QAAQ,CAAC,sBAAsB,EAAE,SAAS,CAAC;IAC3C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IAGjC,QAAQ,CAAC,oBAAoB,EAAE,SAAS,CAAC;IACzC,QAAQ,CAAC,uBAAuB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;CACrD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CA+N/D"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * buildToolRegistry — pure function that composes the agent's
3
+ * augmented tool registry from three sources:
4
+ *
5
+ * 1. **Static registry** — tools registered via `.tool()`. Always
6
+ * visible to the LLM; always executable.
7
+ * 2. **`read_skill`** — auto-attached when ≥1 Skill is registered.
8
+ * Activation tool for LLM-guided Skills.
9
+ * 3. **Skill-supplied tools** (`Skill.inject.tools[]`) — visible
10
+ * only when the Skill is active (filtered by tools-slot subflow);
11
+ * MUST always be in the executor registry so when the LLM calls
12
+ * one, the tool-calls handler can dispatch.
13
+ *
14
+ * Tool-name uniqueness is enforced across all three sources at build
15
+ * time. The LLM only sees `tool.schema.name` (no ids), so names ARE
16
+ * the runtime dispatch key — collisions break the LLM's ability to
17
+ * call the right tool. Throw early instead of subtly shadowing.
18
+ *
19
+ * **Block C runtime — `autoActivate: 'currentSkill'` semantics:**
20
+ * When a skill's `defineSkill({ autoActivate: 'currentSkill' })` is
21
+ * set, its tools are EXCLUDED from the static registry. They flow
22
+ * into the LLM's tool list ONLY through `dynamicSchemas` (the
23
+ * buildToolsSlot path that reads activeInjections), which means
24
+ * they're visible ONLY on iterations after the skill is activated by
25
+ * `read_skill('id')`. Without this, the LLM sees every skill's tools
26
+ * on every iteration and the per-skill-narrowing autoActivate
27
+ * promised in `defineSkill` doesn't actually narrow anything. Skills
28
+ * WITHOUT autoActivate keep the v2.4 behavior (tools always visible)
29
+ * for back-compat.
30
+ *
31
+ * **autoActivate dispatch invariant:** autoActivate skill tools live
32
+ * OUTSIDE the LLM-visible registry (so they don't pollute the
33
+ * per-iteration tool list before the skill activates), but they MUST
34
+ * still be findable by the dispatch handler — the LLM calls them by
35
+ * name once the skill is active, and dispatch looks up by name. We
36
+ * add them to the dispatch map (`registryByName`) so `lookupTool`
37
+ * resolves correctly.
38
+ */
39
+ import type { Injection } from '../../lib/injection-engine/types.js';
40
+ import type { LLMToolSchema } from '../../adapters/types.js';
41
+ import type { Tool, ToolRegistryEntry } from '../tools.js';
42
+ export interface ToolRegistryArtifacts {
43
+ /** All tools the LLM sees in the static portion of its tool list
44
+ * (registry + read_skill + non-autoActivate skill tools). */
45
+ readonly augmentedRegistry: readonly ToolRegistryEntry[];
46
+ /** Dispatch map by name — used by the tool-calls handler at run
47
+ * time to resolve a tool the LLM called. INCLUDES autoActivate
48
+ * skill tools (which aren't in `augmentedRegistry`) so dispatch
49
+ * works once the skill is active. */
50
+ readonly registryByName: ReadonlyMap<string, Tool>;
51
+ /** Static tool schemas for the LLM call. Mirrors `augmentedRegistry`
52
+ * shape; passed to `buildToolsSlot` + the seed stage as the
53
+ * per-iteration default before the dynamic tools slot has run. */
54
+ readonly toolSchemas: readonly LLMToolSchema[];
55
+ }
56
+ /**
57
+ * Compose the augmented tool registry from the static `.tool()`
58
+ * registry + the agent's injections (skills only). Throws on tool-
59
+ * name collisions across sources.
60
+ */
61
+ export declare function buildToolRegistry(registry: readonly ToolRegistryEntry[], injections: readonly Injection[]): ToolRegistryArtifacts;
62
+ //# sourceMappingURL=buildToolRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildToolRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildToolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC;kEAC8D;IAC9D,QAAQ,CAAC,iBAAiB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACzD;;;0CAGsC;IACtC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnD;;uEAEmE;IACnE,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,qBAAqB,CA4EvB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * breakFinal — terminal stage of the agent's "Final" branch subflow.
3
+ *
4
+ * Fires after the (optional) memory-write subflows have persisted the
5
+ * (user, assistant) pair. `$break()` stops execution before the outer
6
+ * loopTo can re-enter the ReAct loop, ending the iteration cleanly.
7
+ * Returns `scope.finalContent` so the parent's `outputMapper` can
8
+ * surface it as the agent's response.
9
+ *
10
+ * Mounted in the final-branch subflow (built in `buildAgentChart`) as
11
+ * the LAST stage. The parent agent chart mounts the final-branch
12
+ * subflow under the Route decider's `'final'` branch with
13
+ * `propagateBreak: true`, so this $break terminates the outer ReAct
14
+ * loop too.
15
+ */
16
+ import type { TypedScope } from 'footprintjs';
17
+ import type { AgentState } from '../types.js';
18
+ /**
19
+ * Pure stage function — no dependencies, no closure over Agent state.
20
+ * Exported as a const, not a factory, since there's nothing to inject.
21
+ */
22
+ export declare const breakFinalStage: (scope: TypedScope<AgentState>) => string;
23
+ //# sourceMappingURL=breakFinal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakFinal.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/breakFinal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,eAAe,UAAW,WAAW,UAAU,CAAC,KAAG,MAG/D,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * callLLM — the LLM-invocation stage of the agent's chart.
3
+ *
4
+ * Reads the assembled prompt + messages from scope (populated by the
5
+ * upstream slot subflows: SystemPrompt, Messages, Tools, CacheDecision,
6
+ * CacheGate). Calls `provider.stream()` if available (token streaming
7
+ * with per-chunk events) else falls back to `provider.complete()`.
8
+ * Writes the response to scope (`llmLatestContent`, `llmLatestToolCalls`,
9
+ * cumulative tokens) for the downstream Route decider to read.
10
+ *
11
+ * Emits `agentfootprint.stream.llm_start` + `llm_end` brackets for
12
+ * observability adapters and per-chunk `stream.token` events during
13
+ * streaming. Emits `cost.tick` via `emitCostTick` when a `pricingTable`
14
+ * is configured.
15
+ *
16
+ * Factory signature so the chart-build-time provider/model/etc. deps
17
+ * are explicit. The `toolSchemas` value is late-bound via a getter
18
+ * because tool schema composition completes after the seed factory is
19
+ * built but before the chart actually runs.
20
+ */
21
+ import type { TypedScope } from 'footprintjs';
22
+ import type { LLMProvider, LLMToolSchema, PricingTable } from '../../../adapters/types.js';
23
+ import type { CacheStrategy } from '../../../cache/types.js';
24
+ import type { AgentState } from '../types.js';
25
+ export interface CallLLMStageDeps {
26
+ /** The LLM provider to invoke. */
27
+ readonly provider: LLMProvider;
28
+ /** Model identifier passed to provider.complete/stream. */
29
+ readonly model: string;
30
+ /** Optional sampling temperature. */
31
+ readonly temperature?: number;
32
+ /** Optional max output tokens. */
33
+ readonly maxTokens?: number;
34
+ /** Optional pricing adapter for cost tracking. */
35
+ readonly pricingTable?: PricingTable;
36
+ /** Optional cumulative USD cap per run. */
37
+ readonly costBudget?: number;
38
+ /** Hard ReAct iteration cap (used to compute iterationsRemaining for
39
+ * the cache strategy's prepareRequest hook). */
40
+ readonly maxIterations: number;
41
+ /** Cache strategy (provider-aware; v2.6+). Pass-through if no markers. */
42
+ readonly cacheStrategy: CacheStrategy;
43
+ /** Static tool schemas, late-bound (see seed.ts for the same
44
+ * pattern — toolSchemas is computed AFTER stage factories are
45
+ * built). The getter resolves the eventual value at run time. */
46
+ readonly toolSchemas: readonly LLMToolSchema[];
47
+ }
48
+ /**
49
+ * Build the callLLM stage function. Captures the LLM provider + model
50
+ * config + cache strategy via the deps object; everything per-iteration
51
+ * comes from scope.
52
+ */
53
+ export declare function buildCallLLMStage(deps: CallLLMStageDeps): (scope: TypedScope<AgentState>) => Promise<void>;
54
+ //# sourceMappingURL=callLLM.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callLLM.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EACb,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kCAAkC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;qDACiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC;;sEAEkE;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,GACrB,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAyGlD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * iterationStart — per-iteration marker stage.
3
+ *
4
+ * Emits `agentfootprint.agent.iteration_start` so observability adapters
5
+ * + recorders can bracket each ReAct iteration. Fires AFTER the slot
6
+ * subflows (SystemPrompt, Messages, Tools, CacheDecision, CacheGate)
7
+ * have produced this iteration's prompt assembly and BEFORE CallLLM.
8
+ *
9
+ * `turnIndex: 0` is intentional — the agent currently runs ONE turn per
10
+ * `agent.run()`. The turn index is reserved for future multi-turn
11
+ * orchestration; iteration index is the per-iteration counter.
12
+ */
13
+ import type { TypedScope } from 'footprintjs';
14
+ import type { AgentState } from '../types.js';
15
+ export declare const iterationStartStage: (scope: TypedScope<AgentState>) => void;
16
+ //# sourceMappingURL=iterationStart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterationStart.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/iterationStart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,mBAAmB,UAAW,WAAW,UAAU,CAAC,KAAG,IAKnE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * prepareFinal — first stage of the agent's "Final" branch subflow.
3
+ *
4
+ * Captures the turn payload (`finalContent` from the LLM's latest
5
+ * content; `newMessages` as the `[user, assistant]` pair the memory-
6
+ * write subflows persist) and emits the per-turn observability
7
+ * brackets (`iteration_end`, `turn_end`).
8
+ *
9
+ * Mounted as the FIRST stage of the final-branch subflow built in
10
+ * `buildAgentChart`. Subsequent memory-write subflows mount AFTER this
11
+ * stage so they have `newMessages` available; `breakFinal` is the
12
+ * terminal stage that stops the ReAct loop.
13
+ *
14
+ * Pure function — no closure over Agent class state. Imported and
15
+ * passed directly to `flowChart(...)` in buildAgentChart.
16
+ */
17
+ import type { TypedScope } from 'footprintjs';
18
+ import type { AgentState } from '../types.js';
19
+ export declare const prepareFinalStage: (scope: TypedScope<AgentState>) => void;
20
+ //# sourceMappingURL=prepareFinal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareFinal.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/prepareFinal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,iBAAiB,UAAW,WAAW,UAAU,CAAC,KAAG,IAuBjE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * route — decider that branches the ReAct loop into 'tool-calls' or 'final'.
3
+ *
4
+ * Runs after CallLLM. If the LLM returned tool calls AND we haven't hit
5
+ * `maxIterations`, route to the tool execution branch (which loops back
6
+ * to PromptBuilder). Otherwise route to the final-branch subflow which
7
+ * persists memory writes and breaks the loop.
8
+ *
9
+ * Emits `agentfootprint.agent.route_decided` with the chosen branch +
10
+ * a human-readable rationale (visible in narrative + observability).
11
+ *
12
+ * Pure function — no closure over Agent class state. Imported and
13
+ * passed directly to `addDeciderFunction(...)` in buildAgentChart.
14
+ */
15
+ import type { TypedScope } from 'footprintjs';
16
+ import type { AgentState } from '../types.js';
17
+ export type RouteBranch = 'tool-calls' | 'final';
18
+ export declare const routeDeciderStage: (scope: TypedScope<AgentState>) => RouteBranch;
19
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAW,WAAW,UAAU,CAAC,KAAG,WAmBjE,CAAC"}