agentfootprint 6.44.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/package.json +203 -56
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BoundaryRecorder — unified domain event log for an agentfootprint run.
|
|
3
|
+
*
|
|
4
|
+
* The single source of truth Lens (and any other consumer) reads to
|
|
5
|
+
* render a run. Every observable moment in a run is captured as one
|
|
6
|
+
* `DomainEvent` in a single ordered stream:
|
|
7
|
+
*
|
|
8
|
+
* - `run.entry` / `run.exit` — top-level executor.run()
|
|
9
|
+
* - `subflow.entry` / `subflow.exit` — every subflow boundary
|
|
10
|
+
* - `fork.branch` — one per parallel child
|
|
11
|
+
* - `decision.branch` — chosen branch of a Conditional
|
|
12
|
+
* - `loop.iteration` — one per back-edge traversal
|
|
13
|
+
* - `llm.start` / `llm.end` — LLM provider call lifecycle
|
|
14
|
+
* - `tool.start` / `tool.end` — tool execution lifecycle
|
|
15
|
+
* - `context.injected` — anything injected into a slot
|
|
16
|
+
*
|
|
17
|
+
* All events carry `runtimeStageId` (binds with footprintjs Trace view +
|
|
18
|
+
* with each other), `subflowPath`, `depth`, and `ts` (wall-clock ms).
|
|
19
|
+
* Subflow events are domain-tagged (`slotKind` / `primitiveKind` /
|
|
20
|
+
* `isAgentInternal`) so consumers dispatch on tag without re-parsing.
|
|
21
|
+
*
|
|
22
|
+
* Architecture:
|
|
23
|
+
*
|
|
24
|
+
* ┌──── footprintjs (domain-agnostic) ────┐
|
|
25
|
+
* │ FlowRecorder events (run/subflow/ │ ──┐
|
|
26
|
+
* │ fork/decision/loop) │ │
|
|
27
|
+
* └───────────────────────────────────────┘ │
|
|
28
|
+
* │
|
|
29
|
+
* ┌──── agentfootprint dispatcher ─────────┐ │ consumed by
|
|
30
|
+
* │ Typed events (llm/tool/context) │ ──┤
|
|
31
|
+
* └────────────────────────────────────────┘ │
|
|
32
|
+
* ▼
|
|
33
|
+
* ┌─── BoundaryRecorder ───┐
|
|
34
|
+
* │ one tagged stream of │
|
|
35
|
+
* │ DomainEvent │
|
|
36
|
+
* └────────────────────────┘
|
|
37
|
+
* │
|
|
38
|
+
* ▼ consumed by
|
|
39
|
+
* ┌────── Lens (UI) ──────┐
|
|
40
|
+
* │ Slider / RunFlow / │
|
|
41
|
+
* │ NodeDetail / etc. │
|
|
42
|
+
* └───────────────────────┘
|
|
43
|
+
*
|
|
44
|
+
* Why ONE recorder: Lens scrub axis, run-flow graph, slot rows inside
|
|
45
|
+
* the LLM card, right-pane detail panel, commentary panel — every UI
|
|
46
|
+
* surface reads from the SAME stream. Adding a new domain event = one
|
|
47
|
+
* tagged emit + one render shape. No state machines spread across
|
|
48
|
+
* renderers, no merging of multiple sources, no name-based filter lists.
|
|
49
|
+
*
|
|
50
|
+
* Naming: `runtimeStageId` is footprintjs's primitive (path-prefixed +
|
|
51
|
+
* `#executionIndex`). `subflowPath` is rooted under the synthetic
|
|
52
|
+
* `'__root__'`. `slotKind` / `primitiveKind` are agent-domain. The
|
|
53
|
+
* design follows the React Fiber + OpenTelemetry pattern:
|
|
54
|
+
* **producers self-describe; consumers dispatch on type**.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { boundaryRecorder, EventDispatcher } from 'agentfootprint';
|
|
59
|
+
*
|
|
60
|
+
* const boundary = boundaryRecorder();
|
|
61
|
+
* const dispatcher = new EventDispatcher();
|
|
62
|
+
* executor.attachCombinedRecorder(boundary); // wires FlowRecorder side
|
|
63
|
+
* boundary.subscribe(dispatcher); // wires typed-event side
|
|
64
|
+
*
|
|
65
|
+
* await executor.run({ input });
|
|
66
|
+
*
|
|
67
|
+
* for (const e of boundary.getEvents()) {
|
|
68
|
+
* switch (e.type) {
|
|
69
|
+
* case 'run.entry': renderRoot(e); break;
|
|
70
|
+
* case 'subflow.entry': if (e.slotKind) renderSlotRow(e);
|
|
71
|
+
* else if (e.primitiveKind) renderPrimitive(e);
|
|
72
|
+
* break;
|
|
73
|
+
* case 'llm.start': renderLLMCall(e); break;
|
|
74
|
+
* // ...
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
import { CommitRangeIndex } from 'footprintjs/trace';
|
|
80
|
+
import type { CombinedRecorder, FlowDecisionEvent, FlowForkEvent, FlowLoopEvent, FlowSubflowEvent, TraversalContext } from 'footprintjs';
|
|
81
|
+
interface FlowRunEvent {
|
|
82
|
+
readonly payload?: unknown;
|
|
83
|
+
readonly traversalContext?: TraversalContext;
|
|
84
|
+
}
|
|
85
|
+
interface FlowRunFailedEvent {
|
|
86
|
+
readonly structuredError: {
|
|
87
|
+
readonly message: string;
|
|
88
|
+
};
|
|
89
|
+
readonly traversalContext?: TraversalContext;
|
|
90
|
+
}
|
|
91
|
+
import type { EventDispatcher, Unsubscribe } from '../../events/dispatcher.js';
|
|
92
|
+
import type { ContextSlot } from '../../events/types.js';
|
|
93
|
+
/** Fields every domain event carries. */
|
|
94
|
+
interface DomainEventBase {
|
|
95
|
+
/** Stable per-execution key (footprintjs primitive). For run events it
|
|
96
|
+
* is `'__root__#0'`; subflow events use the parent stage's runtimeStageId
|
|
97
|
+
* at mount; typed events use the firing stage's runtimeStageId. */
|
|
98
|
+
readonly runtimeStageId: string;
|
|
99
|
+
/** Decomposition of `subflowId` into segments, rooted under `'__root__'`. */
|
|
100
|
+
readonly subflowPath: readonly string[];
|
|
101
|
+
/** Depth in the run tree — root = 0, top-level subflow = 1, etc. */
|
|
102
|
+
readonly depth: number;
|
|
103
|
+
/** Wall-clock ms at capture time. */
|
|
104
|
+
readonly ts: number;
|
|
105
|
+
/** Commit count when this event fired. 0 if the recorder was
|
|
106
|
+
* constructed without `getCommitCount` (legacy mode). The boundary
|
|
107
|
+
* RANGE for an (entry, exit) pair is `[entry.commitIdxBefore,
|
|
108
|
+
* exit.commitIdxBefore]`. Phase 5 Layer 2 — see
|
|
109
|
+
* `docs/design/boundary-commit-ranges.md`. */
|
|
110
|
+
readonly commitIdxBefore: number;
|
|
111
|
+
/** RESERVED for future event types that trigger engine writes.
|
|
112
|
+
* CURRENT BEHAVIOR: always equals `commitIdxBefore` for every event
|
|
113
|
+
* emitted by today's BoundaryRecorder. Observer events don't write
|
|
114
|
+
* to scope, so the executor's commit count doesn't change between
|
|
115
|
+
* the moment the event is sampled and the moment it's recorded.
|
|
116
|
+
* Consumers should currently treat this as identical to
|
|
117
|
+
* `commitIdxBefore`; do NOT rely on it being strictly greater.
|
|
118
|
+
* The field exists for forward compatibility — if a future
|
|
119
|
+
* observer pattern triggers commits during its handler, this is
|
|
120
|
+
* where the post-effect count will land. */
|
|
121
|
+
readonly commitIdxAfter: number;
|
|
122
|
+
}
|
|
123
|
+
export interface DomainRunEvent extends DomainEventBase {
|
|
124
|
+
readonly type: 'run.entry' | 'run.exit';
|
|
125
|
+
readonly payload?: unknown;
|
|
126
|
+
/** Always `true` for run events — convenience flag for filter callers. */
|
|
127
|
+
readonly isRoot: true;
|
|
128
|
+
}
|
|
129
|
+
export interface DomainSubflowEvent extends DomainEventBase {
|
|
130
|
+
readonly type: 'subflow.entry' | 'subflow.exit';
|
|
131
|
+
/** Path-prefixed engine id (matches `FlowSubflowEvent.subflowId`). */
|
|
132
|
+
readonly subflowId: string;
|
|
133
|
+
/** Last segment of `subflowId` — convenience for leaf-name grouping. */
|
|
134
|
+
readonly localSubflowId: string;
|
|
135
|
+
readonly subflowName: string;
|
|
136
|
+
/** Build-time description from the subflow root (`'<Kind>: <detail>'`). */
|
|
137
|
+
readonly description?: string;
|
|
138
|
+
/** Parsed `'<Kind>:'` prefix — `'Agent'`, `'LLMCall'`, `'Sequence'`, etc. */
|
|
139
|
+
readonly primitiveKind?: string;
|
|
140
|
+
/** Set ONLY for the 3 input-slot subflows (sf-system-prompt / sf-messages / sf-tools). */
|
|
141
|
+
readonly slotKind?: ContextSlot;
|
|
142
|
+
/** True for Agent state-machine routing/wrapper subflows (route, tool-calls, final, merge). */
|
|
143
|
+
readonly isAgentInternal: boolean;
|
|
144
|
+
/** `inputMapper` result on entry; subflow shared state on exit. */
|
|
145
|
+
readonly payload?: unknown;
|
|
146
|
+
}
|
|
147
|
+
export interface DomainForkBranchEvent extends DomainEventBase {
|
|
148
|
+
readonly type: 'fork.branch';
|
|
149
|
+
readonly parentSubflowId: string;
|
|
150
|
+
readonly childName: string;
|
|
151
|
+
}
|
|
152
|
+
export interface DomainDecisionBranchEvent extends DomainEventBase {
|
|
153
|
+
readonly type: 'decision.branch';
|
|
154
|
+
readonly decider: string;
|
|
155
|
+
readonly chosen: string;
|
|
156
|
+
readonly rationale?: string;
|
|
157
|
+
/**
|
|
158
|
+
* `true` when this decision comes from one of the Agent's internal
|
|
159
|
+
* routing stages (e.g., the ReAct `Route` decider that picks
|
|
160
|
+
* `tool-calls` vs `final`). Filtered out of the timeline by
|
|
161
|
+
* `buildStepGraph` — the actor arrows that follow already encode
|
|
162
|
+
* the routing observably (`llm→tool` vs `llm→user`).
|
|
163
|
+
*
|
|
164
|
+
* `false` when the decision comes from a consumer-defined
|
|
165
|
+
* `Conditional` primitive — those ARE meaningful timeline steps.
|
|
166
|
+
*/
|
|
167
|
+
readonly isAgentInternal: boolean;
|
|
168
|
+
}
|
|
169
|
+
export interface DomainLoopIterationEvent extends DomainEventBase {
|
|
170
|
+
readonly type: 'loop.iteration';
|
|
171
|
+
readonly target: string;
|
|
172
|
+
readonly iteration: number;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Composition boundary event — fired for every composition primitive
|
|
176
|
+
* (Parallel / Sequence / Loop / Conditional). Mirrors `subflow.entry/exit`
|
|
177
|
+
* but for the COMPOSITION wrapper itself (the box that contains the
|
|
178
|
+
* branches / steps / iterations / chosen-branch).
|
|
179
|
+
*
|
|
180
|
+
* This pair OPENS and CLOSES a boundary range in `boundaryIndex`. Child
|
|
181
|
+
* subflows that fire between the pair nest naturally inside the
|
|
182
|
+
* composition's range.
|
|
183
|
+
*
|
|
184
|
+
* The `runtimeStageId` is the composition's own per-execution id —
|
|
185
|
+
* SAME format as any other runtimeStageId, with `#executionIndex`. The
|
|
186
|
+
* `kind` discriminates which composition primitive this is.
|
|
187
|
+
*
|
|
188
|
+
* For the Lens compound time axis, this group is what collapses
|
|
189
|
+
* parallel branches into ONE slider position at the parent's drill
|
|
190
|
+
* level. Drill into the composition to see its children as positions.
|
|
191
|
+
*/
|
|
192
|
+
export interface DomainCompositionEvent extends DomainEventBase {
|
|
193
|
+
readonly type: 'composition.start' | 'composition.end';
|
|
194
|
+
readonly kind: 'Parallel' | 'Sequence' | 'Loop' | 'Conditional';
|
|
195
|
+
readonly compositionId: string;
|
|
196
|
+
readonly name: string;
|
|
197
|
+
/** On `composition.end`, the exit status reported by the composition. */
|
|
198
|
+
readonly status?: 'ok' | 'err' | 'break' | 'budget_exhausted';
|
|
199
|
+
readonly durationMs?: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The 4 actor arrows of a ReAct cycle. Tagged on `llm.start` / `llm.end`
|
|
203
|
+
* at capture time so consumers (slider, run-flow renderer) dispatch by
|
|
204
|
+
* `event.actorArrow` instead of running their own state machine.
|
|
205
|
+
*
|
|
206
|
+
* - `'user→llm'` — first LLM call, or any LLM call NOT preceded by a
|
|
207
|
+
* tool result (assembled-context delivery to the model).
|
|
208
|
+
* - `'tool→llm'` — LLM call that follows a tool's result (the next
|
|
209
|
+
* iteration of a ReAct loop).
|
|
210
|
+
* - `'llm→tool'` — `llm.end` whose `toolCallCount > 0` (the LLM is
|
|
211
|
+
* requesting tool execution).
|
|
212
|
+
* - `'llm→user'` — `llm.end` with `toolCallCount === 0` (terminal
|
|
213
|
+
* response delivered to the user).
|
|
214
|
+
*/
|
|
215
|
+
export type ActorArrow = 'user→llm' | 'tool→llm' | 'llm→tool' | 'llm→user';
|
|
216
|
+
export interface DomainLLMStartEvent extends DomainEventBase {
|
|
217
|
+
readonly type: 'llm.start';
|
|
218
|
+
readonly model: string;
|
|
219
|
+
readonly provider: string;
|
|
220
|
+
readonly systemPromptChars?: number;
|
|
221
|
+
readonly messagesCount?: number;
|
|
222
|
+
readonly toolsCount?: number;
|
|
223
|
+
/** Capture-time classification: `'user→llm'` for the first call or any
|
|
224
|
+
* call not preceded by a tool result; `'tool→llm'` after a tool result. */
|
|
225
|
+
readonly actorArrow: 'user→llm' | 'tool→llm';
|
|
226
|
+
}
|
|
227
|
+
export interface DomainLLMEndEvent extends DomainEventBase {
|
|
228
|
+
readonly type: 'llm.end';
|
|
229
|
+
readonly content: string;
|
|
230
|
+
readonly toolCallCount: number;
|
|
231
|
+
readonly usage: {
|
|
232
|
+
readonly input: number;
|
|
233
|
+
readonly output: number;
|
|
234
|
+
};
|
|
235
|
+
readonly stopReason?: string;
|
|
236
|
+
/** Capture-time classification: `'llm→tool'` when the LLM requested
|
|
237
|
+
* tools (`toolCallCount > 0`); `'llm→user'` for terminal delivery. */
|
|
238
|
+
readonly actorArrow: 'llm→tool' | 'llm→user';
|
|
239
|
+
}
|
|
240
|
+
export interface DomainToolStartEvent extends DomainEventBase {
|
|
241
|
+
readonly type: 'tool.start';
|
|
242
|
+
readonly toolName: string;
|
|
243
|
+
readonly toolCallId: string;
|
|
244
|
+
readonly args?: unknown;
|
|
245
|
+
}
|
|
246
|
+
export interface DomainToolEndEvent extends DomainEventBase {
|
|
247
|
+
readonly type: 'tool.end';
|
|
248
|
+
readonly toolCallId: string;
|
|
249
|
+
readonly result?: unknown;
|
|
250
|
+
readonly durationMs?: number;
|
|
251
|
+
readonly error?: boolean;
|
|
252
|
+
}
|
|
253
|
+
export interface DomainContextInjectedEvent extends DomainEventBase {
|
|
254
|
+
readonly type: 'context.injected';
|
|
255
|
+
readonly slot: ContextSlot;
|
|
256
|
+
readonly source: string;
|
|
257
|
+
readonly sourceId?: string;
|
|
258
|
+
readonly asRole?: 'system' | 'user' | 'assistant' | 'tool';
|
|
259
|
+
readonly contentSummary?: string;
|
|
260
|
+
readonly reason?: string;
|
|
261
|
+
readonly sectionTag?: string;
|
|
262
|
+
readonly upstreamRef?: string;
|
|
263
|
+
readonly retrievalScore?: number;
|
|
264
|
+
readonly rankPosition?: number;
|
|
265
|
+
/** Tokens consumed by this injection (from `budgetSpent.tokens`). */
|
|
266
|
+
readonly budgetTokens?: number;
|
|
267
|
+
/** Fraction of slot cap consumed (from `budgetSpent.fractionOfCap`). */
|
|
268
|
+
readonly budgetFraction?: number;
|
|
269
|
+
}
|
|
270
|
+
/** Discriminated union covering every observable moment in a run. */
|
|
271
|
+
export type DomainEvent = DomainRunEvent | DomainSubflowEvent | DomainCompositionEvent | DomainForkBranchEvent | DomainDecisionBranchEvent | DomainLoopIterationEvent | DomainLLMStartEvent | DomainLLMEndEvent | DomainToolStartEvent | DomainToolEndEvent | DomainContextInjectedEvent;
|
|
272
|
+
/**
|
|
273
|
+
* Per-boundary rollup returned by
|
|
274
|
+
* `BoundaryRecorder.aggregateForBoundary` and
|
|
275
|
+
* `BoundaryRecorder.aggregateAllBoundaries`. Same shape regardless of
|
|
276
|
+
* primitive kind — UIs render the same chip set for every Agent /
|
|
277
|
+
* LLMCall / Sequence / Parallel / Conditional / Loop.
|
|
278
|
+
*
|
|
279
|
+
* Events count toward this rollup when their `subflowPath` is a
|
|
280
|
+
* prefix-match of the boundary's `subflowPath`. Nested boundaries
|
|
281
|
+
* (e.g., LLMCall inside an Agent) contribute to BOTH rollups.
|
|
282
|
+
*
|
|
283
|
+
* In-flight boundaries (no `subflow.exit` yet) get partial values;
|
|
284
|
+
* `endedAtMs` and `durationMs` are undefined until close.
|
|
285
|
+
*/
|
|
286
|
+
export interface BoundaryAggregate {
|
|
287
|
+
readonly runtimeStageId: string;
|
|
288
|
+
readonly subflowId: string;
|
|
289
|
+
readonly subflowPath: readonly string[];
|
|
290
|
+
/** `'Agent'` / `'LLMCall'` / `'Sequence'` / `'Parallel'` /
|
|
291
|
+
* `'Conditional'` / `'Loop'`. Always set on rollups returned by
|
|
292
|
+
* `aggregateAllBoundaries` (which filters to primitive boundaries).
|
|
293
|
+
* Optional on `aggregateForBoundary` results because the caller may
|
|
294
|
+
* request rollup for a non-primitive subflow (rare). */
|
|
295
|
+
readonly primitiveKind?: string;
|
|
296
|
+
/** Subflow display name (e.g., 'Triage', 'Billing'). */
|
|
297
|
+
readonly label: string;
|
|
298
|
+
/** Token usage summed across every `llm.end` inside this boundary. */
|
|
299
|
+
readonly tokens: {
|
|
300
|
+
readonly input: number;
|
|
301
|
+
readonly output: number;
|
|
302
|
+
};
|
|
303
|
+
/** Count of `llm.start` events inside this boundary. */
|
|
304
|
+
readonly llmCalls: number;
|
|
305
|
+
/** Count of `tool.start` events inside this boundary. */
|
|
306
|
+
readonly toolCalls: number;
|
|
307
|
+
/** Count of `agent.iteration_start` events scoped to this boundary —
|
|
308
|
+
* ReAct-loop iterations. Always `0` for non-Agent primitives. */
|
|
309
|
+
readonly iterations: number;
|
|
310
|
+
/** Wall-clock ms of `subflow.entry`. */
|
|
311
|
+
readonly startedAtMs: number;
|
|
312
|
+
/** Wall-clock ms of `subflow.exit`. Undefined while in flight. */
|
|
313
|
+
readonly endedAtMs?: number;
|
|
314
|
+
/** `endedAtMs - startedAtMs`. Undefined while in flight. */
|
|
315
|
+
readonly durationMs?: number;
|
|
316
|
+
}
|
|
317
|
+
export interface BoundaryRecorderOptions {
|
|
318
|
+
readonly id?: string;
|
|
319
|
+
/**
|
|
320
|
+
* Live commit-count accessor — typically `() => executor.getCommitCount()`
|
|
321
|
+
* from footprintjs 5.1+. Inject from your runner. When provided:
|
|
322
|
+
* - Every DomainEvent gains `commitIdxBefore` / `commitIdxAfter`.
|
|
323
|
+
* - `recorder.boundaryIndex` is populated with open/close ranges
|
|
324
|
+
* keyed on each subflow's entry event.
|
|
325
|
+
* When omitted (legacy / pre-5.1 footprintjs): both fields are 0 on
|
|
326
|
+
* every event; `boundaryIndex` exists but is empty. Phase 5 Layer 2.
|
|
327
|
+
*/
|
|
328
|
+
readonly getCommitCount?: () => number;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Stripped projection used as the LABEL for the commit-range index.
|
|
332
|
+
* Intentionally OMITS `payload` (security panel review YELLOW #1):
|
|
333
|
+
* `boundaryIndex.enclosing()` queries should not bypass redaction by
|
|
334
|
+
* exposing raw scope payloads through the range index. Consumers
|
|
335
|
+
* needing payload can join on `runtimeStageId` with the full event
|
|
336
|
+
* stream via `getEvents()` (which IS subject to redaction policy).
|
|
337
|
+
*/
|
|
338
|
+
export interface BoundaryRangeLabel {
|
|
339
|
+
readonly type: 'subflow.entry' | 'run.entry' | 'composition.start';
|
|
340
|
+
readonly runtimeStageId: string;
|
|
341
|
+
readonly subflowPath: readonly string[];
|
|
342
|
+
readonly depth: number;
|
|
343
|
+
readonly ts: number;
|
|
344
|
+
/** Set on subflow entries; undefined on the synthetic run-root entry. */
|
|
345
|
+
readonly subflowId?: string;
|
|
346
|
+
readonly localSubflowId?: string;
|
|
347
|
+
readonly subflowName?: string;
|
|
348
|
+
readonly description?: string;
|
|
349
|
+
readonly primitiveKind?: string;
|
|
350
|
+
readonly slotKind?: ContextSlot;
|
|
351
|
+
readonly isAgentInternal?: boolean;
|
|
352
|
+
/** Composition primitive (Parallel/Sequence/Loop/Conditional) when the
|
|
353
|
+
* range was opened by a `composition.start` event. */
|
|
354
|
+
readonly compositionKind?: 'Parallel' | 'Sequence' | 'Loop' | 'Conditional';
|
|
355
|
+
readonly compositionName?: string;
|
|
356
|
+
}
|
|
357
|
+
/** Factory — matches the `inOutRecorder()` / `topologyRecorder()` style. */
|
|
358
|
+
export declare function boundaryRecorder(options?: BoundaryRecorderOptions): BoundaryRecorder;
|
|
359
|
+
/**
|
|
360
|
+
* Unified domain event recorder. Implements `CombinedRecorder` so it can
|
|
361
|
+
* attach to the executor's FlowRecorder channel; exposes `subscribe()`
|
|
362
|
+
* to wire to the agentfootprint typed-event dispatcher.
|
|
363
|
+
*
|
|
364
|
+
* v5: composes a `SequenceStore<DomainEvent>` (storage) instead of
|
|
365
|
+
* extending the deprecated `SequenceStore<T>` base. Time-travel
|
|
366
|
+
* utilities (`getEntryRanges`, `accumulate`) are accessed through the
|
|
367
|
+
* store via the public read API on this class.
|
|
368
|
+
*/
|
|
369
|
+
export declare class BoundaryRecorder implements CombinedRecorder {
|
|
370
|
+
readonly id: string;
|
|
371
|
+
/** Composition: storage shelf. */
|
|
372
|
+
private readonly store;
|
|
373
|
+
/**
|
|
374
|
+
* Phase 5 Layer 2 — interval index over commit indices, populated
|
|
375
|
+
* live as boundary entry/exit pairs fire. Consumers (Lens) read
|
|
376
|
+
* `enclosing(commitIdx)` for breadcrumbs and `overlapping(slice)`
|
|
377
|
+
* for time-range queries. Empty when `getCommitCount` is not
|
|
378
|
+
* injected. See `docs/design/boundary-commit-ranges.md`.
|
|
379
|
+
*/
|
|
380
|
+
readonly boundaryIndex: CommitRangeIndex<BoundaryRangeLabel>;
|
|
381
|
+
/** Open-range tokens keyed by `runtimeStageId` so the matching exit
|
|
382
|
+
* can close the correct range. Pure side-table; cleared on runId
|
|
383
|
+
* reset. Not exposed externally. */
|
|
384
|
+
private readonly openTokens;
|
|
385
|
+
/** Live commit-count accessor injected by the runner. Sanitized
|
|
386
|
+
* (NaN/Infinity/negative → 0) before use. */
|
|
387
|
+
private readonly getCommitCount;
|
|
388
|
+
/** True when `getCommitCount` was explicitly injected. In LEGACY
|
|
389
|
+
* MODE (false), `boundaryIndex` is intentionally NOT populated —
|
|
390
|
+
* zero-width [0,0] ranges would mislead consumers querying the
|
|
391
|
+
* index. Multi-panel review flagged this footgun. */
|
|
392
|
+
private readonly hasCommitTracking;
|
|
393
|
+
/**
|
|
394
|
+
* Tracks whether the most recent `llm.end` had toolCalls. Used to
|
|
395
|
+
* classify the NEXT `llm.start` as `'tool→llm'` (vs `'user→llm'` if
|
|
396
|
+
* there's no pending tool result). Reset on `clear()` and on every
|
|
397
|
+
* `llm.start` event after the classification is applied.
|
|
398
|
+
*/
|
|
399
|
+
private prevLLMEndHadTools;
|
|
400
|
+
/**
|
|
401
|
+
* Run-boundary observer — fires resetForNewRun() when
|
|
402
|
+
* traversalContext.runId changes between events AND no boundary is
|
|
403
|
+
* currently open. The "no open boundary" gate distinguishes:
|
|
404
|
+
*
|
|
405
|
+
* - **Legitimate new run** — consumer reuses one recorder across
|
|
406
|
+
* sequential `executor.run()` calls. All prior boundaries closed
|
|
407
|
+
* before the second run began; openTokens is empty when the new
|
|
408
|
+
* runId arrives → safe to wipe state so the second run doesn't
|
|
409
|
+
* alias with the first.
|
|
410
|
+
* - **Composition sub-run** — primitives like `LLMCall`, `Sequence`,
|
|
411
|
+
* and `Parallel` internally spawn their own `FlowChartExecutor`
|
|
412
|
+
* instances. Each sub-executor mints a NEW runId. When that
|
|
413
|
+
* sub-executor fires events on the SHARED recorder, the recorder
|
|
414
|
+
* is still inside the parent run — `openTokens` is non-empty.
|
|
415
|
+
* Resetting here would wipe the parent's boundary index mid-run
|
|
416
|
+
* (the bug Layer 4 surfaced in agentfootprint-lens fanout).
|
|
417
|
+
*
|
|
418
|
+
* The `openTokens.size === 0` check is the cleanest semantic signal:
|
|
419
|
+
* if nothing is in-flight, a runId change means "the consumer started
|
|
420
|
+
* fresh"; if something is open, the new runId is from a sub-executor
|
|
421
|
+
* nested inside the still-ongoing parent.
|
|
422
|
+
*/
|
|
423
|
+
private readonly runIdGuard;
|
|
424
|
+
constructor(options?: BoundaryRecorderOptions);
|
|
425
|
+
/**
|
|
426
|
+
* Reset all transient state.
|
|
427
|
+
*
|
|
428
|
+
* **Composition-safe gate (Phase 5 Layer 4):** if `openTokens.size > 0`
|
|
429
|
+
* the call is a no-op. Rationale: `FlowChartExecutor.run()` calls
|
|
430
|
+
* `r.clear?.()` on every attached recorder during its pre-run loop.
|
|
431
|
+
* When agentfootprint composition primitives (LLMCall, Sequence,
|
|
432
|
+
* Parallel, etc.) propagate the parent's recorders to nested
|
|
433
|
+
* sub-executors, EACH sub-executor's pre-run clear loop calls
|
|
434
|
+
* `clear()` on the SHARED parent recorder mid-run — wiping live
|
|
435
|
+
* parent state. The `openTokens.size > 0` check distinguishes:
|
|
436
|
+
*
|
|
437
|
+
* - **Legitimate reset** — consumer or executor calls `clear()`
|
|
438
|
+
* when no boundary is in-flight (`openTokens` empty). Safe to
|
|
439
|
+
* wipe; the recorder is idle.
|
|
440
|
+
* - **Composition wipe** — sub-executor's pre-run clear fires
|
|
441
|
+
* while the parent has open boundaries (`openTokens` non-empty).
|
|
442
|
+
* Skip the wipe; the parent's state must be preserved.
|
|
443
|
+
*
|
|
444
|
+
* If a consumer needs to forcibly wipe state even with open tokens
|
|
445
|
+
* (e.g., manual recovery after a crashed run), pair `clear()` with
|
|
446
|
+
* an explicit `forceClear()` (TODO — add when the use case shows up;
|
|
447
|
+
* today the recorder lifecycle pattern is "one recorder per logical
|
|
448
|
+
* run" so leaked tokens shouldn't occur).
|
|
449
|
+
*/
|
|
450
|
+
clear(): void;
|
|
451
|
+
private observeRunId;
|
|
452
|
+
onRunStart(event: FlowRunEvent): void;
|
|
453
|
+
onRunEnd(event: FlowRunEvent): void;
|
|
454
|
+
onRunFailed(event: FlowRunFailedEvent): void;
|
|
455
|
+
onSubflowEntry(event: FlowSubflowEvent): void;
|
|
456
|
+
onSubflowExit(event: FlowSubflowEvent): void;
|
|
457
|
+
onFork(event: FlowForkEvent): void;
|
|
458
|
+
onDecision(event: FlowDecisionEvent): void;
|
|
459
|
+
onLoop(event: FlowLoopEvent): void;
|
|
460
|
+
/**
|
|
461
|
+
* Subscribe to the runner's typed-event dispatcher and emit a domain
|
|
462
|
+
* event for each `llm.*` / `tool.*` / `context.injected` event.
|
|
463
|
+
*
|
|
464
|
+
* Returns an unsubscribe function; safe to call multiple times (each
|
|
465
|
+
* call adds a new subscription). Most consumers call this once at
|
|
466
|
+
* recorder construction and dispose with the returned function.
|
|
467
|
+
*/
|
|
468
|
+
subscribe(dispatcher: EventDispatcher): Unsubscribe;
|
|
469
|
+
private ingestTypedEvent;
|
|
470
|
+
/** All events in capture order (the canonical projection). */
|
|
471
|
+
getEvents(): DomainEvent[];
|
|
472
|
+
/** Type-narrowed lookup: all events of one kind. */
|
|
473
|
+
getEventsByType<T extends DomainEvent['type']>(type: T): Extract<DomainEvent, {
|
|
474
|
+
type: T;
|
|
475
|
+
}>[];
|
|
476
|
+
/** All boundary events (run + subflow, entry + exit interleaved). */
|
|
477
|
+
getBoundaries(): (DomainRunEvent | DomainSubflowEvent)[];
|
|
478
|
+
/** Just the entry-phase boundary events — the "step list" timeline. */
|
|
479
|
+
getSteps(): (DomainRunEvent | DomainSubflowEvent)[];
|
|
480
|
+
/** Subset of `getSteps()` excluding agent-internal routing subflows. */
|
|
481
|
+
getVisibleSteps(): (DomainRunEvent | DomainSubflowEvent)[];
|
|
482
|
+
/** Entry/exit pair for one chart execution by `runtimeStageId`. */
|
|
483
|
+
getBoundary(runtimeStageId: string): {
|
|
484
|
+
entry?: DomainRunEvent | DomainSubflowEvent;
|
|
485
|
+
exit?: DomainRunEvent | DomainSubflowEvent;
|
|
486
|
+
};
|
|
487
|
+
/** Convenience for the outermost `__root__` pair. */
|
|
488
|
+
getRootBoundary(): {
|
|
489
|
+
entry?: DomainRunEvent;
|
|
490
|
+
exit?: DomainRunEvent;
|
|
491
|
+
};
|
|
492
|
+
/** Subflow events grouped by the 3 input slots — for slot-row rendering. */
|
|
493
|
+
getSlotBoundaries(): {
|
|
494
|
+
systemPrompt: DomainSubflowEvent[];
|
|
495
|
+
messages: DomainSubflowEvent[];
|
|
496
|
+
tools: DomainSubflowEvent[];
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* Roll up the event stream for ONE primitive boundary (Agent /
|
|
500
|
+
* LLMCall / Sequence / Parallel / Conditional / Loop) into per-
|
|
501
|
+
* boundary totals — tokens, llm calls, tool calls, iterations,
|
|
502
|
+
* cache hits, duration.
|
|
503
|
+
*
|
|
504
|
+
* Pure projection over `getEvents()`. Events are attributed to a
|
|
505
|
+
* boundary when their `subflowPath` is a **prefix-match** of the
|
|
506
|
+
* boundary's path — so a nested `LLMCall` inside an `Agent` rolls
|
|
507
|
+
* up into BOTH (LLMCall total + Agent total).
|
|
508
|
+
*
|
|
509
|
+
* Works mid-run (the boundary's `subflow.exit` may not have fired
|
|
510
|
+
* yet — `endedAtMs` / `durationMs` are undefined in that case).
|
|
511
|
+
* Works post-run.
|
|
512
|
+
*
|
|
513
|
+
* Multi-consumer story: this is the single source of rollup truth
|
|
514
|
+
* for Lens, CLI live monitors, Sentry breadcrumbs, OTel exporters,
|
|
515
|
+
* dashboards. Domain math (what counts as an "iteration"? does
|
|
516
|
+
* cache hit count separately from llmCalls?) lives HERE — every
|
|
517
|
+
* consumer hooks up; nobody re-implements.
|
|
518
|
+
*
|
|
519
|
+
* @param runtimeStageId The boundary's runtimeStageId (the same id
|
|
520
|
+
* carried by `StepNode.runtimeStageId` for primitive subflows).
|
|
521
|
+
* @returns The rollup, or `undefined` if no `subflow.entry` event
|
|
522
|
+
* matches `runtimeStageId`.
|
|
523
|
+
*/
|
|
524
|
+
aggregateForBoundary(runtimeStageId: string): BoundaryAggregate | undefined;
|
|
525
|
+
/**
|
|
526
|
+
* Roll up every primitive boundary in the run into one rollup each,
|
|
527
|
+
* in the order their `subflow.entry` events fired. Top-level multi-
|
|
528
|
+
* agent UIs call this once per render to populate per-agent chips.
|
|
529
|
+
*
|
|
530
|
+
* Filters to `primitiveKind`-tagged subflows ONLY (Agent / LLMCall /
|
|
531
|
+
* Sequence / Parallel / Conditional / Loop). Slot subflows
|
|
532
|
+
* (`sf-system-prompt` / `sf-messages` / `sf-tools`) are NOT
|
|
533
|
+
* boundaries in this sense — they're context-engineering machinery,
|
|
534
|
+
* not user-facing rollup units.
|
|
535
|
+
*/
|
|
536
|
+
aggregateAllBoundaries(): readonly BoundaryAggregate[];
|
|
537
|
+
/** Snapshot bundle — included in `executor.getSnapshot()` if the
|
|
538
|
+
* executor implements the snapshot extension protocol. */
|
|
539
|
+
toSnapshot(): {
|
|
540
|
+
name: string;
|
|
541
|
+
description: string;
|
|
542
|
+
preferredOperation: "translate";
|
|
543
|
+
data: DomainEvent[];
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
export {};
|