yaml-flow 5.4.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/board-live-cards-cli.js +2 -2
  2. package/board-livecards-server-runtime.js +488 -551
  3. package/browser/asset-integrity.json +10 -0
  4. package/browser/board-livecards-runtime-client.js +0 -6
  5. package/browser/board-livegraph-engine.js +2 -1676
  6. package/browser/board-livegraph-engine.js.map +1 -1
  7. package/browser/live-cards.js +347 -26
  8. package/browser/live-cards.schema.json +418 -132
  9. package/card-store.js +37 -0
  10. package/dist/batch/index.cjs +1 -108
  11. package/dist/batch/index.cjs.map +1 -1
  12. package/dist/batch/index.js +1 -106
  13. package/dist/batch/index.js.map +1 -1
  14. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  15. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  16. package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
  17. package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
  18. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  19. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  20. package/dist/board-livegraph-runtime/index.d.cts +1 -2
  21. package/dist/board-livegraph-runtime/index.d.ts +1 -2
  22. package/dist/board-livegraph-runtime/index.js +2 -1662
  23. package/dist/board-livegraph-runtime/index.js.map +1 -1
  24. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
  25. package/dist/card-compute/index.cjs +9 -7159
  26. package/dist/card-compute/index.cjs.map +1 -1
  27. package/dist/card-compute/index.d.cts +22 -0
  28. package/dist/card-compute/index.d.ts +22 -0
  29. package/dist/card-compute/index.js +9 -7145
  30. package/dist/card-compute/index.js.map +1 -1
  31. package/dist/card-compute/jsonata-sync.cjs +7587 -0
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
  36. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
  37. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  38. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  39. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  40. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  41. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  42. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  43. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  44. package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
  45. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  46. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  47. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  48. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  49. package/dist/cli/node/artifacts-store-cli.js +11 -0
  50. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  51. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  52. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  53. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  54. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  55. package/dist/cli/node/board-live-cards-cli.js +15 -0
  56. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  57. package/dist/cli/node/card-store-cli.cjs +8 -0
  58. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  59. package/dist/cli/node/card-store-cli.d.cts +15 -0
  60. package/dist/cli/node/card-store-cli.d.ts +15 -0
  61. package/dist/cli/node/card-store-cli.js +8 -0
  62. package/dist/cli/node/card-store-cli.js.map +1 -0
  63. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  64. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  65. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  66. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  67. package/dist/cli/node/fs-board-adapter.js +14 -0
  68. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  69. package/dist/cli/node/jsonata-sync.cjs +7587 -0
  70. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  71. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  72. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  73. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  74. package/dist/cli/node/source-cli-task-executor.js +11 -0
  75. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  76. package/dist/config/index.cjs +1 -79
  77. package/dist/config/index.cjs.map +1 -1
  78. package/dist/config/index.js +1 -76
  79. package/dist/config/index.js.map +1 -1
  80. package/dist/continuous-event-graph/index.cjs +2 -2129
  81. package/dist/continuous-event-graph/index.cjs.map +1 -1
  82. package/dist/continuous-event-graph/index.d.cts +81 -5
  83. package/dist/continuous-event-graph/index.d.ts +81 -5
  84. package/dist/continuous-event-graph/index.js +2 -2088
  85. package/dist/continuous-event-graph/index.js.map +1 -1
  86. package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
  87. package/dist/event-graph/index.cjs +22 -8292
  88. package/dist/event-graph/index.cjs.map +1 -1
  89. package/dist/event-graph/index.js +22 -8237
  90. package/dist/event-graph/index.js.map +1 -1
  91. package/dist/execution-refs.cjs +2 -0
  92. package/dist/execution-refs.cjs.map +1 -0
  93. package/dist/execution-refs.d.cts +222 -0
  94. package/dist/execution-refs.d.ts +222 -0
  95. package/dist/execution-refs.js +2 -0
  96. package/dist/execution-refs.js.map +1 -0
  97. package/dist/index.cjs +29 -13221
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +2 -4
  100. package/dist/index.d.ts +2 -4
  101. package/dist/index.js +29 -13112
  102. package/dist/index.js.map +1 -1
  103. package/dist/inference/index.cjs +5 -617
  104. package/dist/inference/index.cjs.map +1 -1
  105. package/dist/inference/index.js +5 -610
  106. package/dist/inference/index.js.map +1 -1
  107. package/dist/jsonata-sync.cjs +7587 -0
  108. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  109. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  110. package/dist/pycli/quickjs-board-runtime.global.js +9 -0
  111. package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
  112. package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
  113. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
  114. package/dist/step-machine/index.cjs +11 -7129
  115. package/dist/step-machine/index.cjs.map +1 -1
  116. package/dist/step-machine/index.js +11 -7113
  117. package/dist/step-machine/index.js.map +1 -1
  118. package/dist/storage-refs.cjs +10 -0
  119. package/dist/storage-refs.cjs.map +1 -0
  120. package/dist/storage-refs.d.cts +92 -0
  121. package/dist/storage-refs.d.ts +92 -0
  122. package/dist/storage-refs.js +10 -0
  123. package/dist/storage-refs.js.map +1 -0
  124. package/dist/stores/file.cjs +1 -114
  125. package/dist/stores/file.cjs.map +1 -1
  126. package/dist/stores/file.js +1 -112
  127. package/dist/stores/file.js.map +1 -1
  128. package/dist/stores/index.cjs +1 -231
  129. package/dist/stores/index.cjs.map +1 -1
  130. package/dist/stores/index.js +1 -227
  131. package/dist/stores/index.js.map +1 -1
  132. package/dist/stores/localStorage.cjs +1 -76
  133. package/dist/stores/localStorage.cjs.map +1 -1
  134. package/dist/stores/localStorage.js +1 -74
  135. package/dist/stores/localStorage.js.map +1 -1
  136. package/dist/stores/memory.cjs +1 -47
  137. package/dist/stores/memory.cjs.map +1 -1
  138. package/dist/stores/memory.js +1 -45
  139. package/dist/stores/memory.js.map +1 -1
  140. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
  141. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  142. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  143. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  144. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
  145. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
  146. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  147. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  148. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
  149. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
  150. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
  151. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
  152. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
  153. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
  154. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
  155. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
  156. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
  157. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
  158. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
  159. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
  160. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  161. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  162. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  163. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  164. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
  165. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  166. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
  167. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  168. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  169. package/examples/example-board/agent-instructions.md +11 -5
  170. package/examples/example-board/demo-chat-handler.js +14 -4
  171. package/examples/example-board/demo-server-config.json +1 -0
  172. package/examples/example-board/demo-server.js +19 -34
  173. package/examples/example-board/demo-shell-browser.html +5 -4
  174. package/examples/example-board/demo-shell-with-server.html +10 -6
  175. package/examples/example-board/demo-task-executor.js +81 -35
  176. package/examples/index.html +0 -14
  177. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  178. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  179. package/package.json +39 -3
  180. package/schema/live-cards.schema.json +418 -132
  181. package/dist/cli/board-live-cards-cli.cjs +0 -10644
  182. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  183. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  184. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  185. package/dist/cli/board-live-cards-cli.js +0 -10592
  186. package/dist/cli/board-live-cards-cli.js.map +0 -1
  187. package/dist/journal-9HEgs7dU.d.ts +0 -28
  188. package/dist/journal-B-JCfQnh.d.cts +0 -28
  189. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  190. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  191. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  192. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  193. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  194. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  195. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  196. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  197. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  198. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  199. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  200. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
@@ -0,0 +1,10 @@
1
+ 'use strict';var i=require('fs'),c=require('path'),child_process=require('child_process');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__namespace=/*#__PURE__*/_interopNamespace(i);var c__namespace=/*#__PURE__*/_interopNamespace(c);function x(t){if(!t.startsWith("::"))throw new Error(`Invalid ref format (expected ::kind::value): ${t}`);let n=t.slice(2),r=n.indexOf("::");if(r===-1)throw new Error(`Invalid ref format (expected ::kind::value): ${t}`);return {kind:n.slice(0,r),value:n.slice(r+2)}}function h(t){return `::${t.kind}::${t.value}`}function R(){return {read(t){if(!i__namespace.existsSync(t))return null;try{return i__namespace.readFileSync(t,"utf-8")}catch{return null}},write(t,n){i__namespace.mkdirSync(c__namespace.dirname(t),{recursive:true}),i__namespace.writeFileSync(t,n,"utf-8");}}}function k(t){if(t.kind==="fs-path")return R();throw new Error(`Unsupported storage kind: "${t.kind}". Supported kinds: fs-path`)}function d(t){try{return x(t).value}catch{return t}}function g(t){let n=t.extra?.notifyChannel;return typeof n=="string"&&n.length>0?n:void 0}function w(t){if(!t.endsWith(".ts"))return {cmd:process.execPath,args:[t]};let n=c__namespace.dirname(t),r=[];for(let o=1;o<=5;o++){let s=c__namespace.join(n,...Array(o).fill(".."),"node_modules");r.push(c__namespace.join(s,"tsx","dist","cli.mjs")),r.push(c__namespace.join(s,".bin","tsx"));}let e=r.find(o=>i__namespace.existsSync(o));return e?{cmd:process.execPath,args:[e,t]}:{cmd:"npx",args:["tsx",t]}}function v(t,n){let{token:r,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let o=d(e.whatToRun),{cmd:s,args:l}=w(o),u=g(e),f=[...l,"source-data-fetched","--ref",h(n),"--token",r,...u?["--notify-channel",u]:[]],a=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportComplete: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let o=d(e.whatToRun),s=JSON.stringify({status:"complete",ref:h(n),token:r});m(o,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${e.howToRun}"`)}function T(t,n){let{token:r,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let o=d(e.whatToRun),{cmd:s,args:l}=w(o),u=g(e),f=[...l,"source-data-fetch-failure","--token",r,"--reason",n,...u?["--notify-channel",u]:[]],a=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportFailed: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let o=d(e.whatToRun),s=JSON.stringify({status:"failed",reason:n,token:r});m(o,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${e.howToRun}"`)}function m(t,n){let r=`
2
+ const {request} = require(new URL('${t}').protocol === 'https:' ? 'https' : 'http');
3
+ const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)})};
4
+ const u = new URL('${t}');
5
+ const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
6
+ req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
7
+ req.write(${JSON.stringify(n)});
8
+ req.end();
9
+ `,e=child_process.spawnSync(process.execPath,["-e",r],{encoding:"utf-8",windowsHide:true});if(e.status!==0)throw new Error(`http-post failed: ${e.stderr?.trim()}`)}exports.blobStorageForRef=k;exports.parseRef=x;exports.reportComplete=v;exports.reportFailed=T;exports.serializeRef=h;//# sourceMappingURL=storage-refs.cjs.map
10
+ //# sourceMappingURL=storage-refs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/node/public-storage-adapter.ts"],"names":["parseRef","s","inner","idx","serializeRef","ref","createFsPathBlobStorage","key","i","content","c","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","candidate","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script"],"mappings":"mfA8CO,SAASA,CAAAA,CAASC,CAAAA,CAAyB,CAChD,GAAI,CAACA,CAAAA,CAAE,UAAA,CAAW,IAAI,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgDA,CAAC,CAAA,CAAE,CAAA,CAC5F,IAAMC,CAAAA,CAAQD,CAAAA,CAAE,MAAM,CAAC,CAAA,CACjBE,CAAAA,CAAMD,CAAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,CAC9B,GAAIC,CAAAA,GAAQ,EAAA,CAAI,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgDF,CAAC,CAAA,CAAE,EACnF,OAAO,CAAE,IAAA,CAAMC,CAAAA,CAAM,KAAA,CAAM,CAAA,CAAGC,CAAG,CAAA,CAAG,KAAA,CAAOD,CAAAA,CAAM,KAAA,CAAMC,CAAAA,CAAM,CAAC,CAAE,CAClE,CAGO,SAASC,CAAAA,CAAaC,CAAAA,CAA2B,CACtD,OAAO,CAAA,EAAA,EAAKA,CAAAA,CAAI,IAAI,CAAA,EAAA,EAAKA,CAAAA,CAAI,KAAK,CAAA,CACpC,CAiBA,SAASC,CAAAA,EAAuC,CAC9C,OAAO,CACL,IAAA,CAAKC,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A,CAAgB,kBAAA,CAAoB,gBAAA,CAAkB,MAAA,CAAO,UAAA,CAAWC,CAAI,CAAE,CAAC,CAAC,CAAA;AAAA,uBAAA,EACxFD,CAAG,CAAA;AAAA;AAAA;AAAA,cAAA,EAGZ,IAAA,CAAK,SAAA,CAAUC,CAAI,CAAC,CAAA;AAAA;AAAA,EAAA,CAAA,CAG5BH,CAAAA,CAASC,uBAAAA,CAAU,OAAA,CAAQ,QAAA,CAAU,CAAC,IAAA,CAAMM,CAAM,CAAA,CAAG,CAAE,QAAA,CAAU,OAAA,CAAS,WAAA,CAAa,IAAK,CAAC,CAAA,CACnG,GAAIP,CAAAA,CAAO,MAAA,GAAW,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqBA,CAAAA,CAAO,MAAA,EAAQ,IAAA,EAAM,CAAA,CAAE,CACvF","file":"storage-refs.cjs","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: ::kind::value\n * - parseRef() parse a ::kind::value string\n * - serializeRef() produce a ::kind::value string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (::kind::value) into a KindValueRef. */\nexport function parseRef(s: string): KindValueRef {\n if (!s.startsWith('::')) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n const inner = s.slice(2);\n const idx = inner.indexOf('::');\n if (idx === -1) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n return { kind: inner.slice(0, idx), value: inner.slice(idx + 2) };\n}\n\n/** Serialize a KindValueRef to the wire format: ::kind::value */\nexport function serializeRef(ref: KindValueRef): string {\n return `::${ref.kind}::${ref.value}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun ::kind::value wire string.\n * Falls back to the raw string if it isn’t in ::kind::value form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n"]}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * public-storage-adapter.ts
3
+ *
4
+ * Standalone file — copy this to your task-executor project.
5
+ * Zero dependencies on the rest of yaml-flow.
6
+ *
7
+ * Provides:
8
+ * - KindValueRef wire format: ::kind::value
9
+ * - parseRef() parse a ::kind::value string
10
+ * - serializeRef() produce a ::kind::value string
11
+ * - BlobStorage read/write interface
12
+ * - blobStorageForRef resolve a ref to its BlobStorage backend
13
+ * - ExecutionRef portable invocation descriptor (inlined, stays standalone)
14
+ * - TaskCallback how to report task completion back to the board
15
+ * - reportComplete() call from executor on success
16
+ * - reportFailed() call from executor on failure
17
+ *
18
+ * Supported storage kinds:
19
+ * fs-path — ref.value is an absolute file path; reads/writes via node:fs
20
+ *
21
+ * Supported callback transports (via ExecutionRef.howToRun):
22
+ * local-node — invoke board CLI as a child Node process
23
+ * http:post — HTTP POST to a board endpoint
24
+ *
25
+ * Usage:
26
+ * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';
27
+ *
28
+ * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));
29
+ * // ... do work, write to outRef ...
30
+ * reportComplete(callback, outRef);
31
+ */
32
+ interface KindValueRef {
33
+ readonly kind: string;
34
+ readonly value: string;
35
+ }
36
+ /** Parse a wire-format ref string (::kind::value) into a KindValueRef. */
37
+ declare function parseRef(s: string): KindValueRef;
38
+ /** Serialize a KindValueRef to the wire format: ::kind::value */
39
+ declare function serializeRef(ref: KindValueRef): string;
40
+ interface BlobStorage {
41
+ /** Returns content string, or null if not found. */
42
+ read(key: string): string | null;
43
+ /** Write content at key. */
44
+ write(key: string, content: string): void;
45
+ }
46
+ /**
47
+ * Resolve a KindValueRef to its BlobStorage backend.
48
+ * Throws a clear error for unrecognised kinds.
49
+ */
50
+ declare function blobStorageForRef(ref: KindValueRef): BlobStorage;
51
+ /**
52
+ * Portable invocation descriptor for the board CLI back-channel.
53
+ * Inlined here so this file stays standalone (zero deps on yaml-flow internals).
54
+ * Shape matches ExecutionRef in execution-interface.ts — keep in sync.
55
+ *
56
+ * Supported howToRun values for TaskCallback.via:
57
+ * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]
58
+ * http:post — POST to <whatToRun.value> with a JSON body
59
+ */
60
+ interface ExecutionRef {
61
+ /** Optional human-readable label. Not used for dispatch. */
62
+ meta?: string;
63
+ /** Transport / runtime kind. */
64
+ howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';
65
+ /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */
66
+ whatToRun: string;
67
+ /** Opaque executor config stored with the ref. */
68
+ extra?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Describes how the board wants to receive task completion callbacks.
72
+ * Baked into the inRef payload as { source_def, callback }.
73
+ * The executor treats `token` as opaque and passes it back unchanged.
74
+ */
75
+ interface TaskCallback {
76
+ /** Opaque routing token — generated by the board, passed back unchanged. */
77
+ token: string;
78
+ /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */
79
+ via: ExecutionRef;
80
+ }
81
+ /**
82
+ * Report successful task completion back to the board.
83
+ * Call this from a task-executor after writing the result to outRef.
84
+ */
85
+ declare function reportComplete(callback: TaskCallback, outRef: KindValueRef): void;
86
+ /**
87
+ * Report task failure back to the board.
88
+ * Call this from a task-executor instead of writing to outRef.
89
+ */
90
+ declare function reportFailed(callback: TaskCallback, reason: string): void;
91
+
92
+ export { type BlobStorage, type ExecutionRef, type KindValueRef, type TaskCallback, blobStorageForRef, parseRef, reportComplete, reportFailed, serializeRef };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * public-storage-adapter.ts
3
+ *
4
+ * Standalone file — copy this to your task-executor project.
5
+ * Zero dependencies on the rest of yaml-flow.
6
+ *
7
+ * Provides:
8
+ * - KindValueRef wire format: ::kind::value
9
+ * - parseRef() parse a ::kind::value string
10
+ * - serializeRef() produce a ::kind::value string
11
+ * - BlobStorage read/write interface
12
+ * - blobStorageForRef resolve a ref to its BlobStorage backend
13
+ * - ExecutionRef portable invocation descriptor (inlined, stays standalone)
14
+ * - TaskCallback how to report task completion back to the board
15
+ * - reportComplete() call from executor on success
16
+ * - reportFailed() call from executor on failure
17
+ *
18
+ * Supported storage kinds:
19
+ * fs-path — ref.value is an absolute file path; reads/writes via node:fs
20
+ *
21
+ * Supported callback transports (via ExecutionRef.howToRun):
22
+ * local-node — invoke board CLI as a child Node process
23
+ * http:post — HTTP POST to a board endpoint
24
+ *
25
+ * Usage:
26
+ * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';
27
+ *
28
+ * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));
29
+ * // ... do work, write to outRef ...
30
+ * reportComplete(callback, outRef);
31
+ */
32
+ interface KindValueRef {
33
+ readonly kind: string;
34
+ readonly value: string;
35
+ }
36
+ /** Parse a wire-format ref string (::kind::value) into a KindValueRef. */
37
+ declare function parseRef(s: string): KindValueRef;
38
+ /** Serialize a KindValueRef to the wire format: ::kind::value */
39
+ declare function serializeRef(ref: KindValueRef): string;
40
+ interface BlobStorage {
41
+ /** Returns content string, or null if not found. */
42
+ read(key: string): string | null;
43
+ /** Write content at key. */
44
+ write(key: string, content: string): void;
45
+ }
46
+ /**
47
+ * Resolve a KindValueRef to its BlobStorage backend.
48
+ * Throws a clear error for unrecognised kinds.
49
+ */
50
+ declare function blobStorageForRef(ref: KindValueRef): BlobStorage;
51
+ /**
52
+ * Portable invocation descriptor for the board CLI back-channel.
53
+ * Inlined here so this file stays standalone (zero deps on yaml-flow internals).
54
+ * Shape matches ExecutionRef in execution-interface.ts — keep in sync.
55
+ *
56
+ * Supported howToRun values for TaskCallback.via:
57
+ * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]
58
+ * http:post — POST to <whatToRun.value> with a JSON body
59
+ */
60
+ interface ExecutionRef {
61
+ /** Optional human-readable label. Not used for dispatch. */
62
+ meta?: string;
63
+ /** Transport / runtime kind. */
64
+ howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';
65
+ /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */
66
+ whatToRun: string;
67
+ /** Opaque executor config stored with the ref. */
68
+ extra?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Describes how the board wants to receive task completion callbacks.
72
+ * Baked into the inRef payload as { source_def, callback }.
73
+ * The executor treats `token` as opaque and passes it back unchanged.
74
+ */
75
+ interface TaskCallback {
76
+ /** Opaque routing token — generated by the board, passed back unchanged. */
77
+ token: string;
78
+ /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */
79
+ via: ExecutionRef;
80
+ }
81
+ /**
82
+ * Report successful task completion back to the board.
83
+ * Call this from a task-executor after writing the result to outRef.
84
+ */
85
+ declare function reportComplete(callback: TaskCallback, outRef: KindValueRef): void;
86
+ /**
87
+ * Report task failure back to the board.
88
+ * Call this from a task-executor instead of writing to outRef.
89
+ */
90
+ declare function reportFailed(callback: TaskCallback, reason: string): void;
91
+
92
+ export { type BlobStorage, type ExecutionRef, type KindValueRef, type TaskCallback, blobStorageForRef, parseRef, reportComplete, reportFailed, serializeRef };
@@ -0,0 +1,10 @@
1
+ import*as i from'fs';import*as c from'path';import {spawnSync}from'child_process';function x(t){if(!t.startsWith("::"))throw new Error(`Invalid ref format (expected ::kind::value): ${t}`);let n=t.slice(2),r=n.indexOf("::");if(r===-1)throw new Error(`Invalid ref format (expected ::kind::value): ${t}`);return {kind:n.slice(0,r),value:n.slice(r+2)}}function h(t){return `::${t.kind}::${t.value}`}function R(){return {read(t){if(!i.existsSync(t))return null;try{return i.readFileSync(t,"utf-8")}catch{return null}},write(t,n){i.mkdirSync(c.dirname(t),{recursive:true}),i.writeFileSync(t,n,"utf-8");}}}function k(t){if(t.kind==="fs-path")return R();throw new Error(`Unsupported storage kind: "${t.kind}". Supported kinds: fs-path`)}function d(t){try{return x(t).value}catch{return t}}function g(t){let n=t.extra?.notifyChannel;return typeof n=="string"&&n.length>0?n:void 0}function w(t){if(!t.endsWith(".ts"))return {cmd:process.execPath,args:[t]};let n=c.dirname(t),r=[];for(let o=1;o<=5;o++){let s=c.join(n,...Array(o).fill(".."),"node_modules");r.push(c.join(s,"tsx","dist","cli.mjs")),r.push(c.join(s,".bin","tsx"));}let e=r.find(o=>i.existsSync(o));return e?{cmd:process.execPath,args:[e,t]}:{cmd:"npx",args:["tsx",t]}}function v(t,n){let{token:r,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let o=d(e.whatToRun),{cmd:s,args:l}=w(o),u=g(e),f=[...l,"source-data-fetched","--ref",h(n),"--token",r,...u?["--notify-channel",u]:[]],a=spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportComplete: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let o=d(e.whatToRun),s=JSON.stringify({status:"complete",ref:h(n),token:r});m(o,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${e.howToRun}"`)}function T(t,n){let{token:r,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let o=d(e.whatToRun),{cmd:s,args:l}=w(o),u=g(e),f=[...l,"source-data-fetch-failure","--token",r,"--reason",n,...u?["--notify-channel",u]:[]],a=spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportFailed: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let o=d(e.whatToRun),s=JSON.stringify({status:"failed",reason:n,token:r});m(o,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${e.howToRun}"`)}function m(t,n){let r=`
2
+ const {request} = require(new URL('${t}').protocol === 'https:' ? 'https' : 'http');
3
+ const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)})};
4
+ const u = new URL('${t}');
5
+ const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
6
+ req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
7
+ req.write(${JSON.stringify(n)});
8
+ req.end();
9
+ `,e=spawnSync(process.execPath,["-e",r],{encoding:"utf-8",windowsHide:true});if(e.status!==0)throw new Error(`http-post failed: ${e.stderr?.trim()}`)}export{k as blobStorageForRef,x as parseRef,v as reportComplete,T as reportFailed,h as serializeRef};//# sourceMappingURL=storage-refs.js.map
10
+ //# sourceMappingURL=storage-refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/node/public-storage-adapter.ts"],"names":["parseRef","s","inner","idx","serializeRef","ref","createFsPathBlobStorage","key","content","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","candidate","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script"],"mappings":"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O,MAAA,EAAQ,IAAA,EAAM,CAAA,CAAE,CACvF","file":"storage-refs.js","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: ::kind::value\n * - parseRef() parse a ::kind::value string\n * - serializeRef() produce a ::kind::value string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (::kind::value) into a KindValueRef. */\nexport function parseRef(s: string): KindValueRef {\n if (!s.startsWith('::')) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n const inner = s.slice(2);\n const idx = inner.indexOf('::');\n if (idx === -1) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n return { kind: inner.slice(0, idx), value: inner.slice(idx + 2) };\n}\n\n/** Serialize a KindValueRef to the wire format: ::kind::value */\nexport function serializeRef(ref: KindValueRef): string {\n return `::${ref.kind}::${ref.value}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun ::kind::value wire string.\n * Falls back to the raw string if it isn’t in ::kind::value form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n"]}
@@ -1,115 +1,2 @@
1
- 'use strict';
2
-
3
- // src/stores/file.ts
4
- var FileStore = class {
5
- directory;
6
- fs = null;
7
- path = null;
8
- constructor(options) {
9
- this.directory = options.directory;
10
- }
11
- async ensureModules() {
12
- if (!this.fs || !this.path) {
13
- this.fs = await import('fs/promises');
14
- this.path = await import('path');
15
- await this.fs.mkdir(this.directory, { recursive: true });
16
- }
17
- }
18
- runPath(runId) {
19
- return this.path.join(this.directory, `${runId}.run.json`);
20
- }
21
- dataPath(runId) {
22
- return this.path.join(this.directory, `${runId}.data.json`);
23
- }
24
- async saveRunState(runId, state) {
25
- await this.ensureModules();
26
- await this.fs.writeFile(
27
- this.runPath(runId),
28
- JSON.stringify(state, null, 2),
29
- "utf-8"
30
- );
31
- }
32
- async loadRunState(runId) {
33
- await this.ensureModules();
34
- try {
35
- const raw = await this.fs.readFile(this.runPath(runId), "utf-8");
36
- return JSON.parse(raw);
37
- } catch (err) {
38
- if (err.code === "ENOENT") {
39
- return null;
40
- }
41
- throw err;
42
- }
43
- }
44
- async deleteRunState(runId) {
45
- await this.ensureModules();
46
- try {
47
- await this.fs.unlink(this.runPath(runId));
48
- } catch (err) {
49
- if (err.code !== "ENOENT") throw err;
50
- }
51
- try {
52
- await this.fs.unlink(this.dataPath(runId));
53
- } catch (err) {
54
- if (err.code !== "ENOENT") throw err;
55
- }
56
- }
57
- async setData(runId, key, value) {
58
- await this.ensureModules();
59
- const allData = await this.getAllData(runId);
60
- allData[key] = value;
61
- await this.fs.writeFile(
62
- this.dataPath(runId),
63
- JSON.stringify(allData, null, 2),
64
- "utf-8"
65
- );
66
- }
67
- async getData(runId, key) {
68
- const allData = await this.getAllData(runId);
69
- return allData[key];
70
- }
71
- async getAllData(runId) {
72
- await this.ensureModules();
73
- try {
74
- const raw = await this.fs.readFile(this.dataPath(runId), "utf-8");
75
- return JSON.parse(raw);
76
- } catch (err) {
77
- if (err.code === "ENOENT") {
78
- return {};
79
- }
80
- throw err;
81
- }
82
- }
83
- async clearData(runId) {
84
- await this.ensureModules();
85
- try {
86
- await this.fs.unlink(this.dataPath(runId));
87
- } catch (err) {
88
- if (err.code !== "ENOENT") throw err;
89
- }
90
- }
91
- async listRuns() {
92
- await this.ensureModules();
93
- try {
94
- const files = await this.fs.readdir(this.directory);
95
- return files.filter((f) => f.endsWith(".run.json")).map((f) => f.replace(".run.json", ""));
96
- } catch (err) {
97
- if (err.code === "ENOENT") {
98
- return [];
99
- }
100
- throw err;
101
- }
102
- }
103
- /**
104
- * Clear all flow data from directory
105
- */
106
- async clearAll() {
107
- await this.ensureModules();
108
- const runs = await this.listRuns();
109
- await Promise.all(runs.map((runId) => this.deleteRunState(runId)));
110
- }
111
- };
112
-
113
- exports.FileStore = FileStore;
114
- //# sourceMappingURL=file.cjs.map
1
+ 'use strict';var a=class{directory;fs=null;path=null;constructor(i){this.directory=i.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(i){return this.path.join(this.directory,`${i}.run.json`)}dataPath(i){return this.path.join(this.directory,`${i}.data.json`)}async saveRunState(i,t){await this.ensureModules(),await this.fs.writeFile(this.runPath(i),JSON.stringify(t,null,2),"utf-8");}async loadRunState(i){await this.ensureModules();try{let t=await this.fs.readFile(this.runPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return null;throw t}}async deleteRunState(i){await this.ensureModules();try{await this.fs.unlink(this.runPath(i));}catch(t){if(t.code!=="ENOENT")throw t}try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async setData(i,t,r){await this.ensureModules();let e=await this.getAllData(i);e[t]=r,await this.fs.writeFile(this.dataPath(i),JSON.stringify(e,null,2),"utf-8");}async getData(i,t){return (await this.getAllData(i))[t]}async getAllData(i){await this.ensureModules();try{let t=await this.fs.readFile(this.dataPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return {};throw t}}async clearData(i){await this.ensureModules();try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(t=>t.endsWith(".run.json")).map(t=>t.replace(".run.json",""))}catch(i){if(i.code==="ENOENT")return [];throw i}}async clearAll(){await this.ensureModules();let i=await this.listRuns();await Promise.all(i.map(t=>this.deleteRunState(t)));}};exports.FileStore=a;//# sourceMappingURL=file.cjs.map
115
2
  //# sourceMappingURL=file.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stores/file.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAN,MAA4C;AAAA,EACzC,SAAA;AAAA,EACA,EAAA,GAA0C,IAAA;AAAA,EAC1C,IAAA,GAAqC,IAAA;AAAA,EAE7C,YAAY,OAAA,EAA2B;AACrC,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AAAA,EAC3B;AAAA,EAEA,MAAc,aAAA,GAA+B;AAC3C,IAAA,IAAI,CAAC,IAAA,CAAK,EAAA,IAAM,CAAC,KAAK,IAAA,EAAM;AAE1B,MAAA,IAAA,CAAK,EAAA,GAAK,MAAM,OAAO,aAAa,CAAA;AACpC,MAAA,IAAA,CAAK,IAAA,GAAO,MAAM,OAAO,MAAM,CAAA;AAG/B,MAAA,MAAM,IAAA,CAAK,GAAG,KAAA,CAAM,IAAA,CAAK,WAAW,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA,IACzD;AAAA,EACF;AAAA,EAEQ,QAAQ,KAAA,EAAuB;AACrC,IAAA,OAAO,KAAK,IAAA,CAAM,IAAA,CAAK,KAAK,SAAA,EAAW,CAAA,EAAG,KAAK,CAAA,SAAA,CAAW,CAAA;AAAA,EAC5D;AAAA,EAEQ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AA,IAAI;AACF,MAAA,MAAM,KAAK,EAAA,CAAI,MAAA,CAAO,IAAA,CAAK,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,IAC5C,SAAS,GAAA,EAAc;AACrB,MAAA,IAAK,GAAA,CAA8B,IAAA,KAAS,QAAA,EAAU,MAAM,GAAA;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,MAAM,QAAA,GAA8B;AAClC,IAAA,MAAM,KAAK,aAAA,EAAc;AACzB,IAAA,IAAI;AACF,MAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,EAAA,CAAI,OAAA,CAAQ,KAAK,SAAS,CAAA;AACnD,MAAA,OAAO,KAAA,CACJ,MAAA,CAAO,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,WAAW,CAAC,CAAA,CACnC,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,OAAA,CAAQ,WAAA,EAAa,EAAE,CAAC,CAAA;AAAA,IACxC,SAAS,GAAA,EAAc;AACrB,MAAA,IAAK,GAAA,CAA8B,SAAS,QAAA,EAAU;AACpD,QAAA,OAAO,EAAC;AAAA,MACV;AACA,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAA,GAA0B;AAC9B,IAAA,MAAM,KAAK,aAAA,EAAc;AACzB,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,QAAA,EAAS;AACjC,IAAA,MAAM,OAAA,CAAQ,IAAI,IAAA,CAAK,GAAA,CAAI,WAAS,IAAA,CAAK,cAAA,CAAe,KAAK,CAAC,CAAC,CAAA;AAAA,EACjE;AACF","file":"file.cjs","sourcesContent":["/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/stores/file.ts"],"names":["FileStore","options","runId","state","raw","err","key","value","allData","f","runs"],"mappings":"aAcO,IAAMA,CAAAA,CAAN,KAA4C,CACzC,SAAA,CACA,GAA0C,IAAA,CAC1C,IAAA,CAAqC,KAE7C,WAAA,CAAYC,CAAAA,CAA2B,CACrC,IAAA,CAAK,SAAA,CAAYA,EAAQ,UAC3B,CAEA,MAAc,aAAA,EAA+B,CAAA,CACvC,CAAC,IAAA,CAAK,EAAA,EAAM,CAAC,IAAA,CAAK,IAAA,IAEpB,KAAK,EAAA,CAAK,aAAa,aAAa,CAAA,CACpC,KAAK,IAAA,CAAO,aAAa,MAAM,CAAA,CAG/B,MAAM,IAAA,CAAK,EAAA,CAAG,MAAM,IAAA,CAAK,SAAA,CAAW,CAAE,SAAA,CAAW,IAAK,CAAC,GAE3D,CAEQ,OAAA,CAAQC,EAAuB,CACrC,OAAO,KAAK,IAAA,CAAM,IAAA,CAAK,KAAK,SAAA,CAAW,CAAA,EAAGA,CAAK,CAAA,SAAA,CAAW,CAC5D,CAEQ,QAAA,CAASA,CAAAA,CAAuB,CACtC,OAAO,IA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V,MAAMA,CACR,CACF,CAKA,MAAM,QAAA,EAA0B,CAC9B,MAAM,IAAA,CAAK,eAAc,CACzB,IAAMK,EAAO,MAAM,IAAA,CAAK,UAAS,CACjC,MAAM,QAAQ,GAAA,CAAIA,CAAAA,CAAK,IAAIR,CAAAA,EAAS,IAAA,CAAK,eAAeA,CAAK,CAAC,CAAC,EACjE,CACF","file":"file.cjs","sourcesContent":["/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
@@ -1,113 +1,2 @@
1
- // src/stores/file.ts
2
- var FileStore = class {
3
- directory;
4
- fs = null;
5
- path = null;
6
- constructor(options) {
7
- this.directory = options.directory;
8
- }
9
- async ensureModules() {
10
- if (!this.fs || !this.path) {
11
- this.fs = await import('fs/promises');
12
- this.path = await import('path');
13
- await this.fs.mkdir(this.directory, { recursive: true });
14
- }
15
- }
16
- runPath(runId) {
17
- return this.path.join(this.directory, `${runId}.run.json`);
18
- }
19
- dataPath(runId) {
20
- return this.path.join(this.directory, `${runId}.data.json`);
21
- }
22
- async saveRunState(runId, state) {
23
- await this.ensureModules();
24
- await this.fs.writeFile(
25
- this.runPath(runId),
26
- JSON.stringify(state, null, 2),
27
- "utf-8"
28
- );
29
- }
30
- async loadRunState(runId) {
31
- await this.ensureModules();
32
- try {
33
- const raw = await this.fs.readFile(this.runPath(runId), "utf-8");
34
- return JSON.parse(raw);
35
- } catch (err) {
36
- if (err.code === "ENOENT") {
37
- return null;
38
- }
39
- throw err;
40
- }
41
- }
42
- async deleteRunState(runId) {
43
- await this.ensureModules();
44
- try {
45
- await this.fs.unlink(this.runPath(runId));
46
- } catch (err) {
47
- if (err.code !== "ENOENT") throw err;
48
- }
49
- try {
50
- await this.fs.unlink(this.dataPath(runId));
51
- } catch (err) {
52
- if (err.code !== "ENOENT") throw err;
53
- }
54
- }
55
- async setData(runId, key, value) {
56
- await this.ensureModules();
57
- const allData = await this.getAllData(runId);
58
- allData[key] = value;
59
- await this.fs.writeFile(
60
- this.dataPath(runId),
61
- JSON.stringify(allData, null, 2),
62
- "utf-8"
63
- );
64
- }
65
- async getData(runId, key) {
66
- const allData = await this.getAllData(runId);
67
- return allData[key];
68
- }
69
- async getAllData(runId) {
70
- await this.ensureModules();
71
- try {
72
- const raw = await this.fs.readFile(this.dataPath(runId), "utf-8");
73
- return JSON.parse(raw);
74
- } catch (err) {
75
- if (err.code === "ENOENT") {
76
- return {};
77
- }
78
- throw err;
79
- }
80
- }
81
- async clearData(runId) {
82
- await this.ensureModules();
83
- try {
84
- await this.fs.unlink(this.dataPath(runId));
85
- } catch (err) {
86
- if (err.code !== "ENOENT") throw err;
87
- }
88
- }
89
- async listRuns() {
90
- await this.ensureModules();
91
- try {
92
- const files = await this.fs.readdir(this.directory);
93
- return files.filter((f) => f.endsWith(".run.json")).map((f) => f.replace(".run.json", ""));
94
- } catch (err) {
95
- if (err.code === "ENOENT") {
96
- return [];
97
- }
98
- throw err;
99
- }
100
- }
101
- /**
102
- * Clear all flow data from directory
103
- */
104
- async clearAll() {
105
- await this.ensureModules();
106
- const runs = await this.listRuns();
107
- await Promise.all(runs.map((runId) => this.deleteRunState(runId)));
108
- }
109
- };
110
-
111
- export { FileStore };
112
- //# sourceMappingURL=file.js.map
1
+ var a=class{directory;fs=null;path=null;constructor(i){this.directory=i.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(i){return this.path.join(this.directory,`${i}.run.json`)}dataPath(i){return this.path.join(this.directory,`${i}.data.json`)}async saveRunState(i,t){await this.ensureModules(),await this.fs.writeFile(this.runPath(i),JSON.stringify(t,null,2),"utf-8");}async loadRunState(i){await this.ensureModules();try{let t=await this.fs.readFile(this.runPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return null;throw t}}async deleteRunState(i){await this.ensureModules();try{await this.fs.unlink(this.runPath(i));}catch(t){if(t.code!=="ENOENT")throw t}try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async setData(i,t,r){await this.ensureModules();let e=await this.getAllData(i);e[t]=r,await this.fs.writeFile(this.dataPath(i),JSON.stringify(e,null,2),"utf-8");}async getData(i,t){return (await this.getAllData(i))[t]}async getAllData(i){await this.ensureModules();try{let t=await this.fs.readFile(this.dataPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return {};throw t}}async clearData(i){await this.ensureModules();try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(t=>t.endsWith(".run.json")).map(t=>t.replace(".run.json",""))}catch(i){if(i.code==="ENOENT")return [];throw i}}async clearAll(){await this.ensureModules();let i=await this.listRuns();await Promise.all(i.map(t=>this.deleteRunState(t)));}};export{a as FileStore};//# sourceMappingURL=file.js.map
113
2
  //# sourceMappingURL=file.js.map