agentfootprint 6.44.0 → 7.0.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/AGENTS.md +4 -0
- package/CLAUDE.md +4 -0
- package/README.md +141 -167
- package/ai-instructions/claude-code/SKILL.md +11 -0
- package/ai-instructions/setup.sh +0 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/adapters/llm/MockProvider.js +2 -1
- package/dist/adapters/llm/MockProvider.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/debug/finders.js +29 -0
- package/dist/debug/finders.js.map +1 -0
- package/dist/debug.js +134 -0
- package/dist/debug.js.map +1 -0
- 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/BrowserOpenAIProvider.js +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +154 -0
- package/dist/esm/adapters/llm/MockProvider.js +2 -1
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/debug/finders.d.ts +12 -0
- package/dist/esm/debug/finders.js +13 -0
- package/dist/esm/debug/finders.js.map +1 -0
- package/dist/esm/debug.d.ts +25 -0
- package/dist/esm/debug.js +54 -0
- package/dist/esm/debug.js.map +1 -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/events.d.ts +18 -0
- package/dist/esm/events.js +22 -0
- package/dist/esm/events.js.map +1 -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 +44 -0
- package/dist/esm/index.js +7 -52
- 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 +2 -1
- 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 +290 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +38 -43
- 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/defineRAG.js +3 -3
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +106 -0
- package/dist/esm/lib/rag/indexDocuments.js +2 -1
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- 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 +141 -0
- package/dist/esm/locales/index.js +7 -0
- package/dist/esm/locales/index.js.map +1 -1
- 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 +134 -0
- package/dist/esm/memory/causal/types.js.map +1 -1
- 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 +278 -0
- package/dist/esm/memory/define.types.js +6 -4
- package/dist/esm/memory/define.types.js.map +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 +57 -0
- package/dist/esm/observe.js +7 -36
- 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/providers.js +1 -1
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +54 -0
- package/dist/esm/status.js +13 -4
- package/dist/esm/status.js.map +1 -1
- 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/events.js +42 -0
- package/dist/events.js.map +1 -0
- package/dist/index.js +7 -117
- 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 +6 -2
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +40 -45
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/rag/defineRAG.js +3 -3
- package/dist/lib/rag/indexDocuments.js +2 -1
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/locales/index.js +2 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/memory/causal/types.js.map +1 -1
- package/dist/memory/define.types.js +6 -4
- package/dist/memory/define.types.js.map +1 -1
- package/dist/observe.js +22 -115
- package/dist/observe.js.map +1 -1
- package/dist/providers.js +3 -1
- package/dist/providers.js.map +1 -1
- package/dist/status.js +13 -5
- package/dist/status.js.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/MockProvider.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/debug/finders.d.ts +13 -0
- package/dist/types/debug/finders.d.ts.map +1 -0
- package/dist/types/debug.d.ts +26 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/events.d.ts +19 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -24
- 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 +2 -1
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +24 -26
- 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/lib/rag/defineRAG.d.ts +3 -3
- package/dist/types/lib/rag/indexDocuments.d.ts +2 -1
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/locales/index.d.ts +9 -0
- package/dist/types/locales/index.d.ts.map +1 -1
- package/dist/types/memory/causal/types.d.ts +13 -9
- package/dist/types/memory/causal/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +6 -4
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/observe.d.ts +1 -6
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/providers.d.ts +2 -2
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/status.d.ts +10 -4
- package/dist/types/status.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +1 -1
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +261 -57
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAIThinkingHandler — normalizes OpenAI's o1/o3 reasoning_summary
|
|
3
|
+
* structured output into the framework's `ThinkingBlock[]` contract.
|
|
4
|
+
*
|
|
5
|
+
* OpenAI's reasoning_summary shape varies by model + API version:
|
|
6
|
+
*
|
|
7
|
+
* 1. Older o1 format — simple string:
|
|
8
|
+
* "I worked through the problem by first..."
|
|
9
|
+
*
|
|
10
|
+
* 2. Newer o3+ structured — array of summary items:
|
|
11
|
+
* [
|
|
12
|
+
* { type: 'summary_text', text: 'Identify the user request' },
|
|
13
|
+
* { type: 'summary_text', text: 'Choose appropriate tool' },
|
|
14
|
+
* ]
|
|
15
|
+
*
|
|
16
|
+
* 3. Missing entirely — most calls (gpt-4o, or o1/o3 without
|
|
17
|
+
* reasoning_summary param requested) → undefined raw input
|
|
18
|
+
*
|
|
19
|
+
* Handler dispatches on shape; output is `ThinkingBlock[]` with
|
|
20
|
+
* `summary: true` per Phase 1 contract — distinguishes structured-
|
|
21
|
+
* summary blocks from raw thinking content (Anthropic's shape).
|
|
22
|
+
*
|
|
23
|
+
* **No signature** — OpenAI doesn't sign reasoning. The output's
|
|
24
|
+
* `signature` field stays undefined. No round-trip integrity invariant
|
|
25
|
+
* (unlike Anthropic).
|
|
26
|
+
*
|
|
27
|
+
* **No `parseChunk`** — OpenAI doesn't stream reasoning content as of
|
|
28
|
+
* early 2026. Reasoning arrives only on the terminal response. Per
|
|
29
|
+
* Phase 1 design, `parseChunk` is optional; we omit entirely.
|
|
30
|
+
*
|
|
31
|
+
* **No `usage.thinking` computation** — reasoning_tokens lives on
|
|
32
|
+
* `response.usage.completion_tokens_details.reasoning_tokens` and is
|
|
33
|
+
* the OpenAIProvider's job to surface (deferred). Handler doesn't
|
|
34
|
+
* compute token counts.
|
|
35
|
+
*/
|
|
36
|
+
import type { ThinkingHandler } from './types.js';
|
|
37
|
+
export declare const openAIThinkingHandler: ThinkingHandler;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/thinking — extended-thinking subsystem (v2.14+).
|
|
3
|
+
*
|
|
4
|
+
* **Two-layer architecture:**
|
|
5
|
+
*
|
|
6
|
+
* • CONSUMER-FACING: `ThinkingHandler` — simple function-pair
|
|
7
|
+
* implemented by provider authors.
|
|
8
|
+
* • FRAMEWORK-INTERNAL: each handler is auto-wrapped in a real
|
|
9
|
+
* footprintjs subflow at chart build time;
|
|
10
|
+
* shows in trace as own runtimeStageId.
|
|
11
|
+
*
|
|
12
|
+
* **Auto-wire by provider name:**
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Agent } from 'agentfootprint';
|
|
16
|
+
*
|
|
17
|
+
* // Library scans SHIPPED_THINKING_HANDLERS, finds the handler
|
|
18
|
+
* // whose providerNames includes provider.name. Mounted as a
|
|
19
|
+
* // sub-subflow of sf-call-llm.
|
|
20
|
+
* const agent = Agent.create({ provider: anthropic({...}), model: '...' })
|
|
21
|
+
* .build();
|
|
22
|
+
*
|
|
23
|
+
* // Opt out:
|
|
24
|
+
* // .thinkingHandler(undefined)
|
|
25
|
+
* // Override with a custom handler:
|
|
26
|
+
* // .thinkingHandler(myCustomHandler)
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* **Custom handlers:**
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { type ThinkingHandler } from 'agentfootprint/thinking';
|
|
33
|
+
*
|
|
34
|
+
* export const geminiThinkingHandler: ThinkingHandler = {
|
|
35
|
+
* id: 'gemini',
|
|
36
|
+
* providerNames: ['gemini'],
|
|
37
|
+
* normalize(raw) { ... },
|
|
38
|
+
* parseChunk(chunk) { ... }, // optional
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Failure isolation: handler `normalize()` throws are caught by the
|
|
43
|
+
* framework — emit `agentfootprint.agent.thinking_parse_failed`, drop
|
|
44
|
+
* the blocks, continue. Same graceful pattern as v2.11.6
|
|
45
|
+
* `tools.discovery_failed`.
|
|
46
|
+
*/
|
|
47
|
+
export type { ThinkingBlock, ThinkingHandler } from './types.js';
|
|
48
|
+
export { mockThinkingHandler, mockAnthropicRaw, mockOpenAIRaw } from './MockThinkingHandler.js';
|
|
49
|
+
export { anthropicThinkingHandler } from './AnthropicThinkingHandler.js';
|
|
50
|
+
export { openAIThinkingHandler } from './OpenAIThinkingHandler.js';
|
|
51
|
+
export { SHIPPED_THINKING_HANDLERS, findThinkingHandler } from './registry.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry — single source of truth for the framework's auto-wire
|
|
3
|
+
* logic AND the shared contract test.
|
|
4
|
+
*
|
|
5
|
+
* Phase 3 wiring scans this array at chart build time and selects the
|
|
6
|
+
* first handler whose `providerNames` includes the active
|
|
7
|
+
* `provider.name`. Phase 4a adds AnthropicThinkingHandler; Phase 5
|
|
8
|
+
* adds OpenAIThinkingHandler — append-only as new providers ship.
|
|
9
|
+
*
|
|
10
|
+
* Future provider authors:
|
|
11
|
+
* • Implement `ThinkingHandler` for your provider
|
|
12
|
+
* • Append to this array
|
|
13
|
+
* • The shared contract test in `test/thinking/contract.test.ts`
|
|
14
|
+
* verifies your handler honors the framework's invariants
|
|
15
|
+
*/
|
|
16
|
+
import type { ThinkingHandler } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* All thinking handlers shipped with the library. Append in alphabetical
|
|
19
|
+
* order (by `id`) so diffs stay readable as new handlers land.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SHIPPED_THINKING_HANDLERS: readonly ThinkingHandler[];
|
|
22
|
+
/**
|
|
23
|
+
* Look up a handler by `provider.name`. Returns the first match in
|
|
24
|
+
* `SHIPPED_THINKING_HANDLERS`. Returns `undefined` when no handler
|
|
25
|
+
* matches — framework treats this as "no thinking support for this
|
|
26
|
+
* provider", which is the correct default for providers that don't
|
|
27
|
+
* emit thinking content (gpt-3.5, mistral, etc.).
|
|
28
|
+
*
|
|
29
|
+
* Used by:
|
|
30
|
+
* • Phase 3 framework auto-wire (chart build time)
|
|
31
|
+
* • Tests verifying registry lookup
|
|
32
|
+
*/
|
|
33
|
+
export declare function findThinkingHandler(providerName: string): ThinkingHandler | undefined;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking — public types for the v2.14 extended-thinking subsystem.
|
|
3
|
+
*
|
|
4
|
+
* Mental model — TWO-LAYER architecture:
|
|
5
|
+
*
|
|
6
|
+
* • CONSUMER-FACING: `ThinkingHandler` — a simple function-pair
|
|
7
|
+
* (id, providerNames, normalize, parseChunk?).
|
|
8
|
+
* Provider authors and custom-LLM consumers
|
|
9
|
+
* implement THIS shape.
|
|
10
|
+
*
|
|
11
|
+
* • FRAMEWORK-INTERNAL: each `ThinkingHandler` is auto-wrapped in a
|
|
12
|
+
* real footprintjs subflow at chart build time.
|
|
13
|
+
* The subflow gets its own `runtimeStageId`,
|
|
14
|
+
* narrative entry, and InOutRecorder boundary
|
|
15
|
+
* — full trace observability for free without
|
|
16
|
+
* the consumer writing flowchart code.
|
|
17
|
+
*
|
|
18
|
+
* Same pattern as how consumers write a `Tool` and the framework wraps
|
|
19
|
+
* dispatch in a tool-call subflow, or how consumers write a
|
|
20
|
+
* `ToolProvider` and the framework wraps `list()` in the Tools slot
|
|
21
|
+
* subflow.
|
|
22
|
+
*
|
|
23
|
+
* @see SHIPPED_THINKING_HANDLERS for the registry the framework uses
|
|
24
|
+
* to auto-wire by `provider.name` (Phase 3 wiring).
|
|
25
|
+
* @see MockThinkingHandler for the canonical example demonstrating
|
|
26
|
+
* both Anthropic-shape (signed blocks) and OpenAI-shape (multi-
|
|
27
|
+
* block summary) inputs.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* One thinking block from an LLM response, normalized into a provider-
|
|
31
|
+
* agnostic shape. A response may contain multiple blocks (e.g. OpenAI's
|
|
32
|
+
* structured reasoning_summary emits one block per summary step).
|
|
33
|
+
*
|
|
34
|
+
* Discriminator `type`:
|
|
35
|
+
* - `'thinking'` — content is the model's reasoning
|
|
36
|
+
* - `'redacted_thinking'` — Anthropic emits this when reasoning
|
|
37
|
+
* trips a safety filter; content is
|
|
38
|
+
* EMPTY but `signature` is still required
|
|
39
|
+
* for round-trip on the next turn
|
|
40
|
+
*/
|
|
41
|
+
export interface ThinkingBlock {
|
|
42
|
+
/**
|
|
43
|
+
* Block type discriminator. Required so consumers can distinguish
|
|
44
|
+
* normal thinking blocks from server-redacted ones (Anthropic-only
|
|
45
|
+
* today; other providers may produce only `'thinking'`).
|
|
46
|
+
*/
|
|
47
|
+
readonly type: 'thinking' | 'redacted_thinking';
|
|
48
|
+
/**
|
|
49
|
+
* Reasoning content as plain text. EMPTY string when `type ===
|
|
50
|
+
* 'redacted_thinking'` (the model's reasoning was redacted by the
|
|
51
|
+
* provider's safety layer; only the signature remains).
|
|
52
|
+
*/
|
|
53
|
+
readonly content: string;
|
|
54
|
+
/**
|
|
55
|
+
* Provider cryptographic signature for round-trip integrity.
|
|
56
|
+
*
|
|
57
|
+
* **Anthropic:** REQUIRED for any block emitted in a response that
|
|
58
|
+
* also contained tool_use. The signed block MUST be echoed
|
|
59
|
+
* byte-exact in the assistant message of subsequent tool_result
|
|
60
|
+
* turns — Anthropic validates the signature server-side and rejects
|
|
61
|
+
* (HTTP 400) requests where signed blocks are missing or modified.
|
|
62
|
+
*
|
|
63
|
+
* **OpenAI:** not used (their reasoning_summary doesn't sign blocks).
|
|
64
|
+
*
|
|
65
|
+
* **Future providers:** opaque to the framework; preserved as-is.
|
|
66
|
+
*
|
|
67
|
+
* The framework persists this field in `scope.history` so the
|
|
68
|
+
* provider's serialization layer (Phase 4b) can echo it back on the
|
|
69
|
+
* next request.
|
|
70
|
+
*/
|
|
71
|
+
readonly signature?: string;
|
|
72
|
+
/**
|
|
73
|
+
* `true` when this block is a structured-summary step rather than
|
|
74
|
+
* raw thinking content. Set by `OpenAIThinkingHandler` for each step
|
|
75
|
+
* of `reasoning_summary`; never set by Anthropic. Consumers
|
|
76
|
+
* displaying thinking can render summary blocks differently
|
|
77
|
+
* (e.g. as numbered steps) from raw blocks (continuous prose).
|
|
78
|
+
*/
|
|
79
|
+
readonly summary?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Provider-specific metadata escape hatch for fields the normalized
|
|
82
|
+
* shape doesn't model.
|
|
83
|
+
*
|
|
84
|
+
* **ANTI-PATTERN:** providers MUST NOT include sensitive raw data
|
|
85
|
+
* here (PII, internal IDs, request tokens, customer data). Use the
|
|
86
|
+
* dedicated `signature` field for cryptographic material; nothing
|
|
87
|
+
* else identity-bearing. The framework excludes `providerMeta` from
|
|
88
|
+
* `getNarrative()` by default to avoid accidental audit-log leakage.
|
|
89
|
+
*/
|
|
90
|
+
readonly providerMeta?: Readonly<Record<string, unknown>>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The consumer-facing contract for thinking normalization. Provider
|
|
94
|
+
* authors and custom-LLM consumers implement this shape; the framework
|
|
95
|
+
* auto-wraps each handler in a real footprintjs subflow at chart build
|
|
96
|
+
* time so the trace shows it as a discrete `runtimeStageId` (e.g.
|
|
97
|
+
* `sf-call-llm/thinking-{id}#5`).
|
|
98
|
+
*
|
|
99
|
+
* The framework matches handlers to providers by `providerNames` —
|
|
100
|
+
* the first handler whose `providerNames` includes the active
|
|
101
|
+
* `provider.name` is auto-wired. Override per-agent via
|
|
102
|
+
* `.thinkingHandler(customHandler)` (Phase 3 wiring).
|
|
103
|
+
*/
|
|
104
|
+
export interface ThinkingHandler {
|
|
105
|
+
/**
|
|
106
|
+
* Stable identifier used for `runtimeStageId`, telemetry, narrative
|
|
107
|
+
* entries, and the `agentfootprint.agent.thinking_parse_failed` event
|
|
108
|
+
* payload's `subflowId` field. Convention: lowercase + dash, e.g.
|
|
109
|
+
* `'anthropic'`, `'openai'`, `'mock'`.
|
|
110
|
+
*/
|
|
111
|
+
readonly id: string;
|
|
112
|
+
/**
|
|
113
|
+
* Provider names this handler matches for auto-wire. The framework
|
|
114
|
+
* scans `SHIPPED_THINKING_HANDLERS` at chart build time and selects
|
|
115
|
+
* the first handler whose `providerNames` contains the active
|
|
116
|
+
* `provider.name`. Most handlers list one name; Bedrock-via-Anthropic
|
|
117
|
+
* style handlers may list multiple.
|
|
118
|
+
*/
|
|
119
|
+
readonly providerNames: readonly string[];
|
|
120
|
+
/**
|
|
121
|
+
* Pure: raw provider data → normalized blocks.
|
|
122
|
+
*
|
|
123
|
+
* The framework wraps this call in a try/catch — throwing from
|
|
124
|
+
* `normalize()` does NOT abort the agent run. Instead the framework
|
|
125
|
+
* emits `agentfootprint.agent.thinking_parse_failed`, drops the
|
|
126
|
+
* thinking blocks (LLMMessage.thinkingBlocks remains undefined),
|
|
127
|
+
* and continues. Same graceful-failure pattern as v2.11.6
|
|
128
|
+
* `tools.discovery_failed`.
|
|
129
|
+
*
|
|
130
|
+
* Sync only in v2.14. Future widening to Promise return is a
|
|
131
|
+
* separate decision once a real consumer needs network-backed
|
|
132
|
+
* normalization.
|
|
133
|
+
*
|
|
134
|
+
* @param raw Provider-specific raw data — typically pulled from
|
|
135
|
+
* `LLMResponse.providerRef`. Handler is responsible for
|
|
136
|
+
* shape-checking; framework passes whatever the provider
|
|
137
|
+
* stashed.
|
|
138
|
+
* @returns Normalized blocks in the order they appeared in the
|
|
139
|
+
* response. Empty array when no thinking is present
|
|
140
|
+
* (preferred over `undefined` for type stability).
|
|
141
|
+
*/
|
|
142
|
+
normalize(raw: unknown): readonly ThinkingBlock[];
|
|
143
|
+
/**
|
|
144
|
+
* Optional streaming hot-path. When provided AND the provider streams,
|
|
145
|
+
* the framework calls `parseChunk(chunk)` per provider chunk and
|
|
146
|
+
* emits `agentfootprint.stream.thinking_delta` events for any
|
|
147
|
+
* `thinkingDelta` returned. Handlers without streaming support omit
|
|
148
|
+
* this field; the framework still calls `normalize()` on the
|
|
149
|
+
* response's terminal `LLMResponse.providerRef`.
|
|
150
|
+
*
|
|
151
|
+
* @param chunk Provider-specific chunk shape (Anthropic emits
|
|
152
|
+
* `content_block_delta` events; OpenAI doesn't yet
|
|
153
|
+
* stream reasoning content).
|
|
154
|
+
* @returns Object with optional `thinkingDelta` text — when set,
|
|
155
|
+
* framework fires `stream.thinking_delta` event with the
|
|
156
|
+
* content. Return `{}` (or omit) for chunks that contain
|
|
157
|
+
* no thinking content.
|
|
158
|
+
*/
|
|
159
|
+
parseChunk?(chunk: unknown): {
|
|
160
|
+
thinkingDelta?: string;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gatedTools — wrap any ToolProvider with a per-tool gating predicate.
|
|
3
|
+
*
|
|
4
|
+
* The DECORATOR for tool providers. Filters the inner provider's
|
|
5
|
+
* output by running the predicate against each tool name. Composes
|
|
6
|
+
* freely:
|
|
7
|
+
*
|
|
8
|
+
* gatedTools(
|
|
9
|
+
* gatedTools(staticTools(allTools), readOnlyPredicate),
|
|
10
|
+
* skillGatePredicate,
|
|
11
|
+
* )
|
|
12
|
+
*
|
|
13
|
+
* Reads as: "static list of all tools, filtered by readonly policy,
|
|
14
|
+
* then further filtered by the active skill's tool set." Each gate
|
|
15
|
+
* is one concern; composition handles the rest.
|
|
16
|
+
*
|
|
17
|
+
* Pattern: Decorator (GoF) — wraps any ToolProvider with an additional
|
|
18
|
+
* filter. Mirrors `withRetry` / `withFallback` over LLMProvider.
|
|
19
|
+
*
|
|
20
|
+
* @example Read-only enforcement
|
|
21
|
+
* const readOnly = gatedTools(
|
|
22
|
+
* staticTools([read, write]),
|
|
23
|
+
* (toolName) => toolName.startsWith('read_'),
|
|
24
|
+
* );
|
|
25
|
+
* readOnly.list(ctx); // → [read]
|
|
26
|
+
*
|
|
27
|
+
* @example Skill-gated dispatch (autoActivate use case)
|
|
28
|
+
* const skillGated = gatedTools(
|
|
29
|
+
* staticTools(allTools),
|
|
30
|
+
* (toolName, ctx) => ctx.activeSkillId
|
|
31
|
+
* ? skillToolMap[ctx.activeSkillId].includes(toolName)
|
|
32
|
+
* : alwaysVisible.includes(toolName),
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
import type { ToolProvider, ToolGatePredicate } from './types.js';
|
|
36
|
+
export declare function gatedTools(inner: ToolProvider, predicate: ToolGatePredicate): ToolProvider;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/tool-providers — chainable tool dispatch + tool sources.
|
|
3
|
+
*
|
|
4
|
+
* Two layers under one subpath:
|
|
5
|
+
*
|
|
6
|
+
* 1. Tool dispatch (this folder)
|
|
7
|
+
* - `staticTools(arr)` — wrap a flat tool list
|
|
8
|
+
* - `gatedTools(inner, predicate)` — decorator that filters
|
|
9
|
+
* - `ToolProvider` interface — the contract
|
|
10
|
+
* - `ToolDispatchContext` — read-only context per iteration
|
|
11
|
+
*
|
|
12
|
+
* 2. Tool sources (re-exported from existing modules)
|
|
13
|
+
* - `mcpClient(opts)` — connect to an MCP server (real)
|
|
14
|
+
* - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests
|
|
15
|
+
*
|
|
16
|
+
* Compose freely. The dispatch layer is decorator-shaped (mirroring
|
|
17
|
+
* `withRetry` / `withFallback` over LLMProvider). Tool sources produce
|
|
18
|
+
* `Tool[]` that flow into a `staticTools(arr)` provider, which can
|
|
19
|
+
* then be wrapped by `gatedTools(...)` for permission gating or
|
|
20
|
+
* per-skill filtering.
|
|
21
|
+
*
|
|
22
|
+
* @example Static (90% case — what `agent.tools(arr)` does today)
|
|
23
|
+
* const provider = staticTools([weatherTool, lookupTool]);
|
|
24
|
+
*
|
|
25
|
+
* @example Read-only enforcement
|
|
26
|
+
* const readOnly = gatedTools(
|
|
27
|
+
* staticTools(allTools),
|
|
28
|
+
* (name) => policy.isAllowed(name),
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* @example MCP source + permission gate
|
|
32
|
+
* const slack = await mcpClient({ transport: ... });
|
|
33
|
+
* const slackTools = await slack.tools();
|
|
34
|
+
* const provider = gatedTools(staticTools(slackTools), (name) => allowed(name));
|
|
35
|
+
*/
|
|
36
|
+
export { staticTools } from './staticTools.js';
|
|
37
|
+
export { gatedTools } from './gatedTools.js';
|
|
38
|
+
export { skillScopedTools } from './skillScopedTools.js';
|
|
39
|
+
export type { ToolProvider, ToolDispatchContext, ToolGatePredicate } from './types.js';
|
|
40
|
+
export { mcpClient, mockMcpClient } from '../lib/mcp/index.js';
|
|
41
|
+
export type { McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, MockMcpClientOptions, MockMcpTool, } from '../lib/mcp/index.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* skillScopedTools — ToolProvider that exposes a tool subset only when
|
|
3
|
+
* a specific Skill is active in the current iteration's context.
|
|
4
|
+
*
|
|
5
|
+
* The Block A5 piece. Pairs with `defineSkill({ autoActivate: 'currentSkill' })`
|
|
6
|
+
* to give the LLM a sharper choice space: when `billing` activates, the
|
|
7
|
+
* tool list flips from "all 25 agent tools" to "the 7 billing tools" +
|
|
8
|
+
* any baseline (always-on) tools the consumer composes alongside.
|
|
9
|
+
*
|
|
10
|
+
* Pattern: gated ToolProvider keyed by `ctx.activeSkillId`. Pure compute;
|
|
11
|
+
* no Agent-runtime dependency. Composes freely with `staticTools`
|
|
12
|
+
* for the always-on baseline.
|
|
13
|
+
*
|
|
14
|
+
* @example One skill's tools, scoped by activation
|
|
15
|
+
* const billingTools = skillScopedTools('billing', [refundTool, chargeTool]);
|
|
16
|
+
* billingTools.list({ iteration: 1, activeSkillId: 'billing' });
|
|
17
|
+
* // → [refundTool, chargeTool]
|
|
18
|
+
* billingTools.list({ iteration: 1, activeSkillId: 'refund' });
|
|
19
|
+
* // → [] (different skill active)
|
|
20
|
+
* billingTools.list({ iteration: 1 });
|
|
21
|
+
* // → [] (no skill active)
|
|
22
|
+
*
|
|
23
|
+
* @example Compose with baseline + multiple skills
|
|
24
|
+
* const baseline = staticTools([lookupOrderTool, listSkills, readSkill]);
|
|
25
|
+
* const billingTbx = skillScopedTools('billing', [refundTool, chargeTool]);
|
|
26
|
+
* const refundTbx = skillScopedTools('refund', [reverseTool]);
|
|
27
|
+
*
|
|
28
|
+
* // Wrap each scope-provider in a gatedTools for downstream composition,
|
|
29
|
+
* // OR build a small wrapper that concatenates list(ctx) outputs:
|
|
30
|
+
* const provider: ToolProvider = {
|
|
31
|
+
* id: 'composite',
|
|
32
|
+
* list: (ctx) => [
|
|
33
|
+
* ...baseline.list(ctx),
|
|
34
|
+
* ...billingTbx.list(ctx),
|
|
35
|
+
* ...refundTbx.list(ctx),
|
|
36
|
+
* ],
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* Note: the runtime that POPULATES `ctx.activeSkillId` from
|
|
40
|
+
* `scope.activatedInjectionIds` lands in Block C / v2.5+. Today,
|
|
41
|
+
* consumers can drive it manually for tests + design-time inspection.
|
|
42
|
+
*/
|
|
43
|
+
import type { Tool } from '../core/tools.js';
|
|
44
|
+
import type { ToolProvider } from './types.js';
|
|
45
|
+
export declare function skillScopedTools(skillId: string, tools: readonly Tool[]): ToolProvider;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* staticTools — the simplest ToolProvider. Wraps a fixed Tool[] list.
|
|
3
|
+
*
|
|
4
|
+
* 90% case. What `agent.tools(arr)` does today, made composable.
|
|
5
|
+
* Equivalent to passing `arr` directly EXCEPT that `staticTools(arr)`
|
|
6
|
+
* is now a `ToolProvider` you can wrap with `gatedTools(...)` for
|
|
7
|
+
* permission filtering or per-skill gating.
|
|
8
|
+
*
|
|
9
|
+
* Pattern: identity ToolProvider — no filtering, just exposes the
|
|
10
|
+
* underlying list verbatim.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const provider = staticTools([weatherTool, lookupTool]);
|
|
14
|
+
* // Materialize the visible list and register via .tools(...).
|
|
15
|
+
* // Direct .toolProvider(...) wiring on the builder lands in Block A5 / v2.5+.
|
|
16
|
+
* const visible = provider.list({ iteration: 0, identity: { conversationId: '_' } });
|
|
17
|
+
* const agent = Agent.create({ provider: llm, model }).tools(visible).build();
|
|
18
|
+
*/
|
|
19
|
+
import type { Tool } from '../core/tools.js';
|
|
20
|
+
import type { ToolProvider } from './types.js';
|
|
21
|
+
export declare function staticTools(tools: readonly Tool[]): ToolProvider;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolProvider — abstraction over tool dispatch.
|
|
3
|
+
*
|
|
4
|
+
* v2.4 shipped tools as a flat array on the agent (registered via
|
|
5
|
+
* `agent.tool(t)` / `agent.tools(arr)`). That model breaks down once
|
|
6
|
+
* production agents need:
|
|
7
|
+
* 1. Permission gating per-tool, per-caller (read-only roles, etc.)
|
|
8
|
+
* 2. Per-skill tool gating (only show the active skill's tools to
|
|
9
|
+
* the LLM each turn)
|
|
10
|
+
* 3. Composable filters (a `withReadonly` decorator over a `withSkill`
|
|
11
|
+
* decorator over the base tool list)
|
|
12
|
+
*
|
|
13
|
+
* `ToolProvider` is the answer: a chainable abstraction over "what
|
|
14
|
+
* tools does the LLM see right now?". The agent asks the provider
|
|
15
|
+
* each iteration; the provider returns the visible tool set computed
|
|
16
|
+
* from whatever predicates / role gates / skill filters the consumer
|
|
17
|
+
* composed.
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Strategy (GoF) — each ToolProvider is a strategy for
|
|
20
|
+
* "compute the visible tool list given current context".
|
|
21
|
+
* Decorator (GoF) — `gatedTools(inner, predicate)` wraps any
|
|
22
|
+
* provider with an additional filter, mirroring how `withRetry`
|
|
23
|
+
* / `withFallback` decorate `LLMProvider`.
|
|
24
|
+
* Role: Layer-3 tool-dispatch primitive. Agent calls `provider.list(ctx)`
|
|
25
|
+
* each iteration to compute the visible tool set.
|
|
26
|
+
* Emits: N/A (pure compute; permission denials emit elsewhere via the
|
|
27
|
+
* permission subsystem).
|
|
28
|
+
*
|
|
29
|
+
* @example Static tool list (90% case — what `.tools(arr)` does today)
|
|
30
|
+
* const provider = staticTools([weather, lookupOrder]);
|
|
31
|
+
*
|
|
32
|
+
* @example Read-only enforcement (role-based gate)
|
|
33
|
+
* const readOnlyProvider = gatedTools(
|
|
34
|
+
* staticTools([weather, lookupOrder, processRefund]),
|
|
35
|
+
* (toolName) => policy.isAllowed(toolName),
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* @example Skill-gated dispatch (only active skill's tools visible)
|
|
39
|
+
* const skillGated = gatedTools(
|
|
40
|
+
* staticTools(allTools),
|
|
41
|
+
* (toolName, ctx) => ctx.activeSkillId
|
|
42
|
+
* ? skillsToolMap[ctx.activeSkillId].includes(toolName)
|
|
43
|
+
* : alwaysVisible.includes(toolName),
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* @example Stack: read-only over skill-gated
|
|
47
|
+
* const provider = gatedTools(
|
|
48
|
+
* gatedTools(staticTools(allTools), readOnlyPredicate),
|
|
49
|
+
* skillGatePredicate,
|
|
50
|
+
* );
|
|
51
|
+
*/
|
|
52
|
+
import type { Tool } from '../core/tools.js';
|
|
53
|
+
/**
|
|
54
|
+
* Read-only context the provider receives each iteration. Pure data
|
|
55
|
+
* — providers MUST NOT mutate. Used by gating predicates to inspect
|
|
56
|
+
* the current activation state.
|
|
57
|
+
*/
|
|
58
|
+
export interface ToolDispatchContext {
|
|
59
|
+
/** Current ReAct iteration (1-based). */
|
|
60
|
+
readonly iteration: number;
|
|
61
|
+
/**
|
|
62
|
+
* The id of the currently-activated Skill, if any.
|
|
63
|
+
* Set by `read_skill(id)` activation; cleared between turns.
|
|
64
|
+
* Used by `autoActivate`-driven per-skill tool gating.
|
|
65
|
+
*/
|
|
66
|
+
readonly activeSkillId?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Caller identity tuple — passed through from `agent.run({ identity })`.
|
|
69
|
+
* Permission predicates can role-check based on `identity.principal`
|
|
70
|
+
* or `identity.tenant`.
|
|
71
|
+
*/
|
|
72
|
+
readonly identity?: {
|
|
73
|
+
readonly tenant?: string;
|
|
74
|
+
readonly principal?: string;
|
|
75
|
+
readonly conversationId: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Optional abort signal propagated from the agent's `run({ env })` /
|
|
79
|
+
* AbortController. Async providers (network discovery, MCP catalog
|
|
80
|
+
* fetch, registry pull) MUST honor this — abandon the in-flight
|
|
81
|
+
* request when the agent is cancelled mid-discovery, otherwise the
|
|
82
|
+
* provider holds the run open past abort. Sync providers can ignore
|
|
83
|
+
* it.
|
|
84
|
+
*/
|
|
85
|
+
readonly signal?: AbortSignal;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The provider interface. A `ToolProvider` answers ONE question per
|
|
89
|
+
* iteration: "what tools should the LLM see right now?"
|
|
90
|
+
*
|
|
91
|
+
* Implementations are PURE — given the same context, return the same
|
|
92
|
+
* tool list (no observable mutation; reentrant; safe under concurrent
|
|
93
|
+
* calls).
|
|
94
|
+
*
|
|
95
|
+
* **Sync vs async.** Most providers (`staticTools`, `gatedTools`,
|
|
96
|
+
* `skillScopedTools`) compute the answer synchronously and return
|
|
97
|
+
* `readonly Tool[]` — the agent's hot path skips the await microtask
|
|
98
|
+
* entirely via a runtime `instanceof Promise` check. Discovery-style
|
|
99
|
+
* providers (MCP catalog fetch, registry pull, dynamic skill resolution)
|
|
100
|
+
* may return `Promise<readonly Tool[]>`; the agent awaits only when
|
|
101
|
+
* the value is actually a Promise. Sync providers pay zero overhead.
|
|
102
|
+
*
|
|
103
|
+
* **Caching.** The agent calls `list(ctx)` once per iteration. For
|
|
104
|
+
* expensive lookups (network calls, hub queries), the provider is
|
|
105
|
+
* responsible for caching — typically TTL- or iteration-keyed. The
|
|
106
|
+
* framework deliberately does NOT cache for you because the cache
|
|
107
|
+
* key depends on which fields of `ctx` matter to your provider
|
|
108
|
+
* (e.g., per-skill vs per-tenant vs per-iteration).
|
|
109
|
+
*
|
|
110
|
+
* **Errors.** A throwing or rejecting provider emits
|
|
111
|
+
* `agentfootprint.tools.discovery_failed` and aborts the iteration —
|
|
112
|
+
* the run continues only if a configured `reliability` rule routes
|
|
113
|
+
* the error (`fail-fast`, `retry`, etc.). Discovery failure is loud
|
|
114
|
+
* by design; silently dropping tools mid-conversation produces
|
|
115
|
+
* non-deterministic agent behavior that's harder to debug than a
|
|
116
|
+
* crash.
|
|
117
|
+
*/
|
|
118
|
+
export interface ToolProvider {
|
|
119
|
+
/**
|
|
120
|
+
* Return the tool list visible to the LLM for the current iteration.
|
|
121
|
+
* Sync return is the fast path; Promise return is supported for
|
|
122
|
+
* discovery-style providers. The returned array MUST be a NEW
|
|
123
|
+
* reference each call (the agent compares for change detection).
|
|
124
|
+
* Order is preserved — the LLM may use position as a hint when tool
|
|
125
|
+
* descriptions are ambiguous.
|
|
126
|
+
*/
|
|
127
|
+
list(ctx: ToolDispatchContext): readonly Tool[] | Promise<readonly Tool[]>;
|
|
128
|
+
/**
|
|
129
|
+
* Optional: stable id for observability / debugging. Defaults to
|
|
130
|
+
* `'static'` for `staticTools`, `'gated'` for `gatedTools`. Custom
|
|
131
|
+
* implementations should set their own id — surfaces on
|
|
132
|
+
* `agentfootprint.tools.discovery_failed.providerId` so consumers
|
|
133
|
+
* can route alerts to the right hub adapter.
|
|
134
|
+
*/
|
|
135
|
+
readonly id?: string;
|
|
136
|
+
}
|
|
137
|
+
/** Predicate for `gatedTools` — runs per tool, per iteration. */
|
|
138
|
+
export type ToolGatePredicate = (toolName: string, ctx: ToolDispatchContext) => boolean;
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agentfootprint/events — the typed event system.
|
|
4
|
+
*
|
|
5
|
+
* Every agentfootprint run emits a single, strongly-typed event stream:
|
|
6
|
+
* the registry (`EVENT_NAMES`, `AgentfootprintEventMap`, `AgentfootprintEvent`),
|
|
7
|
+
* the dispatcher (`EventDispatcher` + listener/wildcard types), the shared
|
|
8
|
+
* context/composition types, and the ~60 typed payload shapes (grouped
|
|
9
|
+
* under the `Payloads` namespace).
|
|
10
|
+
*
|
|
11
|
+
* This is observability infrastructure, not core agent API, so in v7 it
|
|
12
|
+
* lives on its own subpath — consistent with `/observe`, `/memory`, etc.
|
|
13
|
+
* Recorders (`agentfootprint/observe`) and viewer libraries consume it;
|
|
14
|
+
* the `Agent` builder wires it for you.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.EventDispatcher = exports.ALL_EVENT_TYPES = exports.EVENT_NAMES = void 0;
|
|
32
|
+
// Shared event/context/composition types.
|
|
33
|
+
__exportStar(require("./events/types.js"), exports);
|
|
34
|
+
// Registry — the event-name set + the typed map/union/discriminant.
|
|
35
|
+
var registry_js_1 = require("./events/registry.js");
|
|
36
|
+
Object.defineProperty(exports, "EVENT_NAMES", { enumerable: true, get: function () { return registry_js_1.EVENT_NAMES; } });
|
|
37
|
+
Object.defineProperty(exports, "ALL_EVENT_TYPES", { enumerable: true, get: function () { return registry_js_1.ALL_EVENT_TYPES; } });
|
|
38
|
+
// Dispatcher — subscribe to the stream (`.on(type, listener)`), wildcard
|
|
39
|
+
// subscriptions, and the unsubscribe handle.
|
|
40
|
+
var dispatcher_js_1 = require("./events/dispatcher.js");
|
|
41
|
+
Object.defineProperty(exports, "EventDispatcher", { enumerable: true, get: function () { return dispatcher_js_1.EventDispatcher; } });
|
|
42
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,0CAA0C;AAC1C,oDAAkC;AAQlC,oEAAoE;AACpE,oDAM8B;AAL5B,0GAAA,WAAW,OAAA;AACX,8GAAA,eAAe,OAAA;AAMjB,yEAAyE;AACzE,6CAA6C;AAC7C,wDASgC;AAR9B,gHAAA,eAAe,OAAA"}
|