@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,419 @@
1
+ import type { FieldMapping, WorkflowDefinition, WorkflowEdge, WorkflowNode } from '../engine';
2
+
3
+ /**
4
+ * EV Charging Demo — three executable example flows for a solar/EV charge
5
+ * scheduler. Each flow drives the pure decision logic (src/nodes/pradar/logic.ts)
6
+ * as a graph; the vehicle / push-notification effect nodes are SIMULATED (dry-run
7
+ * by default). Every scenario pins `now` (UTC) so the sun-clock + time gates are
8
+ * reproducible.
9
+ *
10
+ * Wiring convention: a branch-gated node gets ONLY its branch edge (sourceHandle
11
+ * = the taken branch); its data is pulled via inputMap from ancestors through the
12
+ * branch chain. Non-gated backbone nodes use ordinary data/order edges.
13
+ *
14
+ * SNAPSHOT NOTE: a run reads an inverter status ({soc, ppv, loadPower,
15
+ * gridExport}) and a vehicle status (evStatus.batteryStatus / batteryPlugin /
16
+ * batteryCharge). The Input node is that combined snapshot, flattened for wiring
17
+ * — homeSoc = growatt.soc, pluggedIn = (batteryPlugin ?? 0) > 0, charging =
18
+ * batteryCharge === true, evBattery = batteryStatus.
19
+ */
20
+
21
+ const FOLDER = 'EV Charging Demo';
22
+ const CREATED = '2026-07-03T00:00:00Z';
23
+
24
+ // Demo location (Berlin). Instants below fall in solar / golden / night windows.
25
+ const DAY = '2026-07-02T13:00:00Z'; // solar hours, ~7h to sunset
26
+ const GOLDEN = '2026-07-02T19:06:00Z'; // ~1h to sunset (golden hour)
27
+ const AFTER_SUNSET = '2026-07-02T22:00:00Z'; // dark, hour 22 (not night window)
28
+ const NIGHT = '2026-07-02T23:30:00Z'; // hour 23, night window
29
+ const DAY_HOUR = '2026-07-02T14:00:00Z'; // hour 14, day
30
+
31
+ const from = (sourceNodeId: string, sourceField: string): FieldMapping => ({ sourceNodeId, sourceField });
32
+
33
+ interface NodeSpec {
34
+ id: string;
35
+ type: string;
36
+ label: string;
37
+ x: number;
38
+ y: number;
39
+ config?: Record<string, unknown>;
40
+ inputMap?: Record<string, FieldMapping>;
41
+ }
42
+
43
+ function dataEdge(id: string, source: string, target: string, targetHandle: string): WorkflowEdge {
44
+ return { id, source, target, targetHandle };
45
+ }
46
+ function branchEdge(id: string, source: string, target: string, sourceHandle: string): WorkflowEdge {
47
+ return { id, source, target, sourceHandle };
48
+ }
49
+ function orderEdge(id: string, source: string, target: string): WorkflowEdge {
50
+ return { id, source, target };
51
+ }
52
+
53
+ function buildFlow(
54
+ id: string,
55
+ name: string,
56
+ specs: NodeSpec[],
57
+ edges: WorkflowEdge[],
58
+ scenarios: WorkflowDefinition['scenarios'],
59
+ ): WorkflowDefinition {
60
+ const nodes: WorkflowNode[] = specs.map((s) => ({
61
+ id: s.id,
62
+ type: s.type,
63
+ label: s.label,
64
+ position: { x: s.x, y: s.y },
65
+ config: s.config ?? {},
66
+ ...(s.inputMap ? { inputMap: s.inputMap } : {}),
67
+ }));
68
+ return {
69
+ id,
70
+ name,
71
+ version: 1,
72
+ folder: FOLDER,
73
+ nodes,
74
+ edges: withMappingEdges(nodes, edges),
75
+ scenarios,
76
+ createdAt: CREATED,
77
+ updatedAt: CREATED,
78
+ };
79
+ }
80
+
81
+ /**
82
+ * Every input mapping gets a visible edge. The engine resolves inputMap with
83
+ * or without one, but an edgeless mapping renders as a floating node and —
84
+ * worse — the topological order can't see the data dependency. Edges make
85
+ * the canvas honest and the ordering correct.
86
+ */
87
+ function withMappingEdges(nodes: WorkflowNode[], edges: WorkflowEdge[]): WorkflowEdge[] {
88
+ const ids = new Set(nodes.map((n) => n.id));
89
+ const out = [...edges];
90
+ const covered = new Set(out.map((e) => `${e.source}→${e.target}::${e.targetHandle ?? ''}`));
91
+ const connected = new Set(out.flatMap((e) => [`${e.source}→${e.target}`]));
92
+ for (const node of nodes) {
93
+ for (const [field, mapping] of Object.entries(node.inputMap ?? {})) {
94
+ if (!ids.has(mapping.sourceNodeId)) continue;
95
+ const key = `${mapping.sourceNodeId}→${node.id}::${field}`;
96
+ // Skip when this exact field edge exists, or a branch/select edge
97
+ // already links the pair (gating edges double as the visual link).
98
+ if (covered.has(key) || connected.has(`${mapping.sourceNodeId}→${node.id}`)) continue;
99
+ covered.add(key);
100
+ out.push({ id: `m-${node.id}-${field}`, source: mapping.sourceNodeId, target: node.id, targetHandle: field });
101
+ }
102
+ }
103
+ return out;
104
+ }
105
+
106
+ // ============================================================================
107
+ // 1. EV · Evaluate Cycle — the full 5-min tick as a graph
108
+ // ============================================================================
109
+ export function createEvaluateCycleFlow(): WorkflowDefinition {
110
+ return buildFlow(
111
+ 'ev-evaluate-cycle',
112
+ 'EV · Evaluate Cycle',
113
+ [
114
+ {
115
+ id: 'input',
116
+ type: 'Input',
117
+ label: 'Tick Snapshot',
118
+ x: -40,
119
+ y: 400,
120
+ config: {
121
+ fields: [
122
+ { name: 'ppv', type: 'number', required: true },
123
+ { name: 'loadPower', type: 'number', required: true },
124
+ { name: 'gridExport', type: 'number', required: true },
125
+ { name: 'homeSoc', type: 'number', required: true },
126
+ { name: 'evBattery', type: 'number' },
127
+ { name: 'pluggedIn', type: 'boolean', required: true },
128
+ { name: 'charging', type: 'boolean', required: true },
129
+ { name: 'forecast', type: 'object' },
130
+ { name: 'readings', type: 'array' },
131
+ { name: 'state', type: 'enum', enumValues: ['idle', 'waiting', 'charging'], required: true },
132
+ { name: 'now', type: 'datetime', required: true },
133
+ ],
134
+ defaults: {
135
+ ppv: 3000, loadPower: 500, gridExport: 2500, homeSoc: 80, evBattery: 60,
136
+ pluggedIn: true, charging: false, state: 'idle', readings: [], now: DAY,
137
+ forecast: { remainingKwh: 20, strongHoursLeft: 5, tomorrowKwh: 25 },
138
+ },
139
+ },
140
+ },
141
+ // Env-aware live telemetry: prod pulls real inverter + vehicle readings from
142
+ // the EV Demo service; every other env passes the scenario snapshot through. The
143
+ // downstream nodes read the LIVE tick fields (ppv/loadPower/gridExport/
144
+ // homeSoc/evBattery/pluggedIn/charging) from here; now/forecast/readings/
145
+ // state stay on 'input' (not exposed per-tick by the status endpoints).
146
+ {
147
+ id: 'load', type: 'EvLoadTickSnapshot', label: 'Load Tick', x: 200, y: 220, inputMap: {
148
+ ppv: from('input', 'ppv'), loadPower: from('input', 'loadPower'), gridExport: from('input', 'gridExport'),
149
+ homeSoc: from('input', 'homeSoc'), evBattery: from('input', 'evBattery'),
150
+ pluggedIn: from('input', 'pluggedIn'), charging: from('input', 'charging'),
151
+ forecast: from('input', 'forecast'), readings: from('input', 'readings'),
152
+ state: from('input', 'state'), now: from('input', 'now'),
153
+ },
154
+ },
155
+ { id: 'sun', type: 'EvSunClock', label: 'Sun Clock', x: 200, y: 400, inputMap: { now: from('input', 'now') } },
156
+ // ── top branch: solar hours vs off-hours ──
157
+ { id: 'condSolar', type: 'Conditional', label: 'Solar Hours?', x: 440, y: 400, config: { branches: [{ name: 'solar', op: 'truthy' }], fallback: 'off' }, inputMap: { value: from('sun', 'isSolarHours') } },
158
+ // off-hours sub-branch: night window vs stop-any-charge
159
+ { id: 'condNight', type: 'Conditional', label: 'Night Window?', x: 680, y: 700, config: { branches: [{ name: 'night', op: 'truthy' }], fallback: 'notNight' }, inputMap: { value: from('sun', 'isNightWindow') } },
160
+ // Night window → hand off to the standalone Night Charge flow as a subflow.
161
+ { 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') } },
162
+ { id: 'resultNight', type: 'Result', label: 'Night Charge Result', x: 1160, y: 820, inputMap: { data: from('subflowNight', '$') } },
163
+ { 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') } },
164
+ { id: 'offStop', type: 'EvStopCharge', label: 'Stop Charge (sun set)', x: 1160, y: 580, config: { commit: false }, inputMap: {} },
165
+ { id: 'notifyOff', type: 'EvNotify', label: 'Notify (sun set)', x: 1400, y: 580, config: { commit: false }, inputMap: { title: from('offStop', 'reason'), message: from('offStop', 'command') } },
166
+ { id: 'resultOffStop', type: 'Result', label: 'Off-Hours Stop', x: 1640, y: 580, inputMap: { data: from('notifyOff', '$') } },
167
+ { id: 'resultOffIdle', type: 'Result', label: 'Off-Hours Idle', x: 1160, y: 720, inputMap: { data: from('sun', '$') } },
168
+ // ── solar backbone ──
169
+ { id: 'surplus', type: 'EvComputeSurplus', label: 'Compute Surplus', x: 680, y: 360, inputMap: { ppv: from('load', 'ppv'), loadPower: from('load', 'loadPower'), gridExport: from('load', 'gridExport') } },
170
+ { id: 'trend', type: 'EvTrendWindow', label: 'Trend Window', x: 920, y: 360, inputMap: { readings: from('input', 'readings') } },
171
+ {
172
+ id: 'thresholds', type: 'EvThresholds', label: 'Thresholds', x: 1160, y: 360, inputMap: {
173
+ homeSoc: from('load', 'homeSoc'), ppv: from('load', 'ppv'), sunHoursLeft: from('sun', 'hoursUntilSunset'),
174
+ evBattery: from('load', 'evBattery'), forecast: from('input', 'forecast'),
175
+ surplusTrend: from('trend', 'surplusTrend'), socTrend: from('trend', 'socTrend'),
176
+ },
177
+ },
178
+ { id: 'resultSkip', type: 'Result', label: 'Holding Off (skip)', x: 1400, y: 200, inputMap: { data: from('thresholds', '$') } },
179
+ {
180
+ id: 'target', type: 'EvTargetCheck', label: 'Target Check', x: 1400, y: 360, inputMap: {
181
+ pluggedIn: from('load', 'pluggedIn'), evBattery: from('load', 'evBattery'),
182
+ isSolarHours: from('sun', 'isSolarHours'), charging: from('load', 'charging'),
183
+ },
184
+ },
185
+ { id: 'resultNotPlugged', type: 'Result', label: 'Not Plugged In', x: 1640, y: 160, inputMap: { data: from('target', '$') } },
186
+ // atTarget → stop + notify
187
+ { id: 'stopAtTarget', type: 'EvStopCharge', label: 'Stop (at target)', x: 1640, y: 280, config: { commit: false }, inputMap: { reason: from('target', 'reason') } },
188
+ { id: 'notifyAtTarget', type: 'EvNotify', label: 'Notify (at target)', x: 1880, y: 280, config: { commit: false }, inputMap: { title: from('stopAtTarget', 'reason'), message: from('stopAtTarget', 'command') } },
189
+ { id: 'resultAtTarget', type: 'Result', label: 'EV At Target', x: 2120, y: 280, inputMap: { data: from('notifyAtTarget', '$') } },
190
+ // belowTarget → unscheduled guard
191
+ {
192
+ id: 'guard', type: 'EvUnscheduledGuard', label: 'Unscheduled Guard', x: 1640, y: 440, inputMap: {
193
+ charging: from('load', 'charging'), state: from('input', 'state'), surplus: from('surplus', 'surplus'),
194
+ startW: from('thresholds', 'startW'), skipReason: from('thresholds', 'skipReason'), homeSoc: from('load', 'homeSoc'),
195
+ },
196
+ },
197
+ // guard stop → stop + notify
198
+ { id: 'stopUnsched', type: 'EvStopCharge', label: 'Stop (unscheduled)', x: 1880, y: 560, config: { commit: false }, inputMap: { reason: from('guard', 'reason') } },
199
+ { id: 'notifyUnsched', type: 'EvNotify', label: 'Notify (unscheduled)', x: 2120, y: 560, config: { commit: false }, inputMap: { title: from('stopUnsched', 'reason'), message: from('stopUnsched', 'command') } },
200
+ { id: 'resultUnsched', type: 'Result', label: 'Unscheduled Stopped', x: 2360, y: 560, inputMap: { data: from('notifyUnsched', '$') } },
201
+ // guard continue → reconcile
202
+ { id: 'reconcile', type: 'EvReconcile', label: 'Reconcile', x: 1880, y: 440, inputMap: { charging: from('load', 'charging'), state: from('input', 'state') } },
203
+ { id: 'resultAdopt', type: 'Result', label: 'Adopted (charging continues)', x: 2120, y: 380, inputMap: { data: from('reconcile', '$') } },
204
+ // reconcile hold → charge decision
205
+ {
206
+ id: 'decision', type: 'EvChargeDecision', label: 'Charge Decision', x: 2120, y: 460, inputMap: {
207
+ state: from('input', 'state'), surplus: from('surplus', 'surplus'), startW: from('thresholds', 'startW'),
208
+ stopW: from('thresholds', 'stopW'), homeSoc: from('load', 'homeSoc'), skipReason: from('thresholds', 'skipReason'),
209
+ },
210
+ },
211
+ // decision start → start + notify
212
+ { id: 'startCharge', type: 'EvStartCharge', label: 'Start Charge', x: 2360, y: 300, config: { commit: false }, inputMap: { reason: from('decision', 'reason') } },
213
+ { id: 'notifyStart', type: 'EvNotify', label: 'Notify (start)', x: 2600, y: 300, config: { commit: false }, inputMap: { title: from('startCharge', 'reason'), message: from('startCharge', 'command') } },
214
+ { id: 'resultStart', type: 'Result', label: 'Charge Started', x: 2840, y: 300, inputMap: { data: from('notifyStart', '$') } },
215
+ // decision stop → stop + notify
216
+ { id: 'stopCharge', type: 'EvStopCharge', label: 'Stop Charge', x: 2360, y: 440, config: { commit: false }, inputMap: { reason: from('decision', 'reason') } },
217
+ { id: 'notifyStop', type: 'EvNotify', label: 'Notify (stop)', x: 2600, y: 440, config: { commit: false }, inputMap: { title: from('stopCharge', 'reason'), message: from('stopCharge', 'command') } },
218
+ { id: 'resultStop', type: 'Result', label: 'Charge Stopped', x: 2840, y: 440, inputMap: { data: from('notifyStop', '$') } },
219
+ // decision holds
220
+ { id: 'resultHoldWaiting', type: 'Result', label: 'Hold (waiting)', x: 2360, y: 560, inputMap: { data: from('decision', '$') } },
221
+ { id: 'resultHoldCharging', type: 'Result', label: 'Hold (charging)', x: 2360, y: 660, inputMap: { data: from('decision', '$') } },
222
+ ],
223
+ [
224
+ orderEdge('eLoad', 'input', 'load'),
225
+ dataEdge('e0', 'input', 'sun', 'now'),
226
+ dataEdge('e1', 'sun', 'condSolar', 'value'),
227
+ // off-hours
228
+ branchEdge('e2', 'condSolar', 'condNight', 'off'),
229
+ dataEdge('e3', 'sun', 'condNight', 'value'),
230
+ branchEdge('e4', 'condNight', 'subflowNight', 'night'),
231
+ dataEdge('e4b', 'subflowNight', 'resultNight', 'data'),
232
+ branchEdge('e5', 'condNight', 'condOffCharging', 'notNight'),
233
+ dataEdge('e6', 'load', 'condOffCharging', 'value'),
234
+ branchEdge('e7', 'condOffCharging', 'offStop', 'stop'),
235
+ dataEdge('e8', 'offStop', 'notifyOff', 'title'),
236
+ dataEdge('e9', 'notifyOff', 'resultOffStop', 'data'),
237
+ branchEdge('e10', 'condOffCharging', 'resultOffIdle', 'idle'),
238
+ // solar backbone
239
+ branchEdge('e11', 'condSolar', 'surplus', 'solar'),
240
+ dataEdge('e11b', 'load', 'surplus', 'ppv'),
241
+ orderEdge('e12', 'surplus', 'trend'),
242
+ orderEdge('e13', 'trend', 'thresholds'),
243
+ // thresholds skip/ok
244
+ branchEdge('e14', 'thresholds', 'resultSkip', 'skip'),
245
+ branchEdge('e15', 'thresholds', 'target', 'ok'),
246
+ // target branches
247
+ branchEdge('e16', 'target', 'resultNotPlugged', 'notPlugged'),
248
+ branchEdge('e17', 'target', 'stopAtTarget', 'atTarget'),
249
+ dataEdge('e18', 'stopAtTarget', 'notifyAtTarget', 'title'),
250
+ dataEdge('e19', 'notifyAtTarget', 'resultAtTarget', 'data'),
251
+ branchEdge('e20', 'target', 'guard', 'belowTarget'),
252
+ // guard branches
253
+ branchEdge('e21', 'guard', 'stopUnsched', 'stop'),
254
+ dataEdge('e22', 'stopUnsched', 'notifyUnsched', 'title'),
255
+ dataEdge('e23', 'notifyUnsched', 'resultUnsched', 'data'),
256
+ branchEdge('e24', 'guard', 'reconcile', 'continue'),
257
+ // reconcile branches
258
+ branchEdge('e25', 'reconcile', 'resultAdopt', 'adopt'),
259
+ branchEdge('e26', 'reconcile', 'decision', 'hold'),
260
+ // decision branches
261
+ branchEdge('e27', 'decision', 'startCharge', 'start'),
262
+ dataEdge('e28', 'startCharge', 'notifyStart', 'title'),
263
+ dataEdge('e29', 'notifyStart', 'resultStart', 'data'),
264
+ branchEdge('e30', 'decision', 'stopCharge', 'stop'),
265
+ dataEdge('e31', 'stopCharge', 'notifyStop', 'title'),
266
+ dataEdge('e32', 'notifyStop', 'resultStop', 'data'),
267
+ branchEdge('e33', 'decision', 'resultHoldWaiting', 'hold_waiting'),
268
+ branchEdge('e34', 'decision', 'resultHoldCharging', 'hold_charging'),
269
+ ],
270
+ [
271
+ { 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 } } },
272
+ { 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 } } },
273
+ { 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 } } },
274
+ { 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 } } },
275
+ { 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 } } },
276
+ { 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 } } },
277
+ { 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 } } },
278
+ { 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 } } },
279
+ { 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 } } },
280
+ { 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 } } },
281
+ { 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 } } },
282
+ { 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 } },
283
+ { 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 } },
284
+ { 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 } },
285
+ { 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 } } },
286
+ { 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 } } },
287
+ ],
288
+ );
289
+ }
290
+
291
+ // ============================================================================
292
+ // 2. EV · Threshold Intelligence — the intelligence layers, isolated
293
+ // ============================================================================
294
+ export function createThresholdIntelligenceFlow(): WorkflowDefinition {
295
+ return buildFlow(
296
+ 'ev-threshold-intelligence',
297
+ 'EV · Threshold Intelligence',
298
+ [
299
+ {
300
+ id: 'input',
301
+ type: 'Input',
302
+ label: 'Intelligence Inputs',
303
+ x: -40,
304
+ y: 240,
305
+ config: {
306
+ fields: [
307
+ { name: 'homeSoc', type: 'number', required: true },
308
+ { name: 'ppv', type: 'number', required: true },
309
+ { name: 'sunHoursLeft', type: 'number', required: true },
310
+ { name: 'evBattery', type: 'number' },
311
+ { name: 'forecast', type: 'object' },
312
+ { name: 'surplusTrend', type: 'number' },
313
+ { name: 'socTrend', type: 'number' },
314
+ { name: 'target', type: 'number' },
315
+ ],
316
+ // sunHoursLeft is supplied directly (no sun clock) so this focused flow
317
+ // stays deterministic without pinning a `now`.
318
+ defaults: { homeSoc: 50, ppv: 1500, sunHoursLeft: 4, evBattery: 60, surplusTrend: 0, socTrend: 0, target: 80, forecast: { remainingKwh: 15, strongHoursLeft: 4 } },
319
+ },
320
+ },
321
+ {
322
+ id: 'thresholds', type: 'EvThresholds', label: 'Thresholds', x: 220, y: 160, inputMap: {
323
+ homeSoc: from('input', 'homeSoc'), ppv: from('input', 'ppv'), sunHoursLeft: from('input', 'sunHoursLeft'),
324
+ evBattery: from('input', 'evBattery'), forecast: from('input', 'forecast'),
325
+ surplusTrend: from('input', 'surplusTrend'), socTrend: from('input', 'socTrend'),
326
+ },
327
+ },
328
+ { id: 'resultOk', type: 'Result', label: 'Thresholds (ok)', x: 460, y: 60, inputMap: { data: from('thresholds', '$') } },
329
+ { id: 'resultSkip', type: 'Result', label: 'Thresholds (skip)', x: 460, y: 200, inputMap: { data: from('thresholds', '$') } },
330
+ {
331
+ id: 'estimate', type: 'EvSessionEstimate', label: 'Session Estimate', x: 220, y: 360, inputMap: {
332
+ evBattery: from('input', 'evBattery'), target: from('input', 'target'), ppv: from('input', 'ppv'),
333
+ sunHoursLeft: from('input', 'sunHoursLeft'), forecast: from('input', 'forecast'),
334
+ },
335
+ },
336
+ { id: 'resultEstimate', type: 'Result', label: 'Worth-It Estimate', x: 460, y: 360, inputMap: { data: from('estimate', '$') } },
337
+ ],
338
+ [
339
+ dataEdge('e0', 'input', 'thresholds', 'homeSoc'),
340
+ branchEdge('e1', 'thresholds', 'resultOk', 'ok'),
341
+ branchEdge('e2', 'thresholds', 'resultSkip', 'skip'),
342
+ dataEdge('e3', 'input', 'estimate', 'evBattery'),
343
+ dataEdge('e4', 'estimate', 'resultEstimate', 'data'),
344
+ ],
345
+ [
346
+ { 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 } },
347
+ { 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 } },
348
+ { 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 } },
349
+ { 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 } },
350
+ { 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 } },
351
+ { 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 } },
352
+ { 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 } },
353
+ { 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 } },
354
+ ],
355
+ );
356
+ }
357
+
358
+ // ============================================================================
359
+ // 3. EV · Night Charge — the overnight grid-charge decision
360
+ // ============================================================================
361
+ export function createNightChargeFlow(): WorkflowDefinition {
362
+ return buildFlow(
363
+ 'ev-night-charge',
364
+ 'EV · Night Charge',
365
+ [
366
+ {
367
+ id: 'input',
368
+ type: 'Input',
369
+ label: 'Night Snapshot',
370
+ x: -40,
371
+ y: 240,
372
+ config: {
373
+ fields: [
374
+ { name: 'evBattery', type: 'number', required: true },
375
+ { name: 'pluggedIn', type: 'boolean', required: true },
376
+ { name: 'tomorrowKwh', type: 'number' },
377
+ { name: 'alreadyTriggeredToday', type: 'boolean' },
378
+ { name: 'now', type: 'datetime', required: true },
379
+ ],
380
+ defaults: { evBattery: 30, pluggedIn: true, tomorrowKwh: 24, alreadyTriggeredToday: false, now: NIGHT },
381
+ },
382
+ },
383
+ { id: 'sun', type: 'EvSunClock', label: 'Sun Clock', x: 220, y: 240, inputMap: { now: from('input', 'now') } },
384
+ {
385
+ id: 'night', type: 'EvNightChargeDecision', label: 'Night Charge Decision', x: 460, y: 240, inputMap: {
386
+ evBattery: from('input', 'evBattery'), pluggedIn: from('input', 'pluggedIn'),
387
+ tomorrowKwh: from('input', 'tomorrowKwh'), hour: from('sun', 'hour'),
388
+ alreadyTriggeredToday: from('input', 'alreadyTriggeredToday'),
389
+ },
390
+ },
391
+ { id: 'resultSkip', type: 'Result', label: 'Skip Night Charge', x: 700, y: 380, inputMap: { data: from('night', '$') } },
392
+ // charge branch: start → notify
393
+ { id: 'startCharge', type: 'EvStartCharge', label: 'Start Charge (grid)', x: 700, y: 160, config: { commit: false }, inputMap: {} },
394
+ { id: 'notify', type: 'EvNotify', label: 'Notify (night charge)', x: 940, y: 160, config: { commit: false }, inputMap: { title: from('startCharge', 'reason'), message: from('startCharge', 'command') } },
395
+ { id: 'result', type: 'Result', label: 'Night Charge Started', x: 1180, y: 160, inputMap: { data: from('notify', '$') } },
396
+ ],
397
+ [
398
+ dataEdge('e0', 'input', 'sun', 'now'),
399
+ orderEdge('e1', 'sun', 'night'),
400
+ dataEdge('e2', 'sun', 'night', 'hour'),
401
+ branchEdge('e3', 'night', 'startCharge', 'charge'),
402
+ dataEdge('e4', 'startCharge', 'notify', 'title'),
403
+ dataEdge('e5', 'notify', 'result', 'data'),
404
+ branchEdge('e6', 'night', 'resultSkip', 'skip'),
405
+ ],
406
+ [
407
+ { 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 } },
408
+ { 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 } },
409
+ { 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 } },
410
+ { 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 } },
411
+ { 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 } },
412
+ { 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 } },
413
+ ],
414
+ );
415
+ }
416
+
417
+ export function createPradarFlows(): WorkflowDefinition[] {
418
+ return [createEvaluateCycleFlow(), createThresholdIntelligenceFlow(), createNightChargeFlow()];
419
+ }
@@ -0,0 +1,154 @@
1
+ import type { WorkflowDefinition, WorkflowEdge, WorkflowNode } from '../engine';
2
+
3
+ /**
4
+ * Branching weather advisory:
5
+ * geocode → forecast → summarize → classify → route(severity?)
6
+ * ├─ severe → composeAlert → alertResult
7
+ * └─ mild → calmResult
8
+ *
9
+ * Two live Open-Meteo HTTP calls feed a summary, then ClassifyWeather grades
10
+ * the conditions and Route sends severe weather down an alert branch while
11
+ * mild weather just surfaces the plain summary.
12
+ */
13
+ export function createWeatherFlow(): WorkflowDefinition {
14
+ const nodes: WorkflowNode[] = [
15
+ {
16
+ id: 'input',
17
+ type: 'Input',
18
+ label: 'Advisory Request',
19
+ position: { x: -180, y: 240 },
20
+ config: {
21
+ fields: [{ name: 'city', type: 'string', required: true }],
22
+ defaults: { city: 'Belfast' },
23
+ },
24
+ },
25
+ {
26
+ id: 'geocode',
27
+ type: 'GeocodeCity',
28
+ label: 'Geocode City',
29
+ position: { x: 60, y: 240 },
30
+ config: { city: 'Belfast' },
31
+ inputMap: {
32
+ city: { sourceNodeId: 'input', sourceField: 'city' },
33
+ },
34
+ },
35
+ {
36
+ id: 'forecast',
37
+ type: 'FetchForecast',
38
+ label: 'Fetch Forecast',
39
+ position: { x: 300, y: 240 },
40
+ config: {},
41
+ inputMap: {
42
+ latitude: { sourceNodeId: 'geocode', sourceField: 'latitude' },
43
+ longitude: { sourceNodeId: 'geocode', sourceField: 'longitude' },
44
+ },
45
+ },
46
+ {
47
+ id: 'summarize',
48
+ type: 'SummarizeConditions',
49
+ label: 'Summarize Conditions',
50
+ position: { x: 540, y: 240 },
51
+ config: {},
52
+ inputMap: {
53
+ place: { sourceNodeId: 'geocode', sourceField: 'place' },
54
+ temperatureC: { sourceNodeId: 'forecast', sourceField: 'temperatureC' },
55
+ windKmh: { sourceNodeId: 'forecast', sourceField: 'windKmh' },
56
+ weatherCode: { sourceNodeId: 'forecast', sourceField: 'weatherCode' },
57
+ maxC: { sourceNodeId: 'forecast', sourceField: 'maxC' },
58
+ minC: { sourceNodeId: 'forecast', sourceField: 'minC' },
59
+ rainChancePct: { sourceNodeId: 'forecast', sourceField: 'rainChancePct' },
60
+ },
61
+ },
62
+ {
63
+ id: 'classify',
64
+ type: 'ClassifyWeather',
65
+ label: 'Classify Weather',
66
+ position: { x: 780, y: 240 },
67
+ config: {},
68
+ inputMap: {
69
+ windKmh: { sourceNodeId: 'forecast', sourceField: 'windKmh' },
70
+ rainChancePct: { sourceNodeId: 'forecast', sourceField: 'rainChancePct' },
71
+ },
72
+ },
73
+ {
74
+ id: 'route',
75
+ type: 'Route',
76
+ label: 'Severity?',
77
+ position: { x: 1020, y: 240 },
78
+ config: { field: 'severity', branches: ['severe'], fallback: 'mild' },
79
+ inputMap: {
80
+ value: { sourceNodeId: 'classify', sourceField: '$' },
81
+ },
82
+ },
83
+ {
84
+ id: 'composeAlert',
85
+ type: 'ComposeAlert',
86
+ label: 'Compose Alert',
87
+ position: { x: 1260, y: 120 },
88
+ config: {},
89
+ inputMap: {
90
+ place: { sourceNodeId: 'geocode', sourceField: 'place' },
91
+ reason: { sourceNodeId: 'classify', sourceField: 'reason' },
92
+ },
93
+ },
94
+ {
95
+ id: 'alertResult',
96
+ type: 'Result',
97
+ label: 'Alert',
98
+ position: { x: 1500, y: 120 },
99
+ config: {},
100
+ inputMap: {
101
+ data: { sourceNodeId: 'composeAlert', sourceField: '$' },
102
+ },
103
+ },
104
+ {
105
+ id: 'calmResult',
106
+ type: 'Result',
107
+ label: 'Advisory',
108
+ position: { x: 1260, y: 360 },
109
+ config: {},
110
+ inputMap: {
111
+ data: { sourceNodeId: 'summarize', sourceField: '$' },
112
+ },
113
+ },
114
+ ];
115
+
116
+ const edges: WorkflowEdge[] = [
117
+ { id: 'e0', source: 'input', target: 'geocode', targetHandle: 'city' },
118
+ { id: 'e1', source: 'geocode', target: 'forecast', targetHandle: 'latitude' },
119
+ { id: 'e2', source: 'geocode', target: 'forecast', targetHandle: 'longitude' },
120
+ { id: 'e3', source: 'geocode', target: 'summarize', targetHandle: 'place' },
121
+ { id: 'e4', source: 'forecast', target: 'summarize', targetHandle: 'temperatureC' },
122
+ { id: 'e5', source: 'summarize', target: 'classify' },
123
+ { id: 'e6', source: 'classify', target: 'route', targetHandle: 'value' },
124
+ { id: 'e7', source: 'route', target: 'composeAlert', sourceHandle: 'severe' },
125
+ { id: 'e8', source: 'route', target: 'calmResult', sourceHandle: 'mild' },
126
+ { id: 'e9', source: 'composeAlert', target: 'alertResult', targetHandle: 'data' },
127
+ ];
128
+
129
+ return {
130
+ id: 'weather-advisory',
131
+ name: 'Weather Advisory',
132
+ version: 1,
133
+ nodes,
134
+ edges,
135
+ // Live-weather flow: which branch fires depends on real conditions, so the
136
+ // scenarios pick cities that usually sit on opposite sides of the classifier.
137
+ scenarios: [
138
+ {
139
+ id: 'scn-stormy',
140
+ name: 'stormy city',
141
+ description: 'Reykjavik — wind/rain usually trips the severe branch',
142
+ input: { city: 'Reykjavik' },
143
+ },
144
+ {
145
+ id: 'scn-calm',
146
+ name: 'calm city',
147
+ description: 'Valencia — mild branch, plain advisory',
148
+ input: { city: 'Valencia' },
149
+ },
150
+ ],
151
+ createdAt: '2026-07-02T00:00:00Z',
152
+ updatedAt: '2026-07-02T00:00:00Z',
153
+ };
154
+ }