beddel 0.1.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 (236) hide show
  1. package/README.md +297 -0
  2. package/dist/agents/agentRegistry.d.ts +68 -0
  3. package/dist/agents/agentRegistry.d.ts.map +1 -0
  4. package/dist/agents/agentRegistry.js +222 -0
  5. package/dist/agents/agentRegistry.js.map +1 -0
  6. package/dist/agents/formatter-agent.d.ts +10 -0
  7. package/dist/agents/formatter-agent.d.ts.map +1 -0
  8. package/dist/agents/formatter-agent.js +49 -0
  9. package/dist/agents/formatter-agent.js.map +1 -0
  10. package/dist/agents/genkit-agent.d.ts +12 -0
  11. package/dist/agents/genkit-agent.d.ts.map +1 -0
  12. package/dist/agents/genkit-agent.js +119 -0
  13. package/dist/agents/genkit-agent.js.map +1 -0
  14. package/dist/agents/i18n-messages.d.ts +17 -0
  15. package/dist/agents/i18n-messages.d.ts.map +1 -0
  16. package/dist/agents/i18n-messages.js +92 -0
  17. package/dist/agents/i18n-messages.js.map +1 -0
  18. package/dist/agents/index.d.ts +10 -0
  19. package/dist/agents/index.d.ts.map +1 -0
  20. package/dist/agents/index.js +26 -0
  21. package/dist/agents/index.js.map +1 -0
  22. package/dist/agents/pipeline.d.ts +15 -0
  23. package/dist/agents/pipeline.d.ts.map +1 -0
  24. package/dist/agents/pipeline.js +45 -0
  25. package/dist/agents/pipeline.js.map +1 -0
  26. package/dist/agents/schema-factory.d.ts +40 -0
  27. package/dist/agents/schema-factory.d.ts.map +1 -0
  28. package/dist/agents/schema-factory.js +121 -0
  29. package/dist/agents/schema-factory.js.map +1 -0
  30. package/dist/agents/translation-validators.d.ts +26 -0
  31. package/dist/agents/translation-validators.d.ts.map +1 -0
  32. package/dist/agents/translation-validators.js +77 -0
  33. package/dist/agents/translation-validators.js.map +1 -0
  34. package/dist/agents/translator-agents.d.ts +184 -0
  35. package/dist/agents/translator-agents.d.ts.map +1 -0
  36. package/dist/agents/translator-agents.js +613 -0
  37. package/dist/agents/translator-agents.js.map +1 -0
  38. package/dist/agents/types/translation.types.d.ts +100 -0
  39. package/dist/agents/types/translation.types.d.ts.map +1 -0
  40. package/dist/agents/types/translation.types.js +3 -0
  41. package/dist/agents/types/translation.types.js.map +1 -0
  42. package/dist/agents/validator-agent.d.ts +42 -0
  43. package/dist/agents/validator-agent.d.ts.map +1 -0
  44. package/dist/agents/validator-agent.js +122 -0
  45. package/dist/agents/validator-agent.js.map +1 -0
  46. package/dist/audit/auditTrail.d.ts +55 -0
  47. package/dist/audit/auditTrail.d.ts.map +1 -0
  48. package/dist/audit/auditTrail.js +93 -0
  49. package/dist/audit/auditTrail.js.map +1 -0
  50. package/dist/compliance/gdprEngine.d.ts +44 -0
  51. package/dist/compliance/gdprEngine.d.ts.map +1 -0
  52. package/dist/compliance/gdprEngine.js +178 -0
  53. package/dist/compliance/gdprEngine.js.map +1 -0
  54. package/dist/compliance/lgpdEngine.d.ts +51 -0
  55. package/dist/compliance/lgpdEngine.d.ts.map +1 -0
  56. package/dist/compliance/lgpdEngine.js +221 -0
  57. package/dist/compliance/lgpdEngine.js.map +1 -0
  58. package/dist/config.d.ts +78 -0
  59. package/dist/config.d.ts.map +1 -0
  60. package/dist/config.js +77 -0
  61. package/dist/config.js.map +1 -0
  62. package/dist/errors.d.ts +17 -0
  63. package/dist/errors.d.ts.map +1 -0
  64. package/dist/errors.js +40 -0
  65. package/dist/errors.js.map +1 -0
  66. package/dist/firebase/tenantManager.d.ts +84 -0
  67. package/dist/firebase/tenantManager.d.ts.map +1 -0
  68. package/dist/firebase/tenantManager.js +378 -0
  69. package/dist/firebase/tenantManager.js.map +1 -0
  70. package/dist/index.d.ts +36 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +118 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/integration/secure-yaml-runtime.d.ts +68 -0
  75. package/dist/integration/secure-yaml-runtime.d.ts.map +1 -0
  76. package/dist/integration/secure-yaml-runtime.js +245 -0
  77. package/dist/integration/secure-yaml-runtime.js.map +1 -0
  78. package/dist/parser/secure-yaml-parser.d.ts +62 -0
  79. package/dist/parser/secure-yaml-parser.d.ts.map +1 -0
  80. package/dist/parser/secure-yaml-parser.js +234 -0
  81. package/dist/parser/secure-yaml-parser.js.map +1 -0
  82. package/dist/performance/autoscaling.d.ts +100 -0
  83. package/dist/performance/autoscaling.d.ts.map +1 -0
  84. package/dist/performance/autoscaling.js +339 -0
  85. package/dist/performance/autoscaling.js.map +1 -0
  86. package/dist/performance/benchmark.d.ts +104 -0
  87. package/dist/performance/benchmark.d.ts.map +1 -0
  88. package/dist/performance/benchmark.js +514 -0
  89. package/dist/performance/benchmark.js.map +1 -0
  90. package/dist/performance/index.d.ts +14 -0
  91. package/dist/performance/index.d.ts.map +1 -0
  92. package/dist/performance/index.js +35 -0
  93. package/dist/performance/index.js.map +1 -0
  94. package/dist/performance/monitor.d.ts +126 -0
  95. package/dist/performance/monitor.d.ts.map +1 -0
  96. package/dist/performance/monitor.js +324 -0
  97. package/dist/performance/monitor.js.map +1 -0
  98. package/dist/performance/streaming.d.ts +82 -0
  99. package/dist/performance/streaming.d.ts.map +1 -0
  100. package/dist/performance/streaming.js +287 -0
  101. package/dist/performance/streaming.js.map +1 -0
  102. package/dist/runtime/audit.d.ts +240 -0
  103. package/dist/runtime/audit.d.ts.map +1 -0
  104. package/dist/runtime/audit.js +641 -0
  105. package/dist/runtime/audit.js.map +1 -0
  106. package/dist/runtime/declarativeAgentRuntime.d.ts +123 -0
  107. package/dist/runtime/declarativeAgentRuntime.d.ts.map +1 -0
  108. package/dist/runtime/declarativeAgentRuntime.js +576 -0
  109. package/dist/runtime/declarativeAgentRuntime.js.map +1 -0
  110. package/dist/runtime/isolatedRuntime.d.ts +119 -0
  111. package/dist/runtime/isolatedRuntime.d.ts.map +1 -0
  112. package/dist/runtime/isolatedRuntime.js +425 -0
  113. package/dist/runtime/isolatedRuntime.js.map +1 -0
  114. package/dist/runtime/schemaCompiler.d.ts +35 -0
  115. package/dist/runtime/schemaCompiler.d.ts.map +1 -0
  116. package/dist/runtime/schemaCompiler.js +151 -0
  117. package/dist/runtime/schemaCompiler.js.map +1 -0
  118. package/dist/runtime/simpleRuntime.d.ts +57 -0
  119. package/dist/runtime/simpleRuntime.d.ts.map +1 -0
  120. package/dist/runtime/simpleRuntime.js +187 -0
  121. package/dist/runtime/simpleRuntime.js.map +1 -0
  122. package/dist/security/dashboard.d.ts +89 -0
  123. package/dist/security/dashboard.d.ts.map +1 -0
  124. package/dist/security/dashboard.js +300 -0
  125. package/dist/security/dashboard.js.map +1 -0
  126. package/dist/security/hardening.d.ts +130 -0
  127. package/dist/security/hardening.d.ts.map +1 -0
  128. package/dist/security/hardening.js +414 -0
  129. package/dist/security/hardening.js.map +1 -0
  130. package/dist/security/index.d.ts +128 -0
  131. package/dist/security/index.d.ts.map +1 -0
  132. package/dist/security/index.js +353 -0
  133. package/dist/security/index.js.map +1 -0
  134. package/dist/security/monitor.d.ts +88 -0
  135. package/dist/security/monitor.d.ts.map +1 -0
  136. package/dist/security/monitor.js +356 -0
  137. package/dist/security/monitor.js.map +1 -0
  138. package/dist/security/scanner.d.ts +104 -0
  139. package/dist/security/scanner.d.ts.map +1 -0
  140. package/dist/security/scanner.js +298 -0
  141. package/dist/security/scanner.js.map +1 -0
  142. package/dist/security/score.d.ts +150 -0
  143. package/dist/security/score.d.ts.map +1 -0
  144. package/dist/security/score.js +983 -0
  145. package/dist/security/score.js.map +1 -0
  146. package/dist/security/test-security.d.ts +22 -0
  147. package/dist/security/test-security.d.ts.map +1 -0
  148. package/dist/security/test-security.js +154 -0
  149. package/dist/security/test-security.js.map +1 -0
  150. package/dist/security/threatDetector.d.ts +39 -0
  151. package/dist/security/threatDetector.d.ts.map +1 -0
  152. package/dist/security/threatDetector.js +354 -0
  153. package/dist/security/threatDetector.js.map +1 -0
  154. package/dist/security/validation.d.ts +69 -0
  155. package/dist/security/validation.d.ts.map +1 -0
  156. package/dist/security/validation.js +286 -0
  157. package/dist/security/validation.js.map +1 -0
  158. package/dist/server/api/clientsRoute.d.ts +9 -0
  159. package/dist/server/api/clientsRoute.d.ts.map +1 -0
  160. package/dist/server/api/clientsRoute.js +71 -0
  161. package/dist/server/api/clientsRoute.js.map +1 -0
  162. package/dist/server/api/endpointsRoute.d.ts +8 -0
  163. package/dist/server/api/endpointsRoute.d.ts.map +1 -0
  164. package/dist/server/api/endpointsRoute.js +76 -0
  165. package/dist/server/api/endpointsRoute.js.map +1 -0
  166. package/dist/server/api/graphql.d.ts +9 -0
  167. package/dist/server/api/graphql.d.ts.map +1 -0
  168. package/dist/server/api/graphql.js +180 -0
  169. package/dist/server/api/graphql.js.map +1 -0
  170. package/dist/server/errors.d.ts +19 -0
  171. package/dist/server/errors.d.ts.map +1 -0
  172. package/dist/server/errors.js +42 -0
  173. package/dist/server/errors.js.map +1 -0
  174. package/dist/server/index.d.ts +7 -0
  175. package/dist/server/index.d.ts.map +1 -0
  176. package/dist/server/index.js +24 -0
  177. package/dist/server/index.js.map +1 -0
  178. package/dist/server/kvStore.d.ts +27 -0
  179. package/dist/server/kvStore.d.ts.map +1 -0
  180. package/dist/server/kvStore.js +128 -0
  181. package/dist/server/kvStore.js.map +1 -0
  182. package/dist/server/runtimeSecurity.d.ts +28 -0
  183. package/dist/server/runtimeSecurity.d.ts.map +1 -0
  184. package/dist/server/runtimeSecurity.js +85 -0
  185. package/dist/server/runtimeSecurity.js.map +1 -0
  186. package/dist/server/types.d.ts +53 -0
  187. package/dist/server/types.d.ts.map +1 -0
  188. package/dist/server/types.js +8 -0
  189. package/dist/server/types.js.map +1 -0
  190. package/dist/types/executionContext.d.ts +16 -0
  191. package/dist/types/executionContext.d.ts.map +1 -0
  192. package/dist/types/executionContext.js +3 -0
  193. package/dist/types/executionContext.js.map +1 -0
  194. package/package.json +77 -0
  195. package/src/agents/agentRegistry.ts +272 -0
  196. package/src/agents/image-agent.yaml +86 -0
  197. package/src/agents/joker-agent.yaml +47 -0
  198. package/src/agents/translator-agent.yaml +80 -0
  199. package/src/audit/auditTrail.ts +134 -0
  200. package/src/compliance/gdprEngine.ts +209 -0
  201. package/src/compliance/lgpdEngine.ts +268 -0
  202. package/src/config.ts +179 -0
  203. package/src/errors.ts +35 -0
  204. package/src/firebase/tenantManager.ts +443 -0
  205. package/src/index.ts +125 -0
  206. package/src/integration/secure-yaml-runtime.ts +341 -0
  207. package/src/parser/secure-yaml-parser.ts +273 -0
  208. package/src/performance/autoscaling.ts +495 -0
  209. package/src/performance/benchmark.ts +644 -0
  210. package/src/performance/index.ts +34 -0
  211. package/src/performance/monitor.ts +469 -0
  212. package/src/performance/streaming.ts +317 -0
  213. package/src/runtime/audit.ts +907 -0
  214. package/src/runtime/declarativeAgentRuntime.ts +836 -0
  215. package/src/runtime/isolatedRuntime.ts +572 -0
  216. package/src/runtime/schemaCompiler.ts +228 -0
  217. package/src/runtime/simpleRuntime.ts +201 -0
  218. package/src/security/dashboard.ts +462 -0
  219. package/src/security/hardening.ts +560 -0
  220. package/src/security/index.ts +439 -0
  221. package/src/security/monitor.ts +490 -0
  222. package/src/security/scanner.ts +368 -0
  223. package/src/security/score.ts +1138 -0
  224. package/src/security/threatDetector.ts +481 -0
  225. package/src/security/validation.ts +365 -0
  226. package/src/server/api/clientsRoute.ts +92 -0
  227. package/src/server/api/endpointsRoute.ts +97 -0
  228. package/src/server/api/graphql.ts +249 -0
  229. package/src/server/errors.ts +38 -0
  230. package/src/server/index.ts +6 -0
  231. package/src/server/kvStore.ts +152 -0
  232. package/src/server/runtimeSecurity.ts +102 -0
  233. package/src/server/types.ts +60 -0
  234. package/src/types/executionContext.ts +16 -0
  235. package/tools/seed.ts +365 -0
  236. package/tools/test-endpoints.ts +174 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAEjG,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Shared server-side types for the Opal Support App runtime.
4
+ * These live inside the Beddel package so both the Next.js app and
5
+ * the npm distribution reference exactly the same contracts.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Project-agnostic execution context contract for declarative runtimes.
3
+ * Mirrors the shape used inside the Opal Support App but stays self-contained
4
+ * so the npm package does not depend on repository-local files.
5
+ */
6
+ export interface ExecutionContext {
7
+ logs: string[];
8
+ status: "running" | "success" | "error";
9
+ output: unknown;
10
+ error?: string;
11
+ log: (message: string) => void;
12
+ setOutput: (output: unknown) => void;
13
+ setError: (error: string) => void;
14
+ }
15
+ export default ExecutionContext;
16
+ //# sourceMappingURL=executionContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionContext.d.ts","sourceRoot":"","sources":["../../src/types/executionContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=executionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionContext.js","sourceRoot":"","sources":["../../src/types/executionContext.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "beddel",
3
+ "version": "0.1.0",
4
+ "description": "Beddel - A secure YAML parser and OpenAPI endpoint manager for Node.js applications",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src",
10
+ "tools"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./server": {
18
+ "types": "./dist/server/index.d.ts",
19
+ "default": "./dist/server/index.js"
20
+ },
21
+ "./server/*": {
22
+ "types": "./dist/server/*.d.ts",
23
+ "default": "./dist/server/*.js"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.build.json",
28
+ "dev": "tsc -p tsconfig.build.json --watch",
29
+ "test": "jest",
30
+ "test:watch": "jest --watch",
31
+ "test:coverage": "jest --coverage",
32
+ "lint": "eslint src --ext .ts",
33
+ "lint:fix": "eslint src --ext .ts --fix"
34
+ },
35
+ "keywords": [
36
+ "yaml",
37
+ "parser",
38
+ "openapi",
39
+ "endpoint",
40
+ "manager",
41
+ "secure",
42
+ "nodejs"
43
+ ],
44
+ "author": "Beddel Contributors",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/botanarede/beddel-alpha.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/botanarede/beddel-alpha/issues"
52
+ },
53
+ "homepage": "https://github.com/botanarede/beddel-alpha#readme",
54
+ "dependencies": {
55
+ "@ai-sdk/google": "^2.0.23",
56
+ "@upstash/redis": "^1.34.3",
57
+ "ai": "^5.0.70",
58
+ "firebase-admin": "12.7.0",
59
+ "isolated-vm": "5.0.1",
60
+ "js-yaml": "^4.1.0",
61
+ "zod": "^4.1.12"
62
+ },
63
+ "devDependencies": {
64
+ "@types/js-yaml": "^4.0.9",
65
+ "@types/node": "^22.0.0",
66
+ "@types/jest": "^29.5.12",
67
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
68
+ "@typescript-eslint/parser": "^8.0.0",
69
+ "eslint": "^9.0.0",
70
+ "jest": "^29.0.0",
71
+ "ts-jest": "^29.0.0",
72
+ "typescript": "^5.0.0"
73
+ },
74
+ "engines": {
75
+ "node": ">=18.0.0"
76
+ }
77
+ }
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Agent Registry Service
3
+ * Manages registration and execution of declarative YAML agents
4
+ */
5
+
6
+ import { existsSync, readFileSync } from "fs";
7
+ import { join } from "path";
8
+ import { declarativeInterpreter } from "../runtime/declarativeAgentRuntime";
9
+ import { ExecutionContext } from "../types/executionContext";
10
+
11
+ export interface AgentRegistration {
12
+ id: string;
13
+ name: string;
14
+ description: string;
15
+ protocol: string;
16
+ route: string;
17
+ requiredProps: string[];
18
+ yamlContent: string;
19
+ }
20
+
21
+ /**
22
+ * Agent Registry - Manages declarative agent registration and execution
23
+ */
24
+ export class AgentRegistry {
25
+ private readonly agents: Map<string, AgentRegistration> = new Map();
26
+
27
+ constructor() {
28
+ // Register built-in agents on initialization
29
+ this.registerBuiltinAgents();
30
+ }
31
+
32
+ /**
33
+ * Register an agent
34
+ */
35
+ public registerAgent(agent: AgentRegistration): void {
36
+ // Validate agent
37
+ this.validateAgent(agent);
38
+
39
+ // Register the agent
40
+ this.agents.set(agent.name, agent);
41
+ console.log(`Agent registered: ${agent.name} (${agent.protocol})`);
42
+ }
43
+
44
+ /**
45
+ * Execute registered agent
46
+ */
47
+ public async executeAgent(
48
+ agentName: string,
49
+ input: Record<string, any>,
50
+ props: Record<string, string>,
51
+ context: ExecutionContext
52
+ ): Promise<any> {
53
+ // Find agent
54
+ const agent = this.agents.get(agentName);
55
+ if (!agent) {
56
+ throw new Error(`Agent not found: ${agentName}`);
57
+ }
58
+
59
+ // Execute using declarative interpreter
60
+ const result = await declarativeInterpreter.interpret({
61
+ yamlContent: agent.yamlContent,
62
+ input,
63
+ props,
64
+ context,
65
+ });
66
+
67
+ return result;
68
+ }
69
+
70
+ /**
71
+ * Get registered agent
72
+ */
73
+ public getAgent(agentName: string): AgentRegistration | undefined {
74
+ return this.agents.get(agentName);
75
+ }
76
+
77
+ /**
78
+ * Get all registered agents
79
+ */
80
+ public getAllAgents(): AgentRegistration[] {
81
+ return Array.from(this.agents.values());
82
+ }
83
+
84
+ /**
85
+ * Register built-in agents
86
+ */
87
+ private registerBuiltinAgents(): void {
88
+ try {
89
+ // Register Joker Agent
90
+ this.registerJokerAgent();
91
+ // Register Translator Agent
92
+ this.registerTranslatorAgent();
93
+ // Register Image Generator Agent
94
+ this.registerImageAgent();
95
+ } catch (error) {
96
+ console.error("Failed to register built-in agents:", error);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Register Joker Agent
102
+ */
103
+ private registerJokerAgent(): void {
104
+ try {
105
+ // Get the Joker Agent YAML content
106
+ const jokerYamlPath = this.resolveAgentPath("joker-agent.yaml");
107
+ const yamlContent = readFileSync(jokerYamlPath, "utf-8");
108
+
109
+ // Parse YAML to extract metadata
110
+ const agent = this.parseAgentYaml(yamlContent);
111
+
112
+ this.registerAgent({
113
+ id: agent.agent.id,
114
+ name: "joker.execute",
115
+ description: agent.metadata.description,
116
+ protocol: agent.agent.protocol,
117
+ route: agent.metadata.route || "/agents/joker",
118
+ requiredProps: ["gemini_api_key"],
119
+ yamlContent,
120
+ });
121
+ } catch (error) {
122
+ console.error("Failed to register Joker Agent:", error);
123
+ throw error;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Register Translator Agent
129
+ */
130
+ private registerTranslatorAgent(): void {
131
+ try {
132
+ const translatorYamlPath = this.resolveAgentPath("translator-agent.yaml");
133
+ const yamlContent = readFileSync(translatorYamlPath, "utf-8");
134
+ const agent = this.parseAgentYaml(yamlContent);
135
+
136
+ this.registerAgent({
137
+ id: agent.agent.id,
138
+ name: "translator.execute",
139
+ description: agent.metadata.description,
140
+ protocol: agent.agent.protocol,
141
+ route: agent.metadata.route || "/agents/translator",
142
+ requiredProps: ["gemini_api_key"],
143
+ yamlContent,
144
+ });
145
+ } catch (error) {
146
+ console.error("Failed to register Translator Agent:", error);
147
+ throw error;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Register Image Generator Agent
153
+ */
154
+ private registerImageAgent(): void {
155
+ try {
156
+ const imageYamlPath = this.resolveAgentPath("image-agent.yaml");
157
+ const yamlContent = readFileSync(imageYamlPath, "utf-8");
158
+ const agent = this.parseAgentYaml(yamlContent);
159
+
160
+ this.registerAgent({
161
+ id: agent.agent.id,
162
+ name: "image.generate",
163
+ description: agent.metadata.description,
164
+ protocol: agent.agent.protocol,
165
+ route: agent.metadata.route || "/agents/image",
166
+ requiredProps: ["gemini_api_key"],
167
+ yamlContent,
168
+ });
169
+ } catch (error) {
170
+ console.error("Failed to register Image Agent:", error);
171
+ throw error;
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Parse agent YAML content
177
+ */
178
+ private parseAgentYaml(yamlContent: string): any {
179
+ // Simple validation - full parsing will be done by interpreter
180
+ if (!yamlContent.includes("agent:") || !yamlContent.includes("logic:")) {
181
+ throw new Error("Invalid agent YAML: missing required sections");
182
+ }
183
+
184
+ // Basic YAML parsing for metadata extraction
185
+ const lines = yamlContent.split("\n");
186
+ const metadata: any = {
187
+ agent: { id: "", protocol: "" },
188
+ metadata: { description: "", route: "" },
189
+ schema: { required: [] },
190
+ };
191
+
192
+ for (let i = 0; i < lines.length; i++) {
193
+ const line = lines[i].trim();
194
+
195
+ if (line.startsWith("id:") && metadata.agent.id === "") {
196
+ metadata.agent.id = line.split(":")[1].trim();
197
+ }
198
+
199
+ if (line.startsWith("protocol:") && metadata.agent.protocol === "") {
200
+ metadata.agent.protocol = line.split(":")[1].trim();
201
+ }
202
+
203
+ if (
204
+ line.startsWith("description:") &&
205
+ metadata.metadata.description === ""
206
+ ) {
207
+ metadata.metadata.description = line
208
+ .substring(line.indexOf(":") + 1)
209
+ .trim();
210
+ }
211
+
212
+ if (line.startsWith("route:") && metadata.metadata.route === "") {
213
+ metadata.metadata.route = line.split(":")[1].trim();
214
+ }
215
+
216
+ if (
217
+ line.startsWith("required:") &&
218
+ metadata.schema.required.length === 0
219
+ ) {
220
+ // Parse required array
221
+ const requiredStr = line.substring(line.indexOf(":") + 1).trim();
222
+ metadata.schema.required = JSON.parse(requiredStr);
223
+ }
224
+ }
225
+
226
+ return metadata;
227
+ }
228
+
229
+ /**
230
+ * Validate agent registration
231
+ */
232
+ private validateAgent(agent: AgentRegistration): void {
233
+ if (!agent.id || !agent.name || !agent.protocol) {
234
+ throw new Error("Invalid agent: missing required fields");
235
+ }
236
+
237
+ if (!agent.yamlContent || agent.yamlContent.length === 0) {
238
+ throw new Error("Invalid agent: missing YAML content");
239
+ }
240
+
241
+ if (!agent.protocol.startsWith("beddel-declarative-protocol")) {
242
+ throw new Error(`Unsupported protocol: ${agent.protocol}`);
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Resolve agent asset path when running in bundled runtimes
248
+ */
249
+ private resolveAgentPath(filename: string): string {
250
+ const candidatePaths = [
251
+ join(__dirname, filename),
252
+ join(process.cwd(), "packages", "beddel", "src", "agents", filename),
253
+ ];
254
+
255
+ for (const path of candidatePaths) {
256
+ if (existsSync(path)) {
257
+ return path;
258
+ }
259
+ }
260
+
261
+ throw new Error(
262
+ `Unable to locate agent asset '${filename}' in paths: ${candidatePaths.join(
263
+ ", "
264
+ )}`
265
+ );
266
+ }
267
+ }
268
+
269
+ // Singleton instance
270
+ export const agentRegistry = new AgentRegistry();
271
+
272
+ export default AgentRegistry;
@@ -0,0 +1,86 @@
1
+ # Image Generator Agent - Declarative Genkit workflow
2
+ # Route: /agents/image
3
+ # Method: image.generate
4
+
5
+ agent:
6
+ id: image
7
+ version: 1.0.0
8
+ protocol: beddel-declarative-protocol/v2.0
9
+
10
+ metadata:
11
+ name: "Image Generator Agent"
12
+ description: "Gera imagens usando Gemini Flash com estilos curados"
13
+ category: "creative"
14
+ route: "/agents/image"
15
+
16
+ schema:
17
+ input:
18
+ type: "object"
19
+ properties:
20
+ descricao:
21
+ type: "string"
22
+ minLength: 5
23
+ maxLength: 500
24
+ description: "Descrição textual detalhada da cena"
25
+ estilo:
26
+ type: "string"
27
+ enum: ["watercolor", "neon", "sketch"]
28
+ description: "Estilo visual desejado"
29
+ resolucao:
30
+ type: "string"
31
+ pattern: "^[0-9]{3,4}x[0-9]{3,4}$"
32
+ description: "Resolução no formato LARGURAxALTURA (ex: 1024x1024)"
33
+ required: ["descricao", "estilo", "resolucao"]
34
+
35
+ output:
36
+ type: "object"
37
+ properties:
38
+ image_url:
39
+ type: "string"
40
+ image_base64:
41
+ type: "string"
42
+ media_type:
43
+ type: "string"
44
+ prompt_utilizado:
45
+ type: "string"
46
+ metadados:
47
+ type: "object"
48
+ properties:
49
+ modelo_utilizado:
50
+ type: "string"
51
+ tempo_processamento:
52
+ type: "number"
53
+ estilo:
54
+ type: "string"
55
+ resolucao:
56
+ type: "string"
57
+ required: ["modelo_utilizado", "tempo_processamento", "estilo", "resolucao"]
58
+ required: ["image_url", "prompt_utilizado", "metadados"]
59
+
60
+ logic:
61
+ workflow:
62
+ - name: "generate-image"
63
+ type: "genkit-image"
64
+ action:
65
+ type: "image"
66
+ result: "imageResult"
67
+ promptTemplate: "Crie uma imagem em estilo {{estilo}} com foco em: {{descricao}}"
68
+
69
+ - name: "deliver-image"
70
+ type: "output-generator"
71
+ action:
72
+ type: "generate"
73
+ output:
74
+ image_url: "$imageResult.image_url"
75
+ image_base64: "$imageResult.image_base64"
76
+ media_type: "$imageResult.media_type"
77
+ prompt_utilizado: "$imageResult.prompt_utilizado"
78
+ metadados: "$imageResult.metadados"
79
+
80
+ output:
81
+ schema:
82
+ image_url: "$imageResult.image_url"
83
+ image_base64: "$imageResult.image_base64"
84
+ media_type: "$imageResult.media_type"
85
+ prompt_utilizado: "$imageResult.prompt_utilizado"
86
+ metadados: "$imageResult.metadados"
@@ -0,0 +1,47 @@
1
+ # Joker Agent - Simple Response Agent for Beddel Runtime
2
+ # Route: /agents/joker
3
+ # Method: joker.execute
4
+
5
+ agent:
6
+ id: joker
7
+ version: 1.0.0
8
+ protocol: beddel-declarative-protocol/v2.0
9
+
10
+ metadata:
11
+ name: "Joker Agent"
12
+ description: "Conta piadas usando Gemini Flash"
13
+ category: "utility"
14
+ route: "/agents/joker"
15
+
16
+ schema:
17
+ input:
18
+ type: "object"
19
+ properties: {}
20
+ required: []
21
+
22
+ output:
23
+ type: "object"
24
+ properties:
25
+ response:
26
+ type: "string"
27
+ required: ["response"]
28
+
29
+ logic:
30
+ workflow:
31
+ - name: "generate-joke"
32
+ type: "genkit-joke"
33
+ action:
34
+ type: "joke"
35
+ prompt: "Conte uma piada curta e original que funcione para qualquer público."
36
+ result: "jokerResult"
37
+
38
+ - name: "deliver-response"
39
+ type: "output-generator"
40
+ action:
41
+ type: "generate"
42
+ output:
43
+ response: "$jokerResult.texto"
44
+
45
+ output:
46
+ schema:
47
+ response: "$jokerResult.texto"
@@ -0,0 +1,80 @@
1
+ # Translator Agent - Declarative Genkit-powered translation workflow
2
+ # Route: /agents/translator
3
+ # Method: translator.execute
4
+
5
+ agent:
6
+ id: translator
7
+ version: 1.0.0
8
+ protocol: beddel-declarative-protocol/v2.0
9
+
10
+ metadata:
11
+ name: "Translator Agent"
12
+ description: "Traduz textos entre idiomas usando Gemini Flash via Genkit"
13
+ category: "public"
14
+ route: "/agents/translator"
15
+
16
+ schema:
17
+ input:
18
+ type: "object"
19
+ properties:
20
+ texto:
21
+ type: "string"
22
+ minLength: 1
23
+ maxLength: 10000
24
+ description: "Texto original a ser traduzido"
25
+ idioma_origem:
26
+ type: "string"
27
+ pattern: "^[a-z]{2}$"
28
+ description: "Idioma de origem (ISO-639-1, ex: pt, en)"
29
+ idioma_destino:
30
+ type: "string"
31
+ pattern: "^[a-z]{2}$"
32
+ description: "Idioma de destino (ISO-639-1, ex: en, es)"
33
+ required: ["texto", "idioma_origem", "idioma_destino"]
34
+
35
+ output:
36
+ type: "object"
37
+ properties:
38
+ texto_traduzido:
39
+ type: "string"
40
+ metadados:
41
+ type: "object"
42
+ properties:
43
+ modelo_utilizado:
44
+ type: "string"
45
+ tempo_processamento:
46
+ type: "number"
47
+ confianca:
48
+ type: "number"
49
+ idiomas_suportados:
50
+ type: "array"
51
+ items:
52
+ type: "string"
53
+ idiomas_solicitados:
54
+ type: "object"
55
+ properties:
56
+ origem:
57
+ type: "string"
58
+ destino:
59
+ type: "string"
60
+ required: ["origem", "destino"]
61
+ prompt_utilizado:
62
+ type: "string"
63
+ required:
64
+ [
65
+ "modelo_utilizado",
66
+ "tempo_processamento",
67
+ "confianca",
68
+ "idiomas_suportados",
69
+ "idiomas_solicitados",
70
+ "prompt_utilizado",
71
+ ]
72
+ required: ["texto_traduzido", "metadados"]
73
+
74
+ logic:
75
+ workflow:
76
+ - name: "translate"
77
+ type: "genkit-translation"
78
+ action:
79
+ type: "translate"
80
+ result: "translationResult"