agentfootprint 6.44.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/package.json +203 -56
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* softmax — numerically-stable softmax over raw scores.
|
|
3
|
+
*
|
|
4
|
+
* Used by `skillGraph().entryByRelevance(embedder)` to turn per-entry cosine
|
|
5
|
+
* similarities into a relevance distribution (the surfaced `relevance` %): the
|
|
6
|
+
* shares sum to 1, so they read as "how much of the match each entry owns".
|
|
7
|
+
* Internal helper — not a public export (the public surface is `relevance`).
|
|
8
|
+
*
|
|
9
|
+
* `temperature > 0` sharpens (<1) or flattens (>1) the distribution; default 1.
|
|
10
|
+
*/
|
|
11
|
+
export declare function softmax(scores: readonly number[], temperature?: number): number[];
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection Engine — types.
|
|
3
|
+
*
|
|
4
|
+
* THE primitive that unifies every form of context engineering in the
|
|
5
|
+
* library. Skills, Steering docs, Instructions, RAG, Memory, custom
|
|
6
|
+
* Context — all reduce to one shape: an `Injection` with a `trigger`
|
|
7
|
+
* (when), `inject` (what — one or more slot targets), and a `flavor`
|
|
8
|
+
* (observability tag).
|
|
9
|
+
*
|
|
10
|
+
* Pattern: Strategy (GoF) — each Injection's trigger is a strategy for
|
|
11
|
+
* "should I activate this iteration?". Each Injection's
|
|
12
|
+
* `inject` is the Memento (GoF) carrying content to slots.
|
|
13
|
+
* Role: Layer-3 context engineering primitive in the stack.
|
|
14
|
+
* Sits below the slot subflows.
|
|
15
|
+
* Emits: Engine emits `agentfootprint.context.evaluated` once per
|
|
16
|
+
* iteration. Slot subflows emit `agentfootprint.context.injected`
|
|
17
|
+
* for each InjectionRecord they place.
|
|
18
|
+
*/
|
|
19
|
+
import type { Tool } from '../../core/tools.js';
|
|
20
|
+
import type { ContextRole, ContextSource } from '../../events/types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Discriminated union — exactly one of four kinds. Adding a new
|
|
23
|
+
* trigger kind is one new variant; engine evaluator + Lens chip
|
|
24
|
+
* naturally extend.
|
|
25
|
+
*/
|
|
26
|
+
export type InjectionTrigger =
|
|
27
|
+
/** Always-on. Used for steering-doc-style injections. */
|
|
28
|
+
{
|
|
29
|
+
readonly kind: 'always';
|
|
30
|
+
}
|
|
31
|
+
/** Predicate runs once per iteration. Most flexible. */
|
|
32
|
+
| {
|
|
33
|
+
readonly kind: 'rule';
|
|
34
|
+
readonly activeWhen: (ctx: InjectionContext) => boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Activates after a specific tool returns. The "Dynamic ReAct" flavor —
|
|
37
|
+
* tool results steer the next iteration's prompt. `toolName` matches
|
|
38
|
+
* literally (string) or by regex. */
|
|
39
|
+
| {
|
|
40
|
+
readonly kind: 'on-tool-return';
|
|
41
|
+
readonly toolName: string | RegExp;
|
|
42
|
+
}
|
|
43
|
+
/** Activates when the LLM calls a designated tool. The "Skill" flavor:
|
|
44
|
+
* `read_skill('billing')` activates the billing Skill for the next
|
|
45
|
+
* iteration. */
|
|
46
|
+
| {
|
|
47
|
+
readonly kind: 'llm-activated';
|
|
48
|
+
readonly viaToolName: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Multi-slot per Injection. A Skill for example targets BOTH
|
|
52
|
+
* system-prompt (the body) AND tools (the unlocked capabilities)
|
|
53
|
+
* in one Injection. Lens displays the same Injection chip across
|
|
54
|
+
* each slot it lands in.
|
|
55
|
+
*/
|
|
56
|
+
export interface InjectionContent {
|
|
57
|
+
/** Text appended to the system-prompt slot when active. */
|
|
58
|
+
readonly systemPrompt?: string;
|
|
59
|
+
/** Messages prepended to the messages slot when active. */
|
|
60
|
+
readonly messages?: ReadonlyArray<{
|
|
61
|
+
readonly role: ContextRole;
|
|
62
|
+
readonly content: string;
|
|
63
|
+
}>;
|
|
64
|
+
/** Tools added to the tools slot when active. */
|
|
65
|
+
readonly tools?: readonly Tool[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Context passed to `rule` predicates. Read-only snapshot of the
|
|
69
|
+
* agent's iteration state. Internal mutable state is hidden.
|
|
70
|
+
*/
|
|
71
|
+
export interface InjectionContext {
|
|
72
|
+
/** Current ReAct iteration (1-based). */
|
|
73
|
+
readonly iteration: number;
|
|
74
|
+
/** The current user message that started this turn. */
|
|
75
|
+
readonly userMessage: string;
|
|
76
|
+
/**
|
|
77
|
+
* Conversation history up to (but not including) the current
|
|
78
|
+
* iteration's LLM call. Includes prior iterations within the same turn.
|
|
79
|
+
*/
|
|
80
|
+
readonly history: ReadonlyArray<{
|
|
81
|
+
readonly role: ContextRole;
|
|
82
|
+
readonly content: string;
|
|
83
|
+
readonly toolName?: string;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* The most recent tool result, if the previous iteration ended in a
|
|
87
|
+
* tool call. Used both by `rule` predicates and by `on-tool-return`
|
|
88
|
+
* trigger evaluation.
|
|
89
|
+
*/
|
|
90
|
+
readonly lastToolResult?: {
|
|
91
|
+
readonly toolName: string;
|
|
92
|
+
readonly result: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* IDs of LLM-activated injections that the LLM has activated this
|
|
96
|
+
* turn (via their `viaToolName` tool call). Engine includes them
|
|
97
|
+
* in the active set on subsequent iterations until turn end.
|
|
98
|
+
*/
|
|
99
|
+
readonly activatedInjectionIds: readonly string[];
|
|
100
|
+
/**
|
|
101
|
+
* The skill-graph CURSOR — which skill node the graph is currently
|
|
102
|
+
* *in*, persisted across iterations. Undefined before the first entry
|
|
103
|
+
* (cold start). `skillGraph()` route edges are `from`-gated against it:
|
|
104
|
+
* an edge `A → B` only fires while `currentSkillId === 'A'`, which kills
|
|
105
|
+
* cross-skill edge bleed (an edge firing while in an unrelated skill).
|
|
106
|
+
*
|
|
107
|
+
* Set by the loop's cursor-update stage to `graph.nextSkill(ctx)` each
|
|
108
|
+
* iteration; absent for agents that don't use `skillGraph()`. Plain
|
|
109
|
+
* `rule`/`always`/`on-tool-return` predicates may ignore it.
|
|
110
|
+
*/
|
|
111
|
+
readonly currentSkillId?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The relevance ranking of entry candidates from an entry scorer (`.entryBy()` /
|
|
114
|
+
* `.entryByRelevance()`) — written by the PickEntry stage at turn start.
|
|
115
|
+
* `defineRelevanceHint()` reads it to detect a near-tie. Absent unless the graph
|
|
116
|
+
* used an entry scorer. `score` is the raw strategy score (cosine / word-overlap);
|
|
117
|
+
* `relevance` is the softmax share (the surfaced %).
|
|
118
|
+
*/
|
|
119
|
+
readonly entryScores?: ReadonlyArray<{
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly score: number;
|
|
122
|
+
readonly relevance: number;
|
|
123
|
+
}>;
|
|
124
|
+
/** Name of the entry scorer that produced `entryScores` (e.g. `'keyword'`,
|
|
125
|
+
* `'embedding'`). Absent unless an entry scorer ran. */
|
|
126
|
+
readonly entryScorer?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* THE primitive. Five fields. Four trigger kinds. Three slot targets.
|
|
130
|
+
*
|
|
131
|
+
* Every named flavor (Skill, Steering, Instruction, Context, RAG,
|
|
132
|
+
* Memory, Guardrail, …) is a sugar factory that produces one of these.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* // Direct construction (power user)
|
|
136
|
+
* const myInjection: Injection = {
|
|
137
|
+
* id: 'demo',
|
|
138
|
+
* flavor: 'instructions',
|
|
139
|
+
* trigger: { kind: 'rule', activeWhen: (ctx) => ctx.iteration > 1 },
|
|
140
|
+
* inject: { systemPrompt: 'Refine the previous answer.' },
|
|
141
|
+
* };
|
|
142
|
+
*
|
|
143
|
+
* // Sugar (recommended)
|
|
144
|
+
* const myInjection2 = defineInstruction({
|
|
145
|
+
* id: 'demo',
|
|
146
|
+
* activeWhen: (ctx) => ctx.iteration > 1,
|
|
147
|
+
* prompt: 'Refine the previous answer.',
|
|
148
|
+
* });
|
|
149
|
+
*/
|
|
150
|
+
export interface Injection {
|
|
151
|
+
/** Unique id. Used for observability + de-duplication + LLM-activation lookup. */
|
|
152
|
+
readonly id: string;
|
|
153
|
+
/** Human-readable description (Lens / docs / debug). */
|
|
154
|
+
readonly description?: string;
|
|
155
|
+
/** Observability tag. Drives Lens chip color + ContextRecorder source field. */
|
|
156
|
+
readonly flavor: ContextSource;
|
|
157
|
+
/** WHEN to activate. */
|
|
158
|
+
readonly trigger: InjectionTrigger;
|
|
159
|
+
/** WHAT to contribute (one or more slots). */
|
|
160
|
+
readonly inject: InjectionContent;
|
|
161
|
+
/**
|
|
162
|
+
* Optional flavor-specific metadata. Engine ignores keys it doesn't
|
|
163
|
+
* recognize; flavor factories use this for opt-in fields without
|
|
164
|
+
* widening the Injection contract.
|
|
165
|
+
*
|
|
166
|
+
* Known keys:
|
|
167
|
+
* - `surfaceMode` (Skill) — `'auto' | 'system-prompt' | 'tool-only' | 'both'`
|
|
168
|
+
* - `refreshPolicy` (Skill) — `{ afterTokens, via }`
|
|
169
|
+
*/
|
|
170
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Returned by `evaluateInjections()`. Slot subflows consume `active`;
|
|
174
|
+
* `skipped` is observability metadata (predicate errors).
|
|
175
|
+
*/
|
|
176
|
+
export interface InjectionEvaluation {
|
|
177
|
+
readonly active: readonly Injection[];
|
|
178
|
+
readonly skipped: ReadonlyArray<{
|
|
179
|
+
readonly id: string;
|
|
180
|
+
readonly reason: 'predicate-threw' | 'unknown-trigger-kind';
|
|
181
|
+
readonly error?: string;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* POJO projection of an active Injection — flows through footprintjs
|
|
186
|
+
* scope (which cannot serialize functions) so that slot subflows can
|
|
187
|
+
* read it across the subflow boundary.
|
|
188
|
+
*
|
|
189
|
+
* Drops the `trigger` (already evaluated) and projects `inject.tools`
|
|
190
|
+
* to schemas only (the Tool's `execute` function lives on the Agent's
|
|
191
|
+
* closure-held registry, looked up by injection id at exec time).
|
|
192
|
+
*/
|
|
193
|
+
export interface ActiveInjection {
|
|
194
|
+
readonly id: string;
|
|
195
|
+
readonly flavor: import('../../events/types.js').ContextSource;
|
|
196
|
+
readonly description?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Resolved surfaceMode (Skill flavor only). Drives Block C runtime
|
|
199
|
+
* dispatch — slot subflows skip system-slot injection when this is
|
|
200
|
+
* `'tool-only'`; the read_skill tool delivers the body in its
|
|
201
|
+
* result for `'tool-only'` and `'both'`.
|
|
202
|
+
*
|
|
203
|
+
* `'auto'` and absent both mean "keep v2.4 behavior" (body in
|
|
204
|
+
* system slot, tool result is confirmation only). The Block A4
|
|
205
|
+
* cascade resolves 'auto' against provider/model context at a
|
|
206
|
+
* later layer; this projection stays declarative.
|
|
207
|
+
*/
|
|
208
|
+
readonly surfaceMode?: 'auto' | 'system-prompt' | 'tool-only' | 'both';
|
|
209
|
+
/**
|
|
210
|
+
* Per-skill tool gating intent (Skill flavor only). Reserved for
|
|
211
|
+
* Block C+ runtime auto-wiring of `skillScopedTools`. Today
|
|
212
|
+
* consumers wire this manually via `agentfootprint/tool-providers`.
|
|
213
|
+
*/
|
|
214
|
+
readonly autoActivate?: 'currentSkill';
|
|
215
|
+
readonly inject: {
|
|
216
|
+
readonly systemPrompt?: string;
|
|
217
|
+
readonly messages?: ReadonlyArray<{
|
|
218
|
+
readonly role: import('../../events/types.js').ContextRole;
|
|
219
|
+
readonly content: string;
|
|
220
|
+
}>;
|
|
221
|
+
/** Tool schemas only — `execute` lives on Agent's closure registry. */
|
|
222
|
+
readonly tools?: ReadonlyArray<{
|
|
223
|
+
readonly schema: import('../../adapters/types.js').LLMToolSchema;
|
|
224
|
+
readonly injectionId: string;
|
|
225
|
+
}>;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/** Project a full Injection (with functions) into a scope-safe POJO. */
|
|
229
|
+
export declare function projectActiveInjection(inj: Injection): ActiveInjection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkOH,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,GAAc;IACnD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAuE,CAAC;IACzF,MAAM,GAAG,GAAoB;QAC3B,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;QACxD,GAAG,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAA6C,EAAE,CAAC;QAC7F,GAAG,CAAC,IAAI,EAAE,YAAY,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,YAA+C;SACnE,CAAC;QACF,MAAM,EAAE;YACN,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;gBACtB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACvB,WAAW,EAAE,GAAG,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ,CAAC;SACH;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lazyRequire — module-path-indirect `require()` wrapper for lazy
|
|
3
|
+
* peer-dep loading.
|
|
4
|
+
*
|
|
5
|
+
* Why a wrapper: bundlers (Vite, esbuild, webpack, Rollup) statically
|
|
6
|
+
* analyze `require('literal-string')` calls and try to resolve the
|
|
7
|
+
* dependency at BUILD time — even when the function is never called
|
|
8
|
+
* at runtime. For optional peer-deps (`@modelcontextprotocol/sdk`,
|
|
9
|
+
* `@anthropic-ai/sdk`, `ioredis`, `@aws-sdk/client-bedrock-*`), this
|
|
10
|
+
* means consumers who never instantiate the matching adapter still
|
|
11
|
+
* get a build error if the peer-dep isn't installed.
|
|
12
|
+
*
|
|
13
|
+
* Wrapping the call in a function with a string PARAMETER hides the
|
|
14
|
+
* specifier from static analysis. At runtime this is exactly the
|
|
15
|
+
* same as inline `require()`, including the throwing behavior when
|
|
16
|
+
* the peer-dep isn't installed.
|
|
17
|
+
*
|
|
18
|
+
* Pattern: indirect require — used by Node's `createRequire`-style
|
|
19
|
+
* fallbacks for the same reason.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* try {
|
|
23
|
+
* const mod = lazyRequire<typeof import('ioredis')>('ioredis');
|
|
24
|
+
* this._client = new mod.default(...);
|
|
25
|
+
* } catch {
|
|
26
|
+
* throw new Error('install ioredis to use RedisStore');
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export declare function lazyRequire<T = unknown>(specifier: string): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP — Model Context Protocol client integration. Connect to an MCP
|
|
3
|
+
* server, register its tools on your Agent. Server-side support is
|
|
4
|
+
* separate (consumer exposes their agent as an MCP tool — different
|
|
5
|
+
* use case, not yet shipped).
|
|
6
|
+
*/
|
|
7
|
+
export { mcpClient } from './mcpClient.js';
|
|
8
|
+
export { mockMcpClient, type MockMcpClientOptions, type MockMcpTool } from './mockMcpClient.js';
|
|
9
|
+
export type { McpClient, McpClientOptions, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, } from './types.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpClient — connect to an MCP server, expose its tools to your Agent.
|
|
3
|
+
*
|
|
4
|
+
* const slack = await mcpClient({
|
|
5
|
+
* name: 'slack',
|
|
6
|
+
* transport: { transport: 'stdio', command: 'npx', args: ['@example/slack-mcp'] },
|
|
7
|
+
* });
|
|
8
|
+
*
|
|
9
|
+
* const tools = await slack.tools(); // → readonly Tool[]
|
|
10
|
+
* const agent = Agent.create({ ... }).tools(tools).build();
|
|
11
|
+
*
|
|
12
|
+
* // ...
|
|
13
|
+
*
|
|
14
|
+
* await slack.close();
|
|
15
|
+
*
|
|
16
|
+
* Pattern: Adapter (GoF) — translates MCP `listTools()` / `callTool()`
|
|
17
|
+
* into agentfootprint's `Tool` interface (schema + execute).
|
|
18
|
+
* Each MCP tool becomes ONE agentfootprint Tool. The agent's
|
|
19
|
+
* existing tool-call handler invokes `client.callTool()`
|
|
20
|
+
* inside the wrapped `execute`.
|
|
21
|
+
*
|
|
22
|
+
* Role: Layer-3 integration. Sits next to `defineTool` — same
|
|
23
|
+
* shape, different source. Once tools land on the agent,
|
|
24
|
+
* the rest of the library doesn't know they came from MCP.
|
|
25
|
+
*
|
|
26
|
+
* Emits: N/A — wrapped tools emit the standard
|
|
27
|
+
* `agentfootprint.stream.tool_start` / `tool_end` events
|
|
28
|
+
* when the agent calls them. Add `name: '<mcp-server>'` to
|
|
29
|
+
* `McpClientOptions` so observability surfaces can group
|
|
30
|
+
* tool calls by server.
|
|
31
|
+
*
|
|
32
|
+
* Lazy-require pattern: the `@modelcontextprotocol/sdk` peer-dep
|
|
33
|
+
* loads only when a consumer actually constructs a client. Tests
|
|
34
|
+
* inject `_client` and skip the import path entirely.
|
|
35
|
+
*/
|
|
36
|
+
import type { McpClient, McpClientOptions } from './types.js';
|
|
37
|
+
/**
|
|
38
|
+
* Connect to an MCP server. Returns an `McpClient` that exposes the
|
|
39
|
+
* server's tools as agentfootprint `Tool[]` and a `close()` to tear
|
|
40
|
+
* down the transport.
|
|
41
|
+
*
|
|
42
|
+
* @throws when `@modelcontextprotocol/sdk` is not installed (see
|
|
43
|
+
* error message for `npm install` hint), or when the transport
|
|
44
|
+
* fails to connect.
|
|
45
|
+
*/
|
|
46
|
+
export declare function mcpClient(opts: McpClientOptions): Promise<McpClient>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mockMcpClient — in-memory MCP client for development and tests.
|
|
3
|
+
*
|
|
4
|
+
* const slack = mockMcpClient({
|
|
5
|
+
* tools: [
|
|
6
|
+
* {
|
|
7
|
+
* name: 'send_message',
|
|
8
|
+
* description: 'Post a message to a channel',
|
|
9
|
+
* inputSchema: { type: 'object' },
|
|
10
|
+
* handler: async ({ text }) => `Posted: ${text}`,
|
|
11
|
+
* },
|
|
12
|
+
* ],
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const agent = Agent.create({ provider: mock({ reply: 'ok' }) })
|
|
16
|
+
* .tools(await slack.tools())
|
|
17
|
+
* .build();
|
|
18
|
+
*
|
|
19
|
+
* Pattern: Adapter (GoF) — produces an `McpClient` with the same shape
|
|
20
|
+
* as `mcpClient(opts)` but driven by an in-memory tool table
|
|
21
|
+
* instead of the MCP SDK + transport. Drop-in for development:
|
|
22
|
+
* start with `mockMcpClient`, swap to `mcpClient` once the
|
|
23
|
+
* real server is ready.
|
|
24
|
+
*
|
|
25
|
+
* Why public: `mcpClient`'s `_client` injection is `@internal` because
|
|
26
|
+
* the SDK shape isn't a stable public surface. `mockMcpClient` exposes
|
|
27
|
+
* a curated tool-handler shape that's tied to OUR Tool contract instead
|
|
28
|
+
* — stable, documented, and the right level of abstraction for
|
|
29
|
+
* mock-first development.
|
|
30
|
+
*/
|
|
31
|
+
import type { McpClient } from './types.js';
|
|
32
|
+
/** A scripted tool exposed by the mock MCP server. */
|
|
33
|
+
export interface MockMcpTool {
|
|
34
|
+
/** Tool name as the LLM sees it. */
|
|
35
|
+
readonly name: string;
|
|
36
|
+
/** Description surfaced to the LLM via the tool schema. */
|
|
37
|
+
readonly description?: string;
|
|
38
|
+
/**
|
|
39
|
+
* JSON-schema-like input schema. Passed through to the agent's tool
|
|
40
|
+
* registry verbatim — same as a real MCP server's `listTools()`.
|
|
41
|
+
*/
|
|
42
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
43
|
+
/**
|
|
44
|
+
* Async handler that runs when the agent calls this tool. Receives
|
|
45
|
+
* the args the LLM produced; returns the string result the agent
|
|
46
|
+
* sees as the tool-result message.
|
|
47
|
+
*
|
|
48
|
+
* Defaults to `async () => '[mock result]'` when omitted — useful
|
|
49
|
+
* when the consumer cares about wiring not behavior.
|
|
50
|
+
*/
|
|
51
|
+
readonly handler?: (args: Record<string, unknown>) => Promise<string>;
|
|
52
|
+
}
|
|
53
|
+
export interface MockMcpClientOptions {
|
|
54
|
+
/** Logical server name. Surfaces in observability + error messages. */
|
|
55
|
+
readonly name?: string;
|
|
56
|
+
/** Tools exposed by the mock server. */
|
|
57
|
+
readonly tools: readonly MockMcpTool[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build an in-memory `McpClient`. Useful when you want to develop
|
|
61
|
+
* against MCP semantics without spawning subprocesses, hitting the
|
|
62
|
+
* network, or installing `@modelcontextprotocol/sdk`. Same `McpClient`
|
|
63
|
+
* shape as `mcpClient(opts)` — code that consumes one accepts the other.
|
|
64
|
+
*/
|
|
65
|
+
export declare function mockMcpClient(options: MockMcpClientOptions): McpClient;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP — Model Context Protocol client integration.
|
|
3
|
+
*
|
|
4
|
+
* MCP (https://modelcontextprotocol.io) is an open standard for
|
|
5
|
+
* connecting LLMs to external tools and data sources. agentfootprint's
|
|
6
|
+
* MCP adapter is **client-only** — it consumes MCP servers and exposes
|
|
7
|
+
* their tools as agentfootprint `Tool[]` so consumers can plug them
|
|
8
|
+
* straight into `agent.tool(...)`.
|
|
9
|
+
*
|
|
10
|
+
* Pattern: Adapter (GoF) — translates MCP wire format ↔ agentfootprint
|
|
11
|
+
* `Tool` interface. The MCP SDK does the protocol work; we
|
|
12
|
+
* just bridge.
|
|
13
|
+
* Role: Layer-3 tool integration. Pairs with `defineTool` (the
|
|
14
|
+
* inline alternative for non-MCP tools).
|
|
15
|
+
* Emits: N/A directly — wrapped tools emit the standard
|
|
16
|
+
* `agentfootprint.stream.tool_start` / `tool_end` events
|
|
17
|
+
* when the agent calls them.
|
|
18
|
+
*
|
|
19
|
+
* Server-side support (exposing an agent or LLMCall as an MCP tool)
|
|
20
|
+
* is a separate concern not yet shipped. This module covers the
|
|
21
|
+
* 80% case: pulling an existing MCP server's tools INTO an agent.
|
|
22
|
+
*/
|
|
23
|
+
import type { Tool } from '../../core/tools.js';
|
|
24
|
+
/**
|
|
25
|
+
* `stdio` transport — spawns a local subprocess and speaks MCP over
|
|
26
|
+
* its stdin/stdout. Best for development, single-user scenarios, and
|
|
27
|
+
* testing against locally-installed MCP servers.
|
|
28
|
+
*/
|
|
29
|
+
export interface McpStdioTransport {
|
|
30
|
+
readonly transport: 'stdio';
|
|
31
|
+
/** Executable to spawn (e.g., `'npx'`, `'node'`, `'python'`). */
|
|
32
|
+
readonly command: string;
|
|
33
|
+
/** CLI args passed to the executable. */
|
|
34
|
+
readonly args?: readonly string[];
|
|
35
|
+
/** Optional env vars set on the subprocess. */
|
|
36
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
37
|
+
/** Working directory for the subprocess. */
|
|
38
|
+
readonly cwd?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* `http` transport — speaks MCP over Streamable HTTP. Best for remote
|
|
42
|
+
* servers, web environments, and multi-user scenarios.
|
|
43
|
+
*/
|
|
44
|
+
export interface McpHttpTransport {
|
|
45
|
+
readonly transport: 'http';
|
|
46
|
+
/** MCP server endpoint URL. */
|
|
47
|
+
readonly url: string;
|
|
48
|
+
/** Optional auth headers (e.g., `Authorization: Bearer ...`). */
|
|
49
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
50
|
+
}
|
|
51
|
+
export type McpTransport = McpStdioTransport | McpHttpTransport;
|
|
52
|
+
export interface McpClientOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Logical name for observability + tool-call routing. Surfaces in
|
|
55
|
+
* Lens chips and event payloads. Defaults to `'mcp'`. Recommend
|
|
56
|
+
* setting per-server (`'slack-mcp'`, `'github-mcp'`) when you
|
|
57
|
+
* connect to multiple servers.
|
|
58
|
+
*/
|
|
59
|
+
readonly name?: string;
|
|
60
|
+
/** Transport configuration — stdio or http. */
|
|
61
|
+
readonly transport: McpTransport;
|
|
62
|
+
/**
|
|
63
|
+
* Optional client identity sent on connect. Default:
|
|
64
|
+
* `{ name: 'agentfootprint', version: <package version> }`.
|
|
65
|
+
*/
|
|
66
|
+
readonly clientInfo?: {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly version: string;
|
|
69
|
+
};
|
|
70
|
+
/** Abort the connection / list / call paths. Honored by the SDK. */
|
|
71
|
+
readonly signal?: AbortSignal;
|
|
72
|
+
/**
|
|
73
|
+
* @internal Pre-built SDK client for tests. Skips SDK import +
|
|
74
|
+
* transport construction. Same convention as `AnthropicProvider._client`.
|
|
75
|
+
*/
|
|
76
|
+
readonly _client?: McpSdkClient;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* What `mcpClient(opts)` returns. Connect once; call `.tools()` to
|
|
80
|
+
* snapshot the tool list, `.refresh()` to re-list after the server's
|
|
81
|
+
* tools change, `.close()` when done.
|
|
82
|
+
*/
|
|
83
|
+
export interface McpClient {
|
|
84
|
+
/** Logical name from options (or default `'mcp'`). */
|
|
85
|
+
readonly name: string;
|
|
86
|
+
/**
|
|
87
|
+
* List the server's tools as agentfootprint `Tool[]`. First call
|
|
88
|
+
* after `mcpClient(...)` is the snapshot used to register on the
|
|
89
|
+
* agent; subsequent calls re-fetch (cheap, in-memory cached by the
|
|
90
|
+
* SDK between fetches).
|
|
91
|
+
*/
|
|
92
|
+
tools(): Promise<readonly Tool[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Force a refresh from the server. Use when you suspect the server
|
|
95
|
+
* has dynamically added/removed tools mid-session (e.g., after the
|
|
96
|
+
* server processes a config update).
|
|
97
|
+
*/
|
|
98
|
+
refresh(): Promise<readonly Tool[]>;
|
|
99
|
+
/** Close the underlying transport. After `close()` the client is unusable. */
|
|
100
|
+
close(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Minimal structural type capturing the parts of the MCP SDK client
|
|
104
|
+
* we touch. Defined locally so we can:
|
|
105
|
+
* 1. Inject a mock for tests (`McpClientOptions._client`)
|
|
106
|
+
* 2. Avoid a hard import on `@modelcontextprotocol/sdk` (which is
|
|
107
|
+
* a lazy peer-dep)
|
|
108
|
+
*
|
|
109
|
+
* The real SDK exports a richer surface; we narrow to what's needed.
|
|
110
|
+
*/
|
|
111
|
+
export interface McpSdkClient {
|
|
112
|
+
connect(transport: unknown): Promise<void>;
|
|
113
|
+
listTools(): Promise<{
|
|
114
|
+
readonly tools: ReadonlyArray<{
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly description?: string;
|
|
117
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
118
|
+
}>;
|
|
119
|
+
}>;
|
|
120
|
+
callTool(args: {
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly arguments?: Readonly<Record<string, unknown>>;
|
|
123
|
+
/** Forwarded from `McpClientOptions.signal` so consumers can cancel hung tool calls. */
|
|
124
|
+
readonly signal?: AbortSignal;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
readonly content: ReadonlyArray<{
|
|
127
|
+
readonly type: string;
|
|
128
|
+
readonly text?: string;
|
|
129
|
+
}>;
|
|
130
|
+
readonly isError?: boolean;
|
|
131
|
+
}>;
|
|
132
|
+
close(): Promise<void>;
|
|
133
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineRAG — sugar factory for retrieval-augmented generation.
|
|
3
|
+
*
|
|
4
|
+
* RAG is a context-engineering flavor: embed the user's question,
|
|
5
|
+
* retrieve top-K semantically similar chunks from a vector store,
|
|
6
|
+
* inject those chunks into the messages slot of the next LLM call.
|
|
7
|
+
* It's the same plumbing as `defineMemory({ type: SEMANTIC,
|
|
8
|
+
* strategy: TOP_K })` — the rename is for intent + ergonomics.
|
|
9
|
+
*
|
|
10
|
+
* defineMemory ─┬─► EPISODIC (raw conversation)
|
|
11
|
+
* ├─► SEMANTIC (extracted facts / RAG chunks)
|
|
12
|
+
* ├─► NARRATIVE (beats / summaries)
|
|
13
|
+
* └─► CAUSAL (footprintjs decision snapshots)
|
|
14
|
+
*
|
|
15
|
+
* defineRAG ─► SEMANTIC + TOP_K with RAG-specific defaults
|
|
16
|
+
* (asRole='user', threshold=0.7, no LLM-extract)
|
|
17
|
+
*
|
|
18
|
+
* Pattern: Composition over duplication — defineRAG returns a
|
|
19
|
+
* MemoryDefinition produced by defineMemory. No new engine
|
|
20
|
+
* code, no new slot subflow, no new event type.
|
|
21
|
+
*
|
|
22
|
+
* Role: Layer-3 context-engineering primitive. Lives next to
|
|
23
|
+
* defineSkill / defineSteering / defineInstruction / defineFact
|
|
24
|
+
* but resolves to a memory subflow rather than an Injection
|
|
25
|
+
* (RAG content is computed at runtime via async retrieval —
|
|
26
|
+
* can't fit the synchronous Injection.inject shape).
|
|
27
|
+
*
|
|
28
|
+
* Emits: Indirectly — the underlying memory pipeline emits
|
|
29
|
+
* `agentfootprint.context.injected` when retrieved chunks
|
|
30
|
+
* land in the messages slot.
|
|
31
|
+
*
|
|
32
|
+
* @see ./indexDocuments.ts for the seeding helper
|
|
33
|
+
* @see ../../memory/define.ts for the underlying factory
|
|
34
|
+
*
|
|
35
|
+
* @example Basic usage
|
|
36
|
+
* ```ts
|
|
37
|
+
* import {
|
|
38
|
+
* Agent, defineRAG, indexDocuments, InMemoryStore, mockEmbedder, mock,
|
|
39
|
+
* } from 'agentfootprint';
|
|
40
|
+
*
|
|
41
|
+
* const embedder = mockEmbedder();
|
|
42
|
+
* const store = new InMemoryStore();
|
|
43
|
+
*
|
|
44
|
+
* // Seed the store once at startup
|
|
45
|
+
* await indexDocuments(store, embedder, [
|
|
46
|
+
* { id: 'doc1', content: 'Refunds are processed within 3 business days.' },
|
|
47
|
+
* { id: 'doc2', content: 'Pro plan costs $20/month.' },
|
|
48
|
+
* ]);
|
|
49
|
+
*
|
|
50
|
+
* const docs = defineRAG({
|
|
51
|
+
* id: 'product-docs',
|
|
52
|
+
* description: 'Retrieve product documentation chunks',
|
|
53
|
+
* store,
|
|
54
|
+
* embedder,
|
|
55
|
+
* topK: 3,
|
|
56
|
+
* threshold: 0.6,
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* const agent = Agent.create({ provider: mock({ reply: 'ok' }), model: 'mock' })
|
|
60
|
+
* .rag(docs)
|
|
61
|
+
* .build();
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
import type { ContextRole } from '../../events/types.js';
|
|
65
|
+
import type { Embedder } from '../../memory/embedding/index.js';
|
|
66
|
+
import type { MemoryStore } from '../../memory/store/index.js';
|
|
67
|
+
import type { MemoryDefinition } from '../../memory/define.types.js';
|
|
68
|
+
export interface DefineRAGOptions {
|
|
69
|
+
/** Stable id. Becomes the scope-key suffix and the Lens label. */
|
|
70
|
+
readonly id: string;
|
|
71
|
+
/**
|
|
72
|
+
* Human-readable description. Surfaces in narrative + Lens hover.
|
|
73
|
+
* Recommend describing the *corpus* (e.g., "Product documentation
|
|
74
|
+
* chunks indexed weekly from docs.example.com").
|
|
75
|
+
*/
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Vector-capable store containing the indexed corpus. Must implement
|
|
79
|
+
* `search()`. Use `indexDocuments(store, embedder, docs)` at startup
|
|
80
|
+
* to populate it. Ships with `InMemoryStore` for dev/tests; swap to
|
|
81
|
+
* `pgvector` / Pinecone / Qdrant adapters in production.
|
|
82
|
+
*/
|
|
83
|
+
readonly store: MemoryStore;
|
|
84
|
+
/**
|
|
85
|
+
* Embedder used for the read-side query. Pass the SAME embedder
|
|
86
|
+
* instance (or one with the same `name`) that was used for indexing
|
|
87
|
+
* — cross-model similarity scores are not comparable.
|
|
88
|
+
*/
|
|
89
|
+
readonly embedder: Embedder;
|
|
90
|
+
/**
|
|
91
|
+
* Stable id of the embedder. Stored on entries during indexing
|
|
92
|
+
* (via `indexDocuments`) and filtered at search time so a later
|
|
93
|
+
* embedder swap doesn't pollute results.
|
|
94
|
+
*/
|
|
95
|
+
readonly embedderId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Top-K chunks to retrieve per turn. Default 3 (balanced —
|
|
98
|
+
* defends against lost-in-the-middle while giving multiple
|
|
99
|
+
* perspectives). Increase for richer context, decrease for cost.
|
|
100
|
+
*/
|
|
101
|
+
readonly topK?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Minimum cosine similarity to inject. **Strict** — when no chunk
|
|
104
|
+
* meets the threshold, NO injection happens (no fallback that would
|
|
105
|
+
* pollute the prompt with weak matches). Default 0.7.
|
|
106
|
+
*
|
|
107
|
+
* Tuning note: 0.7 is a high bar for some embedders. Sentence-BERT
|
|
108
|
+
* relatives (`all-MiniLM-L6-v2`, etc.) often score 0.4–0.6 even on
|
|
109
|
+
* relevant chunks. If you see frequent zero-result silent skips,
|
|
110
|
+
* lower to ~0.5 and observe the `agentfootprint.context.injected`
|
|
111
|
+
* stream. OpenAI `text-embedding-3-*` and Cohere embed-v3 typically
|
|
112
|
+
* sit comfortably with 0.7.
|
|
113
|
+
*/
|
|
114
|
+
readonly threshold?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Role to use when injecting retrieved chunks into the messages
|
|
117
|
+
* slot. Default `'user'`.
|
|
118
|
+
*
|
|
119
|
+
* Why `'user'`: in tool-using ReAct loops, retrieved chunks
|
|
120
|
+
* conceptually "augment what the user asked." Anthropic's tool-use
|
|
121
|
+
* cookbook and OpenAI's RAG cookbook both show retrieved context
|
|
122
|
+
* inside user-turn messages.
|
|
123
|
+
*
|
|
124
|
+
* Use `'system'` for authoritative reference docs that should
|
|
125
|
+
* outweigh user instruction (policy / compliance / brand-voice
|
|
126
|
+
* corpora). Use `'assistant'` only if you've persisted prior agent
|
|
127
|
+
* turns as context — rare.
|
|
128
|
+
*/
|
|
129
|
+
readonly asRole?: ContextRole;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build a RAG context-engineering definition. The returned
|
|
133
|
+
* `MemoryDefinition` is registered on the Agent via `.rag(definition)`
|
|
134
|
+
* (or, equivalently, `.memory(definition)` — same plumbing).
|
|
135
|
+
*
|
|
136
|
+
* @throws when `store` does not implement `search()`. RAG requires a
|
|
137
|
+
* vector-capable adapter.
|
|
138
|
+
*/
|
|
139
|
+
export declare function defineRAG(opts: DefineRAGOptions): MemoryDefinition;
|