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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal — not part of the public agentfootprint API. Imported only
|
|
3
|
+
* by RunStepRecorder. Subject to change without notice; do not import
|
|
4
|
+
* via deep paths.
|
|
5
|
+
*
|
|
6
|
+
* ForkTracker — owns the bookkeeping for parallel-fork emission and
|
|
7
|
+
* merge-step detection. Extracted from RunStepRecorder per Convention 1
|
|
8
|
+
* (one purpose per recorder/state machine).
|
|
9
|
+
*
|
|
10
|
+
* Responsibilities (and ONLY these):
|
|
11
|
+
* 1. Coalesce repeated `onFork` events for the same parent (race-safe
|
|
12
|
+
* via parent+runtimeStageId key).
|
|
13
|
+
* 2. Track which child branches belong to which parent fork.
|
|
14
|
+
* 3. Track which branches have exited; signal "merge ready" when ALL
|
|
15
|
+
* branches of a fork have exited.
|
|
16
|
+
*
|
|
17
|
+
* What it does NOT own:
|
|
18
|
+
* - Storage (the recorder writes RunSteps to its SequenceStore).
|
|
19
|
+
* - Run-boundary detection (the recorder's runIdGuard wipes this
|
|
20
|
+
* tracker via `clear()`).
|
|
21
|
+
* - Any other state machine.
|
|
22
|
+
*/
|
|
23
|
+
export interface ForkRegistration {
|
|
24
|
+
/** True if this is a NEW fork; false if the same fork was already seen
|
|
25
|
+
* (caller should suppress duplicate emission). */
|
|
26
|
+
readonly fresh: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface MergeReady {
|
|
29
|
+
/** All branch IDs of the now-fully-exited fork, in the order they
|
|
30
|
+
* were originally registered. */
|
|
31
|
+
readonly branches: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
export declare class ForkTracker {
|
|
34
|
+
/** Per-parent: the ordered list of child branch IDs registered. */
|
|
35
|
+
private readonly branches;
|
|
36
|
+
/** Per-parent: the set of child branch IDs that have exited so far. */
|
|
37
|
+
private readonly exited;
|
|
38
|
+
/** Reverse index: child branch ID → its parent fork. */
|
|
39
|
+
private readonly childToParent;
|
|
40
|
+
/** Set of `${parent}@${runtimeStageId}` keys already registered, to
|
|
41
|
+
* coalesce repeated onFork events. */
|
|
42
|
+
private readonly emittedKeys;
|
|
43
|
+
/**
|
|
44
|
+
* Register a new fork. If the same fork (by parent+runtimeStageId)
|
|
45
|
+
* was already registered, returns `{ fresh: false }` and the caller
|
|
46
|
+
* should suppress emission. Otherwise registers all child branches
|
|
47
|
+
* and returns `{ fresh: true }`.
|
|
48
|
+
*/
|
|
49
|
+
registerFork(parent: string, runtimeStageId: string, children: readonly string[]): ForkRegistration;
|
|
50
|
+
/** True if this child belongs to a tracked fork (used to suppress
|
|
51
|
+
* sequential-emission for fork-branch entry events). */
|
|
52
|
+
isForkChild(childSubflowId: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Record a fork-branch exit. If this completes the fork (all branches
|
|
55
|
+
* have exited), returns `{ branches }` so the caller can emit a merge
|
|
56
|
+
* step. Returns `undefined` if not yet complete or not a fork branch.
|
|
57
|
+
*/
|
|
58
|
+
recordChildExit(childSubflowId: string): MergeReady | undefined;
|
|
59
|
+
clear(): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal — not part of the public agentfootprint API. Imported only
|
|
3
|
+
* by RunStepRecorder. Subject to change without notice.
|
|
4
|
+
*
|
|
5
|
+
* RootInferrer — small state machine deciding whether a run's root is
|
|
6
|
+
* a single leaf primitive (Agent / LLMCall) or a composition (Sequence
|
|
7
|
+
* / Parallel / Conditional / Loop).
|
|
8
|
+
*
|
|
9
|
+
* Extracted from RunStepRecorder per Convention 1.
|
|
10
|
+
*
|
|
11
|
+
* Inputs: subflow entries (with their depth + parsed primitiveKind),
|
|
12
|
+
* fork events (depth 0 → Parallel root), decision events (depth 0 →
|
|
13
|
+
* Conditional root), loop events (depth 0 → Loop root).
|
|
14
|
+
*
|
|
15
|
+
* Output: query `kind()` for the inferred root. Returns `undefined`
|
|
16
|
+
* until a signal arrives.
|
|
17
|
+
*
|
|
18
|
+
* Inference rules:
|
|
19
|
+
* - Decisive composition signals (fork / decide / loop AT DEPTH 0)
|
|
20
|
+
* lock the root and are never overridden.
|
|
21
|
+
* - Shallowest primitive boundary IS a composition kind → root is
|
|
22
|
+
* that composition.
|
|
23
|
+
* - Two+ leaf siblings at the shallowest depth → implicit Sequence
|
|
24
|
+
* root (Sequence-as-runner case where the Sequence itself doesn't
|
|
25
|
+
* fire its own subflow.entry).
|
|
26
|
+
* - Single leaf at the shallowest depth → root is "leaf".
|
|
27
|
+
*/
|
|
28
|
+
export type InferredRoot = 'leaf' | 'sequence' | 'parallel' | 'conditional' | 'loop' | undefined;
|
|
29
|
+
export declare class RootInferrer {
|
|
30
|
+
private inferred;
|
|
31
|
+
private shallowestDepth;
|
|
32
|
+
private shallowestSiblings;
|
|
33
|
+
/** Currently-inferred root kind, or undefined if no signal yet. */
|
|
34
|
+
kind(): InferredRoot;
|
|
35
|
+
/** True when the root is a single leaf primitive (or unknown,
|
|
36
|
+
* which should be treated as leaf for kind-filter purposes). */
|
|
37
|
+
isLeafRoot(): boolean;
|
|
38
|
+
/** Observe a subflow entry. */
|
|
39
|
+
observeSubflowEntry(depth: number, primitiveKind: string | undefined): void;
|
|
40
|
+
/** Observe a fork event. Locks root to Parallel if at depth 0 and
|
|
41
|
+
* no decisive root has been inferred yet. */
|
|
42
|
+
observeFork(depth: number): void;
|
|
43
|
+
/** Observe a decision event. Locks root to Conditional if at depth 0
|
|
44
|
+
* and no decisive root has been inferred yet. */
|
|
45
|
+
observeDecision(depth: number): void;
|
|
46
|
+
/** Observe a loop event. Locks root to Loop if at depth 0 and no
|
|
47
|
+
* decisive root has been inferred yet. */
|
|
48
|
+
observeLoop(depth: number): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
private tryInfer;
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal — not part of the public agentfootprint API. Imported only
|
|
3
|
+
* by RunStepRecorder. Subject to change without notice.
|
|
4
|
+
*
|
|
5
|
+
* SequenceSiblingTracker — tracks the most-recent leaf exit at each
|
|
6
|
+
* depth so the recorder knows when a new leaf entry at the same depth
|
|
7
|
+
* should emit a "sequential handoff" step ("forwards" semantics).
|
|
8
|
+
*
|
|
9
|
+
* Extracted from RunStepRecorder per Convention 1.
|
|
10
|
+
*
|
|
11
|
+
* Use:
|
|
12
|
+
* - On leaf EXIT: `recordExit(depth, subflowId)`.
|
|
13
|
+
* - On leaf ENTRY: `peekPrevSibling(depth)` returns the previous
|
|
14
|
+
* leaf's subflowId at this depth, or undefined for the first leaf.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SequenceSiblingTracker {
|
|
17
|
+
private readonly prevExitedAtDepth;
|
|
18
|
+
/** Returns the subflow id of the most-recently-exited leaf at this
|
|
19
|
+
* depth, or undefined if this is the first leaf entry at the depth. */
|
|
20
|
+
peekPrevSibling(depth: number): string | undefined;
|
|
21
|
+
/** Record that a leaf at this depth just exited. */
|
|
22
|
+
recordExit(depth: number, subflowId: string): void;
|
|
23
|
+
clear(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* localObservability — Tier-3 (Debug) observability: RETAIN a live run model,
|
|
3
|
+
* render it live, and snapshot it for offline replay.
|
|
4
|
+
*
|
|
5
|
+
* One handle, two outputs:
|
|
6
|
+
* - LIVE — `onUpdate(graph)` fires per event; pass the handle to
|
|
7
|
+
* `<Lens recorder={handle} />` and it re-renders as the agent runs.
|
|
8
|
+
* - OFFLINE— `getTrace()` (any time) and `onComplete(trace)` (auto, at run
|
|
9
|
+
* exit) freeze the model into a JSON-lossless `Trace` for `<Replay>`.
|
|
10
|
+
*
|
|
11
|
+
* Contrast with `enable.observability({ strategy })` (Tier-4 / Monitor), which
|
|
12
|
+
* ships each event to a vendor and FORGETS. localObservability KEEPS the model
|
|
13
|
+
* so you can look at it — locally, with full content. See
|
|
14
|
+
* `docs/design/local-observability-and-pii.md`.
|
|
15
|
+
*
|
|
16
|
+
* It's a thin wrapper over `enable.flowchart` (the existing live StepGraph) +
|
|
17
|
+
* `serializeTrace` (the snapshot). UI-free: returns data, never React.
|
|
18
|
+
*/
|
|
19
|
+
import type { CombinedRecorder } from 'footprintjs';
|
|
20
|
+
import type { EventDispatcher } from '../../events/dispatcher.js';
|
|
21
|
+
import type { DomainEvent } from './BoundaryRecorder.js';
|
|
22
|
+
import { type FlowchartHandle, type StepGraph } from './FlowchartRecorder.js';
|
|
23
|
+
import { type SerializeTraceOptions, type Trace } from './trace.js';
|
|
24
|
+
export interface LocalObservabilityOptions {
|
|
25
|
+
/** LIVE recording — called with a fresh StepGraph on every event (drives `<Lens>`). */
|
|
26
|
+
readonly onLive?: (graph: StepGraph) => void;
|
|
27
|
+
/** At run exit — called once with the finalized recording (a Trace, auto-serialized) to replay offline. */
|
|
28
|
+
readonly onRecorded?: (trace: Trace) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Default serialize-time redaction, applied to BOTH `onRecorded` and
|
|
31
|
+
* `getTrace()` (overridable per `getTrace` call). Runs once per event so PII
|
|
32
|
+
* never enters the Trace — see the trust-boundary note in the design doc.
|
|
33
|
+
* Pass `redactContent` for a ready-made redactor.
|
|
34
|
+
*/
|
|
35
|
+
readonly redact?: (event: DomainEvent) => DomainEvent;
|
|
36
|
+
}
|
|
37
|
+
/** A `FlowchartHandle` (live) plus `getTrace()` (offline snapshot). */
|
|
38
|
+
export interface LocalObservabilityHandle extends FlowchartHandle {
|
|
39
|
+
/** Freeze the current model into a JSON-lossless Trace. Safe during or after a run. */
|
|
40
|
+
getTrace(options?: SerializeTraceOptions): Trace;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Attach a local-observability handle. `now` is injectable for tests (the
|
|
44
|
+
* library otherwise stamps `Date.now()` at serialize time).
|
|
45
|
+
*
|
|
46
|
+
* @internal Called from `RunnerBase.enable.localObservability`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function attachLocalObservability(runnerAttach: (recorder: CombinedRecorder) => () => void, dispatcher: EventDispatcher, options?: LocalObservabilityOptions, now?: () => number, getStructure?: () => unknown): LocalObservabilityHandle;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* observeRunId — shared run-boundary detection helper for recorders.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: 5 places in observability/* duplicated the same
|
|
5
|
+
* 10-line pattern (lastRunId field + 3-line check + reset). Extract
|
|
6
|
+
* once so the contract stays consistent under maintenance.
|
|
7
|
+
*
|
|
8
|
+
* The pattern: hold a `lastRunId | undefined`. On every observed event:
|
|
9
|
+
* - If runId is missing/undefined → no-op (defensive, allows callers
|
|
10
|
+
* to pass `event.meta?.runId` without checking).
|
|
11
|
+
* - First observation (lastRunId === undefined) → record, no reset.
|
|
12
|
+
* - Same runId → no-op (steady state).
|
|
13
|
+
* - Different runId → call onNewRun() then record the new id.
|
|
14
|
+
*
|
|
15
|
+
* Returned helper is mutable closure state — callers store it as a
|
|
16
|
+
* private field and call `.observe(runId)` from event hooks.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyRecorder implements ScopeRecorder {
|
|
21
|
+
* private readonly runIdGuard = createRunIdObserver(() => this.reset());
|
|
22
|
+
* onWrite(e) {
|
|
23
|
+
* this.runIdGuard.observe(e.traversalContext?.runId);
|
|
24
|
+
* // ... handle event
|
|
25
|
+
* }
|
|
26
|
+
* private reset() { this.store.clear(); }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface RunIdObserver {
|
|
31
|
+
/** Process an event's runId; fires onNewRun callback when it changes. */
|
|
32
|
+
observe(runId: string | undefined): void;
|
|
33
|
+
/** Clear state so the next observation initializes fresh. */
|
|
34
|
+
reset(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function createRunIdObserver(onNewRun: () => void): RunIdObserver;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking templates — chat-bubble surface (separate from commentary).
|
|
3
|
+
*
|
|
4
|
+
* Audience split:
|
|
5
|
+
* • COMMENTARY (`commentaryTemplates`) — third-person, every moment,
|
|
6
|
+
* shown in Lens panel. Audience:
|
|
7
|
+
* developer / observer.
|
|
8
|
+
* • THINKING (this file) — first-person, mid-call only,
|
|
9
|
+
* shown in chat bubble. Audience:
|
|
10
|
+
* end user chatting with the agent.
|
|
11
|
+
*
|
|
12
|
+
* The thinking surface is a tiny finite state machine driven purely by
|
|
13
|
+
* the event log:
|
|
14
|
+
*
|
|
15
|
+
* ┌──────────┐ llm.start, no tools yet
|
|
16
|
+
* ────┤ idle ├────────────────────────────► "Thinking…"
|
|
17
|
+
* └──────────┘
|
|
18
|
+
*
|
|
19
|
+
* ┌──────────┐ stream.token chunks accumulate
|
|
20
|
+
* ────┤streaming ├────────────────────────────► "{{partial}}"
|
|
21
|
+
* └──────────┘
|
|
22
|
+
*
|
|
23
|
+
* ┌──────────┐ tool.start, no tool.end yet
|
|
24
|
+
* ────┤ tool ├────────────────────────────► "Working on `weather`…"
|
|
25
|
+
* └──────────┘ (or per-tool override)
|
|
26
|
+
*
|
|
27
|
+
* ┌──────────┐ pause.request, no resume yet
|
|
28
|
+
* ────┤ paused ├────────────────────────────► "Waiting on you: …"
|
|
29
|
+
* └──────────┘
|
|
30
|
+
*
|
|
31
|
+
* (null) run done / between calls → bubble hidden
|
|
32
|
+
*
|
|
33
|
+
* The selector returns the CURRENT state by walking the event log;
|
|
34
|
+
* the renderer maps state → final string by looking up the template.
|
|
35
|
+
*
|
|
36
|
+
* Per-tool templates: consumers can ship `tool.<toolName>` keys
|
|
37
|
+
* (e.g. `tool.weather: 'Looking up the weather…'`) which the renderer
|
|
38
|
+
* prefers over the generic `tool` template. Lets each tool have its
|
|
39
|
+
* own first-person status without per-tool plumbing.
|
|
40
|
+
*/
|
|
41
|
+
import type { AgentfootprintEvent } from '../../../events/registry.js';
|
|
42
|
+
/** The four mid-call states a chat bubble might render. */
|
|
43
|
+
export type StatusKind = 'idle' | 'tool' | 'streaming' | 'paused';
|
|
44
|
+
/**
|
|
45
|
+
* What the selector returns. The chat-bubble consumer feeds this into
|
|
46
|
+
* the renderer to get the final string.
|
|
47
|
+
*/
|
|
48
|
+
export interface StatusState {
|
|
49
|
+
readonly state: StatusKind;
|
|
50
|
+
/** Vars for `{{name}}` substitution in the matched template. */
|
|
51
|
+
readonly vars: Readonly<Record<string, string>>;
|
|
52
|
+
/** When `state === 'tool'`, the resolving toolName. The renderer
|
|
53
|
+
* uses this to look up `tool.<toolName>` before the generic `tool`. */
|
|
54
|
+
readonly toolName?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Flat template map. Keys: state kinds + per-tool overrides. */
|
|
57
|
+
export type StatusTemplates = Readonly<Record<string, string>>;
|
|
58
|
+
/** Render context — what the consumer's app config injects. */
|
|
59
|
+
export interface StatusContext {
|
|
60
|
+
/** Active actor's name. Substituted as `{{appName}}` in templates. */
|
|
61
|
+
readonly appName: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Bundled English defaults. Override in the agent config via
|
|
65
|
+
* `.thinkingTemplates({...})`. Per-tool overrides go via
|
|
66
|
+
* `tool.<toolName>` keys.
|
|
67
|
+
*/
|
|
68
|
+
export declare const defaultStatusTemplates: StatusTemplates;
|
|
69
|
+
/**
|
|
70
|
+
* Derive the current thinking state from the event log.
|
|
71
|
+
*
|
|
72
|
+
* Single forward walk that tracks "active" state for each domain:
|
|
73
|
+
* • pause — set on pause.request, cleared on pause.resume
|
|
74
|
+
* • tool — set on tool.start, cleared on matching tool.end
|
|
75
|
+
* (matched by `toolCallId` for parallel-tool safety)
|
|
76
|
+
* • llm — set on llm.start, cleared on llm.end
|
|
77
|
+
*
|
|
78
|
+
* Priority order (highest first):
|
|
79
|
+
*
|
|
80
|
+
* 1. ACTIVE PAUSE wins. When the agent is waiting on the human,
|
|
81
|
+
* that's what the chat should show — not the underlying tool
|
|
82
|
+
* that triggered the pause.
|
|
83
|
+
* 2. ACTIVE TOOL — the LLM said "use a tool" and the tool is
|
|
84
|
+
* running. Show "Working on `<toolName>`…".
|
|
85
|
+
* 3. ACTIVE LLM — call in flight. Show streaming tokens if any
|
|
86
|
+
* arrived, otherwise "Thinking…".
|
|
87
|
+
* 4. Otherwise null (bubble hidden).
|
|
88
|
+
*
|
|
89
|
+
* Pure projection. Forward walk is O(n); a closing event correctly
|
|
90
|
+
* cancels its matching opener so a completed tool.start/tool.end
|
|
91
|
+
* pair leaves the state quiescent.
|
|
92
|
+
*/
|
|
93
|
+
export declare function selectStatus(events: readonly AgentfootprintEvent[]): StatusState | null;
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the matched template + substitute vars.
|
|
96
|
+
*
|
|
97
|
+
* • `state === null` → null (chat bubble renders nothing)
|
|
98
|
+
* • `state === 'tool'` → tries `tool.<toolName>` first, then
|
|
99
|
+
* generic `tool`
|
|
100
|
+
* • Other states → looks up the state's name as the key
|
|
101
|
+
*
|
|
102
|
+
* Missing template keys return null rather than the empty string —
|
|
103
|
+
* keeps the contract honest (consumer can detect "no template" and
|
|
104
|
+
* fall back to its own default).
|
|
105
|
+
*/
|
|
106
|
+
export declare function renderStatusLine(state: StatusState | null, ctx: StatusContext, templates?: StatusTemplates): string | null;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace — a UI-free, JSON-lossless snapshot of a run for OFFLINE REPLAY.
|
|
3
|
+
*
|
|
4
|
+
* `localObservability()` (Tier-3 / Debug) retains a live model during a run.
|
|
5
|
+
* `serializeTrace()` freezes that model into a `Trace` — plain JSON you can
|
|
6
|
+
* persist (file, Redis, a bug report) and later rehydrate WITHOUT re-running
|
|
7
|
+
* the agent. `agentfootprint-lens`'s `<Replay trace={…} />` consumes it and
|
|
8
|
+
* rebuilds the flowchart via the existing translators.
|
|
9
|
+
*
|
|
10
|
+
* A `Trace` stores ONLY the domain-event log (the single source of truth the
|
|
11
|
+
* Lens already reads). The step graph is ALWAYS a derived projection of those
|
|
12
|
+
* events (footprint.js's "graph is derived, never post-processed" principle) —
|
|
13
|
+
* it is rebuilt at render time, never stored. Storing a derived graph would be
|
|
14
|
+
* redundant AND a redaction hazard: a second content surface a per-event
|
|
15
|
+
* `redact` could never reach.
|
|
16
|
+
*
|
|
17
|
+
* PII / trust boundary: the event log carries real content — `llm.end.content`,
|
|
18
|
+
* `tool.start.args`, `tool.end.result`, `context.injected.contentSummary`,
|
|
19
|
+
* `run`/`subflow` `payload`, `decision.branch.rationale`. A live, in-process
|
|
20
|
+
* model is fine, but **serializing is a trust-boundary crossing** (the trace
|
|
21
|
+
* can travel). So redaction is applied HERE, at serialize time, via a
|
|
22
|
+
* consumer `redact` function — PII never enters the `Trace`. `redactContent`
|
|
23
|
+
* is a ready-made redactor covering every content field. The result is
|
|
24
|
+
* self-describing: `trace.redaction`. See
|
|
25
|
+
* `docs/design/local-observability-and-pii.md`.
|
|
26
|
+
*
|
|
27
|
+
* Because `getEvents()` is FLAT (parent + every subflow), one `redact` pass
|
|
28
|
+
* covers the whole tree — no per-subflow inheritance needed here. (The engine's
|
|
29
|
+
* `RedactionPolicy` separately propagates to subflows for the OBSERVER mirror.)
|
|
30
|
+
*/
|
|
31
|
+
import type { DomainEvent } from './BoundaryRecorder.js';
|
|
32
|
+
import { type StepGraph } from './FlowchartRecorder.js';
|
|
33
|
+
/**
|
|
34
|
+
* How a `Trace` was redacted before serialization.
|
|
35
|
+
* - `'none'` — raw content (no `redact`). A `<Replay>` UI may warn.
|
|
36
|
+
* - `'pii'` — a consumer `redact` ran (the default label when one is given).
|
|
37
|
+
* - `'policy'` — produced from a declarative `RedactionPolicy` (future).
|
|
38
|
+
*/
|
|
39
|
+
export type TraceRedaction = 'none' | 'pii' | 'policy';
|
|
40
|
+
/** Cheap headline rollup, so a consumer can show totals without folding `events`. */
|
|
41
|
+
export interface TraceSummary {
|
|
42
|
+
readonly tokens: {
|
|
43
|
+
readonly input: number;
|
|
44
|
+
readonly output: number;
|
|
45
|
+
};
|
|
46
|
+
readonly llmCalls: number;
|
|
47
|
+
readonly toolCalls: number;
|
|
48
|
+
readonly durationMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A JSON-lossless, UI-free snapshot of one run. Persist it, ship it, replay it.
|
|
52
|
+
* `events` ARE the run (the graph is a derived projection, rebuilt at render).
|
|
53
|
+
*/
|
|
54
|
+
export interface Trace {
|
|
55
|
+
/** Schema version. Bump on a breaking shape change. */
|
|
56
|
+
readonly version: 1;
|
|
57
|
+
/** The domain-event log — the whole timeline. Already redacted if `redact` ran. */
|
|
58
|
+
readonly events: readonly DomainEvent[];
|
|
59
|
+
/**
|
|
60
|
+
* The serialized STATIC chart structure (footprint.js `buildTimeStructure`).
|
|
61
|
+
* Design-time data (stage ids/names/types/edges) — UI-free. `<Replay>` rebuilds
|
|
62
|
+
* the flowchart from this and overlays `events`, so an offline replay matches
|
|
63
|
+
* the live `<Lens>` exactly. NOT runtime-redacted (it carries no user data; the
|
|
64
|
+
* `redact` function targets runtime events).
|
|
65
|
+
*/
|
|
66
|
+
readonly structure?: unknown;
|
|
67
|
+
/** Optional headline totals. */
|
|
68
|
+
readonly summary?: TraceSummary;
|
|
69
|
+
/** Self-describing redaction state — travels with the trace. */
|
|
70
|
+
readonly redaction: TraceRedaction;
|
|
71
|
+
/** Wall-clock capture time, stamped by the caller (the engine has no clock here). */
|
|
72
|
+
readonly capturedAtMs?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface SerializeTraceOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Consumer redaction — runs once per domain event at the serialize boundary,
|
|
77
|
+
* so PII never enters the `Trace`. Return a scrubbed COPY (do not mutate the
|
|
78
|
+
* input — the live model still references it). Use `redactContent` for a
|
|
79
|
+
* ready-made redactor. When omitted, content is raw.
|
|
80
|
+
*/
|
|
81
|
+
readonly redact?: (event: DomainEvent) => DomainEvent;
|
|
82
|
+
/** Override the `redaction` label. Defaults to `'pii'` when `redact` is given, else `'none'`. */
|
|
83
|
+
readonly redactionLabel?: TraceRedaction;
|
|
84
|
+
/** The serialized static chart (`getSpec().buildTimeStructure`) — for `<Replay>` to rebuild the flowchart. */
|
|
85
|
+
readonly structure?: unknown;
|
|
86
|
+
/** Optional precomputed headline rollup. */
|
|
87
|
+
readonly summary?: TraceSummary;
|
|
88
|
+
/** Wall-clock capture time. Pass `Date.now()` from the call site. */
|
|
89
|
+
readonly capturedAtMs?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Ready-made redactor: replaces every content-bearing field with a marker,
|
|
93
|
+
* keeping structure/counts for a useful replay. Covers ALL `DomainEvent`
|
|
94
|
+
* content surfaces — pass it to `getTrace({ redact: redactContent })`.
|
|
95
|
+
*
|
|
96
|
+
* Returns a copy only when it changes something, so unaffected events stay
|
|
97
|
+
* referentially identical (cheap) and the caller's live model is never mutated.
|
|
98
|
+
*/
|
|
99
|
+
export declare function redactContent(event: DomainEvent): DomainEvent;
|
|
100
|
+
/**
|
|
101
|
+
* Freeze a live run model into a `Trace`. Pure: pass the `BoundaryRecorder`'s
|
|
102
|
+
* `getEvents()` output.
|
|
103
|
+
*
|
|
104
|
+
* const trace = serializeTrace(handle.boundary.getEvents(), {
|
|
105
|
+
* redact: redactContent, // PII stripped before it enters the trace
|
|
106
|
+
* capturedAtMs: Date.now(),
|
|
107
|
+
* });
|
|
108
|
+
* fs.writeFileSync('run.trace.json', JSON.stringify(trace));
|
|
109
|
+
*/
|
|
110
|
+
export declare function serializeTrace(events: readonly DomainEvent[], options?: SerializeTraceOptions): Trace;
|
|
111
|
+
/**
|
|
112
|
+
* Rebuild the step graph from a `Trace` — the offline half of replay. The graph
|
|
113
|
+
* is ALWAYS a derived projection of `trace.events`; because those events were
|
|
114
|
+
* already redacted at serialize time, the rebuilt graph is clean too (no extra
|
|
115
|
+
* redaction needed — that's exactly why the graph is never stored). UI-free:
|
|
116
|
+
* `agentfootprint-lens`'s `<Replay>` translates this `StepGraph` into its
|
|
117
|
+
* xyflow render model.
|
|
118
|
+
*/
|
|
119
|
+
export declare function traceToStepGraph(trace: Trace): StepGraph;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CircuitBreaker — pure state-machine functions for the Nygard breaker
|
|
3
|
+
* pattern.
|
|
4
|
+
*
|
|
5
|
+
* Refactored from a class-with-instance-state to PURE FUNCTIONS that
|
|
6
|
+
* take a state record and return a new one. Reasons:
|
|
7
|
+
*
|
|
8
|
+
* 1. **No hidden runtime state.** Breaker state lives in scope where
|
|
9
|
+
* it's visible to commitLog, narrative, and rules — the footprintjs
|
|
10
|
+
* "everything in scope" principle. The closure used to be the
|
|
11
|
+
* source of truth and scope held only a projection; now scope IS
|
|
12
|
+
* the source of truth.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Round-trippable across gate invocations.** Because state is a
|
|
15
|
+
* plain record, gate's outputMapper writes it back to agent scope;
|
|
16
|
+
* agent scope persists across the ReAct loop's many LLM-call gate
|
|
17
|
+
* invocations; gate's inputMapper reads it back in for the next
|
|
18
|
+
* call. Per-process persistence comes from the agent scope, not
|
|
19
|
+
* from a closure that hides between runs.
|
|
20
|
+
*
|
|
21
|
+
* 3. **Distributable later.** A future v2.12 `BreakerStateStore`
|
|
22
|
+
* adapter (Redis/DynamoDB) just needs to serialize/deserialize the
|
|
23
|
+
* state record. No class instances to reconstruct.
|
|
24
|
+
*
|
|
25
|
+
* 4. **Testable in isolation.** Pure functions; no instance setup.
|
|
26
|
+
*
|
|
27
|
+
* Pattern: Nygard *Release It!* — three states (CLOSED → OPEN →
|
|
28
|
+
* HALF-OPEN) with cooldown and probe-success thresholds.
|
|
29
|
+
*/
|
|
30
|
+
import type { CircuitBreakerConfig } from './types.js';
|
|
31
|
+
export type CircuitState = 'closed' | 'open' | 'half-open';
|
|
32
|
+
/** Plain serializable record holding one breaker's full state. */
|
|
33
|
+
export interface BreakerState {
|
|
34
|
+
state: CircuitState;
|
|
35
|
+
consecutiveFailures: number;
|
|
36
|
+
consecutiveSuccesses: number;
|
|
37
|
+
openedAt: number;
|
|
38
|
+
lastErrorMessage?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Thrown by `assertAdmit()` when the breaker is OPEN and the cooldown
|
|
42
|
+
* window has not elapsed. The reliability gate stage catches this,
|
|
43
|
+
* classifies via `classifyError` → `'circuit-open'`, and lets the
|
|
44
|
+
* post-decide rules route on it.
|
|
45
|
+
*/
|
|
46
|
+
export declare class CircuitOpenError extends Error {
|
|
47
|
+
readonly code: "ERR_CIRCUIT_OPEN";
|
|
48
|
+
readonly cause: unknown;
|
|
49
|
+
readonly retryAfter: number;
|
|
50
|
+
constructor(providerName: string, lastErrorMessage: string | undefined, retryAfter: number);
|
|
51
|
+
}
|
|
52
|
+
/** Initial state for a freshly-CLOSED breaker. */
|
|
53
|
+
export declare function initialBreakerState(): BreakerState;
|
|
54
|
+
/**
|
|
55
|
+
* Decide whether to admit a call. Returns the (possibly-updated) state
|
|
56
|
+
* AND whether to admit. If OPEN and cooldown elapsed, transitions to
|
|
57
|
+
* HALF-OPEN and admits. Pure: caller must use the returned state.
|
|
58
|
+
*
|
|
59
|
+
* Usage in the gate stage:
|
|
60
|
+
* ```ts
|
|
61
|
+
* const { admitted, nextState } = admitCall(scope.breakerStates[name], config);
|
|
62
|
+
* scope.breakerStates[name] = nextState;
|
|
63
|
+
* if (!admitted) throw new CircuitOpenError(name, nextState.lastErrorMessage, ...);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function admitCall(state: BreakerState, config: CircuitBreakerConfig | undefined): {
|
|
67
|
+
admitted: boolean;
|
|
68
|
+
nextState: BreakerState;
|
|
69
|
+
};
|
|
70
|
+
/** Record a successful call. Returns the (possibly-updated) state. */
|
|
71
|
+
export declare function recordSuccess(state: BreakerState, config: CircuitBreakerConfig | undefined): BreakerState;
|
|
72
|
+
/** Record a failed call. Returns the (possibly-updated) state. */
|
|
73
|
+
export declare function recordFailure(state: BreakerState, err: unknown, config: CircuitBreakerConfig | undefined): BreakerState;
|
|
74
|
+
/** Compute the next probe time given a state + config. */
|
|
75
|
+
export declare function nextProbeTime(state: BreakerState, config: CircuitBreakerConfig | undefined): number;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildReliabilityGateChart — produces a footprintjs FlowChart that wraps
|
|
3
|
+
* an LLM call with rules-based reliability semantics, using the native
|
|
4
|
+
* `decide()` DSL via `addDeciderFunction` decider stages.
|
|
5
|
+
*
|
|
6
|
+
* The returned chart is mounted as a subflow in the agent's chart at
|
|
7
|
+
* Agent.build() time (only when reliability is configured). Inside the
|
|
8
|
+
* subflow:
|
|
9
|
+
*
|
|
10
|
+
* PreCheck (decider) → CallProvider (function) → PostDecide (decider)
|
|
11
|
+
* │
|
|
12
|
+
* ┌───────────────┘
|
|
13
|
+
* ▼ loopTo('pre-check')
|
|
14
|
+
*
|
|
15
|
+
* Branch outcomes (escape via $break() to stop the gate's loop;
|
|
16
|
+
* fall-through via no-$break to trigger loopTo back to PreCheck):
|
|
17
|
+
*
|
|
18
|
+
* PreCheck:
|
|
19
|
+
* 'continue' → no-op → falls through to CallProvider
|
|
20
|
+
* 'fail-fast' → set failKind, $emit, $break(reason)
|
|
21
|
+
*
|
|
22
|
+
* PostDecide:
|
|
23
|
+
* 'ok' → $break() (subflow exits normally; agent continues)
|
|
24
|
+
* 'retry' → bump attempt; falls through to loopTo
|
|
25
|
+
* 'retry-other' → bump providerIdx; falls through to loopTo
|
|
26
|
+
* 'fallback' → call config.fallback(); $break() on success
|
|
27
|
+
* 'fail-fast' → set failKind, $emit, $break(reason)
|
|
28
|
+
*
|
|
29
|
+
* The subflow is mounted WITHOUT `propagateBreak: true`. Subflow $break is
|
|
30
|
+
* local — agent.ts adds a `TranslateFailFast` agent-level stage AFTER the
|
|
31
|
+
* subflow that reads scope.reliabilityFailKind and converts it into an
|
|
32
|
+
* agent-level `$break(reason)`. This split lets normal subflow exits
|
|
33
|
+
* (`ok`/`fallback`) leave the agent running while fail-fast stops it.
|
|
34
|
+
*
|
|
35
|
+
* Three-channel discipline preserved:
|
|
36
|
+
* • SCOPE STATE — failKind/failPayload/failReason mapped to parent via
|
|
37
|
+
* outputMapper; consumed by agent's TranslateFailFast.
|
|
38
|
+
* • $emit — passive observability for external consumers.
|
|
39
|
+
* • $break(reason)— control flow + human reason for narrative.
|
|
40
|
+
*/
|
|
41
|
+
import type { FlowChart } from 'footprintjs';
|
|
42
|
+
import type { ReliabilityConfig } from './types.js';
|
|
43
|
+
/**
|
|
44
|
+
* Build the reliability gate FlowChart from a config. Mount via
|
|
45
|
+
* `addSubFlowChartNext` in the agent's chart — see `Agent.build()`.
|
|
46
|
+
*
|
|
47
|
+
* Closure state captured by stage functions:
|
|
48
|
+
* • `breakers` — Map<providerName, CircuitBreaker>; per-instance state
|
|
49
|
+
* persists across gate invocations within ONE agent process.
|
|
50
|
+
* • `preRules` / `postRules` — frozen rule arrays.
|
|
51
|
+
* • `fallbackFn` — consumer's fallback function, if configured.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildReliabilityGateChart(config: ReliabilityConfig): FlowChart;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* classifyError — pure function mapping a thrown error to one of the
|
|
3
|
+
* coarse `ReliabilityScope.errorKind` categories used by reliability rules.
|
|
4
|
+
*
|
|
5
|
+
* Centralized so rules read structured `errorKind` instead of doing
|
|
6
|
+
* regex on `error.message` themselves. Add new categories ONLY when a
|
|
7
|
+
* new rule needs to discriminate them — keep the taxonomy small.
|
|
8
|
+
*
|
|
9
|
+
* Categories:
|
|
10
|
+
* • 'ok' — no error (caller should pass `undefined` or omit)
|
|
11
|
+
* • 'circuit-open' — `CircuitOpenError` from the breaker layer
|
|
12
|
+
* • 'rate-limit' — HTTP 429 or vendor rate-limit signal
|
|
13
|
+
* • '5xx-transient' — HTTP 5xx, ETIMEDOUT, ECONNRESET, ECONNREFUSED
|
|
14
|
+
* • 'schema-fail' — `OutputSchemaError` from the schema validator
|
|
15
|
+
* • 'unknown' — anything else (default; still routable but
|
|
16
|
+
* consumers usually `'fail-fast'` on this)
|
|
17
|
+
*/
|
|
18
|
+
import type { ReliabilityScope } from './types.js';
|
|
19
|
+
type ErrorKind = ReliabilityScope['errorKind'];
|
|
20
|
+
/**
|
|
21
|
+
* Classify an error into a `ReliabilityScope['errorKind']` category.
|
|
22
|
+
*
|
|
23
|
+
* @param err - The thrown value. May be an Error, a vendor SDK error
|
|
24
|
+
* shape with `.status`/`.code`, or anything else (`unknown` defaults).
|
|
25
|
+
* @returns the matching coarse category string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function classifyError(err: unknown): ErrorKind;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reliability — public surface for the v2.11.1 rules-based reliability
|
|
3
|
+
* subsystem. Internal-only helpers (CircuitBreaker class, classifyError,
|
|
4
|
+
* buildReliabilityGate) live in their own files; this barrel exports
|
|
5
|
+
* the consumer-facing types and the typed error.
|
|
6
|
+
*
|
|
7
|
+
* Consumer use:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Agent } from 'agentfootprint';
|
|
10
|
+
* import type { ReliabilityRule, ReliabilityScope } from 'agentfootprint/reliability';
|
|
11
|
+
* import { ReliabilityFailFastError } from 'agentfootprint/reliability';
|
|
12
|
+
*
|
|
13
|
+
* const agent = Agent.create({...}).reliability({
|
|
14
|
+
* postDecide: [
|
|
15
|
+
* { when: (s) => s.errorKind === '5xx-transient' && s.attempt < 3,
|
|
16
|
+
* then: 'retry', kind: 'transient-retry' },
|
|
17
|
+
* { when: (s) => s.error !== undefined,
|
|
18
|
+
* then: 'fail-fast', kind: 'unrecoverable' },
|
|
19
|
+
* ],
|
|
20
|
+
* }).build();
|
|
21
|
+
*
|
|
22
|
+
* try {
|
|
23
|
+
* await agent.run({ message: '...' });
|
|
24
|
+
* } catch (e) {
|
|
25
|
+
* if (e instanceof ReliabilityFailFastError) {
|
|
26
|
+
* console.log(e.kind, e.reason);
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export type { CircuitBreakerConfig, ReliabilityConfig, ReliabilityDecision, ReliabilityFallbackFn, ReliabilityProvider, ReliabilityRule, ReliabilityScope, } from './types.js';
|
|
32
|
+
export { ReliabilityFailFastError } from './types.js';
|
|
33
|
+
export { CircuitOpenError, initialBreakerState, type BreakerState, type CircuitState, } from './CircuitBreaker.js';
|
|
34
|
+
export { ValidationFailure, lastNValidationErrorsMatch, defaultStuckLoopRule, } from '../core/agent/stages/reliabilityExecution.js';
|
|
35
|
+
export type { OutputSchemaValidator } from '../core/agent/stages/reliabilityExecution.js';
|