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.
- package/board-live-cards-cli.js +2 -2
- package/board-livecards-server-runtime.js +486 -547
- package/browser/asset-integrity.json +10 -0
- package/browser/board-livegraph-engine.js +2 -1676
- package/browser/board-livegraph-engine.js.map +1 -1
- package/browser/live-cards.js +347 -26
- package/browser/live-cards.schema.json +418 -132
- package/card-store.js +37 -0
- package/dist/batch/index.cjs +1 -108
- package/dist/batch/index.cjs.map +1 -1
- package/dist/batch/index.js +1 -106
- package/dist/batch/index.js.map +1 -1
- package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
- package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
- package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
- package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
- package/dist/board-livegraph-runtime/index.cjs +2 -1671
- package/dist/board-livegraph-runtime/index.cjs.map +1 -1
- package/dist/board-livegraph-runtime/index.d.cts +1 -2
- package/dist/board-livegraph-runtime/index.d.ts +1 -2
- package/dist/board-livegraph-runtime/index.js +2 -1662
- package/dist/board-livegraph-runtime/index.js.map +1 -1
- package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
- package/dist/card-compute/index.cjs +9 -7159
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +22 -0
- package/dist/card-compute/index.d.ts +22 -0
- package/dist/card-compute/index.js +9 -7145
- package/dist/card-compute/index.js.map +1 -1
- package/dist/card-compute/jsonata-sync.cjs +7587 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.js +2 -0
- package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
- package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
- package/dist/cli/node/artifacts-store-cli.cjs +11 -0
- package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
- package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
- package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
- package/dist/cli/node/artifacts-store-cli.js +11 -0
- package/dist/cli/node/artifacts-store-cli.js.map +1 -0
- package/dist/cli/node/board-live-cards-cli.cjs +15 -0
- package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
- package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
- package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
- package/dist/cli/node/board-live-cards-cli.js +15 -0
- package/dist/cli/node/board-live-cards-cli.js.map +1 -0
- package/dist/cli/node/card-store-cli.cjs +8 -0
- package/dist/cli/node/card-store-cli.cjs.map +1 -0
- package/dist/cli/node/card-store-cli.d.cts +15 -0
- package/dist/cli/node/card-store-cli.d.ts +15 -0
- package/dist/cli/node/card-store-cli.js +8 -0
- package/dist/cli/node/card-store-cli.js.map +1 -0
- package/dist/cli/node/fs-board-adapter.cjs +14 -0
- package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
- package/dist/cli/node/fs-board-adapter.d.cts +204 -0
- package/dist/cli/node/fs-board-adapter.d.ts +204 -0
- package/dist/cli/node/fs-board-adapter.js +14 -0
- package/dist/cli/node/fs-board-adapter.js.map +1 -0
- package/dist/cli/node/jsonata-sync.cjs +7587 -0
- package/dist/cli/node/source-cli-task-executor.cjs +11 -0
- package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
- package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
- package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
- package/dist/cli/node/source-cli-task-executor.js +11 -0
- package/dist/cli/node/source-cli-task-executor.js.map +1 -0
- package/dist/config/index.cjs +1 -79
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.js +1 -76
- package/dist/config/index.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +2 -2129
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +81 -5
- package/dist/continuous-event-graph/index.d.ts +81 -5
- package/dist/continuous-event-graph/index.js +2 -2088
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
- package/dist/event-graph/index.cjs +22 -8292
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.js +22 -8237
- package/dist/event-graph/index.js.map +1 -1
- package/dist/execution-refs.cjs +2 -0
- package/dist/execution-refs.cjs.map +1 -0
- package/dist/execution-refs.d.cts +222 -0
- package/dist/execution-refs.d.ts +222 -0
- package/dist/execution-refs.js +2 -0
- package/dist/execution-refs.js.map +1 -0
- package/dist/index.cjs +29 -13221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +29 -13112
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +5 -617
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.js +5 -610
- package/dist/inference/index.js.map +1 -1
- package/dist/jsonata-sync.cjs +7587 -0
- package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
- package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
- package/dist/pycli/quickjs-board-runtime.global.js +9 -0
- package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
- package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
- package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
- package/dist/step-machine/index.cjs +11 -7129
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.js +11 -7113
- package/dist/step-machine/index.js.map +1 -1
- package/dist/storage-refs.cjs +10 -0
- package/dist/storage-refs.cjs.map +1 -0
- package/dist/storage-refs.d.cts +92 -0
- package/dist/storage-refs.d.ts +92 -0
- package/dist/storage-refs.js +10 -0
- package/dist/storage-refs.js.map +1 -0
- package/dist/stores/file.cjs +1 -114
- package/dist/stores/file.cjs.map +1 -1
- package/dist/stores/file.js +1 -112
- package/dist/stores/file.js.map +1 -1
- package/dist/stores/index.cjs +1 -231
- package/dist/stores/index.cjs.map +1 -1
- package/dist/stores/index.js +1 -227
- package/dist/stores/index.js.map +1 -1
- package/dist/stores/localStorage.cjs +1 -76
- package/dist/stores/localStorage.cjs.map +1 -1
- package/dist/stores/localStorage.js +1 -74
- package/dist/stores/localStorage.js.map +1 -1
- package/dist/stores/memory.cjs +1 -47
- package/dist/stores/memory.cjs.map +1 -1
- package/dist/stores/memory.js +1 -45
- package/dist/stores/memory.js.map +1 -1
- package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
- package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/examples/example-board/agent-instructions.md +11 -5
- package/examples/example-board/demo-chat-handler.js +14 -4
- package/examples/example-board/demo-server-config.json +1 -0
- package/examples/example-board/demo-server.js +14 -7
- package/examples/example-board/demo-shell-browser.html +5 -4
- package/examples/example-board/demo-shell-with-server.html +6 -5
- package/examples/example-board/demo-task-executor.js +81 -35
- package/examples/index.html +0 -14
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/package.json +39 -3
- package/schema/live-cards.schema.json +418 -132
- package/dist/cli/board-live-cards-cli.cjs +0 -10650
- package/dist/cli/board-live-cards-cli.cjs.map +0 -1
- package/dist/cli/board-live-cards-cli.d.cts +0 -179
- package/dist/cli/board-live-cards-cli.d.ts +0 -179
- package/dist/cli/board-live-cards-cli.js +0 -10598
- package/dist/cli/board-live-cards-cli.js.map +0 -1
- package/dist/journal-9HEgs7dU.d.ts +0 -28
- package/dist/journal-B-JCfQnh.d.cts +0 -28
- package/dist/schedule-Cszq9LYY.d.ts +0 -21
- package/dist/schedule-qWNL0RQh.d.cts +0 -21
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
- package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
- 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"]}
|