@xdelivered/emberflow 0.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 (414) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/bin/commands.test.ts +185 -0
  4. package/bin/commands.ts +306 -0
  5. package/bin/emberflow.mjs +38 -0
  6. package/bin/init.test.ts +165 -0
  7. package/bin/init.ts +297 -0
  8. package/bin/runtime.mjs +105 -0
  9. package/bin/runtime.test.ts +167 -0
  10. package/bin/skillTargets.test.ts +108 -0
  11. package/bin/skillTargets.ts +36 -0
  12. package/bin/skillTemplates.test.ts +37 -0
  13. package/bin/tsconfig.json +23 -0
  14. package/dist/bin/commands.d.ts +24 -0
  15. package/dist/bin/commands.js +252 -0
  16. package/dist/bin/init.d.ts +17 -0
  17. package/dist/bin/init.js +241 -0
  18. package/dist/bin/runtime.d.mts +39 -0
  19. package/dist/bin/runtime.mjs +96 -0
  20. package/dist/bin/skillTargets.d.ts +13 -0
  21. package/dist/bin/skillTargets.js +22 -0
  22. package/dist/server/agents/claudeAdapter.d.ts +8 -0
  23. package/dist/server/agents/claudeAdapter.js +190 -0
  24. package/dist/server/agents/claudeParse.d.ts +2 -0
  25. package/dist/server/agents/claudeParse.js +162 -0
  26. package/dist/server/agents/codexAdapter.d.ts +13 -0
  27. package/dist/server/agents/codexAdapter.js +174 -0
  28. package/dist/server/agents/codexParse.d.ts +2 -0
  29. package/dist/server/agents/codexParse.js +74 -0
  30. package/dist/server/agents/detect.d.ts +23 -0
  31. package/dist/server/agents/detect.js +35 -0
  32. package/dist/server/agents/gitScope.d.ts +24 -0
  33. package/dist/server/agents/gitScope.js +95 -0
  34. package/dist/server/agents/modelRejectionHint.d.ts +8 -0
  35. package/dist/server/agents/modelRejectionHint.js +12 -0
  36. package/dist/server/agents/prompt.d.ts +79 -0
  37. package/dist/server/agents/prompt.js +364 -0
  38. package/dist/server/agents/runManager.d.ts +90 -0
  39. package/dist/server/agents/runManager.js +259 -0
  40. package/dist/server/agents/types.d.ts +15 -0
  41. package/dist/server/agents/types.js +1 -0
  42. package/dist/server/apiStore.d.ts +60 -0
  43. package/dist/server/apiStore.js +249 -0
  44. package/dist/server/auth/enforce.d.ts +1 -0
  45. package/dist/server/auth/enforce.js +6 -0
  46. package/dist/server/auth/types.d.ts +1 -0
  47. package/dist/server/auth/types.js +1 -0
  48. package/dist/server/auth/verifiers.d.ts +1 -0
  49. package/dist/server/auth/verifiers.js +4 -0
  50. package/dist/server/authAttach.d.ts +19 -0
  51. package/dist/server/authAttach.js +79 -0
  52. package/dist/server/cli.d.ts +7 -0
  53. package/dist/server/cli.js +804 -0
  54. package/dist/server/client.d.ts +130 -0
  55. package/dist/server/client.js +247 -0
  56. package/dist/server/environments.d.ts +103 -0
  57. package/dist/server/environments.js +486 -0
  58. package/dist/server/flowStore.d.ts +37 -0
  59. package/dist/server/flowStore.js +117 -0
  60. package/dist/server/httpOperations.d.ts +32 -0
  61. package/dist/server/httpOperations.js +62 -0
  62. package/dist/server/index.d.ts +1 -0
  63. package/dist/server/index.js +1022 -0
  64. package/dist/server/infrastructure.d.ts +51 -0
  65. package/dist/server/infrastructure.js +116 -0
  66. package/dist/server/login.d.ts +21 -0
  67. package/dist/server/login.js +44 -0
  68. package/dist/server/mcp.d.ts +1 -0
  69. package/dist/server/mcp.js +182 -0
  70. package/dist/server/migrateFlows.d.ts +8 -0
  71. package/dist/server/migrateFlows.js +25 -0
  72. package/dist/server/mockHandler.d.ts +15 -0
  73. package/dist/server/mockHandler.js +35 -0
  74. package/dist/server/nodesPayload.d.ts +14 -0
  75. package/dist/server/nodesPayload.js +14 -0
  76. package/dist/server/normalizeFlow.d.ts +21 -0
  77. package/dist/server/normalizeFlow.js +48 -0
  78. package/dist/server/openBrowser.d.ts +8 -0
  79. package/dist/server/openBrowser.js +16 -0
  80. package/dist/server/operationResult.d.ts +12 -0
  81. package/dist/server/operationResult.js +26 -0
  82. package/dist/server/pathGuard.d.ts +1 -0
  83. package/dist/server/pathGuard.js +16 -0
  84. package/dist/server/pathSafety.d.ts +20 -0
  85. package/dist/server/pathSafety.js +35 -0
  86. package/dist/server/projectConfig.d.ts +47 -0
  87. package/dist/server/projectConfig.js +61 -0
  88. package/dist/server/projectMode.d.ts +26 -0
  89. package/dist/server/projectMode.js +44 -0
  90. package/dist/server/redact.d.ts +6 -0
  91. package/dist/server/redact.js +37 -0
  92. package/dist/server/runRegistry.d.ts +84 -0
  93. package/dist/server/runRegistry.js +200 -0
  94. package/dist/server/runtime/RuntimeAdapter.d.ts +22 -0
  95. package/dist/server/runtime/RuntimeAdapter.js +1 -0
  96. package/dist/server/runtime/expressAdapter.d.ts +19 -0
  97. package/dist/server/runtime/expressAdapter.js +56 -0
  98. package/dist/server/scenarioTest.d.ts +14 -0
  99. package/dist/server/scenarioTest.js +66 -0
  100. package/dist/server/subflowRunner.d.ts +32 -0
  101. package/dist/server/subflowRunner.js +72 -0
  102. package/dist/server/testRunner.d.ts +70 -0
  103. package/dist/server/testRunner.js +151 -0
  104. package/dist/src/config.d.ts +3 -0
  105. package/dist/src/config.js +2 -0
  106. package/dist/src/engine/authVerify.d.ts +33 -0
  107. package/dist/src/engine/authVerify.js +63 -0
  108. package/dist/src/engine/diagnostics.d.ts +62 -0
  109. package/dist/src/engine/diagnostics.js +148 -0
  110. package/dist/src/engine/executor.d.ts +151 -0
  111. package/dist/src/engine/executor.js +684 -0
  112. package/dist/src/engine/httpError.d.ts +7 -0
  113. package/dist/src/engine/httpError.js +14 -0
  114. package/dist/src/engine/index.d.ts +11 -0
  115. package/dist/src/engine/index.js +11 -0
  116. package/dist/src/engine/output.d.ts +11 -0
  117. package/dist/src/engine/output.js +20 -0
  118. package/dist/src/engine/publish.d.ts +30 -0
  119. package/dist/src/engine/publish.js +95 -0
  120. package/dist/src/engine/registry.d.ts +34 -0
  121. package/dist/src/engine/registry.js +67 -0
  122. package/dist/src/engine/scenarios.d.ts +12 -0
  123. package/dist/src/engine/scenarios.js +19 -0
  124. package/dist/src/engine/schemaCheck.d.ts +4 -0
  125. package/dist/src/engine/schemaCheck.js +34 -0
  126. package/dist/src/engine/trace.d.ts +12 -0
  127. package/dist/src/engine/trace.js +12 -0
  128. package/dist/src/engine/types.d.ts +308 -0
  129. package/dist/src/engine/types.js +1 -0
  130. package/dist/src/engine/validation.d.ts +26 -0
  131. package/dist/src/engine/validation.js +318 -0
  132. package/dist/src/flows/anomaly-flows.d.ts +23 -0
  133. package/dist/src/flows/anomaly-flows.js +151 -0
  134. package/dist/src/flows/city-sweep-flow.d.ts +10 -0
  135. package/dist/src/flows/city-sweep-flow.js +127 -0
  136. package/dist/src/flows/login-flow.d.ts +13 -0
  137. package/dist/src/flows/login-flow.js +145 -0
  138. package/dist/src/flows/pradar-flows.d.ts +5 -0
  139. package/dist/src/flows/pradar-flows.js +375 -0
  140. package/dist/src/flows/weather-flow.d.ts +12 -0
  141. package/dist/src/flows/weather-flow.js +150 -0
  142. package/dist/src/lib/pathParams.d.ts +3 -0
  143. package/dist/src/lib/pathParams.js +6 -0
  144. package/dist/src/nodes/anomaly.d.ts +2 -0
  145. package/dist/src/nodes/anomaly.js +556 -0
  146. package/dist/src/nodes/flow-control.d.ts +7 -0
  147. package/dist/src/nodes/flow-control.js +270 -0
  148. package/dist/src/nodes/index.d.ts +3 -0
  149. package/dist/src/nodes/index.js +20 -0
  150. package/dist/src/nodes/login.d.ts +7 -0
  151. package/dist/src/nodes/login.js +158 -0
  152. package/dist/src/nodes/loops.d.ts +11 -0
  153. package/dist/src/nodes/loops.js +60 -0
  154. package/dist/src/nodes/pradar/index.d.ts +7 -0
  155. package/dist/src/nodes/pradar/index.js +9 -0
  156. package/dist/src/nodes/pradar/logic.d.ts +189 -0
  157. package/dist/src/nodes/pradar/logic.js +370 -0
  158. package/dist/src/nodes/pradar/nodes.d.ts +42 -0
  159. package/dist/src/nodes/pradar/nodes.js +801 -0
  160. package/dist/src/nodes/requireAuth.d.ts +20 -0
  161. package/dist/src/nodes/requireAuth.js +48 -0
  162. package/dist/src/nodes/response.d.ts +8 -0
  163. package/dist/src/nodes/response.js +33 -0
  164. package/dist/src/nodes/weather.d.ts +33 -0
  165. package/dist/src/nodes/weather.js +260 -0
  166. package/package.json +92 -0
  167. package/server/agentRoute.test.ts +157 -0
  168. package/server/agents/__fixtures__/fake-claude-writer.mjs +23 -0
  169. package/server/agents/__fixtures__/fake-claude.mjs +55 -0
  170. package/server/agents/__fixtures__/fake-codex-writer.mjs +27 -0
  171. package/server/agents/__fixtures__/fake-codex.mjs +52 -0
  172. package/server/agents/__fixtures__/fake-version-empty.mjs +3 -0
  173. package/server/agents/__fixtures__/fake-version-fail.mjs +4 -0
  174. package/server/agents/__fixtures__/fake-version-garbage.mjs +4 -0
  175. package/server/agents/__fixtures__/fake-version-good.mjs +4 -0
  176. package/server/agents/__fixtures__/fake-version-hang.mjs +3 -0
  177. package/server/agents/claudeAdapter.test.ts +127 -0
  178. package/server/agents/claudeAdapter.ts +212 -0
  179. package/server/agents/claudeParse.ts +193 -0
  180. package/server/agents/codexAdapter.test.ts +125 -0
  181. package/server/agents/codexAdapter.ts +198 -0
  182. package/server/agents/codexParse.test.ts +58 -0
  183. package/server/agents/codexParse.ts +126 -0
  184. package/server/agents/detect.test.ts +65 -0
  185. package/server/agents/detect.ts +43 -0
  186. package/server/agents/gitScope.test.ts +129 -0
  187. package/server/agents/gitScope.ts +110 -0
  188. package/server/agents/modelRejectionHint.test.ts +30 -0
  189. package/server/agents/modelRejectionHint.ts +14 -0
  190. package/server/agents/prompt.test.ts +613 -0
  191. package/server/agents/prompt.ts +527 -0
  192. package/server/agents/runManager.test.ts +251 -0
  193. package/server/agents/runManager.ts +286 -0
  194. package/server/agents/types.ts +17 -0
  195. package/server/apiMount.test.ts +591 -0
  196. package/server/apiStore.test.ts +324 -0
  197. package/server/apiStore.ts +241 -0
  198. package/server/auth/enforce.test.ts +61 -0
  199. package/server/auth/enforce.ts +6 -0
  200. package/server/auth/types.ts +5 -0
  201. package/server/auth/verifiers.test.ts +37 -0
  202. package/server/auth/verifiers.ts +9 -0
  203. package/server/authAttach.test.ts +175 -0
  204. package/server/authAttach.ts +99 -0
  205. package/server/cli.ts +847 -0
  206. package/server/cliAuth.test.ts +229 -0
  207. package/server/cliCreate.test.ts +131 -0
  208. package/server/cliDoctor.test.ts +326 -0
  209. package/server/cliTest.test.ts +735 -0
  210. package/server/client.ts +314 -0
  211. package/server/demoProject.test.ts +29 -0
  212. package/server/diagnosticsRoute.test.ts +169 -0
  213. package/server/environments.test.ts +620 -0
  214. package/server/environments.ts +603 -0
  215. package/server/environmentsRoute.test.ts +385 -0
  216. package/server/errorWorkflow.test.ts +205 -0
  217. package/server/flowStore.test.ts +84 -0
  218. package/server/flowStore.ts +125 -0
  219. package/server/httpOperations.test.ts +377 -0
  220. package/server/httpOperations.ts +96 -0
  221. package/server/index.ts +1111 -0
  222. package/server/infrastructure.test.ts +154 -0
  223. package/server/infrastructure.ts +161 -0
  224. package/server/infrastructureRoute.test.ts +105 -0
  225. package/server/login.test.ts +153 -0
  226. package/server/login.ts +67 -0
  227. package/server/mcp.ts +278 -0
  228. package/server/migrateFlows.test.ts +55 -0
  229. package/server/migrateFlows.ts +23 -0
  230. package/server/mockHandler.test.ts +138 -0
  231. package/server/mockHandler.ts +52 -0
  232. package/server/mockRun.test.ts +367 -0
  233. package/server/mockServe.test.ts +467 -0
  234. package/server/nodesPayload.test.ts +29 -0
  235. package/server/nodesPayload.ts +26 -0
  236. package/server/normalizeFlow.test.ts +80 -0
  237. package/server/normalizeFlow.ts +59 -0
  238. package/server/openBrowser.test.ts +20 -0
  239. package/server/openBrowser.ts +22 -0
  240. package/server/operationResult.test.ts +67 -0
  241. package/server/operationResult.ts +27 -0
  242. package/server/pathGuard.test.ts +19 -0
  243. package/server/pathGuard.ts +12 -0
  244. package/server/pathSafety.test.ts +38 -0
  245. package/server/pathSafety.ts +33 -0
  246. package/server/projectConfig.test.ts +67 -0
  247. package/server/projectConfig.ts +101 -0
  248. package/server/projectMode.test.ts +106 -0
  249. package/server/projectMode.ts +59 -0
  250. package/server/redact.test.ts +88 -0
  251. package/server/redact.ts +35 -0
  252. package/server/redactEgress.test.ts +281 -0
  253. package/server/runRegistry.ts +270 -0
  254. package/server/runsAuth.test.ts +119 -0
  255. package/server/runtime/RuntimeAdapter.ts +24 -0
  256. package/server/runtime/expressAdapter.test.ts +38 -0
  257. package/server/runtime/expressAdapter.ts +70 -0
  258. package/server/scenarioTest.test.ts +148 -0
  259. package/server/scenarioTest.ts +88 -0
  260. package/server/setupStatus.test.ts +127 -0
  261. package/server/subflowRunner.ts +104 -0
  262. package/server/testRunner.ts +216 -0
  263. package/server/tsconfig.json +20 -0
  264. package/server/workflowTestRoute.test.ts +297 -0
  265. package/src/App.tsx +233 -0
  266. package/src/components/AgentConsole.tsx +461 -0
  267. package/src/components/BranchRulesEditor.tsx +156 -0
  268. package/src/components/CreateModal.tsx +275 -0
  269. package/src/components/Dock.tsx +487 -0
  270. package/src/components/EnvironmentDialog.tsx +569 -0
  271. package/src/components/EnvironmentPicker.tsx +357 -0
  272. package/src/components/EnvironmentsDialog.tsx +144 -0
  273. package/src/components/ExecutionPager.tsx +67 -0
  274. package/src/components/InfraPanel.test.tsx +103 -0
  275. package/src/components/InfraPanel.tsx +171 -0
  276. package/src/components/Inspector.tsx +1182 -0
  277. package/src/components/Json.tsx +50 -0
  278. package/src/components/JsonModal.tsx +52 -0
  279. package/src/components/LogMessage.tsx +61 -0
  280. package/src/components/NodeRunModal.tsx +213 -0
  281. package/src/components/RunLogPanel.tsx +397 -0
  282. package/src/components/RunbookView.tsx +1085 -0
  283. package/src/components/Scenarios.tsx +476 -0
  284. package/src/components/SettingsDialog.tsx +229 -0
  285. package/src/components/Sidebar.tsx +436 -0
  286. package/src/components/StatusBar.tsx +302 -0
  287. package/src/components/Toolbar.tsx +663 -0
  288. package/src/components/WelcomeDialog.test.tsx +107 -0
  289. package/src/components/WelcomeDialog.tsx +412 -0
  290. package/src/components/agentMarkdown.test.tsx +91 -0
  291. package/src/components/agentMarkdown.tsx +158 -0
  292. package/src/components/ui/badge.tsx +31 -0
  293. package/src/components/ui/button.tsx +46 -0
  294. package/src/components/ui/combobox.tsx +114 -0
  295. package/src/components/ui/command.tsx +82 -0
  296. package/src/components/ui/dialog.tsx +73 -0
  297. package/src/components/ui/input.tsx +20 -0
  298. package/src/components/ui/popover.tsx +32 -0
  299. package/src/components/ui/resizable.tsx +44 -0
  300. package/src/components/ui/tabs.tsx +36 -0
  301. package/src/config.ts +4 -0
  302. package/src/engine/authVerify.ts +81 -0
  303. package/src/engine/diagnostics.test.ts +437 -0
  304. package/src/engine/diagnostics.ts +211 -0
  305. package/src/engine/executor.test.ts +1339 -0
  306. package/src/engine/executor.ts +840 -0
  307. package/src/engine/httpError.test.ts +12 -0
  308. package/src/engine/httpError.ts +16 -0
  309. package/src/engine/index.ts +11 -0
  310. package/src/engine/output.ts +21 -0
  311. package/src/engine/publish.test.ts +176 -0
  312. package/src/engine/publish.ts +127 -0
  313. package/src/engine/registry.test.ts +64 -0
  314. package/src/engine/registry.ts +80 -0
  315. package/src/engine/scenarios.test.ts +55 -0
  316. package/src/engine/scenarios.ts +29 -0
  317. package/src/engine/schemaCheck.test.ts +21 -0
  318. package/src/engine/schemaCheck.ts +35 -0
  319. package/src/engine/trace.test.ts +19 -0
  320. package/src/engine/trace.ts +23 -0
  321. package/src/engine/types.test.ts +22 -0
  322. package/src/engine/types.ts +316 -0
  323. package/src/engine/validation.test.ts +314 -0
  324. package/src/engine/validation.ts +354 -0
  325. package/src/flows/anomaly-flows.test.ts +81 -0
  326. package/src/flows/anomaly-flows.ts +202 -0
  327. package/src/flows/city-sweep-flow.ts +131 -0
  328. package/src/flows/flows.test.ts +30 -0
  329. package/src/flows/login-flow.ts +150 -0
  330. package/src/flows/pradar-flows.test.ts +204 -0
  331. package/src/flows/pradar-flows.ts +419 -0
  332. package/src/flows/weather-flow.ts +154 -0
  333. package/src/globals.css +147 -0
  334. package/src/lib/pathParams.test.ts +24 -0
  335. package/src/lib/pathParams.ts +6 -0
  336. package/src/lib/registerLens.test.ts +79 -0
  337. package/src/lib/registerLens.ts +59 -0
  338. package/src/lib/runbookModel.test.ts +61 -0
  339. package/src/lib/runbookModel.ts +290 -0
  340. package/src/lib/runbookProjection.test.ts +417 -0
  341. package/src/lib/runbookProjection.ts +254 -0
  342. package/src/lib/useTailAnchor.ts +53 -0
  343. package/src/lib/utils.ts +7 -0
  344. package/src/main.tsx +13 -0
  345. package/src/nodes/anomaly.test.ts +98 -0
  346. package/src/nodes/anomaly.ts +637 -0
  347. package/src/nodes/effects-scan.test.ts +44 -0
  348. package/src/nodes/flow-control.test.ts +280 -0
  349. package/src/nodes/flow-control.ts +305 -0
  350. package/src/nodes/index.ts +22 -0
  351. package/src/nodes/login.test.ts +81 -0
  352. package/src/nodes/login.ts +186 -0
  353. package/src/nodes/loops.ts +69 -0
  354. package/src/nodes/pradar/index.ts +11 -0
  355. package/src/nodes/pradar/logic.test.ts +288 -0
  356. package/src/nodes/pradar/logic.ts +582 -0
  357. package/src/nodes/pradar/nodes.test.ts +146 -0
  358. package/src/nodes/pradar/nodes.ts +955 -0
  359. package/src/nodes/requireAuth.test.ts +75 -0
  360. package/src/nodes/requireAuth.ts +55 -0
  361. package/src/nodes/response.test.ts +33 -0
  362. package/src/nodes/response.ts +39 -0
  363. package/src/nodes/traceDetail.test.ts +39 -0
  364. package/src/nodes/weather.test.ts +65 -0
  365. package/src/nodes/weather.ts +306 -0
  366. package/src/store/agentClient.test.ts +103 -0
  367. package/src/store/agentClient.ts +131 -0
  368. package/src/store/apiTree.test.ts +17 -0
  369. package/src/store/apiTree.ts +73 -0
  370. package/src/store/builderStore.test.ts +1234 -0
  371. package/src/store/builderStore.ts +1879 -0
  372. package/src/store/infraClient.ts +63 -0
  373. package/src/store/nodeMeta.test.ts +24 -0
  374. package/src/store/nodeMeta.ts +21 -0
  375. package/src/store/persistence.test.ts +15 -0
  376. package/src/store/persistence.ts +54 -0
  377. package/src/store/serverRunner.ts +381 -0
  378. package/src/store/setupClient.ts +57 -0
  379. package/studio-dist/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  380. package/studio-dist/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  381. package/studio-dist/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  382. package/studio-dist/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  383. package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  384. package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  385. package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  386. package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  387. package/studio-dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  388. package/studio-dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  389. package/studio-dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  390. package/studio-dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  391. package/studio-dist/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  392. package/studio-dist/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  393. package/studio-dist/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  394. package/studio-dist/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  395. package/studio-dist/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  396. package/studio-dist/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  397. package/studio-dist/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  398. package/studio-dist/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  399. package/studio-dist/assets/index-DNJwW-hM.css +1 -0
  400. package/studio-dist/assets/index-O26dKRjW.js +65 -0
  401. package/studio-dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  402. package/studio-dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  403. package/studio-dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  404. package/studio-dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  405. package/studio-dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  406. package/studio-dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  407. package/studio-dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  408. package/studio-dist/favicon.svg +1 -0
  409. package/studio-dist/icons.svg +24 -0
  410. package/studio-dist/index.html +14 -0
  411. package/templates/skills/emberflow-basics/SKILL.md +316 -0
  412. package/templates/skills/emberflow-model-process/SKILL.md +209 -0
  413. package/templates/skills/emberflow-new-workflow/SKILL.md +211 -0
  414. package/templates/skills/emberflow-review-workflow/SKILL.md +148 -0
@@ -0,0 +1,375 @@
1
+ /**
2
+ * EV Charging Demo — three executable example flows for a solar/EV charge
3
+ * scheduler. Each flow drives the pure decision logic (src/nodes/pradar/logic.ts)
4
+ * as a graph; the vehicle / push-notification effect nodes are SIMULATED (dry-run
5
+ * by default). Every scenario pins `now` (UTC) so the sun-clock + time gates are
6
+ * reproducible.
7
+ *
8
+ * Wiring convention: a branch-gated node gets ONLY its branch edge (sourceHandle
9
+ * = the taken branch); its data is pulled via inputMap from ancestors through the
10
+ * branch chain. Non-gated backbone nodes use ordinary data/order edges.
11
+ *
12
+ * SNAPSHOT NOTE: a run reads an inverter status ({soc, ppv, loadPower,
13
+ * gridExport}) and a vehicle status (evStatus.batteryStatus / batteryPlugin /
14
+ * batteryCharge). The Input node is that combined snapshot, flattened for wiring
15
+ * — homeSoc = growatt.soc, pluggedIn = (batteryPlugin ?? 0) > 0, charging =
16
+ * batteryCharge === true, evBattery = batteryStatus.
17
+ */
18
+ const FOLDER = 'EV Charging Demo';
19
+ const CREATED = '2026-07-03T00:00:00Z';
20
+ // Demo location (Berlin). Instants below fall in solar / golden / night windows.
21
+ const DAY = '2026-07-02T13:00:00Z'; // solar hours, ~7h to sunset
22
+ const GOLDEN = '2026-07-02T19:06:00Z'; // ~1h to sunset (golden hour)
23
+ const AFTER_SUNSET = '2026-07-02T22:00:00Z'; // dark, hour 22 (not night window)
24
+ const NIGHT = '2026-07-02T23:30:00Z'; // hour 23, night window
25
+ const DAY_HOUR = '2026-07-02T14:00:00Z'; // hour 14, day
26
+ const from = (sourceNodeId, sourceField) => ({ sourceNodeId, sourceField });
27
+ function dataEdge(id, source, target, targetHandle) {
28
+ return { id, source, target, targetHandle };
29
+ }
30
+ function branchEdge(id, source, target, sourceHandle) {
31
+ return { id, source, target, sourceHandle };
32
+ }
33
+ function orderEdge(id, source, target) {
34
+ return { id, source, target };
35
+ }
36
+ function buildFlow(id, name, specs, edges, scenarios) {
37
+ const nodes = specs.map((s) => ({
38
+ id: s.id,
39
+ type: s.type,
40
+ label: s.label,
41
+ position: { x: s.x, y: s.y },
42
+ config: s.config ?? {},
43
+ ...(s.inputMap ? { inputMap: s.inputMap } : {}),
44
+ }));
45
+ return {
46
+ id,
47
+ name,
48
+ version: 1,
49
+ folder: FOLDER,
50
+ nodes,
51
+ edges: withMappingEdges(nodes, edges),
52
+ scenarios,
53
+ createdAt: CREATED,
54
+ updatedAt: CREATED,
55
+ };
56
+ }
57
+ /**
58
+ * Every input mapping gets a visible edge. The engine resolves inputMap with
59
+ * or without one, but an edgeless mapping renders as a floating node and —
60
+ * worse — the topological order can't see the data dependency. Edges make
61
+ * the canvas honest and the ordering correct.
62
+ */
63
+ function withMappingEdges(nodes, edges) {
64
+ const ids = new Set(nodes.map((n) => n.id));
65
+ const out = [...edges];
66
+ const covered = new Set(out.map((e) => `${e.source}→${e.target}::${e.targetHandle ?? ''}`));
67
+ const connected = new Set(out.flatMap((e) => [`${e.source}→${e.target}`]));
68
+ for (const node of nodes) {
69
+ for (const [field, mapping] of Object.entries(node.inputMap ?? {})) {
70
+ if (!ids.has(mapping.sourceNodeId))
71
+ continue;
72
+ const key = `${mapping.sourceNodeId}→${node.id}::${field}`;
73
+ // Skip when this exact field edge exists, or a branch/select edge
74
+ // already links the pair (gating edges double as the visual link).
75
+ if (covered.has(key) || connected.has(`${mapping.sourceNodeId}→${node.id}`))
76
+ continue;
77
+ covered.add(key);
78
+ out.push({ id: `m-${node.id}-${field}`, source: mapping.sourceNodeId, target: node.id, targetHandle: field });
79
+ }
80
+ }
81
+ return out;
82
+ }
83
+ // ============================================================================
84
+ // 1. EV · Evaluate Cycle — the full 5-min tick as a graph
85
+ // ============================================================================
86
+ export function createEvaluateCycleFlow() {
87
+ return buildFlow('ev-evaluate-cycle', 'EV · Evaluate Cycle', [
88
+ {
89
+ id: 'input',
90
+ type: 'Input',
91
+ label: 'Tick Snapshot',
92
+ x: -40,
93
+ y: 400,
94
+ config: {
95
+ fields: [
96
+ { name: 'ppv', type: 'number', required: true },
97
+ { name: 'loadPower', type: 'number', required: true },
98
+ { name: 'gridExport', type: 'number', required: true },
99
+ { name: 'homeSoc', type: 'number', required: true },
100
+ { name: 'evBattery', type: 'number' },
101
+ { name: 'pluggedIn', type: 'boolean', required: true },
102
+ { name: 'charging', type: 'boolean', required: true },
103
+ { name: 'forecast', type: 'object' },
104
+ { name: 'readings', type: 'array' },
105
+ { name: 'state', type: 'enum', enumValues: ['idle', 'waiting', 'charging'], required: true },
106
+ { name: 'now', type: 'datetime', required: true },
107
+ ],
108
+ defaults: {
109
+ ppv: 3000, loadPower: 500, gridExport: 2500, homeSoc: 80, evBattery: 60,
110
+ pluggedIn: true, charging: false, state: 'idle', readings: [], now: DAY,
111
+ forecast: { remainingKwh: 20, strongHoursLeft: 5, tomorrowKwh: 25 },
112
+ },
113
+ },
114
+ },
115
+ // Env-aware live telemetry: prod pulls real inverter + vehicle readings from
116
+ // the EV Demo service; every other env passes the scenario snapshot through. The
117
+ // downstream nodes read the LIVE tick fields (ppv/loadPower/gridExport/
118
+ // homeSoc/evBattery/pluggedIn/charging) from here; now/forecast/readings/
119
+ // state stay on 'input' (not exposed per-tick by the status endpoints).
120
+ {
121
+ id: 'load', type: 'EvLoadTickSnapshot', label: 'Load Tick', x: 200, y: 220, inputMap: {
122
+ ppv: from('input', 'ppv'), loadPower: from('input', 'loadPower'), gridExport: from('input', 'gridExport'),
123
+ homeSoc: from('input', 'homeSoc'), evBattery: from('input', 'evBattery'),
124
+ pluggedIn: from('input', 'pluggedIn'), charging: from('input', 'charging'),
125
+ forecast: from('input', 'forecast'), readings: from('input', 'readings'),
126
+ state: from('input', 'state'), now: from('input', 'now'),
127
+ },
128
+ },
129
+ { id: 'sun', type: 'EvSunClock', label: 'Sun Clock', x: 200, y: 400, inputMap: { now: from('input', 'now') } },
130
+ // ── top branch: solar hours vs off-hours ──
131
+ { id: 'condSolar', type: 'Conditional', label: 'Solar Hours?', x: 440, y: 400, config: { branches: [{ name: 'solar', op: 'truthy' }], fallback: 'off' }, inputMap: { value: from('sun', 'isSolarHours') } },
132
+ // off-hours sub-branch: night window vs stop-any-charge
133
+ { id: 'condNight', type: 'Conditional', label: 'Night Window?', x: 680, y: 700, config: { branches: [{ name: 'night', op: 'truthy' }], fallback: 'notNight' }, inputMap: { value: from('sun', 'isNightWindow') } },
134
+ // Night window → hand off to the standalone Night Charge flow as a subflow.
135
+ { id: 'subflowNight', type: 'Subflow', label: 'Night Charge', x: 920, y: 820, config: { workflowId: 'ev-night-charge' }, inputMap: { evBattery: from('load', 'evBattery'), pluggedIn: from('load', 'pluggedIn'), tomorrowKwh: from('input', 'forecast.tomorrowKwh'), now: from('input', 'now') } },
136
+ { id: 'resultNight', type: 'Result', label: 'Night Charge Result', x: 1160, y: 820, inputMap: { data: from('subflowNight', '$') } },
137
+ { id: 'condOffCharging', type: 'Conditional', label: 'Charging Off-Hours?', x: 920, y: 640, config: { branches: [{ name: 'stop', op: 'truthy' }], fallback: 'idle' }, inputMap: { value: from('load', 'charging') } },
138
+ { id: 'offStop', type: 'EvStopCharge', label: 'Stop Charge (sun set)', x: 1160, y: 580, config: { commit: false }, inputMap: {} },
139
+ { id: 'notifyOff', type: 'EvNotify', label: 'Notify (sun set)', x: 1400, y: 580, config: { commit: false }, inputMap: { title: from('offStop', 'reason'), message: from('offStop', 'command') } },
140
+ { id: 'resultOffStop', type: 'Result', label: 'Off-Hours Stop', x: 1640, y: 580, inputMap: { data: from('notifyOff', '$') } },
141
+ { id: 'resultOffIdle', type: 'Result', label: 'Off-Hours Idle', x: 1160, y: 720, inputMap: { data: from('sun', '$') } },
142
+ // ── solar backbone ──
143
+ { id: 'surplus', type: 'EvComputeSurplus', label: 'Compute Surplus', x: 680, y: 360, inputMap: { ppv: from('load', 'ppv'), loadPower: from('load', 'loadPower'), gridExport: from('load', 'gridExport') } },
144
+ { id: 'trend', type: 'EvTrendWindow', label: 'Trend Window', x: 920, y: 360, inputMap: { readings: from('input', 'readings') } },
145
+ {
146
+ id: 'thresholds', type: 'EvThresholds', label: 'Thresholds', x: 1160, y: 360, inputMap: {
147
+ homeSoc: from('load', 'homeSoc'), ppv: from('load', 'ppv'), sunHoursLeft: from('sun', 'hoursUntilSunset'),
148
+ evBattery: from('load', 'evBattery'), forecast: from('input', 'forecast'),
149
+ surplusTrend: from('trend', 'surplusTrend'), socTrend: from('trend', 'socTrend'),
150
+ },
151
+ },
152
+ { id: 'resultSkip', type: 'Result', label: 'Holding Off (skip)', x: 1400, y: 200, inputMap: { data: from('thresholds', '$') } },
153
+ {
154
+ id: 'target', type: 'EvTargetCheck', label: 'Target Check', x: 1400, y: 360, inputMap: {
155
+ pluggedIn: from('load', 'pluggedIn'), evBattery: from('load', 'evBattery'),
156
+ isSolarHours: from('sun', 'isSolarHours'), charging: from('load', 'charging'),
157
+ },
158
+ },
159
+ { id: 'resultNotPlugged', type: 'Result', label: 'Not Plugged In', x: 1640, y: 160, inputMap: { data: from('target', '$') } },
160
+ // atTarget → stop + notify
161
+ { id: 'stopAtTarget', type: 'EvStopCharge', label: 'Stop (at target)', x: 1640, y: 280, config: { commit: false }, inputMap: { reason: from('target', 'reason') } },
162
+ { id: 'notifyAtTarget', type: 'EvNotify', label: 'Notify (at target)', x: 1880, y: 280, config: { commit: false }, inputMap: { title: from('stopAtTarget', 'reason'), message: from('stopAtTarget', 'command') } },
163
+ { id: 'resultAtTarget', type: 'Result', label: 'EV At Target', x: 2120, y: 280, inputMap: { data: from('notifyAtTarget', '$') } },
164
+ // belowTarget → unscheduled guard
165
+ {
166
+ id: 'guard', type: 'EvUnscheduledGuard', label: 'Unscheduled Guard', x: 1640, y: 440, inputMap: {
167
+ charging: from('load', 'charging'), state: from('input', 'state'), surplus: from('surplus', 'surplus'),
168
+ startW: from('thresholds', 'startW'), skipReason: from('thresholds', 'skipReason'), homeSoc: from('load', 'homeSoc'),
169
+ },
170
+ },
171
+ // guard stop → stop + notify
172
+ { id: 'stopUnsched', type: 'EvStopCharge', label: 'Stop (unscheduled)', x: 1880, y: 560, config: { commit: false }, inputMap: { reason: from('guard', 'reason') } },
173
+ { id: 'notifyUnsched', type: 'EvNotify', label: 'Notify (unscheduled)', x: 2120, y: 560, config: { commit: false }, inputMap: { title: from('stopUnsched', 'reason'), message: from('stopUnsched', 'command') } },
174
+ { id: 'resultUnsched', type: 'Result', label: 'Unscheduled Stopped', x: 2360, y: 560, inputMap: { data: from('notifyUnsched', '$') } },
175
+ // guard continue → reconcile
176
+ { id: 'reconcile', type: 'EvReconcile', label: 'Reconcile', x: 1880, y: 440, inputMap: { charging: from('load', 'charging'), state: from('input', 'state') } },
177
+ { id: 'resultAdopt', type: 'Result', label: 'Adopted (charging continues)', x: 2120, y: 380, inputMap: { data: from('reconcile', '$') } },
178
+ // reconcile hold → charge decision
179
+ {
180
+ id: 'decision', type: 'EvChargeDecision', label: 'Charge Decision', x: 2120, y: 460, inputMap: {
181
+ state: from('input', 'state'), surplus: from('surplus', 'surplus'), startW: from('thresholds', 'startW'),
182
+ stopW: from('thresholds', 'stopW'), homeSoc: from('load', 'homeSoc'), skipReason: from('thresholds', 'skipReason'),
183
+ },
184
+ },
185
+ // decision start → start + notify
186
+ { id: 'startCharge', type: 'EvStartCharge', label: 'Start Charge', x: 2360, y: 300, config: { commit: false }, inputMap: { reason: from('decision', 'reason') } },
187
+ { id: 'notifyStart', type: 'EvNotify', label: 'Notify (start)', x: 2600, y: 300, config: { commit: false }, inputMap: { title: from('startCharge', 'reason'), message: from('startCharge', 'command') } },
188
+ { id: 'resultStart', type: 'Result', label: 'Charge Started', x: 2840, y: 300, inputMap: { data: from('notifyStart', '$') } },
189
+ // decision stop → stop + notify
190
+ { id: 'stopCharge', type: 'EvStopCharge', label: 'Stop Charge', x: 2360, y: 440, config: { commit: false }, inputMap: { reason: from('decision', 'reason') } },
191
+ { id: 'notifyStop', type: 'EvNotify', label: 'Notify (stop)', x: 2600, y: 440, config: { commit: false }, inputMap: { title: from('stopCharge', 'reason'), message: from('stopCharge', 'command') } },
192
+ { id: 'resultStop', type: 'Result', label: 'Charge Stopped', x: 2840, y: 440, inputMap: { data: from('notifyStop', '$') } },
193
+ // decision holds
194
+ { id: 'resultHoldWaiting', type: 'Result', label: 'Hold (waiting)', x: 2360, y: 560, inputMap: { data: from('decision', '$') } },
195
+ { id: 'resultHoldCharging', type: 'Result', label: 'Hold (charging)', x: 2360, y: 660, inputMap: { data: from('decision', '$') } },
196
+ ], [
197
+ orderEdge('eLoad', 'input', 'load'),
198
+ dataEdge('e0', 'input', 'sun', 'now'),
199
+ dataEdge('e1', 'sun', 'condSolar', 'value'),
200
+ // off-hours
201
+ branchEdge('e2', 'condSolar', 'condNight', 'off'),
202
+ dataEdge('e3', 'sun', 'condNight', 'value'),
203
+ branchEdge('e4', 'condNight', 'subflowNight', 'night'),
204
+ dataEdge('e4b', 'subflowNight', 'resultNight', 'data'),
205
+ branchEdge('e5', 'condNight', 'condOffCharging', 'notNight'),
206
+ dataEdge('e6', 'load', 'condOffCharging', 'value'),
207
+ branchEdge('e7', 'condOffCharging', 'offStop', 'stop'),
208
+ dataEdge('e8', 'offStop', 'notifyOff', 'title'),
209
+ dataEdge('e9', 'notifyOff', 'resultOffStop', 'data'),
210
+ branchEdge('e10', 'condOffCharging', 'resultOffIdle', 'idle'),
211
+ // solar backbone
212
+ branchEdge('e11', 'condSolar', 'surplus', 'solar'),
213
+ dataEdge('e11b', 'load', 'surplus', 'ppv'),
214
+ orderEdge('e12', 'surplus', 'trend'),
215
+ orderEdge('e13', 'trend', 'thresholds'),
216
+ // thresholds skip/ok
217
+ branchEdge('e14', 'thresholds', 'resultSkip', 'skip'),
218
+ branchEdge('e15', 'thresholds', 'target', 'ok'),
219
+ // target branches
220
+ branchEdge('e16', 'target', 'resultNotPlugged', 'notPlugged'),
221
+ branchEdge('e17', 'target', 'stopAtTarget', 'atTarget'),
222
+ dataEdge('e18', 'stopAtTarget', 'notifyAtTarget', 'title'),
223
+ dataEdge('e19', 'notifyAtTarget', 'resultAtTarget', 'data'),
224
+ branchEdge('e20', 'target', 'guard', 'belowTarget'),
225
+ // guard branches
226
+ branchEdge('e21', 'guard', 'stopUnsched', 'stop'),
227
+ dataEdge('e22', 'stopUnsched', 'notifyUnsched', 'title'),
228
+ dataEdge('e23', 'notifyUnsched', 'resultUnsched', 'data'),
229
+ branchEdge('e24', 'guard', 'reconcile', 'continue'),
230
+ // reconcile branches
231
+ branchEdge('e25', 'reconcile', 'resultAdopt', 'adopt'),
232
+ branchEdge('e26', 'reconcile', 'decision', 'hold'),
233
+ // decision branches
234
+ branchEdge('e27', 'decision', 'startCharge', 'start'),
235
+ dataEdge('e28', 'startCharge', 'notifyStart', 'title'),
236
+ dataEdge('e29', 'notifyStart', 'resultStart', 'data'),
237
+ branchEdge('e30', 'decision', 'stopCharge', 'stop'),
238
+ dataEdge('e31', 'stopCharge', 'notifyStop', 'title'),
239
+ dataEdge('e32', 'notifyStop', 'resultStop', 'data'),
240
+ branchEdge('e33', 'decision', 'resultHoldWaiting', 'hold_waiting'),
241
+ branchEdge('e34', 'decision', 'resultHoldCharging', 'hold_charging'),
242
+ ], [
243
+ { id: 'scn-sunny-start', name: 'sunny-start', description: 'Strong export (2500W), home 80%, EV 60% → start charge.', input: { now: DAY, ppv: 3000, loadPower: 500, gridExport: 2500, homeSoc: 80, evBattery: 60, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 20, strongHoursLeft: 5, tomorrowKwh: 25 } } },
244
+ { id: 'scn-cloudy-hold', name: 'cloudy-hold', description: 'Flat 900W surplus below the 1200W buffer start → hold waiting.', input: { now: DAY, ppv: 1400, loadPower: 500, gridExport: 0, homeSoc: 50, evBattery: 60, pluggedIn: true, charging: false, state: 'waiting', readings: [], forecast: { remainingKwh: 8, strongHoursLeft: 2, tomorrowKwh: 15 } } },
245
+ { id: 'scn-golden-hour-start', name: 'golden-hour-start', description: '~1h to sunset pulls start to 800W; 900W surplus → start.', input: { now: GOLDEN, ppv: 1000, loadPower: 100, gridExport: 0, homeSoc: 50, evBattery: 60, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 2, strongHoursLeft: 1, tomorrowKwh: 15 } } },
246
+ { id: 'scn-predictive-export', name: 'predictive-export', description: 'Home 95% + ppv 3000W → predictive 500W start; 600W surplus → start.', input: { now: DAY, ppv: 3000, loadPower: 200, gridExport: 600, homeSoc: 95, evBattery: 60, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 20, strongHoursLeft: 5, tomorrowKwh: 25 } } },
247
+ { id: 'scn-urgent-ev', name: 'urgent-ev', description: 'EV 40% (<50) → urgent 1200W start; 1300W surplus → start.', input: { now: DAY, ppv: 1800, loadPower: 500, gridExport: 0, homeSoc: 50, evBattery: 40, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 15, strongHoursLeft: 4, tomorrowKwh: 20 } } },
248
+ { id: 'scn-flat-home-blocked', name: 'flat-home-blocked', description: 'Flat home 10% keeps 2000W start; 1500W surplus → hold waiting.', input: { now: DAY, ppv: 2000, loadPower: 500, gridExport: 0, homeSoc: 10, evBattery: 60, pluggedIn: true, charging: false, state: 'waiting', readings: [], forecast: { remainingKwh: 15, strongHoursLeft: 4, tomorrowKwh: 20 } } },
249
+ { id: 'scn-not-worth-it', name: 'not-worth-it', description: 'EV 70% with only ~0.8kWh solar left → worth-it skip.', input: { now: DAY, ppv: 800, loadPower: 300, gridExport: 0, homeSoc: 50, evBattery: 70, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 0.8, strongHoursLeft: 0, tomorrowKwh: 20 } } },
250
+ { id: 'scn-charging-continue', name: 'charging-continue', description: 'Already charging, 900W above the 400W stop → hold charging.', input: { now: DAY, ppv: 1400, loadPower: 500, gridExport: 0, homeSoc: 50, evBattery: 60, pluggedIn: true, charging: true, state: 'charging', readings: [], forecast: { remainingKwh: 8, strongHoursLeft: 2, tomorrowKwh: 15 } } },
251
+ { id: 'scn-charging-stop', name: 'charging-stop', description: 'Charging but surplus fell to 300W (<400 stop) → stop charge.', input: { now: DAY, ppv: 800, loadPower: 500, gridExport: 0, homeSoc: 50, evBattery: 60, pluggedIn: true, charging: true, state: 'charging', readings: [], forecast: { remainingKwh: 6, strongHoursLeft: 1, tomorrowKwh: 15 } } },
252
+ { id: 'scn-unscheduled-stop', name: 'unscheduled-stop', description: 'Car charging but state idle and 700W < 1200W start → unscheduled stop.', input: { now: DAY, ppv: 1200, loadPower: 500, gridExport: 0, homeSoc: 80, evBattery: 60, pluggedIn: true, charging: true, state: 'idle', readings: [], forecast: { remainingKwh: 10, strongHoursLeft: 3, tomorrowKwh: 15 } } },
253
+ { id: 'scn-reconcile-adopt', name: 'reconcile-adopt', description: 'Car charging, state waiting, 2500W clears start → adopt the session.', input: { now: DAY, ppv: 3000, loadPower: 500, gridExport: 2500, homeSoc: 80, evBattery: 60, pluggedIn: true, charging: true, state: 'waiting', readings: [], forecast: { remainingKwh: 20, strongHoursLeft: 5, tomorrowKwh: 25 } } },
254
+ { id: 'scn-ev-at-target', name: 'ev-at-target', description: 'EV 91% ≥ 90% solar target → at-target stop.', input: { now: DAY, ppv: 2000, loadPower: 500, gridExport: 0, homeSoc: 80, evBattery: 91, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: null } },
255
+ { id: 'scn-unplugged', name: 'unplugged', description: 'EV not plugged in → notPlugged.', input: { now: DAY, ppv: 2000, loadPower: 500, gridExport: 0, homeSoc: 80, evBattery: 60, pluggedIn: false, charging: false, state: 'idle', readings: [], forecast: null } },
256
+ { id: 'scn-sunset-stop', name: 'sunset-stop', description: 'now 22:00 (sun set), charging → off-hours stop.', input: { now: AFTER_SUNSET, ppv: 0, loadPower: 400, gridExport: 0, homeSoc: 50, evBattery: 60, pluggedIn: true, charging: true, state: 'charging', readings: [], forecast: null } },
257
+ { id: 'scn-trend-rising', name: 'trend-rising', description: 'Readings ramp +300W/cycle → trend override lowers start to 1000W; 1100W surplus → start.', input: { now: DAY, ppv: 1600, loadPower: 500, gridExport: 0, homeSoc: 10, evBattery: 60, pluggedIn: true, charging: false, state: 'idle', readings: [{ surplus: 200, homeSoc: 10, ppv: 800 }, { surplus: 500, homeSoc: 10, ppv: 1100 }, { surplus: 800, homeSoc: 10, ppv: 1400 }, { surplus: 1100, homeSoc: 10, ppv: 1600 }], forecast: { remainingKwh: 15, strongHoursLeft: 4, tomorrowKwh: 20 } } },
258
+ { id: 'scn-night-charge', name: 'night-charge', description: 'now 23:30 (night window), EV 30% (<35) → Night Charge subflow charges.', input: { now: NIGHT, ppv: 0, loadPower: 400, gridExport: 0, homeSoc: 50, evBattery: 30, pluggedIn: true, charging: false, state: 'idle', readings: [], forecast: { remainingKwh: 0, strongHoursLeft: 0, tomorrowKwh: 24 } } },
259
+ ]);
260
+ }
261
+ // ============================================================================
262
+ // 2. EV · Threshold Intelligence — the intelligence layers, isolated
263
+ // ============================================================================
264
+ export function createThresholdIntelligenceFlow() {
265
+ return buildFlow('ev-threshold-intelligence', 'EV · Threshold Intelligence', [
266
+ {
267
+ id: 'input',
268
+ type: 'Input',
269
+ label: 'Intelligence Inputs',
270
+ x: -40,
271
+ y: 240,
272
+ config: {
273
+ fields: [
274
+ { name: 'homeSoc', type: 'number', required: true },
275
+ { name: 'ppv', type: 'number', required: true },
276
+ { name: 'sunHoursLeft', type: 'number', required: true },
277
+ { name: 'evBattery', type: 'number' },
278
+ { name: 'forecast', type: 'object' },
279
+ { name: 'surplusTrend', type: 'number' },
280
+ { name: 'socTrend', type: 'number' },
281
+ { name: 'target', type: 'number' },
282
+ ],
283
+ // sunHoursLeft is supplied directly (no sun clock) so this focused flow
284
+ // stays deterministic without pinning a `now`.
285
+ defaults: { homeSoc: 50, ppv: 1500, sunHoursLeft: 4, evBattery: 60, surplusTrend: 0, socTrend: 0, target: 80, forecast: { remainingKwh: 15, strongHoursLeft: 4 } },
286
+ },
287
+ },
288
+ {
289
+ id: 'thresholds', type: 'EvThresholds', label: 'Thresholds', x: 220, y: 160, inputMap: {
290
+ homeSoc: from('input', 'homeSoc'), ppv: from('input', 'ppv'), sunHoursLeft: from('input', 'sunHoursLeft'),
291
+ evBattery: from('input', 'evBattery'), forecast: from('input', 'forecast'),
292
+ surplusTrend: from('input', 'surplusTrend'), socTrend: from('input', 'socTrend'),
293
+ },
294
+ },
295
+ { id: 'resultOk', type: 'Result', label: 'Thresholds (ok)', x: 460, y: 60, inputMap: { data: from('thresholds', '$') } },
296
+ { id: 'resultSkip', type: 'Result', label: 'Thresholds (skip)', x: 460, y: 200, inputMap: { data: from('thresholds', '$') } },
297
+ {
298
+ id: 'estimate', type: 'EvSessionEstimate', label: 'Session Estimate', x: 220, y: 360, inputMap: {
299
+ evBattery: from('input', 'evBattery'), target: from('input', 'target'), ppv: from('input', 'ppv'),
300
+ sunHoursLeft: from('input', 'sunHoursLeft'), forecast: from('input', 'forecast'),
301
+ },
302
+ },
303
+ { id: 'resultEstimate', type: 'Result', label: 'Worth-It Estimate', x: 460, y: 360, inputMap: { data: from('estimate', '$') } },
304
+ ], [
305
+ dataEdge('e0', 'input', 'thresholds', 'homeSoc'),
306
+ branchEdge('e1', 'thresholds', 'resultOk', 'ok'),
307
+ branchEdge('e2', 'thresholds', 'resultSkip', 'skip'),
308
+ dataEdge('e3', 'input', 'estimate', 'evBattery'),
309
+ dataEdge('e4', 'estimate', 'resultEstimate', 'data'),
310
+ ], [
311
+ { id: 'scn-urgent', name: 'urgent (EV <50%)', description: 'EV 40% → urgent band 1200/400.', input: { homeSoc: 20, ppv: 1500, sunHoursLeft: 4, evBattery: 40, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 0, socTrend: 0, target: 80 } },
312
+ { id: 'scn-buffer', name: 'home buffer', description: 'Home 60% (≥30) → buffer band 1200/400.', input: { homeSoc: 60, ppv: 300, sunHoursLeft: 4, evBattery: 60, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 0, socTrend: 0, target: 80 } },
313
+ { id: 'scn-flat', name: 'flat home', description: 'Home 10% flat, EV not urgent → default 2000/800.', input: { homeSoc: 10, ppv: 1500, sunHoursLeft: 4, evBattery: 70, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 0, socTrend: 0, target: 80 } },
314
+ { id: 'scn-predictive', name: 'predictive export', description: 'Home 95% + ppv 2200W → predictive 500/200.', input: { homeSoc: 95, ppv: 2200, sunHoursLeft: 4, evBattery: 60, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 0, socTrend: 0, target: 80 } },
315
+ { id: 'scn-golden', name: 'golden hour', description: '1.5h to sunset → golden hour ≤800/200.', input: { homeSoc: 10, ppv: 900, sunHoursLeft: 1.5, evBattery: 60, forecast: { remainingKwh: 3, strongHoursLeft: 1 }, surplusTrend: 0, socTrend: 0, target: 80 } },
316
+ { id: 'scn-worth-it-skip', name: 'worth-it skip', description: 'EV 70% with 0.8kWh remaining → skip branch.', input: { homeSoc: 50, ppv: 300, sunHoursLeft: 1, evBattery: 70, forecast: { remainingKwh: 0.8, strongHoursLeft: 0 }, surplusTrend: 0, socTrend: 0, target: 90 } },
317
+ { id: 'scn-trend-surplus', name: 'trend: surplus rising', description: 'surplusTrend 300 → start ≤1000.', input: { homeSoc: 10, ppv: 1500, sunHoursLeft: 4, evBattery: 60, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 300, socTrend: 0, target: 80 } },
318
+ { id: 'scn-trend-soc', name: 'trend: SOC rising', description: 'socTrend 3 with home 80% → start ≤600.', input: { homeSoc: 80, ppv: 1500, sunHoursLeft: 4, evBattery: 60, forecast: { remainingKwh: 15, strongHoursLeft: 4 }, surplusTrend: 0, socTrend: 3, target: 80 } },
319
+ ]);
320
+ }
321
+ // ============================================================================
322
+ // 3. EV · Night Charge — the overnight grid-charge decision
323
+ // ============================================================================
324
+ export function createNightChargeFlow() {
325
+ return buildFlow('ev-night-charge', 'EV · Night Charge', [
326
+ {
327
+ id: 'input',
328
+ type: 'Input',
329
+ label: 'Night Snapshot',
330
+ x: -40,
331
+ y: 240,
332
+ config: {
333
+ fields: [
334
+ { name: 'evBattery', type: 'number', required: true },
335
+ { name: 'pluggedIn', type: 'boolean', required: true },
336
+ { name: 'tomorrowKwh', type: 'number' },
337
+ { name: 'alreadyTriggeredToday', type: 'boolean' },
338
+ { name: 'now', type: 'datetime', required: true },
339
+ ],
340
+ defaults: { evBattery: 30, pluggedIn: true, tomorrowKwh: 24, alreadyTriggeredToday: false, now: NIGHT },
341
+ },
342
+ },
343
+ { id: 'sun', type: 'EvSunClock', label: 'Sun Clock', x: 220, y: 240, inputMap: { now: from('input', 'now') } },
344
+ {
345
+ id: 'night', type: 'EvNightChargeDecision', label: 'Night Charge Decision', x: 460, y: 240, inputMap: {
346
+ evBattery: from('input', 'evBattery'), pluggedIn: from('input', 'pluggedIn'),
347
+ tomorrowKwh: from('input', 'tomorrowKwh'), hour: from('sun', 'hour'),
348
+ alreadyTriggeredToday: from('input', 'alreadyTriggeredToday'),
349
+ },
350
+ },
351
+ { id: 'resultSkip', type: 'Result', label: 'Skip Night Charge', x: 700, y: 380, inputMap: { data: from('night', '$') } },
352
+ // charge branch: start → notify
353
+ { id: 'startCharge', type: 'EvStartCharge', label: 'Start Charge (grid)', x: 700, y: 160, config: { commit: false }, inputMap: {} },
354
+ { id: 'notify', type: 'EvNotify', label: 'Notify (night charge)', x: 940, y: 160, config: { commit: false }, inputMap: { title: from('startCharge', 'reason'), message: from('startCharge', 'command') } },
355
+ { id: 'result', type: 'Result', label: 'Night Charge Started', x: 1180, y: 160, inputMap: { data: from('notify', '$') } },
356
+ ], [
357
+ dataEdge('e0', 'input', 'sun', 'now'),
358
+ orderEdge('e1', 'sun', 'night'),
359
+ dataEdge('e2', 'sun', 'night', 'hour'),
360
+ branchEdge('e3', 'night', 'startCharge', 'charge'),
361
+ dataEdge('e4', 'startCharge', 'notify', 'title'),
362
+ dataEdge('e5', 'notify', 'result', 'data'),
363
+ branchEdge('e6', 'night', 'resultSkip', 'skip'),
364
+ ], [
365
+ { id: 'scn-critical-35', name: 'critical-35', description: 'EV 30% (<35) at 23:30 → charge regardless of forecast.', input: { evBattery: 30, pluggedIn: true, tomorrowKwh: 24, alreadyTriggeredToday: false, now: NIGHT } },
366
+ { id: 'scn-moderate-poor-forecast', name: 'moderate-poor-forecast', description: 'EV 55% with poor tomorrow (6kWh) at night → charge.', input: { evBattery: 55, pluggedIn: true, tomorrowKwh: 6, alreadyTriggeredToday: false, now: NIGHT } },
367
+ { id: 'scn-moderate-good-forecast', name: 'moderate-good-forecast', description: 'EV 55% with good tomorrow (20kWh) → skip.', input: { evBattery: 55, pluggedIn: true, tomorrowKwh: 20, alreadyTriggeredToday: false, now: NIGHT } },
368
+ { id: 'scn-wrong-hour', name: 'wrong-hour', description: 'EV 30% but 14:00 (outside 23–05) → skip.', input: { evBattery: 30, pluggedIn: true, tomorrowKwh: 6, alreadyTriggeredToday: false, now: DAY_HOUR } },
369
+ { id: 'scn-already-triggered', name: 'already-triggered', description: 'EV 30% at night but already triggered today → skip.', input: { evBattery: 30, pluggedIn: true, tomorrowKwh: 6, alreadyTriggeredToday: true, now: NIGHT } },
370
+ { id: 'scn-unplugged-night', name: 'unplugged-night', description: 'EV 30% at night but not plugged in → skip.', input: { evBattery: 30, pluggedIn: false, tomorrowKwh: 6, alreadyTriggeredToday: false, now: NIGHT } },
371
+ ]);
372
+ }
373
+ export function createPradarFlows() {
374
+ return [createEvaluateCycleFlow(), createThresholdIntelligenceFlow(), createNightChargeFlow()];
375
+ }
@@ -0,0 +1,12 @@
1
+ import type { WorkflowDefinition } from '../engine/index.js';
2
+ /**
3
+ * Branching weather advisory:
4
+ * geocode → forecast → summarize → classify → route(severity?)
5
+ * ├─ severe → composeAlert → alertResult
6
+ * └─ mild → calmResult
7
+ *
8
+ * Two live Open-Meteo HTTP calls feed a summary, then ClassifyWeather grades
9
+ * the conditions and Route sends severe weather down an alert branch while
10
+ * mild weather just surfaces the plain summary.
11
+ */
12
+ export declare function createWeatherFlow(): WorkflowDefinition;
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Branching weather advisory:
3
+ * geocode → forecast → summarize → classify → route(severity?)
4
+ * ├─ severe → composeAlert → alertResult
5
+ * └─ mild → calmResult
6
+ *
7
+ * Two live Open-Meteo HTTP calls feed a summary, then ClassifyWeather grades
8
+ * the conditions and Route sends severe weather down an alert branch while
9
+ * mild weather just surfaces the plain summary.
10
+ */
11
+ export function createWeatherFlow() {
12
+ const nodes = [
13
+ {
14
+ id: 'input',
15
+ type: 'Input',
16
+ label: 'Advisory Request',
17
+ position: { x: -180, y: 240 },
18
+ config: {
19
+ fields: [{ name: 'city', type: 'string', required: true }],
20
+ defaults: { city: 'Belfast' },
21
+ },
22
+ },
23
+ {
24
+ id: 'geocode',
25
+ type: 'GeocodeCity',
26
+ label: 'Geocode City',
27
+ position: { x: 60, y: 240 },
28
+ config: { city: 'Belfast' },
29
+ inputMap: {
30
+ city: { sourceNodeId: 'input', sourceField: 'city' },
31
+ },
32
+ },
33
+ {
34
+ id: 'forecast',
35
+ type: 'FetchForecast',
36
+ label: 'Fetch Forecast',
37
+ position: { x: 300, y: 240 },
38
+ config: {},
39
+ inputMap: {
40
+ latitude: { sourceNodeId: 'geocode', sourceField: 'latitude' },
41
+ longitude: { sourceNodeId: 'geocode', sourceField: 'longitude' },
42
+ },
43
+ },
44
+ {
45
+ id: 'summarize',
46
+ type: 'SummarizeConditions',
47
+ label: 'Summarize Conditions',
48
+ position: { x: 540, y: 240 },
49
+ config: {},
50
+ inputMap: {
51
+ place: { sourceNodeId: 'geocode', sourceField: 'place' },
52
+ temperatureC: { sourceNodeId: 'forecast', sourceField: 'temperatureC' },
53
+ windKmh: { sourceNodeId: 'forecast', sourceField: 'windKmh' },
54
+ weatherCode: { sourceNodeId: 'forecast', sourceField: 'weatherCode' },
55
+ maxC: { sourceNodeId: 'forecast', sourceField: 'maxC' },
56
+ minC: { sourceNodeId: 'forecast', sourceField: 'minC' },
57
+ rainChancePct: { sourceNodeId: 'forecast', sourceField: 'rainChancePct' },
58
+ },
59
+ },
60
+ {
61
+ id: 'classify',
62
+ type: 'ClassifyWeather',
63
+ label: 'Classify Weather',
64
+ position: { x: 780, y: 240 },
65
+ config: {},
66
+ inputMap: {
67
+ windKmh: { sourceNodeId: 'forecast', sourceField: 'windKmh' },
68
+ rainChancePct: { sourceNodeId: 'forecast', sourceField: 'rainChancePct' },
69
+ },
70
+ },
71
+ {
72
+ id: 'route',
73
+ type: 'Route',
74
+ label: 'Severity?',
75
+ position: { x: 1020, y: 240 },
76
+ config: { field: 'severity', branches: ['severe'], fallback: 'mild' },
77
+ inputMap: {
78
+ value: { sourceNodeId: 'classify', sourceField: '$' },
79
+ },
80
+ },
81
+ {
82
+ id: 'composeAlert',
83
+ type: 'ComposeAlert',
84
+ label: 'Compose Alert',
85
+ position: { x: 1260, y: 120 },
86
+ config: {},
87
+ inputMap: {
88
+ place: { sourceNodeId: 'geocode', sourceField: 'place' },
89
+ reason: { sourceNodeId: 'classify', sourceField: 'reason' },
90
+ },
91
+ },
92
+ {
93
+ id: 'alertResult',
94
+ type: 'Result',
95
+ label: 'Alert',
96
+ position: { x: 1500, y: 120 },
97
+ config: {},
98
+ inputMap: {
99
+ data: { sourceNodeId: 'composeAlert', sourceField: '$' },
100
+ },
101
+ },
102
+ {
103
+ id: 'calmResult',
104
+ type: 'Result',
105
+ label: 'Advisory',
106
+ position: { x: 1260, y: 360 },
107
+ config: {},
108
+ inputMap: {
109
+ data: { sourceNodeId: 'summarize', sourceField: '$' },
110
+ },
111
+ },
112
+ ];
113
+ const edges = [
114
+ { id: 'e0', source: 'input', target: 'geocode', targetHandle: 'city' },
115
+ { id: 'e1', source: 'geocode', target: 'forecast', targetHandle: 'latitude' },
116
+ { id: 'e2', source: 'geocode', target: 'forecast', targetHandle: 'longitude' },
117
+ { id: 'e3', source: 'geocode', target: 'summarize', targetHandle: 'place' },
118
+ { id: 'e4', source: 'forecast', target: 'summarize', targetHandle: 'temperatureC' },
119
+ { id: 'e5', source: 'summarize', target: 'classify' },
120
+ { id: 'e6', source: 'classify', target: 'route', targetHandle: 'value' },
121
+ { id: 'e7', source: 'route', target: 'composeAlert', sourceHandle: 'severe' },
122
+ { id: 'e8', source: 'route', target: 'calmResult', sourceHandle: 'mild' },
123
+ { id: 'e9', source: 'composeAlert', target: 'alertResult', targetHandle: 'data' },
124
+ ];
125
+ return {
126
+ id: 'weather-advisory',
127
+ name: 'Weather Advisory',
128
+ version: 1,
129
+ nodes,
130
+ edges,
131
+ // Live-weather flow: which branch fires depends on real conditions, so the
132
+ // scenarios pick cities that usually sit on opposite sides of the classifier.
133
+ scenarios: [
134
+ {
135
+ id: 'scn-stormy',
136
+ name: 'stormy city',
137
+ description: 'Reykjavik — wind/rain usually trips the severe branch',
138
+ input: { city: 'Reykjavik' },
139
+ },
140
+ {
141
+ id: 'scn-calm',
142
+ name: 'calm city',
143
+ description: 'Valencia — mild branch, plain advisory',
144
+ input: { city: 'Valencia' },
145
+ },
146
+ ],
147
+ createdAt: '2026-07-02T00:00:00Z',
148
+ updatedAt: '2026-07-02T00:00:00Z',
149
+ };
150
+ }
@@ -0,0 +1,3 @@
1
+ /** Extract `:name` path-param segments from an HTTP path, in order, e.g.
2
+ * `/api/channels/:id/approvals/:approvalId` → `['id', 'approvalId']`. */
3
+ export declare function parsePathParams(path: string): string[];
@@ -0,0 +1,6 @@
1
+ /** Extract `:name` path-param segments from an HTTP path, in order, e.g.
2
+ * `/api/channels/:id/approvals/:approvalId` → `['id', 'approvalId']`. */
3
+ export function parsePathParams(path) {
4
+ const matches = path.match(/:([A-Za-z0-9_]+)/g) ?? [];
5
+ return matches.map((m) => m.slice(1));
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { NodeRegistry } from '../engine/index.js';
2
+ export declare function registerAnomalyNodes(registry: NodeRegistry): void;