aimeat 1.2.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 (1366) hide show
  1. package/dist/.env.example +300 -0
  2. package/dist/bin/aimeat.d.ts +3 -0
  3. package/dist/bin/aimeat.d.ts.map +1 -0
  4. package/dist/bin/aimeat.js +22 -0
  5. package/dist/bin/aimeat.js.map +1 -0
  6. package/dist/locales/en.json +4566 -0
  7. package/dist/locales/fi.json +4566 -0
  8. package/dist/public/BingSiteAuth.xml +4 -0
  9. package/dist/public/agent-consent.html +521 -0
  10. package/dist/public/aimeat-developers.html +679 -0
  11. package/dist/public/assets/mcp_1_add_custom_connector.png +0 -0
  12. package/dist/public/assets/mcp_2_connect_disconnect_connector.png +0 -0
  13. package/dist/public/components/Alert.js +18 -0
  14. package/dist/public/components/Card.js +19 -0
  15. package/dist/public/components/CopyButton.js +24 -0
  16. package/dist/public/components/FormField.js +16 -0
  17. package/dist/public/components/Modal.js +121 -0
  18. package/dist/public/components/Spinner.js +11 -0
  19. package/dist/public/components/Toast.js +26 -0
  20. package/dist/public/components/index.js +8 -0
  21. package/dist/public/components/useViewCSS.js +12 -0
  22. package/dist/public/cortex-bundled/aimeat-canvas.js +1408 -0
  23. package/dist/public/cortex-bundled/aimeat-canvas.yaml +241 -0
  24. package/dist/public/cortex-bundled/aimeat-charts.js +455 -0
  25. package/dist/public/cortex-bundled/aimeat-charts.yaml +178 -0
  26. package/dist/public/cortex-bundled/aimeat-ui-dialogs.js +667 -0
  27. package/dist/public/cortex-bundled/aimeat-ui-dialogs.yaml +66 -0
  28. package/dist/public/cortex-bundled/aimeat-ui-forms.js +1106 -0
  29. package/dist/public/cortex-bundled/aimeat-ui-forms.yaml +90 -0
  30. package/dist/public/cortex-bundled/aimeat-ui-layout.js +436 -0
  31. package/dist/public/cortex-bundled/aimeat-ui-layout.yaml +87 -0
  32. package/dist/public/cortex-bundled/aimeat-ui-nav.js +722 -0
  33. package/dist/public/cortex-bundled/aimeat-ui-nav.yaml +73 -0
  34. package/dist/public/cortex-bundled/aimeat-ui-viewers.js +602 -0
  35. package/dist/public/cortex-bundled/aimeat-ui-viewers.yaml +73 -0
  36. package/dist/public/css/components/tags.css +67 -0
  37. package/dist/public/css/theme.css +716 -0
  38. package/dist/public/css/views/admin.css +576 -0
  39. package/dist/public/css/views/aimeat-os.css +153 -0
  40. package/dist/public/css/views/calibrator.css +480 -0
  41. package/dist/public/css/views/foundry.css +1334 -0
  42. package/dist/public/css/views/help.css +136 -0
  43. package/dist/public/css/views/hobbies.css +73 -0
  44. package/dist/public/css/views/marketplace.css +134 -0
  45. package/dist/public/css/views/openclaw.css +33 -0
  46. package/dist/public/css/views/portal-classic.css +484 -0
  47. package/dist/public/css/views/portal-dev.css +139 -0
  48. package/dist/public/css/views/portal.css +365 -0
  49. package/dist/public/css/views/portfolio.css +322 -0
  50. package/dist/public/css/views/profile.css +1799 -0
  51. package/dist/public/echat.html +442 -0
  52. package/dist/public/img/genesis-001-badge.png +0 -0
  53. package/dist/public/img/platforms/chatgpt.png +0 -0
  54. package/dist/public/img/platforms/claude.png +0 -0
  55. package/dist/public/img/platforms/copilot.png +0 -0
  56. package/dist/public/img/platforms/deepseek.png +0 -0
  57. package/dist/public/img/platforms/gemini.png +0 -0
  58. package/dist/public/img/platforms/grok.png +0 -0
  59. package/dist/public/img/platforms/lmstudio.png +0 -0
  60. package/dist/public/img/platforms/m365copilot.png +0 -0
  61. package/dist/public/img/platforms/openclaw.png +0 -0
  62. package/dist/public/img/platforms/other.png +0 -0
  63. package/dist/public/js/api.js +123 -0
  64. package/dist/public/js/components/auth-image.js +59 -0
  65. package/dist/public/js/components/tag-cloud.js +31 -0
  66. package/dist/public/js/components/tag-editor.js +46 -0
  67. package/dist/public/js/hooks.js +63 -0
  68. package/dist/public/js/i18n.js +76 -0
  69. package/dist/public/js/services/admin.js +239 -0
  70. package/dist/public/js/services/agents.js +57 -0
  71. package/dist/public/js/services/apps.js +35 -0
  72. package/dist/public/js/services/auth.js +40 -0
  73. package/dist/public/js/services/boards.js +79 -0
  74. package/dist/public/js/services/calibrator.js +97 -0
  75. package/dist/public/js/services/catalogue.js +39 -0
  76. package/dist/public/js/services/consent.js +57 -0
  77. package/dist/public/js/services/cortex.js +95 -0
  78. package/dist/public/js/services/extensions.js +61 -0
  79. package/dist/public/js/services/federation.js +11 -0
  80. package/dist/public/js/services/foundry-context-bundle.js +128 -0
  81. package/dist/public/js/services/foundry-contract.js +117 -0
  82. package/dist/public/js/services/foundry-packaging.js +762 -0
  83. package/dist/public/js/services/foundry-probe-reconcile.js +52 -0
  84. package/dist/public/js/services/foundry-prompts-base.js +1886 -0
  85. package/dist/public/js/services/foundry-prompts-build.js +2187 -0
  86. package/dist/public/js/services/foundry-prompts-cortex-app.js +154 -0
  87. package/dist/public/js/services/foundry-prompts-cortex-data.js +241 -0
  88. package/dist/public/js/services/foundry-prompts-cortex-feature.js +281 -0
  89. package/dist/public/js/services/foundry-prompts-fix.js +408 -0
  90. package/dist/public/js/services/foundry-prompts-test.js +520 -0
  91. package/dist/public/js/services/foundry-prompts.js +31 -0
  92. package/dist/public/js/services/foundry-smoke.js +65 -0
  93. package/dist/public/js/services/foundry-testing.js +64 -0
  94. package/dist/public/js/services/foundry-validate.js +1082 -0
  95. package/dist/public/js/services/foundry.js +1194 -0
  96. package/dist/public/js/services/generator-context-bundle.js +134 -0
  97. package/dist/public/js/services/generator-contract.js +117 -0
  98. package/dist/public/js/services/generator-packaging.js +762 -0
  99. package/dist/public/js/services/generator-probe-reconcile.js +52 -0
  100. package/dist/public/js/services/generator-prompts-base.js +1890 -0
  101. package/dist/public/js/services/generator-prompts-build.js +1126 -0
  102. package/dist/public/js/services/generator-prompts-cortex-app.js +155 -0
  103. package/dist/public/js/services/generator-prompts-cortex-data.js +199 -0
  104. package/dist/public/js/services/generator-prompts-cortex-feature.js +276 -0
  105. package/dist/public/js/services/generator-prompts-fix.js +316 -0
  106. package/dist/public/js/services/generator-prompts-test.js +402 -0
  107. package/dist/public/js/services/generator-prompts.js +31 -0
  108. package/dist/public/js/services/generator-smoke.js +65 -0
  109. package/dist/public/js/services/generator-spec-tests.js +280 -0
  110. package/dist/public/js/services/generator-spec-validate.js +192 -0
  111. package/dist/public/js/services/generator-specs.js +369 -0
  112. package/dist/public/js/services/generator-testing.js +64 -0
  113. package/dist/public/js/services/generator-validate.js +916 -0
  114. package/dist/public/js/services/generator.js +952 -0
  115. package/dist/public/js/services/knowledge.js +120 -0
  116. package/dist/public/js/services/memory.js +112 -0
  117. package/dist/public/js/services/nodes.js +55 -0
  118. package/dist/public/js/services/organisms.js +74 -0
  119. package/dist/public/js/services/packages.js +97 -0
  120. package/dist/public/js/services/security.js +67 -0
  121. package/dist/public/js/services/stats.js +11 -0
  122. package/dist/public/js/services/wallet.js +24 -0
  123. package/dist/public/js/services/work.js +51 -0
  124. package/dist/public/js/utils.js +184 -0
  125. package/dist/public/lib/htm.mjs +4 -0
  126. package/dist/public/lib/live-updates.js +89 -0
  127. package/dist/public/lib/minidenticons.min.js +1 -0
  128. package/dist/public/lib/preact-hooks.mjs +3 -0
  129. package/dist/public/lib/preact.mjs +3 -0
  130. package/dist/public/lib/realtime.js +549 -0
  131. package/dist/public/lib/three.min.js +6 -0
  132. package/dist/public/lib/yaml.mjs +141 -0
  133. package/dist/public/llms-template.txt +1043 -0
  134. package/dist/public/oauth-consent.html +388 -0
  135. package/dist/public/og-image.png +0 -0
  136. package/dist/public/robots.txt +52 -0
  137. package/dist/public/spa.html +533 -0
  138. package/dist/public/sw.js +34 -0
  139. package/dist/public/tmp-paste.txt +223 -0
  140. package/dist/public/views/_template.js +85 -0
  141. package/dist/public/views/admin/actions-tab.js +41 -0
  142. package/dist/public/views/admin/agents-tab.js +84 -0
  143. package/dist/public/views/admin/boards-tab.js +154 -0
  144. package/dist/public/views/admin/chat-instances-tab.js +207 -0
  145. package/dist/public/views/admin/config-tab.js +151 -0
  146. package/dist/public/views/admin/consul-tab.js +77 -0
  147. package/dist/public/views/admin/cors-tab.js +240 -0
  148. package/dist/public/views/admin/cortex-tab.js +171 -0
  149. package/dist/public/views/admin/csm-tab.js +261 -0
  150. package/dist/public/views/admin/directory-tab.js +44 -0
  151. package/dist/public/views/admin/economy-tab.js +80 -0
  152. package/dist/public/views/admin/email-tab.js +460 -0
  153. package/dist/public/views/admin/federation-tab.js +412 -0
  154. package/dist/public/views/admin/generator-debug-tab.js +238 -0
  155. package/dist/public/views/admin/genesis-tab.js +70 -0
  156. package/dist/public/views/admin/ghii-tab.js +101 -0
  157. package/dist/public/views/admin/hooks-tab.js +69 -0
  158. package/dist/public/views/admin/knowledge-tab.js +297 -0
  159. package/dist/public/views/admin/maintenance-tab.js +98 -0
  160. package/dist/public/views/admin/matching-tab.js +44 -0
  161. package/dist/public/views/admin/memory-tab.js +222 -0
  162. package/dist/public/views/admin/msm-tab.js +342 -0
  163. package/dist/public/views/admin/overview-tab.js +90 -0
  164. package/dist/public/views/admin/owners-tab.js +55 -0
  165. package/dist/public/views/admin/packages-tab.js +510 -0
  166. package/dist/public/views/admin/portal-tab.js +211 -0
  167. package/dist/public/views/admin/prompts-tab.js +287 -0
  168. package/dist/public/views/admin/push-tab.js +291 -0
  169. package/dist/public/views/admin/realtime-tab.js +68 -0
  170. package/dist/public/views/admin/scheduler-tab.js +156 -0
  171. package/dist/public/views/admin/services-tab.js +981 -0
  172. package/dist/public/views/admin/shared.js +148 -0
  173. package/dist/public/views/admin/stats-tab.js +187 -0
  174. package/dist/public/views/admin/work-tab.js +45 -0
  175. package/dist/public/views/admin.js +400 -0
  176. package/dist/public/views/aimeat-os.js +259 -0
  177. package/dist/public/views/guides.js +402 -0
  178. package/dist/public/views/help.js +79 -0
  179. package/dist/public/views/hobbies.js +697 -0
  180. package/dist/public/views/marketplace.js +647 -0
  181. package/dist/public/views/openclaw.js +223 -0
  182. package/dist/public/views/portal-classic.js +519 -0
  183. package/dist/public/views/portal-dev.js +816 -0
  184. package/dist/public/views/portal.js +1354 -0
  185. package/dist/public/views/portfolio.js +795 -0
  186. package/dist/public/views/profile/access-tab.js +58 -0
  187. package/dist/public/views/profile/agents-tab.js +689 -0
  188. package/dist/public/views/profile/apps-tab.js +197 -0
  189. package/dist/public/views/profile/boards-tab.js +323 -0
  190. package/dist/public/views/profile/calibrator-batch.js +926 -0
  191. package/dist/public/views/profile/calibrator-chart.js +135 -0
  192. package/dist/public/views/profile/calibrator-llm-editor.js +205 -0
  193. package/dist/public/views/profile/calibrator-tab.js +535 -0
  194. package/dist/public/views/profile/chat-sessions-tab.js +184 -0
  195. package/dist/public/views/profile/data-wallet-tab.js +313 -0
  196. package/dist/public/views/profile/email-tab.js +157 -0
  197. package/dist/public/views/profile/extensions-tab.js +711 -0
  198. package/dist/public/views/profile/federation-tab.js +63 -0
  199. package/dist/public/views/profile/foundry-dashboard/DebugPanel.js +193 -0
  200. package/dist/public/views/profile/foundry-dashboard/DiagnosticsPanel.js +69 -0
  201. package/dist/public/views/profile/foundry-dashboard/EditModePanel.js +141 -0
  202. package/dist/public/views/profile/foundry-dashboard/PackageDialog.js +96 -0
  203. package/dist/public/views/profile/foundry-dashboard/RemovePanel.js +53 -0
  204. package/dist/public/views/profile/foundry-dashboard/use-autopilot-state.js +53 -0
  205. package/dist/public/views/profile/foundry-dashboard/use-autopilot.js +1016 -0
  206. package/dist/public/views/profile/foundry-dashboard/use-dashboard-core.js +154 -0
  207. package/dist/public/views/profile/foundry-dashboard/use-edit-mode.js +294 -0
  208. package/dist/public/views/profile/foundry-dashboard/use-lifecycle.js +101 -0
  209. package/dist/public/views/profile/foundry-dashboard/use-packaging.js +97 -0
  210. package/dist/public/views/profile/foundry-dashboard/use-test-execution.js +275 -0
  211. package/dist/public/views/profile/foundry-dashboard.js +395 -0
  212. package/dist/public/views/profile/foundry-detail.js +1178 -0
  213. package/dist/public/views/profile/foundry-settings.js +377 -0
  214. package/dist/public/views/profile/foundry-tab.js +546 -0
  215. package/dist/public/views/profile/generator-dashboard/DebugPanel.js +193 -0
  216. package/dist/public/views/profile/generator-dashboard/DiagnosticsPanel.js +69 -0
  217. package/dist/public/views/profile/generator-dashboard/EditModePanel.js +141 -0
  218. package/dist/public/views/profile/generator-dashboard/PackageDialog.js +96 -0
  219. package/dist/public/views/profile/generator-dashboard/RemovePanel.js +53 -0
  220. package/dist/public/views/profile/generator-dashboard/use-autopilot-state.js +53 -0
  221. package/dist/public/views/profile/generator-dashboard/use-autopilot.js +136 -0
  222. package/dist/public/views/profile/generator-dashboard/use-dashboard-core.js +143 -0
  223. package/dist/public/views/profile/generator-dashboard/use-edit-mode.js +296 -0
  224. package/dist/public/views/profile/generator-dashboard/use-lifecycle.js +101 -0
  225. package/dist/public/views/profile/generator-dashboard/use-packaging.js +97 -0
  226. package/dist/public/views/profile/generator-dashboard/use-test-execution.js +275 -0
  227. package/dist/public/views/profile/generator-dashboard.js +377 -0
  228. package/dist/public/views/profile/generator-detail.js +1007 -0
  229. package/dist/public/views/profile/generator-settings.js +417 -0
  230. package/dist/public/views/profile/generator-tab.js +544 -0
  231. package/dist/public/views/profile/inline-panels.js +277 -0
  232. package/dist/public/views/profile/knowledge-tab.js +735 -0
  233. package/dist/public/views/profile/landing-page.js +539 -0
  234. package/dist/public/views/profile/mcp-tab.js +140 -0
  235. package/dist/public/views/profile/memory-tab.js +599 -0
  236. package/dist/public/views/profile/node-stats-tab.js +132 -0
  237. package/dist/public/views/profile/nodes-tab.js +195 -0
  238. package/dist/public/views/profile/notifications-tab.js +274 -0
  239. package/dist/public/views/profile/organisms-tab.js +402 -0
  240. package/dist/public/views/profile/packages-tab.js +393 -0
  241. package/dist/public/views/profile/portfolio-tab.js +31 -0
  242. package/dist/public/views/profile/security-tab.js +219 -0
  243. package/dist/public/views/profile/services-tab.js +281 -0
  244. package/dist/public/views/profile/shared.js +58 -0
  245. package/dist/public/views/profile/wallet-tab.js +272 -0
  246. package/dist/public/views/profile/work-tab.js +220 -0
  247. package/dist/public/views/profile.js +271 -0
  248. package/dist/public/wizard.html +1320 -0
  249. package/dist/scripts/db-init.d.ts +19 -0
  250. package/dist/scripts/db-init.d.ts.map +1 -0
  251. package/dist/scripts/db-init.js +168 -0
  252. package/dist/scripts/db-init.js.map +1 -0
  253. package/dist/scripts/db-reset.d.ts +15 -0
  254. package/dist/scripts/db-reset.d.ts.map +1 -0
  255. package/dist/scripts/db-reset.js +162 -0
  256. package/dist/scripts/db-reset.js.map +1 -0
  257. package/dist/scripts/indexnow.d.ts +18 -0
  258. package/dist/scripts/indexnow.d.ts.map +1 -0
  259. package/dist/scripts/indexnow.js +104 -0
  260. package/dist/scripts/indexnow.js.map +1 -0
  261. package/dist/scripts/kill-port.d.ts +3 -0
  262. package/dist/scripts/kill-port.d.ts.map +1 -0
  263. package/dist/scripts/kill-port.js +89 -0
  264. package/dist/scripts/kill-port.js.map +1 -0
  265. package/dist/scripts/seed-digital-signage.d.ts +13 -0
  266. package/dist/scripts/seed-digital-signage.d.ts.map +1 -0
  267. package/dist/scripts/seed-digital-signage.js +85 -0
  268. package/dist/scripts/seed-digital-signage.js.map +1 -0
  269. package/dist/src/auth/jwt.d.ts +40 -0
  270. package/dist/src/auth/jwt.d.ts.map +1 -0
  271. package/dist/src/auth/jwt.js +139 -0
  272. package/dist/src/auth/jwt.js.map +1 -0
  273. package/dist/src/auth/keypair.d.ts +8 -0
  274. package/dist/src/auth/keypair.d.ts.map +1 -0
  275. package/dist/src/auth/keypair.js +35 -0
  276. package/dist/src/auth/keypair.js.map +1 -0
  277. package/dist/src/auth/middleware.d.ts +50 -0
  278. package/dist/src/auth/middleware.d.ts.map +1 -0
  279. package/dist/src/auth/middleware.js +241 -0
  280. package/dist/src/auth/middleware.js.map +1 -0
  281. package/dist/src/auth/node-keys.d.ts +7 -0
  282. package/dist/src/auth/node-keys.d.ts.map +1 -0
  283. package/dist/src/auth/node-keys.js +116 -0
  284. package/dist/src/auth/node-keys.js.map +1 -0
  285. package/dist/src/cli/config-export.d.ts +9 -0
  286. package/dist/src/cli/config-export.d.ts.map +1 -0
  287. package/dist/src/cli/config-export.js +90 -0
  288. package/dist/src/cli/config-export.js.map +1 -0
  289. package/dist/src/cli/config-import.d.ts +10 -0
  290. package/dist/src/cli/config-import.d.ts.map +1 -0
  291. package/dist/src/cli/config-import.js +124 -0
  292. package/dist/src/cli/config-import.js.map +1 -0
  293. package/dist/src/cli/federation-join.d.ts +13 -0
  294. package/dist/src/cli/federation-join.d.ts.map +1 -0
  295. package/dist/src/cli/federation-join.js +395 -0
  296. package/dist/src/cli/federation-join.js.map +1 -0
  297. package/dist/src/cli/init-wizard.d.ts +8 -0
  298. package/dist/src/cli/init-wizard.d.ts.map +1 -0
  299. package/dist/src/cli/init-wizard.js +1489 -0
  300. package/dist/src/cli/init-wizard.js.map +1 -0
  301. package/dist/src/cli/scaffold.d.ts +33 -0
  302. package/dist/src/cli/scaffold.d.ts.map +1 -0
  303. package/dist/src/cli/scaffold.js +142 -0
  304. package/dist/src/cli/scaffold.js.map +1 -0
  305. package/dist/src/config.d.ts +272 -0
  306. package/dist/src/config.d.ts.map +1 -0
  307. package/dist/src/config.js +362 -0
  308. package/dist/src/config.js.map +1 -0
  309. package/dist/src/data/example-packages.d.ts +49 -0
  310. package/dist/src/data/example-packages.d.ts.map +1 -0
  311. package/dist/src/data/example-packages.js +814 -0
  312. package/dist/src/data/example-packages.js.map +1 -0
  313. package/dist/src/i18n.d.ts +19 -0
  314. package/dist/src/i18n.d.ts.map +1 -0
  315. package/dist/src/i18n.js +126 -0
  316. package/dist/src/i18n.js.map +1 -0
  317. package/dist/src/index.d.ts +3 -0
  318. package/dist/src/index.d.ts.map +1 -0
  319. package/dist/src/index.js +608 -0
  320. package/dist/src/index.js.map +1 -0
  321. package/dist/src/mcp/boards.d.ts +18 -0
  322. package/dist/src/mcp/boards.d.ts.map +1 -0
  323. package/dist/src/mcp/boards.js +279 -0
  324. package/dist/src/mcp/boards.js.map +1 -0
  325. package/dist/src/mcp/catalogue.d.ts +17 -0
  326. package/dist/src/mcp/catalogue.d.ts.map +1 -0
  327. package/dist/src/mcp/catalogue.js +114 -0
  328. package/dist/src/mcp/catalogue.js.map +1 -0
  329. package/dist/src/mcp/chat-instances.d.ts +18 -0
  330. package/dist/src/mcp/chat-instances.d.ts.map +1 -0
  331. package/dist/src/mcp/chat-instances.js +161 -0
  332. package/dist/src/mcp/chat-instances.js.map +1 -0
  333. package/dist/src/mcp/consent.d.ts +18 -0
  334. package/dist/src/mcp/consent.d.ts.map +1 -0
  335. package/dist/src/mcp/consent.js +158 -0
  336. package/dist/src/mcp/consent.js.map +1 -0
  337. package/dist/src/mcp/core.d.ts +18 -0
  338. package/dist/src/mcp/core.d.ts.map +1 -0
  339. package/dist/src/mcp/core.js +489 -0
  340. package/dist/src/mcp/core.js.map +1 -0
  341. package/dist/src/mcp/extensions.d.ts +18 -0
  342. package/dist/src/mcp/extensions.d.ts.map +1 -0
  343. package/dist/src/mcp/extensions.js +299 -0
  344. package/dist/src/mcp/extensions.js.map +1 -0
  345. package/dist/src/mcp/flags.d.ts +18 -0
  346. package/dist/src/mcp/flags.d.ts.map +1 -0
  347. package/dist/src/mcp/flags.js +59 -0
  348. package/dist/src/mcp/flags.js.map +1 -0
  349. package/dist/src/mcp/index.d.ts +31 -0
  350. package/dist/src/mcp/index.d.ts.map +1 -0
  351. package/dist/src/mcp/index.js +694 -0
  352. package/dist/src/mcp/index.js.map +1 -0
  353. package/dist/src/mcp/knowledge.d.ts +18 -0
  354. package/dist/src/mcp/knowledge.d.ts.map +1 -0
  355. package/dist/src/mcp/knowledge.js +214 -0
  356. package/dist/src/mcp/knowledge.js.map +1 -0
  357. package/dist/src/mcp/memory-extended.d.ts +18 -0
  358. package/dist/src/mcp/memory-extended.d.ts.map +1 -0
  359. package/dist/src/mcp/memory-extended.js +73 -0
  360. package/dist/src/mcp/memory-extended.js.map +1 -0
  361. package/dist/src/mcp/organisms.d.ts +18 -0
  362. package/dist/src/mcp/organisms.d.ts.map +1 -0
  363. package/dist/src/mcp/organisms.js +291 -0
  364. package/dist/src/mcp/organisms.js.map +1 -0
  365. package/dist/src/mcp/prompts.d.ts +17 -0
  366. package/dist/src/mcp/prompts.d.ts.map +1 -0
  367. package/dist/src/mcp/prompts.js +65 -0
  368. package/dist/src/mcp/prompts.js.map +1 -0
  369. package/dist/src/mcp/wallet-extended.d.ts +17 -0
  370. package/dist/src/mcp/wallet-extended.d.ts.map +1 -0
  371. package/dist/src/mcp/wallet-extended.js +42 -0
  372. package/dist/src/mcp/wallet-extended.js.map +1 -0
  373. package/dist/src/middleware/__tests__/cookie-consent.test.d.ts +2 -0
  374. package/dist/src/middleware/__tests__/cookie-consent.test.d.ts.map +1 -0
  375. package/dist/src/middleware/__tests__/cookie-consent.test.js +432 -0
  376. package/dist/src/middleware/__tests__/cookie-consent.test.js.map +1 -0
  377. package/dist/src/middleware/cookie-consent.d.ts +19 -0
  378. package/dist/src/middleware/cookie-consent.d.ts.map +1 -0
  379. package/dist/src/middleware/cookie-consent.js +127 -0
  380. package/dist/src/middleware/cookie-consent.js.map +1 -0
  381. package/dist/src/middleware/cors.d.ts +12 -0
  382. package/dist/src/middleware/cors.d.ts.map +1 -0
  383. package/dist/src/middleware/cors.js +112 -0
  384. package/dist/src/middleware/cors.js.map +1 -0
  385. package/dist/src/middleware/envelope.d.ts +33 -0
  386. package/dist/src/middleware/envelope.d.ts.map +1 -0
  387. package/dist/src/middleware/envelope.js +32 -0
  388. package/dist/src/middleware/envelope.js.map +1 -0
  389. package/dist/src/middleware/idempotency.d.ts +3 -0
  390. package/dist/src/middleware/idempotency.d.ts.map +1 -0
  391. package/dist/src/middleware/idempotency.js +64 -0
  392. package/dist/src/middleware/idempotency.js.map +1 -0
  393. package/dist/src/middleware/metrics.d.ts +8 -0
  394. package/dist/src/middleware/metrics.d.ts.map +1 -0
  395. package/dist/src/middleware/metrics.js +25 -0
  396. package/dist/src/middleware/metrics.js.map +1 -0
  397. package/dist/src/middleware/rate-limit.d.ts +4 -0
  398. package/dist/src/middleware/rate-limit.d.ts.map +1 -0
  399. package/dist/src/middleware/rate-limit.js +73 -0
  400. package/dist/src/middleware/rate-limit.js.map +1 -0
  401. package/dist/src/middleware/request-id.d.ts +18 -0
  402. package/dist/src/middleware/request-id.d.ts.map +1 -0
  403. package/dist/src/middleware/request-id.js +23 -0
  404. package/dist/src/middleware/request-id.js.map +1 -0
  405. package/dist/src/middleware/stats.d.ts +4 -0
  406. package/dist/src/middleware/stats.d.ts.map +1 -0
  407. package/dist/src/middleware/stats.js +11 -0
  408. package/dist/src/middleware/stats.js.map +1 -0
  409. package/dist/src/middleware/workspace-access.d.ts +16 -0
  410. package/dist/src/middleware/workspace-access.d.ts.map +1 -0
  411. package/dist/src/middleware/workspace-access.js +115 -0
  412. package/dist/src/middleware/workspace-access.js.map +1 -0
  413. package/dist/src/models/schemas.d.ts +311 -0
  414. package/dist/src/models/schemas.d.ts.map +1 -0
  415. package/dist/src/models/schemas.js +281 -0
  416. package/dist/src/models/schemas.js.map +1 -0
  417. package/dist/src/routes/actions.d.ts +5 -0
  418. package/dist/src/routes/actions.d.ts.map +1 -0
  419. package/dist/src/routes/actions.js +199 -0
  420. package/dist/src/routes/actions.js.map +1 -0
  421. package/dist/src/routes/admin-agents.d.ts +5 -0
  422. package/dist/src/routes/admin-agents.d.ts.map +1 -0
  423. package/dist/src/routes/admin-agents.js +60 -0
  424. package/dist/src/routes/admin-agents.js.map +1 -0
  425. package/dist/src/routes/admin-config.d.ts +7 -0
  426. package/dist/src/routes/admin-config.d.ts.map +1 -0
  427. package/dist/src/routes/admin-config.js +209 -0
  428. package/dist/src/routes/admin-config.js.map +1 -0
  429. package/dist/src/routes/admin-economy.d.ts +5 -0
  430. package/dist/src/routes/admin-economy.d.ts.map +1 -0
  431. package/dist/src/routes/admin-economy.js +57 -0
  432. package/dist/src/routes/admin-economy.js.map +1 -0
  433. package/dist/src/routes/admin-extensions.d.ts +6 -0
  434. package/dist/src/routes/admin-extensions.d.ts.map +1 -0
  435. package/dist/src/routes/admin-extensions.js +619 -0
  436. package/dist/src/routes/admin-extensions.js.map +1 -0
  437. package/dist/src/routes/admin-features.d.ts +16 -0
  438. package/dist/src/routes/admin-features.d.ts.map +1 -0
  439. package/dist/src/routes/admin-features.js +672 -0
  440. package/dist/src/routes/admin-features.js.map +1 -0
  441. package/dist/src/routes/admin-maintenance.d.ts +8 -0
  442. package/dist/src/routes/admin-maintenance.d.ts.map +1 -0
  443. package/dist/src/routes/admin-maintenance.js +86 -0
  444. package/dist/src/routes/admin-maintenance.js.map +1 -0
  445. package/dist/src/routes/admin-memory.d.ts +12 -0
  446. package/dist/src/routes/admin-memory.d.ts.map +1 -0
  447. package/dist/src/routes/admin-memory.js +64 -0
  448. package/dist/src/routes/admin-memory.js.map +1 -0
  449. package/dist/src/routes/admin-monitoring.d.ts +5 -0
  450. package/dist/src/routes/admin-monitoring.d.ts.map +1 -0
  451. package/dist/src/routes/admin-monitoring.js +343 -0
  452. package/dist/src/routes/admin-monitoring.js.map +1 -0
  453. package/dist/src/routes/admin-prompts.d.ts +5 -0
  454. package/dist/src/routes/admin-prompts.d.ts.map +1 -0
  455. package/dist/src/routes/admin-prompts.js +198 -0
  456. package/dist/src/routes/admin-prompts.js.map +1 -0
  457. package/dist/src/routes/admin-scheduler.d.ts +6 -0
  458. package/dist/src/routes/admin-scheduler.d.ts.map +1 -0
  459. package/dist/src/routes/admin-scheduler.js +153 -0
  460. package/dist/src/routes/admin-scheduler.js.map +1 -0
  461. package/dist/src/routes/admin.d.ts +10 -0
  462. package/dist/src/routes/admin.d.ts.map +1 -0
  463. package/dist/src/routes/admin.js +847 -0
  464. package/dist/src/routes/admin.js.map +1 -0
  465. package/dist/src/routes/agents.d.ts +5 -0
  466. package/dist/src/routes/agents.d.ts.map +1 -0
  467. package/dist/src/routes/agents.js +946 -0
  468. package/dist/src/routes/agents.js.map +1 -0
  469. package/dist/src/routes/app-store.d.ts +25 -0
  470. package/dist/src/routes/app-store.d.ts.map +1 -0
  471. package/dist/src/routes/app-store.js +269 -0
  472. package/dist/src/routes/app-store.js.map +1 -0
  473. package/dist/src/routes/appeals.d.ts +5 -0
  474. package/dist/src/routes/appeals.d.ts.map +1 -0
  475. package/dist/src/routes/appeals.js +241 -0
  476. package/dist/src/routes/appeals.js.map +1 -0
  477. package/dist/src/routes/apps.d.ts +14 -0
  478. package/dist/src/routes/apps.d.ts.map +1 -0
  479. package/dist/src/routes/apps.js +395 -0
  480. package/dist/src/routes/apps.js.map +1 -0
  481. package/dist/src/routes/auth.d.ts +13 -0
  482. package/dist/src/routes/auth.d.ts.map +1 -0
  483. package/dist/src/routes/auth.js +517 -0
  484. package/dist/src/routes/auth.js.map +1 -0
  485. package/dist/src/routes/boards.d.ts +5 -0
  486. package/dist/src/routes/boards.d.ts.map +1 -0
  487. package/dist/src/routes/boards.js +614 -0
  488. package/dist/src/routes/boards.js.map +1 -0
  489. package/dist/src/routes/bootstrap.d.ts +6 -0
  490. package/dist/src/routes/bootstrap.d.ts.map +1 -0
  491. package/dist/src/routes/bootstrap.js +360 -0
  492. package/dist/src/routes/bootstrap.js.map +1 -0
  493. package/dist/src/routes/calibrator.d.ts +28 -0
  494. package/dist/src/routes/calibrator.d.ts.map +1 -0
  495. package/dist/src/routes/calibrator.js +556 -0
  496. package/dist/src/routes/calibrator.js.map +1 -0
  497. package/dist/src/routes/catalogue.d.ts +7 -0
  498. package/dist/src/routes/catalogue.d.ts.map +1 -0
  499. package/dist/src/routes/catalogue.js +377 -0
  500. package/dist/src/routes/catalogue.js.map +1 -0
  501. package/dist/src/routes/chat-instances.d.ts +5 -0
  502. package/dist/src/routes/chat-instances.d.ts.map +1 -0
  503. package/dist/src/routes/chat-instances.js +131 -0
  504. package/dist/src/routes/chat-instances.js.map +1 -0
  505. package/dist/src/routes/consent.d.ts +6 -0
  506. package/dist/src/routes/consent.d.ts.map +1 -0
  507. package/dist/src/routes/consent.js +188 -0
  508. package/dist/src/routes/consent.js.map +1 -0
  509. package/dist/src/routes/cortex.d.ts +5 -0
  510. package/dist/src/routes/cortex.d.ts.map +1 -0
  511. package/dist/src/routes/cortex.js +617 -0
  512. package/dist/src/routes/cortex.js.map +1 -0
  513. package/dist/src/routes/csm.d.ts +5 -0
  514. package/dist/src/routes/csm.d.ts.map +1 -0
  515. package/dist/src/routes/csm.js +258 -0
  516. package/dist/src/routes/csm.js.map +1 -0
  517. package/dist/src/routes/disputes.d.ts +5 -0
  518. package/dist/src/routes/disputes.d.ts.map +1 -0
  519. package/dist/src/routes/disputes.js +528 -0
  520. package/dist/src/routes/disputes.js.map +1 -0
  521. package/dist/src/routes/extensions.d.ts +6 -0
  522. package/dist/src/routes/extensions.d.ts.map +1 -0
  523. package/dist/src/routes/extensions.js +1149 -0
  524. package/dist/src/routes/extensions.js.map +1 -0
  525. package/dist/src/routes/federation-genesis.d.ts +11 -0
  526. package/dist/src/routes/federation-genesis.d.ts.map +1 -0
  527. package/dist/src/routes/federation-genesis.js +638 -0
  528. package/dist/src/routes/federation-genesis.js.map +1 -0
  529. package/dist/src/routes/federation-peer.d.ts +10 -0
  530. package/dist/src/routes/federation-peer.d.ts.map +1 -0
  531. package/dist/src/routes/federation-peer.js +613 -0
  532. package/dist/src/routes/federation-peer.js.map +1 -0
  533. package/dist/src/routes/federation-settlements.d.ts +10 -0
  534. package/dist/src/routes/federation-settlements.d.ts.map +1 -0
  535. package/dist/src/routes/federation-settlements.js +231 -0
  536. package/dist/src/routes/federation-settlements.js.map +1 -0
  537. package/dist/src/routes/federation-sync.d.ts +15 -0
  538. package/dist/src/routes/federation-sync.d.ts.map +1 -0
  539. package/dist/src/routes/federation-sync.js +629 -0
  540. package/dist/src/routes/federation-sync.js.map +1 -0
  541. package/dist/src/routes/federation.d.ts +15 -0
  542. package/dist/src/routes/federation.d.ts.map +1 -0
  543. package/dist/src/routes/federation.js +23 -0
  544. package/dist/src/routes/federation.js.map +1 -0
  545. package/dist/src/routes/flags.d.ts +5 -0
  546. package/dist/src/routes/flags.d.ts.map +1 -0
  547. package/dist/src/routes/flags.js +194 -0
  548. package/dist/src/routes/flags.js.map +1 -0
  549. package/dist/src/routes/foundry.d.ts +5 -0
  550. package/dist/src/routes/foundry.d.ts.map +1 -0
  551. package/dist/src/routes/foundry.js +955 -0
  552. package/dist/src/routes/foundry.js.map +1 -0
  553. package/dist/src/routes/generator-autopilot.d.ts +12 -0
  554. package/dist/src/routes/generator-autopilot.d.ts.map +1 -0
  555. package/dist/src/routes/generator-autopilot.js +71 -0
  556. package/dist/src/routes/generator-autopilot.js.map +1 -0
  557. package/dist/src/routes/generator.d.ts +5 -0
  558. package/dist/src/routes/generator.d.ts.map +1 -0
  559. package/dist/src/routes/generator.js +1313 -0
  560. package/dist/src/routes/generator.js.map +1 -0
  561. package/dist/src/routes/ghii.d.ts +16 -0
  562. package/dist/src/routes/ghii.d.ts.map +1 -0
  563. package/dist/src/routes/ghii.js +1115 -0
  564. package/dist/src/routes/ghii.js.map +1 -0
  565. package/dist/src/routes/instances.d.ts +31 -0
  566. package/dist/src/routes/instances.d.ts.map +1 -0
  567. package/dist/src/routes/instances.js +722 -0
  568. package/dist/src/routes/instances.js.map +1 -0
  569. package/dist/src/routes/knowledge.d.ts +33 -0
  570. package/dist/src/routes/knowledge.d.ts.map +1 -0
  571. package/dist/src/routes/knowledge.js +1108 -0
  572. package/dist/src/routes/knowledge.js.map +1 -0
  573. package/dist/src/routes/lib-data.d.ts +7 -0
  574. package/dist/src/routes/lib-data.d.ts.map +1 -0
  575. package/dist/src/routes/lib-data.js +189 -0
  576. package/dist/src/routes/lib-data.js.map +1 -0
  577. package/dist/src/routes/lib-social.d.ts +7 -0
  578. package/dist/src/routes/lib-social.d.ts.map +1 -0
  579. package/dist/src/routes/lib-social.js +159 -0
  580. package/dist/src/routes/lib-social.js.map +1 -0
  581. package/dist/src/routes/lib-storage.d.ts +7 -0
  582. package/dist/src/routes/lib-storage.d.ts.map +1 -0
  583. package/dist/src/routes/lib-storage.js +202 -0
  584. package/dist/src/routes/lib-storage.js.map +1 -0
  585. package/dist/src/routes/lib-tunnel.d.ts +8 -0
  586. package/dist/src/routes/lib-tunnel.d.ts.map +1 -0
  587. package/dist/src/routes/lib-tunnel.js +442 -0
  588. package/dist/src/routes/lib-tunnel.js.map +1 -0
  589. package/dist/src/routes/lib-wallet.d.ts +7 -0
  590. package/dist/src/routes/lib-wallet.d.ts.map +1 -0
  591. package/dist/src/routes/lib-wallet.js +129 -0
  592. package/dist/src/routes/lib-wallet.js.map +1 -0
  593. package/dist/src/routes/lib-work.d.ts +7 -0
  594. package/dist/src/routes/lib-work.d.ts.map +1 -0
  595. package/dist/src/routes/lib-work.js +210 -0
  596. package/dist/src/routes/lib-work.js.map +1 -0
  597. package/dist/src/routes/libs.d.ts +10 -0
  598. package/dist/src/routes/libs.d.ts.map +1 -0
  599. package/dist/src/routes/libs.js +989 -0
  600. package/dist/src/routes/libs.js.map +1 -0
  601. package/dist/src/routes/matches.d.ts +10 -0
  602. package/dist/src/routes/matches.d.ts.map +1 -0
  603. package/dist/src/routes/matches.js +218 -0
  604. package/dist/src/routes/matches.js.map +1 -0
  605. package/dist/src/routes/memory.d.ts +6 -0
  606. package/dist/src/routes/memory.d.ts.map +1 -0
  607. package/dist/src/routes/memory.js +796 -0
  608. package/dist/src/routes/memory.js.map +1 -0
  609. package/dist/src/routes/micro-memory.d.ts +5 -0
  610. package/dist/src/routes/micro-memory.d.ts.map +1 -0
  611. package/dist/src/routes/micro-memory.js +488 -0
  612. package/dist/src/routes/micro-memory.js.map +1 -0
  613. package/dist/src/routes/msm.d.ts +5 -0
  614. package/dist/src/routes/msm.d.ts.map +1 -0
  615. package/dist/src/routes/msm.js +242 -0
  616. package/dist/src/routes/msm.js.map +1 -0
  617. package/dist/src/routes/openrouter.d.ts +23 -0
  618. package/dist/src/routes/openrouter.d.ts.map +1 -0
  619. package/dist/src/routes/openrouter.js +337 -0
  620. package/dist/src/routes/openrouter.js.map +1 -0
  621. package/dist/src/routes/organisms.d.ts +5 -0
  622. package/dist/src/routes/organisms.d.ts.map +1 -0
  623. package/dist/src/routes/organisms.js +415 -0
  624. package/dist/src/routes/organisms.js.map +1 -0
  625. package/dist/src/routes/owners.d.ts +5 -0
  626. package/dist/src/routes/owners.d.ts.map +1 -0
  627. package/dist/src/routes/owners.js +637 -0
  628. package/dist/src/routes/owners.js.map +1 -0
  629. package/dist/src/routes/packages.d.ts +35 -0
  630. package/dist/src/routes/packages.d.ts.map +1 -0
  631. package/dist/src/routes/packages.js +600 -0
  632. package/dist/src/routes/packages.js.map +1 -0
  633. package/dist/src/routes/permissions.d.ts +5 -0
  634. package/dist/src/routes/permissions.d.ts.map +1 -0
  635. package/dist/src/routes/permissions.js +85 -0
  636. package/dist/src/routes/permissions.js.map +1 -0
  637. package/dist/src/routes/personal.d.ts +7 -0
  638. package/dist/src/routes/personal.d.ts.map +1 -0
  639. package/dist/src/routes/personal.js +594 -0
  640. package/dist/src/routes/personal.js.map +1 -0
  641. package/dist/src/routes/portal-api.d.ts +9 -0
  642. package/dist/src/routes/portal-api.d.ts.map +1 -0
  643. package/dist/src/routes/portal-api.js +49 -0
  644. package/dist/src/routes/portal-api.js.map +1 -0
  645. package/dist/src/routes/portal-human.d.ts +12 -0
  646. package/dist/src/routes/portal-human.d.ts.map +1 -0
  647. package/dist/src/routes/portal-human.js +2652 -0
  648. package/dist/src/routes/portal-human.js.map +1 -0
  649. package/dist/src/routes/portal.d.ts +24 -0
  650. package/dist/src/routes/portal.d.ts.map +1 -0
  651. package/dist/src/routes/portal.js +372 -0
  652. package/dist/src/routes/portal.js.map +1 -0
  653. package/dist/src/routes/portfolio.d.ts +5 -0
  654. package/dist/src/routes/portfolio.d.ts.map +1 -0
  655. package/dist/src/routes/portfolio.js +231 -0
  656. package/dist/src/routes/portfolio.js.map +1 -0
  657. package/dist/src/routes/profile.d.ts +5 -0
  658. package/dist/src/routes/profile.d.ts.map +1 -0
  659. package/dist/src/routes/profile.js +2042 -0
  660. package/dist/src/routes/profile.js.map +1 -0
  661. package/dist/src/routes/prompts.d.ts +5 -0
  662. package/dist/src/routes/prompts.d.ts.map +1 -0
  663. package/dist/src/routes/prompts.js +318 -0
  664. package/dist/src/routes/prompts.js.map +1 -0
  665. package/dist/src/routes/push.d.ts +6 -0
  666. package/dist/src/routes/push.d.ts.map +1 -0
  667. package/dist/src/routes/push.js +75 -0
  668. package/dist/src/routes/push.js.map +1 -0
  669. package/dist/src/routes/realtime.d.ts +7 -0
  670. package/dist/src/routes/realtime.d.ts.map +1 -0
  671. package/dist/src/routes/realtime.js +289 -0
  672. package/dist/src/routes/realtime.js.map +1 -0
  673. package/dist/src/routes/schemas.d.ts +5 -0
  674. package/dist/src/routes/schemas.d.ts.map +1 -0
  675. package/dist/src/routes/schemas.js +130 -0
  676. package/dist/src/routes/schemas.js.map +1 -0
  677. package/dist/src/routes/setup.d.ts +7 -0
  678. package/dist/src/routes/setup.d.ts.map +1 -0
  679. package/dist/src/routes/setup.js +243 -0
  680. package/dist/src/routes/setup.js.map +1 -0
  681. package/dist/src/routes/site.d.ts +6 -0
  682. package/dist/src/routes/site.d.ts.map +1 -0
  683. package/dist/src/routes/site.js +201 -0
  684. package/dist/src/routes/site.js.map +1 -0
  685. package/dist/src/routes/spec.d.ts +3 -0
  686. package/dist/src/routes/spec.d.ts.map +1 -0
  687. package/dist/src/routes/spec.js +47 -0
  688. package/dist/src/routes/spec.js.map +1 -0
  689. package/dist/src/routes/sse.d.ts +5 -0
  690. package/dist/src/routes/sse.d.ts.map +1 -0
  691. package/dist/src/routes/sse.js +66 -0
  692. package/dist/src/routes/sse.js.map +1 -0
  693. package/dist/src/routes/stats.d.ts +7 -0
  694. package/dist/src/routes/stats.d.ts.map +1 -0
  695. package/dist/src/routes/stats.js +98 -0
  696. package/dist/src/routes/stats.js.map +1 -0
  697. package/dist/src/routes/storage-files.d.ts +5 -0
  698. package/dist/src/routes/storage-files.d.ts.map +1 -0
  699. package/dist/src/routes/storage-files.js +460 -0
  700. package/dist/src/routes/storage-files.js.map +1 -0
  701. package/dist/src/routes/templates.d.ts +30 -0
  702. package/dist/src/routes/templates.d.ts.map +1 -0
  703. package/dist/src/routes/templates.js +511 -0
  704. package/dist/src/routes/templates.js.map +1 -0
  705. package/dist/src/routes/totp.d.ts +5 -0
  706. package/dist/src/routes/totp.d.ts.map +1 -0
  707. package/dist/src/routes/totp.js +166 -0
  708. package/dist/src/routes/totp.js.map +1 -0
  709. package/dist/src/routes/validate.d.ts +4 -0
  710. package/dist/src/routes/validate.d.ts.map +1 -0
  711. package/dist/src/routes/validate.js +71 -0
  712. package/dist/src/routes/validate.js.map +1 -0
  713. package/dist/src/routes/verification.d.ts +8 -0
  714. package/dist/src/routes/verification.d.ts.map +1 -0
  715. package/dist/src/routes/verification.js +259 -0
  716. package/dist/src/routes/verification.js.map +1 -0
  717. package/dist/src/routes/wallet.d.ts +18 -0
  718. package/dist/src/routes/wallet.d.ts.map +1 -0
  719. package/dist/src/routes/wallet.js +164 -0
  720. package/dist/src/routes/wallet.js.map +1 -0
  721. package/dist/src/routes/wellknown.d.ts +5 -0
  722. package/dist/src/routes/wellknown.d.ts.map +1 -0
  723. package/dist/src/routes/wellknown.js +57 -0
  724. package/dist/src/routes/wellknown.js.map +1 -0
  725. package/dist/src/routes/work.d.ts +21 -0
  726. package/dist/src/routes/work.d.ts.map +1 -0
  727. package/dist/src/routes/work.js +654 -0
  728. package/dist/src/routes/work.js.map +1 -0
  729. package/dist/src/schemas/knowledge-package.d.ts +203 -0
  730. package/dist/src/schemas/knowledge-package.d.ts.map +1 -0
  731. package/dist/src/schemas/knowledge-package.js +233 -0
  732. package/dist/src/schemas/knowledge-package.js.map +1 -0
  733. package/dist/src/server-bootstrap/config-init.d.ts +16 -0
  734. package/dist/src/server-bootstrap/config-init.d.ts.map +1 -0
  735. package/dist/src/server-bootstrap/config-init.js +113 -0
  736. package/dist/src/server-bootstrap/config-init.js.map +1 -0
  737. package/dist/src/server-bootstrap/middleware-guards.d.ts +15 -0
  738. package/dist/src/server-bootstrap/middleware-guards.d.ts.map +1 -0
  739. package/dist/src/server-bootstrap/middleware-guards.js +244 -0
  740. package/dist/src/server-bootstrap/middleware-guards.js.map +1 -0
  741. package/dist/src/server-bootstrap/routes-loader.d.ts +35 -0
  742. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -0
  743. package/dist/src/server-bootstrap/routes-loader.js +290 -0
  744. package/dist/src/server-bootstrap/routes-loader.js.map +1 -0
  745. package/dist/src/server-bootstrap/service-init.d.ts +24 -0
  746. package/dist/src/server-bootstrap/service-init.d.ts.map +1 -0
  747. package/dist/src/server-bootstrap/service-init.js +195 -0
  748. package/dist/src/server-bootstrap/service-init.js.map +1 -0
  749. package/dist/src/server-bootstrap/static-files.d.ts +7 -0
  750. package/dist/src/server-bootstrap/static-files.d.ts.map +1 -0
  751. package/dist/src/server-bootstrap/static-files.js +119 -0
  752. package/dist/src/server-bootstrap/static-files.js.map +1 -0
  753. package/dist/src/server.d.ts +22 -0
  754. package/dist/src/server.d.ts.map +1 -0
  755. package/dist/src/server.js +133 -0
  756. package/dist/src/server.js.map +1 -0
  757. package/dist/src/services/cache-cleanup.d.ts +31 -0
  758. package/dist/src/services/cache-cleanup.d.ts.map +1 -0
  759. package/dist/src/services/cache-cleanup.js +123 -0
  760. package/dist/src/services/cache-cleanup.js.map +1 -0
  761. package/dist/src/services/catalogue-sync.d.ts +45 -0
  762. package/dist/src/services/catalogue-sync.d.ts.map +1 -0
  763. package/dist/src/services/catalogue-sync.js +196 -0
  764. package/dist/src/services/catalogue-sync.js.map +1 -0
  765. package/dist/src/services/component-registrar.d.ts +46 -0
  766. package/dist/src/services/component-registrar.d.ts.map +1 -0
  767. package/dist/src/services/component-registrar.js +389 -0
  768. package/dist/src/services/component-registrar.js.map +1 -0
  769. package/dist/src/services/config-loader.d.ts +42 -0
  770. package/dist/src/services/config-loader.d.ts.map +1 -0
  771. package/dist/src/services/config-loader.js +187 -0
  772. package/dist/src/services/config-loader.js.map +1 -0
  773. package/dist/src/services/config-provenance.d.ts +32 -0
  774. package/dist/src/services/config-provenance.d.ts.map +1 -0
  775. package/dist/src/services/config-provenance.js +59 -0
  776. package/dist/src/services/config-provenance.js.map +1 -0
  777. package/dist/src/services/config-schema.d.ts +52 -0
  778. package/dist/src/services/config-schema.d.ts.map +1 -0
  779. package/dist/src/services/config-schema.js +288 -0
  780. package/dist/src/services/config-schema.js.map +1 -0
  781. package/dist/src/services/consent.d.ts +43 -0
  782. package/dist/src/services/consent.d.ts.map +1 -0
  783. package/dist/src/services/consent.js +137 -0
  784. package/dist/src/services/consent.js.map +1 -0
  785. package/dist/src/services/consul-config.d.ts +30 -0
  786. package/dist/src/services/consul-config.d.ts.map +1 -0
  787. package/dist/src/services/consul-config.js +110 -0
  788. package/dist/src/services/consul-config.js.map +1 -0
  789. package/dist/src/services/core-jobs.d.ts +8 -0
  790. package/dist/src/services/core-jobs.d.ts.map +1 -0
  791. package/dist/src/services/core-jobs.js +161 -0
  792. package/dist/src/services/core-jobs.js.map +1 -0
  793. package/dist/src/services/cortex-manifest.d.ts +17 -0
  794. package/dist/src/services/cortex-manifest.d.ts.map +1 -0
  795. package/dist/src/services/cortex-manifest.js +343 -0
  796. package/dist/src/services/cortex-manifest.js.map +1 -0
  797. package/dist/src/services/cortex-seeder.d.ts +18 -0
  798. package/dist/src/services/cortex-seeder.d.ts.map +1 -0
  799. package/dist/src/services/cortex-seeder.js +86 -0
  800. package/dist/src/services/cortex-seeder.js.map +1 -0
  801. package/dist/src/services/cross-node-matching.d.ts +23 -0
  802. package/dist/src/services/cross-node-matching.d.ts.map +1 -0
  803. package/dist/src/services/cross-node-matching.js +62 -0
  804. package/dist/src/services/cross-node-matching.js.map +1 -0
  805. package/dist/src/services/csm-parser.d.ts +57 -0
  806. package/dist/src/services/csm-parser.d.ts.map +1 -0
  807. package/dist/src/services/csm-parser.js +161 -0
  808. package/dist/src/services/csm-parser.js.map +1 -0
  809. package/dist/src/services/csm-seed.d.ts +15 -0
  810. package/dist/src/services/csm-seed.d.ts.map +1 -0
  811. package/dist/src/services/csm-seed.js +89 -0
  812. package/dist/src/services/csm-seed.js.map +1 -0
  813. package/dist/src/services/directory.d.ts +86 -0
  814. package/dist/src/services/directory.d.ts.map +1 -0
  815. package/dist/src/services/directory.js +307 -0
  816. package/dist/src/services/directory.js.map +1 -0
  817. package/dist/src/services/email-templates.d.ts +29 -0
  818. package/dist/src/services/email-templates.d.ts.map +1 -0
  819. package/dist/src/services/email-templates.js +204 -0
  820. package/dist/src/services/email-templates.js.map +1 -0
  821. package/dist/src/services/email.d.ts +18 -0
  822. package/dist/src/services/email.d.ts.map +1 -0
  823. package/dist/src/services/email.js +102 -0
  824. package/dist/src/services/email.js.map +1 -0
  825. package/dist/src/services/encryption.d.ts +31 -0
  826. package/dist/src/services/encryption.d.ts.map +1 -0
  827. package/dist/src/services/encryption.js +51 -0
  828. package/dist/src/services/encryption.js.map +1 -0
  829. package/dist/src/services/eudiw.d.ts +15 -0
  830. package/dist/src/services/eudiw.d.ts.map +1 -0
  831. package/dist/src/services/eudiw.js +89 -0
  832. package/dist/src/services/eudiw.js.map +1 -0
  833. package/dist/src/services/event-bus.d.ts +8 -0
  834. package/dist/src/services/event-bus.d.ts.map +1 -0
  835. package/dist/src/services/event-bus.js +13 -0
  836. package/dist/src/services/event-bus.js.map +1 -0
  837. package/dist/src/services/extension-runtime.d.ts +72 -0
  838. package/dist/src/services/extension-runtime.d.ts.map +1 -0
  839. package/dist/src/services/extension-runtime.js +282 -0
  840. package/dist/src/services/extension-runtime.js.map +1 -0
  841. package/dist/src/services/federation-helpers.d.ts +37 -0
  842. package/dist/src/services/federation-helpers.d.ts.map +1 -0
  843. package/dist/src/services/federation-helpers.js +100 -0
  844. package/dist/src/services/federation-helpers.js.map +1 -0
  845. package/dist/src/services/federation.d.ts +32 -0
  846. package/dist/src/services/federation.d.ts.map +1 -0
  847. package/dist/src/services/federation.js +201 -0
  848. package/dist/src/services/federation.js.map +1 -0
  849. package/dist/src/services/foundry-debug.d.ts +77 -0
  850. package/dist/src/services/foundry-debug.d.ts.map +1 -0
  851. package/dist/src/services/foundry-debug.js +214 -0
  852. package/dist/src/services/foundry-debug.js.map +1 -0
  853. package/dist/src/services/foundry-registration.d.ts +42 -0
  854. package/dist/src/services/foundry-registration.d.ts.map +1 -0
  855. package/dist/src/services/foundry-registration.js +330 -0
  856. package/dist/src/services/foundry-registration.js.map +1 -0
  857. package/dist/src/services/foundry-testing.d.ts +90 -0
  858. package/dist/src/services/foundry-testing.d.ts.map +1 -0
  859. package/dist/src/services/foundry-testing.js +253 -0
  860. package/dist/src/services/foundry-testing.js.map +1 -0
  861. package/dist/src/services/foundry-validate.d.ts +115 -0
  862. package/dist/src/services/foundry-validate.d.ts.map +1 -0
  863. package/dist/src/services/foundry-validate.js +781 -0
  864. package/dist/src/services/foundry-validate.js.map +1 -0
  865. package/dist/src/services/generator-autopilot.d.ts +37 -0
  866. package/dist/src/services/generator-autopilot.d.ts.map +1 -0
  867. package/dist/src/services/generator-autopilot.js +1076 -0
  868. package/dist/src/services/generator-autopilot.js.map +1 -0
  869. package/dist/src/services/generator-debug.d.ts +79 -0
  870. package/dist/src/services/generator-debug.d.ts.map +1 -0
  871. package/dist/src/services/generator-debug.js +218 -0
  872. package/dist/src/services/generator-debug.js.map +1 -0
  873. package/dist/src/services/generator-prompt-seeds.d.ts +13 -0
  874. package/dist/src/services/generator-prompt-seeds.d.ts.map +1 -0
  875. package/dist/src/services/generator-prompt-seeds.js +2694 -0
  876. package/dist/src/services/generator-prompt-seeds.js.map +1 -0
  877. package/dist/src/services/generator-prompts/bundle.d.ts +17 -0
  878. package/dist/src/services/generator-prompts/bundle.d.ts.map +1 -0
  879. package/dist/src/services/generator-prompts/bundle.js +95 -0
  880. package/dist/src/services/generator-prompts/bundle.js.map +1 -0
  881. package/dist/src/services/generator-prompts/index.d.ts +48 -0
  882. package/dist/src/services/generator-prompts/index.d.ts.map +1 -0
  883. package/dist/src/services/generator-prompts/index.js +97 -0
  884. package/dist/src/services/generator-prompts/index.js.map +1 -0
  885. package/dist/src/services/generator-prompts/resolvers.d.ts +21 -0
  886. package/dist/src/services/generator-prompts/resolvers.d.ts.map +1 -0
  887. package/dist/src/services/generator-prompts/resolvers.js +1553 -0
  888. package/dist/src/services/generator-prompts/resolvers.js.map +1 -0
  889. package/dist/src/services/generator-prompts/spec-validate.d.ts +29 -0
  890. package/dist/src/services/generator-prompts/spec-validate.d.ts.map +1 -0
  891. package/dist/src/services/generator-prompts/spec-validate.js +190 -0
  892. package/dist/src/services/generator-prompts/spec-validate.js.map +1 -0
  893. package/dist/src/services/generator-prompts/strip.d.ts +13 -0
  894. package/dist/src/services/generator-prompts/strip.d.ts.map +1 -0
  895. package/dist/src/services/generator-prompts/strip.js +60 -0
  896. package/dist/src/services/generator-prompts/strip.js.map +1 -0
  897. package/dist/src/services/generator-prompts/types.d.ts +229 -0
  898. package/dist/src/services/generator-prompts/types.d.ts.map +1 -0
  899. package/dist/src/services/generator-prompts/types.js +8 -0
  900. package/dist/src/services/generator-prompts/types.js.map +1 -0
  901. package/dist/src/services/generator-prompts/validate.d.ts +48 -0
  902. package/dist/src/services/generator-prompts/validate.d.ts.map +1 -0
  903. package/dist/src/services/generator-prompts/validate.js +927 -0
  904. package/dist/src/services/generator-prompts/validate.js.map +1 -0
  905. package/dist/src/services/generator-registration.d.ts +43 -0
  906. package/dist/src/services/generator-registration.d.ts.map +1 -0
  907. package/dist/src/services/generator-registration.js +343 -0
  908. package/dist/src/services/generator-registration.js.map +1 -0
  909. package/dist/src/services/generator-testing.d.ts +93 -0
  910. package/dist/src/services/generator-testing.d.ts.map +1 -0
  911. package/dist/src/services/generator-testing.js +300 -0
  912. package/dist/src/services/generator-testing.js.map +1 -0
  913. package/dist/src/services/generator-validate.d.ts +117 -0
  914. package/dist/src/services/generator-validate.d.ts.map +1 -0
  915. package/dist/src/services/generator-validate.js +790 -0
  916. package/dist/src/services/generator-validate.js.map +1 -0
  917. package/dist/src/services/genesis-peering.d.ts +12 -0
  918. package/dist/src/services/genesis-peering.d.ts.map +1 -0
  919. package/dist/src/services/genesis-peering.js +91 -0
  920. package/dist/src/services/genesis-peering.js.map +1 -0
  921. package/dist/src/services/genesis-sync.d.ts +29 -0
  922. package/dist/src/services/genesis-sync.d.ts.map +1 -0
  923. package/dist/src/services/genesis-sync.js +370 -0
  924. package/dist/src/services/genesis-sync.js.map +1 -0
  925. package/dist/src/services/hooks.d.ts +21 -0
  926. package/dist/src/services/hooks.d.ts.map +1 -0
  927. package/dist/src/services/hooks.js +85 -0
  928. package/dist/src/services/hooks.js.map +1 -0
  929. package/dist/src/services/job-seeding.d.ts +7 -0
  930. package/dist/src/services/job-seeding.d.ts.map +1 -0
  931. package/dist/src/services/job-seeding.js +39 -0
  932. package/dist/src/services/job-seeding.js.map +1 -0
  933. package/dist/src/services/knowledge.d.ts +13 -0
  934. package/dist/src/services/knowledge.d.ts.map +1 -0
  935. package/dist/src/services/knowledge.js +15 -0
  936. package/dist/src/services/knowledge.js.map +1 -0
  937. package/dist/src/services/mailbox-notification.d.ts +37 -0
  938. package/dist/src/services/mailbox-notification.d.ts.map +1 -0
  939. package/dist/src/services/mailbox-notification.js +249 -0
  940. package/dist/src/services/mailbox-notification.js.map +1 -0
  941. package/dist/src/services/mailbox.d.ts +16 -0
  942. package/dist/src/services/mailbox.d.ts.map +1 -0
  943. package/dist/src/services/mailbox.js +77 -0
  944. package/dist/src/services/mailbox.js.map +1 -0
  945. package/dist/src/services/match-notification.d.ts +12 -0
  946. package/dist/src/services/match-notification.d.ts.map +1 -0
  947. package/dist/src/services/match-notification.js +121 -0
  948. package/dist/src/services/match-notification.js.map +1 -0
  949. package/dist/src/services/matching.d.ts +54 -0
  950. package/dist/src/services/matching.d.ts.map +1 -0
  951. package/dist/src/services/matching.js +293 -0
  952. package/dist/src/services/matching.js.map +1 -0
  953. package/dist/src/services/memory-replication.d.ts +43 -0
  954. package/dist/src/services/memory-replication.d.ts.map +1 -0
  955. package/dist/src/services/memory-replication.js +213 -0
  956. package/dist/src/services/memory-replication.js.map +1 -0
  957. package/dist/src/services/morsel.d.ts +49 -0
  958. package/dist/src/services/morsel.d.ts.map +1 -0
  959. package/dist/src/services/morsel.js +174 -0
  960. package/dist/src/services/morsel.js.map +1 -0
  961. package/dist/src/services/msm-parser.d.ts +55 -0
  962. package/dist/src/services/msm-parser.d.ts.map +1 -0
  963. package/dist/src/services/msm-parser.js +186 -0
  964. package/dist/src/services/msm-parser.js.map +1 -0
  965. package/dist/src/services/mydata-receipt.d.ts +29 -0
  966. package/dist/src/services/mydata-receipt.d.ts.map +1 -0
  967. package/dist/src/services/mydata-receipt.js +31 -0
  968. package/dist/src/services/mydata-receipt.js.map +1 -0
  969. package/dist/src/services/notification-templates.d.ts +40 -0
  970. package/dist/src/services/notification-templates.d.ts.map +1 -0
  971. package/dist/src/services/notification-templates.js +109 -0
  972. package/dist/src/services/notification-templates.js.map +1 -0
  973. package/dist/src/services/openrouter.d.ts +30 -0
  974. package/dist/src/services/openrouter.d.ts.map +1 -0
  975. package/dist/src/services/openrouter.js +95 -0
  976. package/dist/src/services/openrouter.js.map +1 -0
  977. package/dist/src/services/organism-reputation.d.ts +7 -0
  978. package/dist/src/services/organism-reputation.d.ts.map +1 -0
  979. package/dist/src/services/organism-reputation.js +107 -0
  980. package/dist/src/services/organism-reputation.js.map +1 -0
  981. package/dist/src/services/package-hash.d.ts +19 -0
  982. package/dist/src/services/package-hash.d.ts.map +1 -0
  983. package/dist/src/services/package-hash.js +22 -0
  984. package/dist/src/services/package-hash.js.map +1 -0
  985. package/dist/src/services/package-zip.d.ts +60 -0
  986. package/dist/src/services/package-zip.d.ts.map +1 -0
  987. package/dist/src/services/package-zip.js +267 -0
  988. package/dist/src/services/package-zip.js.map +1 -0
  989. package/dist/src/services/password.d.ts +9 -0
  990. package/dist/src/services/password.d.ts.map +1 -0
  991. package/dist/src/services/password.js +32 -0
  992. package/dist/src/services/password.js.map +1 -0
  993. package/dist/src/services/personal-routing.d.ts +21 -0
  994. package/dist/src/services/personal-routing.d.ts.map +1 -0
  995. package/dist/src/services/personal-routing.js +77 -0
  996. package/dist/src/services/personal-routing.js.map +1 -0
  997. package/dist/src/services/personal-tunnel.d.ts +39 -0
  998. package/dist/src/services/personal-tunnel.d.ts.map +1 -0
  999. package/dist/src/services/personal-tunnel.js +371 -0
  1000. package/dist/src/services/personal-tunnel.js.map +1 -0
  1001. package/dist/src/services/profile-schemas.d.ts +12 -0
  1002. package/dist/src/services/profile-schemas.d.ts.map +1 -0
  1003. package/dist/src/services/profile-schemas.js +100 -0
  1004. package/dist/src/services/profile-schemas.js.map +1 -0
  1005. package/dist/src/services/prometheus.d.ts +32 -0
  1006. package/dist/src/services/prometheus.d.ts.map +1 -0
  1007. package/dist/src/services/prometheus.js +162 -0
  1008. package/dist/src/services/prometheus.js.map +1 -0
  1009. package/dist/src/services/prompt-defaults.d.ts +33 -0
  1010. package/dist/src/services/prompt-defaults.d.ts.map +1 -0
  1011. package/dist/src/services/prompt-defaults.js +1675 -0
  1012. package/dist/src/services/prompt-defaults.js.map +1 -0
  1013. package/dist/src/services/prompt-seeder.d.ts +8 -0
  1014. package/dist/src/services/prompt-seeder.d.ts.map +1 -0
  1015. package/dist/src/services/prompt-seeder.js +65 -0
  1016. package/dist/src/services/prompt-seeder.js.map +1 -0
  1017. package/dist/src/services/prompt-variables.d.ts +15 -0
  1018. package/dist/src/services/prompt-variables.d.ts.map +1 -0
  1019. package/dist/src/services/prompt-variables.js +34 -0
  1020. package/dist/src/services/prompt-variables.js.map +1 -0
  1021. package/dist/src/services/push.d.ts +26 -0
  1022. package/dist/src/services/push.d.ts.map +1 -0
  1023. package/dist/src/services/push.js +70 -0
  1024. package/dist/src/services/push.js.map +1 -0
  1025. package/dist/src/services/quota.d.ts +45 -0
  1026. package/dist/src/services/quota.d.ts.map +1 -0
  1027. package/dist/src/services/quota.js +129 -0
  1028. package/dist/src/services/quota.js.map +1 -0
  1029. package/dist/src/services/realtime-manager.d.ts +144 -0
  1030. package/dist/src/services/realtime-manager.d.ts.map +1 -0
  1031. package/dist/src/services/realtime-manager.js +640 -0
  1032. package/dist/src/services/realtime-manager.js.map +1 -0
  1033. package/dist/src/services/scheduler.d.ts +55 -0
  1034. package/dist/src/services/scheduler.d.ts.map +1 -0
  1035. package/dist/src/services/scheduler.js +420 -0
  1036. package/dist/src/services/scheduler.js.map +1 -0
  1037. package/dist/src/services/schema-validator.d.ts +20 -0
  1038. package/dist/src/services/schema-validator.d.ts.map +1 -0
  1039. package/dist/src/services/schema-validator.js +68 -0
  1040. package/dist/src/services/schema-validator.js.map +1 -0
  1041. package/dist/src/services/site-sync.d.ts +15 -0
  1042. package/dist/src/services/site-sync.d.ts.map +1 -0
  1043. package/dist/src/services/site-sync.js +99 -0
  1044. package/dist/src/services/site-sync.js.map +1 -0
  1045. package/dist/src/services/site.d.ts +65 -0
  1046. package/dist/src/services/site.d.ts.map +1 -0
  1047. package/dist/src/services/site.js +378 -0
  1048. package/dist/src/services/site.js.map +1 -0
  1049. package/dist/src/services/stats.d.ts +75 -0
  1050. package/dist/src/services/stats.d.ts.map +1 -0
  1051. package/dist/src/services/stats.js +124 -0
  1052. package/dist/src/services/stats.js.map +1 -0
  1053. package/dist/src/services/sync-health.d.ts +53 -0
  1054. package/dist/src/services/sync-health.d.ts.map +1 -0
  1055. package/dist/src/services/sync-health.js +122 -0
  1056. package/dist/src/services/sync-health.js.map +1 -0
  1057. package/dist/src/services/sync-scheduler.d.ts +25 -0
  1058. package/dist/src/services/sync-scheduler.d.ts.map +1 -0
  1059. package/dist/src/services/sync-scheduler.js +211 -0
  1060. package/dist/src/services/sync-scheduler.js.map +1 -0
  1061. package/dist/src/services/totp.d.ts +31 -0
  1062. package/dist/src/services/totp.d.ts.map +1 -0
  1063. package/dist/src/services/totp.js +96 -0
  1064. package/dist/src/services/totp.js.map +1 -0
  1065. package/dist/src/services/trust-broadcast.d.ts +37 -0
  1066. package/dist/src/services/trust-broadcast.d.ts.map +1 -0
  1067. package/dist/src/services/trust-broadcast.js +107 -0
  1068. package/dist/src/services/trust-broadcast.js.map +1 -0
  1069. package/dist/src/services/trust.d.ts +16 -0
  1070. package/dist/src/services/trust.d.ts.map +1 -0
  1071. package/dist/src/services/trust.js +109 -0
  1072. package/dist/src/services/trust.js.map +1 -0
  1073. package/dist/src/services/vc-issuer.d.ts +14 -0
  1074. package/dist/src/services/vc-issuer.d.ts.map +1 -0
  1075. package/dist/src/services/vc-issuer.js +24 -0
  1076. package/dist/src/services/vc-issuer.js.map +1 -0
  1077. package/dist/src/storage/interface.d.ts +1161 -0
  1078. package/dist/src/storage/interface.d.ts.map +1 -0
  1079. package/dist/src/storage/interface.js +2 -0
  1080. package/dist/src/storage/interface.js.map +1 -0
  1081. package/dist/src/storage/pattern-utils.d.ts +20 -0
  1082. package/dist/src/storage/pattern-utils.d.ts.map +1 -0
  1083. package/dist/src/storage/pattern-utils.js +57 -0
  1084. package/dist/src/storage/pattern-utils.js.map +1 -0
  1085. package/dist/src/storage/providers/mongodb/index.d.ts +608 -0
  1086. package/dist/src/storage/providers/mongodb/index.d.ts.map +1 -0
  1087. package/dist/src/storage/providers/mongodb/index.js +4931 -0
  1088. package/dist/src/storage/providers/mongodb/index.js.map +1 -0
  1089. package/dist/src/storage/providers/sqlite/index.d.ts +602 -0
  1090. package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -0
  1091. package/dist/src/storage/providers/sqlite/index.js +4156 -0
  1092. package/dist/src/storage/providers/sqlite/index.js.map +1 -0
  1093. package/dist/src/storage/providers/sqlite/repos/action.d.ts +13 -0
  1094. package/dist/src/storage/providers/sqlite/repos/action.d.ts.map +1 -0
  1095. package/dist/src/storage/providers/sqlite/repos/action.js +79 -0
  1096. package/dist/src/storage/providers/sqlite/repos/action.js.map +1 -0
  1097. package/dist/src/storage/providers/sqlite/repos/agent.d.ts +13 -0
  1098. package/dist/src/storage/providers/sqlite/repos/agent.d.ts.map +1 -0
  1099. package/dist/src/storage/providers/sqlite/repos/agent.js +103 -0
  1100. package/dist/src/storage/providers/sqlite/repos/agent.js.map +1 -0
  1101. package/dist/src/storage/providers/sqlite/repos/auth.d.ts +56 -0
  1102. package/dist/src/storage/providers/sqlite/repos/auth.d.ts.map +1 -0
  1103. package/dist/src/storage/providers/sqlite/repos/auth.js +282 -0
  1104. package/dist/src/storage/providers/sqlite/repos/auth.js.map +1 -0
  1105. package/dist/src/storage/providers/sqlite/repos/board.d.ts +24 -0
  1106. package/dist/src/storage/providers/sqlite/repos/board.d.ts.map +1 -0
  1107. package/dist/src/storage/providers/sqlite/repos/board.js +154 -0
  1108. package/dist/src/storage/providers/sqlite/repos/board.js.map +1 -0
  1109. package/dist/src/storage/providers/sqlite/repos/community.d.ts +33 -0
  1110. package/dist/src/storage/providers/sqlite/repos/community.d.ts.map +1 -0
  1111. package/dist/src/storage/providers/sqlite/repos/community.js +202 -0
  1112. package/dist/src/storage/providers/sqlite/repos/community.js.map +1 -0
  1113. package/dist/src/storage/providers/sqlite/repos/consent.d.ts +23 -0
  1114. package/dist/src/storage/providers/sqlite/repos/consent.d.ts.map +1 -0
  1115. package/dist/src/storage/providers/sqlite/repos/consent.js +187 -0
  1116. package/dist/src/storage/providers/sqlite/repos/consent.js.map +1 -0
  1117. package/dist/src/storage/providers/sqlite/repos/dispute.d.ts +20 -0
  1118. package/dist/src/storage/providers/sqlite/repos/dispute.d.ts.map +1 -0
  1119. package/dist/src/storage/providers/sqlite/repos/dispute.js +118 -0
  1120. package/dist/src/storage/providers/sqlite/repos/dispute.js.map +1 -0
  1121. package/dist/src/storage/providers/sqlite/repos/flag.d.ts +26 -0
  1122. package/dist/src/storage/providers/sqlite/repos/flag.d.ts.map +1 -0
  1123. package/dist/src/storage/providers/sqlite/repos/flag.js +147 -0
  1124. package/dist/src/storage/providers/sqlite/repos/flag.js.map +1 -0
  1125. package/dist/src/storage/providers/sqlite/repos/identity.d.ts +36 -0
  1126. package/dist/src/storage/providers/sqlite/repos/identity.d.ts.map +1 -0
  1127. package/dist/src/storage/providers/sqlite/repos/identity.js +297 -0
  1128. package/dist/src/storage/providers/sqlite/repos/identity.js.map +1 -0
  1129. package/dist/src/storage/providers/sqlite/repos/mailbox.d.ts +18 -0
  1130. package/dist/src/storage/providers/sqlite/repos/mailbox.d.ts.map +1 -0
  1131. package/dist/src/storage/providers/sqlite/repos/mailbox.js +91 -0
  1132. package/dist/src/storage/providers/sqlite/repos/mailbox.js.map +1 -0
  1133. package/dist/src/storage/providers/sqlite/repos/memory.d.ts +28 -0
  1134. package/dist/src/storage/providers/sqlite/repos/memory.d.ts.map +1 -0
  1135. package/dist/src/storage/providers/sqlite/repos/memory.js +152 -0
  1136. package/dist/src/storage/providers/sqlite/repos/memory.js.map +1 -0
  1137. package/dist/src/storage/providers/sqlite/repos/owner.d.ts +14 -0
  1138. package/dist/src/storage/providers/sqlite/repos/owner.d.ts.map +1 -0
  1139. package/dist/src/storage/providers/sqlite/repos/owner.js +124 -0
  1140. package/dist/src/storage/providers/sqlite/repos/owner.js.map +1 -0
  1141. package/dist/src/storage/providers/sqlite/repos/service-manifest.d.ts +17 -0
  1142. package/dist/src/storage/providers/sqlite/repos/service-manifest.d.ts.map +1 -0
  1143. package/dist/src/storage/providers/sqlite/repos/service-manifest.js +114 -0
  1144. package/dist/src/storage/providers/sqlite/repos/service-manifest.js.map +1 -0
  1145. package/dist/src/storage/providers/sqlite/repos/storage-file.d.ts +19 -0
  1146. package/dist/src/storage/providers/sqlite/repos/storage-file.d.ts.map +1 -0
  1147. package/dist/src/storage/providers/sqlite/repos/storage-file.js +128 -0
  1148. package/dist/src/storage/providers/sqlite/repos/storage-file.js.map +1 -0
  1149. package/dist/src/storage/providers/sqlite/repos/work.d.ts +13 -0
  1150. package/dist/src/storage/providers/sqlite/repos/work.d.ts.map +1 -0
  1151. package/dist/src/storage/providers/sqlite/repos/work.js +86 -0
  1152. package/dist/src/storage/providers/sqlite/repos/work.js.map +1 -0
  1153. package/dist/src/storage/providers/sqlite/schema.d.ts +7 -0
  1154. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -0
  1155. package/dist/src/storage/providers/sqlite/schema.js +1090 -0
  1156. package/dist/src/storage/providers/sqlite/schema.js.map +1 -0
  1157. package/dist/src/storage/repositories/action.repository.d.ts +14 -0
  1158. package/dist/src/storage/repositories/action.repository.d.ts.map +1 -0
  1159. package/dist/src/storage/repositories/action.repository.js +2 -0
  1160. package/dist/src/storage/repositories/action.repository.js.map +1 -0
  1161. package/dist/src/storage/repositories/agent.repository.d.ts +18 -0
  1162. package/dist/src/storage/repositories/agent.repository.d.ts.map +1 -0
  1163. package/dist/src/storage/repositories/agent.repository.js +2 -0
  1164. package/dist/src/storage/repositories/agent.repository.js.map +1 -0
  1165. package/dist/src/storage/repositories/app-marketplace.repository.d.ts +9 -0
  1166. package/dist/src/storage/repositories/app-marketplace.repository.d.ts.map +1 -0
  1167. package/dist/src/storage/repositories/app-marketplace.repository.js +2 -0
  1168. package/dist/src/storage/repositories/app-marketplace.repository.js.map +1 -0
  1169. package/dist/src/storage/repositories/app.repository.d.ts +17 -0
  1170. package/dist/src/storage/repositories/app.repository.d.ts.map +1 -0
  1171. package/dist/src/storage/repositories/app.repository.js +2 -0
  1172. package/dist/src/storage/repositories/app.repository.js.map +1 -0
  1173. package/dist/src/storage/repositories/auth.repository.d.ts +6 -0
  1174. package/dist/src/storage/repositories/auth.repository.d.ts.map +1 -0
  1175. package/dist/src/storage/repositories/auth.repository.js +2 -0
  1176. package/dist/src/storage/repositories/auth.repository.js.map +1 -0
  1177. package/dist/src/storage/repositories/board.repository.d.ts +27 -0
  1178. package/dist/src/storage/repositories/board.repository.d.ts.map +1 -0
  1179. package/dist/src/storage/repositories/board.repository.js +2 -0
  1180. package/dist/src/storage/repositories/board.repository.js.map +1 -0
  1181. package/dist/src/storage/repositories/catalogue.repository.d.ts +18 -0
  1182. package/dist/src/storage/repositories/catalogue.repository.d.ts.map +1 -0
  1183. package/dist/src/storage/repositories/catalogue.repository.js +2 -0
  1184. package/dist/src/storage/repositories/catalogue.repository.js.map +1 -0
  1185. package/dist/src/storage/repositories/config.repository.d.ts +17 -0
  1186. package/dist/src/storage/repositories/config.repository.d.ts.map +1 -0
  1187. package/dist/src/storage/repositories/config.repository.js +2 -0
  1188. package/dist/src/storage/repositories/config.repository.js.map +1 -0
  1189. package/dist/src/storage/repositories/consent.repository.d.ts +19 -0
  1190. package/dist/src/storage/repositories/consent.repository.d.ts.map +1 -0
  1191. package/dist/src/storage/repositories/consent.repository.js +2 -0
  1192. package/dist/src/storage/repositories/consent.repository.js.map +1 -0
  1193. package/dist/src/storage/repositories/device-auth.repository.d.ts +11 -0
  1194. package/dist/src/storage/repositories/device-auth.repository.d.ts.map +1 -0
  1195. package/dist/src/storage/repositories/device-auth.repository.js +2 -0
  1196. package/dist/src/storage/repositories/device-auth.repository.js.map +1 -0
  1197. package/dist/src/storage/repositories/dispute.repository.d.ts +12 -0
  1198. package/dist/src/storage/repositories/dispute.repository.d.ts.map +1 -0
  1199. package/dist/src/storage/repositories/dispute.repository.js +2 -0
  1200. package/dist/src/storage/repositories/dispute.repository.js.map +1 -0
  1201. package/dist/src/storage/repositories/extension-instance.repository.d.ts +9 -0
  1202. package/dist/src/storage/repositories/extension-instance.repository.d.ts.map +1 -0
  1203. package/dist/src/storage/repositories/extension-instance.repository.js +2 -0
  1204. package/dist/src/storage/repositories/extension-instance.repository.js.map +1 -0
  1205. package/dist/src/storage/repositories/federation.repository.d.ts +37 -0
  1206. package/dist/src/storage/repositories/federation.repository.d.ts.map +1 -0
  1207. package/dist/src/storage/repositories/federation.repository.js +2 -0
  1208. package/dist/src/storage/repositories/federation.repository.js.map +1 -0
  1209. package/dist/src/storage/repositories/file.repository.d.ts +14 -0
  1210. package/dist/src/storage/repositories/file.repository.d.ts.map +1 -0
  1211. package/dist/src/storage/repositories/file.repository.js +2 -0
  1212. package/dist/src/storage/repositories/file.repository.js.map +1 -0
  1213. package/dist/src/storage/repositories/identity.repository.d.ts +29 -0
  1214. package/dist/src/storage/repositories/identity.repository.d.ts.map +1 -0
  1215. package/dist/src/storage/repositories/identity.repository.js +2 -0
  1216. package/dist/src/storage/repositories/identity.repository.js.map +1 -0
  1217. package/dist/src/storage/repositories/index.d.ts +34 -0
  1218. package/dist/src/storage/repositories/index.d.ts.map +1 -0
  1219. package/dist/src/storage/repositories/index.js +2 -0
  1220. package/dist/src/storage/repositories/index.js.map +1 -0
  1221. package/dist/src/storage/repositories/knowledge.repository.d.ts +18 -0
  1222. package/dist/src/storage/repositories/knowledge.repository.d.ts.map +1 -0
  1223. package/dist/src/storage/repositories/knowledge.repository.js +2 -0
  1224. package/dist/src/storage/repositories/knowledge.repository.js.map +1 -0
  1225. package/dist/src/storage/repositories/marketplace.repository.d.ts +23 -0
  1226. package/dist/src/storage/repositories/marketplace.repository.d.ts.map +1 -0
  1227. package/dist/src/storage/repositories/marketplace.repository.js +2 -0
  1228. package/dist/src/storage/repositories/marketplace.repository.js.map +1 -0
  1229. package/dist/src/storage/repositories/memory.repository.d.ts +32 -0
  1230. package/dist/src/storage/repositories/memory.repository.d.ts.map +1 -0
  1231. package/dist/src/storage/repositories/memory.repository.js +2 -0
  1232. package/dist/src/storage/repositories/memory.repository.js.map +1 -0
  1233. package/dist/src/storage/repositories/micro-memory.repository.d.ts +10 -0
  1234. package/dist/src/storage/repositories/micro-memory.repository.d.ts.map +1 -0
  1235. package/dist/src/storage/repositories/micro-memory.repository.js +2 -0
  1236. package/dist/src/storage/repositories/micro-memory.repository.js.map +1 -0
  1237. package/dist/src/storage/repositories/moderation.repository.d.ts +36 -0
  1238. package/dist/src/storage/repositories/moderation.repository.d.ts.map +1 -0
  1239. package/dist/src/storage/repositories/moderation.repository.js +2 -0
  1240. package/dist/src/storage/repositories/moderation.repository.js.map +1 -0
  1241. package/dist/src/storage/repositories/node.repository.d.ts +59 -0
  1242. package/dist/src/storage/repositories/node.repository.d.ts.map +1 -0
  1243. package/dist/src/storage/repositories/node.repository.js +2 -0
  1244. package/dist/src/storage/repositories/node.repository.js.map +1 -0
  1245. package/dist/src/storage/repositories/notification-template.repository.d.ts +8 -0
  1246. package/dist/src/storage/repositories/notification-template.repository.d.ts.map +1 -0
  1247. package/dist/src/storage/repositories/notification-template.repository.js +2 -0
  1248. package/dist/src/storage/repositories/notification-template.repository.js.map +1 -0
  1249. package/dist/src/storage/repositories/notification.repository.d.ts +14 -0
  1250. package/dist/src/storage/repositories/notification.repository.d.ts.map +1 -0
  1251. package/dist/src/storage/repositories/notification.repository.js +2 -0
  1252. package/dist/src/storage/repositories/notification.repository.js.map +1 -0
  1253. package/dist/src/storage/repositories/oauth.repository.d.ts +19 -0
  1254. package/dist/src/storage/repositories/oauth.repository.d.ts.map +1 -0
  1255. package/dist/src/storage/repositories/oauth.repository.js +2 -0
  1256. package/dist/src/storage/repositories/oauth.repository.js.map +1 -0
  1257. package/dist/src/storage/repositories/organism.repository.d.ts +34 -0
  1258. package/dist/src/storage/repositories/organism.repository.d.ts.map +1 -0
  1259. package/dist/src/storage/repositories/organism.repository.js +2 -0
  1260. package/dist/src/storage/repositories/organism.repository.js.map +1 -0
  1261. package/dist/src/storage/repositories/otk.repository.d.ts +9 -0
  1262. package/dist/src/storage/repositories/otk.repository.d.ts.map +1 -0
  1263. package/dist/src/storage/repositories/otk.repository.js +2 -0
  1264. package/dist/src/storage/repositories/otk.repository.js.map +1 -0
  1265. package/dist/src/storage/repositories/owner.repository.d.ts +9 -0
  1266. package/dist/src/storage/repositories/owner.repository.d.ts.map +1 -0
  1267. package/dist/src/storage/repositories/owner.repository.js +2 -0
  1268. package/dist/src/storage/repositories/owner.repository.js.map +1 -0
  1269. package/dist/src/storage/repositories/package-instance.repository.d.ts +26 -0
  1270. package/dist/src/storage/repositories/package-instance.repository.d.ts.map +1 -0
  1271. package/dist/src/storage/repositories/package-instance.repository.js +12 -0
  1272. package/dist/src/storage/repositories/package-instance.repository.js.map +1 -0
  1273. package/dist/src/storage/repositories/package.repository.d.ts +28 -0
  1274. package/dist/src/storage/repositories/package.repository.d.ts.map +1 -0
  1275. package/dist/src/storage/repositories/package.repository.js +12 -0
  1276. package/dist/src/storage/repositories/package.repository.js.map +1 -0
  1277. package/dist/src/storage/repositories/replication-queue.repository.d.ts +10 -0
  1278. package/dist/src/storage/repositories/replication-queue.repository.d.ts.map +1 -0
  1279. package/dist/src/storage/repositories/replication-queue.repository.js +2 -0
  1280. package/dist/src/storage/repositories/replication-queue.repository.js.map +1 -0
  1281. package/dist/src/storage/repositories/scheduler.repository.d.ts +30 -0
  1282. package/dist/src/storage/repositories/scheduler.repository.d.ts.map +1 -0
  1283. package/dist/src/storage/repositories/scheduler.repository.js +2 -0
  1284. package/dist/src/storage/repositories/scheduler.repository.js.map +1 -0
  1285. package/dist/src/storage/repositories/schema.repository.d.ts +9 -0
  1286. package/dist/src/storage/repositories/schema.repository.d.ts.map +1 -0
  1287. package/dist/src/storage/repositories/schema.repository.js +2 -0
  1288. package/dist/src/storage/repositories/schema.repository.js.map +1 -0
  1289. package/dist/src/storage/repositories/session.repository.d.ts +22 -0
  1290. package/dist/src/storage/repositories/session.repository.d.ts.map +1 -0
  1291. package/dist/src/storage/repositories/session.repository.js +2 -0
  1292. package/dist/src/storage/repositories/session.repository.js.map +1 -0
  1293. package/dist/src/storage/repositories/system-prompt.repository.d.ts +14 -0
  1294. package/dist/src/storage/repositories/system-prompt.repository.d.ts.map +1 -0
  1295. package/dist/src/storage/repositories/system-prompt.repository.js +2 -0
  1296. package/dist/src/storage/repositories/system-prompt.repository.js.map +1 -0
  1297. package/dist/src/storage/repositories/template-listing.repository.d.ts +44 -0
  1298. package/dist/src/storage/repositories/template-listing.repository.d.ts.map +1 -0
  1299. package/dist/src/storage/repositories/template-listing.repository.js +13 -0
  1300. package/dist/src/storage/repositories/template-listing.repository.js.map +1 -0
  1301. package/dist/src/storage/repositories/wallet.repository.d.ts +8 -0
  1302. package/dist/src/storage/repositories/wallet.repository.d.ts.map +1 -0
  1303. package/dist/src/storage/repositories/wallet.repository.js +2 -0
  1304. package/dist/src/storage/repositories/wallet.repository.js.map +1 -0
  1305. package/dist/src/storage/repositories/work.repository.d.ts +10 -0
  1306. package/dist/src/storage/repositories/work.repository.d.ts.map +1 -0
  1307. package/dist/src/storage/repositories/work.repository.js +2 -0
  1308. package/dist/src/storage/repositories/work.repository.js.map +1 -0
  1309. package/dist/src/storage/storage-factory.d.ts +9 -0
  1310. package/dist/src/storage/storage-factory.d.ts.map +1 -0
  1311. package/dist/src/storage/storage-factory.js +20 -0
  1312. package/dist/src/storage/storage-factory.js.map +1 -0
  1313. package/dist/src/types/route-manifest.d.ts +53 -0
  1314. package/dist/src/types/route-manifest.d.ts.map +1 -0
  1315. package/dist/src/types/route-manifest.js +44 -0
  1316. package/dist/src/types/route-manifest.js.map +1 -0
  1317. package/dist/src/utils/catalogue-hash.d.ts +10 -0
  1318. package/dist/src/utils/catalogue-hash.d.ts.map +1 -0
  1319. package/dist/src/utils/catalogue-hash.js +23 -0
  1320. package/dist/src/utils/catalogue-hash.js.map +1 -0
  1321. package/dist/src/utils/env-config.d.ts +8 -0
  1322. package/dist/src/utils/env-config.d.ts.map +1 -0
  1323. package/dist/src/utils/env-config.js +1264 -0
  1324. package/dist/src/utils/env-config.js.map +1 -0
  1325. package/dist/src/utils/env-validator.d.ts +14 -0
  1326. package/dist/src/utils/env-validator.d.ts.map +1 -0
  1327. package/dist/src/utils/env-validator.js +338 -0
  1328. package/dist/src/utils/env-validator.js.map +1 -0
  1329. package/dist/src/utils/fire-hook.d.ts +9 -0
  1330. package/dist/src/utils/fire-hook.d.ts.map +1 -0
  1331. package/dist/src/utils/fire-hook.js +12 -0
  1332. package/dist/src/utils/fire-hook.js.map +1 -0
  1333. package/dist/src/utils/gaii.d.ts +57 -0
  1334. package/dist/src/utils/gaii.d.ts.map +1 -0
  1335. package/dist/src/utils/gaii.js +148 -0
  1336. package/dist/src/utils/gaii.js.map +1 -0
  1337. package/dist/src/utils/ghii-resolver.d.ts +14 -0
  1338. package/dist/src/utils/ghii-resolver.d.ts.map +1 -0
  1339. package/dist/src/utils/ghii-resolver.js +21 -0
  1340. package/dist/src/utils/ghii-resolver.js.map +1 -0
  1341. package/dist/src/utils/logger.d.ts +9 -0
  1342. package/dist/src/utils/logger.d.ts.map +1 -0
  1343. package/dist/src/utils/logger.js +36 -0
  1344. package/dist/src/utils/logger.js.map +1 -0
  1345. package/dist/src/utils/otk.d.ts +2 -0
  1346. package/dist/src/utils/otk.d.ts.map +1 -0
  1347. package/dist/src/utils/otk.js +5 -0
  1348. package/dist/src/utils/otk.js.map +1 -0
  1349. package/dist/src/utils/tracking-code.d.ts +9 -0
  1350. package/dist/src/utils/tracking-code.d.ts.map +1 -0
  1351. package/dist/src/utils/tracking-code.js +16 -0
  1352. package/dist/src/utils/tracking-code.js.map +1 -0
  1353. package/dist/src/utils/url-validator.d.ts +5 -0
  1354. package/dist/src/utils/url-validator.d.ts.map +1 -0
  1355. package/dist/src/utils/url-validator.js +56 -0
  1356. package/dist/src/utils/url-validator.js.map +1 -0
  1357. package/dist/static/app-catalog.html +4401 -0
  1358. package/dist/static/cookieconsent.css +1 -0
  1359. package/dist/static/cookieconsent.umd.js +7 -0
  1360. package/dist/static/icons/icon-maskable.svg +27 -0
  1361. package/dist/static/icons/icon.svg +27 -0
  1362. package/dist/static/manifest.json +17 -0
  1363. package/dist/static/offline.html +167 -0
  1364. package/dist/static/sw.js +260 -0
  1365. package/package.json +182 -0
  1366. package/prisma/schema.prisma +1086 -0
@@ -0,0 +1,2187 @@
1
+ /**
2
+ * @file foundry-prompts-build.js
3
+ * @description Build prompts for the service foundry — blueprint analysis,
4
+ * structured interview, and per-component-type generation prompts.
5
+ * @structure
6
+ * - buildBlueprintPrompt: produces blueprint generation prompt
7
+ * - buildInterviewPrompt: produces requirements interview conductor prompt
8
+ * - buildComponentPrompt: per-type component generation prompt dispatcher
9
+ * @usage
10
+ * import { buildBlueprintPrompt, buildInterviewPrompt, buildComponentPrompt } from '/js/services/foundry-prompts-build.js';
11
+ * @version-history
12
+ * v1.0.0 — 2026-03-22 — Extracted from foundry-prompts.js
13
+ * v1.1.0 — 2026-03-24 — Add API URL usage rules + notes to extension data source details
14
+ * v2.0.0 — 2026-03-26 — Add skeleton prompt builders for multi-pass pipeline:
15
+ * buildSkeletonPrompt (dispatcher), buildExtensionSkeletonPrompt,
16
+ * buildDataCortexSkeletonPrompt, buildFeatureCortexSkeletonPrompt,
17
+ * buildAppDomainCortexSkeletonPrompt, buildAppSkeletonPrompt
18
+ * v3.0.0 — 2026-03-26 — Add unit fill + assembly prompt builders:
19
+ * buildExtensionUnitPrompt, buildCortexMethodUnitPrompt,
20
+ * buildFeatureCortexSectionPrompt, buildAppViewUnitPrompt,
21
+ * buildExtensionAssemblyPrompt, buildCortexAssemblyPrompt,
22
+ * buildAppAssemblyPrompt
23
+ * v3.1.0 — 2026-03-28 — Critical prompt fixes from pipeline test:
24
+ * - callExt: switched from raw fetch() to session.fetch() for proper auth
25
+ * - Extension assembly: added author/method/path fields, export default signature
26
+ * - App assembly: added full boot sequence with loadScript, auth, error collector
27
+ * - Cortex assembly: added readExtMemory, t(), dv() helpers
28
+ * - Feature sections: added default platform UI examples, async data loading pattern
29
+ * - App-domain skeleton: added mountLoginButton pattern, dv() helper
30
+ * - All assemblies: added HTML_ENTITY_RULES
31
+ */
32
+
33
+ import { AIMEAT_CONTEXT, INSTRUCTION_DISCLAIMER, COMPONENT_TEMPLATES, EXTENSION_CONSUMPTION_RULES, HTML_ENTITY_RULES, SANDBOX_CONSTRAINTS, summarizeExtensionApi, summarizeCortexApi } from './foundry-prompts-base.js';
34
+
35
+ // Cortex prompt modules — eagerly loaded in browser, skipped on server.
36
+ // The modules are cached after first dynamic import.
37
+ let _cortexModules = null;
38
+ let _cortexModulesPromise = null;
39
+
40
+ // Pre-load cortex modules in background — awaited in buildComponentPrompt if needed
41
+ if (typeof window !== 'undefined') {
42
+ _cortexModulesPromise = Promise.all([
43
+ import('./foundry-prompts-cortex-data.js'),
44
+ import('./foundry-prompts-cortex-feature.js'),
45
+ import('./foundry-prompts-cortex-app.js'),
46
+ import('./foundry-context-bundle.js'),
47
+ ]).then(([data, feature, app, bundle]) => {
48
+ _cortexModules = {
49
+ buildDataCortexPrompt: data.buildDataCortexPrompt,
50
+ buildFeatureCortexPrompt: feature.buildFeatureCortexPrompt,
51
+ buildAppDomainCortexPrompt: app.buildAppDomainCortexPrompt,
52
+ createBundle: bundle.createBundle,
53
+ formatBundlesForPrompt: bundle.formatBundlesForPrompt,
54
+ };
55
+ return _cortexModules;
56
+ }).catch(() => { /* server-side or import failure — cortex prompts unavailable */ });
57
+ }
58
+
59
+ export function buildBlueprintPrompt(description, interviewSpec = null, availableCortexLibs = null) {
60
+ const specContext = interviewSpec ? `
61
+ ## Refined Specification (from requirements interview)
62
+ \`\`\`json
63
+ ${JSON.stringify(interviewSpec, null, 2)}
64
+ \`\`\`
65
+
66
+ Use the specification above to determine the exact components needed. The data sources, entities, views, and constraints have been validated with the user.
67
+
68
+ CRITICAL — Data shape fidelity: If the specification includes a sampleEntry, your dataModel structures MUST match its EXACT nested shape. If a field in sampleEntry is an object (e.g., businessId: { value: "123", registrationDate: "2025-01-01" }), model it as type "object" with those exact properties — do NOT flatten it to type "string". Copy the structure from sampleEntry, do not simplify it.
69
+
70
+ CRITICAL — Feature count: Count the distinct views/screens described in the specification (e.g., search, detail, watchlist, changes, comparison, settings). Each one becomes its OWN feature cortex component. If the spec describes 6 views, you MUST create 6 feature cortexes — not fewer.
71
+ ` : '';
72
+
73
+ // Build cortex catalog if available
74
+ let cortexCatalog = '';
75
+ if (availableCortexLibs && availableCortexLibs.length > 0) {
76
+ cortexCatalog = `
77
+ ## Available Cortex Libraries (reuse these — do NOT recreate)
78
+
79
+ The following cortex libraries are already installed on this node. If the project needs their capabilities, reference them in the cortex component's "uses" field instead of reimplementing.
80
+
81
+ ${availableCortexLibs.map(lib => {
82
+ const libComps = (lib.components || []).filter(c => c.type === 'lib');
83
+ const exports = libComps.map(c => c.exports || []).flat();
84
+ const apiSurface = libComps.map(c => c.api_surface || '').filter(Boolean).join('\n');
85
+ return `### ${lib.name} — ${lib.description || 'no description'}
86
+ - **Exports:** ${exports.join(', ') || 'none'}
87
+ ${apiSurface ? `- **API:**\n\`\`\`\n${apiSurface.trim()}\n\`\`\`` : ''}
88
+ - **Load:** \`<script src="/v1/cortex/${lib.name}/libs/${libComps[0]?.filename || lib.name + '.js'}"></script>\``;
89
+ }).join('\n\n')}
90
+
91
+ When the blueprint's cortex component needs an existing library, add a "uses" field listing the library names:
92
+ { "id": "cortex-1", "type": "cortex", "label": "...", "produces": [...], "consumes": [...], "uses": ["aimeat-charts"] }
93
+
94
+ The generated cortex should load the used library via <script> and call its API (e.g., AIMEAT.charts.ChartBuilder) — NOT reimplement chart rendering.
95
+ `;
96
+ }
97
+
98
+ // Thread language from interview spec to blueprint prompt
99
+ const specLocale = interviewSpec?.locale;
100
+ const langNote = specLocale && specLocale !== 'en'
101
+ ? `\n## LANGUAGE\n\nThe user's language is "${specLocale}". Write all human-readable labels and descriptions in that language.\nJSON keys and technical identifiers stay in English.\n`
102
+ : '';
103
+
104
+ return `${INSTRUCTION_DISCLAIMER}${AIMEAT_CONTEXT}
105
+
106
+ # Your Task
107
+
108
+ The user wants to create this service:
109
+ ---
110
+ ${description}
111
+ ---
112
+ ${specContext}${langNote}${cortexCatalog}
113
+ Analyze this request and produce a JSON blueprint — a lightweight plan that lists all components needed to build this service. Actual code and content are generated later, per component.
114
+
115
+ Return ONLY a raw JSON object. NO markdown fences (\`\`\`json). NO explanatory text before or after. The output must parse as valid JSON directly.
116
+
117
+ ---
118
+
119
+ # Step 1: Understand the Architecture
120
+
121
+ Every AIMEAT service follows a layered architecture called "cortex-modular". Read each layer bottom-to-top — each layer depends only on the layer below it.
122
+
123
+ **Layer 1 — Foundation** (runs first, no dependencies)
124
+ - \`csm\` — service schema definition
125
+ - \`memory\` — pre-loaded settings and static data
126
+ - \`translation\` — one component per locale (fi, en, etc.)
127
+
128
+ **Layer 2 — Extension** (server-side only)
129
+ - Fetches data from external APIs via \`ctx.fetch()\`
130
+ - Runs scheduled background jobs (cron)
131
+ - Stores results in memory via \`ctx.memory.set()\`
132
+ - ONLY for work that REQUIRES the server. If a browser can do it, it does NOT belong here.
133
+
134
+ **Layer 3 — Cortex** (client-side, layered into three subtypes)
135
+ - **data** — reads extension memory + platform APIs, exposes a clean domain API
136
+ - **feature** — one per UI feature (search, detail, settings, etc.), self-contained data+UI
137
+ - **app-domain** — composes all features + auth + translations, single entry point
138
+
139
+ **Layer 4 — App** (client-side)
140
+ - Loads app-domain cortex, wires navigation, handles layout
141
+
142
+ The blueprint declares components in this order. Phases group them into build stages that match these layers.
143
+
144
+ ---
145
+
146
+ # Step 2: Decide What Components You Need
147
+
148
+ Walk through these questions in order:
149
+
150
+ **2a. What data does the service need?**
151
+ - External API data → create an \`extension\` component
152
+ - User-provided static data (lookup tables, reference sets) → create a \`memory\` component
153
+ - Default settings/config → create a \`memory\` component
154
+ - Translations → create one \`translation\` per locale
155
+
156
+ **2b. What does the extension do?**
157
+ Only create extension actions for server-required work:
158
+ - Fetching from external APIs (CORS, auth, server-to-server) → YES
159
+ - Scheduled background jobs (nightly data collection) → YES
160
+ - Filtering, sorting, computing, exporting → NO (cortex or app does this)
161
+ - Reading/writing settings or preferences → NO (cortex wraps memory)
162
+
163
+ **2c. What features does the UI have?**
164
+ Every distinct user-facing capability described in the specification MUST become its own feature cortex component. One view = one feature cortex. Do NOT merge or consolidate features.
165
+
166
+ Count the views in the spec: if it mentions search, detail view, watchlist, change history, comparison, and settings — that is 6 separate feature cortexes, not 3 or 4. Create ALL of them.
167
+
168
+ WRONG: "cortex-feature-search" that produces ["ui:searchView", "ui:detailView"]
169
+ CORRECT: separate "cortex-feature-search" and "cortex-feature-detail"
170
+
171
+ If the service has user-configurable settings (language, notifications, preferences), you MUST include a Settings feature cortex.
172
+
173
+ **2d. Verify the data pipeline.**
174
+ For each feature, trace: what data does it display → where does that data come from → which component produces it? Every field must have a path from source to screen. If a field has no path, add the component that produces it.
175
+
176
+ ---
177
+
178
+ # Step 3: Build the JSON
179
+
180
+ The output has these top-level keys: "architecture", "components", "phases", "dataModel", and optionally "settings" and "testScenarios".
181
+
182
+ ## 3a. Components
183
+
184
+ Each component is an object with: "id", "type", "label", "produces", "consumes".
185
+
186
+ **ID format:** \`{short-type}-{number}\` or \`cortex-{subtype}\` / \`cortex-feature-{name}\`.
187
+ Examples: csm-1, memory-1, ext-1, cortex-data, cortex-feature-search, cortex-app, app-1
188
+ The "id" prefix can be short (\`ext-1\`) but "type" MUST be the full name (\`"extension"\`, not \`"ext"\`).
189
+
190
+ **Component types and their fields:**
191
+
192
+ \`csm\` — service schema. Produces: ["memory:service.schema"]. Consumes: [].
193
+
194
+ \`memory\` — pre-loaded data. Produces: ["memory:{key}"]. Consumes: [].
195
+ Create one for default settings (\`settings.config\`) and one per static dataset.
196
+
197
+ \`translation\` — one per locale. NEVER combine locales.
198
+ translation-1 produces ["memory:i18n.fi"], translation-2 produces ["memory:i18n.en"].
199
+
200
+ \`extension\` — server-side logic. May have "schedules" field.
201
+ Produces: ["memory:{key}"] for each data it stores.
202
+ Consumes: ["memory:settings.config"] if it reads settings.
203
+ Schedules: array of { "action": "actionName", "cron": "expression" }
204
+ - "@activate" — runs on activation + every restart. Use for init/bootstrap. Must be idempotent.
205
+ - Cron: exactly 5 fields. "0 2 * * *" (daily 02:00), "*/15 * * * *" (every 15 min).
206
+ WRONG: "/15 * * * *" (missing asterisk), "0 2 * *" (4 fields).
207
+ If no scheduled actions, omit "schedules" entirely.
208
+
209
+ \`cortex\` — has additional "subtype" and "uses" fields.
210
+ subtype "data": produces ["api:methodName"], consumes ["memory:..."]
211
+ subtype "feature": produces ["ui:viewName"], consumes ["api:..."], uses: ["aimeat-ui-viewers", ...]
212
+ subtype "app-domain": produces ["api:init", "api:render"], consumes all ui:* views
213
+
214
+ \`app\` — final application. Produces: []. Consumes: ["api:init", "api:render"].
215
+
216
+ \`msm\` — ONLY for APIs requiring authentication/API keys. Public APIs do NOT need one.
217
+
218
+ **Produces/consumes format:**
219
+ Memory: "memory:{namespace}.{key}" — e.g., "memory:watchlist.items", "memory:changes.log"
220
+ API: "api:{methodName}" — e.g., "api:searchCompanies", "api:getSettings"
221
+ UI: "ui:{viewName}" — e.g., "ui:searchView", "ui:settingsView"
222
+ Every "consumes" entry must match a "produces" entry in another component.
223
+
224
+ ## 3b. Phases
225
+
226
+ Group components into ordered build stages. Always use this structure:
227
+
228
+ { "id": "define", "componentIds": ["csm-1"] }
229
+ { "id": "seed", "componentIds": ["memory-1", "translation-1", "translation-2"] }
230
+ { "id": "logic", "componentIds": ["ext-1"] }
231
+ { "id": "cortex-data", "componentIds": ["cortex-data"] }
232
+ { "id": "cortex-features", "componentIds": ["cortex-feature-*", ...all features...] }
233
+ { "id": "cortex-app", "componentIds": ["cortex-app"] }
234
+ { "id": "ui", "componentIds": ["app-1"] }
235
+
236
+ ## 3c. Data Model
237
+
238
+ The "dataModel" has three sections: "structures", "memoryKeys", and "actions".
239
+
240
+ **structures** — JSON Schema definitions for every domain entity. These are the single source of truth.
241
+ - Build from the interview's sampleEntry data — model the EXACT shapes from the verified API response.
242
+ - If the API returns a nested object (e.g., businessId: { value, registrationDate, source }), model it as type "object" with those properties. Do NOT flatten to type "string".
243
+ - All property names use English camelCase: "defaultLanguage", NOT "default_language".
244
+ - Use "$ref" to reference structures from memoryKeys and actions. Every "$ref" must match a key in "structures".
245
+
246
+ **memoryKeys** — one entry per memory key. Each has: type, properties/items, source, producedBy, consumedBy.
247
+ - "source": "static" (user data), "external" (API-fetched), "computed" (calculated), "config" (settings)
248
+ - "producedBy": exactly ONE component ID
249
+ - "consumedBy": array of component IDs that read this key
250
+ - Standard key names: "settings.config", "i18n.fi", "i18n.en", then domain-specific: "watchlist.items", "changes.log", "comparisons.saved"
251
+ - Do NOT invent custom namespace prefixes (no "prh.settings", no "app.config" — use "settings.config")
252
+
253
+ **actions** — extension and cortex actions with input/output schemas. Use "$ref" to reference structures.
254
+ - Extension actions: "ext:actionName"
255
+ - Cortex actions: "cortex:methodName"
256
+ - Extension and cortex actions passing the same data MUST reference the SAME structure.
257
+
258
+ ## 3d. Settings (optional)
259
+
260
+ If the InterviewSpec has settings, include them:
261
+
262
+ "settings": {
263
+ "service": [/* from interviewSpec.externalServices[].requiredSettings */],
264
+ "user": [/* from interviewSpec.userSettings — carry over key, type, label, default */]
265
+ }
266
+
267
+ User setting keys MUST use camelCase: "defaultLanguage", NOT "default_language".
268
+ Do not invent settings not in the InterviewSpec. If no settings, omit this section.
269
+
270
+ ## 3e. Test Scenarios (optional but recommended)
271
+
272
+ For each component that produces data:
273
+
274
+ "testScenarios": [{
275
+ "component": "ext-1",
276
+ "scenarios": [
277
+ { "action": "init", "input": {}, "expect": "Initializes memory structures", "type": "memory" },
278
+ { "action": "search", "input": { "query": "test" }, "expect": "Returns results from API", "type": "external-api" }
279
+ ]
280
+ }]
281
+
282
+ Types: "memory" (ctx.memory only, assert exact values) vs "external-api" (ctx.fetch, check shape only — API may be down).
283
+ Use real example values, not placeholders. Test the happy path.
284
+
285
+ ---
286
+
287
+ # Full Example
288
+
289
+ IMPORTANT: This example shows a MINIMAL blueprint with only 3 features. YOUR blueprint will likely have MORE features — one per distinct view or capability described in the specification. If the spec describes 6 views, create 6 feature cortexes. Do NOT limit yourself to the example's feature count.
290
+
291
+ NOTE: Labels in this example use the spec's language. YOUR labels must also match YOUR spec's language. JSON keys stay in English.
292
+
293
+ {
294
+ "architecture": "cortex-modular",
295
+ "components": [
296
+ { "id": "csm-1", "type": "csm", "label": "Palvelun skeema", "produces": ["memory:service.schema"], "consumes": [] },
297
+ { "id": "memory-1", "type": "memory", "label": "Oletusasetukset", "produces": ["memory:settings.config"], "consumes": [] },
298
+ { "id": "translation-1", "type": "translation", "label": "Käännökset (fi)", "produces": ["memory:i18n.fi"], "consumes": [] },
299
+ { "id": "translation-2", "type": "translation", "label": "Käännökset (en)", "produces": ["memory:i18n.en"], "consumes": [] },
300
+ { "id": "ext-1", "type": "extension", "label": "Tietojen haku", "produces": ["memory:items.data"], "consumes": ["memory:settings.config"], "schedules": [{"action":"init","cron":"@activate"},{"action":"collect","cron":"0 2 * * *"}] },
301
+ { "id": "cortex-data", "type": "cortex", "subtype": "data", "label": "Tietokerros", "produces": ["api:getItem", "api:search", "api:getSettings", "api:saveSettings"], "consumes": ["memory:items.data", "memory:settings.config"], "uses": [] },
302
+ { "id": "cortex-feature-search", "type": "cortex", "subtype": "feature", "label": "Haku", "produces": ["ui:searchView"], "consumes": ["api:search"], "uses": ["aimeat-ui-viewers", "aimeat-ui-forms"] },
303
+ { "id": "cortex-feature-detail", "type": "cortex", "subtype": "feature", "label": "Tiedot", "produces": ["ui:detailView"], "consumes": ["api:getItem"], "uses": ["aimeat-ui-viewers"] },
304
+ { "id": "cortex-feature-settings", "type": "cortex", "subtype": "feature", "label": "Asetukset", "produces": ["ui:settingsView"], "consumes": ["api:getSettings", "api:saveSettings"], "uses": ["aimeat-ui-forms"] },
305
+ { "id": "cortex-app", "type": "cortex", "subtype": "app-domain", "label": "Sovelluskehys", "produces": ["api:init", "api:render"], "consumes": ["ui:searchView", "ui:detailView", "ui:settingsView"], "uses": ["aimeat-ui-nav"] },
306
+ { "id": "app-1", "type": "app", "label": "Sovellus", "produces": [], "consumes": ["api:init", "api:render"] }
307
+ ],
308
+ "phases": [
309
+ { "id": "define", "label": "Määrittely", "componentIds": ["csm-1"] },
310
+ { "id": "seed", "label": "Perustiedot", "componentIds": ["memory-1", "translation-1", "translation-2"] },
311
+ { "id": "logic", "label": "Taustalogiikka", "componentIds": ["ext-1"] },
312
+ { "id": "cortex-data", "label": "Tietokerros", "componentIds": ["cortex-data"] },
313
+ { "id": "cortex-features", "label": "Ominaisuudet", "componentIds": ["cortex-feature-search", "cortex-feature-detail", "cortex-feature-settings"] },
314
+ { "id": "cortex-app", "label": "Sovelluskehys", "componentIds": ["cortex-app"] },
315
+ { "id": "ui", "label": "Käyttöliittymä", "componentIds": ["app-1"] }
316
+ ],
317
+ "dataModel": {
318
+ "structures": {
319
+ "Item": {
320
+ "type": "object",
321
+ "properties": {
322
+ "id": { "type": "string" },
323
+ "title": { "type": "string" },
324
+ "status": { "type": "string" },
325
+ "createdAt": { "type": "string", "description": "ISO 8601" }
326
+ }
327
+ },
328
+ "SearchResult": {
329
+ "type": "object",
330
+ "properties": {
331
+ "totalResults": { "type": "number" },
332
+ "items": { "type": "array", "items": { "$ref": "Item" } }
333
+ }
334
+ }
335
+ },
336
+ "memoryKeys": {
337
+ "settings.config": {
338
+ "type": "object",
339
+ "properties": { "locale": { "type": "string" }, "refreshHours": { "type": "number" } },
340
+ "source": "config",
341
+ "producedBy": "memory-1",
342
+ "consumedBy": ["ext-1", "cortex-data"]
343
+ },
344
+ "items.data": {
345
+ "type": "array",
346
+ "items": { "$ref": "Item" },
347
+ "source": "external",
348
+ "producedBy": "ext-1",
349
+ "consumedBy": ["cortex-data"]
350
+ }
351
+ },
352
+ "actions": {
353
+ "ext:search": { "input": { "query": { "type": "string" } }, "output": { "$ref": "SearchResult" } },
354
+ "ext:getItem": { "input": { "id": { "type": "string" } }, "output": { "$ref": "Item" } },
355
+ "cortex:search": { "input": { "query": { "type": "string" } }, "output": { "$ref": "SearchResult" } },
356
+ "cortex:getItem": { "input": { "id": { "type": "string" } }, "output": { "$ref": "Item" } }
357
+ }
358
+ }
359
+ }
360
+
361
+ ---
362
+
363
+ # Pre-Generation Checklist
364
+
365
+ Before generating, verify:
366
+ - [ ] Each feature has its own cortex component (not merged)
367
+ - [ ] Settings feature cortex exists if user has configurable preferences
368
+ - [ ] Every "consumes" matches a "produces" in another component
369
+ - [ ] Data structures match the interview's sampleEntry shapes exactly (nested objects stay nested)
370
+ - [ ] All property names use camelCase (not snake_case)
371
+ - [ ] Memory keys use standard names: "settings.config", "i18n.{locale}", "{domain}.{key}"
372
+ - [ ] Memory keys do NOT have custom prefixes (no "prh.settings" — just "settings.config")
373
+ - [ ] Extension actions are only for server-required work (API calls, cron jobs)
374
+ - [ ] Cron expressions have exactly 5 fields
375
+ - [ ] Translation components: one per locale, never combined`;
376
+ }
377
+
378
+ /* ── Interview Prompt ──────────────────────────────────── */
379
+
380
+ /**
381
+ * Build an interview prompt that the user copies to AI Chat.
382
+ * AI Chat interviews the user and produces a structured JSON spec.
383
+ */
384
+ export function buildInterviewPrompt(description, locale = 'en') {
385
+ const langMap = { fi: 'Finnish (suomi)', en: 'English', sv: 'Swedish (svenska)', de: 'German (Deutsch)', fr: 'French (français)', es: 'Spanish (español)', ja: 'Japanese (日本語)', zh: 'Chinese (中文)' };
386
+ const langName = langMap[locale] || locale;
387
+ const langInstruction = locale !== 'en'
388
+ ? `\n## LANGUAGE\n\nCONDUCT THIS ENTIRE INTERVIEW IN ${langName.toUpperCase()}.\nAll your questions, summaries, options, and explanations must be in ${langName}.\nThe final JSON specification field values (descriptions, titles, notes) should also be in ${langName}.\nJSON keys and technical identifiers (field names, type values) stay in English.\nInclude "locale": "${locale}" in the output JSON root so downstream prompts continue in the same language.\n`
389
+ : '';
390
+
391
+ return `${INSTRUCTION_DISCLAIMER}You are a requirements analyst for the AIMEAT service foundry.
392
+ The user wants to build a service. Your job is to interview them to produce a clear, structured specification.
393
+ ${langInstruction}
394
+ ## User's Initial Description
395
+ ---
396
+ ${description}
397
+ ---
398
+
399
+ ## CRITICAL — Interview Discipline
400
+
401
+ QUESTION BUDGET: You have a maximum of 20 questions total across all sections.
402
+ Use cases get the most (up to 8), other sections 2-3 each. Batch related questions together.
403
+ Do NOT split every detail into a separate numbered question.
404
+
405
+ YOU DECIDE (never ask the user about these — the foundry handles them):
406
+ - Implementation details: file formats, data serialization, error handling, API design, caching
407
+ - Technical methods: how to fetch data, how to parse it, how to store it, how to compute derived values
408
+ - UI component details: which chart library, marker clustering, column ordering, widget placement
409
+ - Infrastructure: scheduler times, retention periods, timeout values, rate limits, job scheduling
410
+ - Data schema internals: field names, ID generation, deduplication strategy, index design
411
+ - Code-level choices: typography/font specifics, animation libraries, export format implementation
412
+ - Auth, login, user management, access control, user counts, audience size — AIMEAT handles all of these
413
+
414
+ The user describes WHAT they want and WHY. The foundry decides HOW.
415
+
416
+ ## Interview Rules
417
+
418
+ 1. ADAPT TO THE USER'S LEVEL:
419
+ - Start by asking: "Are you a technical person who'd prefer detailed technical questions, or would you like me to keep things simple and explain as we go?"
420
+ - If non-technical: ask simple questions with examples
421
+ - If technical: ask direct questions to speed things up
422
+
423
+ 2. COVER THESE AREAS (in order):
424
+ a) USE CASES — What will people actually do with this? (up to 8 questions)
425
+ This is the MOST IMPORTANT section. Spend time here.
426
+ - Propose 3-5 concrete use cases based on the description as selectable options (A, B, C, D)
427
+ - For each use case, include a one-sentence description of what it means in practice
428
+ - Let the user add their own use cases
429
+ - For must-have use cases, ask 1-2 clarifying questions about scope and defaults
430
+ - IMPORTANT: Do NOT move to the next section until the user confirms all use cases
431
+ - Ask: "Any other use cases, or shall we move on?"
432
+
433
+ b) DATA SOURCES — Where does the data come from? (2-3 questions)
434
+ - What external feeds/APIs/URLs does it use?
435
+ - Is any data user-generated or computed from other data?
436
+
437
+ URL VALIDATION PROTOCOL (MANDATORY for every external data source):
438
+ For EVERY URL the user mentions, follow this escalation path:
439
+
440
+ Step 1: YOU test it
441
+ - Try to fetch the URL and describe what you see
442
+ - If it works: capture one raw entry verbatim (RSS <item>, JSON object, etc.)
443
+ - Note encoding, content type, response structure, any auth requirements
444
+
445
+ Step 2: If YOU cannot access it, help the USER test it
446
+ - Say honestly: "I can't access this URL. Can you test it?"
447
+ - Give the user a concrete test command they can run:
448
+ curl -s "https://example.com/api/endpoint" | head -50
449
+ Or: "Open this URL in your browser and paste what you see"
450
+ - Ask the user to paste the response (or a representative sample)
451
+ - When they paste it, analyze the format and confirm you understand the structure
452
+
453
+ Step 3: If NEITHER can access it, decide TOGETHER what to do
454
+ - Present these options clearly:
455
+ A) SKIP this data source — remove use cases and features that depend on it
456
+ B) USE DEMO DATA — generate realistic mock data that gets loaded as static
457
+ data on first install. The app works immediately but shows example data.
458
+ Mark the data source as "demo" in the spec so extensions skip the fetch.
459
+ C) DEFER — keep the data source in the spec but mark it "unverified".
460
+ The extension will try to fetch it, but the app must handle gracefully
461
+ when no data is available (empty states, "data source unavailable" message)
462
+ - Let the user choose. If they pick B, help them define what realistic demo
463
+ data looks like (5-10 sample entries with realistic field values).
464
+ - If they pick A, immediately review use cases and remove any that fully
465
+ depend on the removed source. Confirm removals with the user.
466
+
467
+ HARD RULE: Never generate extension code that calls an unverified external URL.
468
+ Every URL in the final spec must have "verified": true (tested by AI or user)
469
+ or "verified": false with a "fallback" strategy ("demo", "defer", or "skip").
470
+
471
+ For VERIFIED sources:
472
+ - Capture at least ONE real sample entry in the spec
473
+ - CRITICAL: Also capture the response ENVELOPE — the top-level JSON structure that wraps the entries.
474
+ Example: if the API returns {"totalResults": 1, "companies": [...]}, the envelope is:
475
+ {"totalResults": "number", "companies": "array of company objects"}
476
+ Put this in the "responseEnvelope" field. This prevents the extension foundry from guessing
477
+ wrong field names (e.g., using "results" when the API returns "companies").
478
+ - Note non-obvious characteristics: encoding declaration, nested structures,
479
+ timestamps with ambiguous formats, mixed-language content
480
+ - NEVER generate parsing code based on assumed format — you need real evidence
481
+
482
+ STATIC / USER-PROVIDED DATA (type: "user-input"):
483
+ - If the user provides a complete dataset (coordinate lists, lookup tables, category mappings, etc.),
484
+ you MUST capture the ENTIRE dataset in the "staticData" field as a JSON array of {key, value} objects.
485
+ - Do NOT truncate, summarize, or put only one sample row — include EVERY row the user provides.
486
+ - Parse the user's format (TSV, CSV, pasted table, etc.) into clean JSON objects.
487
+ Example: "Item A\\t42.5\\tactive" → { "key": "Item A", "value": { "score": 42.5, "status": "active" } }
488
+ - The staticData will be written directly to memory as initial data when the service is installed.
489
+ - "sampleEntry" still holds ONE example for documentation; "staticData" holds the FULL dataset.
490
+
491
+ c) DATA MODEL — What are the key entities? (1-2 questions)
492
+ - Propose entities based on use cases (just name + one-line description each)
493
+ - Ask: "Does this cover your data, or is anything missing?"
494
+ - Do NOT ask about individual fields, ID formats, or storage details — the foundry decides those
495
+
496
+ d) VIEWS & INTERACTIONS — What should it look like? (2-3 questions)
497
+ - Propose views based on use cases (map, list, dashboard, cards, timeline, etc.)
498
+ - Ask which views are essential vs optional
499
+ - Ask about key interactions (filter, search, create, export)
500
+ - Do NOT ask about individual UI controls, column orders, or widget placement
501
+
502
+ e) STYLE & LOOK — How should it feel? (2-3 questions)
503
+ Ask in ONE batch:
504
+ - Mood: clean/minimal, playful, data-dense/professional?
505
+ - Color feel: suggest a palette based on the domain (e.g., "warm earth tones for food", "clean blues for data")
506
+ - Layout preference: tabs, single page, split panels?
507
+ - Any apps or websites whose look they admire?
508
+
509
+ f) SETTINGS & EXTERNAL SERVICES — What configuration does this need? (1-2 questions)
510
+ As you interview the user, identify external services and settings needs:
511
+
512
+ 1. When the user describes data sources, recognize external API dependencies. For each:
513
+ - Name the service (e.g., "Finnhub", "OpenWeatherMap")
514
+ - Identify required settings (API key, base URL, refresh interval, etc.)
515
+ - Suggest whether settings should be shared (one key for all users) or per-user
516
+
517
+ 2. Ask ONE simple question: "Will you share this service with other users or use it only yourself?"
518
+ This drives the architecture — personal use means simpler settings, shared means admin capabilities may be needed.
519
+
520
+ 3. Identify user-configurable preferences (default values, display options, limits).
521
+
522
+ 4. If the service is complex with shared sensitive settings, recommend a separate admin app.
523
+ If simple or personal-use, a single app is fine. Do NOT create an admin app unless clearly justified.
524
+
525
+ g) CONSTRAINTS & PREFERENCES (1-2 questions)
526
+ Ask in ONE batch:
527
+ - How often should data refresh?
528
+ - What languages does the UI need?
529
+ - Any domain-specific rules the foundry should know?
530
+
531
+ 3. STAY IN SCOPE — This is an AIMEAT service:
532
+ - The AIMEAT platform handles: storage, scheduling, auth, login, user management, access control, serving, i18n
533
+ - Do NOT ask about authentication, login systems, user registration, user counts, audience size, or access control — AIMEAT provides all of these automatically
534
+ - Do NOT ask about frameworks, runtimes, databases, Docker, deployment, hosting, CI/CD
535
+ - Do NOT ask about file formats, build tools, API design, error handling, data serialization
536
+ - Do NOT ask about retention periods, scheduler times, geolocation methods, caching
537
+ - Focus ONLY on WHAT the service does — the foundry handles architecture and implementation
538
+
539
+ 4. SECTION RULES:
540
+ - Each section stays open until the user confirms
541
+ - After each section, give a brief summary (2-3 bullet points) and ask for confirmation
542
+ - Do NOT repeat the full accumulated summary after every section — just the current one
543
+ - If the user brings up something from a previous section, go back to it
544
+
545
+ 5. HONESTY RULES:
546
+ - If you don't know something, say so
547
+ - If you can't access a URL, say so explicitly
548
+ - Don't make assumptions about external APIs — ask the user
549
+ - If a use case seems infeasible, explain why and suggest alternatives
550
+
551
+ 6. WHEN THE INTERVIEW IS COMPLETE:
552
+ - Give a BRIEF final summary (one paragraph, not a section-by-section repetition)
553
+ - Ask the user to confirm
554
+ - Then output the structured specification in this EXACT JSON format:
555
+
556
+ \\\`\\\`\\\`json
557
+ {
558
+ "version": "1.0",
559
+ "locale": "${locale}",
560
+ "projectName": "Human-readable project name",
561
+ "description": "Enhanced description incorporating all interview findings",
562
+ "technicalLevel": "beginner|intermediate|advanced",
563
+ "useCases": [
564
+ {
565
+ "id": "uc-1",
566
+ "title": "Use case title",
567
+ "description": "What the user does and why",
568
+ "priority": "must-have|nice-to-have"
569
+ }
570
+ ],
571
+ "dataSources": [
572
+ {
573
+ "id": "ds-1",
574
+ "name": "Source name",
575
+ "type": "rss|api|websocket|user-input|computed",
576
+ "url": "https://... or null",
577
+ "format": "xml|json|html|csv|unknown",
578
+ "encoding": "utf-8|iso-8859-1|auto",
579
+ "sampleEntry": "One raw entry from the source, copy-pasted exactly as-is",
580
+ "responseEnvelope": "For API/RSS sources: describe the top-level response structure that WRAPS the entries. Example for REST API: { \"totalResults\": \"number\", \"companies\": \"array of company objects\" }. Example for RSS: { \"channel\": { \"item\": \"array of items\" } }. This tells the extension foundry which field name to use when accessing the results array (e.g., response.companies, not response.results). CRITICAL for correct parsing.",
581
+ "staticData": "For type 'user-input' ONLY: the COMPLETE dataset as an array of {key, value} objects. Include EVERY row the user provided, parsed into clean JSON. Example: [{ \"key\": \"Item A\", \"value\": { \"score\": 42.5, \"status\": \"active\" } }]. Omit this field for non-user-input sources.",
582
+ "updateFrequency": "realtime|minutes|hourly|daily|on-demand",
583
+ "sampleFields": ["field1", "field2"],
584
+ "notes": "Any observations from fetching/analyzing the source",
585
+ "verified": true,
586
+ "verifiedBy": "ai|user",
587
+ "fallback": "Only if verified=false: 'demo' (use generated mock data), 'defer' (try at runtime, handle failure), or 'skip' (remove this source). Omit if verified=true.",
588
+ "demoData": "Only if fallback='demo': array of 5-10 realistic sample entries that will be loaded as static data on install. Omit otherwise."
589
+ }
590
+ ],
591
+ "dataModel": {
592
+ "entities": [
593
+ {
594
+ "name": "entity-name",
595
+ "description": "What this entity represents",
596
+ "fields": [
597
+ { "name": "fieldName", "type": "string|number|boolean|date|coordinates|array|object", "required": true, "description": "What this field holds" }
598
+ ],
599
+ "relationships": ["related-to entity-name-2 via fieldName"]
600
+ }
601
+ ]
602
+ },
603
+ "views": [
604
+ {
605
+ "id": "view-1",
606
+ "type": "map|list|dashboard|cards|timeline|form|detail|settings",
607
+ "title": "View title",
608
+ "description": "What this view shows",
609
+ "dataEntities": ["entity-name"],
610
+ "interactions": ["filter", "search", "create", "export"],
611
+ "visualizations": ["bar-chart", "pie-chart", "heatmap"]
612
+ }
613
+ ],
614
+ "style": {
615
+ "mood": "minimal|playful|professional|data-dense",
616
+ "colorPalette": "Description or hex values",
617
+ "typography": "standard|compact|large-display",
618
+ "layout": "single-page|tabbed|split-panel|fullscreen",
619
+ "animations": "none|subtle|rich",
620
+ "displayContext": "desktop|mobile|kiosk|embedded",
621
+ "references": "Any reference apps or styles the user mentioned"
622
+ },
623
+ "externalServices": [
624
+ {
625
+ "name": "ServiceName",
626
+ "purpose": "what it provides",
627
+ "requiredSettings": [{ "key": "api_key_name", "type": "secret|string|url|number", "label": "Human-readable Label" }],
628
+ "sharingModel": "shared|per-user",
629
+ "suggestedBy": "ai"
630
+ }
631
+ ],
632
+ "sharedService": true,
633
+ "adminAppRecommended": false,
634
+ "adminAppReason": "reason string or null — only set if adminAppRecommended is true",
635
+ "userSettings": [
636
+ { "key": "setting_name", "type": "string|number|boolean|select", "label": "Human-readable Label", "default": "default value" }
637
+ ],
638
+ "constraints": {
639
+ "updateMode": "realtime|scheduled|on-demand",
640
+ "scheduleInterval": "15m|1h|daily|null",
641
+ "locales": ["fi", "en"],
642
+ "domainRules": "Any domain-specific rules or edge cases",
643
+ "notes": "Any additional context that doesn't fit above"
644
+ },
645
+ "interviewNotes": "Any important context from the conversation that doesn't fit above"
646
+ }
647
+ \\\`\\\`\\\`
648
+
649
+ IMPORTANT: The JSON must be inside a \\\`\\\`\\\`json code fence so the user can easily copy it.
650
+
651
+ Begin the interview now. Start by greeting the user and asking about their technical level.`;
652
+ }
653
+
654
+ export async function buildComponentPrompt(type, label, projectDescription, blueprint, completedComponents, interviewSpec) {
655
+ const template = COMPONENT_TEMPLATES[type];
656
+ if (!template) throw new Error(`No template for type: ${type}`);
657
+
658
+ let context = `Project: ${projectDescription}\n`;
659
+ if (blueprint) {
660
+ context += `\nBlueprint components: ${blueprint.components.map(c => `${c.id} (${c.type}: ${c.label})`).join(', ')}\n`;
661
+ }
662
+
663
+ // Inject interview spec context for app and cortex — use cases, views, style
664
+ if (interviewSpec && (type === 'app' || type === 'cortex')) {
665
+ if (interviewSpec.useCases && interviewSpec.useCases.length > 0) {
666
+ context += '\n## USE CASES (from user interview — the app MUST support ALL of these)\n';
667
+ for (const uc of interviewSpec.useCases) {
668
+ context += `- **${uc.title || uc.id}** [${uc.priority || 'must-have'}]: ${uc.description}\n`;
669
+ }
670
+ context += '\n';
671
+ }
672
+ if (interviewSpec.views && interviewSpec.views.length > 0) {
673
+ context += '## VIEWS (from user interview — implement these as tabs/pages)\n';
674
+ for (const v of interviewSpec.views) {
675
+ context += `- **${v.title}** (${v.type}): ${v.description}`;
676
+ if (v.interactions?.length) context += ` — interactions: ${v.interactions.join(', ')}`;
677
+ context += '\n';
678
+ }
679
+ context += '\n';
680
+ }
681
+ if (interviewSpec.style) {
682
+ const s = interviewSpec.style;
683
+ context += `## STYLE: mood=${s.mood || 'professional'}, layout=${s.layout || 'tabbed'}, typography=${s.typography || 'standard'}\n\n`;
684
+ }
685
+ }
686
+
687
+ // Inject relevant dataModel entries — the centralized data contract
688
+ if (blueprint?.dataModel) {
689
+ const componentId = blueprint.components?.find(c => c.label === label)?.id;
690
+ const relevant = {};
691
+ for (const [key, schema] of Object.entries(blueprint.dataModel)) {
692
+ // CSM: show all data model keys (CSM defines the service schema)
693
+ if (type === 'csm') {
694
+ relevant[key] = schema;
695
+ }
696
+ // Memory component: show keys it produces
697
+ if (type === 'memory' && schema.producedBy === componentId) {
698
+ relevant[key] = schema;
699
+ }
700
+ // Extension: show keys it produces AND consumes
701
+ if (type === 'extension' && (schema.producedBy === componentId || schema.consumedBy?.includes(componentId))) {
702
+ relevant[key] = schema;
703
+ }
704
+ // Cortex: show all keys it consumes
705
+ if (type === 'cortex' && schema.consumedBy?.includes(componentId)) {
706
+ relevant[key] = schema;
707
+ }
708
+ // App: show all keys it consumes (via cortex)
709
+ if (type === 'app' && schema.consumedBy?.includes(componentId)) {
710
+ relevant[key] = schema;
711
+ }
712
+ // Translation: show i18n keys it produces
713
+ if (type === 'translation' && schema.producedBy === componentId) {
714
+ relevant[key] = schema;
715
+ }
716
+ }
717
+ if (Object.keys(relevant).length > 0) {
718
+ // Strip pipeline metadata (source, producedBy, consumedBy) — these are NOT part of the data shape
719
+ // and AI copies them into the actual values if they're present
720
+ const cleaned = {};
721
+ for (const [key, schema] of Object.entries(relevant)) {
722
+ const { source, producedBy, consumedBy, ...dataSchema } = schema;
723
+ cleaned[key] = dataSchema;
724
+ }
725
+ context += '\n## Domain Data Model (EXACT schemas — follow these precisely)\n';
726
+ context += 'These are the memory key schemas for this component. Use these exact key names and data shapes.\n\n';
727
+ context += '```json\n' + JSON.stringify(cleaned, null, 2) + '\n```\n\n';
728
+ }
729
+ }
730
+
731
+ if (completedComponents && completedComponents.length > 0) {
732
+ // Use context bundles when available — structured summaries from registration + probe
733
+ const bundled = completedComponents.filter(c => c.contextBundle);
734
+ const unbundled = completedComponents.filter(c => !c.contextBundle);
735
+
736
+ if (bundled.length > 0) {
737
+ const { formatBundlesForPrompt } = _cortexModules || {};
738
+ if (formatBundlesForPrompt) {
739
+ context += formatBundlesForPrompt(bundled.map(c => c.contextBundle));
740
+ } else {
741
+ // Fallback: simple listing if module not loaded
742
+ context += '\nAlready completed:\n';
743
+ for (const c of bundled) {
744
+ const b = c.contextBundle;
745
+ context += `- ${c.id} (${c.type}: ${c.label}): registered as "${b.registeredAs}"`;
746
+ if (b.actions) context += ` — actions: ${b.actions.join(', ')}`;
747
+ if (b.exports) context += ` — exports: ${b.exports.join(', ')}`;
748
+ context += '\n';
749
+ }
750
+ }
751
+ }
752
+
753
+ // Fallback for components without bundles
754
+ if (unbundled.length > 0) {
755
+ context += '\nAlready completed:\n';
756
+ for (const c of unbundled) {
757
+ context += `- ${c.id} (${c.type}: ${c.label}): registered as "${c.registeredAs}"\n`;
758
+ if (c.result && c.type === 'extension') {
759
+ context += ` API summary:\n${summarizeExtensionApi(c.result)}\n`;
760
+ if (c.probeResults && Array.isArray(c.probeResults) && c.probeResults.length > 0 && (type === 'cortex' || type === 'app' || type === 'extension')) {
761
+ context += `\n ## ACTUAL API RESPONSES (captured from live execution of ${c.registeredAs})\n`;
762
+ context += ` Study these carefully — your code MUST handle these exact data shapes.\n\n`;
763
+ for (const probe of c.probeResults) {
764
+ if (probe.status === 200 && probe.response) {
765
+ context += ` POST /v1/ext/${c.registeredAs}/${probe.action} ${JSON.stringify(probe.input)}\n`;
766
+ context += ` → ${JSON.stringify(probe.response)}\n\n`;
767
+ }
768
+ }
769
+ }
770
+ } else if (c.result && c.type === 'cortex') {
771
+ context += ` API summary:\n${summarizeCortexApi(c.result)}\n`;
772
+ }
773
+ }
774
+ }
775
+ }
776
+
777
+ // For memory components with static data: only include if this component's dataModel has source:"static"
778
+ if (type === 'memory' && interviewSpec?.dataSources && blueprint?.dataModel) {
779
+ const componentId = blueprint.components?.find(c => c.label === label)?.id;
780
+ const hasStaticKey = componentId && Object.values(blueprint.dataModel).some(
781
+ schema => schema.source === 'static' && schema.producedBy === componentId
782
+ );
783
+ if (hasStaticKey) {
784
+ const staticSources = interviewSpec.dataSources.filter(ds => ds.staticData && Array.isArray(ds.staticData));
785
+ if (staticSources.length > 0) {
786
+ context += '\n## Static Data from Interview\n';
787
+ context += 'The user provided complete datasets. Store each as a SINGLE memory key (one array value, not one key per entry).\n';
788
+ context += 'The dataModel above shows the exact schema. Include ALL entries in the value.\n\n';
789
+ for (const ds of staticSources) {
790
+ context += `### ${ds.name} (${ds.staticData.length} entries)\n`;
791
+ context += '```json\n' + JSON.stringify(ds.staticData, null, 2) + '\n```\n\n';
792
+ }
793
+ }
794
+ }
795
+ }
796
+
797
+ // Inject scheduled jobs from blueprint to extension prompts
798
+ if (type === 'extension' && blueprint?.components) {
799
+ const componentId = blueprint.components.find(c => c.label === label)?.id;
800
+ const comp = componentId && blueprint.components.find(c => c.id === componentId);
801
+ if (comp?.schedules && comp.schedules.length > 0) {
802
+ context += '\n## Scheduled Jobs (from blueprint — MUST include in manifest)\n';
803
+ context += 'This extension has recurring background jobs. Add a `schedules` section to the YAML manifest:\n\n';
804
+ context += '```yaml\nschedules:\n';
805
+ for (const s of comp.schedules) {
806
+ context += ` - id: ${s.action}-scheduled\n action: ${s.action}\n cron: "${s.cron}"\n description: "Scheduled: ${s.action}"\n instance_scope: false\n input: {}\n`;
807
+ }
808
+ context += '```\n\n';
809
+ context += 'The scheduler runs these automatically in the background — no browser needed.\n';
810
+ }
811
+ }
812
+
813
+ // Inject blueprint settings as extension config keys
814
+ // The user enters settings values BEFORE generation. These values are injected into ctx.config
815
+ // at runtime. The extension MUST use these EXACT key names in ctx.config.
816
+ if (type === 'extension' && blueprint?.settings) {
817
+ const allSettings = [...(blueprint.settings.service || []), ...(blueprint.settings.user || [])];
818
+ if (allSettings.length > 0) {
819
+ context += '\n## Extension Config Keys (from blueprint settings — use EXACTLY these)\n';
820
+ context += 'These settings are injected into `ctx.config` at runtime. Use these EXACT key names:\n\n';
821
+ context += '```yaml\nconfig:\n';
822
+ for (const s of allSettings) {
823
+ const yamlType = s.type === 'secret' ? 'string' : s.type === 'boolean' ? 'boolean' : s.type === 'number' ? 'number' : 'string';
824
+ context += ` ${s.key}:\n type: ${yamlType}\n description: "${s.label}"\n`;
825
+ if (s.required) context += ` required: true\n`;
826
+ }
827
+ context += '```\n\n';
828
+ context += 'In your action code, read these as: `ctx.config?.${allSettings[0].key}`\n';
829
+ context += 'Do NOT rename these keys. Do NOT use different key names like "apiKey" when the blueprint says "' + allSettings[0].key + '".\n\n';
830
+ }
831
+ }
832
+
833
+ // Inject required action/method names from blueprint testScenarios
834
+ // These are the EXACT names the component MUST implement — tests will call them by name
835
+ if ((type === 'extension' || type === 'cortex' || type === 'app') && blueprint?.testScenarios) {
836
+ const componentId = blueprint.components?.find(c => c.label === label)?.id;
837
+ const scenarios = (blueprint.testScenarios || [])
838
+ .filter(ts => ts.component === componentId)
839
+ .flatMap(ts => ts.scenarios || []);
840
+ if (scenarios.length > 0) {
841
+ const names = [...new Set(scenarios.map(s => s.action))];
842
+ if (type === 'extension') {
843
+ context += '\n## Required Action IDs (from blueprint — use EXACTLY these names)\n';
844
+ context += 'The blueprint specifies these EXACT action IDs. Your extension MUST use these names:\n\n';
845
+ for (const s of scenarios) {
846
+ context += `- **${s.action}** — ${s.expect.split('.')[0]}.\n`;
847
+ if (Object.keys(s.input).length > 0) context += ` Input: ${JSON.stringify(s.input)}\n`;
848
+ }
849
+ context += `\nDo NOT rename these actions. Use "${names.join('", "')}" as the action id values in your YAML manifest.\n`;
850
+ context += 'If you use different names (e.g., "getCandles" instead of "fetchCandles"), validation WILL fail.\n\n';
851
+ } else if (type === 'cortex') {
852
+ context += '\n## Required Method Names (from blueprint — use EXACTLY these)\n';
853
+ context += 'Tests will call these methods by name. Your cortex MUST export them:\n\n';
854
+ for (const s of scenarios) {
855
+ context += `- **${s.action}()** — ${s.expect.split('.')[0]}.\n`;
856
+ if (Object.keys(s.input).length > 0) context += ` Args: ${JSON.stringify(s.input)}\n`;
857
+ }
858
+ context += '\nDo NOT rename these methods. Validation WILL fail if names don\'t match.\n\n';
859
+ } else if (type === 'app') {
860
+ context += '\n## Required User Flows (from blueprint — the app MUST support these)\n';
861
+ context += 'Tests will verify these workflows exist and function in the UI:\n\n';
862
+ for (const s of scenarios) {
863
+ context += `- **${s.action}** — ${s.expect}\n`;
864
+ }
865
+ context += '\n';
866
+ }
867
+ }
868
+ }
869
+
870
+ // Cortex: inject EXTENSION_CONSUMPTION_RULES so cortex knows ALL actions are POST
871
+ if (type === 'cortex') {
872
+ context += '\n' + EXTENSION_CONSUMPTION_RULES + '\n';
873
+ }
874
+
875
+ // Cortex: if blueprint produces api:t, cortex MUST include translation helper methods
876
+ if (type === 'cortex' && blueprint?.components) {
877
+ const componentId = blueprint.components.find(c => c.label === label)?.id;
878
+ const comp = componentId && blueprint.components.find(c => c.id === componentId);
879
+ if (comp?.produces && comp.produces.some(p => p === 'api:t')) {
880
+ context += `\n## REQUIRED: Translation Helper Methods
881
+
882
+ Your cortex MUST include these translation methods (blueprint produces "api:t"):
883
+
884
+ \`\`\`javascript
885
+ // Translation helper — MUST be included
886
+ async function getTranslations(locale) {
887
+ const strings = await readExtMemory(EXT.name, 'i18n.' + (locale || 'fi'));
888
+ return strings || {};
889
+ }
890
+
891
+ function t(key, translations) {
892
+ if (!translations) return key;
893
+ const parts = key.split('.');
894
+ let val = translations;
895
+ for (const p of parts) {
896
+ val = val?.[p];
897
+ if (val === undefined) return key;
898
+ }
899
+ return val;
900
+ }
901
+ \`\`\`
902
+
903
+ Export both as public methods: getTranslations(locale) and t(key, translations).
904
+ The app calls getTranslations() during startup and t() for every UI string.
905
+ If these are missing, the app WILL crash with "getTranslations is not a function".\n`;
906
+ }
907
+ }
908
+
909
+ // Thread interview data source details to extension prompts
910
+ if (type === 'extension' && interviewSpec?.dataSources) {
911
+ context += '\n## Data Source Details (from interview — use these to write correct parsers)\n';
912
+ for (const ds of interviewSpec.dataSources) {
913
+ context += `- **${ds.name}** (${ds.type}): ${ds.url || 'user-input'}\n`;
914
+ if (ds.url) {
915
+ context += ` ⚠️ Use this EXACT URL as the base. Do NOT guess or modify the URL structure — read the notes below for how to construct requests.\n`;
916
+ }
917
+ if (ds.encoding) context += ` Encoding: ${ds.encoding}\n`;
918
+ if (ds.notes) context += ` Notes: ${ds.notes}\n`;
919
+ if (ds.responseEnvelope) {
920
+ context += ` Response envelope (top-level JSON structure): \`${typeof ds.responseEnvelope === 'string' ? ds.responseEnvelope : JSON.stringify(ds.responseEnvelope)}\`\n`;
921
+ context += ` ⚠️ Use the EXACT field names from this envelope to access the results array. Do NOT guess field names like "results" or "data" — use what the API actually returns.\n`;
922
+ }
923
+ if (ds.sampleEntry) context += ` Sample entry (ONE item from the results array — write your parser against this):\n \`\`\`\n ${ds.sampleEntry}\n \`\`\`\n`;
924
+ if (ds.staticData && Array.isArray(ds.staticData)) {
925
+ context += ` **STATIC DATA (${ds.staticData.length} entries) — pre-loaded in OWNER memory. Read with ctx.memory.getPublic(ctx.caller.owner, key), do NOT re-create it.**\n`;
926
+ }
927
+ }
928
+ }
929
+
930
+ // Inject use cases from interview spec to app prompts — drives UI design
931
+ if (type === 'app' && interviewSpec?.useCases) {
932
+ const cases = interviewSpec.useCases.map(uc => {
933
+ if (typeof uc === 'string') return uc;
934
+ if (uc?.description) return uc.description;
935
+ if (uc?.title) return uc.title;
936
+ return JSON.stringify(uc);
937
+ }).filter(Boolean);
938
+ if (cases.length > 0) {
939
+ context += '\n## Use Cases (from interview — the app MUST support ALL of these)\n';
940
+ cases.forEach((c, i) => { context += `${i + 1}. ${c}\n`; });
941
+ context += '\nDesign the UI around these workflows. Every use case must be reachable.\n\n';
942
+ }
943
+ }
944
+
945
+ // Thread language preference from interview spec to all component prompts
946
+ const specLocale = interviewSpec?.locale;
947
+ if (specLocale && specLocale !== 'en') {
948
+ context += `\n## LANGUAGE\n\nThe user works in "${specLocale}". Write all human-readable text (labels, descriptions, comments, UI strings, variable names for display) in that language.\nCode identifiers, JSON keys, YAML keys, and API names stay in English.\n`;
949
+ }
950
+
951
+ // For translation components: if another locale is already done, inject its keys
952
+ // so AI generates matching keys for this locale
953
+ if (type === 'translation' && completedComponents?.length > 0) {
954
+ const otherTranslations = completedComponents.filter(c => c.type === 'translation' && c.result);
955
+ for (const t of otherTranslations) {
956
+ try {
957
+ const parsed = JSON.parse(typeof t.result === 'string' ? t.result : JSON.stringify(t.result));
958
+ const locale = Object.keys(parsed).find(k => typeof parsed[k] === 'object');
959
+ if (locale && parsed[locale]) {
960
+ const keys = Object.keys(parsed[locale]);
961
+ context += `\n## REQUIRED: Match these EXACT keys from the "${locale}" translation\n`;
962
+ context += `The other locale has these ${keys.length} keys. You MUST use the SAME keys:\n`;
963
+ context += `\`\`\`\n${keys.join('\n')}\n\`\`\`\n`;
964
+ context += `Do NOT add extra keys and do NOT omit any keys — the sets must be identical.\n`;
965
+ }
966
+ } catch { /* ignore parse errors */ }
967
+ }
968
+ }
969
+
970
+ // Inject MANDATORY API methods from blueprint produces list into cortex prompt
971
+ // This is THE critical contract: cortex MUST implement exactly these methods
972
+ if (type === 'cortex' && blueprint?.components) {
973
+ const componentId = blueprint.components.find(c => c.label === label)?.id;
974
+ const comp = componentId && blueprint.components.find(c => c.id === componentId);
975
+ if (comp?.produces && comp.produces.length > 0) {
976
+ const apiMethods = comp.produces
977
+ .filter(p => p.startsWith('api:'))
978
+ .map(p => p.replace('api:', ''));
979
+ if (apiMethods.length > 0) {
980
+ context += '\n## MANDATORY API METHODS (from blueprint — you MUST implement ALL of these)\n\n';
981
+ context += '╔══════════════════════════════════════════════════════════════════════════╗\n';
982
+ context += '║ Your cortex MUST export EXACTLY these methods. Do NOT rename them. ║\n';
983
+ context += '║ Do NOT add extra public methods. Do NOT omit any method. ║\n';
984
+ context += '║ The app component depends on these EXACT names. ║\n';
985
+ context += '╚══════════════════════════════════════════════════════════════════════════╝\n\n';
986
+ context += 'Required exports:\n';
987
+ for (const m of apiMethods) {
988
+ context += `- \`${m}()\` — MUST be in the exports object\n`;
989
+ }
990
+ context += '\nThe `exports` object at the bottom of your IIFE must include ALL of these:\n';
991
+ context += '```javascript\nconst exports = { ' + apiMethods.join(', ') + ' };\n```\n\n';
992
+ }
993
+ }
994
+
995
+ // Also inject consumes so cortex knows which memory keys to read
996
+ if (comp?.consumes && comp.consumes.length > 0) {
997
+ const memoryKeys = comp.consumes
998
+ .filter(c => c.startsWith('memory:'))
999
+ .map(c => c.replace('memory:', ''));
1000
+ if (memoryKeys.length > 0) {
1001
+ context += '\n## CONSUMED DATA (memory keys this cortex reads)\n';
1002
+ for (const k of memoryKeys) {
1003
+ context += `- \`${k}\`\n`;
1004
+ }
1005
+ context += '\n';
1006
+ }
1007
+ }
1008
+ }
1009
+
1010
+ // Inject "uses" cortex dependencies from blueprint
1011
+ if (type === 'cortex' && blueprint?.components) {
1012
+ const componentId = blueprint.components.find(c => c.label === label)?.id;
1013
+ const comp = componentId && blueprint.components.find(c => c.id === componentId);
1014
+ if (comp?.uses && comp.uses.length > 0) {
1015
+ context += '\n## Reusable Cortex Libraries (from blueprint — load and use these)\n';
1016
+ context += 'This cortex component should use the following existing cortex libraries.\n';
1017
+ context += 'Load them via `<script>` tags in the prompt component and call their API.\n';
1018
+ context += 'Do NOT reimplement their functionality.\n\n';
1019
+ // Platform cortex library API reference
1020
+ const platformApis = {
1021
+ 'aimeat-ui-nav': 'Tabs(container, tabs, onSelect), Breadcrumbs(container, items), Sidebar(container, items, onSelect), BottomNav(container, items, onSelect), BurgerMenu(container, items, onSelect)',
1022
+ 'aimeat-ui-layout': 'MainDetail(container, {main, detail}), DashboardGrid(container, cards), Split(container, {left, right}), Stacked(container, sections), Header(container, {title, actions}), Footer(container, content)',
1023
+ 'aimeat-ui-viewers': 'DataTable(container, {columns, rows, onRowClick}), Timeline(container, events), Grid(container, items, renderItem), List(container, items, renderItem), Gallery(container, images), Carousel(container, slides)',
1024
+ 'aimeat-ui-forms': 'Input(container, {label, value, onChange}), Select(container, {label, options, value, onChange}), Toggle(container, {label, checked, onChange}), Checkbox(container, {label, checked, onChange}), FormGroup(container, fields)',
1025
+ 'aimeat-ui-dialogs': 'toast(message, type), Modal(container, {title, content, onClose}), Confirm({title, message, onConfirm}), Alert({title, message}), ContextMenu(container, items), Dropdown(container, items)',
1026
+ 'aimeat-charts': 'ChartPanel(container, {type, data, options}), ChartBuilder(container, config), TYPES (bar, line, pie, doughnut, radar, scatter, bubble)',
1027
+ 'aimeat-canvas': 'DrawingCanvas(container, {width, height, tools, onSave})',
1028
+ };
1029
+ for (const libName of comp.uses) {
1030
+ const camelName = libName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1031
+ context += `- **${libName}**: Load via \`<script src="/v1/cortex/${libName}/libs/${libName}.js"></script>\`\n`;
1032
+ context += ` Access via \`AIMEAT['${libName}'].*\`\n`;
1033
+ if (platformApis[libName]) {
1034
+ context += ` API: ${platformApis[libName]}\n`;
1035
+ }
1036
+ }
1037
+ context += '\n';
1038
+ }
1039
+ }
1040
+
1041
+ // Cortex subtype dispatch — use specialized templates for new multi-cortex architecture
1042
+ if (type === 'cortex' && blueprint) {
1043
+ const componentId = blueprint.components?.find(c => c.label === label)?.id;
1044
+ const comp = componentId && blueprint.components.find(c => c.id === componentId);
1045
+ const subtype = comp?.subtype;
1046
+
1047
+ // Ensure cortex modules are loaded before dispatching
1048
+ if (subtype && !_cortexModules && _cortexModulesPromise) {
1049
+ await _cortexModulesPromise;
1050
+ }
1051
+ if (subtype && _cortexModules) {
1052
+ const { buildDataCortexPrompt, buildFeatureCortexPrompt, buildAppDomainCortexPrompt, createBundle } = _cortexModules;
1053
+ const bundles = (completedComponents || []).map(c => createBundle(c, c.probeResults));
1054
+
1055
+ if (subtype === 'data') {
1056
+ return buildDataCortexPrompt(label, projectDescription, blueprint, bundles);
1057
+ }
1058
+ if (subtype === 'feature') {
1059
+ const useCase = interviewSpec?.useCases?.find(uc =>
1060
+ label.toLowerCase().includes(uc.title?.toLowerCase().split(' ')[0] || '___')
1061
+ ) || interviewSpec?.useCases?.[0];
1062
+ const view = interviewSpec?.views?.find(v =>
1063
+ label.toLowerCase().includes(v.title?.toLowerCase().split(' ')[0] || '___')
1064
+ ) || interviewSpec?.views?.[0];
1065
+ const dataCortexBundle = bundles.find(b => b.subtype === 'data');
1066
+ const structures = blueprint?.dataModel?.structures || {};
1067
+ const translationBundle = bundles.find(b => b.type === 'translation');
1068
+ const translationKeys = translationBundle?.keys || [];
1069
+ const usesLibs = comp?.uses || [];
1070
+ return buildFeatureCortexPrompt(label, useCase, view, dataCortexBundle, structures, translationKeys, usesLibs);
1071
+ }
1072
+ if (subtype === 'app-domain') {
1073
+ const featureBundles = bundles.filter(b => b.subtype === 'feature');
1074
+ const dataCortexBundle = bundles.find(b => b.subtype === 'data');
1075
+ const translationBundle = bundles.find(b => b.type === 'translation');
1076
+ return buildAppDomainCortexPrompt(label, projectDescription, featureBundles, dataCortexBundle, translationBundle);
1077
+ }
1078
+ // Fallback for unknown subtype — use generic cortex template
1079
+ return INSTRUCTION_DISCLAIMER + template(label, context, completedComponents);
1080
+ } // end if (subtype && _cortexModules)
1081
+ }
1082
+
1083
+ // App and cortex templates receive completedComponents for cross-referencing
1084
+ if (type === 'app' || type === 'cortex') {
1085
+ return INSTRUCTION_DISCLAIMER + template(label, context, completedComponents);
1086
+ }
1087
+
1088
+ return INSTRUCTION_DISCLAIMER + template(label, context);
1089
+ }
1090
+
1091
+ /* ── Skeleton Prompt Builders (Multi-Pass Pipeline) ──── */
1092
+
1093
+ /**
1094
+ * Build skeleton prompt for any multi-pass component type.
1095
+ * Dispatches to the type-specific skeleton builder.
1096
+ */
1097
+ export function buildSkeletonPrompt(params) {
1098
+ const type = params.blueprintComponent?.type;
1099
+ const subtype = params.blueprintComponent?.subtype;
1100
+
1101
+ if (type === 'extension') return buildExtensionSkeletonPrompt(params);
1102
+ if (type === 'cortex' && subtype === 'data') return buildDataCortexSkeletonPrompt(params);
1103
+ if (type === 'cortex' && subtype === 'feature') return buildFeatureCortexSkeletonPrompt(params);
1104
+ if (type === 'cortex' && subtype === 'app-domain') return buildAppDomainCortexSkeletonPrompt(params);
1105
+ if (type === 'app') return buildAppSkeletonPrompt(params);
1106
+
1107
+ throw new Error(`No skeleton prompt builder for type=${type} subtype=${subtype}`);
1108
+ }
1109
+
1110
+ /**
1111
+ * Build the skeleton prompt for an extension component.
1112
+ * Produces a YAML skeleton with action signatures, schemas, memory keys — no implementation.
1113
+ */
1114
+ export function buildExtensionSkeletonPrompt({ label, description, blueprint, blueprintComponent, interviewSpec }) {
1115
+ const structures = blueprint.dataModel?.structures || {};
1116
+ const memoryKeys = blueprint.dataModel?.memoryKeys || {};
1117
+ const actions = blueprint.dataModel?.actions || {};
1118
+
1119
+ // Collect data sources relevant to this extension
1120
+ const dataSources = (interviewSpec?.dataSources || []).map(ds => ({
1121
+ name: ds.name,
1122
+ url: ds.url,
1123
+ sampleResponse: ds.sampleResponse || ds.sampleEntry || null,
1124
+ notes: ds.notes || '',
1125
+ }));
1126
+
1127
+ // Collect schedules from blueprint
1128
+ const schedules = blueprintComponent.schedules || [];
1129
+
1130
+ // Collect config keys
1131
+ const settingsArr = Array.isArray(blueprint.settings) ? blueprint.settings : (blueprint.settings?.user || []);
1132
+ const configKeys = settingsArr.map(s => s.key);
1133
+
1134
+ return `${INSTRUCTION_DISCLAIMER}
1135
+ # Task: Generate Extension Skeleton
1136
+
1137
+ You are generating a SKELETON for an AIMEAT extension. A skeleton defines the complete structure — action signatures, input/output schemas, memory keys, schedules — with ZERO implementation code.
1138
+
1139
+ ## Project
1140
+ ${description}
1141
+
1142
+ ## Component
1143
+ Label: ${label}
1144
+ Type: Extension (server-side V8 sandbox)
1145
+
1146
+ ## Data Sources
1147
+ ${dataSources.map(ds => `- ${ds.name}: ${ds.url}${ds.sampleResponse ? `\n Sample response: ${JSON.stringify(ds.sampleResponse, null, 2).slice(0, 2000)}` : ''}${ds.notes ? `\n Notes: ${ds.notes}` : ''}`).join('\n')}
1148
+
1149
+ ## Data Model Structures
1150
+ ${Object.entries(structures).length > 0 ? Object.entries(structures).map(([name, schema]) => `### ${name}\n\`\`\`json\n${JSON.stringify(schema, null, 2)}\n\`\`\``).join('\n\n') : 'No structures defined in blueprint.'}
1151
+
1152
+ ## Memory Keys This Extension Uses
1153
+ ${Object.entries(memoryKeys).filter(([, v]) => v.producedBy === blueprintComponent.id || v.consumedBy?.includes(blueprintComponent.id)).map(([key, def]) => `- \`${key}\`: ${def.description || ''} (${def.producedBy === blueprintComponent.id ? 'writes' : 'reads'})`).join('\n') || 'None declared in blueprint.'}
1154
+
1155
+ ## Actions From Blueprint
1156
+ ${Object.entries(actions).filter(([, v]) => v.component === blueprintComponent.id).map(([name, def]) => `- \`${name}\`: ${def.description || ''}\n Input: ${JSON.stringify(def.input || {})}\n Output: ${JSON.stringify(def.output || {})}`).join('\n\n') || 'None declared — infer from data sources and use cases.'}
1157
+
1158
+ ## Schedules
1159
+ ${schedules.length > 0 ? schedules.map(s => `- ${s.action}: ${s.cron} — ${s.description || ''}`).join('\n') : 'None.'}
1160
+
1161
+ ## Config Keys
1162
+ ${configKeys.length > 0 ? configKeys.map(k => `- ${k}`).join('\n') : 'None.'}
1163
+
1164
+ ## Output Format
1165
+
1166
+ Produce a YAML skeleton document. Use EXACTLY this structure:
1167
+
1168
+ \`\`\`yaml
1169
+ component: extension
1170
+ name: <kebab-case-name>
1171
+ version: 1.0.0
1172
+ description: <one-line description>
1173
+
1174
+ memory:
1175
+ writes:
1176
+ - key: <memory-key>
1177
+ schema: <inline JSON schema of the value>
1178
+ reads:
1179
+ - key: <memory-key>
1180
+ schema: <inline JSON schema>
1181
+
1182
+ actions:
1183
+ - id: <actionId>
1184
+ method: POST
1185
+ path: /<path>
1186
+ input: <JSON schema of input parameters>
1187
+ output: <JSON schema of return value>
1188
+ dataSource: <URL if this action calls an external API>
1189
+ sampleResponse: |
1190
+ <actual JSON from sample data — copy field names exactly>
1191
+ notes: "<any transformation notes>"
1192
+ reads: [<memory-keys-read>]
1193
+ writes: [<memory-keys-written>]
1194
+ schedule: "<cron expression if scheduled>"
1195
+ depends: [<otherActionIds>]
1196
+
1197
+ config:
1198
+ keys: [<config-memory-keys>]
1199
+
1200
+ activate:
1201
+ initCopies: []
1202
+ \`\`\`
1203
+
1204
+ ## CRITICAL RULES
1205
+
1206
+ 1. **ZERO implementation code.** No function bodies, no ctx calls, no logic. Only signatures and schemas.
1207
+ 2. **Use EXACT field names from sample responses.** If the API returns \`results\`, write \`results\` not \`companies\`. Copy the field names character-for-character from the sampleResponse.
1208
+ 3. **Every action from the blueprint must appear.** Do not skip or rename actions.
1209
+ 4. **Output schemas must match the actual API response structure**, not an idealized version.
1210
+ 5. **Include sampleResponse verbatim** for every action that calls an external API — this is used for validation.
1211
+ `;
1212
+ }
1213
+
1214
+ /**
1215
+ * Build skeleton prompt for data cortex.
1216
+ */
1217
+ export function buildDataCortexSkeletonPrompt({ label, description, blueprint, blueprintComponent, extensionSkeleton, extensionProbes }) {
1218
+ return `${INSTRUCTION_DISCLAIMER}
1219
+ # Task: Generate Data Cortex Skeleton
1220
+
1221
+ You are generating a SKELETON for an AIMEAT data cortex. A data cortex wraps extension actions into clean JavaScript methods. No UI, no rendering — pure data access.
1222
+
1223
+ ## Project
1224
+ ${description}
1225
+
1226
+ ## Component
1227
+ Label: ${label}
1228
+ Type: Data Cortex (browser-side IIFE)
1229
+
1230
+ ## Extension It Wraps
1231
+ ${extensionSkeleton || 'No extension skeleton available.'}
1232
+
1233
+ ## Extension Probe Results (Real API Responses)
1234
+ ${extensionProbes ? Object.entries(extensionProbes).map(([action, result]) => `### ${action}\n\`\`\`json\n${JSON.stringify(result, null, 2).slice(0, 1500)}\n\`\`\``).join('\n\n') : 'No probes available yet.'}
1235
+
1236
+ ## Output Format
1237
+
1238
+ \`\`\`yaml
1239
+ component: data-cortex
1240
+ name: <kebab-case-name>
1241
+ extension: <extension-registered-as-name>
1242
+
1243
+ methods:
1244
+ - name: <camelCaseMethodName>
1245
+ params: <JSON schema of parameters>
1246
+ returns: <JSON schema of return value — use EXACT field names from probe results>
1247
+ calls: <extensionActionId>
1248
+ - name: <methodName>
1249
+ returns: <schema>
1250
+ reads: <memory-key>
1251
+ \`\`\`
1252
+
1253
+ ## CRITICAL RULES
1254
+
1255
+ 1. ZERO implementation code. Only method signatures and schemas.
1256
+ 2. Return schemas MUST use exact field names from probe results, not invented names.
1257
+ 3. Every extension action that downstream components need must have a corresponding method.
1258
+ `;
1259
+ }
1260
+
1261
+ /**
1262
+ * Build skeleton prompt for feature cortex.
1263
+ */
1264
+ export function buildFeatureCortexSkeletonPrompt({ label, description, blueprint, blueprintComponent, dataCortexSkeleton, dataCortexProbes, interviewSpec }) {
1265
+ const useCase = (interviewSpec?.useCases || []).find(uc =>
1266
+ blueprintComponent.consumes?.some(c => c.includes(uc.name?.toLowerCase?.()))
1267
+ ) || interviewSpec?.useCases?.[0];
1268
+
1269
+ const view = (interviewSpec?.views || []).find(v =>
1270
+ v.name?.toLowerCase?.().includes(blueprintComponent.label?.toLowerCase?.())
1271
+ ) || interviewSpec?.views?.[0];
1272
+
1273
+ return `${INSTRUCTION_DISCLAIMER}
1274
+ # Task: Generate Feature Cortex Skeleton
1275
+
1276
+ You are generating a SKELETON for an AIMEAT feature cortex. A feature cortex combines data access + UI rendering for one use case. It exports a \`render(container)\` function.
1277
+
1278
+ ## Project
1279
+ ${description}
1280
+
1281
+ ## Component
1282
+ Label: ${label}
1283
+ Type: Feature Cortex (browser-side IIFE)
1284
+
1285
+ ## Use Case
1286
+ ${useCase ? JSON.stringify(useCase, null, 2) : 'Not specified.'}
1287
+
1288
+ ## View Definition
1289
+ ${view ? JSON.stringify(view, null, 2) : 'Not specified.'}
1290
+
1291
+ ## Data Cortex API (upstream)
1292
+ ${dataCortexSkeleton || 'No data cortex skeleton available.'}
1293
+
1294
+ ## Data Cortex Probe Results (Real Return Values)
1295
+ ${dataCortexProbes ? Object.entries(dataCortexProbes).map(([method, result]) => `### ${method}\n\`\`\`json\n${JSON.stringify(result, null, 2).slice(0, 1000)}\n\`\`\``).join('\n\n') : 'No probes available yet.'}
1296
+
1297
+ ## Output Format
1298
+
1299
+ \`\`\`yaml
1300
+ component: feature-cortex
1301
+ name: <kebab-case-name>
1302
+ useCase: "<use case description>"
1303
+ view: <view-id>
1304
+
1305
+ dataCortex: <data-cortex-name>
1306
+
1307
+ sections:
1308
+ - id: <section-id>
1309
+ description: "<what this section renders>"
1310
+ uses:
1311
+ data: [<dataCortexMethodNames>]
1312
+ ui: [<PlatformUIComponents>]
1313
+ translationKeys: [<key1>, <key2>]
1314
+
1315
+ exports:
1316
+ - name: render
1317
+ params: { container: HTMLElement }
1318
+ \`\`\`
1319
+
1320
+ ## CRITICAL RULES
1321
+
1322
+ 1. ZERO implementation code. Only section definitions and dependencies.
1323
+ 2. Each section should be a self-contained UI area (e.g., search form, results table, detail card).
1324
+ 3. Translation keys must follow the project's flat dot-notation pattern.
1325
+ `;
1326
+ }
1327
+
1328
+ /**
1329
+ * Build skeleton prompt for app-domain cortex.
1330
+ */
1331
+ export function buildAppDomainCortexSkeletonPrompt({ label, description, featureCortexSkeletons, featureCortexProbes }) {
1332
+ return `${INSTRUCTION_DISCLAIMER}
1333
+ # Task: Generate App-Domain Cortex Skeleton
1334
+
1335
+ You are generating a SKELETON for an AIMEAT app-domain cortex. This is the composition layer: it combines all feature cortex components + auth + i18n + settings.
1336
+
1337
+ ## Project
1338
+ ${description}
1339
+
1340
+ ## Feature Cortex Components
1341
+ ${featureCortexSkeletons?.map((s, i) => `### Feature ${i + 1}\n${s}`).join('\n\n') || 'No feature cortex skeletons available.'}
1342
+
1343
+ ## Output Format
1344
+
1345
+ \`\`\`yaml
1346
+ component: app-domain-cortex
1347
+ name: <kebab-case-name>
1348
+
1349
+ features:
1350
+ - cortex: <feature-cortex-name>
1351
+ renderTarget: "#<container-id>"
1352
+
1353
+ exports:
1354
+ - name: init
1355
+ description: "Auth check, load locale, apply settings"
1356
+ - name: render
1357
+ params: { container: HTMLElement }
1358
+ description: "Render tab navigation, mount features"
1359
+ - name: t
1360
+ params: { key: string }
1361
+ returns: string
1362
+ - name: switchLocale
1363
+ params: { locale: string }
1364
+ - name: getTranslations
1365
+ returns: object
1366
+ \`\`\`
1367
+
1368
+ ## Translation Loading Pattern
1369
+
1370
+ The app-domain cortex MUST load translations from the owner's memory namespace:
1371
+ \`\`\`javascript
1372
+ // Translations are stored by the translation component in the OWNER namespace
1373
+ // Key pattern: i18n.{locale} — loaded via AIMEAT.data.get()
1374
+ const translations = await AIMEAT.data.get('i18n.' + locale) || {};
1375
+ // If that returns null, try with service prefix:
1376
+ // const translations = await AIMEAT.data.get('SERVICE_NAME.i18n.' + locale) || {};
1377
+ \`\`\`
1378
+
1379
+ The t() function MUST use loaded translations to return human-readable text, NOT raw keys.
1380
+
1381
+ ## Auth Pattern
1382
+
1383
+ \`\`\`javascript
1384
+ // Restore session from storage — MUST call login() first
1385
+ // getSession() alone returns null until login() is called
1386
+ var session = await AIMEAT.auth.login();
1387
+ if (!session) {
1388
+ // No stored session — show login button
1389
+ // mountLoginButton takes a CSS SELECTOR string, NOT a DOM element
1390
+ container.id = container.id || 'app-auth';
1391
+ AIMEAT.auth.mountLoginButton('#' + container.id);
1392
+ return { ready: false, authenticated: false };
1393
+ }
1394
+ \`\`\`
1395
+
1396
+ ## Nested Object Helper (MUST include)
1397
+ API responses contain nested objects. Include this helper in the IIFE:
1398
+ \`\`\`javascript
1399
+ function dv(val) {
1400
+ if (val == null) return '-';
1401
+ if (typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean') return String(val);
1402
+ if (val.value) return val.value;
1403
+ if (val.url) return val.url;
1404
+ if (val.name) return val.name;
1405
+ if (Array.isArray(val)) return val.map(dv).join(', ');
1406
+ return JSON.stringify(val);
1407
+ }
1408
+ \`\`\`
1409
+
1410
+ ## CRITICAL RULES
1411
+
1412
+ 1. ZERO implementation code in the skeleton — only structure.
1413
+ 2. List ALL feature cortex components that will be composed.
1414
+ 3. Export names must be exactly: init, render, t, switchLocale, getTranslations.
1415
+ 4. init() MUST call AIMEAT.auth.login() first, THEN load translations.
1416
+ 5. init() MUST load translations via AIMEAT.data.get('SERVICE_PREFIX.i18n.' + locale) with fallback to AIMEAT.data.get('i18n.' + locale).
1417
+ 6. t(key) MUST return the translated string from loaded translations, NOT the raw key.
1418
+ 7. render() MUST call init() first if translations aren't loaded yet.
1419
+ 8. Store translations in AIMEAT._translations so feature cortexes can access them.
1420
+ `;
1421
+ }
1422
+
1423
+ /**
1424
+ * Build skeleton prompt for app.
1425
+ */
1426
+ export function buildAppSkeletonPrompt({ label, description, blueprint, interviewSpec, appDomainCortexSkeleton, appDomainCortexProbe }) {
1427
+ const views = interviewSpec?.views || [];
1428
+ const style = interviewSpec?.style || {};
1429
+
1430
+ return `${INSTRUCTION_DISCLAIMER}
1431
+ # Task: Generate App Skeleton
1432
+
1433
+ You are generating a SKELETON for an AIMEAT app. An app is an HTML page that loads the app-domain cortex and renders feature cortex components into containers.
1434
+
1435
+ ## Project
1436
+ ${description}
1437
+
1438
+ ## Views
1439
+ ${views.map(v => `- ${v.name}: ${v.description || ''}`).join('\n') || 'Not specified.'}
1440
+
1441
+ ## Style Preferences
1442
+ ${JSON.stringify(style, null, 2)}
1443
+
1444
+ ## App-Domain Cortex API
1445
+ ${appDomainCortexSkeleton || 'Not available.'}
1446
+
1447
+ ## App-Domain Cortex Probe (Real API Surface)
1448
+ ${appDomainCortexProbe ? JSON.stringify(appDomainCortexProbe, null, 2).slice(0, 2000) : 'Not available.'}
1449
+
1450
+ ## Output Format
1451
+
1452
+ \`\`\`yaml
1453
+ component: app
1454
+ name: <App Display Name>
1455
+ version: 1.0.0
1456
+
1457
+ cortex: <app-domain-cortex-name>
1458
+
1459
+ views:
1460
+ - id: <view-id>
1461
+ tab: <translation-key-for-tab-label>
1462
+ feature: <feature-cortex-name>
1463
+ layout: "<layout description>"
1464
+
1465
+ navigation: tabs
1466
+ auth: required
1467
+ locales: [fi, en]
1468
+ defaultLocale: fi
1469
+ \`\`\`
1470
+
1471
+ ## CRITICAL RULES
1472
+
1473
+ 1. ZERO implementation code. Only view definitions and layout descriptions.
1474
+ 2. Every view from the interview spec must appear.
1475
+ 3. Tab labels must use translation keys, not hardcoded text.
1476
+ `;
1477
+ }
1478
+
1479
+ /* ── Unit Fill Prompt Builders (Multi-Pass Pipeline) ──── */
1480
+
1481
+ /**
1482
+ * Build prompt for implementing a single extension action.
1483
+ * Produces just the handler function body — no manifest, no boilerplate.
1484
+ */
1485
+ export function buildExtensionUnitPrompt({ skeleton, unitDef, dataSources, testExcerpt }) {
1486
+ // Pick only the sandbox APIs this action needs
1487
+ const apis = [];
1488
+ if (unitDef.dataSource) apis.push('ctx.fetch(url, { method, headers, body }) → { status, ok, text, headers }. Body is always .text (string) — parse with JSON.parse(resp.text).');
1489
+ if (unitDef.reads?.length || unitDef.writes?.length) {
1490
+ apis.push('ctx.memory.get(key) → value|null. ctx.memory.set(key, value). ctx.memory.search(prefix) → Array<{key,value}>. ctx.memory.delete(key) → boolean.');
1491
+ apis.push('ctx.memory.getPublic(namespace, key) → value|null. Use for owner data: ctx.memory.getPublic(ctx.caller.gaii, key).');
1492
+ }
1493
+ if (unitDef.schedule) apis.push('Scheduled actions run automatically via cron. The handler receives empty input and ctx.');
1494
+
1495
+ // Find the relevant data source
1496
+ const ds = dataSources?.find(d => unitDef.dataSource && d.url === unitDef.dataSource);
1497
+
1498
+ return `${INSTRUCTION_DISCLAIMER}
1499
+ # Task: Implement Extension Action — \`${unitDef.id}\`
1500
+
1501
+ You are implementing ONE action handler for an AIMEAT extension. Return ONLY the function body.
1502
+
1503
+ ## Skeleton (full contract — do not deviate)
1504
+ \`\`\`yaml
1505
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1506
+ \`\`\`
1507
+
1508
+ ## This Action's Contract
1509
+ - **ID:** ${unitDef.id}
1510
+ - **Method:** ${unitDef.method || 'POST'}
1511
+ - **Path:** ${unitDef.path || '/' + unitDef.id}
1512
+ - **Input:** \`${JSON.stringify(unitDef.input || {})}\`
1513
+ - **Output:** \`${JSON.stringify(unitDef.output || {})}\`
1514
+ ${unitDef.reads?.length ? `- **Reads:** ${unitDef.reads.join(', ')}` : ''}
1515
+ ${unitDef.writes?.length ? `- **Writes:** ${unitDef.writes.join(', ')}` : ''}
1516
+ ${unitDef.schedule ? `- **Schedule:** ${unitDef.schedule}` : ''}
1517
+ ${unitDef.notes ? `- **Notes:** ${unitDef.notes}` : ''}
1518
+ ${ds ? `
1519
+ ## Data Source
1520
+ - **URL:** ${ds.url}
1521
+ - **Sample Response:**
1522
+ \`\`\`
1523
+ ${typeof ds.sampleResponse === 'string' ? ds.sampleResponse.slice(0, 2000) : JSON.stringify(ds.sampleResponse, null, 2).slice(0, 2000)}
1524
+ \`\`\`
1525
+ ${ds.notes ? `- **Notes:** ${ds.notes}` : ''}` : ''}
1526
+
1527
+ ${SANDBOX_CONSTRAINTS}
1528
+
1529
+ ${testExcerpt ? `## Test Excerpt (your code must pass this)\n\`\`\`\n${testExcerpt.slice(0, 1500)}\n\`\`\`` : ''}
1530
+
1531
+ ${HTML_ENTITY_RULES}
1532
+
1533
+ ## Output Format
1534
+
1535
+ Return ONLY the action function. No YAML, no manifest, no wrapping:
1536
+
1537
+ \`\`\`javascript
1538
+ export default async function(ctx, input) {
1539
+ // your implementation here
1540
+ }
1541
+ \`\`\`
1542
+
1543
+ CRITICAL: The function signature MUST be \`export default async function(ctx, input)\` — ctx is the FIRST parameter, input is the SECOND. The V8 sandbox requires this exact format.
1544
+ `;
1545
+ }
1546
+
1547
+ /**
1548
+ * Build prompt for implementing a single cortex method (data or feature cortex).
1549
+ * Produces just the method function — no IIFE wrapper, no registration.
1550
+ */
1551
+ export function buildCortexMethodUnitPrompt({ skeleton, unitDef, extensionProbeResult, componentSubtype }) {
1552
+ const isDataCortex = componentSubtype === 'data';
1553
+
1554
+ // Show the right pattern based on how the method accesses data
1555
+ let accessPattern = '';
1556
+ if (unitDef.calls) {
1557
+ accessPattern = `
1558
+ ## Extension Call Pattern
1559
+ \`\`\`javascript
1560
+ // callExt helper is defined at the top of the IIFE — use it for ALL extension calls
1561
+ // It uses AIMEAT.auth session.fetch() for proper auth handling
1562
+ async function callExt(actionId, body) {
1563
+ try {
1564
+ if (!AIMEAT.auth || !AIMEAT.auth.getSession) {
1565
+ console.warn('[cortex] callExt(' + actionId + '): auth not available');
1566
+ return null;
1567
+ }
1568
+ var session = AIMEAT.auth.getSession();
1569
+ if (!session || !session.fetch) {
1570
+ console.warn('[cortex] callExt(' + actionId + '): no session — login required');
1571
+ return null;
1572
+ }
1573
+ var resp = await session.fetch('/v1/ext/' + EXT_NAME + '/' + actionId, {
1574
+ method: 'POST',
1575
+ headers: { 'Content-Type': 'application/json' },
1576
+ body: JSON.stringify(body || {})
1577
+ });
1578
+ if (!resp || !resp.ok) {
1579
+ console.warn('[cortex] callExt(' + actionId + '): failed', resp?.error || resp?.status);
1580
+ return null;
1581
+ }
1582
+ return resp.data?.result ?? resp.data ?? null;
1583
+ } catch(e) {
1584
+ console.warn('[cortex] callExt(' + actionId + '):', e.message);
1585
+ return null;
1586
+ }
1587
+ }
1588
+
1589
+ // Usage in your method:
1590
+ const result = await callExt('${unitDef.calls}', { /* input */ });
1591
+ // ALWAYS null-check: if (!result) return fallbackValue;
1592
+ \`\`\`
1593
+ IMPORTANT: session.fetch() returns ALREADY-PARSED JSON — do NOT call resp.json(). Use resp.data directly.
1594
+ IMPORTANT: ALWAYS null-check the result — callExt returns null on auth failure or network error.`;
1595
+ } else if (unitDef.reads) {
1596
+ accessPattern = `
1597
+ ## Memory Read Pattern
1598
+ \`\`\`javascript
1599
+ // Read extension data from ext: namespace
1600
+ const data = await AIMEAT.data.getPublic('ext:<extension-name>', '${unitDef.reads}');
1601
+ // ALWAYS null-check: data may be null on first run
1602
+ \`\`\`
1603
+ IMPORTANT: Do NOT use session.fetch — it does not exist in cortex scope.`;
1604
+ }
1605
+
1606
+ return `${INSTRUCTION_DISCLAIMER}
1607
+ # Task: Implement Cortex Method — \`${unitDef.name}\`
1608
+
1609
+ You are implementing ONE method for an AIMEAT ${isDataCortex ? 'data' : 'feature'} cortex. Return ONLY the function.
1610
+
1611
+ ## Skeleton (full contract)
1612
+ \`\`\`yaml
1613
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1614
+ \`\`\`
1615
+
1616
+ ## This Method's Contract
1617
+ - **Name:** ${unitDef.name}
1618
+ - **Params:** \`${JSON.stringify(unitDef.params || {})}\`
1619
+ - **Returns:** \`${JSON.stringify(unitDef.returns || {})}\`
1620
+ ${unitDef.calls ? `- **Calls extension action:** ${unitDef.calls}` : ''}
1621
+ ${unitDef.reads ? `- **Reads memory key:** ${unitDef.reads}` : ''}
1622
+ ${accessPattern}
1623
+ ${extensionProbeResult ? `
1624
+ ## Extension Probe Result (real data — match this shape)
1625
+ \`\`\`json
1626
+ ${JSON.stringify(extensionProbeResult, null, 2).slice(0, 2000)}
1627
+ \`\`\`` : ''}
1628
+
1629
+ ## Output Format
1630
+
1631
+ Return ONLY the method function:
1632
+
1633
+ \`\`\`javascript
1634
+ async function ${unitDef.name}(${unitDef.params ? Object.keys(unitDef.params).join(', ') : ''}) {
1635
+ // your implementation here
1636
+ }
1637
+ \`\`\`
1638
+ `;
1639
+ }
1640
+
1641
+ /**
1642
+ * Build prompt for implementing a single feature cortex UI section.
1643
+ * Produces the section's render function — one self-contained UI area.
1644
+ */
1645
+ export function buildFeatureCortexSectionPrompt({ skeleton, sectionDef, dataCortexProbe, platformUiExample, translationKeys }) {
1646
+ // Default platform UI examples for common component types
1647
+ const defaultUiExamples = {
1648
+ input: `var nameInput = AIMEAT['aimeat-ui-forms'].Input({ label: 'Hakusana', placeholder: 'Hae...', type: 'text' });
1649
+ container.appendChild(nameInput.el);
1650
+ // Read value: nameInput.getValue()
1651
+ // Listen: nameInput.el.querySelector('input').addEventListener('input', function(e) { ... });`,
1652
+ button: `var btn = document.createElement('button');
1653
+ btn.textContent = t('search.button') || 'Hae';
1654
+ btn.onclick = async function() { /* action */ };
1655
+ container.appendChild(btn);`,
1656
+ table: `var table = AIMEAT['aimeat-ui-viewers'].DataTable({
1657
+ columns: [{ key: 'name', label: 'Nimi', sortable: true }, { key: 'id', label: 'ID' }],
1658
+ rows: data,
1659
+ sortable: true, filterable: true, pageSize: 20
1660
+ });
1661
+ container.appendChild(table);
1662
+ // NOTE: DataTable does NOT have onRowClick. Build your own card list for clickable rows.`,
1663
+ timeline: `var timeline = AIMEAT['aimeat-ui-viewers'].Timeline({
1664
+ events: changes.map(function(c) {
1665
+ return { date: c.detectedAt, title: c.field, description: (c.oldValue || '-') + ' → ' + (c.newValue || '-') };
1666
+ })
1667
+ });
1668
+ container.appendChild(timeline);`,
1669
+ list: `// Build a simple list with items
1670
+ items.forEach(function(item) {
1671
+ var row = document.createElement('div');
1672
+ row.style.cssText = 'display:flex;justify-content:space-between;padding:8px;border-bottom:1px solid #eee;';
1673
+ row.textContent = item.name || item.id;
1674
+ container.appendChild(row);
1675
+ });`,
1676
+ card: `var card = document.createElement('div');
1677
+ card.style.cssText = 'padding:16px;border:1px solid #e2e8f0;border-radius:8px;margin-bottom:8px;';
1678
+ card.innerHTML = '<h3>' + title + '</h3><p>' + content + '</p>';
1679
+ container.appendChild(card);`,
1680
+ tabs: `var tabs = AIMEAT['aimeat-ui-nav'].Tabs({
1681
+ target: container,
1682
+ tabs: [{ id: 'tab1', label: 'Tab 1' }, { id: 'tab2', label: 'Tab 2' }],
1683
+ active: 'tab1',
1684
+ onChange: function(tabId) { switchTab(tabId); }
1685
+ });`,
1686
+ toggle: `var toggle = AIMEAT['aimeat-ui-forms'].Toggle({
1687
+ label: 'Ilmoitukset', checked: true,
1688
+ onChange: function(checked) { savePref(checked); }
1689
+ });
1690
+ container.appendChild(toggle.el);`,
1691
+ select: `var sel = AIMEAT['aimeat-ui-forms'].Select({
1692
+ label: 'Kieli', options: [{ value: 'fi', label: 'Suomi' }, { value: 'en', label: 'English' }]
1693
+ });
1694
+ container.appendChild(sel.el);
1695
+ // Read value: sel.getValue()`,
1696
+ };
1697
+
1698
+ // Show only the platform UI components this section uses
1699
+ let uiExampleText = '';
1700
+ const uiComponents = sectionDef.uses?.ui || [];
1701
+ if (uiComponents.length > 0) {
1702
+ uiExampleText = `
1703
+ ## Platform UI Components (only the ones this section uses)
1704
+ ${uiComponents.map(comp => {
1705
+ const example = platformUiExample?.[comp] || defaultUiExamples[comp];
1706
+ return example ? `### ${comp}\n\`\`\`javascript\n${example}\n\`\`\`` : `### ${comp}\n(use standard DOM creation)`;
1707
+ }).join('\n\n')}`;
1708
+ }
1709
+
1710
+ return `${INSTRUCTION_DISCLAIMER}
1711
+ # Task: Implement Feature Cortex Section — \`${sectionDef.id}\`
1712
+
1713
+ You are implementing ONE UI section for a feature cortex. Return ONLY the section render function.
1714
+
1715
+ ## Skeleton (full contract)
1716
+ \`\`\`yaml
1717
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1718
+ \`\`\`
1719
+
1720
+ ## This Section's Definition
1721
+ - **ID:** ${sectionDef.id}
1722
+ - **Description:** ${sectionDef.description || ''}
1723
+ - **Data methods used:** ${sectionDef.uses?.data?.join(', ') || 'none'}
1724
+ - **UI components used:** ${sectionDef.uses?.ui?.join(', ') || 'none'}
1725
+ - **Translation keys:** ${(sectionDef.translationKeys || []).join(', ') || 'none'}
1726
+ ${dataCortexProbe ? `
1727
+ ## Data Cortex Probe Results (real data for the methods this section uses)
1728
+ ${Object.entries(dataCortexProbe).filter(([method]) => sectionDef.uses?.data?.includes(method)).map(([method, result]) => `### ${method}()\n\`\`\`json\n${JSON.stringify(result, null, 2).slice(0, 1000)}\n\`\`\``).join('\n\n')}` : ''}
1729
+ ${uiExampleText}
1730
+
1731
+ ## Translation Helper Pattern
1732
+ \`\`\`javascript
1733
+ // t() is available in scope — use for all user-visible text
1734
+ var label = t('${(translationKeys || [])[0] || 'section.title'}');
1735
+ \`\`\`
1736
+
1737
+ ## Async Data Loading Pattern (CRITICAL)
1738
+ Data cortex methods return Promises. Handle loading states:
1739
+ \`\`\`javascript
1740
+ // Show loading state
1741
+ container.innerHTML = '<p>Ladataan...</p>';
1742
+ // Call data cortex method
1743
+ var data = await dataCortex.someMethod();
1744
+ // ALWAYS null-check — callExt returns null on auth failure or first run
1745
+ if (!data || (Array.isArray(data) && data.length === 0)) {
1746
+ container.innerHTML = '<p>' + (t('empty.key') || 'Ei dataa') + '</p>';
1747
+ return;
1748
+ }
1749
+ // Now render the data...
1750
+ \`\`\`
1751
+
1752
+ ## Nested Object Helper
1753
+ API responses contain nested objects. Use this to safely render values:
1754
+ \`\`\`javascript
1755
+ function dv(val) {
1756
+ if (val == null) return '-';
1757
+ if (typeof val === 'string' || typeof val === 'number') return String(val);
1758
+ if (val.value) return val.value;
1759
+ if (val.url) return val.url;
1760
+ if (val.name) return val.name;
1761
+ if (Array.isArray(val)) return val.map(dv).join(', ');
1762
+ return JSON.stringify(val);
1763
+ }
1764
+ \`\`\`
1765
+
1766
+ ## Output Format
1767
+
1768
+ Return ONLY the section render function:
1769
+
1770
+ \`\`\`javascript
1771
+ function render${sectionDef.id.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join('')}(container, { dataCortex, t }) {
1772
+ // your implementation here
1773
+ }
1774
+ \`\`\`
1775
+ `;
1776
+ }
1777
+
1778
+ /**
1779
+ * Build prompt for implementing a single app view.
1780
+ * Produces the view's HTML fragment + mount function.
1781
+ */
1782
+ export function buildAppViewUnitPrompt({ skeleton, viewDef, featureCortexRenderSpec, translationKeys }) {
1783
+ return `${INSTRUCTION_DISCLAIMER}
1784
+ # Task: Implement App View — \`${viewDef.id}\`
1785
+
1786
+ You are implementing ONE view for an AIMEAT app. Return the view HTML + mount function.
1787
+
1788
+ ## Skeleton (full contract)
1789
+ \`\`\`yaml
1790
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1791
+ \`\`\`
1792
+
1793
+ ## This View's Definition
1794
+ - **ID:** ${viewDef.id}
1795
+ - **Tab label key:** ${viewDef.tab || viewDef.id}
1796
+ - **Feature cortex:** ${viewDef.feature || 'none'}
1797
+ - **Layout:** ${viewDef.layout || 'default'}
1798
+ ${translationKeys?.length ? `- **Translation keys:** ${translationKeys.join(', ')}` : ''}
1799
+ ${featureCortexRenderSpec ? `
1800
+ ## Feature Cortex Render Spec
1801
+ The feature cortex exposes \`render(container)\`. Call it to render the feature into the view container.
1802
+ \`\`\`
1803
+ ${typeof featureCortexRenderSpec === 'string' ? featureCortexRenderSpec.slice(0, 1500) : JSON.stringify(featureCortexRenderSpec, null, 2).slice(0, 1500)}
1804
+ \`\`\`` : ''}
1805
+
1806
+ ## Output Format
1807
+
1808
+ Return the view HTML and mount function:
1809
+
1810
+ \`\`\`html
1811
+ <!-- View: ${viewDef.id} -->
1812
+ <div id="view-${viewDef.id}" class="app-view" style="display:none;">
1813
+ <!-- view content -->
1814
+ </div>
1815
+ \`\`\`
1816
+
1817
+ \`\`\`javascript
1818
+ function mount${viewDef.id.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join('')}(container, { cortex, t }) {
1819
+ // mount feature cortex into container
1820
+ }
1821
+ \`\`\`
1822
+ `;
1823
+ }
1824
+
1825
+ /* ── Assembly Prompt Builders (Multi-Pass Pipeline) ──── */
1826
+
1827
+ /**
1828
+ * Combine extension skeleton + all unit implementations into final YAML manifest + JS actions.
1829
+ * Assembly is mechanical — no new logic, just combining pieces.
1830
+ */
1831
+ export function buildExtensionAssemblyPrompt({ skeleton, units, label }) {
1832
+ return `${INSTRUCTION_DISCLAIMER}
1833
+ # Task: Assemble Extension — ${label}
1834
+
1835
+ You are ASSEMBLING a complete AIMEAT extension from a skeleton and pre-built unit implementations. This is MECHANICAL assembly — do NOT modify the unit implementations.
1836
+
1837
+ ## Skeleton (the contract)
1838
+ \`\`\`yaml
1839
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1840
+ \`\`\`
1841
+
1842
+ ## Unit Implementations
1843
+ ${units.map((u, i) => `### Action: ${u.id} (unit ${i + 1})\n\`\`\`javascript\n${u.code}\n\`\`\``).join('\n\n')}
1844
+
1845
+ ## Output Format
1846
+
1847
+ Produce the complete extension: YAML manifest first, then fenced JS blocks per action.
1848
+
1849
+ \`\`\`yaml
1850
+ metadata:
1851
+ name: <kebab-case-name>
1852
+ version: "1.0.0"
1853
+ description: "<from skeleton — double-quoted, one line>"
1854
+ author: foundry
1855
+ required_apis: [memory]
1856
+ config: {}
1857
+ limits:
1858
+ memory_mb: 128
1859
+ timeout_ms: 30000
1860
+ max_api_calls: 500
1861
+ actions:
1862
+ - id: <actionId>
1863
+ description: "<from skeleton>"
1864
+ method: POST
1865
+ path: /v1/ext/<extensionName>/<actionId>
1866
+ auth: required
1867
+ input: <schema>
1868
+ output: <schema>
1869
+ script: <actionId>.js
1870
+ # ... repeat for EVERY action from the skeleton
1871
+ schedules:
1872
+ - id: <schedule-id>
1873
+ action: <actionId>
1874
+ cron: "<expression>"
1875
+ description: "<what it does>"
1876
+ instance_scope: false
1877
+ input: {}
1878
+ \`\`\`
1879
+
1880
+ Then one fenced JS block per action (use \`// actions/<actionId>.js\` comment):
1881
+
1882
+ \`\`\`javascript
1883
+ // actions/<actionId>.js
1884
+ export default async function(ctx, input) {
1885
+ // EXACT code from the unit implementation above — do NOT modify
1886
+ }
1887
+ \`\`\`
1888
+
1889
+ ## CRITICAL RULES
1890
+
1891
+ 1. **Do NOT modify the unit implementations.** Copy each action function exactly as provided.
1892
+ 2. **Use action IDs, schemas, and config from the skeleton.** Do not rename or reorder.
1893
+ 3. **Every action in the skeleton must appear in the manifest AND have a JS block.**
1894
+ 4. **Assembly is mechanical.** You are combining pieces, not generating new logic.
1895
+ 5. **metadata MUST include \`author: foundry\`** — the validator requires this field.
1896
+ 6. **Every action MUST have \`method: POST\` and \`path: /v1/ext/<name>/<path>\`** — the validator requires these.
1897
+ 7. **All action JS MUST use \`export default async function(ctx, input)\`** — the V8 sandbox requires ES module default export.
1898
+
1899
+ ${HTML_ENTITY_RULES}
1900
+ `;
1901
+ }
1902
+
1903
+ /**
1904
+ * Combine cortex skeleton + all unit implementations into final cortex YAML manifest + JS IIFE.
1905
+ */
1906
+ export function buildCortexAssemblyPrompt({ skeleton, units, label, subtype }) {
1907
+ const subtypeLabel = subtype === 'data' ? 'Data Cortex' : subtype === 'feature' ? 'Feature Cortex' : 'App-Domain Cortex';
1908
+
1909
+ return `${INSTRUCTION_DISCLAIMER}
1910
+ # Task: Assemble ${subtypeLabel} — ${label}
1911
+
1912
+ You are ASSEMBLING a complete AIMEAT cortex library from a skeleton and pre-built unit implementations. This is MECHANICAL assembly — do NOT modify the unit implementations.
1913
+
1914
+ ## Skeleton (the contract)
1915
+ \`\`\`yaml
1916
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
1917
+ \`\`\`
1918
+
1919
+ ## Unit Implementations
1920
+ ${units.map((u, i) => `### ${u.name || u.id} (unit ${i + 1})\n\`\`\`javascript\n${u.code}\n\`\`\``).join('\n\n')}
1921
+
1922
+ ## Output Format
1923
+
1924
+ Produce the complete cortex: YAML manifest block, then the JS IIFE.
1925
+
1926
+ \`\`\`yaml
1927
+ apiVersion: cortex.aimeat.org/v1
1928
+ kind: Extension
1929
+ metadata:
1930
+ name: <kebab-case-name>
1931
+ version: "1.0.0"
1932
+ description: "<from skeleton>"
1933
+ components:
1934
+ - type: lib
1935
+ filename: <name>.js
1936
+ exports: [<method-names>]
1937
+ \`\`\`
1938
+
1939
+ \`\`\`javascript
1940
+ // <name>.js — ${subtypeLabel} IIFE
1941
+ (function (AIMEAT) {
1942
+ 'use strict';
1943
+ const LIB_NAME = '<camelCaseName>'; // kebab "my-lib" → camelCase "myLib"
1944
+ const EXT_NAME = '<extension-name>'; // the extension this cortex wraps
1945
+
1946
+ // --- callExt helper — uses session.fetch() for proper auth ---
1947
+ async function callExt(actionId, body) {
1948
+ try {
1949
+ if (!AIMEAT.auth || !AIMEAT.auth.getSession) {
1950
+ console.warn('[' + LIB_NAME + '] callExt(' + actionId + '): auth not available');
1951
+ return null;
1952
+ }
1953
+ var session = AIMEAT.auth.getSession();
1954
+ if (!session || !session.fetch) {
1955
+ console.warn('[' + LIB_NAME + '] callExt(' + actionId + '): no active session — login required');
1956
+ return null;
1957
+ }
1958
+ var resp = await session.fetch('/v1/ext/' + EXT_NAME + '/' + actionId, {
1959
+ method: 'POST',
1960
+ headers: { 'Content-Type': 'application/json' },
1961
+ body: JSON.stringify(body || {})
1962
+ });
1963
+ if (!resp || !resp.ok) {
1964
+ console.warn('[' + LIB_NAME + '] callExt(' + actionId + '): failed', resp?.error || resp?.status);
1965
+ return null;
1966
+ }
1967
+ return resp.data?.result ?? resp.data ?? null;
1968
+ } catch(e) {
1969
+ console.warn('[' + LIB_NAME + '] callExt(' + actionId + '):', e.message);
1970
+ return null;
1971
+ }
1972
+ }
1973
+
1974
+ // --- readExtMemory helper — reads extension-owned data ---
1975
+ async function readExtMemory(key) {
1976
+ try { return await AIMEAT.data.getPublic('ext:' + EXT_NAME, key); }
1977
+ catch(e) { return null; }
1978
+ }
1979
+
1980
+ // --- Translation helper — reads from AIMEAT._translations (set by app-domain cortex init) ---
1981
+ function t(key) {
1982
+ var translations = AIMEAT._translations || {};
1983
+ return translations[key] || '';
1984
+ }
1985
+
1986
+ // --- Nested object display helper ---
1987
+ function dv(val) {
1988
+ if (val == null) return '-';
1989
+ if (typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean') return String(val);
1990
+ if (val.value) return val.value;
1991
+ if (val.url) return val.url;
1992
+ if (val.name) return val.name;
1993
+ if (Array.isArray(val)) return val.map(dv).join(', ');
1994
+ return JSON.stringify(val);
1995
+ }
1996
+
1997
+ // --- Unit implementations (copied exactly) ---
1998
+ // PASTE each unit function here.
1999
+
2000
+ // --- Registration ---
2001
+ const exports = { /* all public method names */ };
2002
+ if (AIMEAT.register) AIMEAT.register(LIB_NAME, exports);
2003
+ AIMEAT[LIB_NAME] = exports;
2004
+ })(window.AIMEAT || (window.AIMEAT = {}));
2005
+ \`\`\`
2006
+
2007
+ YAML manifest MUST include \`namespace: community\` under metadata.
2008
+
2009
+ ## CRITICAL RULES
2010
+
2011
+ 1. **Do NOT modify the unit implementations.**
2012
+ 2. **YAML metadata.name (kebab-case) and JS LIB_NAME (camelCase) must correspond.** Example: \`my-data-layer\` → \`myDataLayer\`.
2013
+ 3. **YAML metadata MUST have namespace: community.**
2014
+ 4. **Every method from the skeleton must appear in the exports object.**
2015
+ 5. **Use (function(AIMEAT){...})(window.AIMEAT||(window.AIMEAT={}))** — NOT (function(){...})().
2016
+ 6. **Must have \`const exports = { ... }\`** — the validator checks for this pattern.
2017
+ 7. **Assembly is mechanical.** Combine pieces, don't generate new logic.
2018
+ 8. **callExt uses session.fetch()** which returns ALREADY-PARSED JSON. Use \`resp.data\`, NEVER \`resp.json()\`.
2019
+ 9. **callExt returns null on error** — all methods MUST null-check results before using them.
2020
+ 10. **ALWAYS handle null from callExt gracefully** — return empty arrays \`[]\` or empty objects \`{}\`, NEVER crash.
2021
+
2022
+ ${HTML_ENTITY_RULES}
2023
+ `;
2024
+ }
2025
+
2026
+ /**
2027
+ * Combine app skeleton + all view unit implementations into complete HTML document.
2028
+ */
2029
+ export function buildAppAssemblyPrompt({ skeleton, units, label, appDomainCortexName, designSystem }) {
2030
+ return `${INSTRUCTION_DISCLAIMER}
2031
+ # Task: Assemble App — ${label}
2032
+
2033
+ You are ASSEMBLING a complete AIMEAT app HTML document from a skeleton and pre-built view implementations. This is MECHANICAL assembly — do NOT modify the unit implementations.
2034
+
2035
+ ## Skeleton (the contract)
2036
+ \`\`\`yaml
2037
+ ${typeof skeleton === 'string' ? skeleton : JSON.stringify(skeleton, null, 2)}
2038
+ \`\`\`
2039
+
2040
+ ## View Implementations
2041
+ ${units.map((u, i) => `### View: ${u.id} (unit ${i + 1})\n**HTML:**\n\`\`\`html\n${u.html || ''}\n\`\`\`\n**JS:**\n\`\`\`javascript\n${u.code || ''}\n\`\`\``).join('\n\n')}
2042
+
2043
+ ## App-Domain Cortex
2044
+ Name: ${appDomainCortexName || '<from skeleton>'}
2045
+ ${designSystem ? `\n## Design System\n${designSystem}` : ''}
2046
+
2047
+ ## Output Format
2048
+
2049
+ Produce the complete HTML document. EVERY section below is MANDATORY:
2050
+
2051
+ \`\`\`html
2052
+ <!-- AIMEAT App Manifest
2053
+ name: <kebab-case-name>
2054
+ version: 1.0.0
2055
+ description: <one-line description>
2056
+ entry: index.html
2057
+ -->
2058
+ <!DOCTYPE html>
2059
+ <html lang="fi">
2060
+ <head>
2061
+ <meta charset="UTF-8">
2062
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2063
+ <title>${label}</title>
2064
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; connect-src 'self';">
2065
+ <style>
2066
+ :root {
2067
+ --color-primary: #3b82f6;
2068
+ --color-secondary: #64748b;
2069
+ --color-success: #22c55e;
2070
+ --color-danger: #ef4444;
2071
+ --color-bg: #ffffff;
2072
+ --color-text: #1e293b;
2073
+ --color-text-dim: #64748b;
2074
+ --color-border: #e2e8f0;
2075
+ --radius: 8px;
2076
+ --spacing-sm: 8px;
2077
+ --spacing-md: 16px;
2078
+ --spacing-lg: 24px;
2079
+ --font-sans: system-ui, -apple-system, sans-serif;
2080
+ }
2081
+ body { font-family: var(--font-sans); margin: 0; padding: 0; color: var(--color-text); }
2082
+ #app { max-width: 900px; margin: 0 auto; padding: var(--spacing-md); }
2083
+ /* Add your app styles here */
2084
+ </style>
2085
+ </head>
2086
+ <body>
2087
+ <!-- Error collector — surfaces runtime errors in UI -->
2088
+ <script>
2089
+ (function() {
2090
+ var errors = [];
2091
+ window.onerror = function(msg, src, line) {
2092
+ errors.push({ msg: msg, src: src, line: line, at: new Date().toISOString() });
2093
+ showErrors();
2094
+ };
2095
+ window.addEventListener('unhandledrejection', function(e) {
2096
+ errors.push({ msg: String(e.reason), src: 'promise', line: 0, at: new Date().toISOString() });
2097
+ showErrors();
2098
+ });
2099
+ function showErrors() {
2100
+ var el = document.getElementById('app-errors');
2101
+ if (!el) {
2102
+ el = document.createElement('div');
2103
+ el.id = 'app-errors';
2104
+ el.style.cssText = 'position:fixed;bottom:0;left:0;right:0;background:#1a0000;color:#ff6b6b;font-size:12px;padding:8px;max-height:120px;overflow:auto;z-index:9999;font-family:monospace;border-top:2px solid #f44';
2105
+ document.body.appendChild(el);
2106
+ }
2107
+ el.innerHTML = errors.map(function(e) { return e.at.slice(11,19) + ' ' + e.msg; }).join('<br>');
2108
+ }
2109
+ })();
2110
+ </script>
2111
+
2112
+ <div id="auth-container"></div>
2113
+ <!-- View containers (from unit HTML — copy exactly) -->
2114
+ <div id="app"></div>
2115
+
2116
+ <script>
2117
+ // loadScript helper — loads scripts sequentially
2118
+ function loadScript(src) {
2119
+ return new Promise(function(resolve, reject) {
2120
+ var s = document.createElement('script');
2121
+ s.src = src;
2122
+ s.onload = resolve;
2123
+ s.onerror = function() { reject(new Error('Failed to load: ' + src)); };
2124
+ document.head.appendChild(s);
2125
+ });
2126
+ }
2127
+
2128
+ // Boot sequence — MUST load libraries in correct order
2129
+ (async function() {
2130
+ try {
2131
+ // 1. Load AIMEAT platform libraries FIRST
2132
+ await loadScript('/v1/libs/aimeat-auth.js');
2133
+ await loadScript('/v1/libs/aimeat-data.js');
2134
+
2135
+ // 2. Load platform UI libraries
2136
+ await loadScript('/v1/cortex/aimeat-ui-nav/libs/aimeat-ui-nav.js');
2137
+ await loadScript('/v1/cortex/aimeat-ui-layout/libs/aimeat-ui-layout.js');
2138
+ await loadScript('/v1/cortex/aimeat-ui-viewers/libs/aimeat-ui-viewers.js');
2139
+ await loadScript('/v1/cortex/aimeat-ui-forms/libs/aimeat-ui-forms.js');
2140
+ await loadScript('/v1/cortex/aimeat-ui-dialogs/libs/aimeat-ui-dialogs.js');
2141
+
2142
+ // 3. Load domain cortex libraries (data cortex → feature cortexes → app-domain)
2143
+ // ADD ALL cortex script tags here in dependency order
2144
+
2145
+ // 4. Auth: try to restore session
2146
+ AIMEAT.auth.mountLoginButton('#auth-container', {
2147
+ onLogin: function() { startApp(); },
2148
+ onLogout: function() { location.reload(); }
2149
+ });
2150
+ var session = await AIMEAT.auth.login();
2151
+ if (session) startApp();
2152
+
2153
+ } catch(err) {
2154
+ document.getElementById('app').innerHTML =
2155
+ '<div style="padding:2rem;color:#ef4444"><h2>Failed to load</h2><p>' + err.message + '</p></div>';
2156
+ }
2157
+ })();
2158
+
2159
+ async function startApp() {
2160
+ var cortex = AIMEAT['<camelCaseName>']; // app-domain cortex
2161
+ if (!cortex) {
2162
+ document.getElementById('app').innerHTML = '<p>App cortex not loaded</p>';
2163
+ return;
2164
+ }
2165
+ await cortex.init();
2166
+ cortex.render(document.getElementById('app'));
2167
+ }
2168
+ </script>
2169
+ </body>
2170
+ </html>
2171
+ \`\`\`
2172
+
2173
+ ## CRITICAL RULES
2174
+
2175
+ 1. **MUST start with \`<!-- AIMEAT App Manifest ... -->\` comment** — the validator checks for this.
2176
+ 2. **MUST load aimeat-auth.js and aimeat-data.js** before any cortex scripts.
2177
+ 3. **MUST call AIMEAT.auth.mountLoginButton('#auth-container', ...)** for login UI.
2178
+ 4. **MUST call AIMEAT.auth.login()** to restore session before starting the app.
2179
+ 5. **MUST load cortex scripts in dependency order**: data cortex → feature cortexes → app-domain cortex.
2180
+ 6. **startApp() is called ONLY after successful login** — the cortex init() and render() require auth.
2181
+ 7. **Do NOT modify the view unit implementations.** Copy HTML and JS exactly as provided.
2182
+ 8. **Include the error collector script** at the top of body for diagnostics.
2183
+ 9. **Include CSP meta tag** if loading any CDN scripts.
2184
+
2185
+ ${HTML_ENTITY_RULES}
2186
+ `;
2187
+ }