agentfootprint 6.44.0 → 6.45.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/ai-instructions/setup.sh +0 -0
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/package.json +203 -56
|
@@ -0,0 +1,565 @@
|
|
|
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, InjectionContext } from '../../lib/injection-engine/types.js';
|
|
13
|
+
import type { EntryScoring } from '../../lib/injection-engine/skillGraph.js';
|
|
14
|
+
import type { MemoryDefinition } from '../../memory/define.types.js';
|
|
15
|
+
import type { ReliabilityConfig } from '../../reliability/types.js';
|
|
16
|
+
import type { ThinkingHandler } from '../../thinking/types.js';
|
|
17
|
+
import type { Tool } from '../tools.js';
|
|
18
|
+
import type { ToolProvider } from '../../tool-providers/types.js';
|
|
19
|
+
import { type SelfExplainOptions } from '../../lib/trace-toolpack/selfExplain.js';
|
|
20
|
+
import { Agent } from '../Agent.js';
|
|
21
|
+
import type { AgentOptions } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Fluent builder. `tool()` accepts any Tool<TArgs, TResult> and registers
|
|
24
|
+
* it by its schema.name. Duplicate names throw at build time.
|
|
25
|
+
*/
|
|
26
|
+
export declare class AgentBuilder {
|
|
27
|
+
private readonly opts;
|
|
28
|
+
private systemPromptValue;
|
|
29
|
+
/**
|
|
30
|
+
* Cache policy for the base system prompt. Set via the optional
|
|
31
|
+
* 2nd argument to `.system(text, { cache })`. Default `'always'` —
|
|
32
|
+
* the base prompt is stable per-turn and an ideal cache anchor.
|
|
33
|
+
*/
|
|
34
|
+
private systemPromptCachePolicy;
|
|
35
|
+
/**
|
|
36
|
+
* Global cache kill switch. Set via `Agent.create({ caching: 'off' })`
|
|
37
|
+
* (handled in `AgentOptions` propagation). Defaults to `false`
|
|
38
|
+
* (caching enabled). When `true`, the CacheGate decider routes to
|
|
39
|
+
* `'no-markers'` every iteration regardless of other rules.
|
|
40
|
+
*/
|
|
41
|
+
private cachingDisabledValue;
|
|
42
|
+
/**
|
|
43
|
+
* Optional explicit CacheStrategy override. Default: undefined,
|
|
44
|
+
* which means the agent auto-resolves from
|
|
45
|
+
* `getDefaultCacheStrategy(provider.name)` at construction. Power
|
|
46
|
+
* users override here for custom backends or test mocks.
|
|
47
|
+
*/
|
|
48
|
+
private cacheStrategyOverride?;
|
|
49
|
+
private readonly registry;
|
|
50
|
+
private readonly injectionList;
|
|
51
|
+
/** Captured from `.skillGraph(graph)` — the cursor resolver the Injection
|
|
52
|
+
* Engine uses to `from`-gate route triggers. Undefined unless a graph with
|
|
53
|
+
* route edges was mounted. */
|
|
54
|
+
private skillGraphNextSkill?;
|
|
55
|
+
/** Captured from `.skillGraph(graph)` — the reachable-set resolver the
|
|
56
|
+
* read_skill gate uses to reject out-of-set skill jumps. Undefined → the gate
|
|
57
|
+
* is off (plain read_skill agents are unaffected). */
|
|
58
|
+
private skillGraphReachable?;
|
|
59
|
+
/** Captured from `.skillGraph(graph)` — the relevance entry scorer
|
|
60
|
+
* (`graph.scoreEntries`), present only with `.entryByRelevance()`. When set, the
|
|
61
|
+
* PickEntry stage picks the starting skill by relevance once per turn. */
|
|
62
|
+
private skillGraphScoreEntries?;
|
|
63
|
+
private readonly memoryList;
|
|
64
|
+
/**
|
|
65
|
+
* Optional terminal contract — see `outputSchema()`. Stored on the
|
|
66
|
+
* builder, propagated to the Agent at `.build()` time.
|
|
67
|
+
*/
|
|
68
|
+
private outputSchemaParser?;
|
|
69
|
+
/** 3-tier output fallback chain — set via `.outputFallback({...})`.
|
|
70
|
+
* Optional; absent = current throw-on-validation-failure behavior. */
|
|
71
|
+
private outputFallbackCfg?;
|
|
72
|
+
/**
|
|
73
|
+
* Optional `ToolProvider` set via `.toolProvider()`. Propagated to
|
|
74
|
+
* the Agent's Tools slot subflow + tool-call dispatcher; consulted
|
|
75
|
+
* per iteration so dynamic chains (`gatedTools`, `skillScopedTools`)
|
|
76
|
+
* react to current activation state.
|
|
77
|
+
*/
|
|
78
|
+
private toolProviderRef?;
|
|
79
|
+
/**
|
|
80
|
+
* Optional override for `AgentOptions.maxIterations`. When set via
|
|
81
|
+
* the `.maxIterations()` builder method, takes precedence over the
|
|
82
|
+
* value passed to `Agent.create({ maxIterations })`.
|
|
83
|
+
*/
|
|
84
|
+
private maxIterationsOverride?;
|
|
85
|
+
/**
|
|
86
|
+
* Recorders collected via `.recorder()`. Attached to the built Agent
|
|
87
|
+
* before `build()` returns (each via `agent.attach(rec)`).
|
|
88
|
+
*/
|
|
89
|
+
private readonly recorderList;
|
|
90
|
+
private appNameValue;
|
|
91
|
+
private commentaryOverrides;
|
|
92
|
+
private thinkingOverrides;
|
|
93
|
+
/**
|
|
94
|
+
* Optional rules-based reliability config (v2.11.5+). Set via
|
|
95
|
+
* `.reliability({...})`. Wraps every `CallLLM` execution in a
|
|
96
|
+
* retry/fallback/fail-fast loop driven by `preCheck` and `postDecide`
|
|
97
|
+
* rules. See `ReliabilityConfig` for the rule shape.
|
|
98
|
+
*/
|
|
99
|
+
private reliabilityConfig?;
|
|
100
|
+
/**
|
|
101
|
+
* Optional ThinkingHandler (v2.14+). Three states:
|
|
102
|
+
* - undefined (default): auto-wire by `provider.name` via
|
|
103
|
+
* `findThinkingHandler` from the registry
|
|
104
|
+
* - explicit handler: override the auto-wire
|
|
105
|
+
* - explicit `null`: opt out (no thinking handler mounted at all,
|
|
106
|
+
* even if the provider would auto-match)
|
|
107
|
+
*
|
|
108
|
+
* The framework wraps the configured handler in a real footprintjs
|
|
109
|
+
* sub-subflow at chart build time (see `buildThinkingSubflow`).
|
|
110
|
+
* Mounted as a stage AFTER CallLLM inside `sf-call-llm`. Build-time
|
|
111
|
+
* conditional — no stage when no handler resolves.
|
|
112
|
+
*/
|
|
113
|
+
private thinkingHandlerValue?;
|
|
114
|
+
/**
|
|
115
|
+
* v2.14+ — request-side thinking activation. When set, every LLM
|
|
116
|
+
* call carries `LLMRequest.thinking = { budget }`, asking the
|
|
117
|
+
* provider (Anthropic) to emit reasoning blocks. Independent from
|
|
118
|
+
* `.thinkingHandler()` (response-side normalization choice).
|
|
119
|
+
*/
|
|
120
|
+
private thinkingBudgetValue?;
|
|
121
|
+
private selfExplainConfig?;
|
|
122
|
+
constructor(opts: AgentOptions);
|
|
123
|
+
/**
|
|
124
|
+
* Set the base system prompt.
|
|
125
|
+
*
|
|
126
|
+
* @param prompt - The system prompt text. Stable per-turn.
|
|
127
|
+
* @param options - Optional config. `cache` controls how the
|
|
128
|
+
* CacheDecision subflow treats this prompt block:
|
|
129
|
+
* - `'always'` (default) — cache the base prompt as a stable
|
|
130
|
+
* prefix anchor. Highest cache-hit rate; recommended for
|
|
131
|
+
* production agents whose system prompt rarely changes.
|
|
132
|
+
* - `'never'` — skip caching. Use if the prompt contains volatile
|
|
133
|
+
* content (timestamps, per-request user IDs).
|
|
134
|
+
* - `'while-active'` — semantically equivalent to `'always'` for
|
|
135
|
+
* the base prompt (it's always active by definition).
|
|
136
|
+
* - `{ until }` — conditional invalidation (e.g., flush after iter 5).
|
|
137
|
+
*/
|
|
138
|
+
system(prompt: string, options?: {
|
|
139
|
+
readonly cache?: CachePolicy;
|
|
140
|
+
}): this;
|
|
141
|
+
tool<TArgs, TResult>(tool: Tool<TArgs, TResult>): this;
|
|
142
|
+
/**
|
|
143
|
+
* Register many tools at once. Convenience for tool sources that
|
|
144
|
+
* return a list (e.g., `await mcpClient(...).tools()`). Each tool
|
|
145
|
+
* is registered via `.tool()` so duplicate-name validation still
|
|
146
|
+
* fires per-entry.
|
|
147
|
+
*/
|
|
148
|
+
tools(tools: ReadonlyArray<Tool>): this;
|
|
149
|
+
/**
|
|
150
|
+
* Wire a chainable `ToolProvider` (from `agentfootprint/tool-providers`)
|
|
151
|
+
* as the agent's per-iteration tool source.
|
|
152
|
+
*
|
|
153
|
+
* The provider is consulted EVERY iteration via `provider.list(ctx)`
|
|
154
|
+
* with `ctx = { iteration, activeSkillId, identity }`. Tools the
|
|
155
|
+
* provider emits flow into the Tools slot alongside any static
|
|
156
|
+
* tools registered via `.tool()` / `.tools()`. The tool-call
|
|
157
|
+
* dispatcher also consults the provider so dynamic chains
|
|
158
|
+
* (`gatedTools`, `skillScopedTools`) dispatch correctly when their
|
|
159
|
+
* visible-set changes mid-turn.
|
|
160
|
+
*
|
|
161
|
+
* Throws if called more than once on the same builder (avoids
|
|
162
|
+
* silent override surprises).
|
|
163
|
+
*
|
|
164
|
+
* @example Permission-gated baseline
|
|
165
|
+
* import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
|
|
166
|
+
* import { PermissionPolicy } from 'agentfootprint/security';
|
|
167
|
+
*
|
|
168
|
+
* const policy = PermissionPolicy.fromRoles({
|
|
169
|
+
* readonly: ['lookup', 'list_skills', 'read_skill'],
|
|
170
|
+
* admin: ['lookup', 'list_skills', 'read_skill', 'delete'],
|
|
171
|
+
* }, 'readonly');
|
|
172
|
+
*
|
|
173
|
+
* const provider = gatedTools(
|
|
174
|
+
* staticTools(allTools),
|
|
175
|
+
* (toolName) => policy.isAllowed(toolName),
|
|
176
|
+
* );
|
|
177
|
+
*
|
|
178
|
+
* const agent = Agent.create({ provider: llm, model })
|
|
179
|
+
* .system('You answer.')
|
|
180
|
+
* .toolProvider(provider)
|
|
181
|
+
* .build();
|
|
182
|
+
*/
|
|
183
|
+
toolProvider(provider: ToolProvider): this;
|
|
184
|
+
/**
|
|
185
|
+
* Override the ReAct iteration cap set via `Agent.create({
|
|
186
|
+
* maxIterations })`. Convenience for builder-style code that prefers
|
|
187
|
+
* fluent setters over constructor opts. Last call wins.
|
|
188
|
+
*
|
|
189
|
+
* Throws if `n` is not a positive integer or exceeds the hard cap
|
|
190
|
+
* (`clampIterations`'s upper bound).
|
|
191
|
+
*/
|
|
192
|
+
maxIterations(n: number): this;
|
|
193
|
+
/**
|
|
194
|
+
* Attach a footprintjs `CombinedRecorder` to the built Agent. Wired
|
|
195
|
+
* via `agent.attach(rec)` immediately after construction, so the
|
|
196
|
+
* recorder sees every event from the very first run.
|
|
197
|
+
*
|
|
198
|
+
* Equivalent to calling `agent.attach(rec)` post-build; the builder
|
|
199
|
+
* method is a convenience for codebases that prefer fully-fluent
|
|
200
|
+
* agent assembly. Multiple recorders are supported (each gets its
|
|
201
|
+
* own `attach()` call).
|
|
202
|
+
*/
|
|
203
|
+
recorder(rec: import('footprintjs').CombinedRecorder): this;
|
|
204
|
+
/**
|
|
205
|
+
* Set the agent's display name — substituted as `{{appName}}` in
|
|
206
|
+
* commentary + thinking templates. Same place to brand a tenant
|
|
207
|
+
* ("Acme Bot"), distinguish multi-agent roles ("Triage" vs
|
|
208
|
+
* "Reviewer"), or localize ("Asistente"). Default: `'Chatbot'`.
|
|
209
|
+
*/
|
|
210
|
+
appName(name: string): this;
|
|
211
|
+
/**
|
|
212
|
+
* Override agentfootprint's bundled commentary templates. Spread on
|
|
213
|
+
* top of `defaultCommentaryTemplates`; missing keys fall back. Same
|
|
214
|
+
* `Record<string, string>` shape with `{{vars}}` substitution as
|
|
215
|
+
* the bundled defaults — see `defaultCommentaryTemplates` for the
|
|
216
|
+
* full key list.
|
|
217
|
+
*
|
|
218
|
+
* Use cases: i18n (`'agent.turn_start': 'El usuario...'`), brand
|
|
219
|
+
* voice ("You: {{userPrompt}}"), per-tenant customization.
|
|
220
|
+
*/
|
|
221
|
+
commentaryTemplates(templates: Readonly<Record<string, string>>): this;
|
|
222
|
+
/**
|
|
223
|
+
* Override agentfootprint's bundled thinking templates. Same
|
|
224
|
+
* contract shape as commentary; different vocabulary — first-person
|
|
225
|
+
* status the chat bubble shows mid-call. Per-tool overrides go via
|
|
226
|
+
* `tool.<toolName>` keys (e.g., `'tool.weather': 'Looking up the
|
|
227
|
+
* weather…'`). See `defaultStatusTemplates` for the full key list.
|
|
228
|
+
*/
|
|
229
|
+
thinkingTemplates(templates: Readonly<Record<string, string>>): this;
|
|
230
|
+
/**
|
|
231
|
+
* Register any `Injection`. Use this for power-user / custom flavors;
|
|
232
|
+
* for built-in flavors use the typed sugar (`.skill`, `.steering`,
|
|
233
|
+
* `.instruction`, `.fact`).
|
|
234
|
+
*/
|
|
235
|
+
injection(injection: Injection): this;
|
|
236
|
+
/**
|
|
237
|
+
* Register a Skill — LLM-activated, system-prompt + tools.
|
|
238
|
+
* Auto-attaches the `read_skill` activation tool to the agent.
|
|
239
|
+
* Skill stays active for the rest of the turn once activated.
|
|
240
|
+
*/
|
|
241
|
+
skill(injection: Injection): this;
|
|
242
|
+
/**
|
|
243
|
+
* Bulk-register every Skill in a `SkillRegistry`. Use for shared
|
|
244
|
+
* skill catalogs across multiple Agents — register skills once on
|
|
245
|
+
* the registry; attach the same registry to every consumer Agent.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* const registry = new SkillRegistry();
|
|
249
|
+
* registry.register(billingSkill).register(refundSkill);
|
|
250
|
+
* const supportAgent = Agent.create({ provider }).skills(registry).build();
|
|
251
|
+
* const escalationAgent = Agent.create({ provider }).skills(registry).build();
|
|
252
|
+
*/
|
|
253
|
+
skills(registry: {
|
|
254
|
+
list(): readonly Injection[];
|
|
255
|
+
}): this;
|
|
256
|
+
/**
|
|
257
|
+
* Mount a declarative **skill graph** (proposal 002) — each skill carries a
|
|
258
|
+
* graph-derived trigger (entry → always/rule, deterministic route → rule /
|
|
259
|
+
* on-tool-return), so dynamic token-efficient loading becomes *declared* and
|
|
260
|
+
* *drawable*. Pure sugar over `.injection()` — `graph.toMermaid()` renders the
|
|
261
|
+
* topology.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* const graph = skillGraph()
|
|
265
|
+
* .entry(triage)
|
|
266
|
+
* .route(triage, sfp, { when: (r) => r.toolName === 'get_counters' && JSON.parse(r.result).crc > 0 })
|
|
267
|
+
* .build();
|
|
268
|
+
* Agent.create({ provider }).skillGraph(graph).build();
|
|
269
|
+
*/
|
|
270
|
+
skillGraph(graph: {
|
|
271
|
+
skills: readonly Injection[];
|
|
272
|
+
nextSkill: (ctx: InjectionContext) => string | undefined;
|
|
273
|
+
reachableSkills?: (currentSkillId?: string) => readonly string[];
|
|
274
|
+
scoreEntries?: (ctx: InjectionContext, signal?: AbortSignal) => Promise<EntryScoring>;
|
|
275
|
+
}): this;
|
|
276
|
+
/**
|
|
277
|
+
* Register a Steering doc — always-on system-prompt rule.
|
|
278
|
+
* Use for invariant guidance: output format, persona, safety policies.
|
|
279
|
+
*/
|
|
280
|
+
steering(injection: Injection): this;
|
|
281
|
+
/**
|
|
282
|
+
* Register an Instruction — rule-based system-prompt guidance.
|
|
283
|
+
* Predicate runs each iteration. Use for context-dependent rules
|
|
284
|
+
* including the "Dynamic ReAct" `on-tool-return` pattern.
|
|
285
|
+
*/
|
|
286
|
+
instruction(injection: Injection): this;
|
|
287
|
+
/**
|
|
288
|
+
* Bulk-register many instructions at once. Convenience for consumer
|
|
289
|
+
* code that organizes its instruction set in a flat array (`const
|
|
290
|
+
* instructions = [outputFormat, dataRouting, ...]`). Each element
|
|
291
|
+
* is registered via `.instruction()` so duplicate-id checks still
|
|
292
|
+
* fire per-entry.
|
|
293
|
+
*/
|
|
294
|
+
instructions(injections: ReadonlyArray<Injection>): this;
|
|
295
|
+
/**
|
|
296
|
+
* Register a Fact — developer-supplied data the LLM should see.
|
|
297
|
+
* User profile, env info, computed summary, current time, …
|
|
298
|
+
* Distinct from Skills (LLM-activated guidance) and Steering
|
|
299
|
+
* (always-on rules) in INTENT — the engine treats them all alike.
|
|
300
|
+
*/
|
|
301
|
+
fact(injection: Injection): this;
|
|
302
|
+
/**
|
|
303
|
+
* Register a Memory subsystem — load/persist conversation context,
|
|
304
|
+
* facts, narrative beats, or causal snapshots across runs.
|
|
305
|
+
*
|
|
306
|
+
* The `MemoryDefinition` is produced by `defineMemory({ type, strategy,
|
|
307
|
+
* store })`. Multiple memories layer cleanly via per-id scope keys
|
|
308
|
+
* (`memoryInjection_${id}`):
|
|
309
|
+
*
|
|
310
|
+
* ```ts
|
|
311
|
+
* Agent.create({ provider })
|
|
312
|
+
* .memory(defineMemory({ id: 'short', type: MEMORY_TYPES.EPISODIC,
|
|
313
|
+
* strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 },
|
|
314
|
+
* store }))
|
|
315
|
+
* .memory(defineMemory({ id: 'facts', type: MEMORY_TYPES.SEMANTIC,
|
|
316
|
+
* strategy: { kind: MEMORY_STRATEGIES.EXTRACT,
|
|
317
|
+
* extractor: 'pattern' }, store }))
|
|
318
|
+
* .build();
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* The READ subflow runs at the configured `timing` (default
|
|
322
|
+
* `MEMORY_TIMING.TURN_START`) and writes its formatted output to the
|
|
323
|
+
* `memoryInjection_${id}` scope key for the slot subflows to consume.
|
|
324
|
+
*/
|
|
325
|
+
memory(definition: MemoryDefinition): this;
|
|
326
|
+
/**
|
|
327
|
+
* Register a RAG retriever — semantic search over a vector-indexed
|
|
328
|
+
* corpus. Identical plumbing to `.memory()` (RAG resolves to a
|
|
329
|
+
* `MemoryDefinition` produced by `defineRAG()`); this alias exists
|
|
330
|
+
* so the consumer's intent reads clearly:
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* agent
|
|
334
|
+
* .memory(shortTermConversation) // remembers what the USER said
|
|
335
|
+
* .rag(productDocs) // retrieves what the CORPUS says
|
|
336
|
+
* .build();
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* Both end up as memory subflows, but the alias separates "user
|
|
340
|
+
* conversation memory" from "document corpus retrieval" in code
|
|
341
|
+
* intent, ids, and Lens chips.
|
|
342
|
+
*/
|
|
343
|
+
rag(definition: MemoryDefinition): this;
|
|
344
|
+
/**
|
|
345
|
+
* Declarative terminal contract. The agent's final answer must be
|
|
346
|
+
* JSON matching `parser`. Auto-injects a system-prompt instruction
|
|
347
|
+
* telling the LLM the shape, and exposes `agent.runTyped()` /
|
|
348
|
+
* `agent.parseOutput()` for parse + validate at the call site.
|
|
349
|
+
*
|
|
350
|
+
* The `parser` is duck-typed: any object with a `parse(unknown): T`
|
|
351
|
+
* method works (Zod, Valibot, ArkType, hand-written). The optional
|
|
352
|
+
* `description` field on the parser drives the auto-generated
|
|
353
|
+
* instruction; consumers can also override via `opts.instruction`.
|
|
354
|
+
*
|
|
355
|
+
* Throws if called more than once on the same builder (avoids
|
|
356
|
+
* silent override surprises).
|
|
357
|
+
*
|
|
358
|
+
* @param parser Validation strategy that throws on shape failure.
|
|
359
|
+
* @param opts Optional `{ name, instruction }` to customize.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* import { z } from 'zod';
|
|
363
|
+
* const Output = z.object({
|
|
364
|
+
* status: z.enum(['ok', 'err']),
|
|
365
|
+
* items: z.array(z.string()),
|
|
366
|
+
* }).describe('A status enum + an array of strings.');
|
|
367
|
+
*
|
|
368
|
+
* const agent = Agent.create({...})
|
|
369
|
+
* .outputSchema(Output)
|
|
370
|
+
* .build();
|
|
371
|
+
*
|
|
372
|
+
* const typed = await agent.runTyped({ message: '...' });
|
|
373
|
+
* typed.status; // narrowed to 'ok' | 'err'
|
|
374
|
+
*/
|
|
375
|
+
outputSchema<T>(parser: OutputSchemaParser<T>, opts?: OutputSchemaOptions): this;
|
|
376
|
+
/**
|
|
377
|
+
* 3-tier degradation for output-schema validation failures. Pairs
|
|
378
|
+
* with `.outputSchema()` — calling `.outputFallback()` without an
|
|
379
|
+
* `outputSchema` first throws (the fallback has nothing to validate).
|
|
380
|
+
*
|
|
381
|
+
* Three tiers:
|
|
382
|
+
*
|
|
383
|
+
* 1. **Primary** — LLM emitted schema-valid JSON. Caller gets it.
|
|
384
|
+
* 2. **Fallback** — `OutputSchemaError` thrown. The async
|
|
385
|
+
* `fallback(error, raw)` runs; its return is re-validated.
|
|
386
|
+
* 3. **Canned** — static safety-net value. NEVER throws when set.
|
|
387
|
+
*
|
|
388
|
+
* `canned` is validated against the schema at builder time —
|
|
389
|
+
* fail-fast on misconfig (a `canned` that doesn't validate would
|
|
390
|
+
* defeat the fail-open guarantee).
|
|
391
|
+
*
|
|
392
|
+
* Two typed events fire on tier transitions for observability:
|
|
393
|
+
* - `agentfootprint.resilience.output_fallback_triggered`
|
|
394
|
+
* - `agentfootprint.resilience.output_canned_used`
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* import { z } from 'zod';
|
|
399
|
+
* const Refund = z.object({ amount: z.number(), reason: z.string() });
|
|
400
|
+
*
|
|
401
|
+
* const agent = Agent.create({...})
|
|
402
|
+
* .outputSchema(Refund)
|
|
403
|
+
* .outputFallback({
|
|
404
|
+
* fallback: async (err, raw) => ({ amount: 0, reason: 'manual review' }),
|
|
405
|
+
* canned: { amount: 0, reason: 'unable to process' },
|
|
406
|
+
* })
|
|
407
|
+
* .build();
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
outputFallback<T>(options: OutputFallbackOptions<T>): this;
|
|
411
|
+
/**
|
|
412
|
+
* Wire rules-based reliability around every `CallLLM` execution.
|
|
413
|
+
* The framework wraps the LLM call in a retry/fallback/fail-fast
|
|
414
|
+
* loop driven by `preCheck` and `postDecide` rules.
|
|
415
|
+
*
|
|
416
|
+
* Decision verbs the rules can emit (see `ReliabilityDecision` for
|
|
417
|
+
* the full list):
|
|
418
|
+
*
|
|
419
|
+
* • `continue` — pre-check OK, proceed to the call
|
|
420
|
+
* • `ok` — post-call OK, commit and return
|
|
421
|
+
* • `retry` — re-call same provider (bumps `attempt`)
|
|
422
|
+
* • `retry-other` — advance to next provider in `providers[]`
|
|
423
|
+
* • `fallback` — invoke `config.fallback(req, lastError)`
|
|
424
|
+
* • `fail-fast` — throw `ReliabilityFailFastError` at `agent.run()`
|
|
425
|
+
*
|
|
426
|
+
* **Streaming + reliability semantics — first-chunk arbitration:**
|
|
427
|
+
* Pre-first-chunk failures (connection/headers/breaker-open) honor
|
|
428
|
+
* the full rule set (retry, retry-other, fallback, fail-fast).
|
|
429
|
+
* Post-first-chunk failures (mid-stream) honor only `ok` and
|
|
430
|
+
* `fail-fast`; rules wanting `retry`/`retry-other`/`fallback` are
|
|
431
|
+
* escalated to fail-fast with kind `'mid-stream-not-retryable'`.
|
|
432
|
+
* This matches LangChain's `RunnableWithFallbacks` pattern and
|
|
433
|
+
* the prevailing industry default — see the streaming + reliability
|
|
434
|
+
* design memo for the full discussion.
|
|
435
|
+
*
|
|
436
|
+
* Throws if called more than once on the same builder.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* import { Agent } from 'agentfootprint';
|
|
440
|
+
* import { ReliabilityFailFastError } from 'agentfootprint/reliability';
|
|
441
|
+
*
|
|
442
|
+
* const agent = Agent.create({ provider, model: 'mock' })
|
|
443
|
+
* .system('Triage support tickets.')
|
|
444
|
+
* .reliability({
|
|
445
|
+
* postDecide: [
|
|
446
|
+
* { when: (s) => s.errorKind === '5xx-transient' && s.attempt < 3,
|
|
447
|
+
* then: 'retry', kind: 'transient-retry' },
|
|
448
|
+
* { when: (s) => s.error !== undefined,
|
|
449
|
+
* then: 'fail-fast', kind: 'unrecoverable' },
|
|
450
|
+
* ],
|
|
451
|
+
* circuitBreaker: { failureThreshold: 3 },
|
|
452
|
+
* })
|
|
453
|
+
* .build();
|
|
454
|
+
*
|
|
455
|
+
* try {
|
|
456
|
+
* await agent.run({ message: 'help' });
|
|
457
|
+
* } catch (e) {
|
|
458
|
+
* if (e instanceof ReliabilityFailFastError) {
|
|
459
|
+
* console.log(e.kind, e.reason);
|
|
460
|
+
* }
|
|
461
|
+
* }
|
|
462
|
+
*/
|
|
463
|
+
reliability(config: ReliabilityConfig): this;
|
|
464
|
+
/**
|
|
465
|
+
* Wire a thinking handler (v2.14+). Three usage patterns:
|
|
466
|
+
*
|
|
467
|
+
* • OMITTED (default) — framework auto-wires by `provider.name` via
|
|
468
|
+
* `findThinkingHandler` from the registry. Most consumers using
|
|
469
|
+
* a shipped provider get thinking support for free.
|
|
470
|
+
*
|
|
471
|
+
* • EXPLICIT handler — override the auto-wire. For custom providers
|
|
472
|
+
* or for swapping in a custom Anthropic/OpenAI handler with
|
|
473
|
+
* different normalization (e.g. redacting blocks before they
|
|
474
|
+
* land).
|
|
475
|
+
*
|
|
476
|
+
* • EXPLICIT `null` — opt out entirely. The thinking subflow is NOT
|
|
477
|
+
* mounted even if the provider would auto-match. Use when you
|
|
478
|
+
* want to skip thinking parsing for this agent (cost / latency /
|
|
479
|
+
* UX reasons).
|
|
480
|
+
*
|
|
481
|
+
* Calling twice throws — same shape as `.reliability()` /
|
|
482
|
+
* `.outputSchema()` to enforce single-source intent.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* // Default — auto-wire AnthropicThinkingHandler for anthropic provider
|
|
486
|
+
* Agent.create({ provider: anthropic({...}), model: '...' }).build();
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // Custom handler that redacts thinking content
|
|
490
|
+
* Agent.create({...}).thinkingHandler(myRedactingHandler).build();
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* // Opt out of thinking parsing entirely
|
|
494
|
+
* Agent.create({ provider: anthropic({...}), model: '...' })
|
|
495
|
+
* .thinkingHandler(null)
|
|
496
|
+
* .build();
|
|
497
|
+
*/
|
|
498
|
+
thinkingHandler(handler: ThinkingHandler | null): this;
|
|
499
|
+
/**
|
|
500
|
+
* v2.14+ — REQUEST-side thinking activation. Tells the provider to
|
|
501
|
+
* emit reasoning blocks alongside its response.
|
|
502
|
+
*
|
|
503
|
+
* **What this does:** every LLM call carries
|
|
504
|
+
* `LLMRequest.thinking = { budget }`. The AnthropicProvider
|
|
505
|
+
* translates to `thinking: { type: 'enabled', budget_tokens: N }`
|
|
506
|
+
* on the wire. The model spends up to `budget` reasoning tokens
|
|
507
|
+
* before producing the visible response.
|
|
508
|
+
*
|
|
509
|
+
* **Distinct from `.thinkingHandler()`:**
|
|
510
|
+
* - `.thinking({ budget })` = ASK the model to think (request side)
|
|
511
|
+
* - `.thinkingHandler(h)` = NORMALIZE the response (response side)
|
|
512
|
+
*
|
|
513
|
+
* Most consumers want both; auto-wired handler covers the response
|
|
514
|
+
* side automatically when `.thinking()` is set on a thinking-capable
|
|
515
|
+
* provider. Setting `.thinking()` without `.thinkingHandler(null)`
|
|
516
|
+
* is the typical happy path.
|
|
517
|
+
*
|
|
518
|
+
* **Provider compatibility:**
|
|
519
|
+
* - Anthropic: requires claude-sonnet-4-5 / opus-4-5 (or newer).
|
|
520
|
+
* Older models reject with HTTP 400.
|
|
521
|
+
* - OpenAI: ignores. o1/o3 reasoning is selected at the model id
|
|
522
|
+
* level; this field is a no-op for OpenAIProvider.
|
|
523
|
+
*
|
|
524
|
+
* **Budget guidance:** Anthropic recommends 1024-32000 reasoning
|
|
525
|
+
* tokens. `budget` MUST be less than the request's `max_tokens`
|
|
526
|
+
* (defaults to 4096 in AnthropicProvider — bump via the request
|
|
527
|
+
* `maxTokens` if budget > ~3000).
|
|
528
|
+
*
|
|
529
|
+
* Calling twice throws — same shape as `.reliability()` /
|
|
530
|
+
* `.outputSchema()`.
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* Agent.create({ provider: anthropic({...}), model: 'claude-sonnet-4-5' })
|
|
534
|
+
* .system('You are a careful reasoning agent.')
|
|
535
|
+
* .thinking({ budget: 5000 }) // ask Anthropic to think
|
|
536
|
+
* .build();
|
|
537
|
+
*/
|
|
538
|
+
thinking(opts: {
|
|
539
|
+
budget: number;
|
|
540
|
+
}): this;
|
|
541
|
+
/**
|
|
542
|
+
* Let this agent answer why-questions about its OWN previous completed
|
|
543
|
+
* turn, from its recorded trace. Mounts one skill: day to day the tool
|
|
544
|
+
* catalog carries only the skill's activation row; when the user asks
|
|
545
|
+
* "why did you…", the LLM activates it and that iteration alone gets
|
|
546
|
+
* the trace tools (inline mode) or a single `explain_run` tool that
|
|
547
|
+
* runs a nested trace debugger on a cheaper model (delegate mode).
|
|
548
|
+
*
|
|
549
|
+
* Evidence binds LATE — always to the previous COMPLETED run, never
|
|
550
|
+
* the in-flight one — and includes control edges (a per-run
|
|
551
|
+
* control-dependence recorder is attached automatically).
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* Agent.create({ provider, model })
|
|
555
|
+
* .system('You are a refunds assistant.')
|
|
556
|
+
* .tool(lookupOrder)
|
|
557
|
+
* .selfExplain() // inline, zero config
|
|
558
|
+
* .build();
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* .selfExplain({ delegate: { provider: anthropic(), model: 'claude-haiku-4-5' } })
|
|
562
|
+
*/
|
|
563
|
+
selfExplain(opts?: SelfExplainOptions): this;
|
|
564
|
+
build(): Agent;
|
|
565
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
* Initialize
|
|
19
|
+
* → [memory READ subflows for each .memory()]
|
|
20
|
+
* → InjectionEngine (subflow) ← loop target (tool-calls loops here)
|
|
21
|
+
* → Context (selector, PARALLEL fan-out, failFast)
|
|
22
|
+
* ⇉ {System Prompt ‖ Messages ‖ Tools} (slot subflows)
|
|
23
|
+
* → converge
|
|
24
|
+
* → UpdateSkillHistory
|
|
25
|
+
* → Cache (sf-cache subflow: decideCacheMarkers → CacheGate
|
|
26
|
+
* → ApplyMarkers / SkipCaching)
|
|
27
|
+
* → CallLLM (also emits the per-iteration iteration_start marker)
|
|
28
|
+
* → [NormalizeThinking] (subflow, only when a ThinkingHandler resolved)
|
|
29
|
+
* → Route (decider)
|
|
30
|
+
* ├─ tool-calls (pausable) → loopTo(InjectionEngine) ← branch-sourced loop
|
|
31
|
+
* └─ final (subflow) → terminal leaf
|
|
32
|
+
* ┌────── PrepareFinal
|
|
33
|
+
* ├──── [memory WRITE subflows]
|
|
34
|
+
* └──── BreakFinal ($break)
|
|
35
|
+
*
|
|
36
|
+
* (When v2.11.x reliability is configured, the reliability gate chart
|
|
37
|
+
* mounts as a subflow before CallLLM with a TranslateFailFast stage
|
|
38
|
+
* after it. Lands in the next commit.)
|
|
39
|
+
*/
|
|
40
|
+
import type { FlowChart, StructureRecorder } 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
|
+
/** Evidence bridge (#5): `causalEvidenceRecorder().collect`, threaded into
|
|
52
|
+
* CAUSAL memories' write mounts so snapshots persist real evidence
|
|
53
|
+
* (decisions/toolCalls/iterations/duration/tokens) instead of zeros.
|
|
54
|
+
* Set by the Agent when any mounted memory is CAUSAL. */
|
|
55
|
+
readonly causalEvidenceSource?: () => import('../../memory/causal/evidenceRecorder.js').RunEvidence;
|
|
56
|
+
/** Cache policy for the system-prompt slot, threaded into
|
|
57
|
+
* CacheDecision's inputMapper so its decision rules can match. */
|
|
58
|
+
readonly systemPromptCachePolicy: CachePolicy;
|
|
59
|
+
/** Hard ReAct iteration cap, threaded into CacheDecision's
|
|
60
|
+
* inputMapper for max-iteration policies. */
|
|
61
|
+
readonly maxIterations: number;
|
|
62
|
+
readonly seed: (scope: never) => void;
|
|
63
|
+
readonly callLLM: (scope: never) => Promise<void>;
|
|
64
|
+
readonly routeDecider: (scope: never) => 'tool-calls' | 'final';
|
|
65
|
+
readonly toolCallsHandler: import('footprintjs').PausableHandler<never>;
|
|
66
|
+
readonly injectionEngineSubflow: FlowChart;
|
|
67
|
+
/** Relevance entry router (`entryByRelevance`) — a once-per-turn function stage
|
|
68
|
+
* mounted before the InjectionEngine (off the ReAct loop). Present only when the
|
|
69
|
+
* skill graph was built with a relevance scorer. */
|
|
70
|
+
readonly pickEntryStage?: (scope: never) => Promise<void>;
|
|
71
|
+
readonly systemPromptSubflow: FlowChart;
|
|
72
|
+
readonly messagesSubflow: FlowChart;
|
|
73
|
+
readonly toolsSubflow: FlowChart;
|
|
74
|
+
/**
|
|
75
|
+
* Optional thinking-normalization sub-subflow (v2.14+). Mounted as a
|
|
76
|
+
* stage AFTER CallLLM, BEFORE Route, only when a `ThinkingHandler`
|
|
77
|
+
* resolved (either auto-wired by `provider.name` or explicitly set
|
|
78
|
+
* via `.thinkingHandler()`). When undefined, the stage is NOT added —
|
|
79
|
+
* zero overhead for non-thinking agents (build-time conditional mount).
|
|
80
|
+
*/
|
|
81
|
+
readonly thinkingSubflow?: FlowChart;
|
|
82
|
+
readonly updateSkillHistoryStage: (scope: never) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Whether ≥1 Skill is registered. The `UpdateSkillHistory` stage (and
|
|
85
|
+
* therefore the cache's skill-churn rule) is mounted ONLY when true:
|
|
86
|
+
* with no skills the window would record "no skill" every iteration and
|
|
87
|
+
* `detectSkillChurn` could never fire, so the stage would be pure dead
|
|
88
|
+
* weight + a misleading box. Mirrors the `skills.length > 0` gate that
|
|
89
|
+
* auto-attaches `read_skill`, and the `thinkingSubflow` conditional mount.
|
|
90
|
+
*/
|
|
91
|
+
readonly hasSkills: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* ReAct loop semantics. `'dynamic'` (default) re-runs the InjectionEngine +
|
|
94
|
+
* all 3 slots every iteration (loop → InjectionEngine). `'classic'`
|
|
95
|
+
* engineers context ONCE (InjectionEngine + system-prompt + tools up front)
|
|
96
|
+
* and loops only the Messages slot (loop → Messages). See AgentOptions.reactMode.
|
|
97
|
+
*/
|
|
98
|
+
readonly reactMode?: 'classic' | 'dynamic';
|
|
99
|
+
/** Structure recorders threaded into both `flowChart()` calls (the
|
|
100
|
+
* main chart and the PrepareFinal sub-chart). Each recorder
|
|
101
|
+
* observes per-node build events (`onStageAdded` /
|
|
102
|
+
* `onSubflowMounted` / etc.) for the Agent's chart. Undefined when
|
|
103
|
+
* the consumer didn't attach any. */
|
|
104
|
+
readonly structureRecorders?: readonly StructureRecorder[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build the agent's complete FlowChart from the supplied deps.
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildAgentChart(deps: AgentChartDeps): FlowChart;
|
|
@@ -148,8 +148,9 @@ export function buildAgentChart(deps) {
|
|
|
148
148
|
// Skill-graph cursor as of the previous iteration — the `from`-gate the
|
|
149
149
|
// route triggers compare against. Undefined on cold start / no graph.
|
|
150
150
|
currentSkillId: parent.currentSkillId,
|
|
151
|
-
// Relevance entry ranking (
|
|
151
|
+
// Relevance entry ranking (from an entry scorer) — read by defineRelevanceHint.
|
|
152
152
|
entryScores: parent.entryScores,
|
|
153
|
+
entryScorer: parent.entryScorer,
|
|
153
154
|
}),
|
|
154
155
|
// Carry activeByslot back to parent so next turn's inputMapper can
|
|
155
156
|
// feed it as priorActiveByslot (the Delta round-trip). currentSkillId is
|