agentfootprint 6.43.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/RunnerBase.js +7 -0
- package/dist/core/RunnerBase.js.map +1 -1
- 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/RunnerBase.js +7 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- 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/observe.js +7 -1
- package/dist/esm/observe.js.map +1 -1
- 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/FlowchartRecorder.js +10 -2
- package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
- 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/localObservability.js +54 -0
- package/dist/esm/recorders/observability/localObservability.js.map +1 -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/recorders/observability/trace.js +99 -0
- package/dist/esm/recorders/observability/trace.js.map +1 -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/observe.js +14 -3
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/FlowchartRecorder.js +12 -3
- package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/recorders/observability/localObservability.js +58 -0
- package/dist/recorders/observability/localObservability.js.map +1 -0
- package/dist/recorders/observability/trace.js +105 -0
- package/dist/recorders/observability/trace.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +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/core/runner.d.ts +12 -0
- package/dist/types/core/runner.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/dist/types/observe.d.ts +3 -1
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/localObservability.d.ts +49 -0
- package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
- package/dist/types/recorders/observability/trace.d.ts +120 -0
- package/dist/types/recorders/observability/trace.d.ts.map +1 -0
- package/package.json +203 -56
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent type definitions — both PUBLIC types (AgentOptions, AgentInput,
|
|
3
|
+
* AgentOutput) consumed by `Agent.create({...}).run({...})` callers AND
|
|
4
|
+
* the INTERNAL `AgentState` shape used by stage functions.
|
|
5
|
+
*
|
|
6
|
+
* These were originally inline in `core/Agent.ts`; extracted here as
|
|
7
|
+
* part of the v2.11.1 decomposition. `core/Agent.ts` re-exports them
|
|
8
|
+
* for back-compat (the 28+ existing import sites continue to work).
|
|
9
|
+
*/
|
|
10
|
+
import type { AttachRecorderOptions, ReadTrackingMode, StructureRecorder, CommitValuesMode } from 'footprintjs';
|
|
11
|
+
import type { GroupTranslator } from '../translator.js';
|
|
12
|
+
import type { LLMMessage, LLMProvider, LLMToolSchema, PermissionChecker, PricingTable } from '../../adapters/types.js';
|
|
13
|
+
import type { CacheMarker, CacheStrategy } from '../../cache/types.js';
|
|
14
|
+
import type { ActiveInjection } from '../../lib/injection-engine/types.js';
|
|
15
|
+
import type { InjectionRecord } from '../../recorders/core/types.js';
|
|
16
|
+
import type { MemoryIdentity } from '../../memory/identity/types.js';
|
|
17
|
+
import type { CredentialProvider } from '../../identity/types.js';
|
|
18
|
+
import type { ToolArgValidationMode } from './toolArgsValidation.js';
|
|
19
|
+
import type { ThinkingBlock } from '../../thinking/types.js';
|
|
20
|
+
import type { ReliabilityScope } from '../../reliability/types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Dials for the deferred observer queue (RFC-001) — only meaningful with
|
|
23
|
+
* `observerDelivery: 'deferred'` (passing them without it throws at
|
|
24
|
+
* construction). Same vocabulary as footprintjs's `AttachRecorderOptions`
|
|
25
|
+
* minus `delivery` (the Agent option IS the delivery switch):
|
|
26
|
+
* `capture` (default `'clone'` — hooks receive the same event shape as
|
|
27
|
+
* inline), `maxQueue` (default 10 000), `overflow` (default
|
|
28
|
+
* `'drop-oldest'`), `sampleEvery`, `flushBudgetMs` (default 2).
|
|
29
|
+
*/
|
|
30
|
+
export type ObserverDeliveryOptions = Omit<AttachRecorderOptions, 'delivery'>;
|
|
31
|
+
export interface AgentOptions {
|
|
32
|
+
readonly provider: LLMProvider;
|
|
33
|
+
/** Human-friendly name shown in events/metrics. Default: 'Agent'. */
|
|
34
|
+
readonly name?: string;
|
|
35
|
+
/** Stable id used for topology + events. Default: 'agent'. */
|
|
36
|
+
readonly id?: string;
|
|
37
|
+
readonly model: string;
|
|
38
|
+
readonly temperature?: number;
|
|
39
|
+
readonly maxTokens?: number;
|
|
40
|
+
/** Hard budget on ReAct iterations. Default: 10. Hard cap: 50. */
|
|
41
|
+
readonly maxIterations?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Pricing adapter. When set, Agent emits `agentfootprint.cost.tick`
|
|
44
|
+
* after every LLM response (once per ReAct iteration) with per-call
|
|
45
|
+
* and cumulative USD. Run-scoped — the cumulative resets each `.run()`.
|
|
46
|
+
*/
|
|
47
|
+
readonly pricingTable?: PricingTable;
|
|
48
|
+
/**
|
|
49
|
+
* Cumulative USD budget per run. With `pricingTable`, Agent emits a
|
|
50
|
+
* one-shot `agentfootprint.cost.limit_hit` (`action: 'warn'`) when
|
|
51
|
+
* cumulative USD crosses this budget. Execution continues — consumers
|
|
52
|
+
* choose whether to abort by listening to the event.
|
|
53
|
+
*/
|
|
54
|
+
readonly costBudget?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Permission adapter. When set, the Agent calls
|
|
57
|
+
* `permissionChecker.check({capability: 'tool_call', ...})` BEFORE every
|
|
58
|
+
* `tool.execute()`. Emits `agentfootprint.permission.check` with the
|
|
59
|
+
* decision. On `deny`, the tool is skipped and its result is a
|
|
60
|
+
* synthetic denial string; on `allow` / `gate_open`, execution proceeds
|
|
61
|
+
* normally.
|
|
62
|
+
*/
|
|
63
|
+
readonly permissionChecker?: PermissionChecker;
|
|
64
|
+
/**
|
|
65
|
+
* Tool-args validation mode (#9). Default `'enforce'`: LLM-produced args
|
|
66
|
+
* are validated against the tool's declared `inputSchema` BEFORE dispatch.
|
|
67
|
+
* On mismatch the tool is NOT executed — the model receives a structured
|
|
68
|
+
* retry message as the tool result (paths + expected shapes + received
|
|
69
|
+
* TYPES, never the supplied values) and corrects itself on the next
|
|
70
|
+
* iteration. Emits `agentfootprint.validation.args_invalid`.
|
|
71
|
+
* `'warn'` emits the event but executes anyway; `'off'` disables.
|
|
72
|
+
* Validation is an honest JSON-Schema subset (type/required/properties/
|
|
73
|
+
* items/enum/explicit additionalProperties:false) — unsupported keywords
|
|
74
|
+
* are ignored, never false-rejecting.
|
|
75
|
+
*/
|
|
76
|
+
readonly toolArgValidation?: ToolArgValidationMode;
|
|
77
|
+
/**
|
|
78
|
+
* Read-tracking policy for the snapshot's per-stage read view
|
|
79
|
+
* (footprintjs `StageSnapshot.stageReads`) — the observability-cost
|
|
80
|
+
* lever for LONG runs. Forwarded to the Agent's internal
|
|
81
|
+
* `FlowChartExecutor` as `{ readTracking }`.
|
|
82
|
+
*
|
|
83
|
+
* - `'summary'` (Agent default) — each tracked read records a cheap
|
|
84
|
+
* `ReadSummaryMarker` (type + size proxy + short preview) instead of
|
|
85
|
+
* a `structuredClone` of the value. Measured at N=200 full-feature
|
|
86
|
+
* iterations, `'full'` clones ~18MB of read values that nothing in
|
|
87
|
+
* the agentfootprint/lens/explainable-ui stack consumes.
|
|
88
|
+
* - `'full'` — footprintjs's own default: every tracked read clones the
|
|
89
|
+
* value into `stageReads`. Set explicitly if you inspect
|
|
90
|
+
* `agent.getSnapshot()` read VALUES (not just keys/shapes).
|
|
91
|
+
* - `'off'` — reads are not recorded; `stageReads` is absent.
|
|
92
|
+
*
|
|
93
|
+
* Narrative, recorder events (`onRead` payloads), and commit history are
|
|
94
|
+
* IDENTICAL in every mode — the policy scopes ONLY the snapshot's
|
|
95
|
+
* `stageReads` payload. Note the Agent default (`'summary'`) is
|
|
96
|
+
* deliberately cheaper than footprintjs's (`'full'`); see CHANGELOG
|
|
97
|
+
* behavior-change callout.
|
|
98
|
+
*/
|
|
99
|
+
readonly readTracking?: ReadTrackingMode;
|
|
100
|
+
/**
|
|
101
|
+
* Commit-log value encoding (#13c-B) — forwarded to the internal
|
|
102
|
+
* executor as `{ commitValues }`. Agent default is **`'delta'`**: a
|
|
103
|
+
* stage whose net change to a tracked array is "the old array plus a
|
|
104
|
+
* tail" (the agent's `history` every iteration) records ONLY the tail
|
|
105
|
+
* (`append` verb); key removals record a `delete` verb. LOSSLESS — any
|
|
106
|
+
* step's full value reconstructs by replay (`commitValueAt` from
|
|
107
|
+
* `footprintjs/trace`), which is why this is safe for audit trails.
|
|
108
|
+
* Retained commit-log memory becomes linear instead of quadratic.
|
|
109
|
+
* Set `'full'` for footprintjs's default encoding (every changed key
|
|
110
|
+
* stores its full final value) if a downstream consumer reads
|
|
111
|
+
* `bundle.overwrite[key]` as the complete value.
|
|
112
|
+
*/
|
|
113
|
+
readonly commitValues?: CommitValuesMode;
|
|
114
|
+
/**
|
|
115
|
+
* Credential provider for downstream OAuth (declare-and-push). When set, a
|
|
116
|
+
* tool that declares `needs: { credential }` has it resolved BEFORE `execute`
|
|
117
|
+
* and injected as `ctx.credential`; tools can also pull via `ctx.credentials`.
|
|
118
|
+
* From `agentfootprint/identity` (`agentCoreIdentity({ region })`,
|
|
119
|
+
* `staticTokens({ ... })`, or any `CredentialProvider`).
|
|
120
|
+
*/
|
|
121
|
+
readonly credentials?: CredentialProvider;
|
|
122
|
+
/**
|
|
123
|
+
* Global cache kill switch (v2.6+). `'off'` disables the cache
|
|
124
|
+
* layer entirely — the CacheGate decider routes to `'no-markers'`
|
|
125
|
+
* every iteration regardless of other rules. Default: caching
|
|
126
|
+
* enabled (auto-resolved per provider via the strategy registry).
|
|
127
|
+
*
|
|
128
|
+
* Use `'off'` for low-frequency agents (cron jobs running once per
|
|
129
|
+
* hour) where the cache TTL guarantees zero cache hits and the
|
|
130
|
+
* cache-write penalty isn't worth paying.
|
|
131
|
+
*/
|
|
132
|
+
readonly caching?: 'off';
|
|
133
|
+
/**
|
|
134
|
+
* Optional explicit CacheStrategy override (v2.6+). Defaults to
|
|
135
|
+
* `getDefaultCacheStrategy(provider.name)` — so Anthropic/OpenAI/
|
|
136
|
+
* Bedrock/Mock providers auto-resolve to their respective strategies
|
|
137
|
+
* once those land in Phase 7+.
|
|
138
|
+
*/
|
|
139
|
+
readonly cacheStrategy?: CacheStrategy;
|
|
140
|
+
/**
|
|
141
|
+
* Optional build-time recorders threaded into footprintjs's
|
|
142
|
+
* `flowChart()` factory. Each recorder fires `onStageAdded` once per
|
|
143
|
+
* node in the Agent's internal chart (Seed, CallLLM, Route, tool
|
|
144
|
+
* handler, slot mounts, PrepareFinal, BreakFinal), and
|
|
145
|
+
* `onSubflowMounted` once per mounted subflow. Recorders own their
|
|
146
|
+
* own accumulators — agentfootprint just threads them through.
|
|
147
|
+
*
|
|
148
|
+
* Cascade: each slot subflow (system-prompt, messages, tools)
|
|
149
|
+
* was built earlier with its OWN recorders (or none).
|
|
150
|
+
* footprintjs does NOT propagate StructureRecorders into mounted
|
|
151
|
+
* subflows — attach the same recorders to every nested composition
|
|
152
|
+
* for full coverage.
|
|
153
|
+
*
|
|
154
|
+
* When omitted, no build-time observation is wired up.
|
|
155
|
+
*/
|
|
156
|
+
readonly structureRecorders?: readonly StructureRecorder[];
|
|
157
|
+
/**
|
|
158
|
+
* Optional per-COMPOSITION translator (UI-agnostic). See
|
|
159
|
+
* `core/translator.ts`. When attached, `agent.getUIGroup()` invokes
|
|
160
|
+
* it with the Agent's `GroupMetadata` (kind `'Agent'`, id, name,
|
|
161
|
+
* empty `members[]`, plus `extra.slots` and `extra.toolNames`).
|
|
162
|
+
* Tools are not `Runner` instances (they're function executors)
|
|
163
|
+
* so they're conveyed by name in `extra`, not as group members.
|
|
164
|
+
* Returns `undefined` when omitted.
|
|
165
|
+
*/
|
|
166
|
+
readonly groupTranslator?: GroupTranslator;
|
|
167
|
+
/**
|
|
168
|
+
* How the ReAct loop behaves — a single setting with three honest choices.
|
|
169
|
+
* Default `'dynamic'`. (Merged in 6.0.0 from the old `reactMode` +
|
|
170
|
+
* `reactStructure` pair, which had a silently-ignored combination.)
|
|
171
|
+
*
|
|
172
|
+
* `'dynamic'` (default) — every iteration re-runs the InjectionEngine and
|
|
173
|
+
* all three slots (system-prompt ‖ messages ‖ tools), because which
|
|
174
|
+
* injections are active can change per turn (a skill activates, a rule
|
|
175
|
+
* fires, a tool-return triggers something). The right shape when the agent
|
|
176
|
+
* uses skills, rule/on-tool-return triggers, or any per-turn context
|
|
177
|
+
* steering. Flat chart shape.
|
|
178
|
+
*
|
|
179
|
+
* `'classic'` — textbook ReAct: context is engineered ONCE. The
|
|
180
|
+
* InjectionEngine, system-prompt and tools run a single time up front; the
|
|
181
|
+
* loop targets only the Messages slot, so each iteration just appends the
|
|
182
|
+
* new tool result and re-calls the LLM. Use when the system prompt and tool
|
|
183
|
+
* set are FIXED for the whole run (the common case). Flat chart shape — the
|
|
184
|
+
* chart reads honestly: `ToolCalls → Messages` loops, static slots outside.
|
|
185
|
+
* CAVEAT: because static slots are cached after turn 1, do NOT use `'classic'`
|
|
186
|
+
* with skills or dynamic-trigger injections — a mid-run activation would not
|
|
187
|
+
* surface into the cached system-prompt/tools. Use `'dynamic'` for those.
|
|
188
|
+
*
|
|
189
|
+
* `'dynamic-grouped'` — same semantics as `'dynamic'`, but the whole LLM turn
|
|
190
|
+
* (injection engine + 3 slots + cache + call + thinking) is wrapped in a
|
|
191
|
+
* single `sf-llm-call` SUBFLOW — the same boundary the `LLMCall` primitive
|
|
192
|
+
* produces. Lens (and any explainable-ui consumer) renders it as an LLM group
|
|
193
|
+
* with its slots inside, with zero bespoke collapsing. Behaviour is identical
|
|
194
|
+
* to `'dynamic'`; only the chart's nesting differs. (Grouping is dynamic-only:
|
|
195
|
+
* it re-seeds context every turn by design, so there is no classic-grouped.)
|
|
196
|
+
*/
|
|
197
|
+
readonly reactMode?: 'classic' | 'dynamic' | 'dynamic-grouped';
|
|
198
|
+
/**
|
|
199
|
+
* Observer delivery tier (RFC-001 Block 10). Default `'inline'` —
|
|
200
|
+
* byte-identical to every prior release: the Agent's bridge recorders
|
|
201
|
+
* (and your `.recorder()` attachments) run synchronously inside the
|
|
202
|
+
* producing statement, so a slow `agent.on()` listener taxes every
|
|
203
|
+
* stage of every iteration.
|
|
204
|
+
*
|
|
205
|
+
* `'deferred'` moves observation off the hot path: every observer event
|
|
206
|
+
* is captured into footprintjs's bounded queue (≈ microseconds) and
|
|
207
|
+
* delivered at the next microtask checkpoint — "one beat behind", with
|
|
208
|
+
* listener work overlapping the LLM/tool await windows instead of
|
|
209
|
+
* serializing with the loop. Same events, same payloads, same order;
|
|
210
|
+
* only the timing meta (`wallClockMs` / `runOffsetMs`) reflects the
|
|
211
|
+
* later delivery. Terminal boundaries (run resolve, reject, pause)
|
|
212
|
+
* drain the queue synchronously BEFORE control returns, so crash
|
|
213
|
+
* reports / checkpoints always carry the complete record.
|
|
214
|
+
*
|
|
215
|
+
* Exception kept inline for correctness: the causal-evidence harvest
|
|
216
|
+
* recorder (mounted with CAUSAL memories) — the memory write stage
|
|
217
|
+
* reads its accumulators MID-run, so it cannot run one beat behind.
|
|
218
|
+
*
|
|
219
|
+
* Per-recorder override: a consumer recorder that declares its own
|
|
220
|
+
* `delivery` field keeps it — the agent-level option is the default
|
|
221
|
+
* tier for recorders that don't declare one.
|
|
222
|
+
*
|
|
223
|
+
* For serverless / graceful shutdown, settle async listener work with
|
|
224
|
+
* `await agent.drainObservers({ timeoutMs })` before the process exits.
|
|
225
|
+
* Queue stats surface on `agent.getLastSnapshot()?.observerStats`.
|
|
226
|
+
*/
|
|
227
|
+
readonly observerDelivery?: 'inline' | 'deferred';
|
|
228
|
+
/**
|
|
229
|
+
* Queue dials for `observerDelivery: 'deferred'` — see
|
|
230
|
+
* `ObserverDeliveryOptions`. Throws at construction when set without
|
|
231
|
+
* `observerDelivery: 'deferred'` (no silently-ignored combinations).
|
|
232
|
+
*/
|
|
233
|
+
readonly observerDeliveryOptions?: ObserverDeliveryOptions;
|
|
234
|
+
}
|
|
235
|
+
export interface AgentInput {
|
|
236
|
+
readonly message: string;
|
|
237
|
+
/**
|
|
238
|
+
* Multi-tenant memory scope. Populated to `scope.identity` so memory
|
|
239
|
+
* subflows registered via `.memory()` can isolate reads/writes per
|
|
240
|
+
* tenant + principal + conversation.
|
|
241
|
+
*
|
|
242
|
+
* Defaults to `{ conversationId: '<runId>' }` when omitted, so agents
|
|
243
|
+
* without memory work unchanged.
|
|
244
|
+
*/
|
|
245
|
+
readonly identity?: MemoryIdentity;
|
|
246
|
+
}
|
|
247
|
+
export type AgentOutput = string;
|
|
248
|
+
/**
|
|
249
|
+
* Internal scope state for the Agent's flowchart. Recorders never read
|
|
250
|
+
* this directly — they read the InjectionRecord convention keys + emit
|
|
251
|
+
* events. Each stage function under `./stages/` receives a TypedScope
|
|
252
|
+
* over this shape and reads/writes via typed properties.
|
|
253
|
+
*
|
|
254
|
+
* Mutability conventions (followed by every Agent stage):
|
|
255
|
+
* • Per-iteration scalars (iteration, finalContent, llmLatestContent,
|
|
256
|
+
* etc.) are OVERWRITTEN each pass; commitLog preserves history.
|
|
257
|
+
* • Cumulative scalars (cumTokensInput, totalInputTokens, turnNumber)
|
|
258
|
+
* accumulate monotonically across the run.
|
|
259
|
+
* • Arrays from slot subflows (systemPromptInjections,
|
|
260
|
+
* messagesInjections, toolsInjections, dynamicToolSchemas,
|
|
261
|
+
* cacheMarkers) use `arrayMerge: ArrayMergeMode.Replace` semantics —
|
|
262
|
+
* each iteration's value REPLACES the prior iteration's, not
|
|
263
|
+
* appends.
|
|
264
|
+
*/
|
|
265
|
+
export interface AgentState {
|
|
266
|
+
userMessage: string;
|
|
267
|
+
history: readonly LLMMessage[];
|
|
268
|
+
iteration: number;
|
|
269
|
+
maxIterations: number;
|
|
270
|
+
finalContent: string;
|
|
271
|
+
totalInputTokens: number;
|
|
272
|
+
totalOutputTokens: number;
|
|
273
|
+
turnStartMs: number;
|
|
274
|
+
runIdentity: MemoryIdentity;
|
|
275
|
+
newMessages: readonly LLMMessage[];
|
|
276
|
+
turnNumber: number;
|
|
277
|
+
contextTokensRemaining: number;
|
|
278
|
+
systemPromptInjections: readonly InjectionRecord[];
|
|
279
|
+
messagesInjections: readonly InjectionRecord[];
|
|
280
|
+
toolsInjections: readonly InjectionRecord[];
|
|
281
|
+
llmLatestContent: string;
|
|
282
|
+
llmLatestToolCalls: readonly {
|
|
283
|
+
readonly id: string;
|
|
284
|
+
readonly name: string;
|
|
285
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
286
|
+
}[];
|
|
287
|
+
pausedToolCallId: string;
|
|
288
|
+
pausedToolName: string;
|
|
289
|
+
pausedToolStartMs: number;
|
|
290
|
+
cumTokensInput: number;
|
|
291
|
+
cumTokensOutput: number;
|
|
292
|
+
cumEstimatedUsd: number;
|
|
293
|
+
costBudgetHit: boolean;
|
|
294
|
+
/** Active set output by InjectionEngine subflow each iteration —
|
|
295
|
+
* POJO projections (no functions) suitable for scope round-trip. */
|
|
296
|
+
activeInjections: readonly ActiveInjection[];
|
|
297
|
+
/** IDs of LLM-activated Skills the LLM has activated this turn
|
|
298
|
+
* (via the `read_skill` tool). InjectionEngine matches by id. */
|
|
299
|
+
activatedInjectionIds: readonly string[];
|
|
300
|
+
/** Most recent tool result — drives `on-tool-return` triggers. */
|
|
301
|
+
lastToolResult?: {
|
|
302
|
+
toolName: string;
|
|
303
|
+
result: string;
|
|
304
|
+
};
|
|
305
|
+
/** Tool schemas resolved by the tools slot subflow each iteration
|
|
306
|
+
* (registry + injection-supplied). Used by callLLM. */
|
|
307
|
+
dynamicToolSchemas: readonly LLMToolSchema[];
|
|
308
|
+
/** Provider-agnostic cache markers emitted by CacheDecision subflow.
|
|
309
|
+
* Cleared each iteration by the SkipCaching branch when the
|
|
310
|
+
* CacheGate decides to skip (kill switch / hit-rate / churn). */
|
|
311
|
+
cacheMarkers: readonly CacheMarker[];
|
|
312
|
+
/** Global cache kill switch from `Agent.create({ caching: 'off' })`. */
|
|
313
|
+
cachingDisabled: boolean;
|
|
314
|
+
/** Running cache hit rate from recent iterations (0..1). Computed
|
|
315
|
+
* by cacheRecorder (Phase 9); `undefined` until first metrics. */
|
|
316
|
+
recentHitRate: number | undefined;
|
|
317
|
+
/** Rolling window of active-skill IDs across recent iterations.
|
|
318
|
+
* Maintained by the UpdateSkillHistory function stage; consumed
|
|
319
|
+
* by CacheGate's skill-churn rule. */
|
|
320
|
+
skillHistory: readonly (string | undefined)[];
|
|
321
|
+
/** The skill-graph CURSOR — which skill node a `skillGraph()` agent is
|
|
322
|
+
* currently *in*, persisted across ReAct iterations. Advanced each iteration
|
|
323
|
+
* by the Injection Engine (`currentSkillId = graph.nextSkill(ctx)`) and
|
|
324
|
+
* carried by the mount mappers; reset to `undefined` per turn at seed (each
|
|
325
|
+
* turn re-enters via the entry router). `from`-gates the route triggers.
|
|
326
|
+
* Undefined for agents without a skill graph. */
|
|
327
|
+
currentSkillId?: string;
|
|
328
|
+
/** The relevance ranking of entry candidates from an entry scorer (`.entryBy()` /
|
|
329
|
+
* `.entryByRelevance()`) — written by the PickEntry stage once per turn (the
|
|
330
|
+
* "Why this skill?" relevance %). `score` is the raw strategy score; `relevance`
|
|
331
|
+
* the softmax share. Absent unless the graph used an entry scorer. */
|
|
332
|
+
entryScores?: ReadonlyArray<{
|
|
333
|
+
readonly id: string;
|
|
334
|
+
readonly score: number;
|
|
335
|
+
readonly relevance: number;
|
|
336
|
+
}>;
|
|
337
|
+
/** Name of the entry scorer that produced `entryScores` (`'keyword'` /
|
|
338
|
+
* `'embedding'` / a custom scorer's name). */
|
|
339
|
+
entryScorer?: string;
|
|
340
|
+
/** Set when a `PermissionChecker` returns `{ result: 'halt', ... }`.
|
|
341
|
+
* `Agent.run()` reads these at the API boundary and throws a typed
|
|
342
|
+
* `PolicyHaltError` carrying the same context — the chart $break's
|
|
343
|
+
* graceful termination becomes a runtime signal callers can catch
|
|
344
|
+
* with `instanceof PolicyHaltError`. Telemetry tag from the rule. */
|
|
345
|
+
policyHaltReason?: string;
|
|
346
|
+
/** Content delivered to the LLM as the synthetic tool_result before
|
|
347
|
+
* termination — also surfaces on `PolicyHaltError.tellLLM` for
|
|
348
|
+
* audit / replay. */
|
|
349
|
+
policyHaltTellLLM?: string;
|
|
350
|
+
/** The proposed tool call that triggered the halt (NOT executed). */
|
|
351
|
+
policyHaltTarget?: string;
|
|
352
|
+
policyHaltArgs?: Readonly<Record<string, unknown>>;
|
|
353
|
+
/** ReAct iteration the halt fired on. */
|
|
354
|
+
policyHaltIteration?: number;
|
|
355
|
+
/** Identifier of the PermissionChecker that returned `'halt'`. */
|
|
356
|
+
policyHaltCheckerId?: string;
|
|
357
|
+
/** Provider-specific raw thinking data, set by callLLM after the
|
|
358
|
+
* LLM response lands. The NormalizeThinking sub-subflow reads this
|
|
359
|
+
* and feeds it to the configured `ThinkingHandler.normalize()`.
|
|
360
|
+
* Undefined when the provider has no thinking content for this call. */
|
|
361
|
+
rawThinking?: unknown;
|
|
362
|
+
/** Normalized thinking blocks from the most recent LLM response.
|
|
363
|
+
* Written by the NormalizeThinking sub-subflow; read by toolCalls.ts
|
|
364
|
+
* + prepareFinal.ts when constructing the assistant message for
|
|
365
|
+
* `scope.history` (ensures Anthropic signature round-trip). Empty
|
|
366
|
+
* array when no thinking present. */
|
|
367
|
+
thinkingBlocks: readonly ThinkingBlock[];
|
|
368
|
+
/** Set when the rules-based reliability loop takes the fail-fast path.
|
|
369
|
+
* `Agent.run()` reads these from the post-run snapshot and throws a
|
|
370
|
+
* typed `ReliabilityFailFastError`. Mirrors `policyHalt*` — because the
|
|
371
|
+
* loop stops the chart with `$break` (not a throw), durable scope is the
|
|
372
|
+
* only courier of the structured fail context across the break to the
|
|
373
|
+
* API boundary. (Telemetry ALSO fires via the `reliability.fail_fast`
|
|
374
|
+
* emit event; these scope fields are the business-logic control signal.) */
|
|
375
|
+
reliabilityFailKind?: string;
|
|
376
|
+
reliabilityFailPayload?: ReliabilityScope['failPayload'];
|
|
377
|
+
reliabilityFailReason?: string;
|
|
378
|
+
/** Originating error message/name — stringified because Error objects
|
|
379
|
+
* don't survive footprintjs's `structuredClone` of scope. */
|
|
380
|
+
reliabilityFailCauseMessage?: string;
|
|
381
|
+
reliabilityFailCauseName?: string;
|
|
382
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent validators — pure helper functions extracted from Agent.ts.
|
|
3
|
+
*
|
|
4
|
+
* These run at Agent construction time (eagerly, so misconfiguration
|
|
5
|
+
* fails fast at `.build()`) and during stage execution (safeStringify
|
|
6
|
+
* for tool-result formatting).
|
|
7
|
+
*
|
|
8
|
+
* Pure functions, no class state — extracted for readability and
|
|
9
|
+
* isolated testability. The Agent class imports + invokes these in
|
|
10
|
+
* its constructor and stage handlers.
|
|
11
|
+
*/
|
|
12
|
+
import type { MemoryDefinition } from '../../memory/define.types.js';
|
|
13
|
+
import type { Injection } from '../../lib/injection-engine/types.js';
|
|
14
|
+
import type { ToolRegistryEntry } from '../tools.js';
|
|
15
|
+
/**
|
|
16
|
+
* Validate that every memory definition has a unique id. Each memory
|
|
17
|
+
* writes to its own scope key (`memoryInjection_${id}`); duplicates
|
|
18
|
+
* silently overwrite, leading to data loss that's hard to debug.
|
|
19
|
+
*
|
|
20
|
+
* Throws on collision so `Agent.build()` fails fast at construction.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateMemoryIdUniqueness(memories: readonly MemoryDefinition[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Validate `maxIterations`. The historical silent clamp to 50 existed because
|
|
25
|
+
* footprintjs's recursive traversal hit its depth wall around iteration 71 —
|
|
26
|
+
* footprintjs 9.0.0's trampoline removed that wall (loops run on a flat
|
|
27
|
+
* stack), so the cap is gone. The lower bound (1) still prevents a
|
|
28
|
+
* 0-iteration agent; large values are the consumer's COST choice (each
|
|
29
|
+
* iteration is an LLM call) — a dev-mode warning flags budgets above 100.
|
|
30
|
+
* The Agent passes matching headroom to the engine's own loop-iteration
|
|
31
|
+
* limit so it can never fire below the agent's budget.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clampIterations(n: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Validate tool-name uniqueness across `.tool()`-registered tools +
|
|
36
|
+
* every Skill's `inject.tools[]`. The LLM dispatches by `tool.schema.name`
|
|
37
|
+
* (the wire format), so any collision silently shadows execution.
|
|
38
|
+
*
|
|
39
|
+
* Called eagerly in the Agent constructor so `Agent.build()` throws
|
|
40
|
+
* immediately, not on first `run()`.
|
|
41
|
+
*
|
|
42
|
+
* `read_skill` is reserved when ≥1 Skill is registered — collisions
|
|
43
|
+
* with consumer tools throw.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateToolNameUniqueness(registry: readonly ToolRegistryEntry[], injections: readonly Injection[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* JSON.stringify with circular-ref protection. Tool results are untrusted —
|
|
48
|
+
* a hostile/buggy tool returning a cyclic object must not crash the run.
|
|
49
|
+
* Falls back to '[unstringifiable: <reason>]' so the LLM still sees that
|
|
50
|
+
* the tool ran and produced something unusable.
|
|
51
|
+
*/
|
|
52
|
+
export declare function safeStringify(value: unknown): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cost — shared cost-accounting helper emitted by LLMCall + Agent.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Strategy (PricingTable port) + Event emission (typedEmit).
|
|
5
|
+
* Role: core/ layer. When a runner is configured with a PricingTable,
|
|
6
|
+
* every LLM response drives a `cost.tick` event carrying per-call
|
|
7
|
+
* tokens/USD plus cumulative run totals. When a `costBudget` is
|
|
8
|
+
* also set, the first crossing emits `cost.limit_hit` with
|
|
9
|
+
* `action: 'warn'` (library never auto-aborts; consumers decide).
|
|
10
|
+
* Emits: agentfootprint.cost.tick
|
|
11
|
+
* agentfootprint.cost.limit_hit
|
|
12
|
+
*/
|
|
13
|
+
import type { PricingTable } from '../adapters/types.js';
|
|
14
|
+
export interface CostAccountingScope {
|
|
15
|
+
cumTokensInput: number;
|
|
16
|
+
cumTokensOutput: number;
|
|
17
|
+
cumEstimatedUsd: number;
|
|
18
|
+
costBudgetHit: boolean;
|
|
19
|
+
}
|
|
20
|
+
type Usage = {
|
|
21
|
+
readonly input: number;
|
|
22
|
+
readonly output: number;
|
|
23
|
+
readonly cacheRead?: number;
|
|
24
|
+
readonly cacheWrite?: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Emit `cost.tick` for the just-completed LLM response and, if the
|
|
28
|
+
* consumer set a `costBudget`, emit a one-shot `cost.limit_hit` the first
|
|
29
|
+
* time cumulative USD crosses the budget. Does nothing when no
|
|
30
|
+
* `pricingTable` is configured — zero overhead on runs without costing.
|
|
31
|
+
*
|
|
32
|
+
* Scope must carry the running cumulative counters; callers seed them
|
|
33
|
+
* in their Seed stage.
|
|
34
|
+
*/
|
|
35
|
+
export declare function emitCostTick(scope: CostAccountingScope & {
|
|
36
|
+
$emit: (name: string, payload?: unknown) => void;
|
|
37
|
+
}, pricingTable: PricingTable | undefined, costBudget: number | undefined, model: string, usage: Usage): void;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* flowchartAsTool — wrap a footprintjs `FlowChart` as an Agent `Tool`.
|
|
3
|
+
*
|
|
4
|
+
* The Block A7 piece. footprintjs is the substrate; agentfootprint is
|
|
5
|
+
* the agent layer above it. When a multi-step procedure is already
|
|
6
|
+
* expressed as a footprintjs flowchart (intake validation, refund
|
|
7
|
+
* processing, claim adjudication — anything with branches, loops, or
|
|
8
|
+
* decision evidence), let the LLM call it as ONE tool. The flowchart's
|
|
9
|
+
* step-by-step recorders, narrative, and pause/resume continue to work
|
|
10
|
+
* exactly as they do outside the agent.
|
|
11
|
+
*
|
|
12
|
+
* Why this matters:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Composition over re-write.** A team with a non-trivial
|
|
15
|
+
* footprintjs flowchart shouldn't have to flatten it into N
|
|
16
|
+
* separate tools to expose it to an agent. Wrap it once.
|
|
17
|
+
*
|
|
18
|
+
* 2. **Observability stays free.** Every flowchart stage emits typed
|
|
19
|
+
* events. The Agent's recorders see the wrapping tool call;
|
|
20
|
+
* footprintjs's recorders see everything inside. Two layers,
|
|
21
|
+
* one observation tree. The `recorders` option bridges them:
|
|
22
|
+
* attach agent-layer observers (the causal-evidence bridge,
|
|
23
|
+
* `otel.decisionEvidenceRecorder()`, your own CombinedRecorder)
|
|
24
|
+
* to the tool's INTERNAL executor so decide()/select() evidence
|
|
25
|
+
* inside the flowchart reaches them too.
|
|
26
|
+
*
|
|
27
|
+
* 3. **Pause/resume composes.** A pausable handler inside the
|
|
28
|
+
* flowchart pauses the inner executor; the outer agent treats
|
|
29
|
+
* the pause as an unfinished tool call. Resume the agent and the
|
|
30
|
+
* inner flowchart resumes from its checkpoint. (Today: surfaces
|
|
31
|
+
* the pause as a thrown error with the checkpoint attached;
|
|
32
|
+
* polished agent-side pause integration in v2.6.)
|
|
33
|
+
*
|
|
34
|
+
* Pattern: Adapter (GoF) over `FlowChartExecutor.run()`. Translates
|
|
35
|
+
* `Tool.execute(args, ctx)` into `executor.run({ input: args,
|
|
36
|
+
* env: { signal: ctx.signal } })` and the result back to a
|
|
37
|
+
* string via `resultMapper` (or a default JSON stringify).
|
|
38
|
+
*
|
|
39
|
+
* Role: Layer-6 (Agent) → Layer-1 (footprintjs) bridge. Pure
|
|
40
|
+
* interop; no new abstraction in either layer.
|
|
41
|
+
*
|
|
42
|
+
* @example Single-stage flowchart as a tool
|
|
43
|
+
* import { flowChart } from 'footprintjs';
|
|
44
|
+
* import { Agent, flowchartAsTool } from 'agentfootprint';
|
|
45
|
+
*
|
|
46
|
+
* const refundChart = flowChart<{ refundId: string }>(
|
|
47
|
+
* 'RefundFlow',
|
|
48
|
+
* async (scope) => {
|
|
49
|
+
* const args = scope.$getArgs<{ orderId: string; reason: string }>();
|
|
50
|
+
* scope.refundId = await refundService.process(args.orderId);
|
|
51
|
+
* },
|
|
52
|
+
* 'refund-flow',
|
|
53
|
+
* ).build();
|
|
54
|
+
*
|
|
55
|
+
* const refundTool = flowchartAsTool({
|
|
56
|
+
* name: 'process_refund',
|
|
57
|
+
* description: 'Process a refund for an order. Returns refundId on success.',
|
|
58
|
+
* inputSchema: {
|
|
59
|
+
* type: 'object',
|
|
60
|
+
* properties: {
|
|
61
|
+
* orderId: { type: 'string' },
|
|
62
|
+
* reason: { type: 'string' },
|
|
63
|
+
* },
|
|
64
|
+
* required: ['orderId', 'reason'],
|
|
65
|
+
* },
|
|
66
|
+
* flowchart: refundChart,
|
|
67
|
+
* resultMapper: (snapshot) =>
|
|
68
|
+
* JSON.stringify({ refundId: snapshot.values.refundId, status: 'processed' }),
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* const agent = Agent.create({ provider }).tool(refundTool).build();
|
|
72
|
+
*
|
|
73
|
+
* @example Multi-stage flowchart with decide() + recorders
|
|
74
|
+
* const triageChart = flowChart<TriageState>('Triage', validateInput, 'validate')
|
|
75
|
+
* .addDeciderFunction('Classify', classifyDecider, 'classify')
|
|
76
|
+
* .addFunctionBranch('high', 'Escalate', escalate)
|
|
77
|
+
* .addFunctionBranch('low', 'Auto-handle', autoHandle)
|
|
78
|
+
* .end()
|
|
79
|
+
* .build();
|
|
80
|
+
*
|
|
81
|
+
* // decide() evidence inside the chart fires `onDecision` on each
|
|
82
|
+
* // attached recorder — wire the agent's evidence consumers straight
|
|
83
|
+
* // into the tool instead of hand-mounting the chart.
|
|
84
|
+
* const evidence = causalEvidenceRecorder();
|
|
85
|
+
*
|
|
86
|
+
* const triageTool = flowchartAsTool({
|
|
87
|
+
* name: 'triage_request',
|
|
88
|
+
* description: 'Triage an incoming request and return the decision.',
|
|
89
|
+
* inputSchema: { ... },
|
|
90
|
+
* flowchart: triageChart,
|
|
91
|
+
* recorders: [evidence],
|
|
92
|
+
* });
|
|
93
|
+
*/
|
|
94
|
+
import { type CombinedRecorder, type FlowChart } from 'footprintjs';
|
|
95
|
+
import type { Tool } from './tools.js';
|
|
96
|
+
/**
|
|
97
|
+
* Pruned snapshot view passed to `resultMapper`. We keep this minimal
|
|
98
|
+
* (the values bag + the chart's narrative entries) to avoid leaking
|
|
99
|
+
* internal scope plumbing. Consumers needing the full snapshot can
|
|
100
|
+
* pass a `passthrough` resultMapper that ignores the prune.
|
|
101
|
+
*/
|
|
102
|
+
export interface FlowchartToolSnapshot {
|
|
103
|
+
/**
|
|
104
|
+
* Final scope state — the merged result of every stage's writes.
|
|
105
|
+
* This is what `executor.getSnapshot().values` returns.
|
|
106
|
+
*/
|
|
107
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
108
|
+
/**
|
|
109
|
+
* The flowchart's combined narrative entries (flow + data).
|
|
110
|
+
* Useful for resultMappers that want to extract specific commit
|
|
111
|
+
* artifacts or audit a decision path.
|
|
112
|
+
*/
|
|
113
|
+
readonly narrative: readonly {
|
|
114
|
+
readonly type?: string;
|
|
115
|
+
readonly text?: string;
|
|
116
|
+
}[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Optional result mapper. Receives the flowchart's final snapshot
|
|
120
|
+
* (pruned to `FlowchartToolSnapshot`) and returns the string the LLM
|
|
121
|
+
* sees as the tool result.
|
|
122
|
+
*
|
|
123
|
+
* If omitted, the default behavior is `JSON.stringify(snapshot.values)`.
|
|
124
|
+
*
|
|
125
|
+
* Errors thrown from the mapper become the tool result with a
|
|
126
|
+
* `[mapper-error: ...]` prefix so the LLM sees a useful diagnostic.
|
|
127
|
+
*/
|
|
128
|
+
export type FlowchartResultMapper = (snapshot: FlowchartToolSnapshot) => string;
|
|
129
|
+
/**
|
|
130
|
+
* Options for `flowchartAsTool`.
|
|
131
|
+
*/
|
|
132
|
+
export interface FlowchartAsToolOptions {
|
|
133
|
+
/** Tool name the LLM dispatches by. Must be unique across the agent's tools. */
|
|
134
|
+
readonly name: string;
|
|
135
|
+
/** Tool description shown to the LLM. */
|
|
136
|
+
readonly description: string;
|
|
137
|
+
/**
|
|
138
|
+
* JSON Schema describing the input args the LLM must produce.
|
|
139
|
+
* Becomes `flowchart.run({ input: args })`. Default: `{ type: 'object', properties: {} }`.
|
|
140
|
+
*/
|
|
141
|
+
readonly inputSchema?: Readonly<Record<string, unknown>>;
|
|
142
|
+
/**
|
|
143
|
+
* The footprintjs flowchart to mount as the tool's body.
|
|
144
|
+
* The chart's stages receive args via `scope.$getArgs()`.
|
|
145
|
+
*/
|
|
146
|
+
readonly flowchart: FlowChart;
|
|
147
|
+
/**
|
|
148
|
+
* Optional shaping function. Default: `JSON.stringify(snapshot.values)`.
|
|
149
|
+
* Errors throw into the tool's `[mapper-error: ...]` envelope.
|
|
150
|
+
*/
|
|
151
|
+
readonly resultMapper?: FlowchartResultMapper;
|
|
152
|
+
/**
|
|
153
|
+
* Observers to attach to the tool's INTERNAL `FlowChartExecutor`
|
|
154
|
+
* before each run. This is the hook that lets decide()/select()
|
|
155
|
+
* evidence (and every other footprintjs event) inside a tool-mounted
|
|
156
|
+
* flowchart reach agent-layer evidence consumers — e.g. the causal
|
|
157
|
+
* `causalEvidenceRecorder()` bridge or `otel.decisionEvidenceRecorder()`.
|
|
158
|
+
* Without it, the internal executor is unobservable from outside.
|
|
159
|
+
*
|
|
160
|
+
* Each entry is a footprintjs `CombinedRecorder`, attached via
|
|
161
|
+
* `executor.attachCombinedRecorder` and routed by runtime
|
|
162
|
+
* method-shape detection — so ONE array covers all three observer
|
|
163
|
+
* channels (scope data-flow `onRead`/`onWrite`/`onCommit`/…,
|
|
164
|
+
* control-flow `onDecision`/`onSelected`/`onLoop`/…, and emit
|
|
165
|
+
* `onEmit`). Implement only the hooks you care about.
|
|
166
|
+
*
|
|
167
|
+
* **Per-invocation semantics:** the tool builds a FRESH executor per
|
|
168
|
+
* call (flowchart state never leaks between invocations) and attaches
|
|
169
|
+
* every recorder in this array to EACH invocation's executor before
|
|
170
|
+
* `run()`. The recorder INSTANCES are yours and are shared across
|
|
171
|
+
* invocations — a stateful recorder therefore accumulates events from
|
|
172
|
+
* EVERY invocation of the tool. Each invocation is a distinct run
|
|
173
|
+
* with a fresh `runId`; recorders needing per-invocation bookkeeping
|
|
174
|
+
* detect the boundary via `event.traversalContext.runId !== lastRunId`
|
|
175
|
+
* (Convention 4) rather than assuming one run per recorder lifetime.
|
|
176
|
+
*/
|
|
177
|
+
readonly recorders?: ReadonlyArray<CombinedRecorder>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Wrap a footprintjs `FlowChart` as a `Tool` the Agent's LLM can call.
|
|
181
|
+
*
|
|
182
|
+
* On execute:
|
|
183
|
+
* 1. Constructs a fresh `FlowChartExecutor(flowchart)` per call (so
|
|
184
|
+
* consecutive invocations don't share state).
|
|
185
|
+
* 2. Attaches each `opts.recorders` entry via
|
|
186
|
+
* `executor.attachCombinedRecorder` — the SAME recorder instances
|
|
187
|
+
* attach to every invocation's fresh executor (see the option's
|
|
188
|
+
* JSDoc for the shared-state / runId implications).
|
|
189
|
+
* 3. Calls `executor.run({ input: args, env: { signal } })` with the
|
|
190
|
+
* LLM-supplied args + the agent's abort signal.
|
|
191
|
+
* 4. If the run paused, throws an Error with the checkpoint attached
|
|
192
|
+
* (`error.checkpoint`) so the agent loop can surface it. Polished
|
|
193
|
+
* agent-side pause integration is v2.6 work.
|
|
194
|
+
* 5. If the run completed, calls `resultMapper(snapshot)` (or the
|
|
195
|
+
* default JSON.stringify) and returns the string.
|
|
196
|
+
* 6. If the run threw, the error propagates — the Agent's
|
|
197
|
+
* tool-call handler converts it to a synthetic error string for
|
|
198
|
+
* the LLM to see + recover from.
|
|
199
|
+
*/
|
|
200
|
+
export declare function flowchartAsTool(opts: FlowchartAsToolOptions): Tool;
|