agentfootprint 18.0.0 → 18.1.1
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/CAPABILITIES.md +2 -1
- package/dist/adapters/llm/BedrockProvider/client.js +93 -0
- package/dist/adapters/llm/BedrockProvider/client.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardedStream.js +150 -0
- package/dist/adapters/llm/BedrockProvider/guardedStream.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardedStreamBuffer.js +109 -0
- package/dist/adapters/llm/BedrockProvider/guardedStreamBuffer.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardrailClassify.js +189 -0
- package/dist/adapters/llm/BedrockProvider/guardrailClassify.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardrailConfig.js +79 -0
- package/dist/adapters/llm/BedrockProvider/guardrailConfig.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardrailRead.js +101 -0
- package/dist/adapters/llm/BedrockProvider/guardrailRead.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardrailResponse.js +81 -0
- package/dist/adapters/llm/BedrockProvider/guardrailResponse.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/guardrailSchemas.js +95 -0
- package/dist/adapters/llm/BedrockProvider/guardrailSchemas.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/request.js +119 -0
- package/dist/adapters/llm/BedrockProvider/request.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/response.js +107 -0
- package/dist/adapters/llm/BedrockProvider/response.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/stream.js +109 -0
- package/dist/adapters/llm/BedrockProvider/stream.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider/types.js +3 -0
- package/dist/adapters/llm/BedrockProvider/types.js.map +1 -0
- package/dist/adapters/llm/BedrockProvider.js +48 -381
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/MockProvider.js +1 -0
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/ag-ui/serializer/settle.js +110 -0
- package/dist/ag-ui/serializer/settle.js.map +1 -0
- package/dist/ag-ui/serializer/translate.js +310 -0
- package/dist/ag-ui/serializer/translate.js.map +1 -0
- package/dist/ag-ui/serializer/types.js +3 -0
- package/dist/ag-ui/serializer/types.js.map +1 -0
- package/dist/ag-ui/serializer/values.js +72 -0
- package/dist/ag-ui/serializer/values.js.map +1 -0
- package/dist/ag-ui/serializer.js +110 -543
- package/dist/ag-ui/serializer.js.map +1 -1
- package/dist/core/LLMCall/chart.js +294 -0
- package/dist/core/LLMCall/chart.js.map +1 -0
- package/dist/core/LLMCall.js +30 -314
- package/dist/core/LLMCall.js.map +1 -1
- package/dist/core/agent/buildAgentMessageApiChart.js +10 -5
- package/dist/core/agent/buildAgentMessageApiChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart/boundary.js +148 -0
- package/dist/core/agent/buildDynamicAgentChart/boundary.js.map +1 -0
- package/dist/core/agent/buildDynamicAgentChart/engineBoundary.js +122 -0
- package/dist/core/agent/buildDynamicAgentChart/engineBoundary.js.map +1 -0
- package/dist/core/agent/buildDynamicAgentChart/finalBranch.js +26 -0
- package/dist/core/agent/buildDynamicAgentChart/finalBranch.js.map +1 -0
- package/dist/core/agent/buildDynamicAgentChart.js +14 -263
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/buildMessageApiChart.js +11 -6
- package/dist/core/agent/buildMessageApiChart.js.map +1 -1
- package/dist/core/agent/composeRequest.js +1 -1
- package/dist/core/agent/dynamicTurnSeed.js +2 -0
- package/dist/core/agent/dynamicTurnSeed.js.map +1 -1
- package/dist/core/agent/findings/answerText.js +1 -1
- package/dist/core/agent/receipt/receipt.js +2 -2
- package/dist/core/agent/runtime/admission/owner.js +1 -1
- package/dist/core/agent/runtime/admission/owner.js.map +1 -1
- package/dist/core/agent/runtime/terminal/verdicts.js +4 -0
- package/dist/core/agent/runtime/terminal/verdicts.js.map +1 -1
- package/dist/core/agent/stagedRefs.js +1 -1
- package/dist/core/agent/stagedRefs.js.map +1 -1
- package/dist/core/agent/stages/callLLM/acceptResponse.js +226 -0
- package/dist/core/agent/stages/callLLM/acceptResponse.js.map +1 -0
- package/dist/core/agent/stages/callLLM/executeCall.js +254 -0
- package/dist/core/agent/stages/callLLM/executeCall.js.map +1 -0
- package/dist/core/agent/stages/callLLM/prepareCall.js +467 -0
- package/dist/core/agent/stages/callLLM/prepareCall.js.map +1 -0
- package/dist/core/agent/stages/callLLM/responseAccounting.js +34 -0
- package/dist/core/agent/stages/callLLM/responseAccounting.js.map +1 -0
- package/dist/core/agent/stages/callLLM.js +34 -852
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/reliabilityExecution/contracts.js +28 -0
- package/dist/core/agent/stages/reliabilityExecution/contracts.js.map +1 -0
- package/dist/core/agent/stages/reliabilityExecution/feedback.js +40 -0
- package/dist/core/agent/stages/reliabilityExecution/feedback.js.map +1 -0
- package/dist/core/agent/stages/reliabilityExecution/stuckLoop.js +48 -0
- package/dist/core/agent/stages/reliabilityExecution/stuckLoop.js.map +1 -0
- package/dist/core/agent/stages/reliabilityExecution.js +18 -156
- package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
- package/dist/core/agent/toolChoice/record.js +1 -1
- package/dist/core/agent/window/toolNames.js +1 -1
- package/dist/core/providerIntervention.js +115 -0
- package/dist/core/providerIntervention.js.map +1 -0
- package/dist/core/slots/buildMessagesSlot.js +1 -1
- package/dist/core/terminalVerdict.js +3 -0
- package/dist/core/terminalVerdict.js.map +1 -1
- package/dist/core-flow/Graph.js +1 -1
- package/dist/core-flow/Parallel/builder.js +101 -0
- package/dist/core-flow/Parallel/builder.js.map +1 -0
- package/dist/core-flow/Parallel/chart.js +221 -0
- package/dist/core-flow/Parallel/chart.js.map +1 -0
- package/dist/core-flow/Parallel/mapper.js +41 -0
- package/dist/core-flow/Parallel/mapper.js.map +1 -0
- package/dist/core-flow/Parallel/merge.js +63 -0
- package/dist/core-flow/Parallel/merge.js.map +1 -0
- package/dist/core-flow/Parallel/types.js +3 -0
- package/dist/core-flow/Parallel/types.js.map +1 -0
- package/dist/core-flow/Parallel.js +19 -395
- package/dist/core-flow/Parallel.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider/client.d.ts +11 -0
- package/dist/esm/adapters/llm/BedrockProvider/client.js +87 -0
- package/dist/esm/adapters/llm/BedrockProvider/client.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStream.d.ts +7 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStream.js +145 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStream.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStreamBuffer.d.ts +21 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStreamBuffer.js +105 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardedStreamBuffer.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailClassify.d.ts +8 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailClassify.js +183 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailClassify.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailConfig.d.ts +30 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailConfig.js +74 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailConfig.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailRead.d.ts +19 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailRead.js +96 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailRead.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailResponse.d.ts +13 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailResponse.js +74 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailResponse.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailSchemas.d.ts +13 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailSchemas.js +92 -0
- package/dist/esm/adapters/llm/BedrockProvider/guardrailSchemas.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/request.d.ts +4 -0
- package/dist/esm/adapters/llm/BedrockProvider/request.js +115 -0
- package/dist/esm/adapters/llm/BedrockProvider/request.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/response.d.ts +32 -0
- package/dist/esm/adapters/llm/BedrockProvider/response.js +100 -0
- package/dist/esm/adapters/llm/BedrockProvider/response.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/stream.d.ts +4 -0
- package/dist/esm/adapters/llm/BedrockProvider/stream.js +105 -0
- package/dist/esm/adapters/llm/BedrockProvider/stream.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider/types.d.ts +174 -0
- package/dist/esm/adapters/llm/BedrockProvider/types.js +2 -0
- package/dist/esm/adapters/llm/BedrockProvider/types.js.map +1 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +5 -148
- package/dist/esm/adapters/llm/BedrockProvider.js +44 -377
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/MockProvider.js +1 -0
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/ag-ui/serializer/settle.d.ts +28 -0
- package/dist/esm/ag-ui/serializer/settle.js +106 -0
- package/dist/esm/ag-ui/serializer/settle.js.map +1 -0
- package/dist/esm/ag-ui/serializer/translate.d.ts +39 -0
- package/dist/esm/ag-ui/serializer/translate.js +306 -0
- package/dist/esm/ag-ui/serializer/translate.js.map +1 -0
- package/dist/esm/ag-ui/serializer/types.d.ts +66 -0
- package/dist/esm/ag-ui/serializer/types.js +2 -0
- package/dist/esm/ag-ui/serializer/types.js.map +1 -0
- package/dist/esm/ag-ui/serializer/values.d.ts +39 -0
- package/dist/esm/ag-ui/serializer/values.js +59 -0
- package/dist/esm/ag-ui/serializer/values.js.map +1 -0
- package/dist/esm/ag-ui/serializer.d.ts +3 -146
- package/dist/esm/ag-ui/serializer.js +85 -522
- package/dist/esm/ag-ui/serializer.js.map +1 -1
- package/dist/esm/core/LLMCall/chart.d.ts +21 -0
- package/dist/esm/core/LLMCall/chart.js +290 -0
- package/dist/esm/core/LLMCall/chart.js.map +1 -0
- package/dist/esm/core/LLMCall.d.ts +3 -0
- package/dist/esm/core/LLMCall.js +31 -315
- package/dist/esm/core/LLMCall.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.js +10 -5
- package/dist/esm/core/agent/buildAgentMessageApiChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart/boundary.d.ts +100 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/boundary.js +144 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/boundary.js.map +1 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/engineBoundary.d.ts +51 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/engineBoundary.js +118 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/engineBoundary.js.map +1 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/finalBranch.d.ts +3 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/finalBranch.js +22 -0
- package/dist/esm/core/agent/buildDynamicAgentChart/finalBranch.js.map +1 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +0 -50
- package/dist/esm/core/agent/buildDynamicAgentChart.js +14 -263
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.js +11 -6
- package/dist/esm/core/agent/buildMessageApiChart.js.map +1 -1
- package/dist/esm/core/agent/composeRequest.d.ts +1 -1
- package/dist/esm/core/agent/composeRequest.js +1 -1
- package/dist/esm/core/agent/dynamicTurnSeed.js +2 -0
- package/dist/esm/core/agent/dynamicTurnSeed.js.map +1 -1
- package/dist/esm/core/agent/findings/answerText.d.ts +1 -1
- package/dist/esm/core/agent/findings/answerText.js +1 -1
- package/dist/esm/core/agent/receipt/receipt.d.ts +2 -2
- package/dist/esm/core/agent/receipt/receipt.js +2 -2
- package/dist/esm/core/agent/runtime/admission/owner.js +1 -1
- package/dist/esm/core/agent/runtime/admission/owner.js.map +1 -1
- package/dist/esm/core/agent/runtime/terminal/verdicts.js +4 -0
- package/dist/esm/core/agent/runtime/terminal/verdicts.js.map +1 -1
- package/dist/esm/core/agent/stagedRefs.js +1 -1
- package/dist/esm/core/agent/stagedRefs.js.map +1 -1
- package/dist/esm/core/agent/stages/callLLM/acceptResponse.d.ts +6 -0
- package/dist/esm/core/agent/stages/callLLM/acceptResponse.js +199 -0
- package/dist/esm/core/agent/stages/callLLM/acceptResponse.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM/executeCall.d.ts +26 -0
- package/dist/esm/core/agent/stages/callLLM/executeCall.js +250 -0
- package/dist/esm/core/agent/stages/callLLM/executeCall.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM/prepareCall.d.ts +88 -0
- package/dist/esm/core/agent/stages/callLLM/prepareCall.js +440 -0
- package/dist/esm/core/agent/stages/callLLM/prepareCall.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM/responseAccounting.d.ts +10 -0
- package/dist/esm/core/agent/stages/callLLM/responseAccounting.js +29 -0
- package/dist/esm/core/agent/stages/callLLM/responseAccounting.js.map +1 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +1 -1
- package/dist/esm/core/agent/stages/callLLM.js +34 -829
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/reliabilityExecution/contracts.d.ts +53 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/contracts.js +24 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/contracts.js.map +1 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/feedback.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/feedback.js +36 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/feedback.js.map +1 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/stuckLoop.d.ts +29 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/stuckLoop.js +44 -0
- package/dist/esm/core/agent/stages/reliabilityExecution/stuckLoop.js.map +1 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +4 -81
- package/dist/esm/core/agent/stages/reliabilityExecution.js +7 -147
- package/dist/esm/core/agent/stages/reliabilityExecution.js.map +1 -1
- package/dist/esm/core/agent/toolChoice/record.d.ts +1 -1
- package/dist/esm/core/agent/toolChoice/record.js +1 -1
- package/dist/esm/core/agent/window/toolNames.d.ts +1 -1
- package/dist/esm/core/agent/window/toolNames.js +1 -1
- package/dist/esm/core/providerIntervention.d.ts +25 -0
- package/dist/esm/core/providerIntervention.js +106 -0
- package/dist/esm/core/providerIntervention.js.map +1 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +1 -1
- package/dist/esm/core/slots/buildMessagesSlot.js +1 -1
- package/dist/esm/core/terminalVerdict.d.ts +4 -0
- package/dist/esm/core/terminalVerdict.js +3 -0
- package/dist/esm/core/terminalVerdict.js.map +1 -1
- package/dist/esm/core-flow/Graph.d.ts +1 -1
- package/dist/esm/core-flow/Graph.js +1 -1
- package/dist/esm/core-flow/Parallel/builder.d.ts +39 -0
- package/dist/esm/core-flow/Parallel/builder.js +97 -0
- package/dist/esm/core-flow/Parallel/builder.js.map +1 -0
- package/dist/esm/core-flow/Parallel/chart.d.ts +15 -0
- package/dist/esm/core-flow/Parallel/chart.js +217 -0
- package/dist/esm/core-flow/Parallel/chart.js.map +1 -0
- package/dist/esm/core-flow/Parallel/mapper.d.ts +21 -0
- package/dist/esm/core-flow/Parallel/mapper.js +37 -0
- package/dist/esm/core-flow/Parallel/mapper.js.map +1 -0
- package/dist/esm/core-flow/Parallel/merge.d.ts +4 -0
- package/dist/esm/core-flow/Parallel/merge.js +58 -0
- package/dist/esm/core-flow/Parallel/merge.js.map +1 -0
- package/dist/esm/core-flow/Parallel/types.d.ts +179 -0
- package/dist/esm/core-flow/Parallel/types.js +2 -0
- package/dist/esm/core-flow/Parallel/types.js.map +1 -0
- package/dist/esm/core-flow/Parallel.d.ts +7 -233
- package/dist/esm/core-flow/Parallel.js +18 -394
- package/dist/esm/core-flow/Parallel.js.map +1 -1
- package/dist/esm/hosting/failedSettlement.d.ts +9 -0
- package/dist/esm/hosting/failedSettlement.js +15 -0
- package/dist/esm/hosting/failedSettlement.js.map +1 -0
- package/dist/esm/hosting/headers.d.ts +8 -0
- package/dist/esm/hosting/headers.js +18 -0
- package/dist/esm/hosting/headers.js.map +1 -1
- package/dist/esm/hosting/httpHost.js +5 -20
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/httpStreaming.d.ts +5 -2
- package/dist/esm/hosting/protocolRoute.js +9 -2
- package/dist/esm/hosting/protocolRoute.js.map +1 -1
- package/dist/esm/hosting/refusalStatus.d.ts +3 -0
- package/dist/esm/hosting/refusalStatus.js +5 -0
- package/dist/esm/hosting/refusalStatus.js.map +1 -1
- package/dist/esm/hosting/streamHandler/conversation.d.ts +17 -0
- package/dist/esm/hosting/streamHandler/conversation.js +32 -0
- package/dist/esm/hosting/streamHandler/conversation.js.map +1 -0
- package/dist/esm/hosting/streamHandler/request.d.ts +12 -0
- package/dist/esm/hosting/streamHandler/request.js +84 -0
- package/dist/esm/hosting/streamHandler/request.js.map +1 -0
- package/dist/esm/hosting/streamHandler/types.d.ts +106 -0
- package/dist/esm/hosting/streamHandler/types.js +5 -0
- package/dist/esm/hosting/streamHandler/types.js.map +1 -0
- package/dist/esm/hosting/streamHandler.d.ts +3 -133
- package/dist/esm/hosting/streamHandler.js +10 -119
- package/dist/esm/hosting/streamHandler.js.map +1 -1
- package/dist/esm/hosting/unstreamedText.d.ts +1 -1
- package/dist/esm/hosting/unstreamedText.js +1 -1
- package/dist/esm/lib/iterationBudget.js +1 -1
- package/dist/esm/lib/iterationBudget.js.map +1 -1
- package/dist/esm/lib/toolBytes.d.ts +1 -1
- package/dist/esm/lib/toolBytes.js +2 -2
- package/dist/esm/lib/toolBytes.js.map +1 -1
- package/dist/esm/ontology/serve.d.ts +2 -2
- package/dist/esm/ontology/serve.js +2 -2
- package/dist/esm/provider-contract/intervention.d.ts +56 -0
- package/dist/esm/provider-contract/intervention.js +112 -0
- package/dist/esm/provider-contract/intervention.js.map +1 -0
- package/dist/esm/provider-contract/replaySafety.d.ts +4 -0
- package/dist/esm/provider-contract/replaySafety.js +25 -0
- package/dist/esm/provider-contract/replaySafety.js.map +1 -0
- package/dist/esm/provider-contract/requestRefusal.js +3 -1
- package/dist/esm/provider-contract/requestRefusal.js.map +1 -1
- package/dist/esm/provider-contract/responseAdmission.d.ts +10 -0
- package/dist/esm/provider-contract/responseAdmission.js +91 -0
- package/dist/esm/provider-contract/responseAdmission.js.map +1 -0
- package/dist/esm/provider-contract/types/code.d.ts +434 -0
- package/dist/esm/provider-contract/types/code.js +27 -0
- package/dist/esm/provider-contract/types/code.js.map +1 -0
- package/dist/esm/provider-contract/types/message.d.ts +226 -0
- package/dist/esm/provider-contract/types/message.js +2 -0
- package/dist/esm/provider-contract/types/message.js.map +1 -0
- package/dist/esm/provider-contract/types/provider.d.ts +261 -0
- package/dist/esm/provider-contract/types/provider.js +2 -0
- package/dist/esm/provider-contract/types/provider.js.map +1 -0
- package/dist/esm/provider-contract/types/request.d.ts +93 -0
- package/dist/esm/provider-contract/types/request.js +2 -0
- package/dist/esm/provider-contract/types/request.js.map +1 -0
- package/dist/esm/provider-contract/types/response.d.ts +142 -0
- package/dist/esm/provider-contract/types/response.js +2 -0
- package/dist/esm/provider-contract/types/response.js.map +1 -0
- package/dist/esm/provider-contract/types.d.ts +7 -1149
- package/dist/esm/provider-contract/types.js +1 -25
- package/dist/esm/provider-contract/types.js.map +1 -1
- package/dist/esm/providers.d.ts +2 -1
- package/dist/esm/providers.js +1 -0
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/core/ErrorBridge.d.ts +3 -1
- package/dist/esm/recorders/core/ErrorBridge.js +14 -0
- package/dist/esm/recorders/core/ErrorBridge.js.map +1 -1
- package/dist/esm/recorders/core/ResilienceRecorder.d.ts +4 -4
- package/dist/esm/recorders/core/ResilienceRecorder.js +4 -4
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +1 -1
- package/dist/esm/reliability/buildReliabilityGateChart.js +2 -2
- package/dist/esm/reliability/buildReliabilityGateChart.js.map +1 -1
- package/dist/esm/resilience/replayAttempt.d.ts +1 -1
- package/dist/esm/resilience/replayAttempt.js +18 -6
- package/dist/esm/resilience/replayAttempt.js.map +1 -1
- package/dist/esm/resilience/withCircuitBreaker.js +29 -13
- package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/esm/resilience/withFallback.js +22 -7
- package/dist/esm/resilience/withFallback.js.map +1 -1
- package/dist/esm/resilience/withRetry.js +35 -11
- package/dist/esm/resilience/withRetry.js.map +1 -1
- package/dist/esm/time/convert/bounds.js +18 -2
- package/dist/esm/time/convert/bounds.js.map +1 -1
- package/dist/esm/time/convert/exact.js +26 -1
- package/dist/esm/time/convert/exact.js.map +1 -1
- package/dist/esm/time/convert.d.ts +2 -2
- package/dist/esm/time/convert.js +2 -2
- package/dist/esm/time-travel/servedView/findings.js +2 -2
- package/dist/esm/time-travel/servedView/findings.js.map +1 -1
- package/dist/esm/time-travel/servedView/gaps.js +1 -1
- package/dist/esm/time-travel/servedView/gaps.js.map +1 -1
- package/dist/esm/time-travel/servedView/ontology.js +1 -1
- package/dist/esm/time-travel/servedView.d.ts +2 -2
- package/dist/esm/time-travel/servedView.js +2 -2
- package/dist/hosting/failedSettlement.js +19 -0
- package/dist/hosting/failedSettlement.js.map +1 -0
- package/dist/hosting/headers.js +20 -1
- package/dist/hosting/headers.js.map +1 -1
- package/dist/hosting/httpHost.js +5 -20
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/protocolRoute.js +9 -2
- package/dist/hosting/protocolRoute.js.map +1 -1
- package/dist/hosting/refusalStatus.js +5 -0
- package/dist/hosting/refusalStatus.js.map +1 -1
- package/dist/hosting/streamHandler/conversation.js +37 -0
- package/dist/hosting/streamHandler/conversation.js.map +1 -0
- package/dist/hosting/streamHandler/request.js +93 -0
- package/dist/hosting/streamHandler/request.js.map +1 -0
- package/dist/hosting/streamHandler/types.js +8 -0
- package/dist/hosting/streamHandler/types.js.map +1 -0
- package/dist/hosting/streamHandler.js +25 -132
- package/dist/hosting/streamHandler.js.map +1 -1
- package/dist/hosting/unstreamedText.js +1 -1
- package/dist/lib/iterationBudget.js +1 -1
- package/dist/lib/iterationBudget.js.map +1 -1
- package/dist/lib/toolBytes.js +2 -2
- package/dist/lib/toolBytes.js.map +1 -1
- package/dist/ontology/serve.js +2 -2
- package/dist/provider-contract/intervention.js +122 -0
- package/dist/provider-contract/intervention.js.map +1 -0
- package/dist/provider-contract/replaySafety.js +30 -0
- package/dist/provider-contract/replaySafety.js.map +1 -0
- package/dist/provider-contract/requestRefusal.js +3 -1
- package/dist/provider-contract/requestRefusal.js.map +1 -1
- package/dist/provider-contract/responseAdmission.js +96 -0
- package/dist/provider-contract/responseAdmission.js.map +1 -0
- package/dist/provider-contract/types/code.js +33 -0
- package/dist/provider-contract/types/code.js.map +1 -0
- package/dist/provider-contract/types/message.js +3 -0
- package/dist/provider-contract/types/message.js.map +1 -0
- package/dist/provider-contract/types/provider.js +3 -0
- package/dist/provider-contract/types/provider.js.map +1 -0
- package/dist/provider-contract/types/request.js +3 -0
- package/dist/provider-contract/types/request.js.map +1 -0
- package/dist/provider-contract/types/response.js +3 -0
- package/dist/provider-contract/types/response.js.map +1 -0
- package/dist/provider-contract/types.js +6 -29
- package/dist/provider-contract/types.js.map +1 -1
- package/dist/providers.js +5 -1
- package/dist/providers.js.map +1 -1
- package/dist/recorders/core/ErrorBridge.js +14 -0
- package/dist/recorders/core/ErrorBridge.js.map +1 -1
- package/dist/recorders/core/ResilienceRecorder.js +4 -4
- package/dist/reliability/buildReliabilityGateChart.js +2 -2
- package/dist/reliability/buildReliabilityGateChart.js.map +1 -1
- package/dist/resilience/replayAttempt.js +18 -6
- package/dist/resilience/replayAttempt.js.map +1 -1
- package/dist/resilience/withCircuitBreaker.js +29 -13
- package/dist/resilience/withCircuitBreaker.js.map +1 -1
- package/dist/resilience/withFallback.js +22 -7
- package/dist/resilience/withFallback.js.map +1 -1
- package/dist/resilience/withRetry.js +35 -11
- package/dist/resilience/withRetry.js.map +1 -1
- package/dist/time/convert/bounds.js +18 -2
- package/dist/time/convert/bounds.js.map +1 -1
- package/dist/time/convert/exact.js +26 -1
- package/dist/time/convert/exact.js.map +1 -1
- package/dist/time/convert.js +2 -2
- package/dist/time-travel/servedView/findings.js +2 -2
- package/dist/time-travel/servedView/findings.js.map +1 -1
- package/dist/time-travel/servedView/gaps.js +1 -1
- package/dist/time-travel/servedView/gaps.js.map +1 -1
- package/dist/time-travel/servedView/ontology.js +1 -1
- package/dist/time-travel/servedView.js +2 -2
- package/dist/types/adapters/llm/BedrockProvider/client.d.ts +12 -0
- package/dist/types/adapters/llm/BedrockProvider/client.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardedStream.d.ts +8 -0
- package/dist/types/adapters/llm/BedrockProvider/guardedStream.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardedStreamBuffer.d.ts +22 -0
- package/dist/types/adapters/llm/BedrockProvider/guardedStreamBuffer.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailClassify.d.ts +9 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailClassify.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailConfig.d.ts +31 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailConfig.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailRead.d.ts +20 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailRead.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailResponse.d.ts +14 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailResponse.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailSchemas.d.ts +14 -0
- package/dist/types/adapters/llm/BedrockProvider/guardrailSchemas.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/request.d.ts +5 -0
- package/dist/types/adapters/llm/BedrockProvider/request.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/response.d.ts +33 -0
- package/dist/types/adapters/llm/BedrockProvider/response.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/stream.d.ts +5 -0
- package/dist/types/adapters/llm/BedrockProvider/stream.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider/types.d.ts +175 -0
- package/dist/types/adapters/llm/BedrockProvider/types.d.ts.map +1 -0
- package/dist/types/adapters/llm/BedrockProvider.d.ts +5 -148
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/ag-ui/serializer/settle.d.ts +29 -0
- package/dist/types/ag-ui/serializer/settle.d.ts.map +1 -0
- package/dist/types/ag-ui/serializer/translate.d.ts +40 -0
- package/dist/types/ag-ui/serializer/translate.d.ts.map +1 -0
- package/dist/types/ag-ui/serializer/types.d.ts +67 -0
- package/dist/types/ag-ui/serializer/types.d.ts.map +1 -0
- package/dist/types/ag-ui/serializer/values.d.ts +40 -0
- package/dist/types/ag-ui/serializer/values.d.ts.map +1 -0
- package/dist/types/ag-ui/serializer.d.ts +3 -146
- package/dist/types/ag-ui/serializer.d.ts.map +1 -1
- package/dist/types/core/LLMCall/chart.d.ts +22 -0
- package/dist/types/core/LLMCall/chart.d.ts.map +1 -0
- package/dist/types/core/LLMCall.d.ts +3 -0
- package/dist/types/core/LLMCall.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentMessageApiChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart/boundary.d.ts +101 -0
- package/dist/types/core/agent/buildDynamicAgentChart/boundary.d.ts.map +1 -0
- package/dist/types/core/agent/buildDynamicAgentChart/engineBoundary.d.ts +52 -0
- package/dist/types/core/agent/buildDynamicAgentChart/engineBoundary.d.ts.map +1 -0
- package/dist/types/core/agent/buildDynamicAgentChart/finalBranch.d.ts +4 -0
- package/dist/types/core/agent/buildDynamicAgentChart/finalBranch.d.ts.map +1 -0
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts +0 -50
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildMessageApiChart.d.ts.map +1 -1
- package/dist/types/core/agent/composeRequest.d.ts +1 -1
- package/dist/types/core/agent/dynamicTurnSeed.d.ts.map +1 -1
- package/dist/types/core/agent/findings/answerText.d.ts +1 -1
- package/dist/types/core/agent/receipt/receipt.d.ts +2 -2
- package/dist/types/core/agent/runtime/terminal/verdicts.d.ts.map +1 -1
- package/dist/types/core/agent/stages/callLLM/acceptResponse.d.ts +7 -0
- package/dist/types/core/agent/stages/callLLM/acceptResponse.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM/executeCall.d.ts +27 -0
- package/dist/types/core/agent/stages/callLLM/executeCall.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM/prepareCall.d.ts +89 -0
- package/dist/types/core/agent/stages/callLLM/prepareCall.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM/responseAccounting.d.ts +11 -0
- package/dist/types/core/agent/stages/callLLM/responseAccounting.d.ts.map +1 -0
- package/dist/types/core/agent/stages/callLLM.d.ts +1 -1
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/reliabilityExecution/contracts.d.ts +54 -0
- package/dist/types/core/agent/stages/reliabilityExecution/contracts.d.ts.map +1 -0
- package/dist/types/core/agent/stages/reliabilityExecution/feedback.d.ts +20 -0
- package/dist/types/core/agent/stages/reliabilityExecution/feedback.d.ts.map +1 -0
- package/dist/types/core/agent/stages/reliabilityExecution/stuckLoop.d.ts +30 -0
- package/dist/types/core/agent/stages/reliabilityExecution/stuckLoop.d.ts.map +1 -0
- package/dist/types/core/agent/stages/reliabilityExecution.d.ts +4 -81
- package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
- package/dist/types/core/agent/toolChoice/record.d.ts +1 -1
- package/dist/types/core/agent/window/toolNames.d.ts +1 -1
- package/dist/types/core/providerIntervention.d.ts +26 -0
- package/dist/types/core/providerIntervention.d.ts.map +1 -0
- package/dist/types/core/slots/buildMessagesSlot.d.ts +1 -1
- package/dist/types/core/terminalVerdict.d.ts +4 -0
- package/dist/types/core/terminalVerdict.d.ts.map +1 -1
- package/dist/types/core-flow/Graph.d.ts +1 -1
- package/dist/types/core-flow/Parallel/builder.d.ts +40 -0
- package/dist/types/core-flow/Parallel/builder.d.ts.map +1 -0
- package/dist/types/core-flow/Parallel/chart.d.ts +16 -0
- package/dist/types/core-flow/Parallel/chart.d.ts.map +1 -0
- package/dist/types/core-flow/Parallel/mapper.d.ts +22 -0
- package/dist/types/core-flow/Parallel/mapper.d.ts.map +1 -0
- package/dist/types/core-flow/Parallel/merge.d.ts +5 -0
- package/dist/types/core-flow/Parallel/merge.d.ts.map +1 -0
- package/dist/types/core-flow/Parallel/types.d.ts +180 -0
- package/dist/types/core-flow/Parallel/types.d.ts.map +1 -0
- package/dist/types/core-flow/Parallel.d.ts +7 -233
- package/dist/types/core-flow/Parallel.d.ts.map +1 -1
- package/dist/types/hosting/failedSettlement.d.ts +10 -0
- package/dist/types/hosting/failedSettlement.d.ts.map +1 -0
- package/dist/types/hosting/headers.d.ts +8 -0
- package/dist/types/hosting/headers.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/httpStreaming.d.ts +5 -2
- package/dist/types/hosting/httpStreaming.d.ts.map +1 -1
- package/dist/types/hosting/protocolRoute.d.ts.map +1 -1
- package/dist/types/hosting/refusalStatus.d.ts +3 -0
- package/dist/types/hosting/refusalStatus.d.ts.map +1 -1
- package/dist/types/hosting/streamHandler/conversation.d.ts +18 -0
- package/dist/types/hosting/streamHandler/conversation.d.ts.map +1 -0
- package/dist/types/hosting/streamHandler/request.d.ts +13 -0
- package/dist/types/hosting/streamHandler/request.d.ts.map +1 -0
- package/dist/types/hosting/streamHandler/types.d.ts +107 -0
- package/dist/types/hosting/streamHandler/types.d.ts.map +1 -0
- package/dist/types/hosting/streamHandler.d.ts +3 -133
- package/dist/types/hosting/streamHandler.d.ts.map +1 -1
- package/dist/types/hosting/unstreamedText.d.ts +1 -1
- package/dist/types/lib/toolBytes.d.ts +1 -1
- package/dist/types/ontology/serve.d.ts +2 -2
- package/dist/types/provider-contract/intervention.d.ts +57 -0
- package/dist/types/provider-contract/intervention.d.ts.map +1 -0
- package/dist/types/provider-contract/replaySafety.d.ts +5 -0
- package/dist/types/provider-contract/replaySafety.d.ts.map +1 -0
- package/dist/types/provider-contract/requestRefusal.d.ts.map +1 -1
- package/dist/types/provider-contract/responseAdmission.d.ts +11 -0
- package/dist/types/provider-contract/responseAdmission.d.ts.map +1 -0
- package/dist/types/provider-contract/types/code.d.ts +435 -0
- package/dist/types/provider-contract/types/code.d.ts.map +1 -0
- package/dist/types/provider-contract/types/message.d.ts +227 -0
- package/dist/types/provider-contract/types/message.d.ts.map +1 -0
- package/dist/types/provider-contract/types/provider.d.ts +262 -0
- package/dist/types/provider-contract/types/provider.d.ts.map +1 -0
- package/dist/types/provider-contract/types/request.d.ts +94 -0
- package/dist/types/provider-contract/types/request.d.ts.map +1 -0
- package/dist/types/provider-contract/types/response.d.ts +143 -0
- package/dist/types/provider-contract/types/response.d.ts.map +1 -0
- package/dist/types/provider-contract/types.d.ts +7 -1149
- package/dist/types/provider-contract/types.d.ts.map +1 -1
- package/dist/types/providers.d.ts +2 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/recorders/core/ErrorBridge.d.ts +3 -1
- package/dist/types/recorders/core/ErrorBridge.d.ts.map +1 -1
- package/dist/types/recorders/core/ResilienceRecorder.d.ts +4 -4
- package/dist/types/reliability/buildReliabilityGateChart.d.ts +1 -1
- package/dist/types/resilience/replayAttempt.d.ts +1 -1
- package/dist/types/resilience/replayAttempt.d.ts.map +1 -1
- package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
- package/dist/types/resilience/withFallback.d.ts.map +1 -1
- package/dist/types/resilience/withRetry.d.ts.map +1 -1
- package/dist/types/time/convert/bounds.d.ts.map +1 -1
- package/dist/types/time/convert/exact.d.ts.map +1 -1
- package/dist/types/time/convert.d.ts +2 -2
- package/dist/types/time-travel/servedView.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,55 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { RECEIPT_KEY } from '../../../lib/conventions.js';
|
|
27
|
-
import { fileIntegrityFindings } from '../integrityFindings.js';
|
|
28
|
-
import { resilienceHooks } from '../../../recorders/core/resilienceHooks.js';
|
|
29
|
-
import { replayAttempts } from '../../../resilience/replayAttempt.js';
|
|
30
|
-
import { throwIfAborted } from '../../../lib/abort.js';
|
|
31
|
-
import { tagThinkingResponse } from '../../../thinking/dispatch.js';
|
|
32
|
-
import { emitCostTick } from '../../cost.js';
|
|
33
|
-
import { applyOutputSchema } from '../../../answer-validation/outputSchema.js';
|
|
34
|
-
import { carriesFindingsDecoration, splitFindings, withoutFindingsArgument, } from '../findings/reserved.js';
|
|
35
|
-
import { collapseJudged } from '../findings/serve.js';
|
|
36
|
-
import { captureReplayPrefix, replayCacheMarkers } from '../requestTurn/replayPrefix.js';
|
|
37
|
-
import { afterReplayResponse, sameReplayProjection } from '../requestTurn/state.js';
|
|
38
|
-
import { writeRequestReplay } from '../requestTurn/native.js';
|
|
39
|
-
import { projectCallHistory } from './callLLM/requestProjection.js';
|
|
40
|
-
import { trackRecallRequests } from './callLLM/recallRequest.js';
|
|
41
|
-
import { readSchemaToolAnswer } from '../outputEnforcement.js';
|
|
42
|
-
import { executeWithReliability, ValidationFailure, } from './reliabilityExecution.js';
|
|
43
|
-
/** The wrap-up call's tool list (9.56.0). A frozen module constant so the
|
|
44
|
-
* withholding allocates nothing on the one call it applies to. */
|
|
45
|
-
const EMPTY_TOOL_SCHEMAS = Object.freeze([]);
|
|
1
|
+
/**
|
|
2
|
+
* callLLM — the LLM-invocation stage of the agent's chart.
|
|
3
|
+
*
|
|
4
|
+
* Reads the assembled prompt + messages from scope (populated by the
|
|
5
|
+
* upstream slot subflows: SystemPrompt, Messages, Tools, CacheDecision,
|
|
6
|
+
* CacheGate). Calls `provider.stream()` if available (token streaming
|
|
7
|
+
* with per-chunk events) else falls back to `provider.complete()`.
|
|
8
|
+
* Writes the response to scope (`llmLatestContent`, `llmLatestToolCalls`,
|
|
9
|
+
* cumulative tokens) for the downstream Route decider to read.
|
|
10
|
+
*
|
|
11
|
+
* Emits `agentfootprint.stream.llm_start` + `llm_end` brackets for
|
|
12
|
+
* observability adapters and per-chunk `stream.token` events during
|
|
13
|
+
* streaming. Emits `cost.tick` via `emitCostTick` when a `pricingTable`
|
|
14
|
+
* is configured.
|
|
15
|
+
*
|
|
16
|
+
* Factory signature so the chart-build-time provider/model/etc. deps
|
|
17
|
+
* are explicit. The `toolSchemas` value is late-bound via a getter
|
|
18
|
+
* because tool schema composition completes after the seed factory is
|
|
19
|
+
* built but before the chart actually runs.
|
|
20
|
+
*/
|
|
21
|
+
import { prepareCall } from './callLLM/prepareCall.js';
|
|
22
|
+
import { executeCall } from './callLLM/executeCall.js';
|
|
23
|
+
import { acceptResponse } from './callLLM/acceptResponse.js';
|
|
24
|
+
import { admitProviderIntervention } from '../../providerIntervention.js';
|
|
25
|
+
import { recordTerminalResponse } from './callLLM/responseAccounting.js';
|
|
46
26
|
// LENS · system-text + tool-list · request-ephemeral
|
|
47
27
|
// reads: systemPrompt ← scope.systemPromptInjections, joined by `systemPrompt` below (the system-prompt slot's output)
|
|
48
28
|
// messages ← scope.history (`history`; `messages` is its wire-only collapse of judged tool results under `.findings()` — `collapseJudged`); tools ← scope.dynamicToolSchemas (`registeredToolSchemas`), EMPTIED to EMPTY_TOOL_SCHEMAS under scope.wrapUpAsked
|
|
49
29
|
// ontology piece ← scope.ontology (`ontologyPieceRecord`, under `deps.ontology` only), joined after the recovery piece
|
|
50
30
|
// findings DATA ← scope.findingsLedger (under `deps.hasFindingsLedger` only), appended after committed history
|
|
51
31
|
// brain ← deps.brainFor(nextSkillCursor ?? currentSkillId)
|
|
52
|
-
// THIS is the wire,
|
|
32
|
+
// THIS is the wire, assembled by `callLLM/prepareCall.ts · prepareCall` inside the
|
|
33
|
+
// native stage `buildCallLLMStage` wires — cite that assembly owner, not this header,
|
|
53
34
|
// when another file points at the assembly. The three slots feed it; they are not it. The staged-refs
|
|
54
35
|
// nudge appended by `wireMessages` exists on THIS request only — scope.history is untouched, which is the right
|
|
55
36
|
// lifetime for a forward-looking sentence.
|
|
@@ -61,789 +42,13 @@ const EMPTY_TOOL_SCHEMAS = Object.freeze([]);
|
|
|
61
42
|
*/
|
|
62
43
|
export function buildCallLLMStage(deps) {
|
|
63
44
|
return async (scope) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const systemPromptInjections = scope.systemPromptInjections ?? [];
|
|
72
|
-
// `scope.messagesInjections` is read by ContextRecorder for
|
|
73
|
-
// observability; the LLM-wire path now reads scope.history directly.
|
|
74
|
-
const iteration = scope.iteration;
|
|
75
|
-
// "The cursor picks the brain" (9.19.0) — ONE consult, at the top, with
|
|
76
|
-
// the advanced cursor and the escalation flag. Gated on `deps.brainFor`
|
|
77
|
-
// so an agent without brains reads no new scope key and resolves on the
|
|
78
|
-
// exact line it always did.
|
|
79
|
-
const brain = deps.brainFor
|
|
80
|
-
? deps.brainFor((scope.nextSkillCursor ?? scope.currentSkillId), scope.skillEscalated === true)
|
|
81
|
-
: undefined;
|
|
82
|
-
const firstReliabilityProvider = deps.reliability?.providers?.[0];
|
|
83
|
-
const provider = firstReliabilityProvider?.provider ?? brain?.provider ?? deps.provider;
|
|
84
|
-
// The model for this run. `.configure()` resolved it at seed and
|
|
85
|
-
// COMMITTED it to scope, so what gets called, what the `llm_start`
|
|
86
|
-
// event reports and what cost is priced against are all one value —
|
|
87
|
-
// the one the trace records. Without `.configure()` this is the
|
|
88
|
-
// build-time model and scope is never touched. A winning brain rung
|
|
89
|
-
// (9.19.0) outranks both — the stated precedence chain.
|
|
90
|
-
const model = firstReliabilityProvider?.model ??
|
|
91
|
-
brain?.model ??
|
|
92
|
-
(deps.runConfigured ? scope.resolvedModel : undefined) ??
|
|
93
|
-
deps.model;
|
|
94
|
-
// A configured/skill model can differ from the build default. Resolve the
|
|
95
|
-
// adapter's same capability for the model actually being sent, while a
|
|
96
|
-
// host's explicit strategy remains authoritative.
|
|
97
|
-
const cacheStrategy = deps.cacheStrategyIsOverride === true && provider === deps.provider
|
|
98
|
-
? deps.cacheStrategy
|
|
99
|
-
: typeof provider.promptCaching === 'function'
|
|
100
|
-
? cacheStrategyFor(provider, model)
|
|
101
|
-
: brain?.cacheStrategy ?? deps.cacheStrategy;
|
|
102
|
-
// Per-iteration boundary marker (was a dedicated `IterationStart` stage —
|
|
103
|
-
// folded here since emitting is passive observability, not work that needs
|
|
104
|
-
// its own execution stage). Fires FIRST, before the LLM call, so recorders
|
|
105
|
-
// still bracket each ReAct iteration. Payload unchanged (turnIndex reserved
|
|
106
|
-
// for future multi-turn; iterIndex is the per-iteration counter).
|
|
107
|
-
typedEmit(scope, 'agentfootprint.agent.iteration_start', {
|
|
108
|
-
turnIndex: 0,
|
|
109
|
-
iterIndex: iteration,
|
|
110
|
-
});
|
|
111
|
-
// ── the system-prompt join ────────────────────────────────────────
|
|
112
|
-
// The pieces are committed (`systemPromptInjections`); THIS STRING IS NOT.
|
|
113
|
-
// It lives and dies inside this stage, which is why the join is one
|
|
114
|
-
// exported function rather than four lines here — a reader rebuilding what
|
|
115
|
-
// the model was served has to apply the identical rule to the identical
|
|
116
|
-
// records (`composeRequest.ts` · `joinSystemPrompt`).
|
|
117
|
-
const trustedSystemPrompt = joinSystemPrompt(systemPromptInjections);
|
|
118
|
-
const recoveryPiece = deps.hasEvidenceRecovery === true
|
|
119
|
-
? evidenceRecoveryPiece(scope.evidenceRecovery, scope.evidenceRecoveryUsed, iteration)
|
|
120
|
-
: undefined;
|
|
121
|
-
// Read the LLM message stream from `scope.history` directly. The
|
|
122
|
-
// `messagesInjections` projection is for observability — it
|
|
123
|
-
// flattens InjectionRecords for event reporting and doesn't carry
|
|
124
|
-
// the full LLM-protocol shape (assistant `toolCalls[]`, etc.). For
|
|
125
|
-
// Anthropic's API contract we need the original LLMMessage with
|
|
126
|
-
// `toolCalls` intact so tool_use → tool_result correlation survives.
|
|
127
|
-
// `stripFrameworkFields` takes off `injectedBy` — the marker the delivery
|
|
128
|
-
// stage stamps so the messages slot can say WHO put a message here — and
|
|
129
|
-
// `notDispatched`, the batch settlement's marker (9.113.0). Both are
|
|
130
|
-
// framework bookkeeping, not conversation, and are removed BEFORE the
|
|
131
|
-
// request exists rather than trusted to be ignored: a consumer-authored
|
|
132
|
-
// adapter that serializes a message wholesale would otherwise put library
|
|
133
|
-
// internals on someone's wire. Stripping removes a FIELD, never a message,
|
|
134
|
-
// so `messages[i]` is still the message the cache marker's index names.
|
|
135
|
-
// `committed` keeps both markers for the readers below that must see them.
|
|
136
|
-
const committed = scope.history ?? [];
|
|
137
|
-
const projected = stripFrameworkFields(committed, true);
|
|
138
|
-
// Receipt assembly keeps a stable list even when stripping returns a live array.
|
|
139
|
-
const history = projected === committed ? [...projected] : projected;
|
|
140
|
-
// ── the findings ledger, served (9.101.0, step 3) ──────────────────
|
|
141
|
-
// ONE gated read of the committed key, used twice. The COLLAPSE rewrites,
|
|
142
|
-
// on the wire only, the `content` of `role: 'tool'` messages the model
|
|
143
|
-
// has already judged noise or ruled-out (facts too under the bench-gated
|
|
144
|
-
// `'ledger-only'`) to a ticket with no model words in it — the
|
|
145
|
-
// `placedToolResult` precedent. It runs HERE, before the staged-refs
|
|
146
|
-
// nudge and before the receipt mint, so `findStagedRefs` reads the
|
|
147
|
-
// conversation the model reads and the receipt hashes what was sent.
|
|
148
|
-
// Count, order, `toolCallId` and `toolName` are unchanged, so
|
|
149
|
-
// `messages[i]` is still the message the cache marker's index names and
|
|
150
|
-
// The tool_use/tool_result pair remains valid. Collapse changes only the
|
|
151
|
-
// wire copy, never committed history. Current declarations and advisory
|
|
152
|
-
// IDs are composed later as request-only DATA, outside the cached prefix.
|
|
153
|
-
// Both DATA and collapse read the committed twin, whose notDispatched
|
|
154
|
-
// marker distinguishes a settlement notice from an actual result.
|
|
155
|
-
const ledger = deps.hasFindingsLedger === true
|
|
156
|
-
? scope.findingsLedger
|
|
157
|
-
: undefined;
|
|
158
|
-
const collapsed = deps.hasFindingsLedger === true
|
|
159
|
-
? collapseJudged(committed, ledger, deps.findingsServe ?? 'ledger-and-facts')
|
|
160
|
-
: committed;
|
|
161
|
-
const rendered = collapsed === committed ? history : stripFrameworkFields(collapsed, true);
|
|
162
|
-
// ── the declared ontology, served (9.106.0) ──────────────────────────
|
|
163
|
-
// ONE gated read of the run constant seed wrote; the piece is a pure
|
|
164
|
-
// function of the spec and nothing else (no call number, no clock — the
|
|
165
|
-
// cached system-prefix contract), so an unchanged map serves unchanged bytes
|
|
166
|
-
// on every call of the run. The composer is loaded through `import()` —
|
|
167
|
-
// the optional-family law of docs-next's site budget (`toolCalls/evidence/judgeLanded.ts ·
|
|
168
|
-
// judgeLanded`): an unarmed agent never loads the module. The event
|
|
169
|
-
// carries identities and counts only.
|
|
170
|
-
let ontologyPieceRecord;
|
|
171
|
-
if (deps.ontology === true) {
|
|
172
|
-
const record = scope.ontology;
|
|
173
|
-
if (record !== undefined) {
|
|
174
|
-
const { ontologyPiece } = await import('../../../ontology/serve.js');
|
|
175
|
-
// The join (9.108.0): the record's tool → skills map and this
|
|
176
|
-
// iteration's hidden skill ids — the same filter every model-facing
|
|
177
|
-
// sentence applies, so the piece names no skill the caller may not see.
|
|
178
|
-
const hidden = scope.hiddenSkillIds;
|
|
179
|
-
ontologyPieceRecord = ontologyPiece(record.spec, {
|
|
180
|
-
...(record.tools !== undefined && { tools: record.tools }),
|
|
181
|
-
...(hidden !== undefined && { hiddenSkillIds: hidden }),
|
|
182
|
-
});
|
|
183
|
-
typedEmit(scope, 'agentfootprint.ontology.served', {
|
|
184
|
-
iteration,
|
|
185
|
-
id: record.id,
|
|
186
|
-
version: record.version,
|
|
187
|
-
hash: record.hash,
|
|
188
|
-
nodes: Object.keys(record.spec.nodes).length,
|
|
189
|
-
sources: Object.keys(record.spec.sources).length,
|
|
190
|
-
edges: record.spec.edges.length,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// Dynamic schemas — registry tools + injection-supplied tools (Skills'
|
|
195
|
-
// `inject.tools` when their Injection is active). Falls back to the static
|
|
196
|
-
// schemas at startup before the tools slot has run. Computed BEFORE the
|
|
197
|
-
// llm_start emit so the event reports what the model ACTUALLY saw this call
|
|
198
|
-
// (count + the name/description catalog), not the static startup set.
|
|
199
|
-
//
|
|
200
|
-
// 9.56.0 — unless this is the WRAP-UP call, in which case the tools come
|
|
201
|
-
// OFF. They are withheld HERE, at request assembly, for the same reason
|
|
202
|
-
// the schema tool is ADDED here: this is the one seam that decides what
|
|
203
|
-
// goes on the wire, so the change never has to be known by the tools slot,
|
|
204
|
-
// the registry, `tools.offered`, an MCP server's served list or the
|
|
205
|
-
// dispatcher that runs tools. Nothing downstream learns a new mode — the
|
|
206
|
-
// model is simply handed a request with no tools, which is what makes the
|
|
207
|
-
// wrap-up terminal by construction rather than by another rule.
|
|
208
|
-
//
|
|
209
|
-
// `llm_start` reports the truth (`toolsCount: 0`, no catalog), because its
|
|
210
|
-
// whole claim is what the model actually saw this call.
|
|
211
|
-
//
|
|
212
|
-
// The same seam withholds them once the evidence gate asked for its
|
|
213
|
-
// revision under an ENFORCING answer validation
|
|
214
|
-
// (`AgentState.toolsOffAfterRevision`): the answer may yet be withheld, so
|
|
215
|
-
// no tool that writes or sends may run again, and the library cannot tell
|
|
216
|
-
// one that only reads. Route refuses any call the model returns anyway.
|
|
217
|
-
const withheld = toolsWithheld(scope.wrapUpAsked, deps.toolsOffAfterRevision === true ? scope.toolsOffAfterRevision : undefined);
|
|
218
|
-
const registeredToolSchemas = withheld !== null
|
|
219
|
-
? EMPTY_TOOL_SCHEMAS
|
|
220
|
-
: scope.dynamicToolSchemas ?? deps.toolSchemas;
|
|
221
|
-
const { replayFrames, closure, continuing, messages } = projectCallHistory(scope, history, rendered, recoveryPiece !== undefined && withheld !== null);
|
|
222
|
-
// The forced schema rides on the wire and in `llm_start`. Offered contracts
|
|
223
|
-
// specialize the findings instruction in request-only copies that replay rebuilds.
|
|
224
|
-
const recoveryNote = recoveryPiece !== undefined && continuing !== undefined && withheld === null
|
|
225
|
-
? recoveryFeedback(recoveryPiece.rawContent)
|
|
226
|
-
: undefined;
|
|
227
|
-
const systemRecovery = recoveryNote === undefined ? recoveryPiece : undefined;
|
|
228
|
-
const systemPieces = projectSourceInstructions(systemRecovery === undefined && ontologyPieceRecord === undefined
|
|
229
|
-
? systemPromptInjections
|
|
230
|
-
: [
|
|
231
|
-
...systemPromptInjections,
|
|
232
|
-
...(systemRecovery === undefined ? [] : [systemRecovery]),
|
|
233
|
-
...(ontologyPieceRecord === undefined ? [] : [ontologyPieceRecord]),
|
|
234
|
-
], registeredToolSchemas);
|
|
235
|
-
const systemPrompt = joinSystemPrompt(systemPieces);
|
|
236
|
-
const activeToolSchemas = deps.schemaTool
|
|
237
|
-
? [...registeredToolSchemas, deps.schemaTool]
|
|
238
|
-
: registeredToolSchemas;
|
|
239
|
-
const freshNotes = requestOnlyMessages(scope, deps, {
|
|
240
|
-
iteration,
|
|
241
|
-
committed,
|
|
242
|
-
messages,
|
|
243
|
-
ledger,
|
|
244
|
-
registeredToolSchemas,
|
|
245
|
-
withheld,
|
|
246
|
-
});
|
|
247
|
-
const recoveryContext = closure ?? recoveryNote;
|
|
248
|
-
const tail = recoveryContext === undefined ? freshNotes : [recoveryContext, ...freshNotes];
|
|
249
|
-
const prefixWire = continuing?.wire ?? messages;
|
|
250
|
-
const wireMessages = tail.length === 0 ? prefixWire : [...prefixWire, ...tail.map(({ message }) => message)];
|
|
251
|
-
const requestOnly = continuing === undefined
|
|
252
|
-
? tail
|
|
253
|
-
: [
|
|
254
|
-
...continuing.additions.map(({ message, reason, wireIndex }) => ({
|
|
255
|
-
message,
|
|
256
|
-
reason: `native-turn-prefix:${wireIndex}:${reason}`,
|
|
257
|
-
})),
|
|
258
|
-
...tail,
|
|
259
|
-
];
|
|
260
|
-
typedEmit(scope, 'agentfootprint.stream.llm_start', {
|
|
261
|
-
iteration,
|
|
262
|
-
provider: provider.name,
|
|
263
|
-
model,
|
|
264
|
-
systemPromptChars: systemPrompt.length,
|
|
265
|
-
// Opt-in (9.50.0): the assembled prompt VERBATIM, exactly the string
|
|
266
|
-
// handed to the provider below — never re-joined by a consumer.
|
|
267
|
-
...(deps.recordSystemPrompt === true && { systemPromptText: systemPrompt }),
|
|
268
|
-
messagesCount: wireMessages.length,
|
|
269
|
-
toolsCount: activeToolSchemas.length,
|
|
270
|
-
// WHICH BRAIN answered (9.19.0) — stamped ONLY when a brain rung won,
|
|
271
|
-
// so configured/default runs keep byte-identical events.
|
|
272
|
-
...(brain !== undefined && {
|
|
273
|
-
brain: {
|
|
274
|
-
via: brain.via,
|
|
275
|
-
...(brain.skillId !== undefined && { skillId: brain.skillId }),
|
|
276
|
-
},
|
|
277
|
-
}),
|
|
278
|
-
...(activeToolSchemas.length > 0 && {
|
|
279
|
-
tools: activeToolSchemas.map((t) => ({
|
|
280
|
-
name: t.name,
|
|
281
|
-
...(t.description ? { description: t.description } : {}),
|
|
282
|
-
})),
|
|
283
|
-
}),
|
|
284
|
-
...(deps.temperature !== undefined && { temperature: deps.temperature }),
|
|
285
|
-
});
|
|
286
|
-
const startMs = Date.now();
|
|
287
|
-
// Auto follows the actual provider/model, including cache-selected models
|
|
288
|
-
// and each reliability fallback. Explicit strategies retain their refusals.
|
|
289
|
-
const baseRequest = selectOutputFormat({
|
|
290
|
-
...(systemPrompt.length > 0 && { systemPrompt }),
|
|
291
|
-
messages: wireMessages,
|
|
292
|
-
...(activeToolSchemas.length > 0 && { tools: activeToolSchemas }),
|
|
293
|
-
model,
|
|
294
|
-
...(deps.temperature !== undefined && { temperature: deps.temperature }),
|
|
295
|
-
...(deps.maxTokens !== undefined && { maxTokens: deps.maxTokens }),
|
|
296
|
-
...(deps.thinkingBudget !== undefined && {
|
|
297
|
-
thinking: { budget: deps.thinkingBudget },
|
|
298
|
-
}),
|
|
299
|
-
...(deps.schemaTool !== undefined && {
|
|
300
|
-
toolChoice: { type: 'tool', name: deps.schemaTool.name },
|
|
301
|
-
}),
|
|
302
|
-
...(deps.outputFormat !== undefined && { outputFormat: deps.outputFormat }),
|
|
303
|
-
}, provider, deps.nativeOutputAuto === true, deps.outputFormat);
|
|
304
|
-
// v2.6+ — call cache strategy to attach provider-specific cache
|
|
305
|
-
// hints. CacheGate has already routed (apply-markers / no-markers)
|
|
306
|
-
// and populated scope.cacheMarkers accordingly. Strategy.prepareRequest
|
|
307
|
-
// is a pass-through for empty markers.
|
|
308
|
-
// A custom strategy can create remote cache handles, so refuse a known
|
|
309
|
-
// unsupported effective request before even that preparation does I/O.
|
|
310
|
-
assertForcedRequestSupported(provider, baseRequest);
|
|
311
|
-
const cacheMarkers = replayCacheMarkers(scope.cacheMarkers ?? [], continuing);
|
|
312
|
-
const detached = detachProviderInput(baseRequest, cacheMarkers, deps.outputFormat);
|
|
313
|
-
const citations = prepareCitationProjection(scope, deps.offerCitations === true &&
|
|
314
|
-
continuing === undefined &&
|
|
315
|
-
deps.outputSchemaParser === undefined &&
|
|
316
|
-
deps.outputFormat === undefined, committed, wireMessages, detached.request.messages);
|
|
317
|
-
const selection = deps.servedTools?.selection &&
|
|
318
|
-
selectionAtRequest(deps, iteration, scope.$attempt?.(), baseRequest, withheld !== null);
|
|
319
|
-
const serving = deps.recordReceipt === false
|
|
320
|
-
? undefined
|
|
321
|
-
: servedRequestRecorder(scope, committed, messages, wireMessages, detached);
|
|
322
|
-
const cachePrepared = await cacheStrategy.prepareRequest(detached.request, detached.markers, {
|
|
323
|
-
iteration,
|
|
324
|
-
iterationsRemaining: iterationsRemainingOf(deps.maxIterations, iteration),
|
|
325
|
-
recentHitRate: scope.recentHitRate,
|
|
326
|
-
cachingDisabled: scope.cachingDisabled ?? false,
|
|
327
|
-
});
|
|
328
|
-
const llmRequest = selectOutputFormat(cachePrepared.request, provider, deps.nativeOutputAuto === true, detached.outputFormat);
|
|
329
|
-
// Judge the final request on the effective brain/configured model, not
|
|
330
|
-
// the agent's build-time default. This is before provider I/O and outside
|
|
331
|
-
// the reliability loop: retrying cannot repair an unsupported contract.
|
|
332
|
-
assertForcedRequestSupported(provider, llmRequest);
|
|
333
|
-
// ── THE RECEIPT ──────────────────────────────────────────────────────
|
|
334
|
-
// Written HERE, immediately before the provider is called, so it is
|
|
335
|
-
// committed in the call-llm bundle that already exists — the llm-turn stop
|
|
336
|
-
// a reader already scrubs to. Before rather than after on purpose: the
|
|
337
|
-
// stage commits on the error path too, so a call that throws still leaves
|
|
338
|
-
// the record of what it was about to send.
|
|
339
|
-
//
|
|
340
|
-
// Hashes and references only. Every law this record obeys — no bytes, no
|
|
341
|
-
// authority omissions, run-salted digests — is stated once, at
|
|
342
|
-
// `receipt.ts` · `Receipt`, and enforced by the shape it fills in.
|
|
343
|
-
//
|
|
344
|
-
// `omittedForAttention` comes from the WINDOW, through `deps.evictedTurns`
|
|
345
|
-
// (9.93.0) — never from a scope read. The slots were the first place this
|
|
346
|
-
// was looked for, and they drop nothing; the one measured pass that read
|
|
347
|
-
// `slotCompositions` here put a tracked get of an always-absent key on
|
|
348
|
-
// every call-llm stage's read set, which gave `trajectory.ts` a phantom
|
|
349
|
-
// context source per loop and moved the localizer's ranking. The window's
|
|
350
|
-
// `compactions` key is absent on every run without a window and would do
|
|
351
|
-
// the same. A receipt records what the run knows; it does not go looking —
|
|
352
|
-
// so the window hands the turns across, and an agent with no window hands
|
|
353
|
-
// nothing.
|
|
354
|
-
if (deps.recordReceipt !== false) {
|
|
355
|
-
const evictedForAttention = deps.evictedTurns?.read(iteration) ?? [];
|
|
356
|
-
const hostStrategy = deps.cacheStrategyIsOverride === true && cacheStrategy === deps.cacheStrategy;
|
|
357
|
-
scope[RECEIPT_KEY] = buildReceipt({
|
|
358
|
-
runId: deps.getRunId?.() ?? '',
|
|
359
|
-
epoch: iteration,
|
|
360
|
-
model,
|
|
361
|
-
provider: provider.name,
|
|
362
|
-
systemText: systemPrompt,
|
|
363
|
-
systemPieces: receiptPieces(systemPieces),
|
|
364
|
-
messages,
|
|
365
|
-
requestOnly,
|
|
366
|
-
tools: activeToolSchemas,
|
|
367
|
-
forced: deps.schemaTool?.name ?? null,
|
|
368
|
-
// Read as it always was; the revision's rule rides `withheld`.
|
|
369
|
-
withheld: scope.wrapUpAsked === true ? 'wrap-up' : withheld,
|
|
370
|
-
baseRequest,
|
|
371
|
-
preparedRequest: receiptProviderRequest(llmRequest, detached.request, baseRequest, hostStrategy),
|
|
372
|
-
// The breakpoints the strategy really APPLIED, not the candidates it
|
|
373
|
-
// was offered. `scope.cacheMarkers` already records the offer; which of
|
|
374
|
-
// them survived the provider's clamp is the half that decides the bill,
|
|
375
|
-
// and it existed only in this local until now.
|
|
376
|
-
markersApplied: cachePrepared.markersApplied,
|
|
377
|
-
// WHICH strategy the request went through — its `name`, which for the
|
|
378
|
-
// built-ins is the capability the provider declared (`'breakpoints'`,
|
|
379
|
-
// `'automatic'`, `'none'` for the pass-through). Every agent has one,
|
|
380
|
-
// so this is never `null` here; the charts that run none say `null` at
|
|
381
|
-
// their own mints. A strategy handed in past the type with no `name`
|
|
382
|
-
// is still a strategy, and is recorded as one under the empty name
|
|
383
|
-
// rather than denied.
|
|
384
|
-
strategy: typeof cacheStrategy.name === 'string' ? cacheStrategy.name : '',
|
|
385
|
-
...(evictedForAttention.length > 0 && { omittedForAttention: evictedForAttention }),
|
|
386
|
-
},
|
|
387
|
-
// Host strategies can reissue their own objects with nested edits.
|
|
388
|
-
hostStrategy ? undefined : deps.receiptDigests);
|
|
389
|
-
}
|
|
390
|
-
recordModelContext(scope, () => ({
|
|
391
|
-
iteration,
|
|
392
|
-
systemPieces,
|
|
393
|
-
tools: activeToolSchemas,
|
|
394
|
-
requestOnly: freshNotes,
|
|
395
|
-
}));
|
|
396
|
-
// THE CLOSURE CHECK (9.60.0, dangling-reference). At assembly, BEFORE the
|
|
397
|
-
// call — the composition defect exists whether or not the call lands. A
|
|
398
|
-
// served tool whose declared argument ground (`Tool.argumentsFrom`) has
|
|
399
|
-
// left the window (the union of every visit's droppedObservations) and
|
|
400
|
-
// has no fresh result in the frame is being offered without its evidence.
|
|
401
|
-
// Both fences live in the check: never-dropped is silent (not-yet-grounded
|
|
402
|
-
// is legitimate sequencing) and a re-fetched ground is silent.
|
|
403
|
-
//
|
|
404
|
-
// ONE HELPER, BOTH SIDES. The dropped side is the window ledger, which
|
|
405
|
-
// names a result with `toolNameOfMessage` — the helper that recovers the
|
|
406
|
-
// name from the assistant turn that asked when the result itself carries
|
|
407
|
-
// no `toolName`. The present side asks the SAME helper the SAME question,
|
|
408
|
-
// because `LLMMessage.toolName` is optional and a conversation restored
|
|
409
|
-
// from an older release (or a host that speaks only the wire shape) names
|
|
410
|
-
// its tools through `toolCalls[].id` alone. Reading `m.toolName` here
|
|
411
|
-
// instead made the same message evidence-that-left on one side and
|
|
412
|
-
// not-present on the other, and the check then accused a window that had
|
|
413
|
-
// been RE-GROUNDED — a legitimate re-fetch reported as a dangling
|
|
414
|
-
// reference. A false accusation is this family's unrecoverable failure.
|
|
415
|
-
if (deps.toolGrounding !== undefined && deps.toolGrounding.size > 0) {
|
|
416
|
-
const grounding = deps.toolGrounding;
|
|
417
|
-
const servedGrounded = (llmRequest.tools ?? [])
|
|
418
|
-
.filter((t) => grounding.has(t.name))
|
|
419
|
-
.map((t) => ({ name: t.name, argumentsFrom: grounding.get(t.name) }));
|
|
420
|
-
const windowVisits = scope.compactions ??
|
|
421
|
-
[];
|
|
422
|
-
const droppedResults = new Set(windowVisits.flatMap((v) => v.droppedObservations ?? []));
|
|
423
|
-
if (servedGrounded.length > 0 && droppedResults.size > 0) {
|
|
424
|
-
// The frame's tool messages, named from `committed` — the stage's ONE
|
|
425
|
-
// read of `scope.history`, at its top — rather than
|
|
426
|
-
// `llmRequest.messages`: the same messages in the same order
|
|
427
|
-
// (stripping removes a FIELD, never a message; the collapse rewrites
|
|
428
|
-
// `content` only; the staged-refs nudge is a `role: 'user'` line that
|
|
429
|
-
// names no tool), but the wire has lost the batch settlement's marker
|
|
430
|
-
// (9.113.0), and a settled sentence is no fresh result — the helper
|
|
431
|
-
// says so only when it can see `LLMMessage.notDispatched`
|
|
432
|
-
// (`window/toolNames.ts` · "A settled message is not a result at
|
|
433
|
-
// all"). Never a second `scope.history` read: every tracked read is a
|
|
434
|
-
// narrative step, and one more here renumbered every step after it on
|
|
435
|
-
// runs that never settle anything (pinned by
|
|
436
|
-
// `src/integrity/dangling-reference/danglingReference.test.ts` · "the narrative").
|
|
437
|
-
const frame = committed;
|
|
438
|
-
const presentResults = new Set(frame
|
|
439
|
-
.map((m) => toolNameOfMessage(m, frame))
|
|
440
|
-
.filter((name) => name !== undefined));
|
|
441
|
-
const danglingFindings = danglingReferencesOf(servedGrounded, droppedResults, presentResults, iteration);
|
|
442
|
-
deps.integrityLedger?.current?.note('dangling-reference', 'compose', danglingFindings.length > 0 ? 'checked-fail' : 'checked-pass', danglingFindings.length > 0 ? Date.now() : undefined);
|
|
443
|
-
fileIntegrityFindings(scope, danglingFindings, iteration, deps.integrityLedger);
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
// No grounded tool served, or nothing has dropped: nothing this call
|
|
447
|
-
// could violate — stated, never silence.
|
|
448
|
-
deps.integrityLedger?.current?.note('dangling-reference', 'compose', 'not-applicable');
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
// Streaming-first: when the provider implements `stream()` we
|
|
452
|
-
// consume chunk-by-chunk so consumers see tokens as they arrive
|
|
453
|
-
// instead of waiting for the full LLM call to finish. Non-terminal
|
|
454
|
-
// chunks can carry thinking, visible text, or both. The
|
|
455
|
-
// terminal chunk SHOULD carry the authoritative `LLMResponse`;
|
|
456
|
-
// when it doesn't (older providers, partial implementations) we
|
|
457
|
-
// fall back to `complete()` for the authoritative payload —
|
|
458
|
-
// keeping the ReAct loop deterministic.
|
|
459
|
-
//
|
|
460
|
-
// `singleProviderCall` is the per-attempt call function. Used
|
|
461
|
-
// directly when reliability is OFF; passed into `executeWithReliability`
|
|
462
|
-
// when reliability is configured (the helper invokes it once per
|
|
463
|
-
// retry-loop iteration).
|
|
464
|
-
//
|
|
465
|
-
// `providerHooks` is the resilience-report channel handed to the
|
|
466
|
-
// provider on every call. When `deps.provider` is decorated
|
|
467
|
-
// (withFallback / withRetry / withCircuitBreaker) its reports become
|
|
468
|
-
// in-run typed events with this stage's real runtimeStageId. Built
|
|
469
|
-
// once per stage — reused across reliability-loop
|
|
470
|
-
// iterations. Named to avoid shadowing `singleProviderCall`'s own
|
|
471
|
-
// `hooks` parameter, which is the unrelated `{ onFirstChunk }` bag.
|
|
472
|
-
const ordinaryProviderHooks = resilienceHooks(scope, deps.recordReceipt !== false, deps.onReplayPrepared);
|
|
473
|
-
const providerHooks = citations?.attach(ordinaryProviderHooks) ?? ordinaryProviderHooks;
|
|
474
|
-
const recall = deps.recallRequests === undefined
|
|
475
|
-
? undefined
|
|
476
|
-
: trackRecallRequests(systemPieces, committed, wireMessages, continuing?.historyPositions, systemPrompt);
|
|
477
|
-
let answeredBy = { provider: provider.name, model, native: false };
|
|
478
|
-
let localFallback = false;
|
|
479
|
-
let acceptedFindingsRequest;
|
|
480
|
-
const choice = deps.sourceConsultation;
|
|
481
|
-
let acceptedOffer;
|
|
482
|
-
const preserveReplay = deps.hasEvidenceRecovery === true ||
|
|
483
|
-
deps.hasFindingsLedger === true ||
|
|
484
|
-
tail.length > 0 ||
|
|
485
|
-
continuing !== undefined;
|
|
486
|
-
let acceptedProjection = false;
|
|
487
|
-
const issued = deps.findings === true ? issuedTicketsOf(scope.placedTickets) : undefined;
|
|
488
|
-
const capture = (req) => captureFindingsRequest(req, committed, iteration, issued);
|
|
489
|
-
// The run signal reaches the wire. See callLLM/README.md#dispatch-lifetime.
|
|
490
|
-
const runSignal = scope.$getEnv?.()?.signal;
|
|
491
|
-
const dispatchFor = providerDispatchFor(runSignal, deps.nativeOutputAuto === true, detached.outputFormat);
|
|
492
|
-
const singleProviderCall = async (req, hooks) => {
|
|
493
|
-
const selectedProvider = hooks.provider ?? provider;
|
|
494
|
-
req = dispatchFor.forAttempt(req, selectedProvider);
|
|
495
|
-
assertForcedRequestSupported(selectedProvider, req);
|
|
496
|
-
throwIfAborted(runSignal);
|
|
497
|
-
const attempts = replayAttempts(req, hooks.providerHooks ?? providerHooks);
|
|
498
|
-
let dispatch = describeProviderDispatch(selectedProvider, req);
|
|
499
|
-
let candidate = deps.findings === true ? capture(req) : undefined;
|
|
500
|
-
let offer = choice?.capture(scope, req, baseRequest);
|
|
501
|
-
let stableProjection = preserveReplay && sameReplayProjection(wireMessages, req.messages);
|
|
502
|
-
if (selectedProvider !== provider)
|
|
503
|
-
serving?.discard();
|
|
504
|
-
const selectionAttempt = selection?.attempt();
|
|
505
|
-
const ordinaryHooks = observeCallRequests(attempts.hooks, !selectionAttempt &&
|
|
506
|
-
serving === undefined &&
|
|
507
|
-
deps.findings !== true &&
|
|
508
|
-
!preserveReplay &&
|
|
509
|
-
choice === undefined
|
|
510
|
-
? undefined
|
|
511
|
-
: (request) => {
|
|
512
|
-
selectionAttempt?.observe(request);
|
|
513
|
-
serving?.beforeRequest(request);
|
|
514
|
-
if (deps.findings === true)
|
|
515
|
-
candidate = capture(request);
|
|
516
|
-
if (choice !== undefined)
|
|
517
|
-
offer = choice.capture(scope, request, baseRequest, offer);
|
|
518
|
-
if (preserveReplay)
|
|
519
|
-
stableProjection = sameReplayProjection(wireMessages, request.messages);
|
|
520
|
-
}, serving?.discard);
|
|
521
|
-
const attemptHooks = recall?.hooks(ordinaryHooks) ?? ordinaryHooks;
|
|
522
|
-
// THE STREAM CARRIES WHAT STANDS (9.114.2, `.findings()`): each chunk
|
|
523
|
-
// goes through the scanner the answer's peel uses, so a token never
|
|
524
|
-
// carries the model's `_findings` notes — not even when a chunk ends
|
|
525
|
-
// part way through the key — and the tokens join to exactly the text
|
|
526
|
-
// the run hands back. A fresh scanner per attempt; unarmed, the chunks
|
|
527
|
-
// go out as the provider sent them.
|
|
528
|
-
const shown = deps.suppressDraftTokens === true ? undefined : peel?.reservedMemberFilter();
|
|
529
|
-
const liveChunks = liveChunkEmitter(scope, runSignal, {
|
|
530
|
-
providerName: selectedProvider.name,
|
|
531
|
-
iteration,
|
|
532
|
-
suppressDraftTokens: deps.suppressDraftTokens === true,
|
|
533
|
-
allowHeldProviderSummary: deps.allowHeldProviderSummary === true,
|
|
534
|
-
textFilter: shown,
|
|
535
|
-
onFirstChunk: hooks.onFirstChunk,
|
|
536
|
-
});
|
|
537
|
-
let resp = await callObserved(selectedProvider, attempts.request, attemptHooks, runSignal, liveChunks, () => {
|
|
538
|
-
const completion = selectedProvider.stream
|
|
539
|
-
? dispatchFor.select(attempts.request, selectedProvider)
|
|
540
|
-
: attempts.request;
|
|
541
|
-
dispatch = describeProviderDispatch(selectedProvider, completion);
|
|
542
|
-
if (deps.findings === true)
|
|
543
|
-
candidate = capture(completion);
|
|
544
|
-
if (choice !== undefined)
|
|
545
|
-
offer = choice.capture(scope, completion, baseRequest);
|
|
546
|
-
if (preserveReplay)
|
|
547
|
-
stableProjection = sameReplayProjection(wireMessages, completion.messages);
|
|
548
|
-
return completion;
|
|
549
|
-
});
|
|
550
|
-
// An answer that arrived after the abort is not an answer: refused here,
|
|
551
|
-
// before the usage is counted, the turn committed or `llm_end` fired.
|
|
552
|
-
throwIfAborted(runSignal);
|
|
553
|
-
// `'tool-forced'`: the answer arrived as the synthetic tool's ARGUMENTS,
|
|
554
|
-
// so it is moved into `content` and the call is taken off the list here,
|
|
555
|
-
// at the single seam every later reader goes through. Everything
|
|
556
|
-
// downstream — the reliability validator, the scope writes, the Route
|
|
557
|
-
// decider, the retry loop — then sees the response it would have seen
|
|
558
|
-
// under `'instruct'`: a final answer that is a JSON string, and no tool
|
|
559
|
-
// calls. One normalization, no second code path, and nothing further
|
|
560
|
-
// down has to know which strategy is in force.
|
|
561
|
-
const forcedName = deps.schemaTool?.name;
|
|
562
|
-
if (forcedName !== undefined) {
|
|
563
|
-
const answer = readSchemaToolAnswer(resp);
|
|
564
|
-
if (answer !== undefined) {
|
|
565
|
-
resp = {
|
|
566
|
-
...resp,
|
|
567
|
-
content: answer,
|
|
568
|
-
toolCalls: resp.toolCalls.filter((tc) => tc.name !== forcedName),
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
const answered = hooks.providerIndex === undefined
|
|
573
|
-
? resp
|
|
574
|
-
: tagThinkingResponse(resp, String(hooks.providerIndex));
|
|
575
|
-
answeredBy = dispatch;
|
|
576
|
-
acceptedFindingsRequest = candidate;
|
|
577
|
-
acceptedOffer = offer;
|
|
578
|
-
acceptedProjection = stableProjection;
|
|
579
|
-
const result = attempts.response(answered);
|
|
580
|
-
selectionAttempt?.finish(result);
|
|
581
|
-
return result;
|
|
582
|
-
};
|
|
583
|
-
// v2.13 — build the output-schema validator hook when both
|
|
584
|
-
// reliability + outputSchemaParser are configured. The reliability
|
|
585
|
-
// loop applies the validator only on terminal turns (toolCalls
|
|
586
|
-
// empty) so tool-using turns aren't rejected for failing the final-
|
|
587
|
-
// answer schema. ValidationFailure carries `stage` + `path` for the
|
|
588
|
-
// typed event payload.
|
|
589
|
-
let postValidate;
|
|
590
|
-
if (deps.outputSchemaParser !== undefined) {
|
|
591
|
-
const parser = deps.outputSchemaParser;
|
|
592
|
-
postValidate = (response) => {
|
|
593
|
-
try {
|
|
594
|
-
// Judged with the reserved answer key peeled under the arm
|
|
595
|
-
// (9.101.0): this runs BEFORE the route decider's own peel, and a
|
|
596
|
-
// strict schema must see the answer the model meant, not the
|
|
597
|
-
// envelope its standings rode in on. Unarmed: the content itself.
|
|
598
|
-
applyOutputSchema(peel !== undefined
|
|
599
|
-
? peel.peelAnswerFindings(response.content).content
|
|
600
|
-
: response.content, parser);
|
|
601
|
-
}
|
|
602
|
-
catch (err) {
|
|
603
|
-
// applyOutputSchema throws OutputSchemaError with
|
|
604
|
-
// {stage, rawOutput, cause}. Convert to ValidationFailure for
|
|
605
|
-
// the gate's typed handling. Pull a `path` if the underlying
|
|
606
|
-
// cause exposes Zod-style issues. Use the cause's message
|
|
607
|
-
// (the actual parser error) when available, falling back to
|
|
608
|
-
// the wrapper's message for parsers without a cause.
|
|
609
|
-
const e = err;
|
|
610
|
-
let path;
|
|
611
|
-
const firstIssue = e.cause?.issues?.[0];
|
|
612
|
-
if (firstIssue?.path && firstIssue.path.length > 0) {
|
|
613
|
-
path = firstIssue.path.join('.');
|
|
614
|
-
}
|
|
615
|
-
// Use cause message when present (parsers like Zod attach the
|
|
616
|
-
// real error as cause); fall back to wrapper message.
|
|
617
|
-
const message = e.cause?.message ?? e.message;
|
|
618
|
-
throw new ValidationFailure({
|
|
619
|
-
message,
|
|
620
|
-
stage: e.stage ?? 'schema-validate',
|
|
621
|
-
...(path !== undefined && { path }),
|
|
622
|
-
...(e.rawOutput !== undefined && { rawOutput: e.rawOutput }),
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
let response;
|
|
628
|
-
if (deps.reliability) {
|
|
629
|
-
response = await executeWithReliability(scope, llmRequest, deps.reliability, provider, provider.name, model, singleProviderCall, postValidate, {
|
|
630
|
-
...(deps.withholdDraftContent === true && { withholdDraftContent: true }),
|
|
631
|
-
providerHooks,
|
|
632
|
-
prepareFallback: (request) => {
|
|
633
|
-
serving?.discard();
|
|
634
|
-
const witness = deps.findings === true ? capture(request) : undefined;
|
|
635
|
-
return () => {
|
|
636
|
-
// A local answer does not inherit the replaced provider's stop reason
|
|
637
|
-
// or native generation. The callback may return arbitrary text.
|
|
638
|
-
localFallback = true;
|
|
639
|
-
acceptedFindingsRequest = witness;
|
|
640
|
-
};
|
|
641
|
-
},
|
|
642
|
-
...(deps.outputFormat !== undefined && {
|
|
643
|
-
isTerminalRefusal: (response) => answeredBy.native && response.stopReason === 'refusal',
|
|
644
|
-
}),
|
|
645
|
-
});
|
|
646
|
-
// `executeWithReliability` returns `undefined` when it took the
|
|
647
|
-
// fail-fast path. It already wrote scope state and called
|
|
648
|
-
// `$break(reason)` — `Agent.run()` translates the propagated
|
|
649
|
-
// break into a `ReliabilityFailFastError` at the API boundary.
|
|
650
|
-
// File the incomplete request when armed. There is no response to commit.
|
|
651
|
-
if (response === undefined) {
|
|
652
|
-
if (recall !== undefined)
|
|
653
|
-
deps.recallRequests?.(scope, iteration, recall.summary('incomplete'));
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
response = await singleProviderCall(llmRequest, {});
|
|
659
|
-
}
|
|
660
|
-
// Preserve the pending carrier if the provider fails, so crash recovery
|
|
661
|
-
// retries the same instruction. The prior committed value proves delivery.
|
|
662
|
-
if (recoveryPiece !== undefined)
|
|
663
|
-
scope.evidenceRecoveryUsed = true;
|
|
664
|
-
const durationMs = Date.now() - startMs;
|
|
665
|
-
scope.totalInputTokens = scope.totalInputTokens + response.usage.input;
|
|
666
|
-
scope.totalOutputTokens = scope.totalOutputTokens + response.usage.output;
|
|
667
|
-
// Cache reads as a cost (9.110.0) — VALUE-conditional: the key exists
|
|
668
|
-
// only once a provider has reported one, so a provider that reports
|
|
669
|
-
// none (the mock, a local model) writes nothing and keeps its bytes.
|
|
670
|
-
if (typeof response.usage.cacheRead === 'number') {
|
|
671
|
-
scope.totalCacheReadTokens = (scope.totalCacheReadTokens ?? 0) + response.usage.cacheRead;
|
|
672
|
-
}
|
|
673
|
-
const acceptedToolCalls = commitAcceptedResponse(scope, deps, response, serving, {
|
|
674
|
-
localFallback,
|
|
675
|
-
answeredBy,
|
|
676
|
-
findingsRequest: acceptedFindingsRequest,
|
|
677
|
-
citationOffer: citations?.accepted(response),
|
|
678
|
-
sourceOffer: acceptedOffer,
|
|
679
|
-
iteration,
|
|
680
|
-
recall: recall?.summary(localFallback ? 'local' : 'provider'),
|
|
681
|
-
});
|
|
682
|
-
// A response owns its replay evidence, never the previous response's.
|
|
683
|
-
// The presence trap does not record a read on never-replay providers.
|
|
684
|
-
if (response.replay !== undefined || 'llmLatestReplay' in scope) {
|
|
685
|
-
scope.llmLatestReplay = response.replay === undefined ? undefined : [response.replay];
|
|
686
|
-
}
|
|
687
|
-
const nextReplay = !localFallback && acceptedProjection
|
|
688
|
-
? afterReplayResponse(response, continuing === undefined ? [] : replayFrames ?? [], (replay) => captureReplayPrefix(replay, history, messages, tail, continuing?.frozenBefore ?? 0), deps.toolsOffAfterRevision === true)
|
|
689
|
-
: undefined;
|
|
690
|
-
if (nextReplay !== undefined || replayFrames !== undefined)
|
|
691
|
-
writeRequestReplay(scope, nextReplay);
|
|
692
|
-
// v2.14 — hand provider-specific raw thinking data to the
|
|
693
|
-
// NormalizeThinking sub-subflow (the next stage in sf-call-llm
|
|
694
|
-
// when a ThinkingHandler is configured). Undefined when the
|
|
695
|
-
// provider has no thinking content for this call (most calls).
|
|
696
|
-
if (response.rawThinking !== undefined || 'rawThinking' in scope) {
|
|
697
|
-
scope.rawThinking =
|
|
698
|
-
response.rawThinking;
|
|
699
|
-
}
|
|
700
|
-
typedEmit(scope, 'agentfootprint.stream.llm_end', {
|
|
701
|
-
iteration,
|
|
702
|
-
// Under the arm, the content as the stream showed it (9.114.2) — the
|
|
703
|
-
// committed `llmLatestContent` below keeps what the model sent.
|
|
704
|
-
content: deps.withholdDraftContent === true
|
|
705
|
-
? ''
|
|
706
|
-
: peel !== undefined
|
|
707
|
-
? peel.withoutReservedMembers(response.content).text
|
|
708
|
-
: response.content,
|
|
709
|
-
...(deps.withholdDraftContent === true && { contentWithheld: true }),
|
|
710
|
-
toolCallCount: response.toolCalls.length,
|
|
711
|
-
usage: response.usage,
|
|
712
|
-
stopReason: response.stopReason,
|
|
713
|
-
durationMs,
|
|
714
|
-
});
|
|
715
|
-
recordWireFindings(scope, llmRequest, response, answeredBy, iteration, deps);
|
|
716
|
-
// THE CHOICE SEAM (9.63.0, unsupported-argument). The wire check above
|
|
717
|
-
// asks what the library put in front of the model; this asks what the
|
|
718
|
-
// model did with it. For every call to an ARMED tool (one whose author
|
|
719
|
-
// declared `argumentsFrom`), each identifier-like string argument must
|
|
720
|
-
// appear somewhere in the frame this very call was assembled from.
|
|
721
|
-
//
|
|
722
|
-
// THE CORPUS IS SPLIT, and the split is the whole check. The system
|
|
723
|
-
// prompt, every user message and every tool result are things the RUN
|
|
724
|
-
// served. The assistant turns are things the MODEL wrote — deliberately
|
|
725
|
-
// not ground, because a value whose only source is the model's own
|
|
726
|
-
// rendered prose has been re-derived from a rendering instead of read
|
|
727
|
-
// from evidence. That is the recorded failure exactly: a truncated job
|
|
728
|
-
// name mined out of a prior answer, passed as a machine name, answered
|
|
729
|
-
// with an honest "nothing found", reported to a person as fact.
|
|
730
|
-
//
|
|
731
|
-
// `llmRequest` is the frame — the object handed to the adapter, after the
|
|
732
|
-
// cache strategy's transform — so the check judges the choice against
|
|
733
|
-
// what the model actually saw, never against scope history it did not.
|
|
734
|
-
if (deps.toolGrounding !== undefined && deps.toolGrounding.size > 0) {
|
|
735
|
-
const grounding = deps.toolGrounding;
|
|
736
|
-
const armedCalls = acceptedToolCalls.filter((c) => grounding.has(c.name));
|
|
737
|
-
if (armedCalls.length > 0) {
|
|
738
|
-
const schemaOf = new Map((llmRequest.tools ?? []).map((t) => [t.name, t.inputSchema]));
|
|
739
|
-
const frameMessages = llmRequest.messages;
|
|
740
|
-
// THE EXTERNAL-GROUND DOOR (9.72.0). The app may vouch for values the
|
|
741
|
-
// run never served — a human clicked a row, the app verified the
|
|
742
|
-
// clicked cells against the artifact the panel renders — and those
|
|
743
|
-
// entries join the grounded corpus for THIS response only, consulted
|
|
744
|
-
// fresh each time because the selection moves between turns. The
|
|
745
|
-
// library records what the app asserts; the source label rides every
|
|
746
|
-
// excusal so a reader can audit the chain.
|
|
747
|
-
const external = readExternalGrounds(deps.externalGrounds);
|
|
748
|
-
const { findings: argumentFindings, externalGroundings, occurrences, } = unsupportedArgumentsOf(armedCalls.map((c) => ({
|
|
749
|
-
toolName: c.name,
|
|
750
|
-
toolCallId: c.id,
|
|
751
|
-
...callOccurrenceField(c.callOccurrenceKey),
|
|
752
|
-
// Peel the model's `_findings` metadata before reading argument
|
|
753
|
-
// leaves. Grounded registry tools reserve that key. With sources
|
|
754
|
-
// alone, only ruled tools advertise it in their served schemas.
|
|
755
|
-
args: deps.findings === true ||
|
|
756
|
-
(deps.argumentSources === true && carriesFindingsDecoration(schemaOf.get(c.name)))
|
|
757
|
-
? splitFindings(c.args).args
|
|
758
|
-
: c.args,
|
|
759
|
-
argumentsFrom: grounding.get(c.name) ?? [],
|
|
760
|
-
// The enum fence reads the schema WITHOUT the decoration: the
|
|
761
|
-
// reserved words (`direct`, `fact`, `noise`, `user`, …) are the
|
|
762
|
-
// model's vocabulary for a declaration, never an excuse for an
|
|
763
|
-
// argument.
|
|
764
|
-
declaredEnums: declaredEnumValuesOf(deps.findings === true || deps.argumentSources === true
|
|
765
|
-
? withoutFindingsArgument(schemaOf.get(c.name))
|
|
766
|
-
: schemaOf.get(c.name)),
|
|
767
|
-
})), {
|
|
768
|
-
grounded: [
|
|
769
|
-
// The recovery piece quotes the model's words; only the trusted
|
|
770
|
-
// system injections count as grounds when that piece is present.
|
|
771
|
-
// Findings DATA is a request-only message after history.
|
|
772
|
-
...(systemRecovery === undefined
|
|
773
|
-
? llmRequest.systemPrompt === undefined
|
|
774
|
-
? []
|
|
775
|
-
: [llmRequest.systemPrompt]
|
|
776
|
-
: // A cache strategy can rewrite the request. If it rewrote
|
|
777
|
-
// this mixed-trust system slot, its provenance is unknown;
|
|
778
|
-
// never credit either the rejected draft or an unsent base.
|
|
779
|
-
llmRequest.systemPrompt === systemPrompt
|
|
780
|
-
? [trustedSystemPrompt]
|
|
781
|
-
: []),
|
|
782
|
-
// Every tool result as the TOOL's own bytes — the inputs layer's note
|
|
783
|
-
// after a filled call's result is the library's words (`groundedTextOf`).
|
|
784
|
-
...groundedTextOf(frameMessages, committed, continuing?.historyPositions),
|
|
785
|
-
],
|
|
786
|
-
assistant: frameMessages.filter((m) => m.role === 'assistant').map((m) => m.content),
|
|
787
|
-
...(external.length > 0 && { external }),
|
|
788
|
-
}, iteration);
|
|
789
|
-
deps.integrityLedger?.current?.note('unsupported-argument', 'choice', argumentFindings.length > 0 ? 'checked-fail' : 'checked-pass', argumentFindings.length > 0 ? Date.now() : undefined);
|
|
790
|
-
fileIntegrityFindings(scope, argumentFindings, iteration, deps.integrityLedger, (finding) => occurrences.get(finding));
|
|
791
|
-
// Each excusal is a per-attempt fact and rides the emit channel —
|
|
792
|
-
// deliberately NOT deduplicated the way findings are: a repeated call
|
|
793
|
-
// is a fresh choice, and each excusal names the assertion that stood
|
|
794
|
-
// between that choice and a finding.
|
|
795
|
-
for (const g of externalGroundings) {
|
|
796
|
-
typedEmit(scope, 'agentfootprint.integrity.external_ground_used', {
|
|
797
|
-
toolName: g.toolName,
|
|
798
|
-
toolCallId: g.toolCallId,
|
|
799
|
-
path: g.path,
|
|
800
|
-
value: g.value,
|
|
801
|
-
source: g.source,
|
|
802
|
-
iteration,
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
// No armed tool was called this turn — a response with nothing this
|
|
808
|
-
// check could be about. Stated, never silence.
|
|
809
|
-
deps.integrityLedger?.current?.note('unsupported-argument', 'choice', 'not-applicable');
|
|
810
|
-
}
|
|
811
|
-
// THE WRITE SEAM'S other half (9.77.0). `empty-lookup` is judged where
|
|
812
|
-
// the RESULT is — the tool-dispatch boundary — but a response that
|
|
813
|
-
// asked for no armed tool can never produce an armed result, and that
|
|
814
|
-
// is decidable here, at the one stage every iteration passes through.
|
|
815
|
-
// Saying it out loud is what keeps an armed row from sitting untouched
|
|
816
|
-
// through a run that simply never called a declaring tool: a
|
|
817
|
-
// not-applicable row is an answer, and an untouched one reads as rot.
|
|
818
|
-
if (deps.noticeEmptyLookups === true && armedCalls.length === 0) {
|
|
819
|
-
deps.integrityLedger?.current?.note('empty-lookup', 'write', 'not-applicable');
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
// Column checks arm independently of argumentsFrom. Results are judged at
|
|
823
|
-
// write; here, a response with no currently declaring call states NA in
|
|
824
|
-
// both rows. An opaque provider still owes this note when its set is empty.
|
|
825
|
-
// A function observes declarations after this iteration's actual discovery.
|
|
826
|
-
if (deps.columnDeclaringTools !== undefined) {
|
|
827
|
-
const declaring = typeof deps.columnDeclaringTools === 'function'
|
|
828
|
-
? deps.columnDeclaringTools(response.toolCalls.map((call) => call.name))
|
|
829
|
-
: deps.columnDeclaringTools;
|
|
830
|
-
if (!response.toolCalls.some((c) => declaring.has(c.name))) {
|
|
831
|
-
deps.integrityLedger?.current?.note('column-type-mismatch', 'write', 'not-applicable');
|
|
832
|
-
deps.integrityLedger?.current?.note('missing-column', 'write', 'not-applicable');
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
if (deps.toolChoice === true) {
|
|
836
|
-
// `import()` — the optional-family law of docs-next's site budget (the
|
|
837
|
-
// `toolCalls/evidence/judgeLanded.ts · judgeLanded` precedent): an unarmed agent never loads
|
|
838
|
-
// the module; the slot loads the same one under the same gate.
|
|
839
|
-
const { recordToolChoiceOutcome } = await import('../toolChoice/record.js');
|
|
840
|
-
recordToolChoiceOutcome(scope, response, iteration);
|
|
841
|
-
}
|
|
842
|
-
// Attribute the successful response to its actual selected transport/model.
|
|
843
|
-
emitCostTick(scope, deps.pricingTable, deps.costBudget, answeredBy, response.usage);
|
|
844
|
-
const selected = localFallback ? undefined : selection?.accept(response);
|
|
845
|
-
if (selected && deps.servedTools && deps.canRecordToolSelection?.())
|
|
846
|
-
recordToolSelection(scope, selected, deps.servedTools, choice);
|
|
45
|
+
const prepared = await prepareCall(scope, deps);
|
|
46
|
+
const executed = await executeCall(scope, deps, prepared);
|
|
47
|
+
if (executed === undefined)
|
|
48
|
+
return;
|
|
49
|
+
if (admitProviderIntervention(scope, executed.response, () => recordTerminalResponse(scope, deps, prepared, executed)))
|
|
50
|
+
return;
|
|
51
|
+
await acceptResponse(scope, deps, prepared, executed);
|
|
847
52
|
};
|
|
848
53
|
}
|
|
849
54
|
//# sourceMappingURL=callLLM.js.map
|