@robota-sdk/agent-core 3.0.0-beta.8 → 3.0.0-beta.82

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 (557) hide show
  1. package/CHANGELOG.md +878 -0
  2. package/LICENSE +661 -21
  3. package/README.md +153 -26
  4. package/dist/browser/bounded-output-DpjpS98g.js +2 -0
  5. package/dist/browser/bounded-output-DpjpS98g.js.map +1 -0
  6. package/dist/browser/command-executor-cI7XJ374.js +2 -0
  7. package/dist/browser/command-executor-cI7XJ374.js.map +1 -0
  8. package/dist/browser/http-executor-CHy6UeBU.js +2 -0
  9. package/dist/browser/http-executor-CHy6UeBU.js.map +1 -0
  10. package/dist/browser/index.d.ts +6385 -3393
  11. package/dist/browser/index.d.ts.map +1 -0
  12. package/dist/browser/index.js +13 -5
  13. package/dist/browser/index.js.map +1 -0
  14. package/dist/browser/verdict-decoder-Dk_w2NG9.js +2 -0
  15. package/dist/browser/verdict-decoder-Dk_w2NG9.js.map +1 -0
  16. package/dist/node/bounded-output-DpjpS98g.js +2 -0
  17. package/dist/node/bounded-output-DpjpS98g.js.map +1 -0
  18. package/dist/node/command-executor-Aat_q7P2.cjs +1 -0
  19. package/dist/node/command-executor-DV-H2oD6.js +2 -0
  20. package/dist/node/command-executor-DV-H2oD6.js.map +1 -0
  21. package/dist/node/http-executor-71JiIdFP.cjs +1 -0
  22. package/dist/node/http-executor-cWzI2svn.js +2 -0
  23. package/dist/node/http-executor-cWzI2svn.js.map +1 -0
  24. package/dist/node/index-BhfNtQJk.d.cts +6898 -0
  25. package/dist/node/index-BhfNtQJk.d.cts.map +1 -0
  26. package/dist/node/index-D2rky0wZ.d.ts +6898 -0
  27. package/dist/node/index-D2rky0wZ.d.ts.map +1 -0
  28. package/dist/node/index.cjs +12 -5
  29. package/dist/node/index.d.cts +3 -4238
  30. package/dist/node/index.d.ts +3 -4238
  31. package/dist/node/index.js +13 -5
  32. package/dist/node/index.js.map +1 -0
  33. package/dist/node/node.cjs +1 -0
  34. package/dist/node/node.d.cts +236 -0
  35. package/dist/node/node.d.cts.map +1 -0
  36. package/dist/node/node.d.ts +236 -0
  37. package/dist/node/node.d.ts.map +1 -0
  38. package/dist/node/node.js +2 -0
  39. package/dist/node/node.js.map +1 -0
  40. package/dist/node/project-tool-schema-DrDjGKnH.cjs +1 -0
  41. package/dist/node/project-tool-schema-_UKfY7yO.js +2 -0
  42. package/dist/node/project-tool-schema-_UKfY7yO.js.map +1 -0
  43. package/dist/node/rolldown-runtime-DK3Fl9T5.js +1 -0
  44. package/dist/node/rolldown-runtime-DWNI8pZO.cjs +1 -0
  45. package/dist/node/testing/index.cjs +1 -0
  46. package/dist/node/testing/index.d.cts +96 -0
  47. package/dist/node/testing/index.d.cts.map +1 -0
  48. package/dist/node/testing/index.d.ts +96 -0
  49. package/dist/node/testing/index.d.ts.map +1 -0
  50. package/dist/node/testing/index.js +2 -0
  51. package/dist/node/testing/index.js.map +1 -0
  52. package/dist/node/types-gNrckgFE.d.cts +335 -0
  53. package/dist/node/types-gNrckgFE.d.cts.map +1 -0
  54. package/dist/node/types-gNrckgFE.d.ts +335 -0
  55. package/dist/node/types-gNrckgFE.d.ts.map +1 -0
  56. package/dist/node/verdict-decoder-Dk_w2NG9.js +2 -0
  57. package/dist/node/verdict-decoder-Dk_w2NG9.js.map +1 -0
  58. package/dist/node/verdict-decoder-Estx9MtY.cjs +1 -0
  59. package/package.json +89 -23
  60. package/dist/abstracts/abstract-agent.d.ts +0 -56
  61. package/dist/abstracts/abstract-agent.d.ts.map +0 -1
  62. package/dist/abstracts/abstract-agent.js +0 -55
  63. package/dist/abstracts/abstract-agent.js.map +0 -1
  64. package/dist/abstracts/abstract-ai-provider.d.ts +0 -187
  65. package/dist/abstracts/abstract-ai-provider.d.ts.map +0 -1
  66. package/dist/abstracts/abstract-ai-provider.js +0 -252
  67. package/dist/abstracts/abstract-ai-provider.js.map +0 -1
  68. package/dist/abstracts/abstract-executor.d.ts +0 -110
  69. package/dist/abstracts/abstract-executor.d.ts.map +0 -1
  70. package/dist/abstracts/abstract-executor.js +0 -156
  71. package/dist/abstracts/abstract-executor.js.map +0 -1
  72. package/dist/abstracts/abstract-manager.d.ts +0 -42
  73. package/dist/abstracts/abstract-manager.d.ts.map +0 -1
  74. package/dist/abstracts/abstract-manager.js +0 -49
  75. package/dist/abstracts/abstract-manager.js.map +0 -1
  76. package/dist/abstracts/abstract-module.d.ts +0 -365
  77. package/dist/abstracts/abstract-module.d.ts.map +0 -1
  78. package/dist/abstracts/abstract-module.js +0 -474
  79. package/dist/abstracts/abstract-module.js.map +0 -1
  80. package/dist/abstracts/abstract-plugin.d.ts +0 -369
  81. package/dist/abstracts/abstract-plugin.d.ts.map +0 -1
  82. package/dist/abstracts/abstract-plugin.js +0 -258
  83. package/dist/abstracts/abstract-plugin.js.map +0 -1
  84. package/dist/abstracts/abstract-tool.d.ts +0 -175
  85. package/dist/abstracts/abstract-tool.d.ts.map +0 -1
  86. package/dist/abstracts/abstract-tool.js +0 -140
  87. package/dist/abstracts/abstract-tool.js.map +0 -1
  88. package/dist/abstracts/abstract-workflow-converter.d.ts +0 -136
  89. package/dist/abstracts/abstract-workflow-converter.d.ts.map +0 -1
  90. package/dist/abstracts/abstract-workflow-converter.js +0 -252
  91. package/dist/abstracts/abstract-workflow-converter.js.map +0 -1
  92. package/dist/abstracts/abstract-workflow-validator.d.ts +0 -203
  93. package/dist/abstracts/abstract-workflow-validator.d.ts.map +0 -1
  94. package/dist/abstracts/abstract-workflow-validator.js +0 -447
  95. package/dist/abstracts/abstract-workflow-validator.js.map +0 -1
  96. package/dist/abstracts/index.d.ts +0 -6
  97. package/dist/abstracts/index.d.ts.map +0 -1
  98. package/dist/abstracts/index.js +0 -9
  99. package/dist/abstracts/index.js.map +0 -1
  100. package/dist/agents/constants.d.ts +0 -23
  101. package/dist/agents/constants.d.ts.map +0 -1
  102. package/dist/agents/constants.js +0 -22
  103. package/dist/agents/constants.js.map +0 -1
  104. package/dist/agents/index.d.ts +0 -1
  105. package/dist/agents/index.d.ts.map +0 -1
  106. package/dist/agents/index.js +0 -4
  107. package/dist/agents/index.js.map +0 -1
  108. package/dist/agents/robota.test.d.ts +0 -2
  109. package/dist/agents/robota.test.d.ts.map +0 -1
  110. package/dist/agents/robota.test.js +0 -416
  111. package/dist/agents/robota.test.js.map +0 -1
  112. package/dist/browser/builtin-templates.json +0 -107
  113. package/dist/core/robota.d.ts +0 -694
  114. package/dist/core/robota.d.ts.map +0 -1
  115. package/dist/core/robota.js +0 -1277
  116. package/dist/core/robota.js.map +0 -1
  117. package/dist/executors/local-executor.d.ts +0 -96
  118. package/dist/executors/local-executor.d.ts.map +0 -1
  119. package/dist/executors/local-executor.js +0 -197
  120. package/dist/executors/local-executor.js.map +0 -1
  121. package/dist/executors/local-executor.test.d.ts +0 -2
  122. package/dist/executors/local-executor.test.d.ts.map +0 -1
  123. package/dist/executors/local-executor.test.js +0 -192
  124. package/dist/executors/local-executor.test.js.map +0 -1
  125. package/dist/index.d.ts +0 -274
  126. package/dist/index.d.ts.map +0 -1
  127. package/dist/index.js +0 -235
  128. package/dist/index.js.map +0 -1
  129. package/dist/interfaces/agent.d.ts +0 -198
  130. package/dist/interfaces/agent.d.ts.map +0 -1
  131. package/dist/interfaces/agent.js +0 -2
  132. package/dist/interfaces/agent.js.map +0 -1
  133. package/dist/interfaces/event-service.d.ts +0 -79
  134. package/dist/interfaces/event-service.d.ts.map +0 -1
  135. package/dist/interfaces/event-service.js +0 -2
  136. package/dist/interfaces/event-service.js.map +0 -1
  137. package/dist/interfaces/executor.d.ts +0 -128
  138. package/dist/interfaces/executor.d.ts.map +0 -1
  139. package/dist/interfaces/executor.js +0 -2
  140. package/dist/interfaces/executor.js.map +0 -1
  141. package/dist/interfaces/history-module.d.ts +0 -19
  142. package/dist/interfaces/history-module.d.ts.map +0 -1
  143. package/dist/interfaces/history-module.js +0 -2
  144. package/dist/interfaces/history-module.js.map +0 -1
  145. package/dist/interfaces/index.d.ts +0 -13
  146. package/dist/interfaces/index.d.ts.map +0 -1
  147. package/dist/interfaces/index.js +0 -4
  148. package/dist/interfaces/index.js.map +0 -1
  149. package/dist/interfaces/manager.d.ts +0 -142
  150. package/dist/interfaces/manager.d.ts.map +0 -1
  151. package/dist/interfaces/manager.js +0 -2
  152. package/dist/interfaces/manager.js.map +0 -1
  153. package/dist/interfaces/messages.d.ts +0 -75
  154. package/dist/interfaces/messages.d.ts.map +0 -1
  155. package/dist/interfaces/messages.js +0 -29
  156. package/dist/interfaces/messages.js.map +0 -1
  157. package/dist/interfaces/progress-reporting.d.ts +0 -86
  158. package/dist/interfaces/progress-reporting.d.ts.map +0 -1
  159. package/dist/interfaces/progress-reporting.js +0 -37
  160. package/dist/interfaces/progress-reporting.js.map +0 -1
  161. package/dist/interfaces/provider.d.ts +0 -217
  162. package/dist/interfaces/provider.d.ts.map +0 -1
  163. package/dist/interfaces/provider.js +0 -2
  164. package/dist/interfaces/provider.js.map +0 -1
  165. package/dist/interfaces/service.d.ts +0 -205
  166. package/dist/interfaces/service.d.ts.map +0 -1
  167. package/dist/interfaces/service.js +0 -6
  168. package/dist/interfaces/service.js.map +0 -1
  169. package/dist/interfaces/tool.d.ts +0 -248
  170. package/dist/interfaces/tool.d.ts.map +0 -1
  171. package/dist/interfaces/tool.js +0 -2
  172. package/dist/interfaces/tool.js.map +0 -1
  173. package/dist/interfaces/types.d.ts +0 -71
  174. package/dist/interfaces/types.d.ts.map +0 -1
  175. package/dist/interfaces/types.js +0 -33
  176. package/dist/interfaces/types.js.map +0 -1
  177. package/dist/interfaces/workflow-converter.d.ts +0 -193
  178. package/dist/interfaces/workflow-converter.d.ts.map +0 -1
  179. package/dist/interfaces/workflow-converter.js +0 -11
  180. package/dist/interfaces/workflow-converter.js.map +0 -1
  181. package/dist/interfaces/workflow-validator.d.ts +0 -209
  182. package/dist/interfaces/workflow-validator.d.ts.map +0 -1
  183. package/dist/interfaces/workflow-validator.js +0 -16
  184. package/dist/interfaces/workflow-validator.js.map +0 -1
  185. package/dist/managers/agent-factory.d.ts +0 -132
  186. package/dist/managers/agent-factory.d.ts.map +0 -1
  187. package/dist/managers/agent-factory.js +0 -284
  188. package/dist/managers/agent-factory.js.map +0 -1
  189. package/dist/managers/agent-factory.test.d.ts +0 -2
  190. package/dist/managers/agent-factory.test.d.ts.map +0 -1
  191. package/dist/managers/agent-factory.test.js +0 -249
  192. package/dist/managers/agent-factory.test.js.map +0 -1
  193. package/dist/managers/agent-templates.d.ts +0 -84
  194. package/dist/managers/agent-templates.d.ts.map +0 -1
  195. package/dist/managers/agent-templates.js +0 -159
  196. package/dist/managers/agent-templates.js.map +0 -1
  197. package/dist/managers/ai-provider-manager.d.ts +0 -80
  198. package/dist/managers/ai-provider-manager.d.ts.map +0 -1
  199. package/dist/managers/ai-provider-manager.js +0 -226
  200. package/dist/managers/ai-provider-manager.js.map +0 -1
  201. package/dist/managers/conversation-history-manager.d.ts +0 -455
  202. package/dist/managers/conversation-history-manager.d.ts.map +0 -1
  203. package/dist/managers/conversation-history-manager.js +0 -578
  204. package/dist/managers/conversation-history-manager.js.map +0 -1
  205. package/dist/managers/conversation-history-manager.test.d.ts +0 -2
  206. package/dist/managers/conversation-history-manager.test.d.ts.map +0 -1
  207. package/dist/managers/conversation-history-manager.test.js +0 -374
  208. package/dist/managers/conversation-history-manager.test.js.map +0 -1
  209. package/dist/managers/index.d.ts +0 -8
  210. package/dist/managers/index.d.ts.map +0 -1
  211. package/dist/managers/index.js +0 -8
  212. package/dist/managers/index.js.map +0 -1
  213. package/dist/managers/module-registry.d.ts +0 -161
  214. package/dist/managers/module-registry.d.ts.map +0 -1
  215. package/dist/managers/module-registry.js +0 -519
  216. package/dist/managers/module-registry.js.map +0 -1
  217. package/dist/managers/module-type-registry.d.ts +0 -113
  218. package/dist/managers/module-type-registry.d.ts.map +0 -1
  219. package/dist/managers/module-type-registry.js +0 -439
  220. package/dist/managers/module-type-registry.js.map +0 -1
  221. package/dist/managers/plugins.d.ts +0 -166
  222. package/dist/managers/plugins.d.ts.map +0 -1
  223. package/dist/managers/plugins.js +0 -339
  224. package/dist/managers/plugins.js.map +0 -1
  225. package/dist/managers/tool-manager.d.ts +0 -70
  226. package/dist/managers/tool-manager.d.ts.map +0 -1
  227. package/dist/managers/tool-manager.js +0 -138
  228. package/dist/managers/tool-manager.js.map +0 -1
  229. package/dist/managers/tool-manager.test.d.ts +0 -2
  230. package/dist/managers/tool-manager.test.d.ts.map +0 -1
  231. package/dist/managers/tool-manager.test.js +0 -186
  232. package/dist/managers/tool-manager.test.js.map +0 -1
  233. package/dist/node/builtin-templates.json +0 -107
  234. package/dist/plugins/conversation-history/conversation-history-plugin.d.ts +0 -67
  235. package/dist/plugins/conversation-history/conversation-history-plugin.d.ts.map +0 -1
  236. package/dist/plugins/conversation-history/conversation-history-plugin.js +0 -270
  237. package/dist/plugins/conversation-history/conversation-history-plugin.js.map +0 -1
  238. package/dist/plugins/conversation-history/index.d.ts +0 -3
  239. package/dist/plugins/conversation-history/index.d.ts.map +0 -1
  240. package/dist/plugins/conversation-history/index.js +0 -2
  241. package/dist/plugins/conversation-history/index.js.map +0 -1
  242. package/dist/plugins/conversation-history/storages/database-storage.d.ts +0 -19
  243. package/dist/plugins/conversation-history/storages/database-storage.d.ts.map +0 -1
  244. package/dist/plugins/conversation-history/storages/database-storage.js +0 -94
  245. package/dist/plugins/conversation-history/storages/database-storage.js.map +0 -1
  246. package/dist/plugins/conversation-history/storages/file-storage.d.ts +0 -15
  247. package/dist/plugins/conversation-history/storages/file-storage.d.ts.map +0 -1
  248. package/dist/plugins/conversation-history/storages/file-storage.js +0 -94
  249. package/dist/plugins/conversation-history/storages/file-storage.js.map +0 -1
  250. package/dist/plugins/conversation-history/storages/index.d.ts +0 -4
  251. package/dist/plugins/conversation-history/storages/index.d.ts.map +0 -1
  252. package/dist/plugins/conversation-history/storages/index.js +0 -4
  253. package/dist/plugins/conversation-history/storages/index.js.map +0 -1
  254. package/dist/plugins/conversation-history/storages/memory-storage.d.ts +0 -15
  255. package/dist/plugins/conversation-history/storages/memory-storage.d.ts.map +0 -1
  256. package/dist/plugins/conversation-history/storages/memory-storage.js +0 -33
  257. package/dist/plugins/conversation-history/storages/memory-storage.js.map +0 -1
  258. package/dist/plugins/conversation-history/types.d.ts +0 -61
  259. package/dist/plugins/conversation-history/types.d.ts.map +0 -1
  260. package/dist/plugins/conversation-history/types.js +0 -2
  261. package/dist/plugins/conversation-history/types.js.map +0 -1
  262. package/dist/plugins/error-handling/context-adapter.d.ts +0 -30
  263. package/dist/plugins/error-handling/context-adapter.d.ts.map +0 -1
  264. package/dist/plugins/error-handling/context-adapter.js +0 -41
  265. package/dist/plugins/error-handling/context-adapter.js.map +0 -1
  266. package/dist/plugins/error-handling/error-handling-plugin.d.ts +0 -49
  267. package/dist/plugins/error-handling/error-handling-plugin.d.ts.map +0 -1
  268. package/dist/plugins/error-handling/error-handling-plugin.js +0 -229
  269. package/dist/plugins/error-handling/error-handling-plugin.js.map +0 -1
  270. package/dist/plugins/error-handling/index.d.ts +0 -10
  271. package/dist/plugins/error-handling/index.d.ts.map +0 -1
  272. package/dist/plugins/error-handling/index.js +0 -10
  273. package/dist/plugins/error-handling/index.js.map +0 -1
  274. package/dist/plugins/error-handling/types.d.ts +0 -73
  275. package/dist/plugins/error-handling/types.d.ts.map +0 -1
  276. package/dist/plugins/error-handling/types.js +0 -14
  277. package/dist/plugins/error-handling/types.js.map +0 -1
  278. package/dist/plugins/event-emitter/metrics.d.ts +0 -17
  279. package/dist/plugins/event-emitter/metrics.d.ts.map +0 -1
  280. package/dist/plugins/event-emitter/metrics.js +0 -17
  281. package/dist/plugins/event-emitter/metrics.js.map +0 -1
  282. package/dist/plugins/event-emitter/types.d.ts +0 -112
  283. package/dist/plugins/event-emitter/types.d.ts.map +0 -1
  284. package/dist/plugins/event-emitter/types.js +0 -65
  285. package/dist/plugins/event-emitter/types.js.map +0 -1
  286. package/dist/plugins/event-emitter-plugin.d.ts +0 -222
  287. package/dist/plugins/event-emitter-plugin.d.ts.map +0 -1
  288. package/dist/plugins/event-emitter-plugin.js +0 -432
  289. package/dist/plugins/event-emitter-plugin.js.map +0 -1
  290. package/dist/plugins/event-emitter-plugin.test.d.ts +0 -2
  291. package/dist/plugins/event-emitter-plugin.test.d.ts.map +0 -1
  292. package/dist/plugins/event-emitter-plugin.test.js +0 -94
  293. package/dist/plugins/event-emitter-plugin.test.js.map +0 -1
  294. package/dist/plugins/execution/execution-analytics-plugin.d.ts +0 -129
  295. package/dist/plugins/execution/execution-analytics-plugin.d.ts.map +0 -1
  296. package/dist/plugins/execution/execution-analytics-plugin.js +0 -517
  297. package/dist/plugins/execution/execution-analytics-plugin.js.map +0 -1
  298. package/dist/plugins/execution/index.d.ts +0 -3
  299. package/dist/plugins/execution/index.d.ts.map +0 -1
  300. package/dist/plugins/execution/index.js +0 -2
  301. package/dist/plugins/execution/index.js.map +0 -1
  302. package/dist/plugins/execution/types.d.ts +0 -90
  303. package/dist/plugins/execution/types.d.ts.map +0 -1
  304. package/dist/plugins/execution/types.js +0 -2
  305. package/dist/plugins/execution/types.js.map +0 -1
  306. package/dist/plugins/index.d.ts +0 -10
  307. package/dist/plugins/index.d.ts.map +0 -1
  308. package/dist/plugins/index.js +0 -11
  309. package/dist/plugins/index.js.map +0 -1
  310. package/dist/plugins/limits/types.d.ts +0 -61
  311. package/dist/plugins/limits/types.d.ts.map +0 -1
  312. package/dist/plugins/limits/types.js +0 -2
  313. package/dist/plugins/limits/types.js.map +0 -1
  314. package/dist/plugins/limits-plugin.d.ts +0 -113
  315. package/dist/plugins/limits-plugin.d.ts.map +0 -1
  316. package/dist/plugins/limits-plugin.js +0 -380
  317. package/dist/plugins/limits-plugin.js.map +0 -1
  318. package/dist/plugins/logging/formatters.d.ts +0 -14
  319. package/dist/plugins/logging/formatters.d.ts.map +0 -1
  320. package/dist/plugins/logging/formatters.js +0 -24
  321. package/dist/plugins/logging/formatters.js.map +0 -1
  322. package/dist/plugins/logging/index.d.ts +0 -3
  323. package/dist/plugins/logging/index.d.ts.map +0 -1
  324. package/dist/plugins/logging/index.js +0 -2
  325. package/dist/plugins/logging/index.js.map +0 -1
  326. package/dist/plugins/logging/logging-plugin.d.ts +0 -91
  327. package/dist/plugins/logging/logging-plugin.d.ts.map +0 -1
  328. package/dist/plugins/logging/logging-plugin.js +0 -335
  329. package/dist/plugins/logging/logging-plugin.js.map +0 -1
  330. package/dist/plugins/logging/storages/console-storage.d.ts +0 -14
  331. package/dist/plugins/logging/storages/console-storage.d.ts.map +0 -1
  332. package/dist/plugins/logging/storages/console-storage.js +0 -38
  333. package/dist/plugins/logging/storages/console-storage.js.map +0 -1
  334. package/dist/plugins/logging/storages/file-storage.d.ts +0 -14
  335. package/dist/plugins/logging/storages/file-storage.d.ts.map +0 -1
  336. package/dist/plugins/logging/storages/file-storage.js +0 -41
  337. package/dist/plugins/logging/storages/file-storage.js.map +0 -1
  338. package/dist/plugins/logging/storages/index.d.ts +0 -5
  339. package/dist/plugins/logging/storages/index.d.ts.map +0 -1
  340. package/dist/plugins/logging/storages/index.js +0 -5
  341. package/dist/plugins/logging/storages/index.js.map +0 -1
  342. package/dist/plugins/logging/storages/remote-storage.d.ts +0 -20
  343. package/dist/plugins/logging/storages/remote-storage.d.ts.map +0 -1
  344. package/dist/plugins/logging/storages/remote-storage.js +0 -61
  345. package/dist/plugins/logging/storages/remote-storage.js.map +0 -1
  346. package/dist/plugins/logging/storages/silent-storage.d.ts +0 -10
  347. package/dist/plugins/logging/storages/silent-storage.d.ts.map +0 -1
  348. package/dist/plugins/logging/storages/silent-storage.js +0 -15
  349. package/dist/plugins/logging/storages/silent-storage.js.map +0 -1
  350. package/dist/plugins/logging/types.d.ts +0 -84
  351. package/dist/plugins/logging/types.d.ts.map +0 -1
  352. package/dist/plugins/logging/types.js +0 -2
  353. package/dist/plugins/logging/types.js.map +0 -1
  354. package/dist/plugins/performance/collectors/system-metrics-collector.d.ts +0 -12
  355. package/dist/plugins/performance/collectors/system-metrics-collector.d.ts.map +0 -1
  356. package/dist/plugins/performance/collectors/system-metrics-collector.js +0 -65
  357. package/dist/plugins/performance/collectors/system-metrics-collector.js.map +0 -1
  358. package/dist/plugins/performance/index.d.ts +0 -5
  359. package/dist/plugins/performance/index.d.ts.map +0 -1
  360. package/dist/plugins/performance/index.js +0 -4
  361. package/dist/plugins/performance/index.js.map +0 -1
  362. package/dist/plugins/performance/performance-plugin.d.ts +0 -49
  363. package/dist/plugins/performance/performance-plugin.d.ts.map +0 -1
  364. package/dist/plugins/performance/performance-plugin.js +0 -293
  365. package/dist/plugins/performance/performance-plugin.js.map +0 -1
  366. package/dist/plugins/performance/storages/index.d.ts +0 -2
  367. package/dist/plugins/performance/storages/index.d.ts.map +0 -1
  368. package/dist/plugins/performance/storages/index.js +0 -4
  369. package/dist/plugins/performance/storages/index.js.map +0 -1
  370. package/dist/plugins/performance/storages/memory-storage.d.ts +0 -19
  371. package/dist/plugins/performance/storages/memory-storage.d.ts.map +0 -1
  372. package/dist/plugins/performance/storages/memory-storage.js +0 -69
  373. package/dist/plugins/performance/storages/memory-storage.js.map +0 -1
  374. package/dist/plugins/performance/types.d.ts +0 -154
  375. package/dist/plugins/performance/types.d.ts.map +0 -1
  376. package/dist/plugins/performance/types.js +0 -2
  377. package/dist/plugins/performance/types.js.map +0 -1
  378. package/dist/plugins/usage/aggregate-usage-stats.d.ts +0 -12
  379. package/dist/plugins/usage/aggregate-usage-stats.d.ts.map +0 -1
  380. package/dist/plugins/usage/aggregate-usage-stats.js +0 -115
  381. package/dist/plugins/usage/aggregate-usage-stats.js.map +0 -1
  382. package/dist/plugins/usage/index.d.ts +0 -5
  383. package/dist/plugins/usage/index.d.ts.map +0 -1
  384. package/dist/plugins/usage/index.js +0 -4
  385. package/dist/plugins/usage/index.js.map +0 -1
  386. package/dist/plugins/usage/storages/file-storage.d.ts +0 -22
  387. package/dist/plugins/usage/storages/file-storage.d.ts.map +0 -1
  388. package/dist/plugins/usage/storages/file-storage.js +0 -111
  389. package/dist/plugins/usage/storages/file-storage.js.map +0 -1
  390. package/dist/plugins/usage/storages/index.d.ts +0 -5
  391. package/dist/plugins/usage/storages/index.d.ts.map +0 -1
  392. package/dist/plugins/usage/storages/index.js +0 -5
  393. package/dist/plugins/usage/storages/index.js.map +0 -1
  394. package/dist/plugins/usage/storages/memory-storage.d.ts +0 -22
  395. package/dist/plugins/usage/storages/memory-storage.d.ts.map +0 -1
  396. package/dist/plugins/usage/storages/memory-storage.js +0 -42
  397. package/dist/plugins/usage/storages/memory-storage.js.map +0 -1
  398. package/dist/plugins/usage/storages/remote-storage.d.ts +0 -26
  399. package/dist/plugins/usage/storages/remote-storage.d.ts.map +0 -1
  400. package/dist/plugins/usage/storages/remote-storage.js +0 -115
  401. package/dist/plugins/usage/storages/remote-storage.js.map +0 -1
  402. package/dist/plugins/usage/storages/silent-storage.d.ts +0 -19
  403. package/dist/plugins/usage/storages/silent-storage.d.ts.map +0 -1
  404. package/dist/plugins/usage/storages/silent-storage.js +0 -26
  405. package/dist/plugins/usage/storages/silent-storage.js.map +0 -1
  406. package/dist/plugins/usage/types.d.ts +0 -127
  407. package/dist/plugins/usage/types.d.ts.map +0 -1
  408. package/dist/plugins/usage/types.js +0 -2
  409. package/dist/plugins/usage/types.js.map +0 -1
  410. package/dist/plugins/usage/usage-plugin.d.ts +0 -67
  411. package/dist/plugins/usage/usage-plugin.d.ts.map +0 -1
  412. package/dist/plugins/usage/usage-plugin.js +0 -309
  413. package/dist/plugins/usage/usage-plugin.js.map +0 -1
  414. package/dist/plugins/webhook/http-client.d.ts +0 -30
  415. package/dist/plugins/webhook/http-client.d.ts.map +0 -1
  416. package/dist/plugins/webhook/http-client.js +0 -110
  417. package/dist/plugins/webhook/http-client.js.map +0 -1
  418. package/dist/plugins/webhook/index.d.ts +0 -9
  419. package/dist/plugins/webhook/index.d.ts.map +0 -1
  420. package/dist/plugins/webhook/index.js +0 -9
  421. package/dist/plugins/webhook/index.js.map +0 -1
  422. package/dist/plugins/webhook/transformer.d.ts +0 -63
  423. package/dist/plugins/webhook/transformer.d.ts.map +0 -1
  424. package/dist/plugins/webhook/transformer.js +0 -157
  425. package/dist/plugins/webhook/transformer.js.map +0 -1
  426. package/dist/plugins/webhook/types.d.ts +0 -183
  427. package/dist/plugins/webhook/types.d.ts.map +0 -1
  428. package/dist/plugins/webhook/types.js +0 -2
  429. package/dist/plugins/webhook/types.js.map +0 -1
  430. package/dist/plugins/webhook/webhook-plugin.d.ts +0 -92
  431. package/dist/plugins/webhook/webhook-plugin.d.ts.map +0 -1
  432. package/dist/plugins/webhook/webhook-plugin.js +0 -328
  433. package/dist/plugins/webhook/webhook-plugin.js.map +0 -1
  434. package/dist/schemas/agent-template-schema.d.ts +0 -137
  435. package/dist/schemas/agent-template-schema.d.ts.map +0 -1
  436. package/dist/schemas/agent-template-schema.js +0 -87
  437. package/dist/schemas/agent-template-schema.js.map +0 -1
  438. package/dist/services/conversation-service/index.d.ts +0 -88
  439. package/dist/services/conversation-service/index.d.ts.map +0 -1
  440. package/dist/services/conversation-service/index.js +0 -441
  441. package/dist/services/conversation-service/index.js.map +0 -1
  442. package/dist/services/conversation-service/types.d.ts +0 -32
  443. package/dist/services/conversation-service/types.d.ts.map +0 -1
  444. package/dist/services/conversation-service/types.js +0 -8
  445. package/dist/services/conversation-service/types.js.map +0 -1
  446. package/dist/services/event-service.d.ts +0 -61
  447. package/dist/services/event-service.d.ts.map +0 -1
  448. package/dist/services/event-service.js +0 -110
  449. package/dist/services/event-service.js.map +0 -1
  450. package/dist/services/event-service.test.d.ts +0 -2
  451. package/dist/services/event-service.test.d.ts.map +0 -1
  452. package/dist/services/event-service.test.js +0 -86
  453. package/dist/services/event-service.test.js.map +0 -1
  454. package/dist/services/execution-service.d.ts +0 -151
  455. package/dist/services/execution-service.d.ts.map +0 -1
  456. package/dist/services/execution-service.js +0 -1262
  457. package/dist/services/execution-service.js.map +0 -1
  458. package/dist/services/execution-service.test.d.ts +0 -2
  459. package/dist/services/execution-service.test.d.ts.map +0 -1
  460. package/dist/services/execution-service.test.js +0 -338
  461. package/dist/services/execution-service.test.js.map +0 -1
  462. package/dist/services/history-module.d.ts +0 -15
  463. package/dist/services/history-module.d.ts.map +0 -1
  464. package/dist/services/history-module.js +0 -42
  465. package/dist/services/history-module.js.map +0 -1
  466. package/dist/services/in-memory-history-store.d.ts +0 -12
  467. package/dist/services/in-memory-history-store.d.ts.map +0 -1
  468. package/dist/services/in-memory-history-store.js +0 -41
  469. package/dist/services/in-memory-history-store.js.map +0 -1
  470. package/dist/services/index.d.ts +0 -7
  471. package/dist/services/index.d.ts.map +0 -1
  472. package/dist/services/index.js +0 -13
  473. package/dist/services/index.js.map +0 -1
  474. package/dist/services/task-events.d.ts +0 -6
  475. package/dist/services/task-events.d.ts.map +0 -1
  476. package/dist/services/task-events.js +0 -6
  477. package/dist/services/task-events.js.map +0 -1
  478. package/dist/services/tool-execution-service.d.ts +0 -74
  479. package/dist/services/tool-execution-service.d.ts.map +0 -1
  480. package/dist/services/tool-execution-service.js +0 -189
  481. package/dist/services/tool-execution-service.js.map +0 -1
  482. package/dist/services/user-events.d.ts +0 -7
  483. package/dist/services/user-events.d.ts.map +0 -1
  484. package/dist/services/user-events.js +0 -6
  485. package/dist/services/user-events.js.map +0 -1
  486. package/dist/tools/implementations/function-tool/index.d.ts +0 -9
  487. package/dist/tools/implementations/function-tool/index.d.ts.map +0 -1
  488. package/dist/tools/implementations/function-tool/index.js +0 -13
  489. package/dist/tools/implementations/function-tool/index.js.map +0 -1
  490. package/dist/tools/implementations/function-tool/schema-converter.d.ts +0 -32
  491. package/dist/tools/implementations/function-tool/schema-converter.d.ts.map +0 -1
  492. package/dist/tools/implementations/function-tool/schema-converter.js +0 -164
  493. package/dist/tools/implementations/function-tool/schema-converter.js.map +0 -1
  494. package/dist/tools/implementations/function-tool/types.d.ts +0 -72
  495. package/dist/tools/implementations/function-tool/types.d.ts.map +0 -1
  496. package/dist/tools/implementations/function-tool/types.js +0 -14
  497. package/dist/tools/implementations/function-tool/types.js.map +0 -1
  498. package/dist/tools/implementations/function-tool.d.ts +0 -49
  499. package/dist/tools/implementations/function-tool.d.ts.map +0 -1
  500. package/dist/tools/implementations/function-tool.js +0 -223
  501. package/dist/tools/implementations/function-tool.js.map +0 -1
  502. package/dist/tools/implementations/index.d.ts +0 -4
  503. package/dist/tools/implementations/index.d.ts.map +0 -1
  504. package/dist/tools/implementations/index.js +0 -5
  505. package/dist/tools/implementations/index.js.map +0 -1
  506. package/dist/tools/implementations/mcp-tool.d.ts +0 -72
  507. package/dist/tools/implementations/mcp-tool.d.ts.map +0 -1
  508. package/dist/tools/implementations/mcp-tool.js +0 -246
  509. package/dist/tools/implementations/mcp-tool.js.map +0 -1
  510. package/dist/tools/implementations/openapi-tool.d.ts +0 -56
  511. package/dist/tools/implementations/openapi-tool.d.ts.map +0 -1
  512. package/dist/tools/implementations/openapi-tool.js +0 -324
  513. package/dist/tools/implementations/openapi-tool.js.map +0 -1
  514. package/dist/tools/implementations/relay-mcp-tool.d.ts +0 -38
  515. package/dist/tools/implementations/relay-mcp-tool.d.ts.map +0 -1
  516. package/dist/tools/implementations/relay-mcp-tool.js +0 -46
  517. package/dist/tools/implementations/relay-mcp-tool.js.map +0 -1
  518. package/dist/tools/index.d.ts +0 -3
  519. package/dist/tools/index.d.ts.map +0 -1
  520. package/dist/tools/index.js +0 -4
  521. package/dist/tools/index.js.map +0 -1
  522. package/dist/tools/registry/index.d.ts +0 -2
  523. package/dist/tools/registry/index.d.ts.map +0 -1
  524. package/dist/tools/registry/index.js +0 -3
  525. package/dist/tools/registry/index.js.map +0 -1
  526. package/dist/tools/registry/tool-registry.d.ts +0 -54
  527. package/dist/tools/registry/tool-registry.d.ts.map +0 -1
  528. package/dist/tools/registry/tool-registry.js +0 -146
  529. package/dist/tools/registry/tool-registry.js.map +0 -1
  530. package/dist/utils/errors.d.ts +0 -155
  531. package/dist/utils/errors.d.ts.map +0 -1
  532. package/dist/utils/errors.js +0 -203
  533. package/dist/utils/errors.js.map +0 -1
  534. package/dist/utils/execution-proxy.d.ts +0 -75
  535. package/dist/utils/execution-proxy.d.ts.map +0 -1
  536. package/dist/utils/execution-proxy.js +0 -230
  537. package/dist/utils/execution-proxy.js.map +0 -1
  538. package/dist/utils/index.d.ts +0 -11
  539. package/dist/utils/index.d.ts.map +0 -1
  540. package/dist/utils/index.js +0 -7
  541. package/dist/utils/index.js.map +0 -1
  542. package/dist/utils/logger.d.ts +0 -74
  543. package/dist/utils/logger.d.ts.map +0 -1
  544. package/dist/utils/logger.js +0 -143
  545. package/dist/utils/logger.js.map +0 -1
  546. package/dist/utils/message-converter.d.ts +0 -68
  547. package/dist/utils/message-converter.d.ts.map +0 -1
  548. package/dist/utils/message-converter.js +0 -87
  549. package/dist/utils/message-converter.js.map +0 -1
  550. package/dist/utils/periodic-task.d.ts +0 -14
  551. package/dist/utils/periodic-task.d.ts.map +0 -1
  552. package/dist/utils/periodic-task.js +0 -26
  553. package/dist/utils/periodic-task.js.map +0 -1
  554. package/dist/utils/validation.d.ts +0 -40
  555. package/dist/utils/validation.d.ts.map +0 -1
  556. package/dist/utils/validation.js +0 -162
  557. package/dist/utils/validation.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @robota-sdk/agent-core
1
+ # Agent Core
2
2
 
3
3
  The foundation layer of the Robota SDK. Provides the `Robota` agent class, abstract base classes for providers/tools/plugins, the permission system, hook system, event services, and error hierarchy.
4
4
 
@@ -22,8 +22,8 @@ const agent = new Robota({
22
22
  defaultModel: {
23
23
  provider: 'anthropic',
24
24
  model: 'claude-sonnet-4-6',
25
- systemMessage: 'You are a helpful assistant.',
26
25
  },
26
+ systemMessage: 'You are a helpful assistant.',
27
27
  });
28
28
 
29
29
  const response = await agent.run('Hello, world!');
@@ -33,17 +33,29 @@ console.log(response);
33
33
  ## Key Features
34
34
 
35
35
  - **Robota class**: AI agent with conversation history, tool execution, and plugin support
36
+ - **ConversationStore**: Append-only conversation history with streaming buffer (`beginAssistant`/`appendStreaming`/`commitAssistant`)
37
+ - **IBaseMessage**: Every message has a unique `id` (UUID) and `state` (`'complete'` | `'interrupted'`)
36
38
  - **Multi-provider**: Register multiple providers, switch dynamically with `setModel()`
39
+ - **Provider capabilities**: Provider-neutral capability reports distinguish local tools from provider-native hosted web search/fetch
40
+ - **AbstractAIProvider.streamWithAbort()**: Standard streaming wrapper for all providers — handles AbortSignal, returns partial content on abort
37
41
  - **Permission system**: Deterministic 3-step policy evaluation (`evaluatePermission`)
38
42
  - **Hook system**: Shell command-based lifecycle hooks (`runHooks`)
39
43
  - **Plugin system**: `AbstractPlugin` base class with lifecycle hooks (beforeRun, afterRun, onError, etc.)
40
44
  - **Event services**: Unified event emission with owner path tracking
41
45
  - **Error hierarchy**: Typed errors extending `RobotaError` (ProviderError, RateLimitError, etc.)
46
+ - **Model metadata registry**: providers contribute their own models via `registerModelMetadata()`; core owns the registry and the lookups, not any vendor's catalogue (NEUT-010)
47
+ - **callProviderWithCache**: Accepts `Partial<IChatOptions>` overrides for per-call configuration
48
+ - **AbortSignal propagation**: Signal flows through the entire execution chain (Session -> Robota -> Provider)
49
+ - **Execution boundary events**: `Robota.run()` can emit provider/tool provenance events through `onExecutionEvent`
42
50
  - **Type safety**: Strict TypeScript, zero `any` in production code
43
51
 
44
52
  ## Robota API
45
53
 
46
54
  ```typescript
55
+ import { Robota } from '@robota-sdk/agent-core';
56
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
57
+
58
+ declare const config: IAgentConfig;
47
59
  const agent = new Robota(config);
48
60
 
49
61
  // Send a message (executes tool calls automatically)
@@ -57,43 +69,150 @@ agent.clearHistory();
57
69
  agent.setModel({ provider: 'openai', model: 'gpt-4o' });
58
70
  ```
59
71
 
72
+ ### Structured Output
73
+
74
+ `run(input, { output })` returns a schema-validated object instead of a string. Zod schemas give a
75
+ typed result; the schema is forwarded to the provider's native structured-output surface where one
76
+ exists, and the response is always validated core-side with a bounded retry on violation
77
+ (`outputRetries`, default 2). Exhausted retries throw `StructuredOutputError`.
78
+
79
+ ```typescript
80
+ import { z } from 'zod';
81
+ import { Robota } from '@robota-sdk/agent-core';
82
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
83
+
84
+ declare const config: IAgentConfig;
85
+ const agent = new Robota(config);
86
+
87
+ const reportSchema = z.object({
88
+ title: z.string(),
89
+ score: z.number(),
90
+ summary: z.string(),
91
+ });
92
+
93
+ // Typed result: { title: string; score: number; summary: string }
94
+ const report = await agent.run('Summarize the meeting as a report.', {
95
+ output: reportSchema,
96
+ });
97
+
98
+ // Streaming variant: deltas stream as usual; the validated object is the
99
+ // generator's return value (the final { done: true, value } iterator result).
100
+ const stream = agent.runStream('Summarize again.', { output: reportSchema });
101
+ const iterator = stream[Symbol.asyncIterator]();
102
+ let next = await iterator.next();
103
+ while (!next.done) {
104
+ process.stdout.write(next.value);
105
+ next = await iterator.next();
106
+ }
107
+ const streamedReport = next.value;
108
+ console.log(streamedReport.title);
109
+ ```
110
+
111
+ A raw JSON-schema wrapper is also accepted: `{ output: { jsonSchema: { type: 'object', properties: { answer: { type: 'string' } }, required: ['answer'] } } }`.
112
+
113
+ ### Model Options per Run
114
+
115
+ `run`/`runStream` accept run-scoped model options that win over `defaultModel.*`:
116
+ `maxTokens`, `temperature`, and `toolChoice`. `toolChoice` directs tool invocation —
117
+ `'auto'` (model decides), `'none'` (suppress tool calls), `'required'` (must call some
118
+ tool), or `{ tool: name }` (must call the named tool). A named tool missing from the run's
119
+ tool list throws immediately; nothing is silently ignored. Forcing directives apply to the
120
+ run's first model call only — rounds after tool results revert to `'auto'` so the model can
121
+ consume the results and finish.
122
+
123
+ ```typescript
124
+ import { Robota } from '@robota-sdk/agent-core';
125
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
126
+
127
+ declare const config: IAgentConfig;
128
+ const agent = new Robota(config);
129
+
130
+ // Force the model to answer via the router tool (decision-agent pattern)
131
+ const decision = await agent.run('Route this request.', {
132
+ toolChoice: { tool: 'route-request' },
133
+ allowToolOnlyCompletion: true,
134
+ });
135
+
136
+ // Suppress tools for a plain-text turn, capped at 100 output tokens
137
+ const summary = await agent.run('Summarize the discussion.', {
138
+ toolChoice: 'none',
139
+ maxTokens: 100,
140
+ });
141
+ console.log(decision, summary);
142
+ ```
143
+
144
+ The same directive can be set agent-wide via `defaultModel.toolChoice`.
145
+
146
+ ### Model Effort Selection
147
+
148
+ `defaultModel.effort` and per-call `IChatOptions.effort` accept `auto`, `none`, `minimal`, `low`,
149
+ `medium`, `high`, `xhigh`, or `max`. `auto` is preserved to the provider adapter, which resolves its
150
+ documented exact-model default from a source-dated capability table. The adapter reports the terminal
151
+ resolution, native-control, and dispatch outcome through `onModelEffortOutcome`; Core does not guess
152
+ vendor field names or defaults.
153
+
154
+ ### Execution Boundary Events
155
+
156
+ `run()` accepts `onExecutionEvent` in run options. The execution loop emits provider-neutral events that higher layers can persist as append-only session provenance:
157
+
158
+ - `provider_request`
159
+ - `provider_native_raw_payload`
160
+ - `provider_stream_raw_delta`
161
+ - `provider_response_raw`
162
+ - `provider_response_normalized`
163
+ - `assistant_message_committed`
164
+ - `tool_batch_started`
165
+ - `tool_execution_request`
166
+ - `tool_execution_result`
167
+ - `tool_message_committed`
168
+ - `history_mutation`
169
+
170
+ Provider-specific SDK payload capture remains provider-owned. Providers may call `IChatOptions.onProviderNativeRawPayload` with exact SDK request, response, or stream event objects; `Robota` forwards those callbacks as provider-neutral `provider_native_raw_payload` execution events without importing concrete provider SDK types. `provider_response_raw.responseKind` remains `provider-normalized-message`, which keeps common replay validation provider-neutral.
171
+
172
+ Each provider round also receives a `usageObservationId` before invocation. Streaming fragments from
173
+ that round reuse the identifier, while a separately billed round receives a new one. Persisted
174
+ analytics can therefore deduplicate provider usage by identity without collapsing equal token totals.
175
+
60
176
  ## IAgentConfig
61
177
 
62
- | Field | Type | Description |
63
- | ---------------------------- | -------------------------- | ------------------------------ |
64
- | `name` | `string` | Agent name |
65
- | `aiProviders` | `IAIProvider[]` | One or more provider instances |
66
- | `defaultModel.provider` | `string` | Provider name |
67
- | `defaultModel.model` | `string` | Model identifier |
68
- | `defaultModel.systemMessage` | `string?` | System prompt |
69
- | `tools` | `IToolWithEventService[]?` | Tools the agent can call |
70
- | `plugins` | `IPluginContract[]?` | Plugins for lifecycle hooks |
178
+ | Field | Type | Description |
179
+ | ----------------------- | -------------------------- | ------------------------------ |
180
+ | `name` | `string` | Agent name |
181
+ | `aiProviders` | `IAIProvider[]` | One or more provider instances |
182
+ | `defaultModel.provider` | `string` | Provider name |
183
+ | `defaultModel.model` | `string` | Model identifier |
184
+ | `systemMessage` | `string?` | System prompt (top-level) |
185
+ | `tools` | `IToolWithEventService[]?` | Tools the agent can call |
186
+ | `plugins` | `IPluginContract[]?` | Plugins for lifecycle hooks |
71
187
 
72
188
  ## Architecture
73
189
 
74
190
  ```
75
191
  agent-core (this package — zero workspace dependencies)
76
192
  ↑
77
- agent-sessions ← Session lifecycle
193
+ agent-session ← Session lifecycle
78
194
  agent-tools ← Tool implementations
79
- agent-providers ← AI provider implementations
80
- agent-plugins ← Plugin implementations (8 extracted packages)
195
+ agent-provider-* ← AI provider implementations (one package per vendor)
196
+ agent-plugin ← Plugin implementations (8 plugins, consolidated)
81
197
  ↑
82
- agent-sdk ← Assembly layer
198
+ agent-framework ← Assembly layer
83
199
  ↑
84
200
  agent-cli ← Terminal UI
85
201
  ```
86
202
 
87
- ## What This Package Provides
203
+ ## Public API Surface
88
204
 
89
- | Category | Exports |
90
- | --------------- | ---------------------------------------------------------------------------------------------------------------------- |
91
- | **Core** | `Robota`, `AbstractAgent`, `AbstractAIProvider`, `AbstractPlugin`, `AbstractTool`, `AbstractExecutor`, `LocalExecutor` |
92
- | **Permissions** | `evaluatePermission`, `MODE_POLICY`, `TRUST_TO_MODE`, `TPermissionMode`, `TToolArgs` |
93
- | **Hooks** | `runHooks`, `THookEvent` (PreToolUse, PostToolUse, PreCompact, PostCompact, SessionStart, Stop) |
94
- | **Events** | `AbstractEventService`, `DefaultEventService`, `StructuredEventService`, `EventEmitterPlugin` |
95
- | **Types** | `TUniversalMessage`, `IAgentConfig`, `IAIProvider`, `IToolSchema`, `IContextWindowState` |
96
- | **Errors** | `RobotaError`, `ProviderError`, `RateLimitError`, `AuthenticationError`, `ToolExecutionError`, etc. |
205
+ | Category | Exports |
206
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
207
+ | **Core** | `Robota`, `ConversationStore`, `AbstractAgent`, `AbstractAIProvider` (+ `streamWithAbort`), `AbstractPlugin`, `AbstractTool`, `AbstractExecutor`, `LocalExecutor`, `getProviderCapabilities`, `assertProviderNativeWebToolsAvailable` |
208
+ | **Permissions** | `evaluatePermission`, `MODE_POLICY`, `TRUST_TO_MODE`, `UNKNOWN_TOOL_FALLBACK`, `TPermissionMode`, `TTrustLevel`, `TPermissionDecision`, `TToolArgs`, `IPermissionLists`, `TKnownToolName` |
209
+ | **Hooks** | `runHooks`, `CommandExecutor`, `HttpExecutor`, `IHookTypeExecutor`, `THookEvent`, `THooksConfig`, `IHookGroup`, `IHookDefinition`, `IHookInput`, `THookOutcome` |
210
+ | **Events** | `EventEmitterPlugin`, `IEventService`, `IOwnerPathSegment` |
211
+ | **Models** | `registerModelMetadata()`, `DEFAULT_CONTEXT_WINDOW`, `DEFAULT_MAX_OUTPUT`, `getModelContextWindow()`, `getModelMaxOutput()`, `getModelName()`, `formatTokenCount()`, `IModelDefinition` |
212
+ | **Context** | `estimateContextTokensFromMessages()`, `estimateSerializedContextTokens()`, `readTokenUsageFromMessage()`, `IContextTokenEstimate`, `IMessageTokenUsage`, `IContextWindowState`, `IContextTokenUsage` |
213
+ | **Types** | `TUniversalMessage`, `IBaseMessage` (`id`, `state`), `TMessageState`, `IAgentConfig`, `IAIProvider`, `IProviderCapabilities`, `IProviderNativeWebToolRequest`, `IToolSchema`, `TTextDeltaCallback` |
214
+ | **Errors** | `RobotaError`, `ProviderError`, `RateLimitError`, `AuthenticationError`, `ToolExecutionError`, etc. |
215
+ | **Managers** | `AgentFactory`, `AgentTemplates`, `ConversationHistory`, `EventHistoryModule` |
97
216
 
98
217
  ## What Moved Out in v3
99
218
 
@@ -101,8 +220,16 @@ agent-cli ← Terminal UI
101
220
  | --------------------------------------------- | ---------------------------- |
102
221
  | `FunctionTool`, `ToolRegistry`, `OpenAPITool` | `@robota-sdk/agent-tools` |
103
222
  | `MCPTool`, `RelayMcpTool` | `@robota-sdk/agent-tool-mcp` |
104
- | 8 plugins (logging, usage, performance, etc.) | `@robota-sdk/agent-plugin-*` |
223
+ | 8 plugins (logging, usage, performance, etc.) | `@robota-sdk/agent-plugin` |
224
+
225
+ ## Repository Examples
226
+
227
+ Repository contributors can run the owner-local hook examples after building this package:
228
+ `node examples/hook-block-demo.mjs`, `node examples/hook-json-response-demo.mjs`,
229
+ `node examples/hook-permission-mode-demo.mjs`, and `node examples/hook-timeout-demo.mjs`,
230
+ from `packages/agent-core`. They exercise hooks without a live model; see the
231
+ [hook contract](./docs/SPEC.md) for each example's verification limits.
105
232
 
106
233
  ## License
107
234
 
108
- MIT
235
+ Robota is dual-licensed under the [GNU AGPL-3.0](../../LICENSE) or a [commercial license](../../COMMERCIAL.md). See [LICENSING.md](../../LICENSING.md).
@@ -0,0 +1,2 @@
1
+ var e=class extends Error{context;constructor(e,t){super(e),this.context=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{code=`CONFIGURATION_ERROR`;category=`user`;recoverable=!1;constructor(e,t){super(`Configuration Error: ${e}`,t)}},n=class extends e{field;code=`VALIDATION_ERROR`;category=`user`;recoverable=!1;constructor(e,t,n){super(`Validation Error: ${e}`,n),this.field=t}},r=class extends e{issues;attempts;code=`STRUCTURED_OUTPUT_ERROR`;category=`provider`;recoverable=!0;constructor(e,t,n,r){super(`Structured Output Error: ${e}`,r),this.issues=t,this.attempts=n}},i=class extends e{provider;originalError;code=`PROVIDER_ERROR`;category=`provider`;recoverable=!0;status;type;constructor(e,t,n,r,i){super(`Provider Error (${t}): ${e}`,r),this.provider=t,this.originalError=n,i?.status!==void 0&&(this.status=i.status),i?.type!==void 0&&(this.type=i.type)}},a=class extends e{provider;code=`AUTHENTICATION_ERROR`;category=`user`;recoverable=!1;constructor(e,t,n){super(`Authentication Error: ${e}`,n),this.provider=t}},o=class extends e{retryAfter;provider;code=`RATE_LIMIT_ERROR`;category=`provider`;recoverable=!0;constructor(e,t,n,r){super(`Rate Limit Error: ${e}`,r),this.retryAfter=t,this.provider=n}},s=class extends e{originalError;code=`NETWORK_ERROR`;category=`system`;recoverable=!0;constructor(e,t,n){super(`Network Error: ${e}`,n),this.originalError=t}},c=class extends e{toolName;originalError;code=`TOOL_EXECUTION_ERROR`;category=`system`;recoverable=!1;constructor(e,t,n,r){super(`Tool Execution Error (${t}): ${e}`,r),this.toolName=t,this.originalError=n}},l=class extends e{toolName;callCount;maxSameToolInputs;code=`SAME_TOOL_INPUT_LOOP`;category=`system`;recoverable=!0;constructor(e,t,n,r){super(`Tool "${e}" was called with identical input ${t} times, past the maxSameToolInputs limit of ${n} — stopping the turn to break the loop`,r),this.toolName=e,this.callCount=t,this.maxSameToolInputs=n}},u=class extends e{availableModels;code=`MODEL_NOT_AVAILABLE`;category=`user`;recoverable=!1;constructor(e,t,n,r){super(`Model "${e}" is not available for provider "${t}"`,r),this.availableModels=n}},d=class extends e{code=`CIRCUIT_BREAKER_OPEN`;category=`system`;recoverable=!0;constructor(e=`Circuit breaker is open`,t){super(e,t)}},f=class extends e{pluginName;code=`PLUGIN_ERROR`;category=`system`;recoverable=!1;constructor(e,t,n){super(`Plugin Error (${t}): ${e}`,n),this.pluginName=t}},p=class extends e{code=`STORAGE_ERROR`;category=`system`;recoverable=!0;constructor(e,t){super(`Storage Error: ${e}`,t)}},m=class extends e{code=`CACHE_INTEGRITY_ERROR`;category=`system`;recoverable=!1;constructor(e,t){super(`Cache Integrity Error: ${e}`,t)}},h=class extends e{executable;code=`UNSUPPORTED_SHELL`;category=`user`;recoverable=!1;constructor(e){super(`Unsupported shell executable: ${e}`,{executable:e}),this.executable=e}};function g(e){return e===`darwin`?'Host OS: macOS (POSIX, BSD userland). Use BSD-flavored utilities: `sed -i ""` needs an empty backup arg, `date`/`grep`/`stat` flags differ from GNU. Prefer portable POSIX flags; avoid Linux/GNU-only options.':e===`linux`?"Host OS: Linux (POSIX, usually GNU coreutils, but distro/user setup varies). Prefer portable POSIX flags; do not assume a specific distro, and probe with `command -v` before relying on a non-standard tool.":`Host OS: ${e}; active shell family: POSIX sh/bash. Write portable POSIX syntax and avoid host-specific flags.`}function _(e,t){let n=b(e)===`bash`?`bash`:`sh`;return{command:e,kind:n,platform:t,commandArgs:e=>[`-c`,e],interactiveArgs:[],label:`${n} on ${t}`,syntaxHint:g(t)}}function v(e,t){return{command:e,kind:`powershell`,platform:t,commandArgs:e=>[`-NoProfile`,`-Command`,e],interactiveArgs:[`-NoProfile`],label:`PowerShell on ${t}`,syntaxHint:`Host OS: ${t}; active shell family: PowerShell. Write PowerShell syntax (not bash): e.g. \`Get-ChildItem\` not \`ls -la\`, \`\$env:VAR\` not \`\$VAR\`.`}}function y(e,t){return{command:e,kind:`cmd`,platform:t,commandArgs:e=>[`/d`,`/s`,`/c`,e],interactiveArgs:[],label:`cmd.exe on ${t}`,syntaxHint:`Host OS: ${t}; active shell family: Windows cmd.exe. Write cmd.exe syntax.`}}function b(e){return(e.split(/[\\/]/).at(-1)?.toLowerCase()??``).replace(/\.exe$/i,``)}function x(e,t){switch(b(e)){case`sh`:case`bash`:return _(e,t);case`powershell`:case`pwsh`:return v(e,t);case`cmd`:return y(e,t);default:throw new h(e)}}function S(e){let t=e?.trim();return t===void 0||t.length===0?void 0:t}function C(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=S(e.executable);return r===void 0?n===`win32`?v(`powershell.exe`,n):_(S(t.SHELL)??`/bin/sh`,n):x(r,n)}const w=/^(?!0{32}$)[0-9a-f]{32}$/,T=/^(?!0{16}$)[0-9a-f]{16}$/;function E(e){return e.replaceAll(`-`,``).slice(0,16)}const D=E;function O(e){return T.test(e)}function k(e,t){if(!(!w.test(e)||!T.test(t)))return`00-${e}-${t}-01`}function A(e,t){if(e.allowedOrigins.length===0)return;let n=k(e.traceId,E(t));if(n!==void 0)return{traceparent:n,allowedOrigins:[...e.allowedOrigins]}}function j(e,t){return A(e,t)}function M(e,t,n){if(t?.subprocessClasses?.includes(e)!==!0)return;let r=k(t.traceId,n);return r===void 0?void 0:{TRACEPARENT:r}}function N(e,t,n={}){if(t===void 0||n.TRACEPARENT!==void 0)return{...e,...n};let{TRACESTATE:r,...i}=e;return{...i,...t,...n}}function P(e,t){if(e===void 0||t===void 0)return{};let n;try{n=new URL(e).origin}catch{return{}}return n===`null`||!t.allowedOrigins.includes(n)?{}:{traceparent:t.traceparent}}const F=e=>`\n…[output truncated: ${e} byte(s) dropped]`;function I(e){let t=e.retain??`head`,n=e.truncationMarker??F,r=Math.max(0,Math.floor(e.maxBytes)),i=new TextEncoder,a=[],o=0,s=0,c=e=>{let t=r-o;if(t<=0)return;let n=e.byteLength<=t?e:e.subarray(0,t);a.push(n),o+=n.byteLength},l=e=>{let t=e.byteLength<=r?e:e.subarray(e.byteLength-r);for(a.push(t),o+=t.byteLength;o>r&&a.length>0;){let e=a[0],t=o-r;e.byteLength<=t?(a.shift(),o-=e.byteLength):(a[0]=e.subarray(t),o-=t)}};return{append(e){let n=typeof e==`string`?i.encode(e):e;s+=n.byteLength,t===`head`?c(n):l(n)},get retainedBytes(){return o},get totalBytes(){return s},get droppedBytes(){return s-o},get truncated(){return s>o},toString(){let e=new Uint8Array(o),r=0;for(let t of a)e.set(t,r),r+=t.byteLength;a=a.length>1?[e]:a;let i=new TextDecoder().decode(e);if(s<=o)return i;let c=n(s-o);return t===`head`?`${i}${c}`:`${c.replace(/^\n/,``)}\n${i}`}}}export{l as C,n as D,c as E,e as S,r as T,u as _,D as a,i as b,j as c,h as d,C as f,t as g,d as h,A as i,M as l,m,k as n,E as o,a as p,O as r,N as s,I as t,P as u,s as v,p as w,o as x,f as y};
2
+ //# sourceMappingURL=bounded-output-DpjpS98g.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-output-DpjpS98g.js","names":[],"sources":["../../src/utils/errors.ts","../../src/utils/platform-shell.ts","../../src/utils/trace-context.ts","../../src/utils/bounded-output.ts"],"sourcesContent":["/**\n * Reusable type definitions for error utilities\n */\n\n/**\n * Error context data type\n * Used for storing contextual information in error instances\n */\nexport type TErrorContextData = Record<\n string,\n string | number | boolean | Date | Error | string[] | undefined\n>;\n\n/**\n * Error external input type\n * Used for handling external errors from unknown sources\n */\nexport type TErrorExternalInput =\n Error | string | Record<string, string | number | boolean> | null | undefined;\n\n/**\n * Base error class for all Robota errors\n */\nexport abstract class RobotaError extends Error {\n abstract readonly code: string;\n abstract readonly category: 'user' | 'system' | 'provider';\n abstract readonly recoverable: boolean;\n\n constructor(\n message: string,\n public readonly context?: TErrorContextData,\n ) {\n super(message);\n this.name = this.constructor.name;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Configuration related errors\n */\nexport class ConfigurationError extends RobotaError {\n readonly code = 'CONFIGURATION_ERROR';\n readonly category = 'user' as const;\n readonly recoverable = false;\n\n constructor(message: string, context?: TErrorContextData) {\n super(`Configuration Error: ${message}`, context);\n }\n}\n\n/**\n * Input validation errors\n */\nexport class ValidationError extends RobotaError {\n readonly code = 'VALIDATION_ERROR';\n readonly category = 'user' as const;\n readonly recoverable = false;\n\n constructor(\n message: string,\n public readonly field?: string,\n context?: TErrorContextData,\n ) {\n super(`Validation Error: ${message}`, context);\n }\n}\n\n/**\n * Structured output validation exhausted its retry budget (CORE-015).\n *\n * Thrown by `run(input, { output })` when the model's final response still fails\n * schema validation after the configured number of retries. `issues` holds the\n * validation messages from the last attempt; `attempts` is the total number of\n * provider turns spent (initial + retries).\n */\nexport class StructuredOutputError extends RobotaError {\n readonly code = 'STRUCTURED_OUTPUT_ERROR';\n readonly category = 'provider' as const;\n readonly recoverable = true;\n\n constructor(\n message: string,\n public readonly issues: string[],\n public readonly attempts: number,\n context?: TErrorContextData,\n ) {\n super(`Structured Output Error: ${message}`, context);\n }\n}\n\n/** What the vendor said about a failed call, as far as it said anything. */\nexport interface IProviderFailureDetails {\n /** The HTTP status of the failed response; absent for a failure with no response (e.g. an SSE error event). */\n status?: number;\n /** The vendor's own error type, e.g. Anthropic's `overloaded_error`. */\n type?: string;\n}\n\n/**\n * Provider related errors\n */\nexport class ProviderError extends RobotaError {\n readonly code = 'PROVIDER_ERROR';\n readonly category = 'provider' as const;\n readonly recoverable = true;\n readonly status?: number;\n readonly type?: string;\n\n constructor(\n message: string,\n public readonly provider: string,\n public readonly originalError?: Error,\n context?: TErrorContextData,\n details?: IProviderFailureDetails,\n ) {\n super(`Provider Error (${provider}): ${message}`, context);\n if (details?.status !== undefined) this.status = details.status;\n if (details?.type !== undefined) this.type = details.type;\n }\n}\n\n/**\n * Authentication errors\n */\nexport class AuthenticationError extends RobotaError {\n readonly code = 'AUTHENTICATION_ERROR';\n readonly category = 'user' as const;\n readonly recoverable = false;\n\n constructor(\n message: string,\n public readonly provider?: string,\n context?: TErrorContextData,\n ) {\n super(`Authentication Error: ${message}`, context);\n }\n}\n\n/**\n * Rate limit errors\n */\nexport class RateLimitError extends RobotaError {\n readonly code = 'RATE_LIMIT_ERROR';\n readonly category = 'provider' as const;\n readonly recoverable = true;\n\n constructor(\n message: string,\n public readonly retryAfter?: number,\n public readonly provider?: string,\n context?: TErrorContextData,\n ) {\n super(`Rate Limit Error: ${message}`, context);\n }\n}\n\n/**\n * Network/connectivity errors\n */\nexport class NetworkError extends RobotaError {\n readonly code = 'NETWORK_ERROR';\n readonly category = 'system' as const;\n readonly recoverable = true;\n\n constructor(\n message: string,\n public readonly originalError?: Error,\n context?: TErrorContextData,\n ) {\n super(`Network Error: ${message}`, context);\n }\n}\n\n/**\n * Tool execution errors\n */\nexport class ToolExecutionError extends RobotaError {\n readonly code = 'TOOL_EXECUTION_ERROR';\n readonly category = 'system' as const;\n readonly recoverable = false;\n\n constructor(\n message: string,\n public readonly toolName: string,\n public readonly originalError?: Error,\n context?: TErrorContextData,\n ) {\n super(`Tool Execution Error (${toolName}): ${message}`, context);\n }\n}\n\n/**\n * The same-tool-input loop guard tripped — CORE-035.\n *\n * A tool was invoked with byte-identical serialized inputs more times than `maxSameToolInputs`\n * allows, so the turn stopped rather than looping. This is the AGENT giving up, not the user\n * cancelling: the SPEC used to promise an `AbortError` here, which `isAbortFailure` resolves as\n * `success: true, interrupted: true` — reporting a run that produced no answer as a success.\n *\n * Named rather than a bare `Error` for the reason the SPEC was reaching for by naming a type at all:\n * a caller must be able to tell \"the agent looped\" from \"the network died\". `RobotaError` carries\n * `code`/`category`/`recoverable` out through CORE-027's failure path intact.\n *\n * `recoverable` is TRUE: the loop is a property of this turn's prompt and tool set, not of the\n * system, and a caller that varies either can reasonably try again.\n */\nexport class SameToolInputLoopError extends RobotaError {\n readonly code = 'SAME_TOOL_INPUT_LOOP';\n readonly category = 'system' as const;\n readonly recoverable = true;\n\n constructor(\n public readonly toolName: string,\n public readonly callCount: number,\n public readonly maxSameToolInputs: number,\n context?: TErrorContextData,\n ) {\n super(\n `Tool \"${toolName}\" was called with identical input ${callCount} times, past the ` +\n `maxSameToolInputs limit of ${maxSameToolInputs} — stopping the turn to break the loop`,\n context,\n );\n }\n}\n\n/**\n * Model not available errors\n */\nexport class ModelNotAvailableError extends RobotaError {\n readonly code = 'MODEL_NOT_AVAILABLE';\n readonly category = 'user' as const;\n readonly recoverable = false;\n\n constructor(\n model: string,\n provider: string,\n public readonly availableModels?: string[],\n context?: TErrorContextData,\n ) {\n super(`Model \"${model}\" is not available for provider \"${provider}\"`, context);\n }\n}\n\n/**\n * Circuit breaker open error\n */\nexport class CircuitBreakerOpenError extends RobotaError {\n readonly code = 'CIRCUIT_BREAKER_OPEN';\n readonly category = 'system' as const;\n readonly recoverable = true;\n\n constructor(message: string = 'Circuit breaker is open', context?: TErrorContextData) {\n super(message, context);\n }\n}\n\n/**\n * Plugin errors\n */\nexport class PluginError extends RobotaError {\n readonly code = 'PLUGIN_ERROR';\n readonly category = 'system' as const;\n readonly recoverable = false;\n\n constructor(\n message: string,\n public readonly pluginName: string,\n context?: TErrorContextData,\n ) {\n super(`Plugin Error (${pluginName}): ${message}`, context);\n }\n}\n\n/**\n * Storage related errors\n */\nexport class StorageError extends RobotaError {\n readonly code = 'STORAGE_ERROR';\n readonly category = 'system' as const;\n readonly recoverable = true;\n\n constructor(message: string, context?: TErrorContextData) {\n super(`Storage Error: ${message}`, context);\n }\n}\n\n/**\n * Cache integrity validation errors\n */\nexport class CacheIntegrityError extends RobotaError {\n readonly code = 'CACHE_INTEGRITY_ERROR';\n readonly category = 'system' as const;\n readonly recoverable = false;\n\n constructor(message: string, context?: TErrorContextData) {\n super(`Cache Integrity Error: ${message}`, context);\n }\n}\n","/**\n * TERM-008: cross-platform shell resolution (SSOT).\n *\n * Single source of truth for \"which shell do we spawn, and how\", shared by every shell-running site.\n * Resolution is a pure function of one request so every branch is testable without the host shell.\n */\n\nimport { RobotaError } from './errors.js';\n\n/** Shell family — drives non-interactive arg shape, quoting, and LLM syntax guidance. */\nexport type TShellKind = 'bash' | 'sh' | 'powershell' | 'cmd';\n\n/** The active shell resolved for a platform, plus the metadata callers need to drive and describe it. */\nexport interface IPlatformShell {\n /** Executable to spawn (e.g. `/bin/sh`, `powershell.exe`, or `$SHELL`). */\n readonly command: string;\n /** Shell family. */\n readonly kind: TShellKind;\n /** Node platform this was resolved for (`process.platform`). */\n readonly platform: NodeJS.Platform;\n /** Args to run a single command string non-interactively. */\n commandArgs(command: string): string[];\n /** Args for an interactive shell session (drop-to-shell). */\n readonly interactiveArgs: string[];\n /** Human label for the active shell, for tool/UI descriptions (e.g. `PowerShell (Windows)`). */\n readonly label: string;\n /** One-line syntax guidance for an LLM authoring commands. */\n readonly syntaxHint: string;\n}\n\n/** Pure inputs for resolving one executable together with its command argument family. */\nexport interface IPlatformShellResolutionRequest {\n /** Request-local executable. A non-blank value has the highest precedence. */\n readonly executable?: string;\n /** Environment used for SHELL resolution. */\n readonly env?: NodeJS.ProcessEnv;\n /** Actual host platform retained in the resolved metadata. */\n readonly platform?: NodeJS.Platform;\n}\n\n/** An explicit executable whose basename has no supported command argument family. */\nexport class UnsupportedShellError extends RobotaError {\n readonly code = 'UNSUPPORTED_SHELL';\n readonly category = 'user' as const;\n readonly recoverable = false;\n\n constructor(public readonly executable: string) {\n super(`Unsupported shell executable: ${executable}`, { executable });\n }\n}\n\n/**\n * OS-family syntax guidance for the LLM. macOS and Linux are both POSIX but ship different userlands\n * (macOS = BSD coreutils, most Linux = GNU coreutils), so flags like `sed -i`, `date`, and `grep`\n * differ — naming the OS lets the model avoid Linux-only invocations on macOS and vice versa.\n */\nfunction posixSyntaxHint(platform: NodeJS.Platform): string {\n if (platform === 'darwin') {\n return 'Host OS: macOS (POSIX, BSD userland). Use BSD-flavored utilities: `sed -i \"\"` needs an empty backup arg, `date`/`grep`/`stat` flags differ from GNU. Prefer portable POSIX flags; avoid Linux/GNU-only options.';\n }\n if (platform === 'linux') {\n return 'Host OS: Linux (POSIX, usually GNU coreutils, but distro/user setup varies). Prefer portable POSIX flags; do not assume a specific distro, and probe with `command -v` before relying on a non-standard tool.';\n }\n return `Host OS: ${platform}; active shell family: POSIX sh/bash. Write portable POSIX syntax and avoid host-specific flags.`;\n}\n\nfunction posixShell(command: string, platform: NodeJS.Platform): IPlatformShell {\n const isBash = shellBasename(command) === 'bash';\n const kind: TShellKind = isBash ? 'bash' : 'sh';\n return {\n command,\n kind,\n platform,\n commandArgs: (cmd: string): string[] => ['-c', cmd],\n interactiveArgs: [],\n label: `${kind} on ${platform}`,\n syntaxHint: posixSyntaxHint(platform),\n };\n}\n\nfunction powerShell(command: string, platform: NodeJS.Platform): IPlatformShell {\n return {\n command,\n kind: 'powershell',\n platform,\n commandArgs: (cmd: string): string[] => ['-NoProfile', '-Command', cmd],\n interactiveArgs: ['-NoProfile'],\n label: `PowerShell on ${platform}`,\n syntaxHint:\n `Host OS: ${platform}; active shell family: PowerShell. Write PowerShell syntax (not bash): e.g. ` +\n '`Get-ChildItem` not `ls -la`, `$env:VAR` not `$VAR`.',\n };\n}\n\nfunction cmdShell(command: string, platform: NodeJS.Platform): IPlatformShell {\n return {\n command,\n kind: 'cmd',\n platform,\n commandArgs: (cmd: string): string[] => ['/d', '/s', '/c', cmd],\n interactiveArgs: [],\n label: `cmd.exe on ${platform}`,\n syntaxHint: `Host OS: ${platform}; active shell family: Windows cmd.exe. Write cmd.exe syntax.`,\n };\n}\n\nfunction shellBasename(command: string): string {\n const basename = command.split(/[\\\\/]/).at(-1)?.toLowerCase() ?? '';\n return basename.replace(/\\.exe$/i, '');\n}\n\nfunction explicitShell(command: string, platform: NodeJS.Platform): IPlatformShell {\n switch (shellBasename(command)) {\n case 'sh':\n case 'bash':\n return posixShell(command, platform);\n case 'powershell':\n case 'pwsh':\n return powerShell(command, platform);\n case 'cmd':\n return cmdShell(command, platform);\n default:\n throw new UnsupportedShellError(command);\n }\n}\n\nfunction nonBlank(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n return trimmed === undefined || trimmed.length === 0 ? undefined : trimmed;\n}\n\n/**\n * Resolve the shell to spawn for the current (or a given) platform.\n *\n * - request `executable` wins when non-blank.\n * - **win32:** PowerShell.\n * - **posix:** `$SHELL` if set, else `/bin/sh`.\n */\nexport function resolvePlatformShell(\n request: IPlatformShellResolutionRequest = {},\n): IPlatformShell {\n const env = request.env ?? process.env;\n const platform = request.platform ?? process.platform;\n const requestedExecutable = nonBlank(request.executable);\n if (requestedExecutable !== undefined) return explicitShell(requestedExecutable, platform);\n\n if (platform === 'win32') return powerShell('powershell.exe', platform);\n\n return posixShell(nonBlank(env['SHELL']) ?? '/bin/sh', platform);\n}\n","/**\n * Pure helpers for trusted W3C trace context. Strings and the WHATWG `URL` only, so they are the\n * same in the browser build and in every adapter that attaches the header.\n */\nimport type {\n IOutboundTraceContext,\n IRunTraceContext,\n ISubprocessTraceEnv,\n TSubprocessTraceClass,\n} from '../interfaces/trace-context';\n\nconst TRACE_ID = /^(?!0{32}$)[0-9a-f]{32}$/;\nconst SPAN_ID = /^(?!0{16}$)[0-9a-f]{16}$/;\n\n/**\n * The span ID an operation is exported under, derived from the ID core mints before it runs (a\n * provider call's call ID, a tool body's body ID). One derivation for both the exporter and the\n * outgoing header, so the span a recipient sees as its parent is the span the trace contains.\n */\nexport function spanIdFromMintedId(mintedId: string): string {\n return mintedId.replaceAll('-', '').slice(0, 16);\n}\n\n/** The provider-call name for {@link spanIdFromMintedId}, kept so existing callers keep working. */\nexport const providerCallSpanId: (callId: string) => string = spanIdFromMintedId;\n\n/** Whether `spanId` is a well-formed minted span ID: 16 lowercase hex characters, not all zero. */\nexport function isMintedSpanId(spanId: string): boolean {\n return SPAN_ID.test(spanId);\n}\n\n/** A sampled version-00 `traceparent`, or undefined when either identifier is invalid. */\nexport function buildTraceparent(traceId: string, spanId: string): string | undefined {\n if (!TRACE_ID.test(traceId) || !SPAN_ID.test(spanId)) return undefined;\n return `00-${traceId}-${spanId}-01`;\n}\n\n/** The outbound context for one invoked call, or undefined when there is nothing valid to send. */\nexport function outboundTraceContextFor(\n traceContext: IRunTraceContext,\n callId: string,\n): IOutboundTraceContext | undefined {\n if (traceContext.allowedOrigins.length === 0) return undefined;\n const traceparent = buildTraceparent(traceContext.traceId, spanIdFromMintedId(callId));\n if (traceparent === undefined) return undefined;\n return { traceparent, allowedOrigins: [...traceContext.allowedOrigins] };\n}\n\n/**\n * The outbound context for one tool body, keyed by the body ID core minted for it — never the\n * vendor's tool call ID, which is neither unique nor hex.\n */\nexport function toolTraceContextFor(\n traceContext: IRunTraceContext,\n toolBodyId: string,\n): IOutboundTraceContext | undefined {\n return outboundTraceContextFor(traceContext, toolBodyId);\n}\n\n/**\n * The environment one child process of `subprocessClass` receives, naming `spanId` as its parent,\n * or undefined when the host did not enable that class. Independent of the origin allowlist.\n */\nexport function traceEnvFor(\n subprocessClass: TSubprocessTraceClass,\n traceContext: IRunTraceContext | undefined,\n spanId: string,\n): ISubprocessTraceEnv | undefined {\n if (traceContext?.subprocessClasses?.includes(subprocessClass) !== true) return undefined;\n const traceparent = buildTraceparent(traceContext.traceId, spanId);\n return traceparent === undefined ? undefined : { TRACEPARENT: traceparent };\n}\n\n/**\n * A fresh child environment: `base`, then Robota's trace, then `overrides`. When Robota's value\n * applies, the ambient `TRACESTATE` is dropped because it belongs to a different parent. When\n * `overrides` sets its own `TRACEPARENT`, Robota's value does not apply and `base` passes unchanged.\n * `base` itself is never modified.\n */\nexport function subprocessTraceEnvironment(\n base: Readonly<Record<string, string | undefined>>,\n traceEnv: ISubprocessTraceEnv | undefined,\n overrides: Readonly<Record<string, string>> = {},\n): Record<string, string | undefined> {\n if (traceEnv === undefined || overrides['TRACEPARENT'] !== undefined) return { ...base, ...overrides };\n const { TRACESTATE: _ambientState, ...rest } = base;\n return { ...rest, ...traceEnv, ...overrides };\n}\n\n/**\n * The headers to add to a request whose effective base URL is `baseUrl`: `traceparent` when its\n * origin exactly equals a listed origin, nothing otherwise. Scheme, host and port must all match;\n * a subdomain or a different port is a different origin.\n */\nexport function traceHeadersFor(\n baseUrl: string | undefined,\n traceContext: IOutboundTraceContext | undefined,\n): Readonly<Record<string, string>> {\n if (baseUrl === undefined || traceContext === undefined) return {};\n let origin: string;\n try {\n origin = new URL(baseUrl).origin;\n } catch {\n return {};\n }\n if (origin === 'null' || !traceContext.allowedOrigins.includes(origin)) return {};\n return { traceparent: traceContext.traceparent };\n}\n","/**\n * ARCH-056 (#2161): the bounded output-retention contract for child-process execution.\n *\n * Every path that reads a child's stdout/stderr must bound memory WHILE the output is being read —\n * not cap a summary afterwards while retaining the whole log. Before this existed, `shell-tool`\n * could buffer for ten minutes, the hook `CommandExecutor` repeated the pattern, and a subagent\n * runner had rediscovered a 4 KiB tail on its own. This module names the policy once:\n *\n * - **Budget.** `maxBytes` is the most that is ever RETAINED; bytes beyond it are dropped as they\n * arrive, so memory is bounded by the budget, not by the child's lifetime.\n * - **Retention.** `head` keeps the first `maxBytes` (a tool result: what the command said first);\n * `tail` keeps the last `maxBytes` (a diagnostic: how it ended).\n * - **Truncation is visible.** `truncated`, `droppedBytes` and a marker in `toString()` say that\n * output was dropped and how much — never a silently shorter string.\n * - **No spill.** This contract never writes to disk; a caller that needs the whole stream owns a\n * log file (background tasks do), and this buffer is what stays in memory beside it.\n * - **Termination is not here.** Exceeding the budget drops bytes; whether the child is killed is\n * the caller's policy (CORE-023 owns process-tree termination).\n *\n * Chunks are `Uint8Array` (a Node `Buffer` is one), and decoding happens once at `toString()`, so a\n * multi-byte character split across a chunk boundary is never decoded twice.\n */\n\nexport type TOutputRetention = 'head' | 'tail';\n\nexport interface IBoundedOutputOptions {\n /** Most bytes ever retained. */\n readonly maxBytes: number;\n /** Which end to keep once over budget. Default `head`. */\n readonly retain?: TOutputRetention;\n /** Marker appended (head) or prepended (tail) to `toString()` when bytes were dropped. */\n readonly truncationMarker?: (droppedBytes: number) => string;\n}\n\nexport interface IBoundedOutput {\n append(chunk: Uint8Array | string): void;\n /** Bytes currently retained (≤ `maxBytes`). */\n readonly retainedBytes: number;\n /** Bytes the child produced in total, retained or not. */\n readonly totalBytes: number;\n readonly droppedBytes: number;\n readonly truncated: boolean;\n /** The retained output, decoded as UTF-8, with the truncation marker when bytes were dropped. */\n toString(): string;\n}\n\nconst DEFAULT_MARKER = (dropped: number): string =>\n `\\n…[output truncated: ${dropped} byte(s) dropped]`;\n\nexport function createBoundedOutput(options: IBoundedOutputOptions): IBoundedOutput {\n const retain = options.retain ?? 'head';\n const marker = options.truncationMarker ?? DEFAULT_MARKER;\n const maxBytes = Math.max(0, Math.floor(options.maxBytes));\n const encoder = new TextEncoder();\n let chunks: Uint8Array[] = [];\n let retained = 0;\n let total = 0;\n\n const appendHead = (bytes: Uint8Array): void => {\n const room = maxBytes - retained;\n if (room <= 0) return;\n const kept = bytes.byteLength <= room ? bytes : bytes.subarray(0, room);\n chunks.push(kept);\n retained += kept.byteLength;\n };\n\n const appendTail = (bytes: Uint8Array): void => {\n const kept = bytes.byteLength <= maxBytes ? bytes : bytes.subarray(bytes.byteLength - maxBytes);\n chunks.push(kept);\n retained += kept.byteLength;\n // Drop whole leading chunks first, then trim the oldest survivor — O(chunks), no re-copying.\n while (retained > maxBytes && chunks.length > 0) {\n const oldest = chunks[0] as Uint8Array;\n const excess = retained - maxBytes;\n if (oldest.byteLength <= excess) {\n chunks.shift();\n retained -= oldest.byteLength;\n } else {\n chunks[0] = oldest.subarray(excess);\n retained -= excess;\n }\n }\n };\n\n return {\n append(chunk) {\n const bytes = typeof chunk === 'string' ? encoder.encode(chunk) : chunk;\n total += bytes.byteLength;\n if (retain === 'head') appendHead(bytes);\n else appendTail(bytes);\n },\n get retainedBytes() {\n return retained;\n },\n get totalBytes() {\n return total;\n },\n get droppedBytes() {\n return total - retained;\n },\n get truncated() {\n return total > retained;\n },\n toString() {\n const joined = new Uint8Array(retained);\n let offset = 0;\n for (const chunk of chunks) {\n joined.set(chunk, offset);\n offset += chunk.byteLength;\n }\n chunks = chunks.length > 1 ? [joined] : chunks;\n const text = new TextDecoder().decode(joined);\n if (total <= retained) return text;\n const note = marker(total - retained);\n return retain === 'head' ? `${text}${note}` : `${note.replace(/^\\n/, '')}\\n${text}`;\n },\n };\n}\n"],"mappings":"AAuBA,IAAsB,EAAtB,cAA0C,KAAM,CAO5B,QAFlB,YACE,EACA,EACA,CACA,MAAM,CAAO,EAFG,KAAA,QAAA,EAGhB,KAAK,KAAO,KAAK,YAAY,KAG7B,OAAO,eAAe,KAAM,IAAI,OAAO,SAAS,CAClD,CACF,EAKa,EAAb,cAAwC,CAAY,CAClD,KAAgB,sBAChB,SAAoB,OACpB,YAAuB,GAEvB,YAAY,EAAiB,EAA6B,CACxD,MAAM,wBAAwB,IAAW,CAAO,CACl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,YAAc,GACvB,EAAO,MAAM,EACb,GAAY,EAAO,aAEnB,EAAO,GAAK,EAAO,SAAS,CAAM,EAClC,GAAY,EAEhB,CACF,EAEA,MAAO,CACL,OAAO,EAAO,CACZ,IAAM,EAAQ,OAAO,GAAU,SAAW,EAAQ,OAAO,CAAK,EAAI,EAClE,GAAS,EAAM,WACX,IAAW,OAAQ,EAAW,CAAK,EAClC,EAAW,CAAK,CACvB,EACA,IAAI,eAAgB,CAClB,OAAO,CACT,EACA,IAAI,YAAa,CACf,OAAO,CACT,EACA,IAAI,cAAe,CACjB,OAAO,EAAQ,CACjB,EACA,IAAI,WAAY,CACd,OAAO,EAAQ,CACjB,EACA,UAAW,CACT,IAAM,EAAS,IAAI,WAAW,CAAQ,EAClC,EAAS,EACb,IAAK,IAAM,KAAS,EAClB,EAAO,IAAI,EAAO,CAAM,EACxB,GAAU,EAAM,WAElB,EAAS,EAAO,OAAS,EAAI,CAAC,CAAM,EAAI,EACxC,IAAM,EAAO,IAAI,YAAY,CAAC,CAAC,OAAO,CAAM,EAC5C,GAAI,GAAS,EAAU,OAAO,EAC9B,IAAM,EAAO,EAAO,EAAQ,CAAQ,EACpC,OAAO,IAAW,OAAS,GAAG,IAAO,IAAS,GAAG,EAAK,QAAQ,MAAO,EAAE,EAAE,IAAI,GAC/E,CACF,CACF"}
@@ -0,0 +1,2 @@
1
+ import{f as e,s as t,t as n}from"./bounded-output-DpjpS98g.js";import{spawn as r}from"node:child_process";const i=1e6;function a(e,t){let r=n({maxBytes:i}),a=n({maxBytes:i,retain:`tail`});return e.stdout?.on(`data`,e=>r.append(e)),e.stderr?.on(`data`,e=>a.append(e)),e.stdin?.on(`error`,()=>{}),e.stdin?.write(t),e.stdin?.end(),{stdoutOutput:r,stderrOutput:a}}function o(e,t,n,r){if(e===0)return{outcome:`allow`,source:`command`,stdout:n};if(e===2)return{outcome:`deny`,source:`command`,reason:r.trim()||`Blocked by hook`};let i=r.trim()?`: ${r.trim()}`:``;return{outcome:`error`,source:`command`,kind:`nonzero-exit`,reason:e===null?`Hook terminated by signal ${t??`unknown`}${i}`:`Hook exited ${e}${i}`}}var s=class{shellExecutable;type=`command`;constructor(e){this.shellExecutable=e}execute(n,i,s){let c=n.timeout??600,l=c*1e3,u=JSON.stringify(i);return new Promise(d=>{let f=!1,p=e({executable:this.shellExecutable}),m=r(p.command,p.commandArgs(n.command),{cwd:i.cwd,env:t(process.env,s,i.env)}),{stdoutOutput:h,stderrOutput:g}=a(m,u),_=setTimeout(()=>{f||(f=!0,m.kill(`SIGTERM`),d({outcome:`error`,source:`command`,kind:`timeout`,reason:`Hook timed out after ${c}s`}))},l);m.on(`close`,(e,t)=>{f||(f=!0,clearTimeout(_),d(o(e,t,h.toString(),g.toString())))}),m.on(`error`,e=>{f||(f=!0,clearTimeout(_),d({outcome:`error`,source:`command`,kind:`spawn-failure`,reason:e.message}))})})}};export{s as CommandExecutor};
2
+ //# sourceMappingURL=command-executor-cI7XJ374.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-executor-cI7XJ374.js","names":[],"sources":["../../src/hooks/executors/command-executor.ts"],"sourcesContent":["/**\n * Command hook executor — executes shell commands with JSON input on stdin.\n *\n * Exit-code mapping (SEC-015):\n * - `0` → `allow`, stdout carried for the runner's response-protocol decode\n * - `2` → `deny`, stderr carried as the reason\n * - any other code → `error` / `nonzero-exit`\n * - killed by a signal (exit code `null`) → `error` / `nonzero-exit`, signal named in the reason\n * - deadline elapsed → `error` / `timeout`\n * - the process never started → `error` / `spawn-failure`\n *\n * The last four used to be one number. A missing binary exits `127` and a timeout resolved `1`, and\n * the runner discarded both alike, so a gate that never ran was indistinguishable from one that\n * approved.\n */\n\nimport { spawn } from 'node:child_process';\n\nimport { createBoundedOutput, type IBoundedOutput } from '../../utils/bounded-output.js';\nimport { resolvePlatformShell } from '../../utils/platform-shell.js';\nimport { subprocessTraceEnvironment } from '../../utils/trace-context.js';\n\nimport type { ISubprocessTraceEnv } from '../../interfaces/trace-context.js';\nimport type {\n ICommandHookDefinition,\n IHookInput,\n THookOutcome,\n IHookTypeExecutor,\n} from '../types.js';\n\n/** Default timeout in seconds — matches Claude Code's 600s default */\nconst DEFAULT_TIMEOUT_SECONDS = 600;\n/** ARCH-056: most bytes retained per hook stream (stdout head, stderr tail). */\nconst MAX_HOOK_OUTPUT_BYTES = 1_000_000;\n\n/**\n * How a finished process maps onto an outcome — a pure function of what the process reported.\n *\n * Extracted from `execute` because it is the part that carries the contract: `execute` owns spawning\n * and settling exactly once, this owns what the result MEANS, and the two change for different\n * reasons.\n */\n/**\n * Attach the output collectors and feed the hook input to stdin.\n *\n * Separated from `execute` so the promise body reads as the three things that can settle it —\n * timeout, close, spawn error — rather than as stream plumbing interleaved with them. The\n * `settled` guard those three share is the invariant worth keeping visible in one place.\n */\nfunction wireChildIo(\n child: ReturnType<typeof spawn>,\n inputJson: string,\n): { stdoutOutput: IBoundedOutput; stderrOutput: IBoundedOutput } {\n // ARCH-056: bounded while reading; a hook that floods stdout cannot grow the parent's memory.\n const stdoutOutput = createBoundedOutput({ maxBytes: MAX_HOOK_OUTPUT_BYTES });\n const stderrOutput = createBoundedOutput({ maxBytes: MAX_HOOK_OUTPUT_BYTES, retain: 'tail' });\n child.stdout?.on('data', (chunk: Buffer) => stdoutOutput.append(chunk));\n child.stderr?.on('data', (chunk: Buffer) => stderrOutput.append(chunk));\n child.stdin?.on('error', () => {\n // EPIPE: child closed stdin before we finished writing — safe to ignore\n });\n child.stdin?.write(inputJson);\n child.stdin?.end();\n return { stdoutOutput, stderrOutput };\n}\n\nfunction outcomeOfExit(\n code: number | null,\n signal: NodeJS.Signals | null,\n stdout: string,\n stderr: string,\n): THookOutcome {\n if (code === 0) return { outcome: 'allow', source: 'command', stdout };\n if (code === 2) {\n return { outcome: 'deny', source: 'command', reason: stderr.trim() || 'Blocked by hook' };\n }\n const detail = stderr.trim() ? `: ${stderr.trim()}` : '';\n return {\n outcome: 'error',\n source: 'command',\n kind: 'nonzero-exit',\n // `code === null` means a signal ended it. That is not an exit code and must not be read as\n // one — the old `code ?? 1` made a SIGKILLed hook indistinguishable from one that exited 1.\n reason:\n code === null\n ? `Hook terminated by signal ${signal ?? 'unknown'}${detail}`\n : `Hook exited ${code}${detail}`,\n };\n}\n\nexport class CommandExecutor implements IHookTypeExecutor {\n readonly type = 'command' as const;\n\n constructor(private readonly shellExecutable?: string) {}\n\n /**\n * `traceEnv` is the prompt's trace for this child, handed separately so it never reaches the\n * stdin JSON. The child sees `process.env`, then Robota's value, then the hook's own `env`; a hook\n * that sets its own `TRACEPARENT` wins and gets the ambient environment unchanged.\n */\n execute(\n definition: ICommandHookDefinition,\n input: IHookInput,\n traceEnv?: ISubprocessTraceEnv,\n ): Promise<THookOutcome> {\n const timeoutSeconds = definition.timeout ?? DEFAULT_TIMEOUT_SECONDS;\n const timeoutMs = timeoutSeconds * 1000;\n const inputJson = JSON.stringify(input);\n\n return new Promise<THookOutcome>((resolve) => {\n let settled = false;\n const shell = resolvePlatformShell({ executable: this.shellExecutable });\n const child = spawn(shell.command, shell.commandArgs(definition.command), {\n cwd: input.cwd,\n env: subprocessTraceEnvironment(process.env, traceEnv, input.env),\n });\n const { stdoutOutput, stderrOutput } = wireChildIo(child, inputJson);\n\n const timer = setTimeout(() => {\n if (!settled) {\n settled = true;\n child.kill('SIGTERM');\n resolve({\n outcome: 'error',\n source: 'command',\n kind: 'timeout',\n reason: `Hook timed out after ${timeoutSeconds}s`,\n });\n }\n }, timeoutMs);\n\n child.on('close', (code: number | null, signal: NodeJS.Signals | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(outcomeOfExit(code, signal, stdoutOutput.toString(), stderrOutput.toString()));\n });\n\n child.on('error', (err: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve({\n outcome: 'error',\n source: 'command',\n kind: 'spawn-failure',\n reason: err.message,\n });\n });\n });\n }\n}\n"],"mappings":"0GA+BA,MAEM,EAAwB,IAgB9B,SAAS,EACP,E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AY,EAAO,CAAS,EAE7D,EAAQ,eAAiB,CACxB,IACH,EAAU,GACV,EAAM,KAAK,SAAS,EACpB,EAAQ,CACN,QAAS,QACT,OAAQ,UACR,KAAM,UACN,OAAQ,wBAAwB,EAAe,EACjD,CAAC,EAEL,EAAG,CAAS,EAEZ,EAAM,GAAG,SAAU,EAAqB,IAAkC,CACpE,IACJ,EAAU,GACV,aAAa,CAAK,EAClB,EAAQ,EAAc,EAAM,EAAQ,EAAa,SAAS,EAAG,EAAa,SAAS,CAAC,CAAC,EACvF,CAAC,EAED,EAAM,GAAG,QAAU,GAAe,CAC5B,IACJ,EAAU,GACV,aAAa,CAAK,EAClB,EAAQ,CACN,QAAS,QACT,OAAQ,UACR,KAAM,gBACN,OAAQ,EAAI,OACd,CAAC,EACH,CAAC,CACH,CAAC,CACH,CACF"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./verdict-decoder-Dk_w2NG9.js";function t(e){return e.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(e,t)=>{let n=process.env[t];return n===void 0?e:n})}var n=class{type=`http`;async execute(n,i){let a=(n.timeout??10)*1e3,o={"Content-Type":`application/json`};if(n.headers)for(let[e,r]of Object.entries(n.headers))o[e]=t(r);try{let t=await fetch(n.url,{method:`POST`,headers:o,body:JSON.stringify(i),signal:AbortSignal.timeout(a)});return t.ok?e(await t.text(),`http`,i.hook_event_name):{outcome:`error`,source:`http`,kind:`http-status`,reason:`HTTP ${t.status} ${t.statusText}`}}catch(e){return r(e)}}};function r(e){return{outcome:`error`,source:`http`,kind:e instanceof Error&&e.name===`TimeoutError`?`timeout`:`transport-failure`,reason:e instanceof Error?e.message:String(e)}}export{n as HttpExecutor};
2
+ //# sourceMappingURL=http-executor-CHy6UeBU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-executor-CHy6UeBU.js","names":[],"sources":["../../src/hooks/executors/http-executor.ts"],"sourcesContent":["/**\n * HTTP hook executor — POSTs hook input as JSON to a URL.\n *\n * Response format: `{ ok: boolean, reason?: string }`, decoded by `decodeHookVerdict` (SEC-015):\n * - `ok: true` → `allow`\n * - `ok: false` → `deny`, carrying `reason`\n * - anything else, including a non-boolean `ok` → `error` / `malformed-response`\n *\n * Transport conditions are outcomes in their own right rather than a shared failure code:\n * non-2xx → `http-status`, deadline elapsed → `timeout`, unreachable → `transport-failure`,\n * unparseable body → `malformed-response`.\n *\n * Supports env var interpolation in headers: $VAR_NAME\n */\n\nimport { decodeHookVerdict } from '../verdict-decoder.js';\n\nimport type { IHttpHookDefinition, IHookInput, THookOutcome, IHookTypeExecutor } from '../types.js';\n\n/** Default timeout in seconds */\nconst DEFAULT_TIMEOUT_SECONDS = 10;\n\n/** Interpolate $VAR_NAME references in a string with process.env values. */\nfunction interpolateEnvVars(value: string): string {\n return value.replace(/\\$([A-Za-z_][A-Za-z0-9_]*)/g, (_match, varName: string) => {\n const envValue = process.env[varName];\n return envValue !== undefined ? envValue : _match;\n });\n}\n\nexport class HttpExecutor implements IHookTypeExecutor {\n readonly type = 'http' as const;\n\n async execute(definition: IHttpHookDefinition, input: IHookInput): Promise<THookOutcome> {\n const timeoutSeconds = definition.timeout ?? DEFAULT_TIMEOUT_SECONDS;\n const timeoutMs = timeoutSeconds * 1000;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n };\n\n if (definition.headers) {\n for (const [key, value] of Object.entries(definition.headers)) {\n headers[key] = interpolateEnvVars(value);\n }\n }\n\n try {\n const response = await fetch(definition.url, {\n method: 'POST',\n headers,\n body: JSON.stringify(input),\n signal: AbortSignal.timeout(timeoutMs),\n });\n\n if (!response.ok) {\n return {\n outcome: 'error',\n source: 'http',\n kind: 'http-status',\n reason: `HTTP ${response.status} ${response.statusText}`,\n };\n }\n\n // Read the body as TEXT first. `response.json()` would collapse \"the endpoint sent HTML\" and\n // \"the endpoint sent a verdict\" into one throw, and the raw text is what the decoder quotes\n // back — so a misconfigured endpoint is identifiable from the reason alone.\n return decodeHookVerdict(await response.text(), 'http', input.hook_event_name);\n } catch (err: unknown) {\n return toTransportOutcome(err);\n }\n }\n}\n\n/**\n * Classify a `fetch` rejection.\n *\n * `AbortSignal.timeout` rejects with a `DOMException` named `TimeoutError`, which is a different\n * fact from a connection refused or dropped: one says the hook was too slow, the other says it was\n * never reached. Both are `error`, and an operator reading the reason needs to know which.\n */\nfunction toTransportOutcome(err: unknown): THookOutcome {\n return {\n outcome: 'error',\n source: 'http',\n kind: err instanceof Error && err.name === 'TimeoutError' ? 'timeout' : 'transport-failure',\n reason: err instanceof Error ? err.message : String(err),\n };\n}\n"],"mappings":"kDAuBA,SAAS,EAAmB,EAAuB,CACjD,OAAO,EAAM,QAAQ,+BAAgC,EAAQ,IAAoB,CAC/E,IAAM,EAAW,QAAQ,IAAI,GAC7B,OAAO,IAAa,IAAA,GAAuB,EAAX,CAClC,CAAC,CACH,CAEA,IAAa,EAAb,KAAuD,CACrD,KAAgB,OAEhB,MAAM,QAAQ,EAAiC,EAA0C,CAEvF,IAAM,GADiB,EAAW,SAAW,IACV,IAE7B,EAAkC,CACtC,eAAgB,kBAClB,EAEA,GAAI,EAAW,QACb,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAW,OAAO,EAC1D,EAAQ,GAAO,EAAmB,CAAK,EAI3C,GAAI,CACF,IAAM,EAAW,MAAM,MAAM,EAAW,IAAK,CAC3C,OAAQ,OACR,UACA,KAAM,KAAK,UAAU,CAAK,EAC1B,OAAQ,YAAY,QAAQ,CAAS,CACvC,CAAC,EAcD,OAZK,EAAS,GAYP,EAAkB,MAAM,EAAS,KAAK,EAAG,OAAQ,EAAM,eAAe,EAXpE,CACL,QAAS,QACT,OAAQ,OACR,KAAM,cACN,OAAQ,QAAQ,EAAS,OAAO,GAAG,EAAS,YAC9C,CAOJ,OAAS,EAAc,CACrB,OAAO,EAAmB,CAAG,CAC/B,CACF,CACF,EASA,SAAS,EAAmB,EAA4B,CACtD,MAAO,CACL,QAAS,QACT,OAAQ,OACR,KAAM,aAAe,OAAS,EAAI,OAAS,eAAiB,UAAY,oBACxE,OAAQ,aAAe,MAAQ,EAAI,QAAU,OAAO,CAAG,CACzD,CACF"}