agentfootprint 10.4.0 → 10.5.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.
Files changed (519) hide show
  1. package/CAPABILITIES.md +6 -1
  2. package/ai-instructions/clinerules +22 -11
  3. package/ai-instructions/copilot-instructions.md +22 -11
  4. package/ai-instructions/cursor/agentfootprint.md +22 -11
  5. package/ai-instructions/kiro/agentfootprint.md +22 -11
  6. package/ai-instructions/windsurfrules +22 -11
  7. package/dist/adapters/llm/AnthropicProvider.js +26 -8
  8. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  9. package/dist/adapters/llm/BedrockProvider.js +23 -7
  10. package/dist/adapters/llm/BedrockProvider.js.map +1 -1
  11. package/dist/adapters/llm/BrowserAnthropicProvider.js +57 -49
  12. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  13. package/dist/adapters/llm/BrowserOpenAIProvider.js +50 -42
  14. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  15. package/dist/adapters/llm/FoundryLocalProvider.js +174 -212
  16. package/dist/adapters/llm/FoundryLocalProvider.js.map +1 -1
  17. package/dist/adapters/llm/GeminiProvider.js +23 -9
  18. package/dist/adapters/llm/GeminiProvider.js.map +1 -1
  19. package/dist/adapters/llm/InvokeModelGatewayProvider.js +32 -9
  20. package/dist/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  21. package/dist/adapters/llm/MockProvider.js +11 -3
  22. package/dist/adapters/llm/MockProvider.js.map +1 -1
  23. package/dist/adapters/llm/OllamaProvider.js +129 -167
  24. package/dist/adapters/llm/OllamaProvider.js.map +1 -1
  25. package/dist/adapters/llm/OpenAIProvider.js +36 -9
  26. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  27. package/dist/adapters/mcp/agentcoreRuntime/invoke.js +15 -8
  28. package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  29. package/dist/adapters/mcp/agentcoreRuntime/transport.js +21 -3
  30. package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  31. package/dist/ag-ui/adapter.js +69 -14
  32. package/dist/ag-ui/adapter.js.map +1 -1
  33. package/dist/ag-ui/framing.js +3 -1
  34. package/dist/ag-ui/framing.js.map +1 -1
  35. package/dist/ag-ui/index.js +4 -2
  36. package/dist/ag-ui/index.js.map +1 -1
  37. package/dist/ag-ui/request.js +66 -6
  38. package/dist/ag-ui/request.js.map +1 -1
  39. package/dist/answer-validation/index.js +8 -1
  40. package/dist/answer-validation/index.js.map +1 -1
  41. package/dist/answer-validation/toolLedger.js +130 -0
  42. package/dist/answer-validation/toolLedger.js.map +1 -0
  43. package/dist/answer-validation/types.js.map +1 -1
  44. package/dist/answer-validation/validate.js +25 -3
  45. package/dist/answer-validation/validate.js.map +1 -1
  46. package/dist/classify/typesafe.js +31 -23
  47. package/dist/classify/typesafe.js.map +1 -1
  48. package/dist/core/Agent.js +69 -16
  49. package/dist/core/Agent.js.map +1 -1
  50. package/dist/core/LLMCall.js +16 -6
  51. package/dist/core/LLMCall.js.map +1 -1
  52. package/dist/core/RunnerBase.js +83 -11
  53. package/dist/core/RunnerBase.js.map +1 -1
  54. package/dist/core/agent/buildAgentChart.js +16 -8
  55. package/dist/core/agent/buildAgentChart.js.map +1 -1
  56. package/dist/core/agent/buildAgentMessageApiChart.js +22 -2
  57. package/dist/core/agent/buildAgentMessageApiChart.js.map +1 -1
  58. package/dist/core/agent/buildDynamicAgentChart.js +22 -7
  59. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  60. package/dist/core/agent/buildMessageApiChart.js +22 -2
  61. package/dist/core/agent/buildMessageApiChart.js.map +1 -1
  62. package/dist/core/agent/stages/answerValidation.js +22 -1
  63. package/dist/core/agent/stages/answerValidation.js.map +1 -1
  64. package/dist/core/agent/stages/callLLM.js +19 -3
  65. package/dist/core/agent/stages/callLLM.js.map +1 -1
  66. package/dist/core/agent/stages/routeTurn.js +14 -1
  67. package/dist/core/agent/stages/routeTurn.js.map +1 -1
  68. package/dist/core/agent/stages/seed.js +9 -0
  69. package/dist/core/agent/stages/seed.js.map +1 -1
  70. package/dist/core/agent/stages/toolCalls.js +59 -20
  71. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  72. package/dist/core/agent/window/strategies/summarizeOldest.js +4 -0
  73. package/dist/core/agent/window/strategies/summarizeOldest.js.map +1 -1
  74. package/dist/core/agent/window/summarize.js +6 -3
  75. package/dist/core/agent/window/summarize.js.map +1 -1
  76. package/dist/core/memberRun.js +58 -9
  77. package/dist/core/memberRun.js.map +1 -1
  78. package/dist/core/requestOfRun.js +28 -0
  79. package/dist/core/requestOfRun.js.map +1 -0
  80. package/dist/core/slots/buildToolsSlot.js +11 -25
  81. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  82. package/dist/core-flow/Conditional.js +17 -11
  83. package/dist/core-flow/Conditional.js.map +1 -1
  84. package/dist/core-flow/Graph.js +17 -11
  85. package/dist/core-flow/Graph.js.map +1 -1
  86. package/dist/core-flow/Loop.js +17 -11
  87. package/dist/core-flow/Loop.js.map +1 -1
  88. package/dist/core-flow/Parallel.js +25 -14
  89. package/dist/core-flow/Parallel.js.map +1 -1
  90. package/dist/core-flow/Sequence.js +17 -11
  91. package/dist/core-flow/Sequence.js.map +1 -1
  92. package/dist/core-flow/Workflow.js +17 -11
  93. package/dist/core-flow/Workflow.js.map +1 -1
  94. package/dist/doors/security.js +2 -1
  95. package/dist/doors/security.js.map +1 -1
  96. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +9 -2
  97. package/dist/esm/adapters/llm/AnthropicProvider.js +26 -8
  98. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  99. package/dist/esm/adapters/llm/BedrockProvider.d.ts +6 -1
  100. package/dist/esm/adapters/llm/BedrockProvider.js +23 -7
  101. package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
  102. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +57 -49
  103. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  104. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +50 -42
  105. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  106. package/dist/esm/adapters/llm/FoundryLocalProvider.js +171 -209
  107. package/dist/esm/adapters/llm/FoundryLocalProvider.js.map +1 -1
  108. package/dist/esm/adapters/llm/GeminiProvider.js +23 -9
  109. package/dist/esm/adapters/llm/GeminiProvider.js.map +1 -1
  110. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js +32 -9
  111. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  112. package/dist/esm/adapters/llm/MockProvider.js +11 -3
  113. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  114. package/dist/esm/adapters/llm/OllamaProvider.js +126 -164
  115. package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -1
  116. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +6 -1
  117. package/dist/esm/adapters/llm/OpenAIProvider.js +36 -9
  118. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  119. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +1 -1
  120. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +15 -8
  121. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  122. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.d.ts +26 -3
  123. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +21 -3
  124. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  125. package/dist/esm/ag-ui/adapter.d.ts +61 -11
  126. package/dist/esm/ag-ui/adapter.js +70 -15
  127. package/dist/esm/ag-ui/adapter.js.map +1 -1
  128. package/dist/esm/ag-ui/framing.d.ts +2 -1
  129. package/dist/esm/ag-ui/framing.js +3 -1
  130. package/dist/esm/ag-ui/framing.js.map +1 -1
  131. package/dist/esm/ag-ui/index.d.ts +6 -4
  132. package/dist/esm/ag-ui/index.js +6 -4
  133. package/dist/esm/ag-ui/index.js.map +1 -1
  134. package/dist/esm/ag-ui/request.d.ts +86 -7
  135. package/dist/esm/ag-ui/request.js +63 -5
  136. package/dist/esm/ag-ui/request.js.map +1 -1
  137. package/dist/esm/answer-validation/index.d.ts +2 -1
  138. package/dist/esm/answer-validation/index.js +1 -0
  139. package/dist/esm/answer-validation/index.js.map +1 -1
  140. package/dist/esm/answer-validation/toolLedger.d.ts +65 -0
  141. package/dist/esm/answer-validation/toolLedger.js +121 -0
  142. package/dist/esm/answer-validation/toolLedger.js.map +1 -0
  143. package/dist/esm/answer-validation/types.d.ts +48 -0
  144. package/dist/esm/answer-validation/types.js.map +1 -1
  145. package/dist/esm/answer-validation/validate.d.ts +2 -2
  146. package/dist/esm/answer-validation/validate.js +25 -3
  147. package/dist/esm/answer-validation/validate.js.map +1 -1
  148. package/dist/esm/classify/typesafe.js +30 -22
  149. package/dist/esm/classify/typesafe.js.map +1 -1
  150. package/dist/esm/core/Agent.d.ts +9 -1
  151. package/dist/esm/core/Agent.js +71 -18
  152. package/dist/esm/core/Agent.js.map +1 -1
  153. package/dist/esm/core/LLMCall.d.ts +2 -1
  154. package/dist/esm/core/LLMCall.js +17 -7
  155. package/dist/esm/core/LLMCall.js.map +1 -1
  156. package/dist/esm/core/RunnerBase.d.ts +39 -8
  157. package/dist/esm/core/RunnerBase.js +80 -9
  158. package/dist/esm/core/RunnerBase.js.map +1 -1
  159. package/dist/esm/core/agent/buildAgentChart.js +16 -8
  160. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  161. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +16 -0
  162. package/dist/esm/core/agent/buildAgentMessageApiChart.js +22 -2
  163. package/dist/esm/core/agent/buildAgentMessageApiChart.js.map +1 -1
  164. package/dist/esm/core/agent/buildDynamicAgentChart.js +22 -7
  165. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  166. package/dist/esm/core/agent/buildMessageApiChart.d.ts +16 -0
  167. package/dist/esm/core/agent/buildMessageApiChart.js +22 -2
  168. package/dist/esm/core/agent/buildMessageApiChart.js.map +1 -1
  169. package/dist/esm/core/agent/stages/answerValidation.js +22 -1
  170. package/dist/esm/core/agent/stages/answerValidation.js.map +1 -1
  171. package/dist/esm/core/agent/stages/callLLM.js +19 -3
  172. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  173. package/dist/esm/core/agent/stages/routeTurn.js +14 -1
  174. package/dist/esm/core/agent/stages/routeTurn.js.map +1 -1
  175. package/dist/esm/core/agent/stages/seed.d.ts +7 -0
  176. package/dist/esm/core/agent/stages/seed.js +9 -0
  177. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  178. package/dist/esm/core/agent/stages/toolCalls.d.ts +21 -0
  179. package/dist/esm/core/agent/stages/toolCalls.js +59 -20
  180. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  181. package/dist/esm/core/agent/types.d.ts +10 -0
  182. package/dist/esm/core/agent/window/strategies/summarizeOldest.js +4 -0
  183. package/dist/esm/core/agent/window/strategies/summarizeOldest.js.map +1 -1
  184. package/dist/esm/core/agent/window/summarize.js +6 -3
  185. package/dist/esm/core/agent/window/summarize.js.map +1 -1
  186. package/dist/esm/core/memberRun.d.ts +23 -2
  187. package/dist/esm/core/memberRun.js +54 -8
  188. package/dist/esm/core/memberRun.js.map +1 -1
  189. package/dist/esm/core/requestOfRun.d.ts +21 -0
  190. package/dist/esm/core/requestOfRun.js +24 -0
  191. package/dist/esm/core/requestOfRun.js.map +1 -0
  192. package/dist/esm/core/runner.d.ts +15 -3
  193. package/dist/esm/core/slots/buildToolsSlot.d.ts +0 -16
  194. package/dist/esm/core/slots/buildToolsSlot.js +11 -25
  195. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  196. package/dist/esm/core-flow/Conditional.d.ts +2 -1
  197. package/dist/esm/core-flow/Conditional.js +18 -12
  198. package/dist/esm/core-flow/Conditional.js.map +1 -1
  199. package/dist/esm/core-flow/Graph.d.ts +2 -1
  200. package/dist/esm/core-flow/Graph.js +18 -12
  201. package/dist/esm/core-flow/Graph.js.map +1 -1
  202. package/dist/esm/core-flow/Loop.d.ts +2 -1
  203. package/dist/esm/core-flow/Loop.js +18 -12
  204. package/dist/esm/core-flow/Loop.js.map +1 -1
  205. package/dist/esm/core-flow/Parallel.d.ts +2 -1
  206. package/dist/esm/core-flow/Parallel.js +26 -15
  207. package/dist/esm/core-flow/Parallel.js.map +1 -1
  208. package/dist/esm/core-flow/Sequence.d.ts +2 -1
  209. package/dist/esm/core-flow/Sequence.js +18 -12
  210. package/dist/esm/core-flow/Sequence.js.map +1 -1
  211. package/dist/esm/core-flow/Workflow.d.ts +2 -1
  212. package/dist/esm/core-flow/Workflow.js +18 -12
  213. package/dist/esm/core-flow/Workflow.js.map +1 -1
  214. package/dist/esm/doors/security.d.ts +2 -1
  215. package/dist/esm/doors/security.js +2 -1
  216. package/dist/esm/doors/security.js.map +1 -1
  217. package/dist/esm/events/payloads.d.ts +4 -2
  218. package/dist/esm/hosting/index.d.ts +1 -0
  219. package/dist/esm/hosting/index.js.map +1 -1
  220. package/dist/esm/hosting/protocolAdapter.d.ts +4 -1
  221. package/dist/esm/hosting/refusalStatus.js +4 -0
  222. package/dist/esm/hosting/refusalStatus.js.map +1 -1
  223. package/dist/esm/hosting/requestSealing.d.ts +65 -0
  224. package/dist/esm/hosting/requestSealing.js +79 -0
  225. package/dist/esm/hosting/requestSealing.js.map +1 -0
  226. package/dist/esm/hosting/standingAgent.js +23 -3
  227. package/dist/esm/hosting/standingAgent.js.map +1 -1
  228. package/dist/esm/hosting/stream.d.ts +23 -2
  229. package/dist/esm/hosting/stream.js +5 -1
  230. package/dist/esm/hosting/stream.js.map +1 -1
  231. package/dist/esm/hosting/streamHandler.d.ts +26 -7
  232. package/dist/esm/hosting/streamHandler.js +36 -12
  233. package/dist/esm/hosting/streamHandler.js.map +1 -1
  234. package/dist/esm/hosting/types.d.ts +29 -0
  235. package/dist/esm/hosting/types.js.map +1 -1
  236. package/dist/esm/identity/requestContext.d.ts +96 -0
  237. package/dist/esm/identity/requestContext.js +131 -0
  238. package/dist/esm/identity/requestContext.js.map +1 -0
  239. package/dist/esm/identity/requestCredentials.d.ts +99 -0
  240. package/dist/esm/identity/requestCredentials.js +157 -0
  241. package/dist/esm/identity/requestCredentials.js.map +1 -0
  242. package/dist/esm/identity/types.d.ts +11 -0
  243. package/dist/esm/identity/types.js.map +1 -1
  244. package/dist/esm/identity.d.ts +2 -0
  245. package/dist/esm/identity.js +5 -0
  246. package/dist/esm/identity.js.map +1 -1
  247. package/dist/esm/index.d.ts +3 -2
  248. package/dist/esm/index.js +5 -1
  249. package/dist/esm/index.js.map +1 -1
  250. package/dist/esm/injection-engine/buildInjectionEngineSubflow.d.ts +11 -0
  251. package/dist/esm/injection-engine/buildInjectionEngineSubflow.js +39 -5
  252. package/dist/esm/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  253. package/dist/esm/injection-engine/constrainedEnumPick.js +4 -2
  254. package/dist/esm/injection-engine/constrainedEnumPick.js.map +1 -1
  255. package/dist/esm/injection-engine/evaluator.d.ts +6 -0
  256. package/dist/esm/injection-engine/evaluator.js +19 -1
  257. package/dist/esm/injection-engine/evaluator.js.map +1 -1
  258. package/dist/esm/injection-engine/skillGraph.js +26 -8
  259. package/dist/esm/injection-engine/skillGraph.js.map +1 -1
  260. package/dist/esm/injection-engine/skillIntent.d.ts +4 -2
  261. package/dist/esm/injection-engine/skillIntent.js +3 -0
  262. package/dist/esm/injection-engine/skillIntent.js.map +1 -1
  263. package/dist/esm/injection-engine/types.d.ts +27 -1
  264. package/dist/esm/injection-engine/types.js +15 -0
  265. package/dist/esm/injection-engine/types.js.map +1 -1
  266. package/dist/esm/lib/abort.d.ts +143 -0
  267. package/dist/esm/lib/abort.js +322 -0
  268. package/dist/esm/lib/abort.js.map +1 -0
  269. package/dist/esm/maps/engagement/parkCard.d.ts +5 -1
  270. package/dist/esm/maps/engagement/parkCard.js +10 -3
  271. package/dist/esm/maps/engagement/parkCard.js.map +1 -1
  272. package/dist/esm/mcp/mcpClient.js +30 -2
  273. package/dist/esm/mcp/mcpClient.js.map +1 -1
  274. package/dist/esm/mcp/mcpServe.js +5 -1
  275. package/dist/esm/mcp/mcpServe.js.map +1 -1
  276. package/dist/esm/mcp/plainData.d.ts +44 -0
  277. package/dist/esm/mcp/plainData.js +204 -0
  278. package/dist/esm/mcp/plainData.js.map +1 -0
  279. package/dist/esm/mcp/sdkLoadFailure.d.ts +6 -7
  280. package/dist/esm/mcp/sdkLoadFailure.js +4 -4
  281. package/dist/esm/mcp/sdkLoadFailure.js.map +1 -1
  282. package/dist/esm/mcp/toolResult.js +8 -50
  283. package/dist/esm/mcp/toolResult.js.map +1 -1
  284. package/dist/esm/mcp/types.d.ts +10 -6
  285. package/dist/esm/memory/beats/llmExtractor.js +6 -3
  286. package/dist/esm/memory/beats/llmExtractor.js.map +1 -1
  287. package/dist/esm/memory/facts/llmFactExtractor.js +6 -3
  288. package/dist/esm/memory/facts/llmFactExtractor.js.map +1 -1
  289. package/dist/esm/memory/stages/summarize.js +16 -5
  290. package/dist/esm/memory/stages/summarize.js.map +1 -1
  291. package/dist/esm/patterns/LlmRouter.js +10 -5
  292. package/dist/esm/patterns/LlmRouter.js.map +1 -1
  293. package/dist/esm/redaction/conversation.js +3 -0
  294. package/dist/esm/redaction/conversation.js.map +1 -1
  295. package/dist/esm/redaction/knownStrings.js +1 -0
  296. package/dist/esm/redaction/knownStrings.js.map +1 -1
  297. package/dist/esm/reliability/buildReliabilityGateChart.js +7 -1
  298. package/dist/esm/reliability/buildReliabilityGateChart.js.map +1 -1
  299. package/dist/esm/resilience/withCircuitBreaker.js +5 -2
  300. package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
  301. package/dist/esm/resilience/withFallback.js +6 -0
  302. package/dist/esm/resilience/withFallback.js.map +1 -1
  303. package/dist/esm/resilience/withRetry.js +5 -0
  304. package/dist/esm/resilience/withRetry.js.map +1 -1
  305. package/dist/esm/time-travel/servedView.js +1 -1
  306. package/dist/esm/time-travel/servedView.js.map +1 -1
  307. package/dist/esm/tools/hostFilled.d.ts +110 -0
  308. package/dist/esm/tools/hostFilled.js +509 -0
  309. package/dist/esm/tools/hostFilled.js.map +1 -0
  310. package/dist/hosting/index.js.map +1 -1
  311. package/dist/hosting/refusalStatus.js +4 -0
  312. package/dist/hosting/refusalStatus.js.map +1 -1
  313. package/dist/hosting/requestSealing.js +83 -0
  314. package/dist/hosting/requestSealing.js.map +1 -0
  315. package/dist/hosting/standingAgent.js +23 -3
  316. package/dist/hosting/standingAgent.js.map +1 -1
  317. package/dist/hosting/stream.js +5 -1
  318. package/dist/hosting/stream.js.map +1 -1
  319. package/dist/hosting/streamHandler.js +36 -12
  320. package/dist/hosting/streamHandler.js.map +1 -1
  321. package/dist/hosting/types.js.map +1 -1
  322. package/dist/identity/requestContext.js +139 -0
  323. package/dist/identity/requestContext.js.map +1 -0
  324. package/dist/identity/requestCredentials.js +165 -0
  325. package/dist/identity/requestCredentials.js.map +1 -0
  326. package/dist/identity/types.js.map +1 -1
  327. package/dist/identity.js +13 -1
  328. package/dist/identity.js.map +1 -1
  329. package/dist/index.js +15 -4
  330. package/dist/index.js.map +1 -1
  331. package/dist/injection-engine/buildInjectionEngineSubflow.js +38 -4
  332. package/dist/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  333. package/dist/injection-engine/constrainedEnumPick.js +4 -2
  334. package/dist/injection-engine/constrainedEnumPick.js.map +1 -1
  335. package/dist/injection-engine/evaluator.js +18 -0
  336. package/dist/injection-engine/evaluator.js.map +1 -1
  337. package/dist/injection-engine/skillGraph.js +25 -7
  338. package/dist/injection-engine/skillGraph.js.map +1 -1
  339. package/dist/injection-engine/skillIntent.js +3 -0
  340. package/dist/injection-engine/skillIntent.js.map +1 -1
  341. package/dist/injection-engine/types.js +17 -1
  342. package/dist/injection-engine/types.js.map +1 -1
  343. package/dist/lib/abort.js +336 -0
  344. package/dist/lib/abort.js.map +1 -0
  345. package/dist/maps/engagement/parkCard.js +10 -3
  346. package/dist/maps/engagement/parkCard.js.map +1 -1
  347. package/dist/mcp/mcpClient.js +30 -2
  348. package/dist/mcp/mcpClient.js.map +1 -1
  349. package/dist/mcp/mcpServe.js +5 -1
  350. package/dist/mcp/mcpServe.js.map +1 -1
  351. package/dist/mcp/plainData.js +208 -0
  352. package/dist/mcp/plainData.js.map +1 -0
  353. package/dist/mcp/sdkLoadFailure.js +4 -4
  354. package/dist/mcp/sdkLoadFailure.js.map +1 -1
  355. package/dist/mcp/toolResult.js +8 -50
  356. package/dist/mcp/toolResult.js.map +1 -1
  357. package/dist/memory/beats/llmExtractor.js +6 -3
  358. package/dist/memory/beats/llmExtractor.js.map +1 -1
  359. package/dist/memory/facts/llmFactExtractor.js +6 -3
  360. package/dist/memory/facts/llmFactExtractor.js.map +1 -1
  361. package/dist/memory/stages/summarize.js +16 -5
  362. package/dist/memory/stages/summarize.js.map +1 -1
  363. package/dist/patterns/LlmRouter.js +9 -4
  364. package/dist/patterns/LlmRouter.js.map +1 -1
  365. package/dist/redaction/conversation.js +3 -0
  366. package/dist/redaction/conversation.js.map +1 -1
  367. package/dist/redaction/knownStrings.js +1 -0
  368. package/dist/redaction/knownStrings.js.map +1 -1
  369. package/dist/reliability/buildReliabilityGateChart.js +7 -1
  370. package/dist/reliability/buildReliabilityGateChart.js.map +1 -1
  371. package/dist/resilience/withCircuitBreaker.js +5 -2
  372. package/dist/resilience/withCircuitBreaker.js.map +1 -1
  373. package/dist/resilience/withFallback.js +6 -0
  374. package/dist/resilience/withFallback.js.map +1 -1
  375. package/dist/resilience/withRetry.js +5 -0
  376. package/dist/resilience/withRetry.js.map +1 -1
  377. package/dist/time-travel/servedView.js +1 -1
  378. package/dist/time-travel/servedView.js.map +1 -1
  379. package/dist/tools/hostFilled.js +517 -0
  380. package/dist/tools/hostFilled.js.map +1 -0
  381. package/dist/types/adapters/llm/AnthropicProvider.d.ts +9 -2
  382. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  383. package/dist/types/adapters/llm/BedrockProvider.d.ts +6 -1
  384. package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
  385. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  386. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  387. package/dist/types/adapters/llm/FoundryLocalProvider.d.ts.map +1 -1
  388. package/dist/types/adapters/llm/GeminiProvider.d.ts.map +1 -1
  389. package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts.map +1 -1
  390. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  391. package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -1
  392. package/dist/types/adapters/llm/OpenAIProvider.d.ts +6 -1
  393. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  394. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +1 -1
  395. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
  396. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts +26 -3
  397. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
  398. package/dist/types/ag-ui/adapter.d.ts +61 -11
  399. package/dist/types/ag-ui/adapter.d.ts.map +1 -1
  400. package/dist/types/ag-ui/framing.d.ts +2 -1
  401. package/dist/types/ag-ui/framing.d.ts.map +1 -1
  402. package/dist/types/ag-ui/index.d.ts +6 -4
  403. package/dist/types/ag-ui/index.d.ts.map +1 -1
  404. package/dist/types/ag-ui/request.d.ts +86 -7
  405. package/dist/types/ag-ui/request.d.ts.map +1 -1
  406. package/dist/types/answer-validation/index.d.ts +2 -1
  407. package/dist/types/answer-validation/index.d.ts.map +1 -1
  408. package/dist/types/answer-validation/toolLedger.d.ts +66 -0
  409. package/dist/types/answer-validation/toolLedger.d.ts.map +1 -0
  410. package/dist/types/answer-validation/types.d.ts +48 -0
  411. package/dist/types/answer-validation/types.d.ts.map +1 -1
  412. package/dist/types/answer-validation/validate.d.ts +2 -2
  413. package/dist/types/answer-validation/validate.d.ts.map +1 -1
  414. package/dist/types/classify/typesafe.d.ts.map +1 -1
  415. package/dist/types/core/Agent.d.ts +9 -1
  416. package/dist/types/core/Agent.d.ts.map +1 -1
  417. package/dist/types/core/LLMCall.d.ts +2 -1
  418. package/dist/types/core/LLMCall.d.ts.map +1 -1
  419. package/dist/types/core/RunnerBase.d.ts +39 -8
  420. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  421. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  422. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts +16 -0
  423. package/dist/types/core/agent/buildAgentMessageApiChart.d.ts.map +1 -1
  424. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  425. package/dist/types/core/agent/buildMessageApiChart.d.ts +16 -0
  426. package/dist/types/core/agent/buildMessageApiChart.d.ts.map +1 -1
  427. package/dist/types/core/agent/stages/answerValidation.d.ts.map +1 -1
  428. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  429. package/dist/types/core/agent/stages/routeTurn.d.ts.map +1 -1
  430. package/dist/types/core/agent/stages/seed.d.ts +7 -0
  431. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  432. package/dist/types/core/agent/stages/toolCalls.d.ts +21 -0
  433. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  434. package/dist/types/core/agent/types.d.ts +10 -0
  435. package/dist/types/core/agent/types.d.ts.map +1 -1
  436. package/dist/types/core/agent/window/strategies/summarizeOldest.d.ts.map +1 -1
  437. package/dist/types/core/agent/window/summarize.d.ts.map +1 -1
  438. package/dist/types/core/memberRun.d.ts +23 -2
  439. package/dist/types/core/memberRun.d.ts.map +1 -1
  440. package/dist/types/core/requestOfRun.d.ts +22 -0
  441. package/dist/types/core/requestOfRun.d.ts.map +1 -0
  442. package/dist/types/core/runner.d.ts +15 -3
  443. package/dist/types/core/runner.d.ts.map +1 -1
  444. package/dist/types/core/slots/buildToolsSlot.d.ts +0 -16
  445. package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
  446. package/dist/types/core-flow/Conditional.d.ts +2 -1
  447. package/dist/types/core-flow/Conditional.d.ts.map +1 -1
  448. package/dist/types/core-flow/Graph.d.ts +2 -1
  449. package/dist/types/core-flow/Graph.d.ts.map +1 -1
  450. package/dist/types/core-flow/Loop.d.ts +2 -1
  451. package/dist/types/core-flow/Loop.d.ts.map +1 -1
  452. package/dist/types/core-flow/Parallel.d.ts +2 -1
  453. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  454. package/dist/types/core-flow/Sequence.d.ts +2 -1
  455. package/dist/types/core-flow/Sequence.d.ts.map +1 -1
  456. package/dist/types/core-flow/Workflow.d.ts +2 -1
  457. package/dist/types/core-flow/Workflow.d.ts.map +1 -1
  458. package/dist/types/doors/security.d.ts +2 -1
  459. package/dist/types/doors/security.d.ts.map +1 -1
  460. package/dist/types/events/payloads.d.ts +4 -2
  461. package/dist/types/events/payloads.d.ts.map +1 -1
  462. package/dist/types/hosting/index.d.ts +1 -0
  463. package/dist/types/hosting/index.d.ts.map +1 -1
  464. package/dist/types/hosting/protocolAdapter.d.ts +4 -1
  465. package/dist/types/hosting/protocolAdapter.d.ts.map +1 -1
  466. package/dist/types/hosting/refusalStatus.d.ts.map +1 -1
  467. package/dist/types/hosting/requestSealing.d.ts +66 -0
  468. package/dist/types/hosting/requestSealing.d.ts.map +1 -0
  469. package/dist/types/hosting/standingAgent.d.ts.map +1 -1
  470. package/dist/types/hosting/stream.d.ts +23 -2
  471. package/dist/types/hosting/stream.d.ts.map +1 -1
  472. package/dist/types/hosting/streamHandler.d.ts +26 -7
  473. package/dist/types/hosting/streamHandler.d.ts.map +1 -1
  474. package/dist/types/hosting/types.d.ts +29 -0
  475. package/dist/types/hosting/types.d.ts.map +1 -1
  476. package/dist/types/identity/requestContext.d.ts +97 -0
  477. package/dist/types/identity/requestContext.d.ts.map +1 -0
  478. package/dist/types/identity/requestCredentials.d.ts +100 -0
  479. package/dist/types/identity/requestCredentials.d.ts.map +1 -0
  480. package/dist/types/identity/types.d.ts +11 -0
  481. package/dist/types/identity/types.d.ts.map +1 -1
  482. package/dist/types/identity.d.ts +2 -0
  483. package/dist/types/identity.d.ts.map +1 -1
  484. package/dist/types/index.d.ts +3 -2
  485. package/dist/types/index.d.ts.map +1 -1
  486. package/dist/types/injection-engine/buildInjectionEngineSubflow.d.ts +11 -0
  487. package/dist/types/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  488. package/dist/types/injection-engine/constrainedEnumPick.d.ts.map +1 -1
  489. package/dist/types/injection-engine/evaluator.d.ts +6 -0
  490. package/dist/types/injection-engine/evaluator.d.ts.map +1 -1
  491. package/dist/types/injection-engine/skillIntent.d.ts +4 -2
  492. package/dist/types/injection-engine/skillIntent.d.ts.map +1 -1
  493. package/dist/types/injection-engine/types.d.ts +27 -1
  494. package/dist/types/injection-engine/types.d.ts.map +1 -1
  495. package/dist/types/lib/abort.d.ts +144 -0
  496. package/dist/types/lib/abort.d.ts.map +1 -0
  497. package/dist/types/maps/engagement/parkCard.d.ts +5 -1
  498. package/dist/types/maps/engagement/parkCard.d.ts.map +1 -1
  499. package/dist/types/mcp/mcpServe.d.ts.map +1 -1
  500. package/dist/types/mcp/plainData.d.ts +45 -0
  501. package/dist/types/mcp/plainData.d.ts.map +1 -0
  502. package/dist/types/mcp/sdkLoadFailure.d.ts +6 -7
  503. package/dist/types/mcp/sdkLoadFailure.d.ts.map +1 -1
  504. package/dist/types/mcp/toolResult.d.ts.map +1 -1
  505. package/dist/types/mcp/types.d.ts +10 -6
  506. package/dist/types/mcp/types.d.ts.map +1 -1
  507. package/dist/types/memory/beats/llmExtractor.d.ts.map +1 -1
  508. package/dist/types/memory/facts/llmFactExtractor.d.ts.map +1 -1
  509. package/dist/types/memory/stages/summarize.d.ts.map +1 -1
  510. package/dist/types/patterns/LlmRouter.d.ts.map +1 -1
  511. package/dist/types/redaction/conversation.d.ts.map +1 -1
  512. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  513. package/dist/types/reliability/buildReliabilityGateChart.d.ts.map +1 -1
  514. package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
  515. package/dist/types/resilience/withFallback.d.ts.map +1 -1
  516. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  517. package/dist/types/tools/hostFilled.d.ts +111 -0
  518. package/dist/types/tools/hostFilled.d.ts.map +1 -0
  519. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ /**
2
+ * requestContext — the INCOMING REQUEST's secrets, sealed for one run.
3
+ *
4
+ * A host that receives a per-request credential (an encrypted token in a
5
+ * header, a session-bound key) seals it here and hands the handle to the run:
6
+ *
7
+ * ```ts
8
+ * const request = requestContext({ secrets: { mcpToken: req.headers['x-mcp-token'] } });
9
+ * await agent.run({ message }, { request });
10
+ * ```
11
+ *
12
+ * ── Why a sealed handle and not a plain object ──────────────────────────────
13
+ * The run's input, its options and its state all travel: input and state into
14
+ * the commit log, the recorders and every exporter; options into whatever a
15
+ * host logs. A plain `{ mcpToken: '…' }` would ride all of them. The handle
16
+ * holds NOTHING an enumeration, `JSON.stringify`, `structuredClone` or an
17
+ * inspector can reach — the values live in a module-private `WeakMap` keyed by
18
+ * the handle, and only {@link requestSecretOf} (internal, never on a door)
19
+ * reads them. So the handle can sit in an options bag, be logged by accident,
20
+ * or be copied, and nothing secret moves with it.
21
+ *
22
+ * ── Who reads it ─────────────────────────────────────────────────────────────
23
+ * Only a credential provider, through `CredentialRequest.request`, which the
24
+ * framework fills from the run the call belongs to (`bindRequest`). The model
25
+ * never sees it, no stage writes it to scope, and a tool reaches what it
26
+ * vends only as `ctx.credential`.
27
+ *
28
+ * ── One request, one run ─────────────────────────────────────────────────────
29
+ * The framework decides WHICH handle a call carries — the agent's own run, or
30
+ * the run a composition opened for its members (`core/memberRun.ts`). A call
31
+ * with no run that carries a request gets none: a request credential then
32
+ * fails closed (`requestCredentials`), and is never borrowed from another run.
33
+ *
34
+ * Pattern: sealed value object (module-private WeakMap). Role: identity, run input.
35
+ */
36
+ import type { CredentialProvider } from './types.js';
37
+ /** What {@link requestContext} takes. */
38
+ export interface RequestContextOptions {
39
+ /**
40
+ * The request's secrets, by name — `{ mcpToken: '<from the header>' }`.
41
+ * Each value must be a non-empty string; names are compared exactly.
42
+ */
43
+ readonly secrets: Readonly<Record<string, string>>;
44
+ }
45
+ /**
46
+ * The incoming request's secrets, sealed. Opaque: it has no readable fields,
47
+ * serializes as a fixed placeholder, and is recognised by the framework only
48
+ * when {@link requestContext} built it.
49
+ */
50
+ export interface RequestContext {
51
+ /** Type-only brand: no value carries it at run time. A value built anywhere
52
+ * else is refused at the door (`assertRequestContext`), never read. */
53
+ readonly [requestContextBrand]: never;
54
+ }
55
+ /** The brand's key — declared, never created; it exists only in the types. */
56
+ declare const requestContextBrand: unique symbol;
57
+ /**
58
+ * Seal an incoming request's secrets for one run. Pass the result as
59
+ * `run(input, { request })` (or `resume(…, { request })`); a credential
60
+ * provider built by `requestCredentials` reads it there.
61
+ *
62
+ * @throws TypeError when `secrets` is not a plain object of non-empty strings.
63
+ */
64
+ export declare function requestContext(options: RequestContextOptions): RequestContext;
65
+ /** Whether `value` is a handle {@link requestContext} built. */
66
+ export declare function isRequestContext(value: unknown): value is RequestContext;
67
+ /**
68
+ * Refuse a `request` that {@link requestContext} did not build — at the door
69
+ * the caller used, before anything moves. A plain object would carry its
70
+ * values wherever the options travel.
71
+ *
72
+ * @throws TypeError naming the door.
73
+ */
74
+ export declare function assertRequestContext(value: unknown, door: string): void;
75
+ /**
76
+ * The secret a sealed request holds under `name`, or `undefined`.
77
+ *
78
+ * @internal Never re-exported on a door. The only reader is a credential
79
+ * provider in this folder, which turns it into a `Credential` for one call.
80
+ */
81
+ export declare function requestSecretOf(request: unknown, name: string): string | undefined;
82
+ /**
83
+ * The provider a call of ONE run is handed: a `getCredential` for `service` —
84
+ * the service the calling tool DECLARES in its `needs` — carries that run's
85
+ * request, and only that run's. A request the caller put on the request
86
+ * itself is always replaced (or removed), so a tool cannot present another
87
+ * run's handle through `ctx.credentials`; and a call for any OTHER service
88
+ * carries no request, so a tool cannot pull a request credential it never
89
+ * declared. `service` undefined → no call carries a request.
90
+ *
91
+ * Every other field passes through untouched; the provider's `id` is kept.
92
+ *
93
+ * @internal The framework's binding; not on a door.
94
+ */
95
+ export declare function bindRequest(provider: CredentialProvider, request: RequestContext | undefined, service: string | undefined): CredentialProvider;
96
+ export {};
@@ -0,0 +1,131 @@
1
+ /**
2
+ * requestContext — the INCOMING REQUEST's secrets, sealed for one run.
3
+ *
4
+ * A host that receives a per-request credential (an encrypted token in a
5
+ * header, a session-bound key) seals it here and hands the handle to the run:
6
+ *
7
+ * ```ts
8
+ * const request = requestContext({ secrets: { mcpToken: req.headers['x-mcp-token'] } });
9
+ * await agent.run({ message }, { request });
10
+ * ```
11
+ *
12
+ * ── Why a sealed handle and not a plain object ──────────────────────────────
13
+ * The run's input, its options and its state all travel: input and state into
14
+ * the commit log, the recorders and every exporter; options into whatever a
15
+ * host logs. A plain `{ mcpToken: '…' }` would ride all of them. The handle
16
+ * holds NOTHING an enumeration, `JSON.stringify`, `structuredClone` or an
17
+ * inspector can reach — the values live in a module-private `WeakMap` keyed by
18
+ * the handle, and only {@link requestSecretOf} (internal, never on a door)
19
+ * reads them. So the handle can sit in an options bag, be logged by accident,
20
+ * or be copied, and nothing secret moves with it.
21
+ *
22
+ * ── Who reads it ─────────────────────────────────────────────────────────────
23
+ * Only a credential provider, through `CredentialRequest.request`, which the
24
+ * framework fills from the run the call belongs to (`bindRequest`). The model
25
+ * never sees it, no stage writes it to scope, and a tool reaches what it
26
+ * vends only as `ctx.credential`.
27
+ *
28
+ * ── One request, one run ─────────────────────────────────────────────────────
29
+ * The framework decides WHICH handle a call carries — the agent's own run, or
30
+ * the run a composition opened for its members (`core/memberRun.ts`). A call
31
+ * with no run that carries a request gets none: a request credential then
32
+ * fails closed (`requestCredentials`), and is never borrowed from another run.
33
+ *
34
+ * Pattern: sealed value object (module-private WeakMap). Role: identity, run input.
35
+ */
36
+ /** The sealed values, keyed by handle. Module-private: nothing else can read them. */
37
+ const sealed = new WeakMap();
38
+ const PLACEHOLDER = '[request context]';
39
+ /**
40
+ * Seal an incoming request's secrets for one run. Pass the result as
41
+ * `run(input, { request })` (or `resume(…, { request })`); a credential
42
+ * provider built by `requestCredentials` reads it there.
43
+ *
44
+ * @throws TypeError when `secrets` is not a plain object of non-empty strings.
45
+ */
46
+ export function requestContext(options) {
47
+ const secrets = options?.secrets;
48
+ if (secrets === null || typeof secrets !== 'object' || Array.isArray(secrets)) {
49
+ throw new TypeError('requestContext: `secrets` must be an object of name → string.');
50
+ }
51
+ const values = new Map();
52
+ for (const name of Object.keys(secrets)) {
53
+ const value = secrets[name];
54
+ if (name === '')
55
+ throw new TypeError('requestContext: a secret name must not be empty.');
56
+ // The NAME is safe to say; the value never is.
57
+ if (typeof value !== 'string' || value === '') {
58
+ throw new TypeError(`requestContext: secret '${name}' must be a non-empty string — an absent value is ` +
59
+ 'left out, never passed empty.');
60
+ }
61
+ values.set(name, value);
62
+ }
63
+ const handle = Object.create(handleProto);
64
+ Object.freeze(handle);
65
+ sealed.set(handle, values);
66
+ return handle;
67
+ }
68
+ /**
69
+ * The handle's prototype — every reader that might print or copy it gets the
70
+ * placeholder. No own properties, so `Object.keys`, a spread or
71
+ * `structuredClone` yields `{}`.
72
+ */
73
+ const handleProto = Object.freeze({
74
+ toJSON: () => PLACEHOLDER,
75
+ toString: () => PLACEHOLDER,
76
+ [Symbol.toStringTag]: 'RequestContext',
77
+ [Symbol.for('nodejs.util.inspect.custom')]: () => PLACEHOLDER,
78
+ });
79
+ /** Whether `value` is a handle {@link requestContext} built. */
80
+ export function isRequestContext(value) {
81
+ return typeof value === 'object' && value !== null && sealed.has(value);
82
+ }
83
+ /**
84
+ * Refuse a `request` that {@link requestContext} did not build — at the door
85
+ * the caller used, before anything moves. A plain object would carry its
86
+ * values wherever the options travel.
87
+ *
88
+ * @throws TypeError naming the door.
89
+ */
90
+ export function assertRequestContext(value, door) {
91
+ if (value === undefined || isRequestContext(value))
92
+ return;
93
+ throw new TypeError(`${door}: \`request\` must be built by requestContext({ secrets }) — a plain object is ` +
94
+ 'refused, because its values would travel wherever these options are logged or copied.');
95
+ }
96
+ /**
97
+ * The secret a sealed request holds under `name`, or `undefined`.
98
+ *
99
+ * @internal Never re-exported on a door. The only reader is a credential
100
+ * provider in this folder, which turns it into a `Credential` for one call.
101
+ */
102
+ export function requestSecretOf(request, name) {
103
+ if (typeof request !== 'object' || request === null)
104
+ return undefined;
105
+ return sealed.get(request)?.get(name);
106
+ }
107
+ /**
108
+ * The provider a call of ONE run is handed: a `getCredential` for `service` —
109
+ * the service the calling tool DECLARES in its `needs` — carries that run's
110
+ * request, and only that run's. A request the caller put on the request
111
+ * itself is always replaced (or removed), so a tool cannot present another
112
+ * run's handle through `ctx.credentials`; and a call for any OTHER service
113
+ * carries no request, so a tool cannot pull a request credential it never
114
+ * declared. `service` undefined → no call carries a request.
115
+ *
116
+ * Every other field passes through untouched; the provider's `id` is kept.
117
+ *
118
+ * @internal The framework's binding; not on a door.
119
+ */
120
+ export function bindRequest(provider, request, service) {
121
+ return {
122
+ id: provider.id,
123
+ getCredential(req) {
124
+ const { request: _presented, ...rest } = req;
125
+ void _presented;
126
+ const carries = request !== undefined && service !== undefined && req.service === service;
127
+ return provider.getCredential(carries ? { ...rest, request } : rest);
128
+ },
129
+ };
130
+ }
131
+ //# sourceMappingURL=requestContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestContext.js","sourceRoot":"","sources":["../../../src/identity/requestContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,sFAAsF;AACtF,MAAM,MAAM,GAAG,IAAI,OAAO,EAAuC,CAAC;AAyBlE,MAAM,W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O,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * requestCredentials — a {@link CredentialProvider} fed from the INCOMING
3
+ * REQUEST: the credential a tool uses is the one this run's caller sent.
4
+ *
5
+ * ```ts
6
+ * import { requestCredentials, requestContext, decodedWith } from 'agentfootprint/security';
7
+ *
8
+ * // Once, at boot — no secret in here:
9
+ * const credentials = requestCredentials({
10
+ * services: {
11
+ * crm: 'crmToken', // bearer, as sent
12
+ * billing: { secret: 'billingKey', as: asApiKey('x-api-key') },
13
+ * mcp: { secret: 'mcpToken', as: decodedWith((raw) => decrypt(raw)) },
14
+ * },
15
+ * });
16
+ * const agent = Agent.create({ provider, credentials }).tool(crmTool).build();
17
+ *
18
+ * // Per request:
19
+ * await agent.run({ message }, { request: requestContext({ secrets: { crmToken, mcpToken } }) });
20
+ * ```
21
+ *
22
+ * A tool declares `needs: { credential: 'crm' }` and reads `ctx.credential`,
23
+ * exactly as with any other provider. Nothing about the tool changes.
24
+ *
25
+ * ── Interface → adapter → strategies ────────────────────────────────────────
26
+ * The interface is the `CredentialProvider` port. This adapter reads the
27
+ * secret named for the service from the request the call belongs to
28
+ * (`CredentialRequest.request`, filled by the framework). A strategy turns the
29
+ * raw value into a `Credential`: {@link asBearer} (the default),
30
+ * {@link asApiKey}, or {@link decodedWith} for a value that must be decrypted
31
+ * or exchanged first.
32
+ *
33
+ * ── Fails closed, by name ───────────────────────────────────────────────────
34
+ * Every refusal is a {@link RequestCredentialError} naming the SERVICE and the
35
+ * secret's NAME — never a value, and never a strategy's own error text (a
36
+ * decrypt library may quote its input). A thrown message reaches the model as
37
+ * the tool result and rides `agentfootprint.credential.failed`.
38
+ * - no request on the call (a run started without one, a mount no run
39
+ * reaches, a connection-level caller) → `'no-request'`;
40
+ * - the request does not carry the secret → `'missing'`;
41
+ * - a service this provider was not told about → `'unknown-service'`;
42
+ * - the strategy threw or returned no credential → `'undecodable'`.
43
+ * There is no fallback: a missing per-request credential is never served from
44
+ * another request, a default, or the process.
45
+ *
46
+ * Pattern: Adapter (port) + Strategy (raw value → Credential).
47
+ */
48
+ import type { Credential, CredentialProvider } from './types.js';
49
+ /** Raw request value → the credential a tool applies. May be async (decrypt, exchange). */
50
+ export type RequestCredentialStrategy = (raw: string) => Credential | Promise<Credential>;
51
+ /** Where a service's credential comes from in the request, and how it is read. */
52
+ export interface RequestCredentialSource {
53
+ /** The secret's name in `requestContext({ secrets })`. */
54
+ readonly secret: string;
55
+ /** How the raw value becomes a credential. Default {@link asBearer}. */
56
+ readonly as?: RequestCredentialStrategy;
57
+ }
58
+ /** What {@link requestCredentials} takes. */
59
+ export interface RequestCredentialsOptions {
60
+ /** Optional id (defaults to `'request-credentials'`). */
61
+ readonly id?: string;
62
+ /**
63
+ * Service id (what a tool's `needs.credential` names) → its source. A string
64
+ * is the secret's name, read as a bearer token.
65
+ */
66
+ readonly services: Readonly<Record<string, string | RequestCredentialSource>>;
67
+ }
68
+ /** Why a request credential was refused. */
69
+ export type RequestCredentialRefusal = 'no-request' | 'missing' | 'unknown-service' | 'undecodable';
70
+ /**
71
+ * A request credential that could not be served. Its message names the
72
+ * service and the secret's name; it never carries a value or a strategy's
73
+ * own error.
74
+ */
75
+ export declare class RequestCredentialError extends Error {
76
+ readonly reason: RequestCredentialRefusal;
77
+ readonly service: string;
78
+ readonly code: "ERR_REQUEST_CREDENTIAL";
79
+ constructor(reason: RequestCredentialRefusal, service: string, message: string);
80
+ }
81
+ /** The raw value, as a bearer token (`Authorization: Bearer …`). The default. */
82
+ export declare function asBearer(): RequestCredentialStrategy;
83
+ /** The raw value, as an API key in one header (default `x-api-key`). */
84
+ export declare function asApiKey(headerName?: string): RequestCredentialStrategy;
85
+ /**
86
+ * Decode the raw value first — decrypt an encrypted per-request token,
87
+ * exchange it — then read the result with `then` (default {@link asBearer}).
88
+ * `decode` may return the plain value or a finished `Credential`. Whatever it
89
+ * throws is replaced by an `'undecodable'` refusal that quotes nothing.
90
+ */
91
+ export declare function decodedWith(decode: (raw: string) => string | Credential | Promise<string | Credential>, then?: RequestCredentialStrategy): RequestCredentialStrategy;
92
+ /**
93
+ * Build the provider. Configuration is checked here, at boot: an empty
94
+ * service map, an empty secret name or a strategy that is not a function is
95
+ * refused by name.
96
+ *
97
+ * @throws TypeError on a malformed `services` map.
98
+ */
99
+ export declare function requestCredentials(options: RequestCredentialsOptions): CredentialProvider;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * requestCredentials — a {@link CredentialProvider} fed from the INCOMING
3
+ * REQUEST: the credential a tool uses is the one this run's caller sent.
4
+ *
5
+ * ```ts
6
+ * import { requestCredentials, requestContext, decodedWith } from 'agentfootprint/security';
7
+ *
8
+ * // Once, at boot — no secret in here:
9
+ * const credentials = requestCredentials({
10
+ * services: {
11
+ * crm: 'crmToken', // bearer, as sent
12
+ * billing: { secret: 'billingKey', as: asApiKey('x-api-key') },
13
+ * mcp: { secret: 'mcpToken', as: decodedWith((raw) => decrypt(raw)) },
14
+ * },
15
+ * });
16
+ * const agent = Agent.create({ provider, credentials }).tool(crmTool).build();
17
+ *
18
+ * // Per request:
19
+ * await agent.run({ message }, { request: requestContext({ secrets: { crmToken, mcpToken } }) });
20
+ * ```
21
+ *
22
+ * A tool declares `needs: { credential: 'crm' }` and reads `ctx.credential`,
23
+ * exactly as with any other provider. Nothing about the tool changes.
24
+ *
25
+ * ── Interface → adapter → strategies ────────────────────────────────────────
26
+ * The interface is the `CredentialProvider` port. This adapter reads the
27
+ * secret named for the service from the request the call belongs to
28
+ * (`CredentialRequest.request`, filled by the framework). A strategy turns the
29
+ * raw value into a `Credential`: {@link asBearer} (the default),
30
+ * {@link asApiKey}, or {@link decodedWith} for a value that must be decrypted
31
+ * or exchanged first.
32
+ *
33
+ * ── Fails closed, by name ───────────────────────────────────────────────────
34
+ * Every refusal is a {@link RequestCredentialError} naming the SERVICE and the
35
+ * secret's NAME — never a value, and never a strategy's own error text (a
36
+ * decrypt library may quote its input). A thrown message reaches the model as
37
+ * the tool result and rides `agentfootprint.credential.failed`.
38
+ * - no request on the call (a run started without one, a mount no run
39
+ * reaches, a connection-level caller) → `'no-request'`;
40
+ * - the request does not carry the secret → `'missing'`;
41
+ * - a service this provider was not told about → `'unknown-service'`;
42
+ * - the strategy threw or returned no credential → `'undecodable'`.
43
+ * There is no fallback: a missing per-request credential is never served from
44
+ * another request, a default, or the process.
45
+ *
46
+ * Pattern: Adapter (port) + Strategy (raw value → Credential).
47
+ */
48
+ import { apiKey, bearer } from './kinds.js';
49
+ import { requestSecretOf } from './requestContext.js';
50
+ /**
51
+ * A request credential that could not be served. Its message names the
52
+ * service and the secret's name; it never carries a value or a strategy's
53
+ * own error.
54
+ */
55
+ export class RequestCredentialError extends Error {
56
+ reason;
57
+ service;
58
+ code = 'ERR_REQUEST_CREDENTIAL';
59
+ constructor(reason, service, message) {
60
+ super(message);
61
+ this.reason = reason;
62
+ this.service = service;
63
+ this.name = 'RequestCredentialError';
64
+ }
65
+ }
66
+ /** The raw value, as a bearer token (`Authorization: Bearer …`). The default. */
67
+ export function asBearer() {
68
+ return (raw) => bearer(raw);
69
+ }
70
+ /** The raw value, as an API key in one header (default `x-api-key`). */
71
+ export function asApiKey(headerName) {
72
+ return (raw) => apiKey(raw, headerName);
73
+ }
74
+ /**
75
+ * Decode the raw value first — decrypt an encrypted per-request token,
76
+ * exchange it — then read the result with `then` (default {@link asBearer}).
77
+ * `decode` may return the plain value or a finished `Credential`. Whatever it
78
+ * throws is replaced by an `'undecodable'` refusal that quotes nothing.
79
+ */
80
+ export function decodedWith(decode, then = asBearer()) {
81
+ return async (raw) => {
82
+ const decoded = await decode(raw);
83
+ return typeof decoded === 'string' ? then(decoded) : decoded;
84
+ };
85
+ }
86
+ /**
87
+ * Build the provider. Configuration is checked here, at boot: an empty
88
+ * service map, an empty secret name or a strategy that is not a function is
89
+ * refused by name.
90
+ *
91
+ * @throws TypeError on a malformed `services` map.
92
+ */
93
+ export function requestCredentials(options) {
94
+ const sources = readSources(options?.services);
95
+ return {
96
+ id: options.id ?? 'request-credentials',
97
+ async getCredential(req) {
98
+ const service = req.service;
99
+ const source = Object.hasOwn(sources, service) ? sources[service] : undefined;
100
+ if (source === undefined) {
101
+ throw new RequestCredentialError('unknown-service', service, `requestCredentials: no request credential is declared for service '${service}'.`);
102
+ }
103
+ if (req.request === undefined) {
104
+ throw new RequestCredentialError('no-request', service, `requestCredentials: service '${service}' takes its credential from the incoming ` +
105
+ 'request, and the call carries none — pass `request: requestContext({ secrets })` ' +
106
+ 'to the run. A credential is never borrowed from another request.');
107
+ }
108
+ const raw = requestSecretOf(req.request, source.secret);
109
+ if (raw === undefined) {
110
+ throw new RequestCredentialError('missing', service, `requestCredentials: the request carries no '${source.secret}' secret for service ` +
111
+ `'${service}'.`);
112
+ }
113
+ let credential;
114
+ try {
115
+ credential = await source.as(raw);
116
+ }
117
+ catch {
118
+ credential = undefined;
119
+ }
120
+ if (!isCredential(credential)) {
121
+ throw new RequestCredentialError('undecodable', service, `requestCredentials: the '${source.secret}' secret for service '${service}' could ` +
122
+ 'not be read as a credential.');
123
+ }
124
+ return { status: 'issued', credential };
125
+ },
126
+ };
127
+ }
128
+ function readSources(services) {
129
+ if (services === null || typeof services !== 'object' || Array.isArray(services)) {
130
+ throw new TypeError('requestCredentials: `services` must be an object of service → source.');
131
+ }
132
+ const out = Object.create(null);
133
+ const names = Object.keys(services);
134
+ if (names.length === 0) {
135
+ throw new TypeError('requestCredentials: `services` names no service.');
136
+ }
137
+ for (const service of names) {
138
+ const entry = services[service];
139
+ const secret = typeof entry === 'string' ? entry : entry?.secret;
140
+ const as = typeof entry === 'string' ? undefined : entry?.as;
141
+ if (typeof secret !== 'string' || secret === '') {
142
+ throw new TypeError(`requestCredentials: service '${service}' must name its secret (a non-empty string).`);
143
+ }
144
+ if (as !== undefined && typeof as !== 'function') {
145
+ throw new TypeError(`requestCredentials: service '${service}': \`as\` must be a strategy function.`);
146
+ }
147
+ out[service] = { secret, as: as ?? asBearer() };
148
+ }
149
+ return out;
150
+ }
151
+ function isCredential(value) {
152
+ return (typeof value === 'object' &&
153
+ value !== null &&
154
+ typeof value.kind === 'string' &&
155
+ typeof value.toHeaders === 'function');
156
+ }
157
+ //# sourceMappingURL=requestCredentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestCredentials.js","sourceRoot":"","sources":["../../../src/identity/requestCredentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA2BtD;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAIpC;IACA;IAJF,IAAI,GAAG,wBAAiC,CAAC;IAElD,YACW,MAAgC,EAChC,OAAe,EACxB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,WAAM,GAAN,MAAM,CAA0B;QAChC,YAAO,GAAP,OAAO,CAAQ;QAIxB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,QAAQ,CAAC,UAAmB;IAC1C,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,MAA2E,EAC3E,OAAkC,QAAQ,EAAE;IAE5C,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,GAAG,CAA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AI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,SAAS,CACjB,gCAAgC,OAAO,8CAA8C,CACtF,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YACjD,MAAM,IAAI,SAAS,CACjB,gCAAgC,OAAO,wCAAwC,CAChF,CAAC;QACJ,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAG,EAA4C,IAAI,QAAQ,EAAE,EAAE,CAAC;IAC7F,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAoB,CAAC,IAAI,KAAK,QAAQ;QAC9C,OAAQ,KAAoB,CAAC,SAAS,KAAK,UAAU,CACtD,CAAC;AACJ,CAAC"}
@@ -23,6 +23,7 @@
23
23
  * and observability exporters, which would leak the token into the trace. Pair
24
24
  * with `RedactionPolicy` for defence in depth.
25
25
  */
26
+ import type { RequestContext } from './requestContext.js';
26
27
  /** What a tool/agent asks for. `service` ↔ the provider's downstream service id. */
27
28
  export interface CredentialRequest {
28
29
  /** Downstream service id, e.g. 'github', 'slack', 'google'. */
@@ -66,6 +67,16 @@ export interface CredentialRequest {
66
67
  * `staticTokens` does exactly that.
67
68
  */
68
69
  readonly userToken?: string;
70
+ /**
71
+ * The incoming request this call belongs to, sealed — set by the FRAMEWORK
72
+ * from the run the call is part of, never by a tool or the model.
73
+ *
74
+ * Opaque: it carries no readable field. Only `requestCredentials` reads it
75
+ * (see `./requestContext`); every other provider ignores it. A call made
76
+ * where no run carries a request has none, and a request-sourced credential
77
+ * then fails closed.
78
+ */
79
+ readonly request?: RequestContext;
69
80
  /** Force a fresh authorization, bypassing any cached/refresh token. */
70
81
  readonly forceReauth?: boolean;
71
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAoGH,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,CAAmB;IACpD,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,EAAE,EAAE,cAAc;QAClB,aAAa,CAAC,GAAsB;YAClC,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,4DAA4D,GAAG,CAAC,OAAO,QAAQ;gBAC7E,wEAAwE;gBACxE,gEAAgE,CACnE,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAgHH,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,CAAmB;IACpD,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,EAAE,EAAE,cAAc;QAClB,aAAa,CAAC,GAAsB;YAClC,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,4DAA4D,GAAG,CAAC,OAAO,QAAQ;gBAC7E,wEAAwE;gBACxE,gEAAgE,CACnE,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -31,6 +31,8 @@ export type { Credential, CredentialProvider, CredentialRequest, CredentialResul
31
31
  export { isCredentialIssued, unconfiguredCredentialProvider } from './identity/types.js';
32
32
  export { bearer, apiKey, basic, headers, type BearerCredential, type ApiKeyCredential, type BasicCredential, type HeadersCredential, } from './identity/kinds.js';
33
33
  export { staticTokens, type StaticTokensOptions } from './identity/staticTokens.js';
34
+ export { requestContext, isRequestContext, type RequestContext, type RequestContextOptions, } from './identity/requestContext.js';
35
+ export { requestCredentials, asBearer, asApiKey, decodedWith, RequestCredentialError, type RequestCredentialsOptions, type RequestCredentialSource, type RequestCredentialStrategy, type RequestCredentialRefusal, } from './identity/requestCredentials.js';
34
36
  export type { AuthorizationRequiredMode, ConsentRequest } from './identity/consent.js';
35
37
  export { CredentialConsentRequiredError, type CredentialConsentRequiredContext, } from './identity/CredentialConsentRequiredError.js';
36
38
  export { withCredentialRetry, type WithCredentialRetryOptions, } from './identity/withCredentialRetry.js';
@@ -30,6 +30,11 @@
30
30
  export { isCredentialIssued, unconfiguredCredentialProvider } from './identity/types.js';
31
31
  export { bearer, apiKey, basic, headers, } from './identity/kinds.js';
32
32
  export { staticTokens } from './identity/staticTokens.js';
33
+ // Credentials from the INCOMING REQUEST: the host seals the request's secrets
34
+ // per run (`requestContext`), and `requestCredentials` vends them to a tool's
35
+ // declared `needs` — only for the run that carries them, failing closed by name.
36
+ export { requestContext, isRequestContext, } from './identity/requestContext.js';
37
+ export { requestCredentials, asBearer, asApiKey, decodedWith, RequestCredentialError, } from './identity/requestCredentials.js';
33
38
  export { CredentialConsentRequiredError, } from './identity/CredentialConsentRequiredError.js';
34
39
  export { withCredentialRetry, } from './identity/withCredentialRetry.js';
35
40
  export { agentCoreIdentity,
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAWH,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,GAKR,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AAKpF,OAAO,EAC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AAM,+BAA+B,CAAC;AAEvC,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AACxE,0EAA0E;AAC1E,gEAAgE;AAChE,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,8BAA8B,GAK/B,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,iEAAiE;AACjE,4EAA4E;AAC5E,sEAAsE;AACtE,4EAA4E;AAC5E,OAAO,EACL,YAAY,EACZ,uBAAuB,GAKxB,MAAM,6BAA6B,CAAC;AAErC,4EAA4E;AAC5E,+EAA+E;AAC/E,2EAA2E;AAC3E,0EAA0E;AAC1E,+EAA+E;AAC/E,4BAA4B;AAC5B,OAAO,EACL,YAAY,GAKb,MAAM,6BAA6B,CAAC;AAErC,sEAAsE;AACtE,+EAA+E;AAC/E,iFAAiF;AACjF,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,GAIX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,kBAAkB,GAInB,MAAM,0CAA0C,CAAC;AAClD,qEAAqE;AACrE,6EAA6E;AAC7E,OAAO,EACL,kBAAkB,GAEnB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,kBAAkB,GAGnB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,aAAa,EACb,iBAAiB,GAMlB,MAAM,uCAAuC,CAAC;AAC/C,8EAA8E;AAC9E,wEAAwE;AACxE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,YAAY,GAEb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GAEpB,MAAM,0CAA0C,CAAC"}
@@ -56,12 +56,13 @@ export { canResume, ConversationMismatchError, RunCheckpointError, type AgentRun
56
56
  export { browserSessionId, DEFAULT_SESSION_STORAGE_KEY, type BrowserSessionIdOptions, } from './hosting/browserSession.js';
57
57
  export { ContextWindowExceededError, ERR_CONTEXT_WINDOW_EXCEEDED, isContextWindowExceeded, } from './provider-contract/contextWindow.js';
58
58
  export { NoConversationError, type NoConversationReason, PendingQuestionError, ResumeIdentityConflictError, ResumeRedactionError, type ResumeRedactionReason, RunInFlightError, } from './core/conversation.js';
59
- export { MemberIdentityError, ParentRunRefusedError } from './core/memberRun.js';
59
+ export { MemberIdentityError, ParentRunRefusedError, ResumeRequestConflictError, } from './core/memberRun.js';
60
60
  export { flowchartAsTool, type FlowchartAsToolOptions, type FlowchartResultMapper, type FlowchartToolSnapshot, } from './core/flowchartAsTool.js';
61
61
  export { absenceSignalOf, DECLINED_VERDICT, DEFAULT_MAX_ROWS, DEFAULT_RECORDING_MAX_BYTES, DEFAULT_WALK_CAP, PANEL_RENDER_NOTE, probeDispatch, projectWalk, recordingDispatch, renderVerdictTable, runbookAsTool, RunbookAbsenceSignal, VERDICT_RENDER_NOTE, verdictRowsOf, type InnerCallRecord, type ProjectedWalk, type RecordedDispatch, type RunbookAsToolOptions, type RunbookEnvelope, type RunbookPresentation, type RunbookProcedure, type RunbookRecordingOptions, type RunbookRules, type RunbookVerdictsOptions, type RunbookWalkOptions, type VerdictRow, type WalkDescriptor, type WalkRow, } from './core/runbook/index.js';
62
62
  export type { Tool, ToolExecutionContext, ToolRegistryEntry, DefineToolOptions, ToolDispatch, ToolDispatchCallOptions, ToolResultCeiling, } from './tools/tools.js';
63
63
  export type { AskOrAssume, ToolPeriod } from './tools/declare.js';
64
64
  export { defineTool, assertResultCeiling, assertResultClass, assertResultKind, assertComposedOf, assertGates, } from './tools/tools.js';
65
+ export { hostFilled, fromCredential, fromIdentity, HostFilledArgumentError, HostFilledValueMissingError, HOST_FILLED_PLACEHOLDER, type HostFill, type HostFillFromCredential, type HostFillFromIdentity, type HostFilledIdentityField, } from './tools/hostFilled.js';
65
66
  export { assertValidToolName, warnIfInvalidToolName } from './lib/toolName.js';
66
67
  export { explainStatusOnlyNearMiss, readToolResultEnvelope, TOOL_RESULT_STATUSES, type InstructionDeliveryLease, type ProposedEffect, type ProposeTransitionEffect, type ReadToolResultEnvelope, type RequireInstructionEffect, type ToolResultEnvelope, type ToolResultStatus, } from './semantics/toolEffects.js';
67
68
  export type { InstructionLease, PendingToolTransition } from './injection-engine/leases.js';
@@ -99,4 +100,4 @@ export { providerFromEnv, type ProviderKind, type CreateProviderOptions, type Pr
99
100
  export * from './patterns/index.js';
100
101
  export { defineRAG, DEFAULT_CORPUS_IDENTITY, type DefineRAGOptions, indexDocuments, type IndexDocumentsOptions, type RagDocument, } from './rag/retriever/index.js';
101
102
  export { topK, type TopKOptions, type RetrievalStrategy, type RetrievalEvidence, type RetrievedCandidate, type RetrievalRejectReason, } from './memory/retrieval/index.js';
102
- export { AnswerValidationError, type AnswerValidationOptions, type AnswerValidationReport, type AnswerCheck, type AnswerEvidenceResolver, } from './answer-validation/index.js';
103
+ export { AnswerValidationError, type AnswerValidationOptions, type AnswerValidationReport, type AnswerCheck, type AnswerEvidenceResolver, type AnswerToolCall, type AnswerToolCallsView, type AnswerValidationContext, } from './answer-validation/index.js';
package/dist/esm/index.js CHANGED
@@ -270,7 +270,7 @@ export { ContextWindowExceededError, ERR_CONTEXT_WINDOW_EXCEEDED, isContextWindo
270
270
  export { NoConversationError, PendingQuestionError, ResumeIdentityConflictError, ResumeRedactionError, RunInFlightError, } from './core/conversation.js';
271
271
  // A composition member runs for the run that mounted it; one no run reached is
272
272
  // refused by name (`core/memberRun.ts`).
273
- export { MemberIdentityError, ParentRunRefusedError } from './core/memberRun.js';
273
+ export { MemberIdentityError, ParentRunRefusedError, ResumeRequestConflictError, } from './core/memberRun.js';
274
274
  export { flowchartAsTool, } from './core/flowchartAsTool.js';
275
275
  // runbookAsTool (9.76.0) — the STANDARD bridge from a footprintjs procedure
276
276
  // to an Agent tool: every answer is the mandatory honesty spine (coverage
@@ -296,6 +296,10 @@ assertResultKind,
296
296
  // procedure can raise an approval gate). Exported beside the others for
297
297
  // consumers assembling `Tool` objects by hand.
298
298
  assertComposedOf, assertGates, } from './tools/tools.js';
299
+ // Host-filled tool arguments: a field the HOST fills from the call's credential
300
+ // or the caller's identity — removed from the model's schema, a model-sent
301
+ // value refused by name, the credential scrubbed from what comes back.
302
+ export { hostFilled, fromCredential, fromIdentity, HostFilledArgumentError, HostFilledValueMissingError, HOST_FILLED_PLACEHOLDER, } from './tools/hostFilled.js';
299
303
  // The tool-name law (`lib/toolName.ts`): the strict check and the dev-mode
300
304
  // warning `defineTool` runs, for consumers assembling `Tool` objects by hand.
301
305
  export { assertValidToolName, warnIfInvalidToolName } from './lib/toolName.js';