agentfootprint 6.44.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CLAUDE.md +4 -0
- package/README.md +141 -167
- package/ai-instructions/claude-code/SKILL.md +11 -0
- package/ai-instructions/setup.sh +0 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/adapters/llm/MockProvider.js +2 -1
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/debug/finders.js +29 -0
- package/dist/debug/finders.js.map +1 -0
- package/dist/debug.js +134 -0
- package/dist/debug.js.map +1 -0
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +154 -0
- package/dist/esm/adapters/llm/MockProvider.js +2 -1
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/debug/finders.d.ts +12 -0
- package/dist/esm/debug/finders.js +13 -0
- package/dist/esm/debug/finders.js.map +1 -0
- package/dist/esm/debug.d.ts +25 -0
- package/dist/esm/debug.js +54 -0
- package/dist/esm/debug.js.map +1 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/events.d.ts +18 -0
- package/dist/esm/events.js +22 -0
- package/dist/esm/events.js.map +1 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +44 -0
- package/dist/esm/index.js +7 -52
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +2 -1
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +290 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +38 -43
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/defineRAG.js +3 -3
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +106 -0
- package/dist/esm/lib/rag/indexDocuments.js +2 -1
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +141 -0
- package/dist/esm/locales/index.js +7 -0
- package/dist/esm/locales/index.js.map +1 -1
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +134 -0
- package/dist/esm/memory/causal/types.js.map +1 -1
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +278 -0
- package/dist/esm/memory/define.types.js +6 -4
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +57 -0
- package/dist/esm/observe.js +7 -36
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/providers.js +1 -1
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +54 -0
- package/dist/esm/status.js +13 -4
- package/dist/esm/status.js.map +1 -1
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/events.js +42 -0
- package/dist/events.js.map +1 -0
- package/dist/index.js +7 -117
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +6 -2
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +40 -45
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/rag/defineRAG.js +3 -3
- package/dist/lib/rag/indexDocuments.js +2 -1
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/locales/index.js +2 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/memory/causal/types.js.map +1 -1
- package/dist/memory/define.types.js +6 -4
- package/dist/memory/define.types.js.map +1 -1
- package/dist/observe.js +22 -115
- package/dist/observe.js.map +1 -1
- package/dist/providers.js +3 -1
- package/dist/providers.js.map +1 -1
- package/dist/status.js +13 -5
- package/dist/status.js.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/debug/finders.d.ts +13 -0
- package/dist/types/debug/finders.d.ts.map +1 -0
- package/dist/types/debug.d.ts +26 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/events.d.ts +19 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -24
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +2 -1
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +24 -26
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/rag/defineRAG.d.ts +3 -3
- package/dist/types/lib/rag/indexDocuments.d.ts +2 -1
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/locales/index.d.ts +9 -0
- package/dist/types/locales/index.d.ts.map +1 -1
- package/dist/types/memory/causal/types.d.ts +13 -9
- package/dist/types/memory/causal/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +6 -4
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/observe.d.ts +1 -6
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/providers.d.ts +2 -2
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/status.d.ts +10 -4
- package/dist/types/status.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +1 -1
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +261 -57
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mountMemoryPipeline — mount a MemoryPipeline's read + write subflows
|
|
3
|
+
* into an arbitrary agent flowchart.
|
|
4
|
+
*
|
|
5
|
+
* Given:
|
|
6
|
+
* - a `FlowChartBuilder<AgentState>` the caller has been assembling,
|
|
7
|
+
* - a `MemoryPipeline { read, write }` (typically from a preset),
|
|
8
|
+
* - identity + turn + budget inputs sourced from agent scope,
|
|
9
|
+
* - mount points (which stage id to insert the read subflow before),
|
|
10
|
+
*
|
|
11
|
+
* returns the builder with:
|
|
12
|
+
* 1. the `read` subflow mounted BEFORE the given anchor stage, with an
|
|
13
|
+
* inputMapper that reads identity/turn/budget from agent scope and
|
|
14
|
+
* an outputMapper that writes `formatted` messages back,
|
|
15
|
+
* 2. the `write` subflow (if present) appended AT THE END, with an
|
|
16
|
+
* inputMapper that reads `newMessages` from agent scope.
|
|
17
|
+
*
|
|
18
|
+
* The agent's existing stages are responsible for:
|
|
19
|
+
* - populating `identity`, `turnNumber`, `contextTokensRemaining`,
|
|
20
|
+
* `newMessages` in scope BEFORE the relevant memory subflow runs,
|
|
21
|
+
* - consuming the injected `formatted` messages (merge into the
|
|
22
|
+
* agent's outgoing LLM prompt).
|
|
23
|
+
*
|
|
24
|
+
* This helper does NOT own any of those concerns — it owns only the
|
|
25
|
+
* mechanical subflow mounting. Consumer-facing API
|
|
26
|
+
* (`AgentBuilder.memoryPipeline()`) is layered on top.
|
|
27
|
+
*
|
|
28
|
+
* Why a standalone helper, not a direct `AgentBuilder` patch?
|
|
29
|
+
* - Lets us test the wire mechanism end-to-end in isolation (Layer 6)
|
|
30
|
+
* without changing the existing AgentRunner path (100+ tests).
|
|
31
|
+
* - The wire is a small, reviewable unit; the AgentBuilder refactor is
|
|
32
|
+
* a larger concern that can ship separately.
|
|
33
|
+
* - Future non-Agent concepts (Swarm, Parallel) can use the same helper
|
|
34
|
+
* — memory isn't tied to Agent conceptually.
|
|
35
|
+
*/
|
|
36
|
+
import type { FlowChartBuilder } from 'footprintjs';
|
|
37
|
+
import type { MemoryPipeline } from '../pipeline/types.js';
|
|
38
|
+
/**
|
|
39
|
+
* Keys this helper reads from / writes to on the parent agent scope.
|
|
40
|
+
* Kept as fields on the config so consumers with non-standard field names
|
|
41
|
+
* can override without renaming scope properties.
|
|
42
|
+
*/
|
|
43
|
+
export interface MountMemoryPipelineConfig<ParentState> {
|
|
44
|
+
/** The compiled read + write subflows from a pipeline preset. */
|
|
45
|
+
readonly pipeline: MemoryPipeline;
|
|
46
|
+
/**
|
|
47
|
+
* Scope field name the read subflow reads identity from. Default
|
|
48
|
+
* `'identity'` — matches `MemoryState.identity`. Override when the
|
|
49
|
+
* host flowchart uses a different name.
|
|
50
|
+
*/
|
|
51
|
+
readonly identityKey?: keyof ParentState & string;
|
|
52
|
+
/** Scope field name for the turn counter. Default `'turnNumber'`. */
|
|
53
|
+
readonly turnNumberKey?: keyof ParentState & string;
|
|
54
|
+
/**
|
|
55
|
+
* Scope field name for the context-tokens-remaining signal.
|
|
56
|
+
* Default `'contextTokensRemaining'`.
|
|
57
|
+
*/
|
|
58
|
+
readonly contextTokensKey?: keyof ParentState & string;
|
|
59
|
+
/**
|
|
60
|
+
* Scope field the read subflow writes its `formatted` output to.
|
|
61
|
+
* Default `'memoryInjection'` — agent stages consume this to prepend
|
|
62
|
+
* to the LLM prompt. Distinct from the pipeline's own `formatted`
|
|
63
|
+
* field so there's no ambiguity between subflow-local and parent scope.
|
|
64
|
+
*/
|
|
65
|
+
readonly injectionKey?: keyof ParentState & string;
|
|
66
|
+
/**
|
|
67
|
+
* Scope field the write subflow reads messages to persist from.
|
|
68
|
+
* Default `'newMessages'` — populated by the agent at turn end.
|
|
69
|
+
*/
|
|
70
|
+
readonly newMessagesKey?: keyof ParentState & string;
|
|
71
|
+
/** Subflow id for the read mount. Default `'sf-memory-read'`. */
|
|
72
|
+
readonly readSubflowId?: string;
|
|
73
|
+
/** Subflow id for the write mount. Default `'sf-memory-write'`. */
|
|
74
|
+
readonly writeSubflowId?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Evidence source for CAUSAL pipelines (the evidence bridge, backlog #5).
|
|
77
|
+
* Called by the write mount's inputMapper at write time; its result lands on
|
|
78
|
+
* `MemoryState.runEvidence` so `writeSnapshot` persists real decisions /
|
|
79
|
+
* tool calls / iterations / duration / token usage instead of zeros. The
|
|
80
|
+
* Agent threads `causalEvidenceRecorder().collect` here automatically when a
|
|
81
|
+
* CAUSAL memory is mounted. Omit for non-causal pipelines.
|
|
82
|
+
*/
|
|
83
|
+
readonly evidenceSource?: () => import('../causal/evidenceRecorder.js').RunEvidence;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mount only the READ subflow. Appends at the current builder tail, so
|
|
87
|
+
* callers typically invoke this BEFORE their LLM-call stage:
|
|
88
|
+
*
|
|
89
|
+
* let b = flowChart('Seed', seedFn, 'seed');
|
|
90
|
+
* b = mountMemoryRead(b, { pipeline });
|
|
91
|
+
* b = b.addFunction('CallLLM', llmStage, 'call-llm'); // reads memoryInjection
|
|
92
|
+
* b = mountMemoryWrite(b, { pipeline }); // persists newMessages
|
|
93
|
+
*
|
|
94
|
+
* Returns the same builder reference (fluent).
|
|
95
|
+
*/
|
|
96
|
+
export declare function mountMemoryRead<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
97
|
+
/**
|
|
98
|
+
* Mount only the WRITE subflow. No-op when the pipeline has no `write`
|
|
99
|
+
* (e.g., ephemeral pipelines) — returns the builder unchanged.
|
|
100
|
+
*/
|
|
101
|
+
export declare function mountMemoryWrite<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
102
|
+
/**
|
|
103
|
+
* Convenience: mount both read and write subflows back-to-back.
|
|
104
|
+
* Appropriate ONLY when the host flowchart has no stages between memory
|
|
105
|
+
* read and memory write (rare — most agents have the LLM call between).
|
|
106
|
+
* Prefer `mountMemoryRead` + stages + `mountMemoryWrite` for typical agents.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mountMemoryPipeline<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/memory-providers — memory store adapters (canonical subpath).
|
|
3
|
+
*
|
|
4
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
5
|
+
* v2.5:
|
|
6
|
+
*
|
|
7
|
+
* agentfootprint/llm-providers ← LLM provider adapters
|
|
8
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
9
|
+
* agentfootprint/memory-providers ← memory store adapters (this file)
|
|
10
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
11
|
+
*
|
|
12
|
+
* One subpath that grows — RedisStore, AgentCoreStore, and future
|
|
13
|
+
* stores (DynamoDB, Postgres, Pinecone, …) all live here. No more
|
|
14
|
+
* adding `agentfootprint/memory-<vendor>` per-adapter subpath each
|
|
15
|
+
* time a new store ships.
|
|
16
|
+
*
|
|
17
|
+
* Per-adapter aliases (`agentfootprint/memory-redis`,
|
|
18
|
+
* `agentfootprint/memory-agentcore`) stay available through the v2.x
|
|
19
|
+
* line — they point at the same files. New code SHOULD import from
|
|
20
|
+
* `agentfootprint/memory-providers`:
|
|
21
|
+
*
|
|
22
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
23
|
+
*
|
|
24
|
+
* Pattern: Adapter (GoF) — each store translates the `MemoryStore`
|
|
25
|
+
* interface onto a specific backend (Redis, DynamoDB-style
|
|
26
|
+
* AWS Bedrock AgentCore Memory, etc.).
|
|
27
|
+
* Role: Outer ring (Hexagonal). All store adapters lazy-require
|
|
28
|
+
* their vendor SDKs at construction time, so importing this
|
|
29
|
+
* barrel costs ZERO peer-dep load — only the stores you
|
|
30
|
+
* actually instantiate pull their SDK in.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
34
|
+
*/
|
|
35
|
+
export { RedisStore, type RedisStoreOptions, type RedisLikeClient, type RedisLikePipeline, } from './adapters/memory/redis.js';
|
|
36
|
+
export { AgentCoreStore, type AgentCoreStoreOptions, type AgentCoreLikeClient, } from './adapters/memory/agentcore.js';
|
|
37
|
+
export { BedrockAgentMemory, type BedrockAgentMemoryOptions, type BedrockAgentMemoryLikeClient, type BedrockAgentSummary, } from './adapters/memory/bedrockAgentMemory.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compareFinders — run several finders on the same case and collect their answers
|
|
3
|
+
* side by side (a leaderboard row per finder). PARAMETRIC: you pass the finders to
|
|
4
|
+
* compare, so nothing is auto-discovered or retained — unused finders stay
|
|
5
|
+
* tree-shakeable.
|
|
6
|
+
*/
|
|
7
|
+
import type { Finder, FindInput, FindResult } from './types.js';
|
|
8
|
+
/** One finder's result in a comparison (or the error it threw). */
|
|
9
|
+
export interface CompareRow {
|
|
10
|
+
readonly finder: string;
|
|
11
|
+
readonly result: FindResult | null;
|
|
12
|
+
readonly error?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Run each finder on `input`; a finder that throws (e.g. missing a dep it needs)
|
|
16
|
+
* becomes a row with `result: null` and `error` set, so one finder cannot abort
|
|
17
|
+
* the comparison.
|
|
18
|
+
*/
|
|
19
|
+
export declare function compareFinders(finders: readonly Finder[], input: FindInput): Promise<CompareRow[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* observability / contextError / finders — pluggable context-bug localization.
|
|
3
|
+
*
|
|
4
|
+
* "Which piece of context made the agent's answer wrong?" Pick a finder and call
|
|
5
|
+
* `find(input)`. Each finder is a thin, self-explaining adapter over the engines in
|
|
6
|
+
* `src/lib/context-bisect` + `src/lib/influence-core`; the academic method + citation
|
|
7
|
+
* live in `meta`, never in the import name.
|
|
8
|
+
*
|
|
9
|
+
* import { rankSuspects } from 'agentfootprint/observability/contextError/finders';
|
|
10
|
+
* const r = await rankSuspects.find(input); // r.lead, r.evidence ('guessed'|'proven')
|
|
11
|
+
*
|
|
12
|
+
* Tree-shakeable: one finder = one file = one named export. Importing one finder does
|
|
13
|
+
* not pull the others (or the heavy ablation path behind removeAndRetry). This barrel
|
|
14
|
+
* is re-export-only — no runtime code, no registry.
|
|
15
|
+
*/
|
|
16
|
+
export type { ContextPiece, Evidence, Finder, FinderMeta, FindInput, FindResult, Granularity, ScoredSuspect, StepInput, } from './types.js';
|
|
17
|
+
export { rankSuspects } from './rankSuspects.js';
|
|
18
|
+
export { removeAndRetry } from './removeAndRetry.js';
|
|
19
|
+
export { traceSteps } from './traceSteps.js';
|
|
20
|
+
export { testManyCombos } from './testManyCombos.js';
|
|
21
|
+
export { shrinkToCause } from './shrinkToCause.js';
|
|
22
|
+
export { compareFinders, type CompareRow } from './compareFinders.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* removeAndRetry — the thorough finder. Removes each context piece, re-runs the
|
|
3
|
+
* agent, and a piece is the cause iff its removal flips the outcome back. No
|
|
4
|
+
* embedder, no heuristic: pure counterfactual. Exact, but pays one re-run per
|
|
5
|
+
* piece (`checks`), and on multi-loop runs it can over-attribute (several pieces
|
|
6
|
+
* each flip) — narrow with a slice first when that happens.
|
|
7
|
+
*
|
|
8
|
+
* Method: leave-one-out ablation (counterfactual necessity).
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const removeAndRetry: Finder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shrinkToCause — keeps cutting the suspect set down until the smallest subset whose
|
|
3
|
+
* removal still fixes the answer. For a single dominant cause it converges in fewer
|
|
4
|
+
* re-runs than leave-one-out (delta-debugging minimization); for co-necessary causes it
|
|
5
|
+
* still returns the minimal recovering set, but may cost more probes than leave-one-out.
|
|
6
|
+
* The returned set is verified to recover by construction.
|
|
7
|
+
*
|
|
8
|
+
* Method: delta-debugging minimization (ddmin) over the removal set that recovers.
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const shrinkToCause: Finder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testManyCombos — turns context pieces on and off in many combinations, re-runs each,
|
|
3
|
+
* and learns which pieces drive the wrong answer (a linear-surrogate attribution), then
|
|
4
|
+
* confirms the top candidate with one clean ablation. The sampling one: it estimates an
|
|
5
|
+
* influence weight per piece from counterfactual data rather than ranking by similarity.
|
|
6
|
+
*
|
|
7
|
+
* Method: random-subset ablation + linear-surrogate attribution. Deterministic
|
|
8
|
+
* pseudo-random masking (a reproducible reimplementation of ContextCite's random subsets).
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const testManyCombos: Finder;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context-error finders — the plain, pluggable public surface for context-bug
|
|
3
|
+
* localization. A `Finder` answers one question: "which piece of context made the
|
|
4
|
+
* agent's answer wrong?" Each finder is a thin, named adapter over the engines in
|
|
5
|
+
* `src/lib/context-bisect` + `src/lib/influence-core`; the academic method + citation
|
|
6
|
+
* live in `meta`, never in the import name.
|
|
7
|
+
*
|
|
8
|
+
* Taxonomy (area / category / thing): observability / contextError / finders.
|
|
9
|
+
* Tree-shakeable: one finder = one file = one named export; import only what you use.
|
|
10
|
+
*/
|
|
11
|
+
import type { Embedder } from '../../../lib/influence-core/index.js';
|
|
12
|
+
/** How sure the finder is. `guessed` = ranked by a similarity proxy only;
|
|
13
|
+
* `proven` = a removal/re-run actually flipped the outcome (counterfactual). */
|
|
14
|
+
export type Evidence = 'guessed' | 'proven';
|
|
15
|
+
/** What the finder points at. `piece` = a context element; `step` = an agent step. */
|
|
16
|
+
export type Granularity = 'piece' | 'step';
|
|
17
|
+
/** A removable piece of context the finder can suspect. */
|
|
18
|
+
export interface ContextPiece {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly text: string;
|
|
21
|
+
}
|
|
22
|
+
/** One agent step (a tool-call), for finders that work at step granularity. */
|
|
23
|
+
export interface StepInput {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
/** Human-readable label, e.g. `get_promo@L1`. */
|
|
26
|
+
readonly label: string;
|
|
27
|
+
readonly text: string;
|
|
28
|
+
}
|
|
29
|
+
/** Everything a finder may need. Light finders use `embedder`; counterfactual
|
|
30
|
+
* finders use `rerun`; step finders use `steps`. A finder throws if a field it
|
|
31
|
+
* needs is missing. */
|
|
32
|
+
export interface FindInput {
|
|
33
|
+
/** The removable context pieces to consider. */
|
|
34
|
+
readonly suspects: readonly ContextPiece[];
|
|
35
|
+
/** The wrong answer to explain. */
|
|
36
|
+
readonly wrongOutput: string;
|
|
37
|
+
/** Embedder for similarity-ranking finders. */
|
|
38
|
+
readonly embedder?: Embedder;
|
|
39
|
+
/** Re-run with the given pieces removed; `recovered` = the outcome flipped back. */
|
|
40
|
+
readonly rerun?: (removedIds: readonly string[]) => Promise<{
|
|
41
|
+
recovered: boolean;
|
|
42
|
+
outcome?: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** The agent's steps, for step-granularity finders. */
|
|
45
|
+
readonly steps?: readonly StepInput[];
|
|
46
|
+
/** For testManyCombos: how many on/off combinations to sample (default ~4×#suspects). */
|
|
47
|
+
readonly samples?: number;
|
|
48
|
+
}
|
|
49
|
+
/** One suspect in the finder's ranked output. */
|
|
50
|
+
export interface ScoredSuspect {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
/** Higher = more suspicious. Absent for finders that don't score. */
|
|
53
|
+
readonly score?: number;
|
|
54
|
+
}
|
|
55
|
+
/** What a finder returns. Plain fields, namespace-independent. */
|
|
56
|
+
export interface FindResult {
|
|
57
|
+
/** Which finder produced this. */
|
|
58
|
+
readonly finder: string;
|
|
59
|
+
/** Suspects, most-to-least suspicious. */
|
|
60
|
+
readonly suspects: readonly ScoredSuspect[];
|
|
61
|
+
/** The single top suspect, if any. */
|
|
62
|
+
readonly lead?: string;
|
|
63
|
+
/** The small set worth confirming when there is no clear single winner. */
|
|
64
|
+
readonly shortlist: readonly string[];
|
|
65
|
+
/** `guessed` (proxy) vs `proven` (counterfactual). */
|
|
66
|
+
readonly evidence: Evidence;
|
|
67
|
+
/** `piece` vs `step`. */
|
|
68
|
+
readonly granularity: Granularity;
|
|
69
|
+
/** How many times the finder re-ran the agent (the honest cost). 0 = free. */
|
|
70
|
+
readonly checks: number;
|
|
71
|
+
/** A self-explaining narrative of how the finder reached its answer. */
|
|
72
|
+
readonly explanation: string;
|
|
73
|
+
}
|
|
74
|
+
/** Attribution — kept off the import name, surfaced in docs / leaderboards. */
|
|
75
|
+
export interface FinderMeta {
|
|
76
|
+
/** Plain one-liner for a leaderboard row. */
|
|
77
|
+
readonly label: string;
|
|
78
|
+
/** The precise technique, for experts. */
|
|
79
|
+
readonly method: string;
|
|
80
|
+
/** Citation, if the finder reimplements a published method. */
|
|
81
|
+
readonly paper?: string;
|
|
82
|
+
}
|
|
83
|
+
/** A pluggable context-error finder. */
|
|
84
|
+
export interface Finder {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly meta: FinderMeta;
|
|
87
|
+
find(input: FindInput): Promise<FindResult>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/observability-providers — vendor observability strategies.
|
|
3
|
+
*
|
|
4
|
+
* Grouped subpath following the parallel-providers pattern v2.5
|
|
5
|
+
* established for `llm-providers` / `tool-providers` /
|
|
6
|
+
* `memory-providers`. Adding a new vendor adds an export here, NOT
|
|
7
|
+
* a new subpath — keeps `package.json#exports` from sprawling.
|
|
8
|
+
*
|
|
9
|
+
* Each adapter lazy-imports its vendor SDK via `lib/lazyRequire.ts`,
|
|
10
|
+
* so consumers who never call a particular factory don't have to
|
|
11
|
+
* install that SDK. Peer-deps are declared in package.json with
|
|
12
|
+
* `peerDependenciesMeta.{name}.optional = true`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
17
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
18
|
+
*
|
|
19
|
+
* agent.enable.observability({
|
|
20
|
+
* strategy: agentcoreObservability({
|
|
21
|
+
* region: 'us-east-1',
|
|
22
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
23
|
+
* }),
|
|
24
|
+
* // Recommended — keeps the agent loop unblocked by network latency.
|
|
25
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Roadmap:
|
|
30
|
+
* - agentcoreObservability ← v2.8.1
|
|
31
|
+
* - cloudwatchObservability ← v2.8.2
|
|
32
|
+
* - xrayObservability ← v2.8.3
|
|
33
|
+
* - otelObservability ← v2.9.0 (this release)
|
|
34
|
+
*
|
|
35
|
+
* Note: `datadogObservability` was on the v2.9 roadmap, but Datadog
|
|
36
|
+
* APM accepts OTLP — point your OTel SDK at Datadog's OTLP endpoint
|
|
37
|
+
* and `otelObservability` covers the Datadog use case. We'll ship a
|
|
38
|
+
* dedicated `dd-trace`-based adapter only if real-world feedback
|
|
39
|
+
* demands the native Datadog APM client.
|
|
40
|
+
*/
|
|
41
|
+
export { agentcoreObservability, type AgentcoreObservabilityOptions, } from './adapters/observability/agentcore.js';
|
|
42
|
+
export { cloudwatchObservability, type CloudwatchObservabilityOptions, } from './adapters/observability/cloudwatch.js';
|
|
43
|
+
export { xrayObservability, type XrayObservabilityOptions, type XRayLikeClient, } from './adapters/observability/xray.js';
|
|
44
|
+
export { otelObservability, type OtelObservabilityOptions, type OtelObservabilityStrategy, type OtelDecisionEvidenceRecorder, type OtelTracerLike, type OtelSpanLike, type OtelSpanOptions, type OtelAttributeValue, } from './adapters/observability/otel.js';
|
|
45
|
+
export { auditExport, verifyAuditBundle, AUDIT_BUNDLE_FORMAT, AUDIT_GENESIS_EVENT_TYPE, AUDIT_ZERO_HASH, type AuditBundle, type AuditBundleHeader, type AuditExportOptions, type AuditExportStrategy, type AuditRecord, type AuditVerifyResult, } from './adapters/observability/audit.js';
|
|
46
|
+
export { canonicalJson, CANONICAL_JSON_VERSION } from './lib/canonicalJson.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/observe — observability recorders.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Observer (GoF) — pluggable, fire-and-forget event listeners
|
|
5
|
+
* for the agent's typed event stream.
|
|
6
|
+
* Role: Outer ring (Hexagonal). Attach via `runner.attachScopeRecorder()`;
|
|
7
|
+
* the runner emits events, recorders accumulate state.
|
|
8
|
+
*
|
|
9
|
+
* Three tiers (progressive disclosure):
|
|
10
|
+
*
|
|
11
|
+
* Tier 1 — context + stream (the core)
|
|
12
|
+
* • ContextRecorder — every slot composition
|
|
13
|
+
* • StreamRecorder — token-level LLM streaming
|
|
14
|
+
*
|
|
15
|
+
* Tier 2 — composition + agent (structural nav)
|
|
16
|
+
* • CompositionRecorder — Sequence/Parallel/Conditional/Loop entries
|
|
17
|
+
* • AgentRecorder — agent-loop iterations, tool calls
|
|
18
|
+
* • BoundaryRecorder — domain-tagged subflow entry/exit
|
|
19
|
+
* • FlowchartRecorder — StepGraph projection (Lens-friendly)
|
|
20
|
+
*
|
|
21
|
+
* Tier 3 — domain dashboards (attach on demand)
|
|
22
|
+
* • CostRecorder — token/USD spend
|
|
23
|
+
* • EvalRecorder — eval scores from `runner.emit('eval.*', ...)`
|
|
24
|
+
* • MemoryRecorder — memory injections + writes
|
|
25
|
+
* • PermissionRecorder — permission decisions + denials
|
|
26
|
+
* • SkillRecorder — skill activations
|
|
27
|
+
* • LoggingRecorder — structured log lines per event
|
|
28
|
+
* • StatusRecorder — chat-bubble first-person status
|
|
29
|
+
*
|
|
30
|
+
* Domain-flavored consumers (Lens, Grafana, Datadog) compose Tier 1+2
|
|
31
|
+
* directly; Tier 3 dashboards are opt-in.
|
|
32
|
+
*/
|
|
33
|
+
export { ContextRecorder, type ContextRecorderOptions } from './recorders/core/ContextRecorder.js';
|
|
34
|
+
export { streamRecorder, type StreamRecorderOptions } from './recorders/core/StreamRecorder.js';
|
|
35
|
+
export { compositionRecorder, type CompositionRecorderOptions, } from './recorders/core/CompositionRecorder.js';
|
|
36
|
+
export { agentRecorder, type AgentRecorderOptions } from './recorders/core/AgentRecorder.js';
|
|
37
|
+
export { boundaryRecorder, BoundaryRecorder, type ActorArrow, type BoundaryAggregate, type BoundaryRecorderOptions, type BoundaryRangeLabel, type DomainContextInjectedEvent, type DomainDecisionBranchEvent, type DomainEvent, type DomainForkBranchEvent, type DomainLLMEndEvent, type DomainLLMStartEvent, type DomainLoopIterationEvent, type DomainRunEvent, type DomainSubflowEvent, type DomainToolStartEvent, type DomainToolEndEvent, } from './recorders/observability/BoundaryRecorder.js';
|
|
38
|
+
export { buildRunSteps, RunStepRecorder, runStepRecorder, type BuildRunStepsOptions, type RunStep, type RunStepGraph, type RunStepKind, type RunStepMeta, type RunStepRecorderOptions, type RunStepTransition, } from './recorders/observability/RunStepRecorder.js';
|
|
39
|
+
export { attachFlowchart, buildStepGraph, buildStepGraphFromEvents, type StepGraph, type StepNode, type StepEdge, type SlotBoundary, type ContextInjection, type FlowchartOptions, type FlowchartHandle, } from './recorders/observability/FlowchartRecorder.js';
|
|
40
|
+
export { serializeTrace, redactContent, traceToStepGraph, type Trace, type TraceSummary, type TraceRedaction, type SerializeTraceOptions, } from './recorders/observability/trace.js';
|
|
41
|
+
export { attachLocalObservability, type LocalObservabilityHandle, type LocalObservabilityOptions, } from './recorders/observability/localObservability.js';
|
|
42
|
+
export { liveStateRecorder, LiveStateRecorder, LiveLLMTracker, LiveToolTracker, LiveAgentTurnTracker, type LLMLiveState, type ToolLiveState, type AgentTurnLiveState, type LiveStateRunnerLike, } from './recorders/observability/LiveStateRecorder.js';
|
|
43
|
+
export { costRecorder, type CostRecorderOptions } from './recorders/core/CostRecorder.js';
|
|
44
|
+
export { toolsRecorder, type ToolsRecorderOptions } from './recorders/core/ToolsRecorder.js';
|
|
45
|
+
export { contextEvaluatedRecorder, type ContextEvaluatedRecorderOptions, } from './recorders/core/ContextEvaluatedRecorder.js';
|
|
46
|
+
export { evalRecorder, type EvalRecorderOptions } from './recorders/core/EvalRecorder.js';
|
|
47
|
+
export { memoryRecorder, type MemoryRecorderOptions } from './recorders/core/MemoryRecorder.js';
|
|
48
|
+
export { permissionRecorder, type PermissionRecorderOptions, } from './recorders/core/PermissionRecorder.js';
|
|
49
|
+
export { skillRecorder, type SkillRecorderOptions } from './recorders/core/SkillRecorder.js';
|
|
50
|
+
export { attachLogging, LoggingDomains, type LoggingLogger, type LoggingDomain, type LoggingOptions, } from './recorders/observability/LoggingRecorder.js';
|
|
51
|
+
export { attachStatus, type StatusEvent, type StatusOptions, } from './recorders/observability/StatusRecorder.js';
|
|
52
|
+
export { toolLineageRecorder, type ToolLineageRecorderHandle, type ToolLineageOptions, type ToolLineageGraph, type ToolLineageEdge, type ToolCallRef, } from './recorders/observability/ToolLineageRecorder.js';
|
|
53
|
+
export { agentThinkingTrace, type AgentThinkingTraceHandle, type AgentThinkingTraceOptions, type AttTrace, type AttStep, type AttCost, type AttAnswer, type AttToolSeen, } from './recorders/observability/AgentThinkingTraceRecorder.js';
|
|
54
|
+
export { typedEmit } from './recorders/core/typedEmit.js';
|
|
55
|
+
export * from "./debug.js";
|
|
56
|
+
export { buildChoiceContext, toolChoiceRecorder, type OfferedTool, type ToolChoiceCall, type ToolChoiceRecorderHandle, type ToolChoiceRecorderOptions, type ToolChoiceSkipReason, type ToolChoiceSummary, } from './recorders/observability/ToolChoiceRecorder.js';
|
|
57
|
+
export { routeRecorder, formatRouteHop, type RouteRecorderHandle, type RouteRecorderOptions, type RouteHop, type RouteOutcome, type RouteTrip, type RouteTripKind, } from './recorders/observability/RouteRecorder.js';
|
package/dist/esm/observe.js
CHANGED
|
@@ -64,42 +64,13 @@ export { toolLineageRecorder, } from './recorders/observability/ToolLineageRecor
|
|
|
64
64
|
export { agentThinkingTrace, } from './recorders/observability/AgentThinkingTraceRecorder.js';
|
|
65
65
|
// Emit primitive — used by every Tier-3 source-domain.
|
|
66
66
|
export { typedEmit } from './recorders/core/typedEmit.js';
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
export { adaptWeights, averageRelevancy, compositeScore, contentHash, DEFAULT_CLEAR_WINNER_MARGIN, DEFAULT_CLEAR_WINNER_RATIO, DEFAULT_INFLUENCE_WEIGHTS, DEFAULT_MARGIN_THRESHOLD, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_SHORTLIST_BAND, EmbeddingCache, embeddingCache, finalAnswerSimilarity, marginStrategy, pairwiseSimilarity, persistence, rankingConfidence, ratioStrategy, scoreContrastiveInfluence, scoreInfluence, scoreMargin, structuralProximity, } from './lib/influence-core/index.js';
|
|
75
|
-
// Introspection toolpack (RFC-003 Part C) — footprintjs trace evidence
|
|
76
|
-
// exposed as TOOLS a debugging LLM calls over a COMPLETED run's artifacts.
|
|
77
|
-
// Bounded, honest (⚠ markers), redaction-respecting, id-navigable.
|
|
78
|
-
export { callTraceTool, lazyTraceToolpack, NO_COMPLETED_RUN_MESSAGE, TOOLPACK_HARD_CAPS, traceToolpack, } from './lib/trace-toolpack/index.js';
|
|
79
|
-
// The two conversational doors over the toolpack: a DEDICATED debugger
|
|
80
|
-
// agent (separate session, any provider — cheap models welcome), and the
|
|
81
|
-
// in-conversation `.selfExplain()` builder option's types. Same evidence,
|
|
82
|
-
// same honesty discipline as the UI doors (BacktrackView / Lens).
|
|
83
|
-
export { buildSelfExplainSkill, buildSelfExplainToolProvider, SelfExplainBinding, traceDebugAgent, } from './lib/trace-toolpack/index.js';
|
|
84
|
-
// Contextual-bug localizer (RFC-003 Part B, D7–D9) — "git bisect for
|
|
85
|
-
// context". Assembly: footprintjs causal DAG (control edges + honesty
|
|
86
|
-
// markers + EdgeWeigher) × influence-core scoring (D6) × consumer-run
|
|
87
|
-
// counterfactual ablation. §B2 claim tiers: scores/weights are
|
|
88
|
-
// embedding-geometry PROXIES; ablation verdicts are the ONLY causal
|
|
89
|
-
// claims; slice completeness is bounded by tracking — and says so.
|
|
90
|
-
export { ablationForSuspect, applyAblations, assembleTrajectory, assignCostVerdicts, bisectCulprits, bucketByAnchors, shortlistEarlyCulprits, walkToRoot, walkTrajectory, buildWriterFrameIndex, DEFAULT_RECENCY_DECAY, classifySuspect, findLoopHeads, CONTEXT_BISECT_DEFAULTS, defaultOutcomeComparator, defaultSuspectClassifier, findDroppedContext, formatContextBugReport, llmCallIdsFromEvents, llmEdgeWeigher, localizeContextBug, probeFlipped, runAblationProbe, runRestorationProbe, stepOutputText, suspectLabel, verdictFor, } from './lib/context-bisect/index.js';
|
|
91
|
-
// BacktrackTrace serializer — feeds agentThinkingUI's <BacktrackView>
|
|
92
|
-
// (the "why?" board) straight off a localizer report. Pure mapping, no
|
|
93
|
-
// UI dependency; the interfaces mirror agentthinkingui's contract.
|
|
94
|
-
export { toBacktrackTrace, } from './lib/context-bisect/index.js';
|
|
95
|
-
// Tool-catalog confusability lint (RFC-002 tier 1, C1–C3) — build-time,
|
|
96
|
-
// CI-gateable, framework-agnostic: plain { name, description?, inputSchema? }
|
|
97
|
-
// tools in (OpenAI/Anthropic/MCP lists coerce via coerceCatalog; the
|
|
98
|
-
// library's Tool[] via catalogFromTools), a report with a gateable `ok`
|
|
99
|
-
// out. Pluggable structural rule pack; thresholds + embedder consumer-
|
|
100
|
-
// injected with our defaults. Bin: `agentfootprint-lint-tools`.
|
|
101
|
-
// Front door: docs/guides/tool-catalog-lint.md.
|
|
102
|
-
export { analyzeToolCatalog, catalogFromTools, coerceCatalog, confusabilityText, DEFAULT_CONFUSABILITY_THRESHOLD, DEFAULT_OMISSION_CUES, DEFAULT_WATCH_BAND, DEFAULT_WHEN_CUES, defaultStructuralRules, descriptionRule, differentiationHint, enumInProseRule, formatToolCatalogReport, MOCK_EMBEDDER_CALIBRATION, optionalParamRule, runToolLintCli, saysWhatNotWhenRule, } from './lib/tool-lint/index.js';
|
|
67
|
+
// ── DEPRECATED (moved to agentfootprint/debug) ─────────────────
|
|
68
|
+
// The diagnosis tools (influence-core, trace-toolpack, context-bisect,
|
|
69
|
+
// tool-lint) moved to `agentfootprint/debug` in the surface cleanup, so the
|
|
70
|
+
// import path matches the Debug docs category. They are re-exported here for
|
|
71
|
+
// ONE transition version — import them from `agentfootprint/debug` instead.
|
|
72
|
+
// They will be removed from `agentfootprint/observe` in the next major.
|
|
73
|
+
export * from "./debug.js";
|
|
103
74
|
// Tool-choice margin recorder (RFC-002 tier 2, C4–C6) — per LLM call,
|
|
104
75
|
// ranks the OFFERED catalog against the choice context (user message +
|
|
105
76
|
// latest assistant reasoning) via influence-core scoreMargin; embeds
|
package/dist/esm/observe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAA+B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAEhG,+BAA+B;AAC/B,OAAO,EACL,mBAAmB,GAEpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAgBjB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAQhB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,EACd,wBAAwB,GAQzB,MAAM,gDAAgD,CAAC;AAExD,8EAA8E;AAC9E,gFAAgF;AAChF,iEAAiE;AACjE,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,GAKjB,MAAM,oCAAoC,CAAC;AAE5C,mFAAmF;AACnF,OAAO,EACL,wBAAwB,GAGzB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,oBAAoB,GAKrB,MAAM,gDAAgD,CAAC;AAExD,6BAA6B;AAC7B,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,wBAAwB,GAEzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,kBAAkB,GAEnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,cAAc,GAIf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,YAAY,GAGb,MAAM,6CAA6C,CAAC;AACrD,4EAA4E;AAC5E,gFAAgF;AAChF,OAAO,EACL,mBAAmB,GAMpB,MAAM,kDAAkD,CAAC;AAC1D,gFAAgF;AAChF,gFAAgF;AAChF,OAAO,EACL,kBAAkB,GAQnB,MAAM,yDAAyD,CAAC;AAEjE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,
|
|
1
|
+
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAA+B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAEhG,+BAA+B;AAC/B,OAAO,EACL,mBAAmB,GAEpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAgBjB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAQhB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,EACd,wBAAwB,GAQzB,MAAM,gDAAgD,CAAC;AAExD,8EAA8E;AAC9E,gFAAgF;AAChF,iEAAiE;AACjE,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,GAKjB,MAAM,oCAAoC,CAAC;AAE5C,mFAAmF;AACnF,OAAO,EACL,wBAAwB,GAGzB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,oBAAoB,GAKrB,MAAM,gDAAgD,CAAC;AAExD,6BAA6B;AAC7B,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,wBAAwB,GAEzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAA4B,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAA8B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,kBAAkB,GAEnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,aAAa,EAA6B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,cAAc,GAIf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,YAAY,GAGb,MAAM,6CAA6C,CAAC;AACrD,4EAA4E;AAC5E,gFAAgF;AAChF,OAAO,EACL,mBAAmB,GAMpB,MAAM,kDAAkD,CAAC;AAC1D,gFAAgF;AAChF,gFAAgF;AAChF,OAAO,EACL,kBAAkB,GAQnB,MAAM,yDAAyD,CAAC;AAEjE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,kEAAkE;AAClE,uEAAuE;AACvE,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,cAAc,YAAY,CAAC;AAC3B,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAOnB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,aAAa,EACb,cAAc,GAOf,MAAM,4CAA4C,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debate — two agents alternate proposing + critiquing, a judge decides.
|
|
3
|
+
*
|
|
4
|
+
* Paper: "Improving Factuality and Reasoning in Language Models through
|
|
5
|
+
* Multiagent Debate" — Du et al., 2023
|
|
6
|
+
* (https://arxiv.org/abs/2305.14325).
|
|
7
|
+
*
|
|
8
|
+
* Pattern: Factory → produces a `Runner` built from
|
|
9
|
+
* `Sequence(Proposer → Critic → Judge)` by default, or an
|
|
10
|
+
* iterated `Loop(Sequence(…))` when `rounds > 1`.
|
|
11
|
+
* Role: patterns/ layer.
|
|
12
|
+
* Emits: Everything Sequence + Loop + LLMCall emit.
|
|
13
|
+
*/
|
|
14
|
+
import type { LLMProvider } from '../adapters/types.js';
|
|
15
|
+
import type { Runner } from '../core/runner.js';
|
|
16
|
+
export interface DebateOptions {
|
|
17
|
+
readonly provider: LLMProvider;
|
|
18
|
+
readonly model: string;
|
|
19
|
+
/** Proposer persona — asserts a position given the question. */
|
|
20
|
+
readonly proposerPrompt: string;
|
|
21
|
+
/** Critic persona — argues against the proposer's position. */
|
|
22
|
+
readonly criticPrompt: string;
|
|
23
|
+
/** Judge persona — reads the debate transcript, returns the verdict. */
|
|
24
|
+
readonly judgePrompt: string;
|
|
25
|
+
/** Rounds of propose+critique before the judge weighs in. Default 1. */
|
|
26
|
+
readonly rounds?: number;
|
|
27
|
+
readonly temperature?: number;
|
|
28
|
+
readonly maxTokens?: number;
|
|
29
|
+
readonly name?: string;
|
|
30
|
+
readonly id?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build a Debate Runner. One debate "round" = Proposer → Critic. After
|
|
34
|
+
* N rounds, the Judge sees the final exchange and renders the verdict.
|
|
35
|
+
* The Judge's output is the Runner's return value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function debate(opts: DebateOptions): Runner<{
|
|
38
|
+
message: string;
|
|
39
|
+
}, string>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapReduce — fan-out N LLMCalls over deterministic input shards, reduce.
|
|
3
|
+
*
|
|
4
|
+
* Origin: classic map-reduce (Dean & Ghemawat, 2004) applied to
|
|
5
|
+
* LLM context-window constraints. Seen in long-document
|
|
6
|
+
* summarization: split → summarize each → combine.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: Factory → produces a Runner composing `Parallel` of N
|
|
9
|
+
* shard-aware branches. Each branch is an LLMCall wrapped so it
|
|
10
|
+
* extracts its shard index from the input by position.
|
|
11
|
+
* Role: patterns/ layer. Pure composition over existing primitives.
|
|
12
|
+
*
|
|
13
|
+
* Shard count is fixed at build time — consumer supplies `shardCount`
|
|
14
|
+
* and a `split(input, shardCount)` function that MUST return exactly
|
|
15
|
+
* `shardCount` strings. The extracted strings are packed into one
|
|
16
|
+
* `message` at run time (delimiter `\u001F`) so each branch can pick
|
|
17
|
+
* its own index. For run-time-variable shard counts, factor MapReduce
|
|
18
|
+
* inside a wrapping Runner that rebuilds the Parallel per call.
|
|
19
|
+
*/
|
|
20
|
+
import type { LLMProvider } from '../adapters/types.js';
|
|
21
|
+
import type { Runner } from '../core/runner.js';
|
|
22
|
+
import type { MergeFn, MergeWithLLMOptions } from '../core-flow/Parallel.js';
|
|
23
|
+
export interface MapReduceOptions {
|
|
24
|
+
readonly provider: LLMProvider;
|
|
25
|
+
readonly model: string;
|
|
26
|
+
/** System prompt applied to every shard's LLMCall. */
|
|
27
|
+
readonly mapPrompt: string;
|
|
28
|
+
/**
|
|
29
|
+
* Number of shards to fan out. Must be >= 2 (for one-shard, use
|
|
30
|
+
* `LLMCall` directly). Fixed at build time.
|
|
31
|
+
*/
|
|
32
|
+
readonly shardCount: number;
|
|
33
|
+
/**
|
|
34
|
+
* Splitter invoked at run time with `(input, shardCount)`. MUST return
|
|
35
|
+
* exactly `shardCount` strings. If it returns fewer, remaining shards
|
|
36
|
+
* receive empty strings; more are truncated.
|
|
37
|
+
*/
|
|
38
|
+
readonly split: (input: string, shardCount: number) => readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Reducer — either a pure fn combining the N shard outputs, OR an LLM
|
|
41
|
+
* synthesizer.
|
|
42
|
+
*/
|
|
43
|
+
readonly reduce: {
|
|
44
|
+
readonly kind: 'fn';
|
|
45
|
+
readonly fn: MergeFn;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: 'llm';
|
|
48
|
+
readonly opts: MergeWithLLMOptions;
|
|
49
|
+
};
|
|
50
|
+
readonly temperature?: number;
|
|
51
|
+
readonly maxTokens?: number;
|
|
52
|
+
readonly name?: string;
|
|
53
|
+
readonly id?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build a MapReduce Runner. At run time:
|
|
57
|
+
* 1. The splitter runs the consumer's `split(input, shardCount)` and
|
|
58
|
+
* packs the resulting N shards into a delimited string.
|
|
59
|
+
* 2. Parallel fans out to N branches. Each branch's wrapper extracts
|
|
60
|
+
* its own shard from the packed input and feeds it to the shared
|
|
61
|
+
* LLMCall.
|
|
62
|
+
* 3. The reducer combines the N branch outputs into the final string.
|
|
63
|
+
*/
|
|
64
|
+
export declare function mapReduce(opts: MapReduceOptions): Runner<{
|
|
65
|
+
message: string;
|
|
66
|
+
}, string>;
|