agentfootprint 6.43.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/RunnerBase.js +7 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/RunnerBase.js +7 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/observe.js +7 -1
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
- package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/localObservability.js +54 -0
- package/dist/esm/recorders/observability/localObservability.js.map +1 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/recorders/observability/trace.js +99 -0
- package/dist/esm/recorders/observability/trace.js.map +1 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/observe.js +14 -3
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/FlowchartRecorder.js +12 -3
- package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/recorders/observability/localObservability.js +58 -0
- package/dist/recorders/observability/localObservability.js.map +1 -0
- package/dist/recorders/observability/trace.js +105 -0
- package/dist/recorders/observability/trace.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/runner.d.ts +12 -0
- package/dist/types/core/runner.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/dist/types/observe.d.ts +3 -1
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/localObservability.d.ts +49 -0
- package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
- package/dist/types/recorders/observability/trace.d.ts +120 -0
- package/dist/types/recorders/observability/trace.d.ts.map +1 -0
- package/package.json +203 -56
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commentary templates — bundled English prose for narrating an
|
|
3
|
+
* agentfootprint run, plus the small engine that picks the right
|
|
4
|
+
* template per event and substitutes payload values.
|
|
5
|
+
*
|
|
6
|
+
* Audience split (load-bearing):
|
|
7
|
+
* • COMMENTARY — pure prose for the bottom panel of any viewer
|
|
8
|
+
* (Lens, CLI tail, log file). NO technical numbers,
|
|
9
|
+
* NO field dumps, NO library terms.
|
|
10
|
+
* • DETAILS — token counts, durations, args, IDs. The right
|
|
11
|
+
* panel / DevTools / structured-log territory.
|
|
12
|
+
*
|
|
13
|
+
* Architecture (3 pieces):
|
|
14
|
+
* 1. `defaultCommentaryTemplates` — flat `key → string` map.
|
|
15
|
+
* i18n-ready: ship a Spanish/Japanese/etc. version with the same
|
|
16
|
+
* keys, pass via `commentaryTemplates` on the renderer.
|
|
17
|
+
* 2. `selectCommentaryKey(event)` — per-event-type routing fn.
|
|
18
|
+
* Returns `string` (render this key), `null` (skip — too
|
|
19
|
+
* low-signal for prose), or `undefined` (fall through to a
|
|
20
|
+
* caller-supplied default humanizer).
|
|
21
|
+
* 3. `extractCommentaryVars(event, ctx)` — builds the
|
|
22
|
+
* `{ appName, userPrompt, toolName, descClause, ... }` bag the
|
|
23
|
+
* template will be rendered with.
|
|
24
|
+
*
|
|
25
|
+
* Plus a tiny non-recursive `renderCommentary(template, vars)`.
|
|
26
|
+
*
|
|
27
|
+
* Why this lives in agentfootprint (not Lens):
|
|
28
|
+
* The keys ARE agentfootprint event types. The prose teaches
|
|
29
|
+
* agentfootprint concepts (slot composition, ReAct, tool-calling).
|
|
30
|
+
* Consumers building agentfootprint Agents ship their voice / locale
|
|
31
|
+
* alongside their system prompt and tool registry. Lens (or any
|
|
32
|
+
* other viewer) is just a renderer that consumes this surface.
|
|
33
|
+
*
|
|
34
|
+
* Verb discipline (encoded in the prose):
|
|
35
|
+
* • `{{appName}}` (active actor) — called, dispatched, returned,
|
|
36
|
+
* decided, read, built
|
|
37
|
+
* • LLM (passive actor) — suggested, responded, produced,
|
|
38
|
+
* asked for, gave
|
|
39
|
+
* The split reflects the architectural truth: LLMs don't act, the
|
|
40
|
+
* orchestrating system does.
|
|
41
|
+
*/
|
|
42
|
+
import type { AgentfootprintEvent } from '../../../events/registry.js';
|
|
43
|
+
/** Flat map of template keys to template strings. Keys use a dotted
|
|
44
|
+
* hierarchy mirroring event types + payload branches
|
|
45
|
+
* (`'stream.llm_start.iter1'`, `'context.injected.rag'`). Values may
|
|
46
|
+
* contain `{{name}}` placeholders that `renderCommentary` substitutes. */
|
|
47
|
+
export type CommentaryTemplates = Readonly<Record<string, string>>;
|
|
48
|
+
/**
|
|
49
|
+
* The bundled English templates. Override per-key via the renderer's
|
|
50
|
+
* `templates` option — partial overrides are spread on top of these
|
|
51
|
+
* defaults so consumers only ship what they want to change.
|
|
52
|
+
*/
|
|
53
|
+
export declare const defaultCommentaryTemplates: CommentaryTemplates;
|
|
54
|
+
/** Context the var-extractor reads from. Anything that's NOT in the
|
|
55
|
+
* event payload (consumer-supplied appName, tool registry lookup) goes
|
|
56
|
+
* here. Pure data — no closures, no I/O. */
|
|
57
|
+
export interface CommentaryContext {
|
|
58
|
+
/** The system that orchestrates the LLM. Substituted as the active
|
|
59
|
+
* actor in every line ("Acme called the LLM"). Default: `'Chatbot'`. */
|
|
60
|
+
readonly appName: string;
|
|
61
|
+
/** Resolves a tool name to its registered description ("Get current
|
|
62
|
+
* weather for a city"). Used to compose the optional `descClause`
|
|
63
|
+
* for `stream.tool_start`. Sync — Lens-style consumers precompute
|
|
64
|
+
* the lookup map from `context.injected source='registry'` events. */
|
|
65
|
+
readonly getToolDescription?: (toolName: string) => string | undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Pick the template key for an event. Branches encoded in the key
|
|
69
|
+
* suffix (no conditional logic in the templates themselves).
|
|
70
|
+
*
|
|
71
|
+
* `null` → explicit skip (baseline injections, low-signal events)
|
|
72
|
+
* `undefined` → fall through to caller's default humanizer
|
|
73
|
+
* `string` → render `templates[key]` with `extractCommentaryVars`
|
|
74
|
+
*/
|
|
75
|
+
export declare function selectCommentaryKey(event: AgentfootprintEvent): string | null | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Build the variable bag for a given event. Flat `name → string` map;
|
|
78
|
+
* `renderCommentary` substitutes by name. Templates use whatever names
|
|
79
|
+
* this function produces.
|
|
80
|
+
*
|
|
81
|
+
* Two-step composition for `stream.tool_start`: the optional
|
|
82
|
+
* `descClause` is a rendered sub-template. We pre-render it here so
|
|
83
|
+
* the outer template stays a single non-recursive substitution pass.
|
|
84
|
+
*/
|
|
85
|
+
export declare function extractCommentaryVars(event: AgentfootprintEvent, ctx: CommentaryContext, templates?: CommentaryTemplates): Record<string, string>;
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the agent name from an event's `meta.subflowPath`.
|
|
88
|
+
*
|
|
89
|
+
* Walks the path right-to-left, skipping library-internal segments
|
|
90
|
+
* (slot subflows, agent-routing subflows, thinking handlers), and
|
|
91
|
+
* returns the FIRST meaningful segment with the optional `step-`
|
|
92
|
+
* Sequence prefix stripped. For events with no meaningful path
|
|
93
|
+
* (single-Agent runners, top-level events), falls back to `appName`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function extractAgentName(event: AgentfootprintEvent, ctx: CommentaryContext): string;
|
|
96
|
+
/**
|
|
97
|
+
* Render a template by substituting `{{name}}` placeholders from the
|
|
98
|
+
* vars bag. Missing keys render as empty string — keeps prose
|
|
99
|
+
* forgiving when an optional field isn't present.
|
|
100
|
+
*
|
|
101
|
+
* Non-recursive: a substituted value is NOT itself processed for
|
|
102
|
+
* placeholders. Compose sub-templates upstream (see
|
|
103
|
+
* `extractCommentaryVars`).
|
|
104
|
+
*/
|
|
105
|
+
export declare function renderCommentary(template: string, vars: Record<string, string>): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal — not part of the public agentfootprint API. Imported only
|
|
3
|
+
* by RunStepRecorder. Subject to change without notice.
|
|
4
|
+
*
|
|
5
|
+
* ActorArrowClassifier — classifies the next `llm.start` as
|
|
6
|
+
* `'user→llm'` (no pending tool result) vs `'tool→llm'` (after a
|
|
7
|
+
* tool result), and the next `llm.end` as `'llm→tool'` vs `'llm→user'`
|
|
8
|
+
* based on the call's `toolCallCount`.
|
|
9
|
+
*
|
|
10
|
+
* Extracted from RunStepRecorder per Convention 1. Keeps a single
|
|
11
|
+
* boolean of state — `prevLLMEndHadTools` — and consumes-then-resets
|
|
12
|
+
* it on each `llm.start`.
|
|
13
|
+
*/
|
|
14
|
+
export type StartArrow = 'user→llm' | 'tool→llm';
|
|
15
|
+
export type EndArrow = 'llm→tool' | 'llm→user';
|
|
16
|
+
export declare class ActorArrowClassifier {
|
|
17
|
+
private prevLLMEndHadTools;
|
|
18
|
+
/** Classify the next `llm.start`. Consumes + resets the pending
|
|
19
|
+
* flag after returning. */
|
|
20
|
+
classifyStart(): StartArrow;
|
|
21
|
+
/** Classify an `llm.end` based on its tool-call count, and update
|
|
22
|
+
* the pending flag for the NEXT llm.start. */
|
|
23
|
+
classifyEnd(toolCallCount: number): EndArrow;
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal — not part of the public agentfootprint API. Imported only
|
|
3
|
+
* by RunStepRecorder. Subject to change without notice.
|
|
4
|
+
*
|
|
5
|
+
* CandidateAnswerBuffer — buffers a "this leaf MIGHT be the run's
|
|
6
|
+
* answer" candidate that's only confirmed on `onRunEnd`. Replaced
|
|
7
|
+
* by every later leaf exit at run scope; the last one wins.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from RunStepRecorder per Convention 1.
|
|
10
|
+
*
|
|
11
|
+
* Use:
|
|
12
|
+
* - On leaf EXIT at run scope: `set(frame, ts, runtimeStageId)`.
|
|
13
|
+
* - On `onRunEnd`: `flush()` returns the buffered candidate (or
|
|
14
|
+
* undefined if none), and clears the buffer.
|
|
15
|
+
*/
|
|
16
|
+
export interface CandidateAnswer<TFrame> {
|
|
17
|
+
readonly frame: TFrame;
|
|
18
|
+
readonly tsMs: number;
|
|
19
|
+
readonly runtimeStageId: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class CandidateAnswerBuffer<TFrame> {
|
|
22
|
+
private candidate;
|
|
23
|
+
/** Buffer a new candidate, replacing any prior one. */
|
|
24
|
+
set(frame: TFrame, tsMs: number, runtimeStageId: string): void;
|
|
25
|
+
/** Return + clear the buffered candidate (or undefined if empty). */
|
|
26
|
+
flush(): CandidateAnswer<TFrame> | undefined;
|
|
27
|
+
clear(): void;
|
|
28
|
+
}
|
|
@@ -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,54 @@
|
|
|
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 { attachFlowchart } from './FlowchartRecorder.js';
|
|
20
|
+
import { serializeTrace } from './trace.js';
|
|
21
|
+
/**
|
|
22
|
+
* Attach a local-observability handle. `now` is injectable for tests (the
|
|
23
|
+
* library otherwise stamps `Date.now()` at serialize time).
|
|
24
|
+
*
|
|
25
|
+
* @internal Called from `RunnerBase.enable.localObservability`.
|
|
26
|
+
*/
|
|
27
|
+
export function attachLocalObservability(runnerAttach, dispatcher, options = {}, now = Date.now, getStructure) {
|
|
28
|
+
let completed = false;
|
|
29
|
+
// `let` (not const): `handle` is referenced by `buildTrace` and the onUpdate
|
|
30
|
+
// closure below, both defined before its assignment. The closures only run
|
|
31
|
+
// after `attachFlowchart` returns, so `handle` is always set by call time.
|
|
32
|
+
// eslint-disable-next-line prefer-const
|
|
33
|
+
let handle;
|
|
34
|
+
const buildTrace = (override) => serializeTrace(handle.boundary.getEvents(), {
|
|
35
|
+
capturedAtMs: now(),
|
|
36
|
+
...(getStructure && { structure: getStructure() }),
|
|
37
|
+
...(options.redact && { redact: options.redact }),
|
|
38
|
+
...override,
|
|
39
|
+
});
|
|
40
|
+
handle = attachFlowchart(runnerAttach, dispatcher, {
|
|
41
|
+
onUpdate: (graph) => {
|
|
42
|
+
options.onLive?.(graph);
|
|
43
|
+
// Fire onRecorded once, when the root run boundary closes.
|
|
44
|
+
if (options.onRecorded &&
|
|
45
|
+
!completed &&
|
|
46
|
+
handle.boundary.getEvents().some((e) => e.type === 'run.exit')) {
|
|
47
|
+
completed = true;
|
|
48
|
+
options.onRecorded(buildTrace());
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return { ...handle, getTrace: buildTrace };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=localObservability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localObservability.js","sourceRoot":"","sources":["../../../../src/recorders/observability/localObservability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,eAAe,EAAwC,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAA0C,MAAM,YAAY,CAAC;AAsBpF;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,YAAwD,EACxD,UAA2B,EAC3B,UAAqC,EAAE,EACvC,MAAoB,IAAI,CAAC,GAAG,EAC5B,YAA4B;IAE5B,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,6EAA6E;IAC7E,2EAA2E;IAC3E,2EAA2E;IAC3E,wCAAwC;IACxC,IAAI,MAAuB,CAAC;IAE5B,MAAM,UAAU,GAAG,CAAC,QAAgC,EAAS,EAAE,CAC7D,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QAC1C,YAAY,EAAE,GAAG,EAAE;QACnB,GAAG,CAAC,YAAY,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;QACjD,GAAG,QAAQ;KACZ,CAAC,CAAC;IAEL,MAAM,GAAG,eAAe,CAAC,YAAY,EAAE,UAAU,EAAE;QACjD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;YACxB,2DAA2D;YAC3D,IACE,OAAO,CAAC,UAAU;gBAClB,CAAC,SAAS;gBACV,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,EAC9D,CAAC;gBACD,SAAS,GAAG,IAAI,CAAC;gBACjB,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -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;
|