yaml-flow 5.4.2 → 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 (199) hide show
  1. package/board-live-cards-cli.js +2 -2
  2. package/board-livecards-server-runtime.js +486 -547
  3. package/browser/asset-integrity.json +10 -0
  4. package/browser/board-livegraph-engine.js +2 -1676
  5. package/browser/board-livegraph-engine.js.map +1 -1
  6. package/browser/live-cards.js +347 -26
  7. package/browser/live-cards.schema.json +418 -132
  8. package/card-store.js +37 -0
  9. package/dist/batch/index.cjs +1 -108
  10. package/dist/batch/index.cjs.map +1 -1
  11. package/dist/batch/index.js +1 -106
  12. package/dist/batch/index.js.map +1 -1
  13. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  14. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  15. package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
  16. package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
  17. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  18. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  19. package/dist/board-livegraph-runtime/index.d.cts +1 -2
  20. package/dist/board-livegraph-runtime/index.d.ts +1 -2
  21. package/dist/board-livegraph-runtime/index.js +2 -1662
  22. package/dist/board-livegraph-runtime/index.js.map +1 -1
  23. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
  24. package/dist/card-compute/index.cjs +9 -7159
  25. package/dist/card-compute/index.cjs.map +1 -1
  26. package/dist/card-compute/index.d.cts +22 -0
  27. package/dist/card-compute/index.d.ts +22 -0
  28. package/dist/card-compute/index.js +9 -7145
  29. package/dist/card-compute/index.js.map +1 -1
  30. package/dist/card-compute/jsonata-sync.cjs +7587 -0
  31. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
  36. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  37. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  38. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  39. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  40. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  41. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  42. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  43. package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
  44. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  45. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  46. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  47. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  48. package/dist/cli/node/artifacts-store-cli.js +11 -0
  49. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  50. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  51. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  52. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  53. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  54. package/dist/cli/node/board-live-cards-cli.js +15 -0
  55. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  56. package/dist/cli/node/card-store-cli.cjs +8 -0
  57. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  58. package/dist/cli/node/card-store-cli.d.cts +15 -0
  59. package/dist/cli/node/card-store-cli.d.ts +15 -0
  60. package/dist/cli/node/card-store-cli.js +8 -0
  61. package/dist/cli/node/card-store-cli.js.map +1 -0
  62. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  63. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  64. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  65. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  66. package/dist/cli/node/fs-board-adapter.js +14 -0
  67. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  68. package/dist/cli/node/jsonata-sync.cjs +7587 -0
  69. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  70. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  71. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  72. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  73. package/dist/cli/node/source-cli-task-executor.js +11 -0
  74. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  75. package/dist/config/index.cjs +1 -79
  76. package/dist/config/index.cjs.map +1 -1
  77. package/dist/config/index.js +1 -76
  78. package/dist/config/index.js.map +1 -1
  79. package/dist/continuous-event-graph/index.cjs +2 -2129
  80. package/dist/continuous-event-graph/index.cjs.map +1 -1
  81. package/dist/continuous-event-graph/index.d.cts +81 -5
  82. package/dist/continuous-event-graph/index.d.ts +81 -5
  83. package/dist/continuous-event-graph/index.js +2 -2088
  84. package/dist/continuous-event-graph/index.js.map +1 -1
  85. package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
  86. package/dist/event-graph/index.cjs +22 -8292
  87. package/dist/event-graph/index.cjs.map +1 -1
  88. package/dist/event-graph/index.js +22 -8237
  89. package/dist/event-graph/index.js.map +1 -1
  90. package/dist/execution-refs.cjs +2 -0
  91. package/dist/execution-refs.cjs.map +1 -0
  92. package/dist/execution-refs.d.cts +222 -0
  93. package/dist/execution-refs.d.ts +222 -0
  94. package/dist/execution-refs.js +2 -0
  95. package/dist/execution-refs.js.map +1 -0
  96. package/dist/index.cjs +29 -13221
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +2 -4
  99. package/dist/index.d.ts +2 -4
  100. package/dist/index.js +29 -13112
  101. package/dist/index.js.map +1 -1
  102. package/dist/inference/index.cjs +5 -617
  103. package/dist/inference/index.cjs.map +1 -1
  104. package/dist/inference/index.js +5 -610
  105. package/dist/inference/index.js.map +1 -1
  106. package/dist/jsonata-sync.cjs +7587 -0
  107. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  108. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  109. package/dist/pycli/quickjs-board-runtime.global.js +9 -0
  110. package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
  111. package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
  112. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
  113. package/dist/step-machine/index.cjs +11 -7129
  114. package/dist/step-machine/index.cjs.map +1 -1
  115. package/dist/step-machine/index.js +11 -7113
  116. package/dist/step-machine/index.js.map +1 -1
  117. package/dist/storage-refs.cjs +10 -0
  118. package/dist/storage-refs.cjs.map +1 -0
  119. package/dist/storage-refs.d.cts +92 -0
  120. package/dist/storage-refs.d.ts +92 -0
  121. package/dist/storage-refs.js +10 -0
  122. package/dist/storage-refs.js.map +1 -0
  123. package/dist/stores/file.cjs +1 -114
  124. package/dist/stores/file.cjs.map +1 -1
  125. package/dist/stores/file.js +1 -112
  126. package/dist/stores/file.js.map +1 -1
  127. package/dist/stores/index.cjs +1 -231
  128. package/dist/stores/index.cjs.map +1 -1
  129. package/dist/stores/index.js +1 -227
  130. package/dist/stores/index.js.map +1 -1
  131. package/dist/stores/localStorage.cjs +1 -76
  132. package/dist/stores/localStorage.cjs.map +1 -1
  133. package/dist/stores/localStorage.js +1 -74
  134. package/dist/stores/localStorage.js.map +1 -1
  135. package/dist/stores/memory.cjs +1 -47
  136. package/dist/stores/memory.cjs.map +1 -1
  137. package/dist/stores/memory.js +1 -45
  138. package/dist/stores/memory.js.map +1 -1
  139. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
  140. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  141. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  142. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  143. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
  144. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
  145. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  146. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  147. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
  148. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
  149. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
  150. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
  151. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
  152. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
  153. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
  154. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
  155. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
  156. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
  157. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
  158. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
  159. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  160. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  161. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  162. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  163. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
  164. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  165. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
  166. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  167. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  168. package/examples/example-board/agent-instructions.md +11 -5
  169. package/examples/example-board/demo-chat-handler.js +14 -4
  170. package/examples/example-board/demo-server-config.json +1 -0
  171. package/examples/example-board/demo-server.js +14 -7
  172. package/examples/example-board/demo-shell-browser.html +5 -4
  173. package/examples/example-board/demo-shell-with-server.html +6 -5
  174. package/examples/example-board/demo-task-executor.js +81 -35
  175. package/examples/index.html +0 -14
  176. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  177. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  178. package/package.json +39 -3
  179. package/schema/live-cards.schema.json +418 -132
  180. package/dist/cli/board-live-cards-cli.cjs +0 -10650
  181. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  182. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  183. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  184. package/dist/cli/board-live-cards-cli.js +0 -10598
  185. package/dist/cli/board-live-cards-cli.js.map +0 -1
  186. package/dist/journal-9HEgs7dU.d.ts +0 -28
  187. package/dist/journal-B-JCfQnh.d.cts +0 -28
  188. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  189. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  190. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  191. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  192. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  193. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  194. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  195. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  196. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  197. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  198. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  199. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
@@ -0,0 +1,2 @@
1
+ 'use strict';function o(e,t){let n;return /\.m?js$/i.test(e)?n="local-node":/\.py$/i.test(e)?n="local-python":n="local-process",{meta:"task-executor",howToRun:n,whatToRun:`::fs-path::${e}`,...t?{extra:t}:{}}}function r(e){return JSON.stringify(e)}function i(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}exports.executionRefFromScriptPath=o;exports.parseExecutionRef=i;exports.serializeExecutionRef=r;//# sourceMappingURL=execution-refs.cjs.map
2
+ //# sourceMappingURL=execution-refs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/common/execution-interface.ts"],"names":["executionRefFromScriptPath","scriptPath","extra","howToRun","serializeExecutionRef","ref","parseExecutionRef","s","parsed"],"mappings":"aA6OO,SAASA,CAAAA,CACdC,EACAC,CAAAA,CACc,CACd,IAAIC,CAAAA,CACJ,OAAI,WAAW,IAAA,CAAKF,CAAU,EAAGE,CAAAA,CAAW,YAAA,CACnC,SAAS,IAAA,CAAKF,CAAU,EAAGE,CAAAA,CAAW,cAAA,CAC1CA,EAAW,eAAA,CACT,CACL,KAAM,eAAA,CACN,QAAA,CAAAA,EACA,SAAA,CAAW,CAAA,WAAA,EAAcF,CAAU,CAAA,CAAA,CACnC,GAAIC,EAAQ,CAAE,KAAA,CAAAA,CAAM,CAAA,CAAI,EAC1B,CACF,CAUO,SAASE,CAAAA,CAAsBC,CAAAA,CAA2B,CAC/D,OAAO,IAAA,CAAK,SAAA,CAAUA,CAAG,CAC3B,CAMO,SAASC,CAAAA,CAAkBC,CAAAA,CAAyB,CACzD,IAAIC,CAAAA,CACJ,GAAI,CACFA,CAAAA,CAAS,KAAK,KAAA,CAAMD,CAAC,EACvB,CAAA,KAAQ,CACN,MAAM,IAAI,KAAA,CAAM,CAAA,uCAAA,EAAqCA,CAAC,CAAA,CAAE,CAC1D,CACA,GACE,OAAOC,GAAW,QAAA,EAClBA,CAAAA,GAAW,MACX,OAAQA,CAAAA,CAAmC,UAAa,QAAA,EACxD,OAAQA,EAAmC,SAAA,EAAc,QAAA,CAEzD,MAAM,IAAI,KAAA,CAAM,wEAAmED,CAAC,CAAA,CAAE,CAAA,CAExF,OAAOC,CACT","file":"execution-refs.cjs","sourcesContent":["/**\n * execution-interface.ts\n *\n * Pure module — no Node/platform imports. Safe for any runtime.\n *\n * Defines the portable descriptor types for invoking any executable target,\n * regardless of transport (local process, HTTP endpoint, cloud function, etc.).\n *\n * Parallel to storage-interface.ts (which describes WHERE data lives), this\n * module describes HOW to invoke a piece of logic.\n *\n * ────────────────────────────────────────────────────────────────────────────\n * CORE CONCEPTS\n * ────────────────────────────────────────────────────────────────────────────\n *\n * ExecutionRef — self-contained, serializable JSON descriptor for one invocation target.\n * • howToRun — transport / runtime kind (discriminator)\n * • whatToRun — address of the artifact (KindValueRef wire form: ::kind::value)\n * • argsMassaging — optional JSONata expressions that map logical args → physical call shape\n * • meta — optional human-readable label (e.g. 'task-executor', 'chat-handler')\n *\n * ExecutionResult — standardized envelope returned by any invocation.\n * • status: 'success' | 'fail' | 'error'\n * • data — KindValueRef wire form pointing to output blob (on success)\n * • error — human-readable message (on fail/error)\n *\n * ────────────────────────────────────────────────────────────────────────────\n * howToRun VALUES\n * ────────────────────────────────────────────────────────────────────────────\n *\n * 'local-node' node <whatToRun> [argv...]\n * 'local-python' python <whatToRun> [argv...]\n * 'local-process' execute <whatToRun> directly (shebang / pre-resolved binary)\n * 'http:post' HTTP POST to <whatToRun>\n * 'http:get' HTTP GET to <whatToRun>\n * 'built-in' resolved by the adapter to a well-known internal implementation\n *\n * ────────────────────────────────────────────────────────────────────────────\n * argsMassaging\n * ────────────────────────────────────────────────────────────────────────────\n *\n * Each field is a JSONata expression evaluated against the caller's logical args object.\n * If argsMassaging is omitted, the adapter uses its default mapping for the howToRun kind.\n *\n * cmdTemplate — array of JSONata exprs, each producing one argv string (local transports)\n * urlTemplate — JSONata expr producing the final URL string (http transports)\n * bodyTemplate — JSONata expr producing the request body object (http transports)\n *\n * ────────────────────────────────────────────────────────────────────────────\n * SERIALIZATION\n * ────────────────────────────────────────────────────────────────────────────\n *\n * ExecutionRef is a plain JSON object — store it as-is on disk, in Cosmos, or any DB.\n * No special encoding needed. parseExecutionRef / serializeExecutionRef are thin\n * JSON wrappers provided for symmetry with storage-interface.\n *\n * ────────────────────────────────────────────────────────────────────────────\n * USAGE EXAMPLES\n * ────────────────────────────────────────────────────────────────────────────\n *\n * // Built-in source-cli task executor (resolved by adapter from cliDir):\n * const builtIn: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'built-in',\n * whatToRun: '::built-in::source-cli-task-executor',\n * };\n *\n * // External local-node task executor with default protocol args:\n * const local: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'local-node',\n * whatToRun: '::fs-path::/path/to/my-executor.js',\n * };\n *\n * // Azure Function task executor with custom arg mapping:\n * const azureFn: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'http:post',\n * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/task-executor',\n * argsMassaging: {\n * urlTemplate: \"whatToRun & '?op=' & subcommand\",\n * bodyTemplate: \"{ 'inRef': inRef, 'outRef': outRef, 'token': token }\",\n * },\n * };\n *\n * // Chat handler over HTTP with a different logical args shape:\n * const chatHandler: ExecutionRef = {\n * meta: 'chat-handler',\n * howToRun: 'http:post',\n * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/chat',\n * argsMassaging: {\n * bodyTemplate: \"{ 'message': message, 'context': context, 'sessionId': sessionId }\",\n * },\n * };\n */\n\n// ============================================================================\n// ArgsMassaging\n// ============================================================================\n\n/**\n * Optional JSONata-based mapping from logical args → physical invocation shape.\n *\n * Each field is a JSONata expression string evaluated against the caller's\n * logical args object (e.g. `{ inRef, outRef, errRef }` for a task-executor).\n *\n * If argsMassaging is omitted entirely, the execution adapter uses its default\n * mapping for the given howToRun kind.\n */\nexport interface ArgsMassaging {\n /**\n * For local transports ('local-node', 'local-python', 'local-process').\n * Array of JSONata expressions — each evaluates to one argv string.\n * The resolved strings are appended after the base command.\n *\n * @example\n * // Standard task-executor protocol:\n * cmdTemplate: [\n * \"'run-source-fetch'\",\n * \"'--in-ref'\", \"inRef\",\n * \"'--out-ref'\", \"outRef\",\n * \"'--err-ref'\", \"errRef\",\n * ]\n */\n cmdTemplate?: string[];\n\n /**\n * For http transports ('http:post', 'http:get').\n * JSONata expression that produces the final URL string.\n * The input context includes 'whatToRun' (the base URL from the ref)\n * plus all logical args.\n *\n * @example\n * urlTemplate: \"whatToRun & '?op=' & subcommand\"\n */\n urlTemplate?: string;\n\n /**\n * For http transports.\n * JSONata expression that produces the request body object.\n * Evaluated against the logical args object.\n *\n * @example\n * bodyTemplate: \"{ 'inRef': inRef, 'outRef': outRef, 'token': token }\"\n */\n bodyTemplate?: string;\n}\n\n// ============================================================================\n// ExecutionRef\n// ============================================================================\n\n/**\n * Self-contained, serializable descriptor for invoking a target.\n *\n * Stores everything needed to make the physical call — transport kind,\n * artifact address, and optional arg-mapping expressions.\n * Serialize as plain JSON; no special wire encoding required.\n */\nexport interface ExecutionRef {\n /**\n * Optional human-readable label identifying the role of this invocation.\n * Not used for dispatch — purely for logging and diagnostics.\n * @example 'task-executor', 'chat-handler', 'board-live-cards'\n */\n meta?: string;\n\n /**\n * Transport and runtime kind — determines how whatToRun is invoked.\n * @see module JSDoc for the full list of supported values.\n */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n\n /**\n * Address of the artifact to run, in KindValueRef wire form (::kind::value).\n * @example '::fs-path::/dist/cli/source-cli-task-executor.js'\n * @example '::http-url::https://fn.example.com/api/executor'\n * @example '::built-in::source-cli-task-executor'\n */\n whatToRun: string;\n\n /**\n * Optional JSONata-based mapping from logical args → physical call shape.\n * When omitted, the adapter applies its default protocol for the howToRun kind.\n */\n argsMassaging?: ArgsMassaging;\n\n /**\n * Opaque executor-specific configuration.\n * For local transports, base64-encoded and passed as --extra <base64-json> in the argv.\n * For HTTP transports, available in argsMassaging.bodyTemplate as the `extra` binding.\n * Stored with the ref so it travels as a single unit with the invocation descriptor.\n */\n extra?: Record<string, unknown>;\n}\n\n// ============================================================================\n// ExecutionResult\n// ============================================================================\n\n/**\n * Standardized result envelope returned by any execution.\n *\n * Replaces the implicit \"file-exists = success, absent = failure\" protocol\n * with an explicit status field. The data ref points to the output blob.\n */\nexport interface ExecutionResult {\n /** Outcome of the execution. */\n status: 'success' | 'fail' | 'error';\n\n /**\n * KindValueRef wire form pointing to the output blob.\n * Present only when status === 'success'.\n */\n data?: string;\n\n /**\n * Human-readable error or failure message.\n * Present when status === 'fail' or 'error'.\n */\n error?: string;\n}\n\n// ============================================================================\n// ExecutionRef factory helpers\n// ============================================================================\n\n/**\n * Create an ExecutionRef from a script path string (e.g. from a --task-executor CLI arg).\n * File extension determines howToRun:\n * .js / .mjs → 'local-node'\n * .py → 'local-python'\n * other → 'local-process'\n *\n * @param scriptPath Absolute or relative path to the script / binary.\n * @param extra Optional opaque executor config stored on the ref.\n */\nexport function executionRefFromScriptPath(\n scriptPath: string,\n extra?: Record<string, unknown>,\n): ExecutionRef {\n let howToRun: ExecutionRef['howToRun'];\n if (/\\.m?js$/i.test(scriptPath)) howToRun = 'local-node';\n else if (/\\.py$/i.test(scriptPath)) howToRun = 'local-python';\n else howToRun = 'local-process';\n return {\n meta: 'task-executor',\n howToRun,\n whatToRun: `::fs-path::${scriptPath}`,\n ...(extra ? { extra } : {}),\n };\n}\n\n// ============================================================================\n// Serialization helpers\n// ============================================================================\n\n/**\n * Serialize an ExecutionRef to a JSON string for storage.\n * Plain JSON.stringify — no special encoding.\n */\nexport function serializeExecutionRef(ref: ExecutionRef): string {\n return JSON.stringify(ref);\n}\n\n/**\n * Parse a JSON string back into an ExecutionRef.\n * Throws if the string is not valid JSON or is missing required fields.\n */\nexport function parseExecutionRef(s: string): ExecutionRef {\n let parsed: unknown;\n try {\n parsed = JSON.parse(s);\n } catch {\n throw new Error(`parseExecutionRef: invalid JSON — ${s}`);\n }\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n typeof (parsed as Record<string, unknown>).howToRun !== 'string' ||\n typeof (parsed as Record<string, unknown>).whatToRun !== 'string'\n ) {\n throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun — ${s}`);\n }\n return parsed as ExecutionRef;\n}\n"]}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * execution-interface.ts
3
+ *
4
+ * Pure module — no Node/platform imports. Safe for any runtime.
5
+ *
6
+ * Defines the portable descriptor types for invoking any executable target,
7
+ * regardless of transport (local process, HTTP endpoint, cloud function, etc.).
8
+ *
9
+ * Parallel to storage-interface.ts (which describes WHERE data lives), this
10
+ * module describes HOW to invoke a piece of logic.
11
+ *
12
+ * ────────────────────────────────────────────────────────────────────────────
13
+ * CORE CONCEPTS
14
+ * ────────────────────────────────────────────────────────────────────────────
15
+ *
16
+ * ExecutionRef — self-contained, serializable JSON descriptor for one invocation target.
17
+ * • howToRun — transport / runtime kind (discriminator)
18
+ * • whatToRun — address of the artifact (KindValueRef wire form: ::kind::value)
19
+ * • argsMassaging — optional JSONata expressions that map logical args → physical call shape
20
+ * • meta — optional human-readable label (e.g. 'task-executor', 'chat-handler')
21
+ *
22
+ * ExecutionResult — standardized envelope returned by any invocation.
23
+ * • status: 'success' | 'fail' | 'error'
24
+ * • data — KindValueRef wire form pointing to output blob (on success)
25
+ * • error — human-readable message (on fail/error)
26
+ *
27
+ * ────────────────────────────────────────────────────────────────────────────
28
+ * howToRun VALUES
29
+ * ────────────────────────────────────────────────────────────────────────────
30
+ *
31
+ * 'local-node' node <whatToRun> [argv...]
32
+ * 'local-python' python <whatToRun> [argv...]
33
+ * 'local-process' execute <whatToRun> directly (shebang / pre-resolved binary)
34
+ * 'http:post' HTTP POST to <whatToRun>
35
+ * 'http:get' HTTP GET to <whatToRun>
36
+ * 'built-in' resolved by the adapter to a well-known internal implementation
37
+ *
38
+ * ────────────────────────────────────────────────────────────────────────────
39
+ * argsMassaging
40
+ * ────────────────────────────────────────────────────────────────────────────
41
+ *
42
+ * Each field is a JSONata expression evaluated against the caller's logical args object.
43
+ * If argsMassaging is omitted, the adapter uses its default mapping for the howToRun kind.
44
+ *
45
+ * cmdTemplate — array of JSONata exprs, each producing one argv string (local transports)
46
+ * urlTemplate — JSONata expr producing the final URL string (http transports)
47
+ * bodyTemplate — JSONata expr producing the request body object (http transports)
48
+ *
49
+ * ────────────────────────────────────────────────────────────────────────────
50
+ * SERIALIZATION
51
+ * ────────────────────────────────────────────────────────────────────────────
52
+ *
53
+ * ExecutionRef is a plain JSON object — store it as-is on disk, in Cosmos, or any DB.
54
+ * No special encoding needed. parseExecutionRef / serializeExecutionRef are thin
55
+ * JSON wrappers provided for symmetry with storage-interface.
56
+ *
57
+ * ────────────────────────────────────────────────────────────────────────────
58
+ * USAGE EXAMPLES
59
+ * ────────────────────────────────────────────────────────────────────────────
60
+ *
61
+ * // Built-in source-cli task executor (resolved by adapter from cliDir):
62
+ * const builtIn: ExecutionRef = {
63
+ * meta: 'task-executor',
64
+ * howToRun: 'built-in',
65
+ * whatToRun: '::built-in::source-cli-task-executor',
66
+ * };
67
+ *
68
+ * // External local-node task executor with default protocol args:
69
+ * const local: ExecutionRef = {
70
+ * meta: 'task-executor',
71
+ * howToRun: 'local-node',
72
+ * whatToRun: '::fs-path::/path/to/my-executor.js',
73
+ * };
74
+ *
75
+ * // Azure Function task executor with custom arg mapping:
76
+ * const azureFn: ExecutionRef = {
77
+ * meta: 'task-executor',
78
+ * howToRun: 'http:post',
79
+ * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/task-executor',
80
+ * argsMassaging: {
81
+ * urlTemplate: "whatToRun & '?op=' & subcommand",
82
+ * bodyTemplate: "{ 'inRef': inRef, 'outRef': outRef, 'token': token }",
83
+ * },
84
+ * };
85
+ *
86
+ * // Chat handler over HTTP with a different logical args shape:
87
+ * const chatHandler: ExecutionRef = {
88
+ * meta: 'chat-handler',
89
+ * howToRun: 'http:post',
90
+ * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/chat',
91
+ * argsMassaging: {
92
+ * bodyTemplate: "{ 'message': message, 'context': context, 'sessionId': sessionId }",
93
+ * },
94
+ * };
95
+ */
96
+ /**
97
+ * Optional JSONata-based mapping from logical args → physical invocation shape.
98
+ *
99
+ * Each field is a JSONata expression string evaluated against the caller's
100
+ * logical args object (e.g. `{ inRef, outRef, errRef }` for a task-executor).
101
+ *
102
+ * If argsMassaging is omitted entirely, the execution adapter uses its default
103
+ * mapping for the given howToRun kind.
104
+ */
105
+ interface ArgsMassaging {
106
+ /**
107
+ * For local transports ('local-node', 'local-python', 'local-process').
108
+ * Array of JSONata expressions — each evaluates to one argv string.
109
+ * The resolved strings are appended after the base command.
110
+ *
111
+ * @example
112
+ * // Standard task-executor protocol:
113
+ * cmdTemplate: [
114
+ * "'run-source-fetch'",
115
+ * "'--in-ref'", "inRef",
116
+ * "'--out-ref'", "outRef",
117
+ * "'--err-ref'", "errRef",
118
+ * ]
119
+ */
120
+ cmdTemplate?: string[];
121
+ /**
122
+ * For http transports ('http:post', 'http:get').
123
+ * JSONata expression that produces the final URL string.
124
+ * The input context includes 'whatToRun' (the base URL from the ref)
125
+ * plus all logical args.
126
+ *
127
+ * @example
128
+ * urlTemplate: "whatToRun & '?op=' & subcommand"
129
+ */
130
+ urlTemplate?: string;
131
+ /**
132
+ * For http transports.
133
+ * JSONata expression that produces the request body object.
134
+ * Evaluated against the logical args object.
135
+ *
136
+ * @example
137
+ * bodyTemplate: "{ 'inRef': inRef, 'outRef': outRef, 'token': token }"
138
+ */
139
+ bodyTemplate?: string;
140
+ }
141
+ /**
142
+ * Self-contained, serializable descriptor for invoking a target.
143
+ *
144
+ * Stores everything needed to make the physical call — transport kind,
145
+ * artifact address, and optional arg-mapping expressions.
146
+ * Serialize as plain JSON; no special wire encoding required.
147
+ */
148
+ interface ExecutionRef {
149
+ /**
150
+ * Optional human-readable label identifying the role of this invocation.
151
+ * Not used for dispatch — purely for logging and diagnostics.
152
+ * @example 'task-executor', 'chat-handler', 'board-live-cards'
153
+ */
154
+ meta?: string;
155
+ /**
156
+ * Transport and runtime kind — determines how whatToRun is invoked.
157
+ * @see module JSDoc for the full list of supported values.
158
+ */
159
+ howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';
160
+ /**
161
+ * Address of the artifact to run, in KindValueRef wire form (::kind::value).
162
+ * @example '::fs-path::/dist/cli/source-cli-task-executor.js'
163
+ * @example '::http-url::https://fn.example.com/api/executor'
164
+ * @example '::built-in::source-cli-task-executor'
165
+ */
166
+ whatToRun: string;
167
+ /**
168
+ * Optional JSONata-based mapping from logical args → physical call shape.
169
+ * When omitted, the adapter applies its default protocol for the howToRun kind.
170
+ */
171
+ argsMassaging?: ArgsMassaging;
172
+ /**
173
+ * Opaque executor-specific configuration.
174
+ * For local transports, base64-encoded and passed as --extra <base64-json> in the argv.
175
+ * For HTTP transports, available in argsMassaging.bodyTemplate as the `extra` binding.
176
+ * Stored with the ref so it travels as a single unit with the invocation descriptor.
177
+ */
178
+ extra?: Record<string, unknown>;
179
+ }
180
+ /**
181
+ * Standardized result envelope returned by any execution.
182
+ *
183
+ * Replaces the implicit "file-exists = success, absent = failure" protocol
184
+ * with an explicit status field. The data ref points to the output blob.
185
+ */
186
+ interface ExecutionResult {
187
+ /** Outcome of the execution. */
188
+ status: 'success' | 'fail' | 'error';
189
+ /**
190
+ * KindValueRef wire form pointing to the output blob.
191
+ * Present only when status === 'success'.
192
+ */
193
+ data?: string;
194
+ /**
195
+ * Human-readable error or failure message.
196
+ * Present when status === 'fail' or 'error'.
197
+ */
198
+ error?: string;
199
+ }
200
+ /**
201
+ * Create an ExecutionRef from a script path string (e.g. from a --task-executor CLI arg).
202
+ * File extension determines howToRun:
203
+ * .js / .mjs → 'local-node'
204
+ * .py → 'local-python'
205
+ * other → 'local-process'
206
+ *
207
+ * @param scriptPath Absolute or relative path to the script / binary.
208
+ * @param extra Optional opaque executor config stored on the ref.
209
+ */
210
+ declare function executionRefFromScriptPath(scriptPath: string, extra?: Record<string, unknown>): ExecutionRef;
211
+ /**
212
+ * Serialize an ExecutionRef to a JSON string for storage.
213
+ * Plain JSON.stringify — no special encoding.
214
+ */
215
+ declare function serializeExecutionRef(ref: ExecutionRef): string;
216
+ /**
217
+ * Parse a JSON string back into an ExecutionRef.
218
+ * Throws if the string is not valid JSON or is missing required fields.
219
+ */
220
+ declare function parseExecutionRef(s: string): ExecutionRef;
221
+
222
+ export { type ArgsMassaging, type ExecutionRef, type ExecutionResult, executionRefFromScriptPath, parseExecutionRef, serializeExecutionRef };
@@ -0,0 +1,222 @@
1
+ /**
2
+ * execution-interface.ts
3
+ *
4
+ * Pure module — no Node/platform imports. Safe for any runtime.
5
+ *
6
+ * Defines the portable descriptor types for invoking any executable target,
7
+ * regardless of transport (local process, HTTP endpoint, cloud function, etc.).
8
+ *
9
+ * Parallel to storage-interface.ts (which describes WHERE data lives), this
10
+ * module describes HOW to invoke a piece of logic.
11
+ *
12
+ * ────────────────────────────────────────────────────────────────────────────
13
+ * CORE CONCEPTS
14
+ * ────────────────────────────────────────────────────────────────────────────
15
+ *
16
+ * ExecutionRef — self-contained, serializable JSON descriptor for one invocation target.
17
+ * • howToRun — transport / runtime kind (discriminator)
18
+ * • whatToRun — address of the artifact (KindValueRef wire form: ::kind::value)
19
+ * • argsMassaging — optional JSONata expressions that map logical args → physical call shape
20
+ * • meta — optional human-readable label (e.g. 'task-executor', 'chat-handler')
21
+ *
22
+ * ExecutionResult — standardized envelope returned by any invocation.
23
+ * • status: 'success' | 'fail' | 'error'
24
+ * • data — KindValueRef wire form pointing to output blob (on success)
25
+ * • error — human-readable message (on fail/error)
26
+ *
27
+ * ────────────────────────────────────────────────────────────────────────────
28
+ * howToRun VALUES
29
+ * ────────────────────────────────────────────────────────────────────────────
30
+ *
31
+ * 'local-node' node <whatToRun> [argv...]
32
+ * 'local-python' python <whatToRun> [argv...]
33
+ * 'local-process' execute <whatToRun> directly (shebang / pre-resolved binary)
34
+ * 'http:post' HTTP POST to <whatToRun>
35
+ * 'http:get' HTTP GET to <whatToRun>
36
+ * 'built-in' resolved by the adapter to a well-known internal implementation
37
+ *
38
+ * ────────────────────────────────────────────────────────────────────────────
39
+ * argsMassaging
40
+ * ────────────────────────────────────────────────────────────────────────────
41
+ *
42
+ * Each field is a JSONata expression evaluated against the caller's logical args object.
43
+ * If argsMassaging is omitted, the adapter uses its default mapping for the howToRun kind.
44
+ *
45
+ * cmdTemplate — array of JSONata exprs, each producing one argv string (local transports)
46
+ * urlTemplate — JSONata expr producing the final URL string (http transports)
47
+ * bodyTemplate — JSONata expr producing the request body object (http transports)
48
+ *
49
+ * ────────────────────────────────────────────────────────────────────────────
50
+ * SERIALIZATION
51
+ * ────────────────────────────────────────────────────────────────────────────
52
+ *
53
+ * ExecutionRef is a plain JSON object — store it as-is on disk, in Cosmos, or any DB.
54
+ * No special encoding needed. parseExecutionRef / serializeExecutionRef are thin
55
+ * JSON wrappers provided for symmetry with storage-interface.
56
+ *
57
+ * ────────────────────────────────────────────────────────────────────────────
58
+ * USAGE EXAMPLES
59
+ * ────────────────────────────────────────────────────────────────────────────
60
+ *
61
+ * // Built-in source-cli task executor (resolved by adapter from cliDir):
62
+ * const builtIn: ExecutionRef = {
63
+ * meta: 'task-executor',
64
+ * howToRun: 'built-in',
65
+ * whatToRun: '::built-in::source-cli-task-executor',
66
+ * };
67
+ *
68
+ * // External local-node task executor with default protocol args:
69
+ * const local: ExecutionRef = {
70
+ * meta: 'task-executor',
71
+ * howToRun: 'local-node',
72
+ * whatToRun: '::fs-path::/path/to/my-executor.js',
73
+ * };
74
+ *
75
+ * // Azure Function task executor with custom arg mapping:
76
+ * const azureFn: ExecutionRef = {
77
+ * meta: 'task-executor',
78
+ * howToRun: 'http:post',
79
+ * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/task-executor',
80
+ * argsMassaging: {
81
+ * urlTemplate: "whatToRun & '?op=' & subcommand",
82
+ * bodyTemplate: "{ 'inRef': inRef, 'outRef': outRef, 'token': token }",
83
+ * },
84
+ * };
85
+ *
86
+ * // Chat handler over HTTP with a different logical args shape:
87
+ * const chatHandler: ExecutionRef = {
88
+ * meta: 'chat-handler',
89
+ * howToRun: 'http:post',
90
+ * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/chat',
91
+ * argsMassaging: {
92
+ * bodyTemplate: "{ 'message': message, 'context': context, 'sessionId': sessionId }",
93
+ * },
94
+ * };
95
+ */
96
+ /**
97
+ * Optional JSONata-based mapping from logical args → physical invocation shape.
98
+ *
99
+ * Each field is a JSONata expression string evaluated against the caller's
100
+ * logical args object (e.g. `{ inRef, outRef, errRef }` for a task-executor).
101
+ *
102
+ * If argsMassaging is omitted entirely, the execution adapter uses its default
103
+ * mapping for the given howToRun kind.
104
+ */
105
+ interface ArgsMassaging {
106
+ /**
107
+ * For local transports ('local-node', 'local-python', 'local-process').
108
+ * Array of JSONata expressions — each evaluates to one argv string.
109
+ * The resolved strings are appended after the base command.
110
+ *
111
+ * @example
112
+ * // Standard task-executor protocol:
113
+ * cmdTemplate: [
114
+ * "'run-source-fetch'",
115
+ * "'--in-ref'", "inRef",
116
+ * "'--out-ref'", "outRef",
117
+ * "'--err-ref'", "errRef",
118
+ * ]
119
+ */
120
+ cmdTemplate?: string[];
121
+ /**
122
+ * For http transports ('http:post', 'http:get').
123
+ * JSONata expression that produces the final URL string.
124
+ * The input context includes 'whatToRun' (the base URL from the ref)
125
+ * plus all logical args.
126
+ *
127
+ * @example
128
+ * urlTemplate: "whatToRun & '?op=' & subcommand"
129
+ */
130
+ urlTemplate?: string;
131
+ /**
132
+ * For http transports.
133
+ * JSONata expression that produces the request body object.
134
+ * Evaluated against the logical args object.
135
+ *
136
+ * @example
137
+ * bodyTemplate: "{ 'inRef': inRef, 'outRef': outRef, 'token': token }"
138
+ */
139
+ bodyTemplate?: string;
140
+ }
141
+ /**
142
+ * Self-contained, serializable descriptor for invoking a target.
143
+ *
144
+ * Stores everything needed to make the physical call — transport kind,
145
+ * artifact address, and optional arg-mapping expressions.
146
+ * Serialize as plain JSON; no special wire encoding required.
147
+ */
148
+ interface ExecutionRef {
149
+ /**
150
+ * Optional human-readable label identifying the role of this invocation.
151
+ * Not used for dispatch — purely for logging and diagnostics.
152
+ * @example 'task-executor', 'chat-handler', 'board-live-cards'
153
+ */
154
+ meta?: string;
155
+ /**
156
+ * Transport and runtime kind — determines how whatToRun is invoked.
157
+ * @see module JSDoc for the full list of supported values.
158
+ */
159
+ howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';
160
+ /**
161
+ * Address of the artifact to run, in KindValueRef wire form (::kind::value).
162
+ * @example '::fs-path::/dist/cli/source-cli-task-executor.js'
163
+ * @example '::http-url::https://fn.example.com/api/executor'
164
+ * @example '::built-in::source-cli-task-executor'
165
+ */
166
+ whatToRun: string;
167
+ /**
168
+ * Optional JSONata-based mapping from logical args → physical call shape.
169
+ * When omitted, the adapter applies its default protocol for the howToRun kind.
170
+ */
171
+ argsMassaging?: ArgsMassaging;
172
+ /**
173
+ * Opaque executor-specific configuration.
174
+ * For local transports, base64-encoded and passed as --extra <base64-json> in the argv.
175
+ * For HTTP transports, available in argsMassaging.bodyTemplate as the `extra` binding.
176
+ * Stored with the ref so it travels as a single unit with the invocation descriptor.
177
+ */
178
+ extra?: Record<string, unknown>;
179
+ }
180
+ /**
181
+ * Standardized result envelope returned by any execution.
182
+ *
183
+ * Replaces the implicit "file-exists = success, absent = failure" protocol
184
+ * with an explicit status field. The data ref points to the output blob.
185
+ */
186
+ interface ExecutionResult {
187
+ /** Outcome of the execution. */
188
+ status: 'success' | 'fail' | 'error';
189
+ /**
190
+ * KindValueRef wire form pointing to the output blob.
191
+ * Present only when status === 'success'.
192
+ */
193
+ data?: string;
194
+ /**
195
+ * Human-readable error or failure message.
196
+ * Present when status === 'fail' or 'error'.
197
+ */
198
+ error?: string;
199
+ }
200
+ /**
201
+ * Create an ExecutionRef from a script path string (e.g. from a --task-executor CLI arg).
202
+ * File extension determines howToRun:
203
+ * .js / .mjs → 'local-node'
204
+ * .py → 'local-python'
205
+ * other → 'local-process'
206
+ *
207
+ * @param scriptPath Absolute or relative path to the script / binary.
208
+ * @param extra Optional opaque executor config stored on the ref.
209
+ */
210
+ declare function executionRefFromScriptPath(scriptPath: string, extra?: Record<string, unknown>): ExecutionRef;
211
+ /**
212
+ * Serialize an ExecutionRef to a JSON string for storage.
213
+ * Plain JSON.stringify — no special encoding.
214
+ */
215
+ declare function serializeExecutionRef(ref: ExecutionRef): string;
216
+ /**
217
+ * Parse a JSON string back into an ExecutionRef.
218
+ * Throws if the string is not valid JSON or is missing required fields.
219
+ */
220
+ declare function parseExecutionRef(s: string): ExecutionRef;
221
+
222
+ export { type ArgsMassaging, type ExecutionRef, type ExecutionResult, executionRefFromScriptPath, parseExecutionRef, serializeExecutionRef };
@@ -0,0 +1,2 @@
1
+ function o(e,t){let n;return /\.m?js$/i.test(e)?n="local-node":/\.py$/i.test(e)?n="local-python":n="local-process",{meta:"task-executor",howToRun:n,whatToRun:`::fs-path::${e}`,...t?{extra:t}:{}}}function r(e){return JSON.stringify(e)}function i(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}export{o as executionRefFromScriptPath,i as parseExecutionRef,r as serializeExecutionRef};//# sourceMappingURL=execution-refs.js.map
2
+ //# sourceMappingURL=execution-refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/common/execution-interface.ts"],"names":["executionRefFromScriptPath","scriptPath","extra","howToRun","serializeExecutionRef","ref","parseExecutionRef","s","parsed"],"mappings":"AA6OO,SAASA,CAAAA,CACdC,EACAC,CAAAA,CACc,CACd,IAAIC,CAAAA,CACJ,OAAI,WAAW,IAAA,CAAKF,CAAU,EAAGE,CAAAA,CAAW,YAAA,CACnC,SAAS,IAAA,CAAKF,CAAU,EAAGE,CAAAA,CAAW,cAAA,CAC1CA,EAAW,eAAA,CACT,CACL,KAAM,eAAA,CACN,QAAA,CAAAA,EACA,SAAA,CAAW,CAAA,WAAA,EAAcF,CAAU,CAAA,CAAA,CACnC,GAAIC,EAAQ,CAAE,KAAA,CAAAA,CAAM,CAAA,CAAI,EAC1B,CACF,CAUO,SAASE,CAAAA,CAAsBC,CAAAA,CAA2B,CAC/D,OAAO,IAAA,CAAK,SAAA,CAAUA,CAAG,CAC3B,CAMO,SAASC,CAAAA,CAAkBC,CAAAA,CAAyB,CACzD,IAAIC,CAAAA,CACJ,GAAI,CACFA,CAAAA,CAAS,KAAK,KAAA,CAAMD,CAAC,EACvB,CAAA,KAAQ,CACN,MAAM,IAAI,KAAA,CAAM,CAAA,uCAAA,EAAqCA,CAAC,CAAA,CAAE,CAC1D,CACA,GACE,OAAOC,GAAW,QAAA,EAClBA,CAAAA,GAAW,MACX,OAAQA,CAAAA,CAAmC,UAAa,QAAA,EACxD,OAAQA,EAAmC,SAAA,EAAc,QAAA,CAEzD,MAAM,IAAI,KAAA,CAAM,wEAAmED,CAAC,CAAA,CAAE,CAAA,CAExF,OAAOC,CACT","file":"execution-refs.js","sourcesContent":["/**\n * execution-interface.ts\n *\n * Pure module — no Node/platform imports. Safe for any runtime.\n *\n * Defines the portable descriptor types for invoking any executable target,\n * regardless of transport (local process, HTTP endpoint, cloud function, etc.).\n *\n * Parallel to storage-interface.ts (which describes WHERE data lives), this\n * module describes HOW to invoke a piece of logic.\n *\n * ────────────────────────────────────────────────────────────────────────────\n * CORE CONCEPTS\n * ────────────────────────────────────────────────────────────────────────────\n *\n * ExecutionRef — self-contained, serializable JSON descriptor for one invocation target.\n * • howToRun — transport / runtime kind (discriminator)\n * • whatToRun — address of the artifact (KindValueRef wire form: ::kind::value)\n * • argsMassaging — optional JSONata expressions that map logical args → physical call shape\n * • meta — optional human-readable label (e.g. 'task-executor', 'chat-handler')\n *\n * ExecutionResult — standardized envelope returned by any invocation.\n * • status: 'success' | 'fail' | 'error'\n * • data — KindValueRef wire form pointing to output blob (on success)\n * • error — human-readable message (on fail/error)\n *\n * ────────────────────────────────────────────────────────────────────────────\n * howToRun VALUES\n * ────────────────────────────────────────────────────────────────────────────\n *\n * 'local-node' node <whatToRun> [argv...]\n * 'local-python' python <whatToRun> [argv...]\n * 'local-process' execute <whatToRun> directly (shebang / pre-resolved binary)\n * 'http:post' HTTP POST to <whatToRun>\n * 'http:get' HTTP GET to <whatToRun>\n * 'built-in' resolved by the adapter to a well-known internal implementation\n *\n * ────────────────────────────────────────────────────────────────────────────\n * argsMassaging\n * ────────────────────────────────────────────────────────────────────────────\n *\n * Each field is a JSONata expression evaluated against the caller's logical args object.\n * If argsMassaging is omitted, the adapter uses its default mapping for the howToRun kind.\n *\n * cmdTemplate — array of JSONata exprs, each producing one argv string (local transports)\n * urlTemplate — JSONata expr producing the final URL string (http transports)\n * bodyTemplate — JSONata expr producing the request body object (http transports)\n *\n * ────────────────────────────────────────────────────────────────────────────\n * SERIALIZATION\n * ────────────────────────────────────────────────────────────────────────────\n *\n * ExecutionRef is a plain JSON object — store it as-is on disk, in Cosmos, or any DB.\n * No special encoding needed. parseExecutionRef / serializeExecutionRef are thin\n * JSON wrappers provided for symmetry with storage-interface.\n *\n * ────────────────────────────────────────────────────────────────────────────\n * USAGE EXAMPLES\n * ────────────────────────────────────────────────────────────────────────────\n *\n * // Built-in source-cli task executor (resolved by adapter from cliDir):\n * const builtIn: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'built-in',\n * whatToRun: '::built-in::source-cli-task-executor',\n * };\n *\n * // External local-node task executor with default protocol args:\n * const local: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'local-node',\n * whatToRun: '::fs-path::/path/to/my-executor.js',\n * };\n *\n * // Azure Function task executor with custom arg mapping:\n * const azureFn: ExecutionRef = {\n * meta: 'task-executor',\n * howToRun: 'http:post',\n * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/task-executor',\n * argsMassaging: {\n * urlTemplate: \"whatToRun & '?op=' & subcommand\",\n * bodyTemplate: \"{ 'inRef': inRef, 'outRef': outRef, 'token': token }\",\n * },\n * };\n *\n * // Chat handler over HTTP with a different logical args shape:\n * const chatHandler: ExecutionRef = {\n * meta: 'chat-handler',\n * howToRun: 'http:post',\n * whatToRun: '::http-url::https://myfn.azurewebsites.net/api/chat',\n * argsMassaging: {\n * bodyTemplate: \"{ 'message': message, 'context': context, 'sessionId': sessionId }\",\n * },\n * };\n */\n\n// ============================================================================\n// ArgsMassaging\n// ============================================================================\n\n/**\n * Optional JSONata-based mapping from logical args → physical invocation shape.\n *\n * Each field is a JSONata expression string evaluated against the caller's\n * logical args object (e.g. `{ inRef, outRef, errRef }` for a task-executor).\n *\n * If argsMassaging is omitted entirely, the execution adapter uses its default\n * mapping for the given howToRun kind.\n */\nexport interface ArgsMassaging {\n /**\n * For local transports ('local-node', 'local-python', 'local-process').\n * Array of JSONata expressions — each evaluates to one argv string.\n * The resolved strings are appended after the base command.\n *\n * @example\n * // Standard task-executor protocol:\n * cmdTemplate: [\n * \"'run-source-fetch'\",\n * \"'--in-ref'\", \"inRef\",\n * \"'--out-ref'\", \"outRef\",\n * \"'--err-ref'\", \"errRef\",\n * ]\n */\n cmdTemplate?: string[];\n\n /**\n * For http transports ('http:post', 'http:get').\n * JSONata expression that produces the final URL string.\n * The input context includes 'whatToRun' (the base URL from the ref)\n * plus all logical args.\n *\n * @example\n * urlTemplate: \"whatToRun & '?op=' & subcommand\"\n */\n urlTemplate?: string;\n\n /**\n * For http transports.\n * JSONata expression that produces the request body object.\n * Evaluated against the logical args object.\n *\n * @example\n * bodyTemplate: \"{ 'inRef': inRef, 'outRef': outRef, 'token': token }\"\n */\n bodyTemplate?: string;\n}\n\n// ============================================================================\n// ExecutionRef\n// ============================================================================\n\n/**\n * Self-contained, serializable descriptor for invoking a target.\n *\n * Stores everything needed to make the physical call — transport kind,\n * artifact address, and optional arg-mapping expressions.\n * Serialize as plain JSON; no special wire encoding required.\n */\nexport interface ExecutionRef {\n /**\n * Optional human-readable label identifying the role of this invocation.\n * Not used for dispatch — purely for logging and diagnostics.\n * @example 'task-executor', 'chat-handler', 'board-live-cards'\n */\n meta?: string;\n\n /**\n * Transport and runtime kind — determines how whatToRun is invoked.\n * @see module JSDoc for the full list of supported values.\n */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n\n /**\n * Address of the artifact to run, in KindValueRef wire form (::kind::value).\n * @example '::fs-path::/dist/cli/source-cli-task-executor.js'\n * @example '::http-url::https://fn.example.com/api/executor'\n * @example '::built-in::source-cli-task-executor'\n */\n whatToRun: string;\n\n /**\n * Optional JSONata-based mapping from logical args → physical call shape.\n * When omitted, the adapter applies its default protocol for the howToRun kind.\n */\n argsMassaging?: ArgsMassaging;\n\n /**\n * Opaque executor-specific configuration.\n * For local transports, base64-encoded and passed as --extra <base64-json> in the argv.\n * For HTTP transports, available in argsMassaging.bodyTemplate as the `extra` binding.\n * Stored with the ref so it travels as a single unit with the invocation descriptor.\n */\n extra?: Record<string, unknown>;\n}\n\n// ============================================================================\n// ExecutionResult\n// ============================================================================\n\n/**\n * Standardized result envelope returned by any execution.\n *\n * Replaces the implicit \"file-exists = success, absent = failure\" protocol\n * with an explicit status field. The data ref points to the output blob.\n */\nexport interface ExecutionResult {\n /** Outcome of the execution. */\n status: 'success' | 'fail' | 'error';\n\n /**\n * KindValueRef wire form pointing to the output blob.\n * Present only when status === 'success'.\n */\n data?: string;\n\n /**\n * Human-readable error or failure message.\n * Present when status === 'fail' or 'error'.\n */\n error?: string;\n}\n\n// ============================================================================\n// ExecutionRef factory helpers\n// ============================================================================\n\n/**\n * Create an ExecutionRef from a script path string (e.g. from a --task-executor CLI arg).\n * File extension determines howToRun:\n * .js / .mjs → 'local-node'\n * .py → 'local-python'\n * other → 'local-process'\n *\n * @param scriptPath Absolute or relative path to the script / binary.\n * @param extra Optional opaque executor config stored on the ref.\n */\nexport function executionRefFromScriptPath(\n scriptPath: string,\n extra?: Record<string, unknown>,\n): ExecutionRef {\n let howToRun: ExecutionRef['howToRun'];\n if (/\\.m?js$/i.test(scriptPath)) howToRun = 'local-node';\n else if (/\\.py$/i.test(scriptPath)) howToRun = 'local-python';\n else howToRun = 'local-process';\n return {\n meta: 'task-executor',\n howToRun,\n whatToRun: `::fs-path::${scriptPath}`,\n ...(extra ? { extra } : {}),\n };\n}\n\n// ============================================================================\n// Serialization helpers\n// ============================================================================\n\n/**\n * Serialize an ExecutionRef to a JSON string for storage.\n * Plain JSON.stringify — no special encoding.\n */\nexport function serializeExecutionRef(ref: ExecutionRef): string {\n return JSON.stringify(ref);\n}\n\n/**\n * Parse a JSON string back into an ExecutionRef.\n * Throws if the string is not valid JSON or is missing required fields.\n */\nexport function parseExecutionRef(s: string): ExecutionRef {\n let parsed: unknown;\n try {\n parsed = JSON.parse(s);\n } catch {\n throw new Error(`parseExecutionRef: invalid JSON — ${s}`);\n }\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n typeof (parsed as Record<string, unknown>).howToRun !== 'string' ||\n typeof (parsed as Record<string, unknown>).whatToRun !== 'string'\n ) {\n throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun — ${s}`);\n }\n return parsed as ExecutionRef;\n}\n"]}