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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reliabilityExecution — the retry-loop helper invoked by `callLLM`
|
|
3
|
+
* when `Agent.create(...).reliability(config)` is configured.
|
|
4
|
+
*
|
|
5
|
+
* Wraps a single-shot LLM call with rules-based reliability semantics:
|
|
6
|
+
*
|
|
7
|
+
* PreCheck rules → continue / fail-fast
|
|
8
|
+
* ↓
|
|
9
|
+
* provider call → response | error
|
|
10
|
+
* ↓
|
|
11
|
+
* PostDecide rules → ok / retry / retry-other / fallback / fail-fast
|
|
12
|
+
* ↓
|
|
13
|
+
* loop or commit
|
|
14
|
+
*
|
|
15
|
+
* The loop runs in JS within a SINGLE footprintjs stage execution. The
|
|
16
|
+
* trace shows one CallLLM stage that internally retried N times. Richer
|
|
17
|
+
* "every retry as a separate stage" tracing is the v2.11.6+ work via
|
|
18
|
+
* `buildReliabilityGateChart` (which trades streaming support for
|
|
19
|
+
* stage-level granularity).
|
|
20
|
+
*
|
|
21
|
+
* Streaming + reliability semantics — first-chunk arbitration:
|
|
22
|
+
* • Pre-first-chunk failures (connection, headers, breaker-open):
|
|
23
|
+
* full rule set fires (retry / retry-other / fallback / fail-fast).
|
|
24
|
+
* • Post-first-chunk failures (mid-stream): rules can ONLY emit
|
|
25
|
+
* `ok` (commit what we have) or `fail-fast`. Retry / retry-other /
|
|
26
|
+
* fallback are escalated to fail-fast with kind
|
|
27
|
+
* `'mid-stream-not-retryable'`. Matches LangChain's
|
|
28
|
+
* `RunnableWithFallbacks` first-chunk arbitration pattern.
|
|
29
|
+
*
|
|
30
|
+
* On fail-fast: writes `failKind` + `failPayload` to agent scope and
|
|
31
|
+
* calls `$break(reason)`. The agent's main chart catches the break;
|
|
32
|
+
* `Agent.run()` translates it into a typed `ReliabilityFailFastError`
|
|
33
|
+
* at the API boundary (via `TranslateFailFast` stage).
|
|
34
|
+
*
|
|
35
|
+
* Closure-local state (NOT scope):
|
|
36
|
+
* • `attempt` — 1-indexed attempt counter
|
|
37
|
+
* • `providerIdx` — index into the failover list
|
|
38
|
+
* • `breakerStates` — per-provider breaker state (Map)
|
|
39
|
+
* • `attemptsPerProvider` — per-provider counter
|
|
40
|
+
*
|
|
41
|
+
* Why closure-local: this is one footprintjs stage execution. Putting
|
|
42
|
+
* counters into scope would commit them across iterations of the
|
|
43
|
+
* agent's outer ReAct loop, which is not the intent.
|
|
44
|
+
*/
|
|
45
|
+
import type { TypedScope } from 'footprintjs';
|
|
46
|
+
import type { LLMProvider, LLMRequest, LLMResponse } from '../../../adapters/types.js';
|
|
47
|
+
import type { ReliabilityConfig, ReliabilityRule, ReliabilityScope } from '../../../reliability/types.js';
|
|
48
|
+
import type { AgentState } from '../types.js';
|
|
49
|
+
/** A single-shot LLM call function. Built once by `callLLM.ts` and
|
|
50
|
+
* passed into this helper; we invoke it once per loop iteration. */
|
|
51
|
+
export type LLMCallFn = (request: LLMRequest, hooks: {
|
|
52
|
+
/** Called the first time a streaming chunk yields content. After
|
|
53
|
+
* this fires, mid-stream errors will escalate retry/fallback to
|
|
54
|
+
* fail-fast. */
|
|
55
|
+
onFirstChunk?: () => void;
|
|
56
|
+
}) => Promise<LLMResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* v2.13 — Output-schema validation hook. Called by the reliability loop
|
|
59
|
+
* AFTER a successful LLM response, BEFORE the response is committed.
|
|
60
|
+
* Throw to signal validation failure — the gate treats the throw as a
|
|
61
|
+
* `'schema-fail'` errorKind and routes via PostDecide rules (which can
|
|
62
|
+
* `retry` with `feedbackForLLM` for Instructor-style schema retry).
|
|
63
|
+
*
|
|
64
|
+
* Sentinel error type — the loop unwraps `ValidationFailure` instances
|
|
65
|
+
* to extract `message` / `path` / `rawOutput` for the
|
|
66
|
+
* `agentfootprint.agent.output_schema_validation_failed` event payload.
|
|
67
|
+
*
|
|
68
|
+
* MUST-FIX #1 from the v2.13 7-panel review: the hook fires ONLY when
|
|
69
|
+
* `response.toolCalls.length === 0` (final-answer turn). Tool-call
|
|
70
|
+
* turns aren't terminal output and validation would be premature.
|
|
71
|
+
* Caller is responsible for the guard; this helper just runs whatever
|
|
72
|
+
* the caller passes.
|
|
73
|
+
*/
|
|
74
|
+
export type OutputSchemaValidator = (response: LLMResponse) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Sentinel error class thrown by an `OutputSchemaValidator` to signal
|
|
77
|
+
* a validation failure. Distinct subclass so the reliability loop can
|
|
78
|
+
* `instanceof` check and route to the schema-fail branch instead of
|
|
79
|
+
* treating it as a generic provider error.
|
|
80
|
+
*/
|
|
81
|
+
export declare class ValidationFailure extends Error {
|
|
82
|
+
readonly stage: 'json-parse' | 'schema-validate';
|
|
83
|
+
readonly path?: string;
|
|
84
|
+
readonly rawOutput?: string;
|
|
85
|
+
constructor(opts: {
|
|
86
|
+
message: string;
|
|
87
|
+
stage: 'json-parse' | 'schema-validate';
|
|
88
|
+
path?: string;
|
|
89
|
+
rawOutput?: string;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Sentinel kind written to scope on a mid-stream failure that the
|
|
93
|
+
* rules wanted to retry. Surfaces in `ReliabilityFailFastError.kind`. */
|
|
94
|
+
export declare const MID_STREAM_KIND = "mid-stream-not-retryable";
|
|
95
|
+
/**
|
|
96
|
+
* Run the reliability retry loop. Returns the committed `LLMResponse`
|
|
97
|
+
* on success; calls `scope.$break(reason)` and returns `undefined` on
|
|
98
|
+
* fail-fast (caller short-circuits when undefined is returned).
|
|
99
|
+
*/
|
|
100
|
+
export declare function executeWithReliability(scope: TypedScope<AgentState>, request: LLMRequest, config: ReliabilityConfig, defaultProvider: LLMProvider, defaultProviderName: string, defaultModel: string, callFn: LLMCallFn,
|
|
101
|
+
/** v2.13 — optional output-schema validator. When supplied, the loop
|
|
102
|
+
* invokes it after every successful LLM call WHERE
|
|
103
|
+
* `response.toolCalls.length === 0` (final-answer turn). Throws of
|
|
104
|
+
* type `ValidationFailure` signal schema-fail and route via
|
|
105
|
+
* PostDecide rules. Caller is responsible for guarding tool-call
|
|
106
|
+
* turns; this helper assumes the validator is already gated. */
|
|
107
|
+
postValidate?: OutputSchemaValidator): Promise<LLMResponse | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* v2.13 — stuck-loop detection helper. Returns `true` when the last
|
|
110
|
+
* `n` validation errors are IDENTICAL — a hallucinating model that
|
|
111
|
+
* keeps making the same mistake won't make progress on more retries.
|
|
112
|
+
*
|
|
113
|
+
* Default rule template — spread into your `postDecide` to short-circuit
|
|
114
|
+
* stuck loops:
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* postDecide: [
|
|
118
|
+
* defaultStuckLoopRule, // ← spread first; fail-fast on stuck
|
|
119
|
+
* { when: (s) => s.validationError !== undefined && s.attempt < 3, then: 'retry', ... },
|
|
120
|
+
* ]
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param scope The reliability scope view passed to rule predicates.
|
|
124
|
+
* @param n How many trailing identical errors trigger detection. Default 2.
|
|
125
|
+
*/
|
|
126
|
+
export declare function lastNValidationErrorsMatch(scope: ReliabilityScope, n?: number): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* v2.13 — drop-in PostDecide rule that fail-fasts when the last 2
|
|
129
|
+
* validation errors match. Spread into `postDecide` BEFORE retry
|
|
130
|
+
* rules so it short-circuits before another wasted attempt.
|
|
131
|
+
*
|
|
132
|
+
* The matched-rule kind `'schema-stuck-loop'` surfaces on
|
|
133
|
+
* `ReliabilityFailFastError.kind` for caller branching.
|
|
134
|
+
*/
|
|
135
|
+
export declare const defaultStuckLoopRule: ReliabilityRule;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* route — decider that branches the ReAct loop into 'tool-calls' or 'final'.
|
|
3
|
+
*
|
|
4
|
+
* Runs after CallLLM. If the LLM returned tool calls AND we haven't hit
|
|
5
|
+
* `maxIterations`, route to the tool execution branch (which loops back
|
|
6
|
+
* to PromptBuilder). Otherwise route to the final-branch subflow which
|
|
7
|
+
* persists memory writes and breaks the loop.
|
|
8
|
+
*
|
|
9
|
+
* Emits `agentfootprint.agent.route_decided` with the chosen branch +
|
|
10
|
+
* a human-readable rationale (visible in narrative + observability).
|
|
11
|
+
*
|
|
12
|
+
* Pure function — no closure over Agent class state. Imported and
|
|
13
|
+
* passed directly to `addDeciderFunction(...)` in buildAgentChart.
|
|
14
|
+
*/
|
|
15
|
+
import type { TypedScope } from 'footprintjs';
|
|
16
|
+
import type { AgentState } from '../types.js';
|
|
17
|
+
export type RouteBranch = 'tool-calls' | 'final';
|
|
18
|
+
export declare const routeDeciderStage: (scope: TypedScope<AgentState>) => RouteBranch;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* seed — initial stage of the agent's chart. Initializes every mutable
|
|
3
|
+
* field of `AgentState` from the consumer's input.
|
|
4
|
+
*
|
|
5
|
+
* Runs once per `agent.run({ input })`. The chart is built once at
|
|
6
|
+
* Agent construction, so seed has access to BOTH:
|
|
7
|
+
*
|
|
8
|
+
* • CHART-BUILD-TIME constants (maxIterations, cachingDisabled,
|
|
9
|
+
* toolSchemas) — passed as direct values to the factory.
|
|
10
|
+
* • PER-RUN MUTABLE state (pendingResumeHistory from
|
|
11
|
+
* resumeOnError(), currentRunContext.runId set per run) —
|
|
12
|
+
* passed as accessor closures over the Agent instance, since
|
|
13
|
+
* these change between consecutive `agent.run()` invocations.
|
|
14
|
+
*
|
|
15
|
+
* The accessor pattern keeps `seed` decoupled from the Agent class
|
|
16
|
+
* while preserving the per-run mutability the resume + identity
|
|
17
|
+
* features need.
|
|
18
|
+
*/
|
|
19
|
+
import type { TypedScope } from 'footprintjs';
|
|
20
|
+
import type { LLMMessage, LLMToolSchema } from '../../../adapters/types.js';
|
|
21
|
+
import type { AgentState } from '../types.js';
|
|
22
|
+
export interface SeedStageDeps {
|
|
23
|
+
/** Resolved `clampIterations(opts.maxIterations ?? 10)`. Frozen at
|
|
24
|
+
* chart-build time. */
|
|
25
|
+
readonly maxIterations: number;
|
|
26
|
+
/** Resolved cache kill switch from `Agent.create({ caching: 'off' })`. */
|
|
27
|
+
readonly cachingDisabled: boolean;
|
|
28
|
+
/** Static tool schemas resolved at chart-build time. The tools slot
|
|
29
|
+
* subflow can OVERRIDE this per-iteration via `dynamicToolSchemas`,
|
|
30
|
+
* but seed populates the initial value so iter 1 has it. */
|
|
31
|
+
readonly toolSchemas: readonly LLMToolSchema[];
|
|
32
|
+
/**
|
|
33
|
+
* Read-AND-CLEAR accessor for the resume side-channel. Called exactly
|
|
34
|
+
* once per `agent.run()` from inside seed. If `resumeOnError(checkpoint)`
|
|
35
|
+
* was invoked before `run()`, this returns the checkpointed history
|
|
36
|
+
* and clears the field so the NEXT `run()` starts fresh. Returns
|
|
37
|
+
* `undefined` for the normal (non-resume) path.
|
|
38
|
+
*/
|
|
39
|
+
readonly consumePendingResumeHistory: () => readonly LLMMessage[] | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Accessor for the current run's id, used to default the memory
|
|
42
|
+
* identity when consumer didn't pass `agent.run({ identity })`. Set
|
|
43
|
+
* by RunnerBase on every `agent.run()` call before the chart starts.
|
|
44
|
+
* Returns `undefined` only in degenerate (test) cases.
|
|
45
|
+
*/
|
|
46
|
+
readonly getCurrentRunId: () => string | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the seed stage function for an Agent instance. Captures both
|
|
50
|
+
* the chart-build-time constants and the per-run mutable accessors
|
|
51
|
+
* via the deps object.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildSeedStage(deps: SeedStageDeps): (scope: TypedScope<AgentState>) => void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolCalls — pausable handler for executing the LLM-requested tool
|
|
3
|
+
* calls in the agent's ReAct loop.
|
|
4
|
+
*
|
|
5
|
+
* • `execute` iterates `scope.llmLatestToolCalls`, dispatches each
|
|
6
|
+
* tool, appends results to scope.history, and increments
|
|
7
|
+
* `scope.iteration`. If a tool throws `PauseRequest` (via
|
|
8
|
+
* `pauseHere()`), commits partial state and returns the pause
|
|
9
|
+
* payload so footprintjs captures a checkpoint.
|
|
10
|
+
* • `resume` runs after the consumer supplies the human's answer.
|
|
11
|
+
* Treats that answer as the paused tool's result, appends to
|
|
12
|
+
* history, then continues the ReAct iteration loop.
|
|
13
|
+
*
|
|
14
|
+
* Dispatch resolution order:
|
|
15
|
+
* 1. Static registry built at chart-build time (registryByName).
|
|
16
|
+
* 2. External `ToolProvider.list(ctx).find(...)` if a `.toolProvider()`
|
|
17
|
+
* was wired and the tool isn't in the static registry.
|
|
18
|
+
*
|
|
19
|
+
* Permission gate (when `permissionChecker` is configured) runs BEFORE
|
|
20
|
+
* `tool.execute`. Deny → tool not executed; result is a synthetic
|
|
21
|
+
* denial string. Allow / gate_open → execution proceeds.
|
|
22
|
+
*
|
|
23
|
+
* `read_skill` is the auto-attached activation tool — when the LLM
|
|
24
|
+
* calls it with a valid Skill id, the next InjectionEngine pass
|
|
25
|
+
* activates that Skill (lifetime: turn).
|
|
26
|
+
*/
|
|
27
|
+
import type { PausableHandler, TypedScope } from 'footprintjs';
|
|
28
|
+
import type { PermissionChecker } from '../../../adapters/types.js';
|
|
29
|
+
import type { ToolProvider } from '../../../tool-providers/types.js';
|
|
30
|
+
import type { CredentialProvider } from '../../../identity/types.js';
|
|
31
|
+
import type { ProviderToolCache } from '../../slots/buildToolsSlot.js';
|
|
32
|
+
import type { Tool } from '../../tools.js';
|
|
33
|
+
import { type ToolArgValidationMode } from '../toolArgsValidation.js';
|
|
34
|
+
import type { AgentState } from '../types.js';
|
|
35
|
+
export interface ToolCallsHandlerDeps {
|
|
36
|
+
/** Map from tool name → Tool instance, built from the augmented
|
|
37
|
+
* registry (static .tool() entries + read_skill if any skills +
|
|
38
|
+
* shared skill tools). The dispatch primary lookup. */
|
|
39
|
+
readonly registryByName: ReadonlyMap<string, Tool>;
|
|
40
|
+
/** Optional external `.toolProvider()` for per-iteration dynamic
|
|
41
|
+
* tools (skill-scoped, multi-tenant, etc.). Consulted only when
|
|
42
|
+
* the static registry doesn't have the tool. */
|
|
43
|
+
readonly externalToolProvider?: ToolProvider;
|
|
44
|
+
/**
|
|
45
|
+
* Cache populated by `buildToolsSlot` after each `provider.list(ctx)`
|
|
46
|
+
* call this iteration. Read here to avoid a second `list()` call
|
|
47
|
+
* (vital for async / network-backed providers). Same closure shared
|
|
48
|
+
* within one chart build.
|
|
49
|
+
*/
|
|
50
|
+
readonly providerToolCache?: ProviderToolCache;
|
|
51
|
+
/** Optional permission gate. When present, every tool dispatch
|
|
52
|
+
* awaits `check({capability: 'tool_call', ...})` BEFORE executing.
|
|
53
|
+
* Throwing checkers are treated as deny-by-default. */
|
|
54
|
+
readonly permissionChecker?: PermissionChecker;
|
|
55
|
+
/** Optional credential provider (declare-and-push). When present, a tool's
|
|
56
|
+
* declared `needs` is resolved BEFORE execute and injected as `ctx.credential`;
|
|
57
|
+
* `ctx.credentials` exposes it for the pull escape hatch. */
|
|
58
|
+
readonly credentialProvider?: CredentialProvider;
|
|
59
|
+
/** Tool-args validation mode (#9). Default 'enforce': LLM-produced args
|
|
60
|
+
* are checked against the tool's `inputSchema` BEFORE dispatch; a
|
|
61
|
+
* mismatch rejects the call with a model-visible retry message.
|
|
62
|
+
* 'warn' emits the event but executes anyway; 'off' skips validation. */
|
|
63
|
+
readonly toolArgValidation?: ToolArgValidationMode;
|
|
64
|
+
/**
|
|
65
|
+
* Skill-graph read_skill GATE (`graph.reachableSkills`). When present, a
|
|
66
|
+
* `read_skill('id')` whose `id` is not reachable from the current cursor is
|
|
67
|
+
* REJECTED — the model gets a synthetic re-prompt naming the allowed ids and
|
|
68
|
+
* the cursor/activations stay unchanged, so it can't leave the graph mid-run.
|
|
69
|
+
* Undefined → no gate (plain read_skill agents append as before).
|
|
70
|
+
*/
|
|
71
|
+
readonly allowedSkillIds?: (currentSkillId?: string) => readonly string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the pausable tool-call handler for the agent's chart.
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildToolCallsHandler(deps: ToolCallsHandlerDeps): PausableHandler<TypedScope<AgentState>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolArgsValidation — validate LLM-produced tool args against the tool's
|
|
3
|
+
* declared `inputSchema` BEFORE dispatch (backlog #9).
|
|
4
|
+
*
|
|
5
|
+
* Pattern: pure function module — no state, no events; the toolCalls stage
|
|
6
|
+
* owns when to call it and what to do with the verdict.
|
|
7
|
+
* Role: The model writes tool args as free-form JSON; nothing guaranteed
|
|
8
|
+
* they match the schema the tool advertised. Dispatching garbage
|
|
9
|
+
* surfaced as deep tool stack traces (or worse, silent misbehavior).
|
|
10
|
+
* Validating at the boundary turns a malformed call into a
|
|
11
|
+
* MODEL-VISIBLE structured tool result, so the LLM corrects its
|
|
12
|
+
* args and retries on the next ReAct iteration.
|
|
13
|
+
*
|
|
14
|
+
* ── Honest-subset contract ────────────────────────────────────────────────
|
|
15
|
+
* This is NOT a full JSON Schema implementation. It enforces the core that
|
|
16
|
+
* tool schemas in the wild actually use, and IGNORES everything else
|
|
17
|
+
* (permissive on unknown keywords — a schema using `pattern`/`oneOf`/`$ref`
|
|
18
|
+
* still validates the supported core, never false-rejects on the rest):
|
|
19
|
+
*
|
|
20
|
+
* ENFORCED: `type` (object/array/string/number/integer/boolean/null,
|
|
21
|
+
* union arrays), `required`, `properties` (recursive),
|
|
22
|
+
* `items` (single-schema, recursive), `enum` (primitives),
|
|
23
|
+
* `additionalProperties: false` ONLY when explicitly set.
|
|
24
|
+
* IGNORED: format, pattern, min/max*, oneOf/anyOf/allOf/not, $ref,
|
|
25
|
+
* const, dependencies, …
|
|
26
|
+
*
|
|
27
|
+
* ── Security: never echo VALUES ───────────────────────────────────────────
|
|
28
|
+
* Issues name the PATH, the EXPECTED shape, and the TYPE of what arrived —
|
|
29
|
+
* never the supplied value itself. The message flows into history (LLM),
|
|
30
|
+
* the emit channel, and traces; arg values can carry PII or injection
|
|
31
|
+
* payloads. Enum expectations echo SCHEMA values only (already LLM-visible
|
|
32
|
+
* in the tools block).
|
|
33
|
+
*/
|
|
34
|
+
/** When to enforce: 'enforce' rejects before dispatch (default), 'warn'
|
|
35
|
+
* emits the event but executes anyway, 'off' skips validation entirely. */
|
|
36
|
+
export type ToolArgValidationMode = 'enforce' | 'warn' | 'off';
|
|
37
|
+
/** One schema violation. `got` is a TYPE NAME, never a value. */
|
|
38
|
+
export interface ToolArgIssue {
|
|
39
|
+
/** Dot/bracket path from the args root, '' for the root itself. */
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly expected: string;
|
|
42
|
+
readonly got: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ToolArgValidationResult {
|
|
45
|
+
readonly ok: boolean;
|
|
46
|
+
readonly issues: readonly ToolArgIssue[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate tool-call args against the tool's `inputSchema`.
|
|
50
|
+
*
|
|
51
|
+
* Total function: a malformed/exotic SCHEMA never throws — anything outside
|
|
52
|
+
* the honest subset is ignored, so the worst a bad schema can do is
|
|
53
|
+
* under-validate (never block a legitimate call).
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateToolArgs(args: unknown, inputSchema: Readonly<Record<string, unknown>> | undefined): ToolArgValidationResult;
|
|
56
|
+
/**
|
|
57
|
+
* Render the MODEL-VISIBLE tool result for a rejected call. Names paths,
|
|
58
|
+
* expectations, and received TYPES — never received values. The model
|
|
59
|
+
* already has the full schema in its tools block; pointing at the issues
|
|
60
|
+
* is what makes the retry converge.
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatToolArgIssues(toolName: string, issues: readonly ToolArgIssue[]): string;
|