beddel 0.2.3 → 1.0.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 (542) hide show
  1. package/README.md +138 -595
  2. package/dist/client.d.ts +10 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +9 -0
  5. package/dist/core/parser.d.ts +25 -0
  6. package/dist/core/parser.d.ts.map +1 -0
  7. package/dist/core/parser.js +31 -0
  8. package/dist/core/variable-resolver.d.ts +23 -0
  9. package/dist/core/variable-resolver.d.ts.map +1 -0
  10. package/dist/core/variable-resolver.js +98 -0
  11. package/dist/core/workflow.d.ts +39 -0
  12. package/dist/core/workflow.d.ts.map +1 -0
  13. package/dist/core/workflow.js +64 -0
  14. package/dist/index.d.ts +14 -36
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +15 -130
  17. package/dist/primitives/index.d.ts +37 -0
  18. package/dist/primitives/index.d.ts.map +1 -0
  19. package/dist/primitives/index.js +72 -0
  20. package/dist/primitives/llm.d.ts +56 -0
  21. package/dist/primitives/llm.d.ts.map +1 -0
  22. package/dist/primitives/llm.js +156 -0
  23. package/dist/primitives/output.d.ts +28 -0
  24. package/dist/primitives/output.d.ts.map +1 -0
  25. package/dist/primitives/output.js +39 -0
  26. package/dist/server/handler.d.ts +7 -0
  27. package/dist/server/handler.d.ts.map +1 -0
  28. package/dist/server/handler.js +55 -0
  29. package/dist/server.d.ts +10 -0
  30. package/dist/server.d.ts.map +1 -0
  31. package/dist/server.js +9 -0
  32. package/dist/tools/index.d.ts +49 -0
  33. package/dist/tools/index.d.ts.map +1 -0
  34. package/dist/tools/index.js +96 -0
  35. package/dist/types/index.d.ts +54 -0
  36. package/dist/types/index.d.ts.map +1 -0
  37. package/dist/types/index.js +5 -0
  38. package/docs/architecture/api-reference.md +307 -0
  39. package/docs/architecture/components.md +246 -0
  40. package/docs/architecture/core-workflows.md +236 -0
  41. package/docs/architecture/high-level-architecture.md +76 -0
  42. package/docs/architecture/index.md +31 -0
  43. package/docs/architecture/source-tree.md +92 -0
  44. package/docs/architecture/tech-stack.md +25 -0
  45. package/docs/prd/epic-list.md +101 -0
  46. package/docs/prd/goals-context.md +23 -0
  47. package/docs/prd/index.md +21 -0
  48. package/docs/prd/requirements.md +25 -0
  49. package/docs/prd/technical-assumptions.md +35 -0
  50. package/package.json +31 -118
  51. package/src/client.ts +18 -0
  52. package/src/core/parser.ts +36 -0
  53. package/src/core/variable-resolver.ts +114 -0
  54. package/src/core/workflow.ts +77 -0
  55. package/src/index.ts +25 -159
  56. package/src/primitives/index.ts +83 -0
  57. package/src/primitives/llm.ts +210 -0
  58. package/src/primitives/output.ts +65 -0
  59. package/src/server/handler.ts +80 -0
  60. package/src/server.ts +10 -0
  61. package/src/tools/index.ts +118 -0
  62. package/src/types/index.ts +62 -0
  63. package/tsconfig.json +27 -0
  64. package/CHANGELOG.md +0 -78
  65. package/LICENSE +0 -21
  66. package/dist/agents/chat/chat.handler.d.ts +0 -12
  67. package/dist/agents/chat/chat.handler.d.ts.map +0 -1
  68. package/dist/agents/chat/chat.handler.js +0 -143
  69. package/dist/agents/chat/chat.handler.js.map +0 -1
  70. package/dist/agents/chat/chat.schema.d.ts +0 -38
  71. package/dist/agents/chat/chat.schema.d.ts.map +0 -1
  72. package/dist/agents/chat/chat.schema.js +0 -31
  73. package/dist/agents/chat/chat.schema.js.map +0 -1
  74. package/dist/agents/chat/chat.types.d.ts +0 -42
  75. package/dist/agents/chat/chat.types.d.ts.map +0 -1
  76. package/dist/agents/chat/chat.types.js +0 -6
  77. package/dist/agents/chat/chat.types.js.map +0 -1
  78. package/dist/agents/chat/chat.yaml +0 -150
  79. package/dist/agents/chat/index.d.ts +0 -16
  80. package/dist/agents/chat/index.d.ts.map +0 -1
  81. package/dist/agents/chat/index.js +0 -21
  82. package/dist/agents/chat/index.js.map +0 -1
  83. package/dist/agents/chromadb/chromadb.handler.d.ts +0 -12
  84. package/dist/agents/chromadb/chromadb.handler.d.ts.map +0 -1
  85. package/dist/agents/chromadb/chromadb.handler.js +0 -139
  86. package/dist/agents/chromadb/chromadb.handler.js.map +0 -1
  87. package/dist/agents/chromadb/chromadb.schema.d.ts +0 -36
  88. package/dist/agents/chromadb/chromadb.schema.d.ts.map +0 -1
  89. package/dist/agents/chromadb/chromadb.schema.js +0 -33
  90. package/dist/agents/chromadb/chromadb.schema.js.map +0 -1
  91. package/dist/agents/chromadb/chromadb.types.d.ts +0 -49
  92. package/dist/agents/chromadb/chromadb.types.d.ts.map +0 -1
  93. package/dist/agents/chromadb/chromadb.types.js +0 -6
  94. package/dist/agents/chromadb/chromadb.types.js.map +0 -1
  95. package/dist/agents/chromadb/chromadb.yaml +0 -128
  96. package/dist/agents/chromadb/index.d.ts +0 -15
  97. package/dist/agents/chromadb/index.d.ts.map +0 -1
  98. package/dist/agents/chromadb/index.js +0 -20
  99. package/dist/agents/chromadb/index.js.map +0 -1
  100. package/dist/agents/gemini-vectorize/gemini-vectorize.handler.d.ts +0 -8
  101. package/dist/agents/gemini-vectorize/gemini-vectorize.handler.d.ts.map +0 -1
  102. package/dist/agents/gemini-vectorize/gemini-vectorize.handler.js +0 -58
  103. package/dist/agents/gemini-vectorize/gemini-vectorize.handler.js.map +0 -1
  104. package/dist/agents/gemini-vectorize/gemini-vectorize.schema.d.ts +0 -22
  105. package/dist/agents/gemini-vectorize/gemini-vectorize.schema.d.ts.map +0 -1
  106. package/dist/agents/gemini-vectorize/gemini-vectorize.schema.js +0 -20
  107. package/dist/agents/gemini-vectorize/gemini-vectorize.schema.js.map +0 -1
  108. package/dist/agents/gemini-vectorize/gemini-vectorize.types.d.ts +0 -32
  109. package/dist/agents/gemini-vectorize/gemini-vectorize.types.d.ts.map +0 -1
  110. package/dist/agents/gemini-vectorize/gemini-vectorize.types.js +0 -6
  111. package/dist/agents/gemini-vectorize/gemini-vectorize.types.js.map +0 -1
  112. package/dist/agents/gemini-vectorize/gemini-vectorize.yaml +0 -84
  113. package/dist/agents/gemini-vectorize/index.d.ts +0 -15
  114. package/dist/agents/gemini-vectorize/index.d.ts.map +0 -1
  115. package/dist/agents/gemini-vectorize/index.js +0 -20
  116. package/dist/agents/gemini-vectorize/index.js.map +0 -1
  117. package/dist/agents/gitmcp/gitmcp.handler.d.ts +0 -12
  118. package/dist/agents/gitmcp/gitmcp.handler.d.ts.map +0 -1
  119. package/dist/agents/gitmcp/gitmcp.handler.js +0 -95
  120. package/dist/agents/gitmcp/gitmcp.handler.js.map +0 -1
  121. package/dist/agents/gitmcp/gitmcp.schema.d.ts +0 -17
  122. package/dist/agents/gitmcp/gitmcp.schema.d.ts.map +0 -1
  123. package/dist/agents/gitmcp/gitmcp.schema.js +0 -18
  124. package/dist/agents/gitmcp/gitmcp.schema.js.map +0 -1
  125. package/dist/agents/gitmcp/gitmcp.types.d.ts +0 -31
  126. package/dist/agents/gitmcp/gitmcp.types.d.ts.map +0 -1
  127. package/dist/agents/gitmcp/gitmcp.types.js +0 -6
  128. package/dist/agents/gitmcp/gitmcp.types.js.map +0 -1
  129. package/dist/agents/gitmcp/gitmcp.yaml +0 -71
  130. package/dist/agents/gitmcp/index.d.ts +0 -16
  131. package/dist/agents/gitmcp/index.d.ts.map +0 -1
  132. package/dist/agents/gitmcp/index.js +0 -21
  133. package/dist/agents/gitmcp/index.js.map +0 -1
  134. package/dist/agents/image/image.handler.d.ts +0 -8
  135. package/dist/agents/image/image.handler.d.ts.map +0 -1
  136. package/dist/agents/image/image.handler.js +0 -66
  137. package/dist/agents/image/image.handler.js.map +0 -1
  138. package/dist/agents/image/image.schema.d.ts +0 -29
  139. package/dist/agents/image/image.schema.d.ts.map +0 -1
  140. package/dist/agents/image/image.schema.js +0 -26
  141. package/dist/agents/image/image.schema.js.map +0 -1
  142. package/dist/agents/image/image.types.d.ts +0 -42
  143. package/dist/agents/image/image.types.d.ts.map +0 -1
  144. package/dist/agents/image/image.types.js +0 -6
  145. package/dist/agents/image/image.types.js.map +0 -1
  146. package/dist/agents/image/image.yaml +0 -86
  147. package/dist/agents/image/index.d.ts +0 -14
  148. package/dist/agents/image/index.d.ts.map +0 -1
  149. package/dist/agents/image/index.js +0 -19
  150. package/dist/agents/image/index.js.map +0 -1
  151. package/dist/agents/index.d.ts +0 -95
  152. package/dist/agents/index.d.ts.map +0 -1
  153. package/dist/agents/index.js +0 -76
  154. package/dist/agents/index.js.map +0 -1
  155. package/dist/agents/joker/index.d.ts +0 -14
  156. package/dist/agents/joker/index.d.ts.map +0 -1
  157. package/dist/agents/joker/index.js +0 -19
  158. package/dist/agents/joker/index.js.map +0 -1
  159. package/dist/agents/joker/joker.handler.d.ts +0 -8
  160. package/dist/agents/joker/joker.handler.d.ts.map +0 -1
  161. package/dist/agents/joker/joker.handler.js +0 -48
  162. package/dist/agents/joker/joker.handler.js.map +0 -1
  163. package/dist/agents/joker/joker.schema.d.ts +0 -12
  164. package/dist/agents/joker/joker.schema.d.ts.map +0 -1
  165. package/dist/agents/joker/joker.schema.js +0 -13
  166. package/dist/agents/joker/joker.schema.js.map +0 -1
  167. package/dist/agents/joker/joker.types.d.ts +0 -35
  168. package/dist/agents/joker/joker.types.d.ts.map +0 -1
  169. package/dist/agents/joker/joker.types.js +0 -6
  170. package/dist/agents/joker/joker.types.js.map +0 -1
  171. package/dist/agents/joker/joker.yaml +0 -47
  172. package/dist/agents/mcp-tool/index.d.ts +0 -14
  173. package/dist/agents/mcp-tool/index.d.ts.map +0 -1
  174. package/dist/agents/mcp-tool/index.js +0 -19
  175. package/dist/agents/mcp-tool/index.js.map +0 -1
  176. package/dist/agents/mcp-tool/mcp-tool.handler.d.ts +0 -12
  177. package/dist/agents/mcp-tool/mcp-tool.handler.d.ts.map +0 -1
  178. package/dist/agents/mcp-tool/mcp-tool.handler.js +0 -116
  179. package/dist/agents/mcp-tool/mcp-tool.handler.js.map +0 -1
  180. package/dist/agents/mcp-tool/mcp-tool.schema.d.ts +0 -19
  181. package/dist/agents/mcp-tool/mcp-tool.schema.d.ts.map +0 -1
  182. package/dist/agents/mcp-tool/mcp-tool.schema.js +0 -20
  183. package/dist/agents/mcp-tool/mcp-tool.schema.js.map +0 -1
  184. package/dist/agents/mcp-tool/mcp-tool.types.d.ts +0 -31
  185. package/dist/agents/mcp-tool/mcp-tool.types.d.ts.map +0 -1
  186. package/dist/agents/mcp-tool/mcp-tool.types.js +0 -6
  187. package/dist/agents/mcp-tool/mcp-tool.types.js.map +0 -1
  188. package/dist/agents/mcp-tool/mcp-tool.yaml +0 -71
  189. package/dist/agents/rag/index.d.ts +0 -15
  190. package/dist/agents/rag/index.d.ts.map +0 -1
  191. package/dist/agents/rag/index.js +0 -20
  192. package/dist/agents/rag/index.js.map +0 -1
  193. package/dist/agents/rag/rag.handler.d.ts +0 -8
  194. package/dist/agents/rag/rag.handler.d.ts.map +0 -1
  195. package/dist/agents/rag/rag.handler.js +0 -101
  196. package/dist/agents/rag/rag.handler.js.map +0 -1
  197. package/dist/agents/rag/rag.schema.d.ts +0 -27
  198. package/dist/agents/rag/rag.schema.d.ts.map +0 -1
  199. package/dist/agents/rag/rag.schema.js +0 -24
  200. package/dist/agents/rag/rag.schema.js.map +0 -1
  201. package/dist/agents/rag/rag.types.d.ts +0 -47
  202. package/dist/agents/rag/rag.types.d.ts.map +0 -1
  203. package/dist/agents/rag/rag.types.js +0 -6
  204. package/dist/agents/rag/rag.types.js.map +0 -1
  205. package/dist/agents/rag/rag.yaml +0 -89
  206. package/dist/agents/registry/agentRegistry.d.ts +0 -117
  207. package/dist/agents/registry/agentRegistry.d.ts.map +0 -1
  208. package/dist/agents/registry/agentRegistry.js +0 -551
  209. package/dist/agents/registry/agentRegistry.js.map +0 -1
  210. package/dist/agents/registry/index.d.ts +0 -6
  211. package/dist/agents/registry/index.d.ts.map +0 -1
  212. package/dist/agents/registry/index.js +0 -10
  213. package/dist/agents/registry/index.js.map +0 -1
  214. package/dist/agents/translator/index.d.ts +0 -14
  215. package/dist/agents/translator/index.d.ts.map +0 -1
  216. package/dist/agents/translator/index.js +0 -19
  217. package/dist/agents/translator/index.js.map +0 -1
  218. package/dist/agents/translator/translator.handler.d.ts +0 -8
  219. package/dist/agents/translator/translator.handler.d.ts.map +0 -1
  220. package/dist/agents/translator/translator.handler.js +0 -83
  221. package/dist/agents/translator/translator.handler.js.map +0 -1
  222. package/dist/agents/translator/translator.schema.d.ts +0 -27
  223. package/dist/agents/translator/translator.schema.d.ts.map +0 -1
  224. package/dist/agents/translator/translator.schema.js +0 -28
  225. package/dist/agents/translator/translator.schema.js.map +0 -1
  226. package/dist/agents/translator/translator.types.d.ts +0 -40
  227. package/dist/agents/translator/translator.types.d.ts.map +0 -1
  228. package/dist/agents/translator/translator.types.js +0 -6
  229. package/dist/agents/translator/translator.types.js.map +0 -1
  230. package/dist/agents/translator/translator.yaml +0 -80
  231. package/dist/audit/auditTrail.d.ts +0 -55
  232. package/dist/audit/auditTrail.d.ts.map +0 -1
  233. package/dist/audit/auditTrail.js +0 -93
  234. package/dist/audit/auditTrail.js.map +0 -1
  235. package/dist/client/index.d.ts +0 -89
  236. package/dist/client/index.d.ts.map +0 -1
  237. package/dist/client/index.js +0 -93
  238. package/dist/client/index.js.map +0 -1
  239. package/dist/client/types.d.ts +0 -17
  240. package/dist/client/types.d.ts.map +0 -1
  241. package/dist/client/types.js +0 -7
  242. package/dist/client/types.js.map +0 -1
  243. package/dist/compliance/gdprEngine.d.ts +0 -44
  244. package/dist/compliance/gdprEngine.d.ts.map +0 -1
  245. package/dist/compliance/gdprEngine.js +0 -178
  246. package/dist/compliance/gdprEngine.js.map +0 -1
  247. package/dist/compliance/lgpdEngine.d.ts +0 -51
  248. package/dist/compliance/lgpdEngine.d.ts.map +0 -1
  249. package/dist/compliance/lgpdEngine.js +0 -221
  250. package/dist/compliance/lgpdEngine.js.map +0 -1
  251. package/dist/config.d.ts +0 -78
  252. package/dist/config.d.ts.map +0 -1
  253. package/dist/config.js +0 -77
  254. package/dist/config.js.map +0 -1
  255. package/dist/errors.d.ts +0 -17
  256. package/dist/errors.d.ts.map +0 -1
  257. package/dist/errors.js +0 -40
  258. package/dist/errors.js.map +0 -1
  259. package/dist/firebase/tenantManager.d.ts +0 -116
  260. package/dist/firebase/tenantManager.d.ts.map +0 -1
  261. package/dist/firebase/tenantManager.js +0 -444
  262. package/dist/firebase/tenantManager.js.map +0 -1
  263. package/dist/index.js.map +0 -1
  264. package/dist/integration/secure-yaml-runtime.d.ts +0 -68
  265. package/dist/integration/secure-yaml-runtime.d.ts.map +0 -1
  266. package/dist/integration/secure-yaml-runtime.js +0 -245
  267. package/dist/integration/secure-yaml-runtime.js.map +0 -1
  268. package/dist/parser/secure-yaml-parser.d.ts +0 -62
  269. package/dist/parser/secure-yaml-parser.d.ts.map +0 -1
  270. package/dist/parser/secure-yaml-parser.js +0 -234
  271. package/dist/parser/secure-yaml-parser.js.map +0 -1
  272. package/dist/performance/autoscaling.d.ts +0 -100
  273. package/dist/performance/autoscaling.d.ts.map +0 -1
  274. package/dist/performance/autoscaling.js +0 -339
  275. package/dist/performance/autoscaling.js.map +0 -1
  276. package/dist/performance/benchmark.d.ts +0 -104
  277. package/dist/performance/benchmark.d.ts.map +0 -1
  278. package/dist/performance/benchmark.js +0 -514
  279. package/dist/performance/benchmark.js.map +0 -1
  280. package/dist/performance/index.d.ts +0 -14
  281. package/dist/performance/index.d.ts.map +0 -1
  282. package/dist/performance/index.js +0 -35
  283. package/dist/performance/index.js.map +0 -1
  284. package/dist/performance/monitor.d.ts +0 -126
  285. package/dist/performance/monitor.d.ts.map +0 -1
  286. package/dist/performance/monitor.js +0 -324
  287. package/dist/performance/monitor.js.map +0 -1
  288. package/dist/performance/streaming.d.ts +0 -82
  289. package/dist/performance/streaming.d.ts.map +0 -1
  290. package/dist/performance/streaming.js +0 -287
  291. package/dist/performance/streaming.js.map +0 -1
  292. package/dist/runtime/audit.d.ts +0 -240
  293. package/dist/runtime/audit.d.ts.map +0 -1
  294. package/dist/runtime/audit.js +0 -641
  295. package/dist/runtime/audit.js.map +0 -1
  296. package/dist/runtime/declarativeAgentRuntime.d.ts +0 -92
  297. package/dist/runtime/declarativeAgentRuntime.d.ts.map +0 -1
  298. package/dist/runtime/declarativeAgentRuntime.js +0 -512
  299. package/dist/runtime/declarativeAgentRuntime.js.map +0 -1
  300. package/dist/runtime/index.d.ts +0 -12
  301. package/dist/runtime/index.d.ts.map +0 -1
  302. package/dist/runtime/index.js +0 -33
  303. package/dist/runtime/index.js.map +0 -1
  304. package/dist/runtime/isolatedRuntime.d.ts +0 -119
  305. package/dist/runtime/isolatedRuntime.d.ts.map +0 -1
  306. package/dist/runtime/isolatedRuntime.js +0 -425
  307. package/dist/runtime/isolatedRuntime.js.map +0 -1
  308. package/dist/runtime/schemaCompiler.d.ts +0 -35
  309. package/dist/runtime/schemaCompiler.d.ts.map +0 -1
  310. package/dist/runtime/schemaCompiler.js +0 -152
  311. package/dist/runtime/schemaCompiler.js.map +0 -1
  312. package/dist/runtime/simpleRuntime.d.ts +0 -57
  313. package/dist/runtime/simpleRuntime.d.ts.map +0 -1
  314. package/dist/runtime/simpleRuntime.js +0 -187
  315. package/dist/runtime/simpleRuntime.js.map +0 -1
  316. package/dist/runtime/workflowExecutor.d.ts +0 -30
  317. package/dist/runtime/workflowExecutor.d.ts.map +0 -1
  318. package/dist/runtime/workflowExecutor.js +0 -70
  319. package/dist/runtime/workflowExecutor.js.map +0 -1
  320. package/dist/security/dashboard.d.ts +0 -89
  321. package/dist/security/dashboard.d.ts.map +0 -1
  322. package/dist/security/dashboard.js +0 -300
  323. package/dist/security/dashboard.js.map +0 -1
  324. package/dist/security/hardening.d.ts +0 -130
  325. package/dist/security/hardening.d.ts.map +0 -1
  326. package/dist/security/hardening.js +0 -414
  327. package/dist/security/hardening.js.map +0 -1
  328. package/dist/security/index.d.ts +0 -128
  329. package/dist/security/index.d.ts.map +0 -1
  330. package/dist/security/index.js +0 -353
  331. package/dist/security/index.js.map +0 -1
  332. package/dist/security/monitor.d.ts +0 -88
  333. package/dist/security/monitor.d.ts.map +0 -1
  334. package/dist/security/monitor.js +0 -356
  335. package/dist/security/monitor.js.map +0 -1
  336. package/dist/security/scanner.d.ts +0 -104
  337. package/dist/security/scanner.d.ts.map +0 -1
  338. package/dist/security/scanner.js +0 -298
  339. package/dist/security/scanner.js.map +0 -1
  340. package/dist/security/score.d.ts +0 -150
  341. package/dist/security/score.d.ts.map +0 -1
  342. package/dist/security/score.js +0 -983
  343. package/dist/security/score.js.map +0 -1
  344. package/dist/security/threatDetector.d.ts +0 -39
  345. package/dist/security/threatDetector.d.ts.map +0 -1
  346. package/dist/security/threatDetector.js +0 -354
  347. package/dist/security/threatDetector.js.map +0 -1
  348. package/dist/security/validation.d.ts +0 -69
  349. package/dist/security/validation.d.ts.map +0 -1
  350. package/dist/security/validation.js +0 -286
  351. package/dist/security/validation.js.map +0 -1
  352. package/dist/server/api/clientsRoute.d.ts +0 -9
  353. package/dist/server/api/clientsRoute.d.ts.map +0 -1
  354. package/dist/server/api/clientsRoute.js +0 -71
  355. package/dist/server/api/clientsRoute.js.map +0 -1
  356. package/dist/server/api/endpointsRoute.d.ts +0 -8
  357. package/dist/server/api/endpointsRoute.d.ts.map +0 -1
  358. package/dist/server/api/endpointsRoute.js +0 -76
  359. package/dist/server/api/endpointsRoute.js.map +0 -1
  360. package/dist/server/api/graphql.d.ts +0 -9
  361. package/dist/server/api/graphql.d.ts.map +0 -1
  362. package/dist/server/api/graphql.js +0 -222
  363. package/dist/server/api/graphql.js.map +0 -1
  364. package/dist/server/errors.d.ts +0 -19
  365. package/dist/server/errors.d.ts.map +0 -1
  366. package/dist/server/errors.js +0 -42
  367. package/dist/server/errors.js.map +0 -1
  368. package/dist/server/index.d.ts +0 -7
  369. package/dist/server/index.d.ts.map +0 -1
  370. package/dist/server/index.js +0 -24
  371. package/dist/server/index.js.map +0 -1
  372. package/dist/server/kvStore.d.ts +0 -27
  373. package/dist/server/kvStore.d.ts.map +0 -1
  374. package/dist/server/kvStore.js +0 -128
  375. package/dist/server/kvStore.js.map +0 -1
  376. package/dist/server/runtimeSecurity.d.ts +0 -28
  377. package/dist/server/runtimeSecurity.d.ts.map +0 -1
  378. package/dist/server/runtimeSecurity.js +0 -85
  379. package/dist/server/runtimeSecurity.js.map +0 -1
  380. package/dist/server/types.d.ts +0 -53
  381. package/dist/server/types.d.ts.map +0 -1
  382. package/dist/server/types.js +0 -8
  383. package/dist/server/types.js.map +0 -1
  384. package/dist/shared/index.d.ts +0 -7
  385. package/dist/shared/index.d.ts.map +0 -1
  386. package/dist/shared/index.js +0 -23
  387. package/dist/shared/index.js.map +0 -1
  388. package/dist/shared/types/agent.types.d.ts +0 -50
  389. package/dist/shared/types/agent.types.d.ts.map +0 -1
  390. package/dist/shared/types/agent.types.js +0 -7
  391. package/dist/shared/types/agent.types.js.map +0 -1
  392. package/dist/shared/types/execution.types.d.ts +0 -42
  393. package/dist/shared/types/execution.types.d.ts.map +0 -1
  394. package/dist/shared/types/execution.types.js +0 -7
  395. package/dist/shared/types/execution.types.js.map +0 -1
  396. package/dist/shared/types/index.d.ts +0 -7
  397. package/dist/shared/types/index.d.ts.map +0 -1
  398. package/dist/shared/types/index.js +0 -23
  399. package/dist/shared/types/index.js.map +0 -1
  400. package/dist/shared/types/schema.types.d.ts +0 -52
  401. package/dist/shared/types/schema.types.d.ts.map +0 -1
  402. package/dist/shared/types/schema.types.js +0 -7
  403. package/dist/shared/types/schema.types.js.map +0 -1
  404. package/dist/shared/utils/index.d.ts +0 -5
  405. package/dist/shared/utils/index.d.ts.map +0 -1
  406. package/dist/shared/utils/index.js +0 -21
  407. package/dist/shared/utils/index.js.map +0 -1
  408. package/dist/shared/utils/validation.d.ts +0 -42
  409. package/dist/shared/utils/validation.d.ts.map +0 -1
  410. package/dist/shared/utils/validation.js +0 -93
  411. package/dist/shared/utils/validation.js.map +0 -1
  412. package/dist/tenant/TenantManager.d.ts +0 -152
  413. package/dist/tenant/TenantManager.d.ts.map +0 -1
  414. package/dist/tenant/TenantManager.js +0 -392
  415. package/dist/tenant/TenantManager.js.map +0 -1
  416. package/dist/tenant/index.d.ts +0 -47
  417. package/dist/tenant/index.d.ts.map +0 -1
  418. package/dist/tenant/index.js +0 -74
  419. package/dist/tenant/index.js.map +0 -1
  420. package/dist/tenant/interfaces.d.ts +0 -170
  421. package/dist/tenant/interfaces.d.ts.map +0 -1
  422. package/dist/tenant/interfaces.js +0 -67
  423. package/dist/tenant/interfaces.js.map +0 -1
  424. package/dist/tenant/providerFactory.d.ts +0 -43
  425. package/dist/tenant/providerFactory.d.ts.map +0 -1
  426. package/dist/tenant/providerFactory.js +0 -70
  427. package/dist/tenant/providerFactory.js.map +0 -1
  428. package/dist/tenant/providerRegistry.d.ts +0 -47
  429. package/dist/tenant/providerRegistry.d.ts.map +0 -1
  430. package/dist/tenant/providerRegistry.js +0 -79
  431. package/dist/tenant/providerRegistry.js.map +0 -1
  432. package/dist/tenant/providers/FirebaseTenantProvider.d.ts +0 -41
  433. package/dist/tenant/providers/FirebaseTenantProvider.d.ts.map +0 -1
  434. package/dist/tenant/providers/FirebaseTenantProvider.js +0 -290
  435. package/dist/tenant/providers/FirebaseTenantProvider.js.map +0 -1
  436. package/dist/tenant/providers/InMemoryTenantProvider.d.ts +0 -18
  437. package/dist/tenant/providers/InMemoryTenantProvider.d.ts.map +0 -1
  438. package/dist/tenant/providers/InMemoryTenantProvider.js +0 -137
  439. package/dist/tenant/providers/InMemoryTenantProvider.js.map +0 -1
  440. package/dist/types/executionContext.d.ts +0 -16
  441. package/dist/types/executionContext.d.ts.map +0 -1
  442. package/dist/types/executionContext.js +0 -3
  443. package/dist/types/executionContext.js.map +0 -1
  444. package/src/agents/chat/chat.handler.ts +0 -209
  445. package/src/agents/chat/chat.schema.ts +0 -33
  446. package/src/agents/chat/chat.types.ts +0 -46
  447. package/src/agents/chat/chat.yaml +0 -150
  448. package/src/agents/chat/index.ts +0 -21
  449. package/src/agents/chromadb/chromadb.handler.ts +0 -130
  450. package/src/agents/chromadb/chromadb.schema.ts +0 -35
  451. package/src/agents/chromadb/chromadb.types.ts +0 -52
  452. package/src/agents/chromadb/chromadb.yaml +0 -128
  453. package/src/agents/chromadb/index.ts +0 -20
  454. package/src/agents/gemini-vectorize/gemini-vectorize.handler.ts +0 -72
  455. package/src/agents/gemini-vectorize/gemini-vectorize.schema.ts +0 -22
  456. package/src/agents/gemini-vectorize/gemini-vectorize.types.ts +0 -34
  457. package/src/agents/gemini-vectorize/gemini-vectorize.yaml +0 -84
  458. package/src/agents/gemini-vectorize/index.ts +0 -20
  459. package/src/agents/gitmcp/gitmcp.handler.ts +0 -122
  460. package/src/agents/gitmcp/gitmcp.schema.ts +0 -20
  461. package/src/agents/gitmcp/gitmcp.types.ts +0 -33
  462. package/src/agents/gitmcp/gitmcp.yaml +0 -71
  463. package/src/agents/gitmcp/index.ts +0 -21
  464. package/src/agents/image/image.handler.ts +0 -82
  465. package/src/agents/image/image.schema.ts +0 -28
  466. package/src/agents/image/image.types.ts +0 -45
  467. package/src/agents/image/image.yaml +0 -86
  468. package/src/agents/image/index.ts +0 -19
  469. package/src/agents/index.ts +0 -59
  470. package/src/agents/joker/index.ts +0 -19
  471. package/src/agents/joker/joker.handler.ts +0 -60
  472. package/src/agents/joker/joker.schema.ts +0 -15
  473. package/src/agents/joker/joker.types.ts +0 -37
  474. package/src/agents/joker/joker.yaml +0 -47
  475. package/src/agents/mcp-tool/index.ts +0 -19
  476. package/src/agents/mcp-tool/mcp-tool.handler.ts +0 -112
  477. package/src/agents/mcp-tool/mcp-tool.schema.ts +0 -22
  478. package/src/agents/mcp-tool/mcp-tool.types.ts +0 -33
  479. package/src/agents/mcp-tool/mcp-tool.yaml +0 -71
  480. package/src/agents/rag/index.ts +0 -20
  481. package/src/agents/rag/rag.handler.ts +0 -119
  482. package/src/agents/rag/rag.schema.ts +0 -26
  483. package/src/agents/rag/rag.types.ts +0 -51
  484. package/src/agents/rag/rag.yaml +0 -89
  485. package/src/agents/registry/agentRegistry.ts +0 -598
  486. package/src/agents/registry/index.ts +0 -6
  487. package/src/agents/translator/index.ts +0 -19
  488. package/src/agents/translator/translator.handler.ts +0 -99
  489. package/src/agents/translator/translator.schema.ts +0 -30
  490. package/src/agents/translator/translator.types.ts +0 -42
  491. package/src/agents/translator/translator.yaml +0 -80
  492. package/src/audit/auditTrail.ts +0 -134
  493. package/src/client/index.ts +0 -53
  494. package/src/client/types.ts +0 -38
  495. package/src/compliance/gdprEngine.ts +0 -209
  496. package/src/compliance/lgpdEngine.ts +0 -268
  497. package/src/config.ts +0 -179
  498. package/src/errors.ts +0 -35
  499. package/src/integration/secure-yaml-runtime.ts +0 -341
  500. package/src/parser/secure-yaml-parser.ts +0 -273
  501. package/src/performance/autoscaling.ts +0 -495
  502. package/src/performance/benchmark.ts +0 -644
  503. package/src/performance/index.ts +0 -34
  504. package/src/performance/monitor.ts +0 -469
  505. package/src/performance/streaming.ts +0 -317
  506. package/src/runtime/audit.ts +0 -907
  507. package/src/runtime/declarativeAgentRuntime.ts +0 -772
  508. package/src/runtime/index.ts +0 -31
  509. package/src/runtime/isolatedRuntime.ts +0 -572
  510. package/src/runtime/schemaCompiler.ts +0 -228
  511. package/src/runtime/simpleRuntime.ts +0 -201
  512. package/src/runtime/workflowExecutor.ts +0 -94
  513. package/src/security/dashboard.ts +0 -462
  514. package/src/security/hardening.ts +0 -560
  515. package/src/security/index.ts +0 -439
  516. package/src/security/monitor.ts +0 -490
  517. package/src/security/scanner.ts +0 -368
  518. package/src/security/score.ts +0 -1138
  519. package/src/security/threatDetector.ts +0 -481
  520. package/src/security/validation.ts +0 -365
  521. package/src/server/api/clientsRoute.ts +0 -92
  522. package/src/server/api/endpointsRoute.ts +0 -97
  523. package/src/server/api/graphql.ts +0 -284
  524. package/src/server/errors.ts +0 -38
  525. package/src/server/index.ts +0 -6
  526. package/src/server/kvStore.ts +0 -152
  527. package/src/server/runtimeSecurity.ts +0 -102
  528. package/src/server/types.ts +0 -60
  529. package/src/shared/index.ts +0 -7
  530. package/src/shared/types/agent.types.ts +0 -80
  531. package/src/shared/types/execution.types.ts +0 -45
  532. package/src/shared/types/index.ts +0 -7
  533. package/src/shared/types/schema.types.ts +0 -55
  534. package/src/shared/utils/index.ts +0 -5
  535. package/src/shared/utils/validation.ts +0 -100
  536. package/src/tenant/TenantManager.ts +0 -488
  537. package/src/tenant/index.ts +0 -101
  538. package/src/tenant/interfaces.ts +0 -231
  539. package/src/tenant/providerFactory.ts +0 -75
  540. package/src/tenant/providerRegistry.ts +0 -86
  541. package/src/tenant/providers/InMemoryTenantProvider.ts +0 -168
  542. package/src/types/executionContext.ts +0 -16
@@ -1,772 +0,0 @@
1
- /**
2
- * Declarative Agent Runtime - YAML Interpreter for Beddel Declarative Protocol
3
- * Safely interprets declarative YAML agent definitions without dynamic code execution
4
- *
5
- * Phase 3 Refactored: Delegates to individual agent handlers via workflowExecutor
6
- */
7
-
8
- import 'server-only';
9
-
10
- import * as yaml from 'js-yaml';
11
- import { type ZodTypeAny } from 'zod';
12
- import { ExecutionContext } from '../types/executionContext';
13
- import { agentRegistry } from '../agents/registry';
14
- import {
15
- DeclarativeSchemaCompiler,
16
- DeclarativeSchemaValidationError,
17
- type DeclarativeSchemaPhase,
18
- } from './schemaCompiler';
19
-
20
- // Import handlers from workflowExecutor
21
- import {
22
- executeJokeHandler,
23
- executeTranslationHandler,
24
- executeImageHandler,
25
- executeMcpToolHandler,
26
- executeVectorizeHandler,
27
- executeChromaDBHandler,
28
- executeGitMcpHandler,
29
- executeRagHandler,
30
- executeChatHandler,
31
- } from './workflowExecutor';
32
-
33
- export interface YamlAgentDefinition {
34
- agent: {
35
- id: string;
36
- version: string;
37
- protocol: string;
38
- };
39
- metadata: {
40
- name: string;
41
- description: string;
42
- category: string;
43
- route?: string;
44
- };
45
- schema: {
46
- input: any;
47
- output: any;
48
- };
49
- logic: {
50
- variables?: Array<{
51
- name: string;
52
- type: string;
53
- init: string;
54
- }>;
55
- workflow: Array<{
56
- name: string;
57
- type: string;
58
- action: {
59
- type: string;
60
- output?: Record<string, any>;
61
- [key: string]: any;
62
- };
63
- }>;
64
- };
65
- output?: {
66
- schema?: any;
67
- };
68
- }
69
-
70
- export interface YamlAgentInterpreterOptions {
71
- yamlContent: string;
72
- input: Record<string, any>;
73
- props: Record<string, string>;
74
- context: ExecutionContext;
75
- }
76
-
77
- export type YamlExecutionResult = Record<string, any>;
78
-
79
- /**
80
- * Safe declarative YAML interpreter - no dynamic code execution
81
- * Delegates execution to individual agent handlers
82
- */
83
- export class DeclarativeAgentInterpreter {
84
- private readonly MAX_VARIABLE_SIZE = 1024;
85
- private readonly MAX_WORKFLOW_STEPS = 100;
86
- private readonly MAX_OUTPUT_SIZE = 5 * 1024 * 1024;
87
- private readonly schemaCompiler = new DeclarativeSchemaCompiler();
88
-
89
- /**
90
- * Interpret declarative YAML agent definition
91
- */
92
- public async interpret(
93
- options: YamlAgentInterpreterOptions
94
- ): Promise<YamlExecutionResult> {
95
- const startTime = Date.now();
96
-
97
- try {
98
- const agent = this.parseYaml(options.yamlContent);
99
- this.validateAgentDefinition(agent);
100
-
101
- const schemas = this.buildSchemaSet(agent);
102
- const validatedInput = this.validateAgainstSchema(
103
- options.input,
104
- schemas.input,
105
- 'input',
106
- options.context
107
- );
108
-
109
- const executionOptions: YamlAgentInterpreterOptions = {
110
- ...options,
111
- input: validatedInput,
112
- };
113
-
114
- const result = await this.executeWorkflow(agent, executionOptions);
115
-
116
- const validatedOutput = this.validateAgainstSchema(
117
- result,
118
- schemas.output,
119
- 'output',
120
- options.context
121
- );
122
- this.enforceOutputSize(validatedOutput);
123
-
124
- const executionTime = Date.now() - startTime;
125
- options.context.log(`Declarative agent executed in ${executionTime}ms`);
126
-
127
- return validatedOutput;
128
- } catch (error) {
129
- options.context.log(`Declarative agent execution failed: ${error}`);
130
- options.context.setError(
131
- error instanceof Error ? error.message : 'Unknown declarative agent error'
132
- );
133
- throw error;
134
- }
135
- }
136
-
137
- private parseYaml(yamlContent: string): YamlAgentDefinition {
138
- try {
139
- const parsed = yaml.load(yamlContent) as YamlAgentDefinition;
140
-
141
- if (!parsed || typeof parsed !== 'object') {
142
- throw new Error('Invalid YAML: expected object');
143
- }
144
-
145
- if (!parsed.agent || !parsed.logic || !parsed.schema) {
146
- throw new Error('Invalid agent definition: missing required sections');
147
- }
148
-
149
- return parsed;
150
- } catch (error) {
151
- throw new Error(`YAML parsing failed: ${error}`);
152
- }
153
- }
154
-
155
- private validateAgentDefinition(agent: YamlAgentDefinition): void {
156
- if (agent.agent.protocol !== 'beddel-declarative-protocol/v2.0') {
157
- throw new Error(`Unsupported protocol: ${agent.agent.protocol}`);
158
- }
159
-
160
- if (!agent.schema.input || !agent.schema.output) {
161
- throw new Error('Invalid schema: missing input or output definition');
162
- }
163
-
164
- if (!Array.isArray(agent.logic.workflow) || agent.logic.workflow.length === 0) {
165
- throw new Error('Invalid workflow: must be non-empty array');
166
- }
167
-
168
- if (agent.logic.workflow.length > this.MAX_WORKFLOW_STEPS) {
169
- throw new Error(`Workflow too complex: max ${this.MAX_WORKFLOW_STEPS} steps allowed`);
170
- }
171
- }
172
-
173
- private buildSchemaSet(agent: YamlAgentDefinition): {
174
- input: ZodTypeAny;
175
- output: ZodTypeAny;
176
- } {
177
- return {
178
- input: this.schemaCompiler.compile(agent.schema.input, 'schema.input'),
179
- output: this.schemaCompiler.compile(agent.schema.output, 'schema.output'),
180
- };
181
- }
182
-
183
- private validateAgainstSchema(
184
- data: unknown,
185
- schema: ZodTypeAny,
186
- phase: DeclarativeSchemaPhase,
187
- context: ExecutionContext
188
- ): any {
189
- const validationResult = schema.safeParse(data);
190
- if (!validationResult.success) {
191
- const issues = validationResult.error.issues;
192
- const issueSummary = issues
193
- .map((issue) => `${issue.path.join('.') || 'root'}: ${issue.message}`)
194
- .join('; ');
195
- const label = phase === 'input' ? 'Input' : 'Output';
196
- const message = `${label} validation failed: ${issueSummary}`;
197
- context.setError(message);
198
- throw new DeclarativeSchemaValidationError(message, phase, issues);
199
- }
200
- return validationResult.data;
201
- }
202
-
203
- private enforceOutputSize(output: any): void {
204
- const outputSize = JSON.stringify(output).length;
205
- if (outputSize > this.MAX_OUTPUT_SIZE) {
206
- throw new Error(`Output size exceeds maximum allowed: ${outputSize} > ${this.MAX_OUTPUT_SIZE}`);
207
- }
208
- }
209
-
210
- private async executeWorkflow(
211
- agent: YamlAgentDefinition,
212
- options: YamlAgentInterpreterOptions
213
- ): Promise<YamlExecutionResult> {
214
- const variables = new Map<string, any>();
215
- let output: any = undefined;
216
-
217
- if (agent.logic.variables) {
218
- for (const variable of agent.logic.variables) {
219
- this.validateVariable(variable);
220
- const value = this.evaluateValue(variable.init, variables);
221
- variables.set(variable.name, value);
222
- }
223
- }
224
-
225
- for (const step of agent.logic.workflow) {
226
- output = await this.executeWorkflowStep(step, variables, options);
227
- }
228
-
229
- return output;
230
- }
231
-
232
- private async executeWorkflowStep(
233
- step: any,
234
- variables: Map<string, any>,
235
- options: YamlAgentInterpreterOptions
236
- ): Promise<any> {
237
- options.context.log(`Executing workflow step: ${step.name} (${step.type})`);
238
-
239
- switch (step.type) {
240
- case 'output-generator':
241
- return this.executeOutputGenerator(step, variables, options);
242
- case 'genkit-joke':
243
- return this.executeGenkitJoke(step, variables, options);
244
- case 'genkit-translation':
245
- return this.executeGenkitTranslation(step, variables, options);
246
- case 'genkit-image':
247
- return this.executeGenkitImage(step, variables, options);
248
- case 'custom-action':
249
- return this.executeCustomAction(step, variables, options);
250
- case 'mcp-tool':
251
- return this.executeMcpTool(step, variables, options);
252
- case 'gemini-vectorize':
253
- return this.executeGeminiVectorize(step, variables, options);
254
- case 'chromadb':
255
- return this.executeChromaDB(step, variables, options);
256
- case 'gitmcp':
257
- return this.executeGitMcp(step, variables, options);
258
- case 'rag':
259
- return this.executeRag(step, variables, options);
260
- case 'chat':
261
- return this.executeChat(step, variables, options);
262
- case 'builtin-agent':
263
- return this.executeBuiltinAgent(step, variables, options);
264
- default:
265
- throw new Error(`Unsupported workflow step type: ${step.type}`);
266
- }
267
- }
268
-
269
- // ============================================================================
270
- // Output Generator (kept inline - orchestration logic)
271
- // ============================================================================
272
-
273
- private executeOutputGenerator(
274
- step: any,
275
- variables: Map<string, any>,
276
- options: YamlAgentInterpreterOptions
277
- ): any {
278
- if (step.action?.type !== 'generate' || !step.action.output) {
279
- throw new Error('Invalid output generator configuration');
280
- }
281
-
282
- const output: any = {};
283
-
284
- options.context.log(
285
- `Output generator: Available variables: ${Array.from(variables.keys()).join(', ')}`
286
- );
287
-
288
- for (const [key, valueExpr] of Object.entries(step.action.output)) {
289
- if (typeof valueExpr === 'string' && valueExpr.startsWith('$')) {
290
- try {
291
- const reference = valueExpr.substring(1);
292
- const resolved = this.resolveReference(reference, variables);
293
- output[key] = resolved;
294
- } catch (error) {
295
- options.context.log(
296
- `Output generator: Failed to resolve ${valueExpr}: ${error instanceof Error ? error.message : String(error)}`
297
- );
298
- throw error;
299
- }
300
- } else {
301
- output[key] = valueExpr;
302
- }
303
- }
304
-
305
- return output;
306
- }
307
-
308
- // ============================================================================
309
- // Delegated Handlers - Using extracted agent handlers
310
- // ============================================================================
311
-
312
- private async executeGenkitJoke(
313
- step: any,
314
- variables: Map<string, any>,
315
- options: YamlAgentInterpreterOptions
316
- ): Promise<any> {
317
- const prompt =
318
- typeof step.action?.prompt === 'string' && step.action.prompt.trim().length
319
- ? step.action.prompt.trim()
320
- : 'Tell a short and original joke that works for any audience.';
321
- const temperature =
322
- typeof step.action?.temperature === 'number' ? step.action.temperature : 0.8;
323
- const maxTokens =
324
- typeof step.action?.maxTokens === 'number' ? step.action.maxTokens : undefined;
325
- const resultVar =
326
- typeof step.action?.result === 'string' && step.action.result.length > 0
327
- ? step.action.result
328
- : 'jokerResult';
329
-
330
- const result = await executeJokeHandler(
331
- { prompt, temperature, maxTokens },
332
- options.props,
333
- options.context
334
- );
335
-
336
- variables.set(resultVar, result);
337
- return result;
338
- }
339
-
340
- private async executeGenkitTranslation(
341
- step: any,
342
- variables: Map<string, any>,
343
- options: YamlAgentInterpreterOptions
344
- ): Promise<any> {
345
- const text = options.input?.texto || options.input?.text;
346
- const sourceLanguage = options.input?.idioma_origem || options.input?.source_language;
347
- const targetLanguage = options.input?.idioma_destino || options.input?.target_language;
348
-
349
- const resultVar =
350
- typeof step.action?.result === 'string' && step.action.result.length > 0
351
- ? step.action.result
352
- : 'translationResult';
353
-
354
- const result = await executeTranslationHandler(
355
- {
356
- text,
357
- source_language: sourceLanguage,
358
- target_language: targetLanguage,
359
- promptTemplate:
360
- typeof step.action?.promptTemplate === 'string'
361
- ? step.action.promptTemplate
362
- : undefined,
363
- },
364
- options.props,
365
- options.context
366
- );
367
-
368
- variables.set(resultVar, result);
369
- return result;
370
- }
371
-
372
- private async executeGenkitImage(
373
- step: any,
374
- variables: Map<string, any>,
375
- options: YamlAgentInterpreterOptions
376
- ): Promise<any> {
377
- const description =
378
- typeof options.input?.descricao === 'string'
379
- ? options.input.descricao.trim()
380
- : typeof options.input?.description === 'string'
381
- ? options.input.description.trim()
382
- : '';
383
- const style =
384
- typeof options.input?.estilo === 'string'
385
- ? options.input.estilo.trim()
386
- : typeof options.input?.style === 'string'
387
- ? options.input.style.trim()
388
- : '';
389
- const resolution =
390
- typeof options.input?.resolucao === 'string'
391
- ? options.input.resolucao.trim()
392
- : typeof options.input?.resolution === 'string'
393
- ? options.input.resolution.trim()
394
- : '';
395
-
396
- if (!description) {
397
- throw new Error('Missing required image input: description');
398
- }
399
- if (!style) {
400
- throw new Error('Missing required image input: style');
401
- }
402
- if (!resolution) {
403
- throw new Error('Missing required image input: resolution');
404
- }
405
-
406
- const promptTemplate =
407
- typeof step.action?.promptTemplate === 'string' &&
408
- step.action.promptTemplate.trim().length > 0
409
- ? step.action.promptTemplate
410
- : 'Create a detailed image in {{style}} style focusing on: {{description}}';
411
-
412
- const resultVar =
413
- typeof step.action?.result === 'string' && step.action.result.length > 0
414
- ? step.action.result
415
- : 'imageResult';
416
-
417
- const result = await executeImageHandler(
418
- {
419
- description,
420
- style,
421
- resolution,
422
- promptTemplate,
423
- },
424
- options.props,
425
- options.context
426
- );
427
-
428
- variables.set(resultVar, result);
429
- return result;
430
- }
431
-
432
- private async executeMcpTool(
433
- step: any,
434
- variables: Map<string, any>,
435
- options: YamlAgentInterpreterOptions
436
- ): Promise<any> {
437
- const serverUrl = this.resolveInputValue(step.action?.server_url, options.input, variables);
438
- const toolName = this.resolveInputValue(step.action?.tool_name, options.input, variables);
439
- const toolArguments =
440
- this.resolveInputValue(step.action?.tool_arguments, options.input, variables) || {};
441
- const resultVar = step.action?.result || 'mcpResult';
442
-
443
- const result = await executeMcpToolHandler(
444
- {
445
- server_url: serverUrl,
446
- tool_name: toolName,
447
- tool_arguments: toolArguments,
448
- },
449
- options.props,
450
- options.context
451
- );
452
-
453
- variables.set(resultVar, result);
454
- return result;
455
- }
456
-
457
- private async executeGeminiVectorize(
458
- step: any,
459
- variables: Map<string, any>,
460
- options: YamlAgentInterpreterOptions
461
- ): Promise<any> {
462
- const action = step.action?.action || 'embedSingle';
463
- const resultVar = step.action?.result || 'vectorizeResult';
464
-
465
- let result;
466
- if (action === 'embedSingle') {
467
- const text = this.resolveInputValue(step.action?.text, options.input, variables);
468
- result = await executeVectorizeHandler(
469
- { action: 'embedSingle', text },
470
- options.props,
471
- options.context
472
- );
473
- } else if (action === 'embedBatch') {
474
- const texts = this.resolveInputValue(step.action?.texts, options.input, variables);
475
- result = await executeVectorizeHandler(
476
- { action: 'embedBatch', texts },
477
- options.props,
478
- options.context
479
- );
480
- } else {
481
- throw new Error(`Unknown vectorize action: ${action}`);
482
- }
483
-
484
- variables.set(resultVar, result);
485
- return result;
486
- }
487
-
488
- private async executeChromaDB(
489
- step: any,
490
- variables: Map<string, any>,
491
- options: YamlAgentInterpreterOptions
492
- ): Promise<any> {
493
- const action = this.resolveInputValue(step.action?.action, options.input, variables);
494
- const collectionName = this.resolveInputValue(
495
- step.action?.collection_name,
496
- options.input,
497
- variables
498
- );
499
- const resultVar = step.action?.result || 'chromaResult';
500
-
501
- let params: any = { action, collection_name: collectionName };
502
-
503
- if (action === 'hasData') {
504
- params.min_count =
505
- this.resolveInputValue(step.action?.min_count, options.input, variables) || 1;
506
- } else if (action === 'store') {
507
- params.ids = this.resolveInputValue(step.action?.ids, options.input, variables);
508
- params.vectors = this.resolveInputValue(step.action?.vectors, options.input, variables);
509
- params.documents = this.resolveInputValue(step.action?.documents, options.input, variables);
510
- params.metadatas = this.resolveInputValue(step.action?.metadatas, options.input, variables);
511
- } else if (action === 'search') {
512
- params.query_vector = this.resolveInputValue(
513
- step.action?.query_vector,
514
- options.input,
515
- variables
516
- );
517
- params.limit =
518
- this.resolveInputValue(step.action?.limit, options.input, variables) || 5;
519
- }
520
-
521
- const result = await executeChromaDBHandler(params, options.props, options.context);
522
-
523
- variables.set(resultVar, result);
524
- return result;
525
- }
526
-
527
- private async executeGitMcp(
528
- step: any,
529
- variables: Map<string, any>,
530
- options: YamlAgentInterpreterOptions
531
- ): Promise<any> {
532
- const gitmcpUrl = this.resolveInputValue(step.action?.gitmcp_url, options.input, variables);
533
- const resultVar = step.action?.result || 'gitmcpResult';
534
-
535
- const result = await executeGitMcpHandler(
536
- { gitmcp_url: gitmcpUrl },
537
- options.props,
538
- options.context
539
- );
540
-
541
- variables.set(resultVar, result);
542
- return result;
543
- }
544
-
545
- private async executeRag(
546
- step: any,
547
- variables: Map<string, any>,
548
- options: YamlAgentInterpreterOptions
549
- ): Promise<any> {
550
- const query = this.resolveInputValue(step.action?.query, options.input, variables);
551
- const context =
552
- this.resolveInputValue(step.action?.context, options.input, variables) ||
553
- this.resolveInputValue(step.action?.documents, options.input, variables);
554
- const history = this.resolveInputValue(step.action?.history, options.input, variables);
555
- const resultVar = step.action?.result || 'ragResult';
556
-
557
- const result = await executeRagHandler(
558
- { query, context, documents: context, history },
559
- options.props,
560
- options.context
561
- );
562
-
563
- variables.set(resultVar, result);
564
- return result;
565
- }
566
-
567
- private async executeChat(
568
- step: any,
569
- variables: Map<string, any>,
570
- options: YamlAgentInterpreterOptions
571
- ): Promise<any> {
572
- const messages = this.resolveInputValue(step.action?.messages, options.input, variables);
573
- const query = this.resolveInputValue(step.action?.query, options.input, variables);
574
- const resultVar = step.action?.result || 'chatResult';
575
-
576
- const result = await executeChatHandler(
577
- { messages, query },
578
- options.props,
579
- options.context
580
- );
581
-
582
- variables.set(resultVar, result);
583
- return result;
584
- }
585
-
586
- // ============================================================================
587
- // Custom Action & Builtin Agent (orchestration logic)
588
- // ============================================================================
589
-
590
- private async executeCustomAction(
591
- step: any,
592
- variables: Map<string, any>,
593
- options: YamlAgentInterpreterOptions
594
- ): Promise<any> {
595
- const functionName = step.action?.function;
596
- if (!functionName) {
597
- throw new Error("Missing 'function' in custom-action");
598
- }
599
-
600
- options.context.log(`Custom action: Looking up function '${functionName}'`);
601
-
602
- const customFunc = agentRegistry.getCustomFunction(functionName);
603
- if (!customFunc) {
604
- throw new Error(
605
- `Custom function '${functionName}' not found in registry. ` +
606
- `Make sure the corresponding .ts file is in the /agents directory.`
607
- );
608
- }
609
-
610
- const args = {
611
- input: options.input,
612
- variables: Object.fromEntries(variables),
613
- action: step.action,
614
- context: options.context,
615
- };
616
-
617
- options.context.log(`Custom action: Executing function '${functionName}'`);
618
-
619
- try {
620
- const result = await customFunc(args);
621
-
622
- if (step.action.result) {
623
- variables.set(step.action.result, result);
624
- }
625
-
626
- return result;
627
- } catch (e) {
628
- const errorMessage = e instanceof Error ? e.message : String(e);
629
- options.context.log(`Custom action execution failed: ${errorMessage}`);
630
- options.context.setError(errorMessage);
631
- throw new Error(`Custom action execution failed: ${errorMessage}`);
632
- }
633
- }
634
-
635
- private async executeBuiltinAgent(
636
- step: any,
637
- variables: Map<string, any>,
638
- options: YamlAgentInterpreterOptions
639
- ): Promise<any> {
640
- const agentName = step.action?.agent;
641
- const agentInput =
642
- this.resolveInputValue(step.action?.input, options.input, variables) || options.input;
643
- const agentProps = step.action?.props || options.props;
644
- const resultVar = step.action?.result || 'builtinResult';
645
-
646
- if (!agentName) {
647
- throw new Error('Missing required builtin-agent input: agent');
648
- }
649
-
650
- options.context.log(`[Builtin Agent] Invoking agent: ${agentName}`);
651
-
652
- try {
653
- const result = await agentRegistry.executeAgent(
654
- agentName,
655
- agentInput,
656
- agentProps,
657
- options.context
658
- );
659
-
660
- variables.set(resultVar, result);
661
- return result;
662
- } catch (error: unknown) {
663
- const message = error instanceof Error ? error.message : String(error);
664
- options.context.log(`[Builtin Agent] Error: ${message}`);
665
- throw new Error(`Builtin agent '${agentName}' execution failed: ${message}`);
666
- }
667
- }
668
-
669
- // ============================================================================
670
- // Helper Methods
671
- // ============================================================================
672
-
673
- private resolveInputValue(
674
- value: any,
675
- input: Record<string, any>,
676
- variables: Map<string, any>
677
- ): any {
678
- if (value === undefined || value === null) return undefined;
679
-
680
- if (typeof value === 'string' && value.startsWith('$')) {
681
- const ref = value.substring(1);
682
- if (ref.startsWith('input.')) {
683
- const inputKey = ref.substring(6);
684
- return this.getNestedValue(input, inputKey);
685
- }
686
- return this.resolveReference(ref, variables);
687
- }
688
-
689
- if (typeof value === 'string' && input[value] !== undefined) {
690
- return input[value];
691
- }
692
-
693
- return value;
694
- }
695
-
696
- private getNestedValue(obj: any, path: string): any {
697
- const parts = path.split('.');
698
- let current = obj;
699
- for (const part of parts) {
700
- if (current == null) return undefined;
701
- current = current[part];
702
- }
703
- return current;
704
- }
705
-
706
- private evaluateValue(expr: string, variables: Map<string, any>): any {
707
- if (expr.startsWith('"') && expr.endsWith('"')) {
708
- if (expr.length - 2 > this.MAX_VARIABLE_SIZE) {
709
- throw new Error('Variable initialization exceeds maximum size');
710
- }
711
- return expr.slice(1, -1);
712
- }
713
-
714
- if (expr.startsWith("'") && expr.endsWith("'")) {
715
- if (expr.length - 2 > this.MAX_VARIABLE_SIZE) {
716
- throw new Error('Variable initialization exceeds maximum size');
717
- }
718
- return expr.slice(1, -1);
719
- }
720
-
721
- if (expr.length > this.MAX_VARIABLE_SIZE) {
722
- throw new Error('Variable initialization exceeds maximum size');
723
- }
724
-
725
- if (expr === 'true') return true;
726
- if (expr === 'false') return false;
727
- if (expr === 'null') return null;
728
-
729
- if (expr.startsWith('$')) {
730
- return this.resolveReference(expr.substring(1), variables);
731
- }
732
-
733
- if (/^-?\d+$/.test(expr)) return parseInt(expr, 10);
734
- if (/^-?\d+\.\d+$/.test(expr)) return parseFloat(expr);
735
-
736
- throw new Error(`Unsupported value expression: ${expr}`);
737
- }
738
-
739
- private validateVariable(variable: any): void {
740
- if (!variable.name || !variable.type) {
741
- throw new Error('Invalid variable declaration: missing name or type');
742
- }
743
-
744
- if (!['string', 'number', 'boolean', 'object'].includes(variable.type)) {
745
- throw new Error(`Unsupported variable type: ${variable.type}`);
746
- }
747
- }
748
-
749
- private resolveReference(reference: string, variables: Map<string, any>): any {
750
- const [varName, ...pathSegments] = reference.split('.');
751
- let value = variables.get(varName);
752
- if (value === undefined) {
753
- throw new Error(`Undefined variable referenced: ${varName}`);
754
- }
755
-
756
- for (const segment of pathSegments) {
757
- if (value == null || typeof value !== 'object') {
758
- throw new Error(
759
- `Cannot resolve path '${reference}': segment '${segment}' is invalid`
760
- );
761
- }
762
- value = value[segment];
763
- }
764
-
765
- return value;
766
- }
767
- }
768
-
769
- // Singleton instance
770
- export const declarativeInterpreter = new DeclarativeAgentInterpreter();
771
-
772
- export default DeclarativeAgentInterpreter;