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,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MockProvider — deterministic LLMProvider for tests + examples.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Adapter (GoF, Design Patterns ch. 4).
|
|
5
|
+
* Role: Ports-and-Adapters outer ring (Cockburn, 2005) — implements the
|
|
6
|
+
* LLMProvider port without calling out to a real LLM service.
|
|
7
|
+
* Emits: N/A (adapters don't emit; recorders observe them).
|
|
8
|
+
*
|
|
9
|
+
* Two modes, same provider:
|
|
10
|
+
* • DEFAULT (no latency options) — instant `complete()`, no streaming.
|
|
11
|
+
* Use in unit tests; behavior unchanged from earlier revisions.
|
|
12
|
+
* • REALISTIC (`thinkingMs` set) — randomised "thinking" latency before
|
|
13
|
+
* the response, plus a `stream()` implementation that emits the
|
|
14
|
+
* content word-by-word with `chunkDelayMs` between chunks. Lets
|
|
15
|
+
* consumers SEE the run unfold (pauses, streaming tokens, tool
|
|
16
|
+
* dispatch) instead of having every step finish in microseconds.
|
|
17
|
+
*
|
|
18
|
+
* Realistic mode is the right default for the playground / Lens demos:
|
|
19
|
+
* a real OpenAI / Anthropic call takes 3–8 s, so the UX you build for
|
|
20
|
+
* that timing is what matters. Use `MockProvider.realistic()` for the
|
|
21
|
+
* common 3–8 s thinking + 30–80 ms per word streaming preset.
|
|
22
|
+
*/
|
|
23
|
+
import type { LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js';
|
|
24
|
+
/** Either a fixed value (in ms) or a random `[min, max]` range (inclusive). */
|
|
25
|
+
export type LatencyMs = number | readonly [number, number];
|
|
26
|
+
/**
|
|
27
|
+
* One scripted reply consumed in order from `MockProviderOptions.replies`.
|
|
28
|
+
* String → plain text content; Partial<LLMResponse> → can include
|
|
29
|
+
* `toolCalls`, `usage`, `stopReason` for tool-using ReAct loops.
|
|
30
|
+
*/
|
|
31
|
+
export type MockReply = string | Partial<LLMResponse>;
|
|
32
|
+
export interface MockProviderOptions {
|
|
33
|
+
readonly name?: string;
|
|
34
|
+
/** Fixed response content. Overrides `respond` when set. */
|
|
35
|
+
readonly reply?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Scripted replies for multi-turn / tool-using agents. Each entry
|
|
38
|
+
* is consumed in order — iteration 1 reads `replies[0]`, iteration
|
|
39
|
+
* 2 reads `replies[1]`, and so on. Use Partial<LLMResponse> to
|
|
40
|
+
* inject `toolCalls`:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* mock({
|
|
44
|
+
* replies: [
|
|
45
|
+
* { toolCalls: [{ id: '1', name: 'lookup', args: { id: 42 } }] },
|
|
46
|
+
* { content: 'Found it: refunds take 3 business days.' },
|
|
47
|
+
* ],
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* **Exhaustion semantics:** if the agent calls the LLM more times
|
|
52
|
+
* than there are replies, `complete()` / `stream()` throw a clear
|
|
53
|
+
* error. This makes mock-script bugs loud, not silent. Tune the
|
|
54
|
+
* agent's `maxIterations` to bound the call count.
|
|
55
|
+
*
|
|
56
|
+
* Takes precedence over `reply` and `respond` when set.
|
|
57
|
+
*/
|
|
58
|
+
readonly replies?: readonly MockReply[];
|
|
59
|
+
/**
|
|
60
|
+
* Build the response from the request. Returns either a plain
|
|
61
|
+
* string (renders as content with no tool calls) or a partial
|
|
62
|
+
* `LLMResponse` so consumers can simulate tool calls + multi-turn
|
|
63
|
+
* loops without needing a separate `scripted()` helper.
|
|
64
|
+
*
|
|
65
|
+
* Default: echoes the last user message.
|
|
66
|
+
*/
|
|
67
|
+
readonly respond?: (req: LLMRequest) => string | Partial<LLMResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Simulated wall-clock delay per request (ms).
|
|
70
|
+
* Pass a single number for a fixed delay or a `[min, max]` tuple for
|
|
71
|
+
* a uniformly random delay (e.g. `[3000, 8000]` for "real LLM"
|
|
72
|
+
* thinking time). Default 0 (instant).
|
|
73
|
+
*
|
|
74
|
+
* Aliased via `delayMs` for backward compatibility.
|
|
75
|
+
*/
|
|
76
|
+
readonly thinkingMs?: LatencyMs;
|
|
77
|
+
/** Alias for `thinkingMs`. Kept for back-compat with prior revisions. */
|
|
78
|
+
readonly delayMs?: LatencyMs;
|
|
79
|
+
/**
|
|
80
|
+
* For `stream()`: delay between successive chunks (ms). Pass a
|
|
81
|
+
* single number for a fixed delay or a `[min, max]` tuple for a
|
|
82
|
+
* uniformly random delay per chunk (e.g. `[30, 80]` for typing-like
|
|
83
|
+
* cadence). Default 30ms.
|
|
84
|
+
*
|
|
85
|
+
* Has no effect on `complete()`.
|
|
86
|
+
*/
|
|
87
|
+
readonly chunkDelayMs?: LatencyMs;
|
|
88
|
+
/** Fixed stop reason to return. Default 'stop'. */
|
|
89
|
+
readonly stopReason?: string;
|
|
90
|
+
/** Override usage counts returned. Default: chars/4 heuristic. */
|
|
91
|
+
readonly usage?: Readonly<{
|
|
92
|
+
input?: number;
|
|
93
|
+
output?: number;
|
|
94
|
+
cacheRead?: number;
|
|
95
|
+
cacheWrite?: number;
|
|
96
|
+
}>;
|
|
97
|
+
}
|
|
98
|
+
export declare class MockProvider implements LLMProvider {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
private readonly reply?;
|
|
101
|
+
private readonly replies?;
|
|
102
|
+
private repliesCursor;
|
|
103
|
+
private readonly respond;
|
|
104
|
+
private readonly thinkingMs;
|
|
105
|
+
private readonly chunkDelayMs;
|
|
106
|
+
private readonly stopReason;
|
|
107
|
+
private readonly usageOverride;
|
|
108
|
+
constructor(options?: MockProviderOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Reset the scripted-replies cursor. Useful when reusing one
|
|
111
|
+
* `MockProvider` instance across multiple test scenarios — each
|
|
112
|
+
* scenario can `provider.resetReplies()` to start from `replies[0]`
|
|
113
|
+
* again. No-op when `replies` was not supplied.
|
|
114
|
+
*/
|
|
115
|
+
resetReplies(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Convenience factory for the playground / Lens demo defaults: a
|
|
118
|
+
* real-feel mock with 3–8 s of "thinking" before the response and
|
|
119
|
+
* 30–80 ms per streamed word. Lets users observe pause/resume,
|
|
120
|
+
* streaming, and tool dispatch happening live without hitting a
|
|
121
|
+
* paid API.
|
|
122
|
+
*/
|
|
123
|
+
static realistic(options?: MockProviderOptions): MockProvider;
|
|
124
|
+
complete(req: LLMRequest): Promise<LLMResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Streaming mode — emits the response content word-by-word so
|
|
127
|
+
* consumers (Lens commentary, chat UIs) can render tokens as they
|
|
128
|
+
* arrive. Tool calls land all at once on the final chunk because
|
|
129
|
+
* that is how real providers (OpenAI, Anthropic) deliver them too.
|
|
130
|
+
*/
|
|
131
|
+
stream(req: LLMRequest): AsyncIterable<LLMChunk>;
|
|
132
|
+
private buildResponse;
|
|
133
|
+
/**
|
|
134
|
+
* Resolve the next reply source for one `complete()` / `stream()` call.
|
|
135
|
+
* Priority: `replies` (scripted, throws on exhaustion) → `reply` (single
|
|
136
|
+
* fixed string) → `respond` (callback default). Replies are consumed
|
|
137
|
+
* in order; the cursor is per-instance, not per-request.
|
|
138
|
+
*/
|
|
139
|
+
private consumeNextReply;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Lowercase factory for `MockProvider` — matches the v1 `mock()` import
|
|
143
|
+
* shape so docs and quick-starts stay copy-pasteable. Equivalent to
|
|
144
|
+
* `new MockProvider(options)`.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* import { Agent, mock, defineTool } from 'agentfootprint';
|
|
148
|
+
*
|
|
149
|
+
* const agent = Agent.create({ provider: mock({ reply: 'hello' }) })
|
|
150
|
+
* .tool(defineTool({ name: 'echo', ... }))
|
|
151
|
+
* .build();
|
|
152
|
+
*/
|
|
153
|
+
export declare function mock(options?: MockProviderOptions): MockProvider;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAIProvider — wraps the `openai` SDK as an `LLMProvider`.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Adapter (GoF) + Ports-and-Adapters (Cockburn 2005).
|
|
5
|
+
* Role: Outer ring — translates `LLMRequest`/`LLMResponse` to/from
|
|
6
|
+
* OpenAI's Chat Completions API. Knows nothing about agents,
|
|
7
|
+
* recorders, or compositions.
|
|
8
|
+
* Emits: N/A.
|
|
9
|
+
*
|
|
10
|
+
* ─── Limitations ────────────────────────────────────────────────────
|
|
11
|
+
*
|
|
12
|
+
* • Multi-modal NOT supported (`LLMMessage.content` is
|
|
13
|
+
* `string`). May extend in a future release.
|
|
14
|
+
* • `responseFormat` (JSON-mode) NOT exposed — pass schema
|
|
15
|
+
* instructions via `systemPrompt` for now.
|
|
16
|
+
*
|
|
17
|
+
* The `baseURL` option enables OpenAI-compatible APIs (Ollama, Together,
|
|
18
|
+
* Groq, vLLM, LM Studio) without a separate adapter — see the `ollama()`
|
|
19
|
+
* convenience factory below.
|
|
20
|
+
*/
|
|
21
|
+
import type { LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js';
|
|
22
|
+
interface OpenAIClient {
|
|
23
|
+
chat: {
|
|
24
|
+
completions: {
|
|
25
|
+
create(params: OpenAICreateParams): Promise<OpenAIChatCompletion> | AsyncIterable<OpenAIStreamChunk>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface OpenAICreateParams {
|
|
30
|
+
model: string;
|
|
31
|
+
messages: OpenAIMessage[];
|
|
32
|
+
tools?: OpenAITool[];
|
|
33
|
+
/** Legacy token cap — DEPRECATED by OpenAI and REJECTED by o-series reasoning
|
|
34
|
+
* models. Kept only for custom OpenAI-compatible endpoints (Ollama/vLLM/…). */
|
|
35
|
+
max_tokens?: number;
|
|
36
|
+
/** Current token cap — accepted by all OpenAI/Azure chat models incl. o-series. */
|
|
37
|
+
max_completion_tokens?: number;
|
|
38
|
+
temperature?: number;
|
|
39
|
+
stop?: string[];
|
|
40
|
+
stream?: boolean;
|
|
41
|
+
/** Ask OpenAI/Azure to emit a final usage chunk while streaming. */
|
|
42
|
+
stream_options?: {
|
|
43
|
+
include_usage: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface OpenAIMessage {
|
|
47
|
+
role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
|
|
48
|
+
content: string | null;
|
|
49
|
+
tool_calls?: OpenAIToolCall[];
|
|
50
|
+
tool_call_id?: string;
|
|
51
|
+
}
|
|
52
|
+
interface OpenAIToolCall {
|
|
53
|
+
id: string;
|
|
54
|
+
type: 'function';
|
|
55
|
+
function: {
|
|
56
|
+
name: string;
|
|
57
|
+
arguments: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
interface OpenAITool {
|
|
61
|
+
type: 'function';
|
|
62
|
+
function: {
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
65
|
+
parameters: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
interface OpenAIChatCompletion {
|
|
69
|
+
id: string;
|
|
70
|
+
model: string;
|
|
71
|
+
choices: Array<{
|
|
72
|
+
index: number;
|
|
73
|
+
message: {
|
|
74
|
+
role: 'assistant';
|
|
75
|
+
content: string | null;
|
|
76
|
+
tool_calls?: OpenAIToolCall[];
|
|
77
|
+
};
|
|
78
|
+
finish_reason: 'stop' | 'tool_calls' | 'length' | 'content_filter' | string;
|
|
79
|
+
}>;
|
|
80
|
+
usage?: {
|
|
81
|
+
prompt_tokens: number;
|
|
82
|
+
completion_tokens: number;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
interface OpenAIStreamChunk {
|
|
86
|
+
id: string;
|
|
87
|
+
model: string;
|
|
88
|
+
choices: Array<{
|
|
89
|
+
index: number;
|
|
90
|
+
delta: {
|
|
91
|
+
role?: string;
|
|
92
|
+
content?: string | null;
|
|
93
|
+
tool_calls?: Array<{
|
|
94
|
+
index: number;
|
|
95
|
+
id?: string;
|
|
96
|
+
type?: string;
|
|
97
|
+
function?: {
|
|
98
|
+
name?: string;
|
|
99
|
+
arguments?: string;
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
finish_reason: string | null;
|
|
104
|
+
}>;
|
|
105
|
+
usage?: {
|
|
106
|
+
prompt_tokens: number;
|
|
107
|
+
completion_tokens: number;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface OpenAIProviderOptions {
|
|
111
|
+
/** API key. Defaults to `OPENAI_API_KEY` env var. */
|
|
112
|
+
readonly apiKey?: string;
|
|
113
|
+
/** Base URL — set for OpenAI-compatible APIs (Ollama, Together, vLLM). */
|
|
114
|
+
readonly baseURL?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Default model used when `LLMRequest.model` is `'openai'` (the
|
|
117
|
+
* shorthand). Full model ids pass through unchanged.
|
|
118
|
+
*/
|
|
119
|
+
readonly defaultModel?: string;
|
|
120
|
+
/** Default max tokens when the request doesn't set it. Optional. */
|
|
121
|
+
readonly defaultMaxTokens?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Treat the target as a **reasoning model** (o-series: o1 / o3 / o4-mini, or an
|
|
124
|
+
* Azure reasoning deployment). Reasoning models reject `max_tokens` and an explicit
|
|
125
|
+
* `temperature`, and use the `developer` role in place of `system`. Standard o-series
|
|
126
|
+
* model ids are auto-detected; set this explicitly for Azure deployments whose name
|
|
127
|
+
* does not reveal the underlying model.
|
|
128
|
+
*/
|
|
129
|
+
readonly reasoning?: boolean;
|
|
130
|
+
/** @internal Pre-built client for testing. Skips SDK import. */
|
|
131
|
+
readonly _client?: OpenAIClient;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Build an `LLMProvider` backed by OpenAI's Chat Completions API.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* import { Agent } from 'agentfootprint';
|
|
138
|
+
* import { openai } from 'agentfootprint/llm-providers';
|
|
139
|
+
*
|
|
140
|
+
* const agent = Agent.create({
|
|
141
|
+
* provider: openai({ defaultModel: 'gpt-4o' }),
|
|
142
|
+
* model: 'openai',
|
|
143
|
+
* })
|
|
144
|
+
* .tool(searchTool)
|
|
145
|
+
* .build();
|
|
146
|
+
*/
|
|
147
|
+
export declare function openai(options?: OpenAIProviderOptions): LLMProvider;
|
|
148
|
+
/**
|
|
149
|
+
* Class form for consumers who prefer `new OpenAIProvider(...)`.
|
|
150
|
+
*/
|
|
151
|
+
export declare class OpenAIProvider implements LLMProvider {
|
|
152
|
+
readonly name = "openai";
|
|
153
|
+
private readonly inner;
|
|
154
|
+
constructor(options?: OpenAIProviderOptions);
|
|
155
|
+
complete(req: LLMRequest): Promise<LLMResponse>;
|
|
156
|
+
stream(req: LLMRequest): AsyncIterable<LLMChunk>;
|
|
157
|
+
}
|
|
158
|
+
export interface AzureOpenAIProviderOptions {
|
|
159
|
+
/** Resource endpoint, e.g. `https://my-co.openai.azure.com`. Env fallbacks:
|
|
160
|
+
* `AZURE_OPENAI_ENDPOINT`, then `OPENAI_BASE_URL`. */
|
|
161
|
+
readonly endpoint?: string;
|
|
162
|
+
/** API key. Env fallbacks: `AZURE_OPENAI_API_KEY`, then `OPENAI_API_KEY`. */
|
|
163
|
+
readonly apiKey?: string;
|
|
164
|
+
/** Azure API version, e.g. `2024-12-01-preview`. Env fallback:
|
|
165
|
+
* `AZURE_OPENAI_API_VERSION`. Required. */
|
|
166
|
+
readonly apiVersion?: string;
|
|
167
|
+
/** The DEPLOYMENT name (Azure's "model"), e.g. `gpt-4o-128k`. Env fallbacks:
|
|
168
|
+
* `AZURE_OPENAI_DEPLOYMENT`, then `MODEL_NAME`. Required. */
|
|
169
|
+
readonly deployment?: string;
|
|
170
|
+
/** Default max tokens when the request doesn't set it. Optional. */
|
|
171
|
+
readonly defaultMaxTokens?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Set when the Azure DEPLOYMENT is a **reasoning model** (o1/o3/o4-mini). Azure
|
|
174
|
+
* deployment names are arbitrary, so this cannot be auto-detected — declare it to
|
|
175
|
+
* omit `temperature` and send the `developer` role. (`max_completion_tokens` is used
|
|
176
|
+
* for all Azure deployments regardless.)
|
|
177
|
+
*/
|
|
178
|
+
readonly reasoning?: boolean;
|
|
179
|
+
/** @internal Pre-built client for testing. Skips SDK import. */
|
|
180
|
+
readonly _client?: OpenAIClient;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Build an `LLMProvider` for **Azure OpenAI**.
|
|
184
|
+
*
|
|
185
|
+
* Azure is NOT a drop-in OpenAI-compatible URL — it uses a deployment-scoped
|
|
186
|
+
* path, `api-key` header auth, and an `api-version` query param. This wraps the
|
|
187
|
+
* `openai` SDK's `AzureOpenAI` client (which handles all that) and reuses the
|
|
188
|
+
* exact same completion/streaming/tool-call logic as `openai()`.
|
|
189
|
+
*
|
|
190
|
+
* The request's `model` is the Azure **deployment** name. Pass a deployment id
|
|
191
|
+
* to target it; the shorthands `'azure'` / `'azure-openai'` resolve to the
|
|
192
|
+
* configured default `deployment`.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* import { azureOpenai } from 'agentfootprint/llm-providers';
|
|
196
|
+
*
|
|
197
|
+
* const agent = Agent.create({
|
|
198
|
+
* provider: azureOpenai({
|
|
199
|
+
* endpoint: process.env.OPENAI_BASE_URL, // *.openai.azure.com
|
|
200
|
+
* apiKey: process.env.AZURE_OPENAI_API_KEY,
|
|
201
|
+
* apiVersion: process.env.AZURE_OPENAI_API_VERSION, // 2024-12-01-preview
|
|
202
|
+
* deployment: process.env.MODEL_NAME, // gpt-4o-128k
|
|
203
|
+
* }),
|
|
204
|
+
* model: 'azure',
|
|
205
|
+
* }).build();
|
|
206
|
+
*/
|
|
207
|
+
export declare function azureOpenai(options?: AzureOpenAIProviderOptions): LLMProvider;
|
|
208
|
+
/**
|
|
209
|
+
* Convenience factory for Ollama (OpenAI-compatible endpoint).
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* import { ollama } from 'agentfootprint/llm-providers';
|
|
213
|
+
*
|
|
214
|
+
* const provider = ollama({ defaultModel: 'llama3.2' });
|
|
215
|
+
* // Talks to http://localhost:11434/v1 by default.
|
|
216
|
+
*/
|
|
217
|
+
export declare function ollama(options?: OpenAIProviderOptions & {
|
|
218
|
+
readonly host?: string;
|
|
219
|
+
}): LLMProvider;
|
|
220
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createProvider — by-name factory for any built-in LLMProvider.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Abstract Factory (GoF) over the concrete provider factories.
|
|
5
|
+
* Role: Convenience entry point. Useful for config-driven setups
|
|
6
|
+
* where the provider is chosen at runtime (env var, feature
|
|
7
|
+
* flag, tenant preference).
|
|
8
|
+
* Emits: N/A.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const kind = (process.env.LLM_PROVIDER ?? 'anthropic') as ProviderKind;
|
|
12
|
+
* const provider = createProvider({
|
|
13
|
+
* kind,
|
|
14
|
+
* apiKey: process.env.LLM_API_KEY,
|
|
15
|
+
* defaultModel: process.env.LLM_MODEL,
|
|
16
|
+
* } as CreateProviderOptions);
|
|
17
|
+
*
|
|
18
|
+
* For provider-specific options (Bedrock region, Ollama host, Browser
|
|
19
|
+
* apiUrl, etc.) construct the underlying factory directly — this
|
|
20
|
+
* helper deliberately exposes only the common subset.
|
|
21
|
+
*/
|
|
22
|
+
import type { LLMProvider } from '../types.js';
|
|
23
|
+
import { type MockProviderOptions } from './MockProvider.js';
|
|
24
|
+
import { type AnthropicProviderOptions } from './AnthropicProvider.js';
|
|
25
|
+
import { type OpenAIProviderOptions } from './OpenAIProvider.js';
|
|
26
|
+
import { type BedrockProviderOptions } from './BedrockProvider.js';
|
|
27
|
+
import { type BrowserAnthropicProviderOptions } from './BrowserAnthropicProvider.js';
|
|
28
|
+
import { type BrowserOpenAIProviderOptions } from './BrowserOpenAIProvider.js';
|
|
29
|
+
/** Built-in provider kinds. Custom providers don't go through this factory. */
|
|
30
|
+
export type ProviderKind = 'mock' | 'anthropic' | 'openai' | 'ollama' | 'bedrock' | 'browser-anthropic' | 'browser-openai';
|
|
31
|
+
/**
|
|
32
|
+
* Common subset of options accepted across all built-in providers.
|
|
33
|
+
* Provider-specific keys (region for Bedrock, host for Ollama,
|
|
34
|
+
* organization for OpenAI, apiUrl for browser) are passed through
|
|
35
|
+
* verbatim — TypeScript narrows by `kind`.
|
|
36
|
+
*/
|
|
37
|
+
export type CreateProviderOptions = ({
|
|
38
|
+
readonly kind: 'mock';
|
|
39
|
+
} & MockProviderOptions) | ({
|
|
40
|
+
readonly kind: 'anthropic';
|
|
41
|
+
} & AnthropicProviderOptions) | ({
|
|
42
|
+
readonly kind: 'openai';
|
|
43
|
+
} & OpenAIProviderOptions) | ({
|
|
44
|
+
readonly kind: 'ollama';
|
|
45
|
+
} & OpenAIProviderOptions & {
|
|
46
|
+
readonly host?: string;
|
|
47
|
+
}) | ({
|
|
48
|
+
readonly kind: 'bedrock';
|
|
49
|
+
} & BedrockProviderOptions) | ({
|
|
50
|
+
readonly kind: 'browser-anthropic';
|
|
51
|
+
} & BrowserAnthropicProviderOptions) | ({
|
|
52
|
+
readonly kind: 'browser-openai';
|
|
53
|
+
} & BrowserOpenAIProviderOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Build any built-in LLMProvider from a tagged options object.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createProvider(options: CreateProviderOptions): LLMProvider;
|
|
58
|
+
/** What `providerFromEnv()` resolved: the provider + the `model` to pass to
|
|
59
|
+
* `Agent.create({ provider, model })`, and which `kind` was detected. */
|
|
60
|
+
export interface ProviderFromEnv {
|
|
61
|
+
readonly provider: LLMProvider;
|
|
62
|
+
readonly model: string;
|
|
63
|
+
readonly kind: 'azure-openai' | 'anthropic' | 'openai' | 'mock';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolve an `LLMProvider` from environment variables — drop your company's
|
|
67
|
+
* values in `.env` and the right provider is configured automatically, with no
|
|
68
|
+
* code branching. (Node only — reads `process.env`; the vendor SDK is lazy-loaded
|
|
69
|
+
* only for the detected provider.)
|
|
70
|
+
*
|
|
71
|
+
* Detection order (first match wins):
|
|
72
|
+
* 1. **Azure OpenAI** — `AZURE_OPENAI_API_KEY` + (`AZURE_OPENAI_ENDPOINT` |
|
|
73
|
+
* `OPENAI_BASE_URL`) [+ `AZURE_OPENAI_API_VERSION`, `AZURE_OPENAI_DEPLOYMENT`|`MODEL_NAME`]
|
|
74
|
+
* 2. **Anthropic** — `ANTHROPIC_API_KEY`
|
|
75
|
+
* 3. **OpenAI** — `OPENAI_API_KEY`
|
|
76
|
+
* Otherwise throws (or returns the mock when `{ fallbackToMock: true }`).
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* import { providerFromEnv } from 'agentfootprint';
|
|
80
|
+
* const { provider, model, kind } = providerFromEnv({ fallbackToMock: true });
|
|
81
|
+
* const agent = Agent.create({ provider, model }).build();
|
|
82
|
+
*/
|
|
83
|
+
export declare function providerFromEnv(opts?: {
|
|
84
|
+
readonly fallbackToMock?: boolean;
|
|
85
|
+
}): ProviderFromEnv;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentCoreStore — AWS Bedrock **AgentCore Memory** adapter
|
|
3
|
+
* (peer-dep `@aws-sdk/client-bedrock-agentcore`).
|
|
4
|
+
*
|
|
5
|
+
* import { AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
6
|
+
*
|
|
7
|
+
* const store = new AgentCoreStore({
|
|
8
|
+
* memoryId: 'arn:aws:bedrock-agentcore:us-west-2:...:memory/my-mem',
|
|
9
|
+
* region: 'us-west-2',
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* Pattern: Adapter (GoF) — maps the `MemoryStore` interface onto AgentCore Memory's
|
|
13
|
+
* data-plane **event** model (`CreateEvent` / `GetEvent` / `ListEvents` /
|
|
14
|
+
* `DeleteEvent`, `@aws-sdk/client-bedrock-agentcore`):
|
|
15
|
+
* MemoryIdentity.{tenant,principal} ↔ AgentCore `actorId`
|
|
16
|
+
* MemoryIdentity.conversationId ↔ AgentCore `sessionId`
|
|
17
|
+
* MemoryEntry ↔ one event whose `payload` is a single
|
|
18
|
+
* `blob` document holding the entry
|
|
19
|
+
*
|
|
20
|
+
* **AgentCore Memory is an append-only event log, not a key-value store.** The server
|
|
21
|
+
* assigns each event's `eventId` on `CreateEvent` (you cannot choose it), and there is no
|
|
22
|
+
* "delete the whole session" call. This shapes the adapter:
|
|
23
|
+
*
|
|
24
|
+
* • `put` → `CreateEvent` (append; `actorId` + `eventTimestamp` are required). O(1)
|
|
25
|
+
* • `list` → `ListEvents` (paginated, `includePayloads`). ← window / episodic memory. O(page)
|
|
26
|
+
* • `get(id)` / `delete(id)` → list-then-find by the entry id stored in the blob, since
|
|
27
|
+
* AgentCore's ids are server-assigned. **O(events in session)** — fine for typical
|
|
28
|
+
* window sizes; if you need O(1) keyed access at scale, use RedisStore.
|
|
29
|
+
* • `forget` → `ListEvents` + `DeleteEvent` per event (no `DeleteSession` on AgentCore).
|
|
30
|
+
* • `search` → still unwired (AgentCore's `RetrieveMemoryRecords` lands as a later helper).
|
|
31
|
+
* • `putIfVersion` / `seen` / `feedback` → in-process emulation (AgentCore has no native
|
|
32
|
+
* CAS / dedup / feedback primitive; these don't survive process restart).
|
|
33
|
+
*
|
|
34
|
+
* Role: Outer ring. Lazy-requires the AWS SDK; zero runtime cost when another adapter is
|
|
35
|
+
* in use. Emits: N/A (storage adapters don't emit).
|
|
36
|
+
*/
|
|
37
|
+
import type { ListOptions, ListResult, MemoryStore, PutIfVersionResult } from '../../memory/store/types.js';
|
|
38
|
+
import type { MemoryEntry } from '../../memory/entry/index.js';
|
|
39
|
+
import type { MemoryIdentity } from '../../memory/identity/index.js';
|
|
40
|
+
/** One event as the adapter cares about it: AgentCore's id + the decoded entry. */
|
|
41
|
+
export interface AgentCoreEvent {
|
|
42
|
+
/** AgentCore server-assigned event id (needed to delete it). */
|
|
43
|
+
readonly eventId: string;
|
|
44
|
+
/** The MemoryEntry decoded from the event's blob payload (null if unparseable). */
|
|
45
|
+
readonly entry: MemoryEntry | null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Minimal, entry-semantic surface the store uses. The real implementation
|
|
49
|
+
* (`createAgentCoreClient`) maps these onto `CreateEvent` / `ListEvents` /
|
|
50
|
+
* `DeleteEvent`; tests inject a mock via `_client`.
|
|
51
|
+
*/
|
|
52
|
+
export interface AgentCoreLikeClient {
|
|
53
|
+
/** Append one entry as an event (server assigns the eventId). */
|
|
54
|
+
createEvent(input: {
|
|
55
|
+
memoryId: string;
|
|
56
|
+
actorId: string;
|
|
57
|
+
sessionId: string;
|
|
58
|
+
entry: MemoryEntry;
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
/** One page of the session's events (newest-first is AgentCore's default). */
|
|
61
|
+
listEvents(input: {
|
|
62
|
+
memoryId: string;
|
|
63
|
+
actorId: string;
|
|
64
|
+
sessionId: string;
|
|
65
|
+
maxResults?: number;
|
|
66
|
+
nextToken?: string;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
events: readonly AgentCoreEvent[];
|
|
69
|
+
nextToken?: string;
|
|
70
|
+
}>;
|
|
71
|
+
/** Delete one event by its AgentCore eventId. */
|
|
72
|
+
deleteEvent(input: {
|
|
73
|
+
memoryId: string;
|
|
74
|
+
actorId: string;
|
|
75
|
+
sessionId: string;
|
|
76
|
+
eventId: string;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
export interface AgentCoreStoreOptions {
|
|
80
|
+
/** AgentCore Memory ARN or id. Required. */
|
|
81
|
+
readonly memoryId: string;
|
|
82
|
+
/** AWS region. Required when constructing the SDK client internally. */
|
|
83
|
+
readonly region?: string;
|
|
84
|
+
/** Pre-built AgentCore client (shares one SDK config across the host app). */
|
|
85
|
+
readonly client?: AgentCoreLikeClient;
|
|
86
|
+
/** Page size for `listEvents`. Default 100. */
|
|
87
|
+
readonly pageSize?: number;
|
|
88
|
+
/** @internal Test injection — skips the SDK require entirely. */
|
|
89
|
+
readonly _client?: AgentCoreLikeClient;
|
|
90
|
+
/** @internal Test injection — the AWS SDK module (to exercise the real shim with a mock SDK). */
|
|
91
|
+
readonly _sdk?: BedrockAgentCoreSdkModule;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* AgentCore Memory-backed `MemoryStore`. Implements every method except `search()`.
|
|
95
|
+
*
|
|
96
|
+
* @throws when `@aws-sdk/client-bedrock-agentcore` is not installed and no `_client`/`_sdk`
|
|
97
|
+
* is supplied.
|
|
98
|
+
*/
|
|
99
|
+
export declare class AgentCoreStore implements MemoryStore {
|
|
100
|
+
private readonly client;
|
|
101
|
+
private readonly memoryId;
|
|
102
|
+
private readonly pageSize;
|
|
103
|
+
private closed;
|
|
104
|
+
private readonly signatures;
|
|
105
|
+
private readonly feedbackBag;
|
|
106
|
+
constructor(options: AgentCoreStoreOptions);
|
|
107
|
+
private actorId;
|
|
108
|
+
private sessionId;
|
|
109
|
+
private scope;
|
|
110
|
+
private shadowKey;
|
|
111
|
+
private feedbackKey;
|
|
112
|
+
/** Walk every event in the session (paginated). */
|
|
113
|
+
private eachEvent;
|
|
114
|
+
get<T = unknown>(identity: MemoryIdentity, id: string): Promise<MemoryEntry<T> | null>;
|
|
115
|
+
put<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>): Promise<void>;
|
|
116
|
+
putMany<T = unknown>(identity: MemoryIdentity, entries: readonly MemoryEntry<T>[]): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Emulated optimistic concurrency. AgentCore appends unconditionally; we read-then-write
|
|
119
|
+
* inside a JS critical section — adequate for single-writer-per-session deployments.
|
|
120
|
+
*/
|
|
121
|
+
putIfVersion<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>, expectedVersion: number): Promise<PutIfVersionResult>;
|
|
122
|
+
list<T = unknown>(identity: MemoryIdentity, options?: ListOptions): Promise<ListResult<T>>;
|
|
123
|
+
delete(identity: MemoryIdentity, id: string): Promise<void>;
|
|
124
|
+
seen(identity: MemoryIdentity, signature: string): Promise<boolean>;
|
|
125
|
+
recordSignature(identity: MemoryIdentity, signature: string): Promise<void>;
|
|
126
|
+
feedback(identity: MemoryIdentity, id: string, usefulness: number): Promise<void>;
|
|
127
|
+
getFeedback(identity: MemoryIdentity, id: string): Promise<{
|
|
128
|
+
average: number;
|
|
129
|
+
count: number;
|
|
130
|
+
} | null>;
|
|
131
|
+
/** GDPR "everything for this identity, gone." No DeleteSession on AgentCore → delete every event. */
|
|
132
|
+
forget(identity: MemoryIdentity): Promise<void>;
|
|
133
|
+
close(): Promise<void>;
|
|
134
|
+
private ensureOpen;
|
|
135
|
+
}
|
|
136
|
+
/** The slice of `@aws-sdk/client-bedrock-agentcore` the shim touches. */
|
|
137
|
+
export interface BedrockAgentCoreSdkModule {
|
|
138
|
+
readonly BedrockAgentCoreClient?: new (config: {
|
|
139
|
+
region?: string;
|
|
140
|
+
}) => {
|
|
141
|
+
send(cmd: unknown): Promise<unknown>;
|
|
142
|
+
};
|
|
143
|
+
readonly CreateEventCommand?: new (input: unknown) => unknown;
|
|
144
|
+
readonly ListEventsCommand?: new (input: unknown) => unknown;
|
|
145
|
+
readonly DeleteEventCommand?: new (input: unknown) => unknown;
|
|
146
|
+
}
|