agentfootprint 6.43.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/RunnerBase.js +7 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/RunnerBase.js +7 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/observe.js +7 -1
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
- package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/localObservability.js +54 -0
- package/dist/esm/recorders/observability/localObservability.js.map +1 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/recorders/observability/trace.js +99 -0
- package/dist/esm/recorders/observability/trace.js.map +1 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/observe.js +14 -3
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/FlowchartRecorder.js +12 -3
- package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/recorders/observability/localObservability.js +58 -0
- package/dist/recorders/observability/localObservability.js.map +1 -0
- package/dist/recorders/observability/trace.js +105 -0
- package/dist/recorders/observability/trace.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/runner.d.ts +12 -0
- package/dist/types/core/runner.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/dist/types/observe.d.ts +3 -1
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/localObservability.d.ts +49 -0
- package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
- package/dist/types/recorders/observability/trace.d.ts +120 -0
- package/dist/types/recorders/observability/trace.d.ts.map +1 -0
- package/package.json +203 -56
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/types — the Ports of the hexagonal architecture.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Adapter (GoF, Design Patterns ch. 4) + Ports-and-Adapters
|
|
5
|
+
* (Cockburn, 2005).
|
|
6
|
+
* Role: Contracts for every external dependency the library reaches for:
|
|
7
|
+
* LLM providers, memory stores, context sources, embeddings,
|
|
8
|
+
* guardrails, policy engines, pricing tables.
|
|
9
|
+
* Emits: N/A (interfaces only).
|
|
10
|
+
*
|
|
11
|
+
* Concrete adapters (AnthropicProvider, PineconeStore, LlamaGuardDetector,
|
|
12
|
+
* ...) implement these contracts. `core/` and `core-flow/` depend only on
|
|
13
|
+
* these interfaces — never on concrete adapters.
|
|
14
|
+
*/
|
|
15
|
+
import type { ContextRole, ContextSlot, ContextSource } from '../events/types.js';
|
|
16
|
+
import type { ThinkingBlock } from '../thinking/types.js';
|
|
17
|
+
export interface LLMMessage {
|
|
18
|
+
readonly role: ContextRole;
|
|
19
|
+
readonly content: string;
|
|
20
|
+
/** For `role: 'tool'` — the tool_use id this result corresponds to. */
|
|
21
|
+
readonly toolCallId?: string;
|
|
22
|
+
/** For `role: 'tool'` — the tool name this result corresponds to. */
|
|
23
|
+
readonly toolName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* For `role: 'assistant'` only — the tool calls the LLM requested in this
|
|
26
|
+
* turn. Required for providers (Anthropic, OpenAI) that need to round-trip
|
|
27
|
+
* tool_use blocks across iterations: when the next `complete()` includes
|
|
28
|
+
* a `role: 'tool'` message, the provider reconstructs the matching
|
|
29
|
+
* `tool_use` block on the previous assistant turn from this field.
|
|
30
|
+
* Empty array on text-only turns; undefined for non-assistant roles.
|
|
31
|
+
*/
|
|
32
|
+
readonly toolCalls?: readonly {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
36
|
+
}[];
|
|
37
|
+
/**
|
|
38
|
+
* v2.14 — Thinking blocks emitted by the LLM on assistant turns.
|
|
39
|
+
*
|
|
40
|
+
* Required for Anthropic extended-thinking + tool-use flows: signed
|
|
41
|
+
* blocks MUST be echoed BYTE-EXACT in subsequent assistant turns or
|
|
42
|
+
* Anthropic's API rejects with 400. The framework persists blocks
|
|
43
|
+
* here so the AnthropicProvider's serializer (Phase 4b) can restore
|
|
44
|
+
* them on the next request.
|
|
45
|
+
*
|
|
46
|
+
* **Persistence model — DIFFERENT from `ephemeral`:**
|
|
47
|
+
* - `ephemeral` messages: NOT persisted to scope.history
|
|
48
|
+
* - `thinkingBlocks`: PERSISTED (required for signature round-trip)
|
|
49
|
+
*
|
|
50
|
+
* Visible to recorders + audit by default. Use
|
|
51
|
+
* `RedactionPolicy.thinkingPatterns` (Phase 3) to scrub sensitive
|
|
52
|
+
* reasoning content before audit-log adapters fire.
|
|
53
|
+
*
|
|
54
|
+
* Empty array OR undefined when no thinking is present (most calls).
|
|
55
|
+
*/
|
|
56
|
+
readonly thinkingBlocks?: readonly ThinkingBlock[];
|
|
57
|
+
/**
|
|
58
|
+
* v2.13 — PERSISTENCE flag (NOT a visibility flag). When `true`:
|
|
59
|
+
* • The message IS sent to the LLM as part of the next request
|
|
60
|
+
* (visible to the model, counts toward its context window).
|
|
61
|
+
* • The message is OBSERVABLE via narrative/recorders/audit log
|
|
62
|
+
* (visible to humans for debugging + forensics).
|
|
63
|
+
* • The message is NOT persisted to `scope.history` after the gate
|
|
64
|
+
* loop that produced it completes — long-term memory writes,
|
|
65
|
+
* `getNarrative()` snapshots, and downstream consumers see only
|
|
66
|
+
* non-ephemeral messages.
|
|
67
|
+
*
|
|
68
|
+
* Use case: Instructor-style schema retry. The reliability gate
|
|
69
|
+
* appends `{ role: 'user', content: feedbackForLLM, ephemeral: true }`
|
|
70
|
+
* before retry — the LLM sees the validation feedback for the next
|
|
71
|
+
* call, but the conversation history (and any memory persistence
|
|
72
|
+
* downstream) sees only the final accepted exchange.
|
|
73
|
+
*
|
|
74
|
+
* Audit-trail safety: ephemeral DOES NOT mean invisible to security
|
|
75
|
+
* review. `getNarrative()`, recorders, and the typed-event stream all
|
|
76
|
+
* see ephemeral messages; only the persistent conversation log filters
|
|
77
|
+
* them out. An attacker cannot use the ephemeral marker to construct
|
|
78
|
+
* audit-invisible prompts.
|
|
79
|
+
*/
|
|
80
|
+
readonly ephemeral?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface LLMToolSchema {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly description: string;
|
|
85
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
86
|
+
}
|
|
87
|
+
export interface LLMRequest {
|
|
88
|
+
readonly systemPrompt?: string;
|
|
89
|
+
readonly messages: readonly LLMMessage[];
|
|
90
|
+
readonly tools?: readonly LLMToolSchema[];
|
|
91
|
+
readonly model: string;
|
|
92
|
+
readonly temperature?: number;
|
|
93
|
+
readonly maxTokens?: number;
|
|
94
|
+
readonly stop?: readonly string[];
|
|
95
|
+
readonly signal?: AbortSignal;
|
|
96
|
+
/**
|
|
97
|
+
* Cache markers (v2.6+) — provider-agnostic prefix-cache hints
|
|
98
|
+
* populated by `CacheStrategy.prepareRequest` after the agent's
|
|
99
|
+
* CacheGate decider routes to `apply-markers`. Each marker
|
|
100
|
+
* identifies a cacheable prefix in `system` / `tools` / `messages`.
|
|
101
|
+
*
|
|
102
|
+
* Providers that support caching (Anthropic, Bedrock-Claude) read
|
|
103
|
+
* this field and translate to their wire format. Providers without
|
|
104
|
+
* cache support (OpenAI auto-cache, Mock, NoOp) ignore it.
|
|
105
|
+
*/
|
|
106
|
+
readonly cacheMarkers?: readonly import('../cache/types.js').CacheMarker[];
|
|
107
|
+
/**
|
|
108
|
+
* v2.14 — request the LLM emit reasoning/thinking content on this call.
|
|
109
|
+
*
|
|
110
|
+
* Activation: presence of this field tells the provider to ASK for
|
|
111
|
+
* thinking. Anthropic translates to `thinking: { type: 'enabled',
|
|
112
|
+
* budget_tokens: budget }` on the wire. OpenAI ignores (o1/o3
|
|
113
|
+
* thinking is selected at the model id level, not per-request).
|
|
114
|
+
*
|
|
115
|
+
* `budget` is the maximum reasoning tokens the model may spend.
|
|
116
|
+
* Anthropic requires it; recommended range 1024-32000 for
|
|
117
|
+
* claude-sonnet-4-5 / opus-4-5. Models that don't support extended
|
|
118
|
+
* thinking will reject the request with HTTP 400 — pick a supported
|
|
119
|
+
* model when setting this field.
|
|
120
|
+
*
|
|
121
|
+
* Independent from `LLMMessage.thinkingBlocks` (the response side):
|
|
122
|
+
* - `request.thinking` = activation (consumer ASKS for thinking)
|
|
123
|
+
* - `message.thinkingBlocks` = round-trip (consumer ECHOES prior
|
|
124
|
+
* assistant turn's signed blocks back to the model)
|
|
125
|
+
*
|
|
126
|
+
* Set via `AgentBuilder.thinking({ budget })` — applied to every
|
|
127
|
+
* LLM call the agent makes. Leave undefined to call without thinking
|
|
128
|
+
* (the v2.13 default).
|
|
129
|
+
*/
|
|
130
|
+
readonly thinking?: {
|
|
131
|
+
readonly budget: number;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface LLMResponse {
|
|
135
|
+
readonly content: string;
|
|
136
|
+
readonly toolCalls: readonly {
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
140
|
+
}[];
|
|
141
|
+
readonly usage: {
|
|
142
|
+
readonly input: number;
|
|
143
|
+
readonly output: number;
|
|
144
|
+
readonly cacheRead?: number;
|
|
145
|
+
readonly cacheWrite?: number;
|
|
146
|
+
/**
|
|
147
|
+
* v2.14 — count of reasoning/thinking tokens used by the model.
|
|
148
|
+
* Distinct from `output` (which is visible-content tokens).
|
|
149
|
+
*
|
|
150
|
+
* Semantics:
|
|
151
|
+
* - `undefined` — provider doesn't expose / no thinking enabled
|
|
152
|
+
* on this call / call without extended thinking
|
|
153
|
+
* - `0` — thinking enabled but model produced no
|
|
154
|
+
* thinking tokens this call
|
|
155
|
+
* - `>0` — actual reasoning token count (billing-relevant
|
|
156
|
+
* for both Anthropic extended thinking and
|
|
157
|
+
* OpenAI o1/o3 reasoning_tokens)
|
|
158
|
+
*
|
|
159
|
+
* Cost dashboards reading `cost.tick` events should track this
|
|
160
|
+
* separately from `output` — pricing differs (Anthropic charges
|
|
161
|
+
* extended thinking at output rates; OpenAI o1/o3 reasoning tokens
|
|
162
|
+
* are billed as a separate line item).
|
|
163
|
+
*/
|
|
164
|
+
readonly thinking?: number;
|
|
165
|
+
};
|
|
166
|
+
readonly stopReason: string;
|
|
167
|
+
readonly providerRef?: string;
|
|
168
|
+
/**
|
|
169
|
+
* v2.14 — Provider-specific raw thinking data, opaque to the
|
|
170
|
+
* framework. Providers that support extended thinking populate this
|
|
171
|
+
* with their native shape (Anthropic: array of `{type, thinking,
|
|
172
|
+
* signature}` blocks; OpenAI: `reasoning_summary` value; custom:
|
|
173
|
+
* whatever the provider emits). The framework hands this to a
|
|
174
|
+
* configured `ThinkingHandler.normalize(rawThinking)` to produce
|
|
175
|
+
* the normalized `ThinkingBlock[]` that lands on
|
|
176
|
+
* `LLMMessage.thinkingBlocks`.
|
|
177
|
+
*
|
|
178
|
+
* Undefined when the provider has no thinking content for this call
|
|
179
|
+
* — most calls (gpt-4o, claude without extended thinking enabled,
|
|
180
|
+
* etc.). The thinking subflow's stage early-returns in this case.
|
|
181
|
+
*/
|
|
182
|
+
readonly rawThinking?: unknown;
|
|
183
|
+
}
|
|
184
|
+
export interface LLMChunk {
|
|
185
|
+
readonly tokenIndex: number;
|
|
186
|
+
/** Token text. Empty for the terminal chunk (`done: true`). */
|
|
187
|
+
readonly content: string;
|
|
188
|
+
/** True only for the final chunk in a stream. */
|
|
189
|
+
readonly done: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Authoritative response payload, populated ONLY on the final chunk
|
|
192
|
+
* (`done: true`). Carries `toolCalls`, `usage`, `stopReason` — the
|
|
193
|
+
* fields that drive the ReAct loop. The `content` mirrors the
|
|
194
|
+
* concatenation of all non-terminal chunks; consumers can use
|
|
195
|
+
* either source.
|
|
196
|
+
*
|
|
197
|
+
* Streaming providers SHOULD populate this. Older providers that
|
|
198
|
+
* yield only text and end with `done: true` (no `response`) are
|
|
199
|
+
* still supported — Agent falls back to `complete()` for the
|
|
200
|
+
* authoritative payload in that case.
|
|
201
|
+
*/
|
|
202
|
+
readonly response?: LLMResponse;
|
|
203
|
+
/**
|
|
204
|
+
* v2.14 — streaming thinking-content tokens. Parallel to `content`
|
|
205
|
+
* but for the model's reasoning chain rather than visible output.
|
|
206
|
+
* Set on chunks that carry thinking deltas (Anthropic emits these
|
|
207
|
+
* via `content_block_delta` events with `delta.type === 'thinking_delta'`);
|
|
208
|
+
* undefined or empty on chunks that carry only visible-content tokens.
|
|
209
|
+
*
|
|
210
|
+
* Frameworks: this field drives `agentfootprint.stream.thinking_delta`
|
|
211
|
+
* events when a `ThinkingHandler.parseChunk()` returns one. Consumers
|
|
212
|
+
* who want to render thinking-as-it-streams subscribe to that event.
|
|
213
|
+
*
|
|
214
|
+
* Default consumer behavior: thinking tokens are not surfaced to end
|
|
215
|
+
* users unless a consumer explicitly subscribes to the
|
|
216
|
+
* `agentfootprint.stream.thinking_delta` event (or renders it through a
|
|
217
|
+
* live-status strategy).
|
|
218
|
+
*/
|
|
219
|
+
readonly thinkingDelta?: string;
|
|
220
|
+
}
|
|
221
|
+
export interface LLMProvider {
|
|
222
|
+
readonly name: string;
|
|
223
|
+
complete(req: LLMRequest): Promise<LLMResponse>;
|
|
224
|
+
stream?(req: LLMRequest): AsyncIterable<LLMChunk>;
|
|
225
|
+
}
|
|
226
|
+
export interface ResolveCtx {
|
|
227
|
+
readonly userMessage: string;
|
|
228
|
+
readonly turnIndex: number;
|
|
229
|
+
readonly iterIndex: number;
|
|
230
|
+
readonly availableBudgetTokens: number;
|
|
231
|
+
readonly signal?: AbortSignal;
|
|
232
|
+
}
|
|
233
|
+
export interface ContextContribution {
|
|
234
|
+
readonly contentSummary: string;
|
|
235
|
+
readonly rawContent?: string;
|
|
236
|
+
readonly score?: number;
|
|
237
|
+
readonly rank?: number;
|
|
238
|
+
readonly asRole?: ContextRole;
|
|
239
|
+
readonly sectionTag?: string;
|
|
240
|
+
readonly reason: string;
|
|
241
|
+
}
|
|
242
|
+
export interface ContextSourceAdapter {
|
|
243
|
+
readonly id: string;
|
|
244
|
+
readonly targetSlot: ContextSlot;
|
|
245
|
+
readonly source: ContextSource;
|
|
246
|
+
resolve(ctx: ResolveCtx): Promise<readonly ContextContribution[]>;
|
|
247
|
+
}
|
|
248
|
+
export interface EmbeddingProvider {
|
|
249
|
+
readonly name: string;
|
|
250
|
+
readonly dimension: number;
|
|
251
|
+
embed(inputs: readonly string[], kind: 'query' | 'document'): Promise<number[][]>;
|
|
252
|
+
}
|
|
253
|
+
export interface RiskContext {
|
|
254
|
+
readonly slot?: ContextSlot;
|
|
255
|
+
readonly source?: ContextSource;
|
|
256
|
+
readonly turnIndex?: number;
|
|
257
|
+
readonly iterIndex?: number;
|
|
258
|
+
}
|
|
259
|
+
export interface RiskResult {
|
|
260
|
+
readonly flagged: boolean;
|
|
261
|
+
readonly severity: 'low' | 'medium' | 'high' | 'critical';
|
|
262
|
+
readonly category: 'pii' | 'prompt_injection' | 'runaway_loop' | 'cost_overrun' | 'hallucination_flag';
|
|
263
|
+
readonly evidence: Readonly<Record<string, unknown>>;
|
|
264
|
+
readonly suggestedAction: 'warn' | 'redact' | 'abort';
|
|
265
|
+
}
|
|
266
|
+
export interface RiskDetector {
|
|
267
|
+
readonly name: string;
|
|
268
|
+
check(content: string, context: RiskContext): Promise<RiskResult>;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* One entry in the in-flight tool-call sequence delivered to
|
|
272
|
+
* `PermissionChecker.check()` since v2.12. Lets sequence-aware
|
|
273
|
+
* policies (exfil chain detection, idempotency limits, cost guards)
|
|
274
|
+
* inspect what the agent has already dispatched this run.
|
|
275
|
+
*
|
|
276
|
+
* Derived from `scope.history` at check time — single source of truth,
|
|
277
|
+
* survives `agent.resumeOnError(checkpoint)` correctly.
|
|
278
|
+
*/
|
|
279
|
+
export interface ToolCallEntry {
|
|
280
|
+
/** Tool name dispatched. */
|
|
281
|
+
readonly name: string;
|
|
282
|
+
/** Tool args passed to `tool.execute(args, ctx)`. */
|
|
283
|
+
readonly args: Readonly<Record<string, unknown>> | undefined;
|
|
284
|
+
/** ReAct iteration the call was dispatched on. */
|
|
285
|
+
readonly iteration: number;
|
|
286
|
+
/**
|
|
287
|
+
* Optional source identifier — `'local'` for tools registered via
|
|
288
|
+
* `.tool(...)` / `staticTools(...)`, or the `ToolProvider.id` for
|
|
289
|
+
* tools resolved through a `discoveryProvider`. Lets cross-hub
|
|
290
|
+
* exfil rules match on origin, not just name.
|
|
291
|
+
*/
|
|
292
|
+
readonly providerId?: string;
|
|
293
|
+
}
|
|
294
|
+
export interface PermissionRequest {
|
|
295
|
+
readonly capability: 'tool_call' | 'memory_read' | 'memory_write' | 'external_net' | 'user_data';
|
|
296
|
+
readonly actor: string;
|
|
297
|
+
readonly target?: string;
|
|
298
|
+
readonly context?: Readonly<Record<string, unknown>>;
|
|
299
|
+
/**
|
|
300
|
+
* v2.12 — Sequence of tool calls already dispatched this run, in
|
|
301
|
+
* call order. EMPTY for non-`tool_call` capabilities. Sequence-aware
|
|
302
|
+
* policies (forbidden chains, idempotency limits) read this to make
|
|
303
|
+
* decisions that single-call governance cannot.
|
|
304
|
+
*/
|
|
305
|
+
readonly sequence?: readonly ToolCallEntry[];
|
|
306
|
+
/**
|
|
307
|
+
* v2.12 — Full conversation history at check time. Lets policies
|
|
308
|
+
* inspect prior assistant content / tool results without maintaining
|
|
309
|
+
* parallel state via event subscription.
|
|
310
|
+
*/
|
|
311
|
+
readonly history?: readonly LLMMessage[];
|
|
312
|
+
/**
|
|
313
|
+
* v2.12 — Current ReAct iteration (1-based). Lets policies fire
|
|
314
|
+
* different rules per iteration without external counters.
|
|
315
|
+
*/
|
|
316
|
+
readonly iteration?: number;
|
|
317
|
+
/**
|
|
318
|
+
* v2.12 — Caller identity from `agent.run({ identity })`. Permission
|
|
319
|
+
* predicates can role-check on `identity.principal` / `identity.tenant`.
|
|
320
|
+
*/
|
|
321
|
+
readonly identity?: {
|
|
322
|
+
readonly tenant?: string;
|
|
323
|
+
readonly principal?: string;
|
|
324
|
+
readonly conversationId: string;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* v2.12 — Optional abort signal propagated from `agent.run({ env: { signal } })`.
|
|
328
|
+
* Async checkers (Redis lookups, hub-backed allowlists) MUST honor this
|
|
329
|
+
* — when the agent run is cancelled, in-flight checks should abort.
|
|
330
|
+
*/
|
|
331
|
+
readonly signal?: AbortSignal;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* v2.12 — content shape mirroring `LLMMessage.content`. Future-compatible
|
|
335
|
+
* with multi-modal `tool_result` blocks once `LLMMessage` widens.
|
|
336
|
+
*/
|
|
337
|
+
export type ToolResultContent = string;
|
|
338
|
+
export interface PermissionDecision {
|
|
339
|
+
/**
|
|
340
|
+
* v2.12 — `'halt'` is NEW. Terminates the run cleanly with a typed
|
|
341
|
+
* `PolicyHaltError`. The framework writes a synthetic `tool_result`
|
|
342
|
+
* (using `tellLLM`) to `scope.history` BEFORE throwing, so:
|
|
343
|
+
* • Anthropic / OpenAI tool_use ↔ tool_result pairing is satisfied
|
|
344
|
+
* • The conversation history is consistent for `resumeOnError`
|
|
345
|
+
* • Lens / `getNarrative()` shows what the LLM was told
|
|
346
|
+
*
|
|
347
|
+
* `'deny'` keeps existing semantics: synthetic tool_result + LLM
|
|
348
|
+
* continues and can pick differently.
|
|
349
|
+
*/
|
|
350
|
+
readonly result: 'allow' | 'deny' | 'halt' | 'gate_open';
|
|
351
|
+
readonly policyRuleId?: string;
|
|
352
|
+
readonly rationale?: string;
|
|
353
|
+
readonly gateId?: string;
|
|
354
|
+
/**
|
|
355
|
+
* v2.12 — telemetry tag (machine-readable, stable across versions).
|
|
356
|
+
* Surfaces on `agentfootprint.permission.halt.reason` for routing
|
|
357
|
+
* alerts (e.g. `'security:exfiltration'` → PagerDuty,
|
|
358
|
+
* `'cost:context-bloat'` → Slack channel).
|
|
359
|
+
*/
|
|
360
|
+
readonly reason?: string;
|
|
361
|
+
/**
|
|
362
|
+
* v2.12 — content delivered to the LLM as the synthetic `tool_result`
|
|
363
|
+
* on `'deny'` and `'halt'`. When omitted, defaults to a deliberately
|
|
364
|
+
* generic `"Tool '${name}' is not available in this context."` —
|
|
365
|
+
* NEVER falls back to `reason` (which is telemetry, not user-facing).
|
|
366
|
+
*/
|
|
367
|
+
readonly tellLLM?: ToolResultContent;
|
|
368
|
+
}
|
|
369
|
+
export interface PermissionChecker {
|
|
370
|
+
readonly name: string;
|
|
371
|
+
check(request: PermissionRequest): Promise<PermissionDecision> | PermissionDecision;
|
|
372
|
+
}
|
|
373
|
+
export type TokenKind = 'input' | 'output' | 'cacheRead' | 'cacheWrite';
|
|
374
|
+
export interface PricingTable {
|
|
375
|
+
readonly name: string;
|
|
376
|
+
/** USD per ONE token for the given model+kind. */
|
|
377
|
+
pricePerToken(model: string, kind: TokenKind): number;
|
|
378
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eventMeta — build EventMeta from a footprintjs TraversalContext.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: Adapter (GoF) — translates footprintjs's per-stage context into
|
|
5
|
+
* agentfootprint's per-event metadata shape.
|
|
6
|
+
* Role: Used by every core recorder to attach meta to emitted events.
|
|
7
|
+
* Emits: N/A (helper only).
|
|
8
|
+
*/
|
|
9
|
+
import type { TraversalContext } from 'footprintjs';
|
|
10
|
+
import type { EventMeta } from '../events/types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Minimal "stage origin" shape — the common subset of footprintjs's
|
|
13
|
+
* TraversalContext (from FlowRecorder events), RecorderContext (from
|
|
14
|
+
* Recorder data-flow events), and EmitEvent (from EmitRecorder).
|
|
15
|
+
*
|
|
16
|
+
* Note: `subflowPath` type varies across footprintjs event shapes:
|
|
17
|
+
* - TraversalContext.subflowPath → `string | undefined` (/-separated)
|
|
18
|
+
* - EmitEvent.subflowPath → `readonly string[]`
|
|
19
|
+
* - RecorderContext → N/A (derived from runtimeStageId)
|
|
20
|
+
*
|
|
21
|
+
* We accept both shapes and normalize inside `buildEventMeta`.
|
|
22
|
+
*/
|
|
23
|
+
export interface StageOrigin {
|
|
24
|
+
readonly runtimeStageId?: string;
|
|
25
|
+
readonly subflowPath?: string | readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export interface RunContext {
|
|
28
|
+
/** Millisecond wall-clock timestamp when the run started. */
|
|
29
|
+
readonly runStartMs: number;
|
|
30
|
+
/** Unique run id (demultiplex concurrent runs sharing one dispatcher). */
|
|
31
|
+
readonly runId: string;
|
|
32
|
+
/** Optional OTEL trace id forwarded from executor.run({ env: { traceId } }). */
|
|
33
|
+
readonly traceId?: string;
|
|
34
|
+
/** Optional correlation id for cross-event tying (retrieval→injection→LLM). */
|
|
35
|
+
readonly correlationId?: string;
|
|
36
|
+
/** Composition ancestry path (e.g. ['Sequence:bot', 'Agent:classify']). */
|
|
37
|
+
readonly compositionPath: readonly string[];
|
|
38
|
+
/** Optional turn/iter indices from agent runtime. */
|
|
39
|
+
readonly turnIndex?: number;
|
|
40
|
+
readonly iterIndex?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build an EventMeta from a stage origin + run-level context.
|
|
44
|
+
*
|
|
45
|
+
* Accepts footprintjs's TraversalContext (FlowRecorder events), RecorderContext
|
|
46
|
+
* (WriteEvent / CommitEvent / etc.), or a bare StageOrigin. When the origin
|
|
47
|
+
* has no runtimeStageId (rare — manual emit during tests), the meta degrades
|
|
48
|
+
* gracefully to 'unknown#0'.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildEventMeta(origin: StageOrigin | TraversalContext | undefined, run: RunContext): EventMeta;
|
|
51
|
+
/**
|
|
52
|
+
* Parse footprintjs's `/`-separated subflow path into a readonly array.
|
|
53
|
+
*
|
|
54
|
+
* The source of truth for runtimeStageId parsing lives in footprintjs at
|
|
55
|
+
* `footprintjs/trace::parseRuntimeStageId`. We only need the path-split
|
|
56
|
+
* convenience here; the `/` separator is stable across footprintjs
|
|
57
|
+
* versions (covered by their `parseRuntimeStageId` tests).
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseSubflowPath(raw: string | undefined): readonly string[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CacheDecision subflow — provider-agnostic translation from
|
|
3
|
+
* `activeInjections + DSL directives` → `CacheMarker[]`.
|
|
4
|
+
*
|
|
5
|
+
* This is the core "policy → markers" Lego layer. It runs every
|
|
6
|
+
* iteration (after slot subflows produce their output, before the
|
|
7
|
+
* CacheGate decider). Pure transform: no IO, no LLM calls, no
|
|
8
|
+
* provider knowledge.
|
|
9
|
+
*
|
|
10
|
+
* Algorithm:
|
|
11
|
+
* 1. Build a `CachePolicyContext` from agent state
|
|
12
|
+
* 2. For each injection in `activeInjections`, evaluate its
|
|
13
|
+
* `metadata.cache` directive against the context → cacheable boolean
|
|
14
|
+
* 3. For each slot (system / tools / messages):
|
|
15
|
+
* a. Walk the slot's contributions in order
|
|
16
|
+
* b. Find the LAST index that's contiguous-from-start cacheable
|
|
17
|
+
* c. Emit one CacheMarker at that boundary if any cacheable
|
|
18
|
+
*
|
|
19
|
+
* Each marker is provider-agnostic. Provider strategy translates
|
|
20
|
+
* to wire format in Phase 6+.
|
|
21
|
+
*
|
|
22
|
+
* Special case — base system prompt: the agent's
|
|
23
|
+
* `agent.getSystemPromptCachePolicy()` value is folded in at index 0
|
|
24
|
+
* of the system slot. Always-on injections (Steering / Fact /
|
|
25
|
+
* always-active rules) follow.
|
|
26
|
+
*/
|
|
27
|
+
import type { TypedScope } from 'footprintjs';
|
|
28
|
+
import type { CacheMarker, CachePolicy, CachePolicyContext } from './types.js';
|
|
29
|
+
import type { Injection } from '../lib/injection-engine/types.js';
|
|
30
|
+
/**
|
|
31
|
+
* Subflow scope state. Set via inputMapper from the agent's parent
|
|
32
|
+
* scope; produces `cacheMarkers` consumed by the BuildLLMRequest stage.
|
|
33
|
+
*/
|
|
34
|
+
export interface CacheDecisionState {
|
|
35
|
+
readonly activeInjections: readonly Injection[];
|
|
36
|
+
readonly iteration: number;
|
|
37
|
+
readonly maxIterations: number;
|
|
38
|
+
readonly userMessage: string;
|
|
39
|
+
readonly lastToolName?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Cumulative input tokens spent across all LLM calls in THIS
|
|
42
|
+
* `agent.run()` invocation only. Resets at the start of each turn
|
|
43
|
+
* (each `agent.run()` call). Predicates can use this for budget-
|
|
44
|
+
* aware cache invalidation (e.g., "flush cache after 50K tokens").
|
|
45
|
+
*/
|
|
46
|
+
readonly cumulativeInputTokens: number;
|
|
47
|
+
/**
|
|
48
|
+
* Base system prompt's cache policy (from
|
|
49
|
+
* `agent.getSystemPromptCachePolicy()`). Folded in at index 0 of
|
|
50
|
+
* the system slot's cache evaluation, ahead of any always-on
|
|
51
|
+
* injections.
|
|
52
|
+
*/
|
|
53
|
+
readonly systemPromptCachePolicy: CachePolicy;
|
|
54
|
+
/** Global kill switch. When `true`, subflow emits zero markers. */
|
|
55
|
+
readonly cachingDisabled: boolean;
|
|
56
|
+
cacheMarkers: readonly CacheMarker[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Evaluate a `CachePolicy` against the current context.
|
|
60
|
+
* Returns `true` if the policy says THIS iteration's content is cacheable.
|
|
61
|
+
*/
|
|
62
|
+
export declare function evaluateCachePolicy(policy: CachePolicy, ctx: CachePolicyContext): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Identify which slots an injection contributes to. An injection can
|
|
65
|
+
* target multiple slots simultaneously (Skills target both system +
|
|
66
|
+
* tools); we visit each contributing slot independently.
|
|
67
|
+
*/
|
|
68
|
+
export declare function injectionTargetSlots(injection: Injection): ReadonlyArray<'system' | 'tools' | 'messages'>;
|
|
69
|
+
/**
|
|
70
|
+
* Pure transform: state → markers. Exported so tests can exercise
|
|
71
|
+
* the algorithm directly without the FlowChartExecutor ceremony of
|
|
72
|
+
* mounting the subflow as a child of a parent chart.
|
|
73
|
+
*
|
|
74
|
+
* The subflow body (`decide` below) is a thin wrapper that pulls
|
|
75
|
+
* state from scope and delegates here.
|
|
76
|
+
*/
|
|
77
|
+
export declare function computeCacheMarkers(state: Omit<CacheDecisionState, 'cacheMarkers'>): readonly CacheMarker[];
|
|
78
|
+
/**
|
|
79
|
+
* The decision stage function. Thin scope-binding wrapper around
|
|
80
|
+
* `computeCacheMarkers`. Exported so it can serve as the ROOT stage of
|
|
81
|
+
* the `sf-cache` subflow (a chart cannot start with a nested subflow),
|
|
82
|
+
* while `cacheDecisionSubflow` below still wraps the SAME function for
|
|
83
|
+
* standalone use — no logic duplication.
|
|
84
|
+
*/
|
|
85
|
+
export declare function decideCacheMarkers(scope: TypedScope<CacheDecisionState>): void;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CacheGate — runtime decider that gates cache-marker application.
|
|
3
|
+
*
|
|
4
|
+
* Runs every iteration AFTER the CacheDecision subflow produces
|
|
5
|
+
* `scope.cacheMarkers` and BEFORE the BuildLLMRequest stage applies
|
|
6
|
+
* them. Three rules can fall through to "no-markers" (skip caching);
|
|
7
|
+
* default branch is "apply-markers" (proceed with caching).
|
|
8
|
+
*
|
|
9
|
+
* Why a decider stage and not a function: footprintjs's `decide()`
|
|
10
|
+
* captures evidence on `FlowRecorder.onDecision` natively. The
|
|
11
|
+
* `cacheRecorder()` (Phase 9) reads
|
|
12
|
+
* `event.evidence.rules.find(r => r.matched).inputs[]` to surface
|
|
13
|
+
* WHY caching was applied or skipped each iter. Same channel
|
|
14
|
+
* footprintjs uses for every other decision; same renderer in Lens.
|
|
15
|
+
*
|
|
16
|
+
* Three rules (evaluated top-down; first match wins):
|
|
17
|
+
* 1. Kill switch — `Agent.create({ caching: 'off' })` was set
|
|
18
|
+
* 2. Hit-rate floor — recent hit rate < 30%; cache writes outpacing
|
|
19
|
+
* reads, auto-disable to avoid the cache-write penalty
|
|
20
|
+
* 3. Skill churn — active skills changing too rapidly for caching
|
|
21
|
+
* to amortize (Anthropic LLM expert's concern from Phase 4 review)
|
|
22
|
+
*
|
|
23
|
+
* Default branch (no rule matches): `'apply-markers'`.
|
|
24
|
+
*/
|
|
25
|
+
import { type DecisionResult, type TypedScope } from 'footprintjs';
|
|
26
|
+
/**
|
|
27
|
+
* Subset of agent scope state the CacheGate decider reads.
|
|
28
|
+
* Phase 6 wires these keys into the agent's main chart.
|
|
29
|
+
*/
|
|
30
|
+
export interface CacheGateState {
|
|
31
|
+
/**
|
|
32
|
+
* Global kill switch. When `true`, decider skips caching
|
|
33
|
+
* unconditionally. Set via `Agent.create({ caching: 'off' })`.
|
|
34
|
+
*/
|
|
35
|
+
readonly cachingDisabled: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Running cache hit rate from the last N iterations (0..1).
|
|
38
|
+
* `undefined` when no cache events have fired yet (e.g., iter 1 of
|
|
39
|
+
* the first turn — no history). The cacheRecorder (Phase 9)
|
|
40
|
+
* computes this from `CacheMetrics` events.
|
|
41
|
+
*/
|
|
42
|
+
readonly recentHitRate: number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Rolling window of active-skill IDs across recent iterations,
|
|
45
|
+
* one per iteration (latest LAST). Maintained by the
|
|
46
|
+
* UpdateSkillHistory function stage (Phase 6 mount).
|
|
47
|
+
*
|
|
48
|
+
* `undefined` entry = no skill active that iteration.
|
|
49
|
+
*/
|
|
50
|
+
readonly skillHistory: readonly (string | undefined)[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Hit-rate floor below which we auto-disable caching. The 30% number
|
|
54
|
+
* is calibrated for Anthropic's pricing: cache write costs +25%
|
|
55
|
+
* premium, cache read costs 90% off. Break-even at ~25% hit rate.
|
|
56
|
+
* 30% gives a buffer; below that we're losing money on writes that
|
|
57
|
+
* never recoup.
|
|
58
|
+
*
|
|
59
|
+
* Reasoning: if hit rate is X, cost-per-token vs no caching is
|
|
60
|
+
* (1 - X) * 1.0 + X * 0.1 // baseline
|
|
61
|
+
* minus
|
|
62
|
+
* write_iters * 1.25 + read_iters * 0.1 // with caching
|
|
63
|
+
* Solving for break-even gives X ≈ 0.25 for typical agent shapes.
|
|
64
|
+
*/
|
|
65
|
+
export declare const HIT_RATE_FLOOR = 0.3;
|
|
66
|
+
/**
|
|
67
|
+
* Window size for skill-churn detection. Last 5 iterations of
|
|
68
|
+
* active skill IDs are inspected.
|
|
69
|
+
*/
|
|
70
|
+
export declare const SKILL_CHURN_WINDOW = 5;
|
|
71
|
+
/**
|
|
72
|
+
* Threshold above which skill churn is considered detected: this many
|
|
73
|
+
* UNIQUE skills in the rolling window. With window=5 and threshold=3,
|
|
74
|
+
* the pattern A → B → A → C still triggers (3 unique skills in 4 iters).
|
|
75
|
+
*/
|
|
76
|
+
export declare const SKILL_CHURN_THRESHOLD = 3;
|
|
77
|
+
/**
|
|
78
|
+
* Pure helper: detect skill churn given a rolling history.
|
|
79
|
+
* Exported for direct testing without decider/scope ceremony.
|
|
80
|
+
*/
|
|
81
|
+
export declare function detectSkillChurn(history: readonly (string | undefined)[], windowSize?: number, threshold?: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Branch routing keys for the CacheGate decider. Two outcomes:
|
|
84
|
+
* apply markers (proceed with cache) or skip (no markers this iter).
|
|
85
|
+
*/
|
|
86
|
+
export type CacheGateBranch = 'apply-markers' | 'no-markers';
|
|
87
|
+
/**
|
|
88
|
+
* The decider function. Mounted via `addDeciderFunction` in the
|
|
89
|
+
* agent's main chart in Phase 6.
|
|
90
|
+
*
|
|
91
|
+
* Returns a `DecisionResult` (footprintjs's `decide()` helper output)
|
|
92
|
+
* which the engine unwraps via `.branch` for routing AND publishes
|
|
93
|
+
* `evidence.rules[matched].inputs[]` to FlowRecorder.onDecision.
|
|
94
|
+
* cacheRecorder (Phase 9) subscribes to that channel for the audit trail.
|
|
95
|
+
*
|
|
96
|
+
* For non-routing consumers (testing the decision in isolation), read
|
|
97
|
+
* the `.branch` field of the returned DecisionResult.
|
|
98
|
+
*/
|
|
99
|
+
export declare function cacheGateDecide(scope: TypedScope<CacheGateState>): DecisionResult;
|
|
100
|
+
/**
|
|
101
|
+
* Update the skill-history rolling window. Called as a function
|
|
102
|
+
* stage BEFORE the CacheGate decider. Reads the current iteration's
|
|
103
|
+
* active skill (the MOST-RECENTLY activated one — the TAIL of
|
|
104
|
+
* `activatedInjectionIds`) and appends it to the `skillHistory` array.
|
|
105
|
+
*
|
|
106
|
+
* WHY THE TAIL, NOT THE HEAD: `read_skill` APPENDS each newly-activated
|
|
107
|
+
* skill to the end of `activatedInjectionIds`, and the list is cumulative
|
|
108
|
+
* + deduped per turn (reset only at seed). So the HEAD is frozen at the
|
|
109
|
+
* FIRST skill activated and never changes mid-turn — sampling it made the
|
|
110
|
+
* window record one constant value, so `detectSkillChurn` could never fire
|
|
111
|
+
* (the skill-churn cache rule was effectively dead). The tail tracks what
|
|
112
|
+
* the agent just switched to, which is the churn signal we actually want.
|
|
113
|
+
*
|
|
114
|
+
* KNOWN LIMITATION: if several skills are activated in the SAME iteration,
|
|
115
|
+
* only the last (tail) is recorded for that iteration — churn can
|
|
116
|
+
* under-count a multi-skill burst. A fully order-independent signal would
|
|
117
|
+
* read `activatedInjectionIds.length` directly in the gate; that is a
|
|
118
|
+
* larger change deferred for now.
|
|
119
|
+
*
|
|
120
|
+
* Window length is bounded at `SKILL_CHURN_WINDOW * 2` so the array
|
|
121
|
+
* doesn't grow unboundedly across long agent runs. Old entries
|
|
122
|
+
* fall off the front naturally.
|
|
123
|
+
*/
|
|
124
|
+
export declare function updateSkillHistory(scope: TypedScope<{
|
|
125
|
+
activatedInjectionIds?: readonly string[];
|
|
126
|
+
skillHistory: readonly (string | undefined)[];
|
|
127
|
+
}>): void;
|