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,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';var l=require('fs'),f=require('path'),child_process=require('child_process');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var l__namespace=/*#__PURE__*/_interopNamespace(l);var f__namespace=/*#__PURE__*/_interopNamespace(f);function w(e){if(!e.startsWith("::"))throw new Error(`Invalid ref format (expected ::kind::value): ${e}`);let r=e.slice(2),n=r.indexOf("::");if(n===-1)throw new Error(`Invalid ref format (expected ::kind::value): ${e}`);return {kind:r.slice(0,n),value:r.slice(n+2)}}function I(e){return `::${e.kind}::${e.value}`}function P(){return {read(e){if(!l__namespace.existsSync(e))return null;try{return l__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,r){l__namespace.mkdirSync(f__namespace.dirname(e),{recursive:true}),l__namespace.writeFileSync(e,r,"utf-8");}}}function b(e){if(e.kind==="fs-path")return P();throw new Error(`Unsupported storage kind: "${e.kind}". Supported kinds: fs-path`)}function y(e){try{return w(e).value}catch{return e}}function _(e){let r=e.extra?.notifyChannel;return typeof r=="string"&&r.length>0?r:void 0}function F(e){if(!e.endsWith(".ts"))return {cmd:process.execPath,args:[e]};let r=f__namespace.dirname(e),n=[];for(let o=1;o<=5;o++){let s=f__namespace.join(r,...Array(o).fill(".."),"node_modules");n.push(f__namespace.join(s,"tsx","dist","cli.mjs")),n.push(f__namespace.join(s,".bin","tsx"));}let t=n.find(o=>l__namespace.existsSync(o));return t?{cmd:process.execPath,args:[t,e]}:{cmd:"npx",args:["tsx",e]}}function O(e,r){let{token:n,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let o=y(t.whatToRun),{cmd:s,args:p}=F(o),u=_(t),d=[...p,"source-data-fetched","--ref",I(r),"--token",n,...u?["--notify-channel",u]:[]],i=child_process.spawnSync(s,d,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportComplete: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let o=y(t.whatToRun),s=JSON.stringify({status:"complete",ref:I(r),token:n});D(o,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${t.howToRun}"`)}function q(e,r){let{token:n,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let o=y(t.whatToRun),{cmd:s,args:p}=F(o),u=_(t),d=[...p,"source-data-fetch-failure","--token",n,"--reason",r,...u?["--notify-channel",u]:[]],i=child_process.spawnSync(s,d,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportFailed: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let o=y(t.whatToRun),s=JSON.stringify({status:"failed",reason:r,token:n});D(o,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${t.howToRun}"`)}function D(e,r){let n=`
|
|
3
|
+
const {request} = require(new URL('${e}').protocol === 'https:' ? 'https' : 'http');
|
|
4
|
+
const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)})};
|
|
5
|
+
const u = new URL('${e}');
|
|
6
|
+
const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
|
|
7
|
+
req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
|
|
8
|
+
req.write(${JSON.stringify(r)});
|
|
9
|
+
req.end();
|
|
10
|
+
`,t=child_process.spawnSync(process.execPath,["-e",n],{encoding:"utf-8",windowsHide:true});if(t.status!==0)throw new Error(`http-post failed: ${t.stderr?.trim()}`)}function H(e){let r=[],n="",t=false,o=false;for(let s of e){if(s==="'"&&!o){t=!t;continue}if(s==='"'&&!t){o=!o;continue}s===" "&&!t&&!o?n&&(r.push(n),n=""):n+=s;}return n&&r.push(n),r}function W(e){if(process.platform!=="win32"||f__namespace.isAbsolute(e)||e.includes("/")||e.includes("\\"))return e;let r=process.env.PATH??"";for(let n of r.split(f__namespace.delimiter))for(let t of [".cmd",".bat"]){let o=f__namespace.join(n,e+t);if(l__namespace.existsSync(o))return o}return e}function z(e){let r=e.indexOf("--in-ref"),n=e.indexOf("--out-ref"),t=e.indexOf("--err-ref"),o=r!==-1?e[r+1]:void 0,s=n!==-1?e[n+1]:void 0,p=t!==-1?e[t+1]:void 0;(!o||!s)&&(console.error("[source-cli-task-executor] Usage: run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]"),process.exit(1));let u,d,i;try{u=w(o),d=w(s),p&&(i=w(p));}catch(c){console.error(`[source-cli-task-executor] invalid ref: ${c.message}`),process.exit(1);}let K=b(u),V=b(d),T=i?b(i):void 0;function h(c,C){if(T&&i)try{T.write(i.value,c);}catch{}if(console.error(`[source-cli-task-executor] ${c}`),C)try{q(C,c);}catch{}process.exit(1);}let $=K.read(u.value);$===null&&h(`Input not found: ${o}`);let x;try{x=JSON.parse($);}catch(c){h(`Cannot parse input envelope: ${c.message}`);}let g=x.source_def!=null?x.callback:void 0,a=x.source_def??x;(!a.cli||typeof a.cli!="string")&&h("source_def missing required field: cli (source-cli-task-executor only handles source.cli)",g);let B=typeof a.timeout=="number"?a.timeout:12e4,k=typeof a.boardDir=="string"&&a.boardDir?a.boardDir:void 0,j=k??process.cwd(),L=typeof a.bindTo=="string"?a.bindTo:"unknown",R=H(a.cli);R.length===0&&h("source_def.cli is empty",g);let N=W(R[0]),J=R.slice(1);console.log(`[source-cli-task-executor] ${L}: ${a.cli}`);let E;try{E=child_process.execFileSync(N,J,{shell:!1,encoding:"utf-8",timeout:B,cwd:j,env:{...process.env,...k?{BOARD_DIR:k}:{}},maxBuffer:50*1024*1024});}catch(c){h(`cli execution failed: ${c.message}`,g);}try{V.write(d.value,E.trim());}catch(c){h(`Cannot write output: ${c.message}`,g);}if(g)try{O(g,d);}catch(c){console.error(`[source-cli-task-executor] reportComplete failed: ${c.message}`),process.exit(1);}}var Q={version:"1.0",executor:"source-cli-task-executor",subcommands:["run-source-fetch","describe-capabilities"],sourceKinds:{cli:{description:"Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.",inputSchema:{cli:{type:"string",required:true,description:"Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell)."},timeout:{type:"number",required:false,description:"Execution timeout in milliseconds (default: 120000)."},cwd:{type:"string",required:false,description:"Working directory for the command (default: process.cwd())."},boardDir:{type:"string",required:false,description:"Injected as BOARD_DIR environment variable."}},outputShape:"string \u2014 trimmed stdout of the command."}}},S=process.argv[2];S==="run-source-fetch"?z(process.argv.slice(3)):S==="describe-capabilities"?console.log(JSON.stringify(Q,null,2)):(console.warn(`[source-cli-task-executor] Unknown subcommand: ${S??"(none)"}`),process.exit(1));//# sourceMappingURL=source-cli-task-executor.cjs.map
|
|
11
|
+
//# sourceMappingURL=source-cli-task-executor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/node/public-storage-adapter.ts","../../../src/cli/node/source-cli-task-executor.ts"],"names":["parseRef","s","inner","idx","serializeRef","ref","createFsPathBlobStorage","key","l","content","f","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","candidate","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script","splitCommand","parts","current","inSingle","inDouble","ch","resolveExecutable","rawCmd","m","pathEnv","ext","A","runSourceFetch","argv","inIdx","outIdx","errIdx","inRefStr","outRefStr","errRefStr","inRef","errRef","e","inStorage","outStorage","errStorage","fail","msg","rawIn","envelope","sourceDef","timeout","boardDir","cwd","bindTo","cliArgs","stdout","execFileSync","err","CAPABILITIES","sub"],"mappings":";mfA8CO,SAASA,CAAAA,CAASC,CAAAA,CAAyB,CAChD,GAAI,CAACA,CAAAA,CAAE,UAAA,CAAW,IAAI,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgDA,CAAC,CAAA,CAAE,CAAA,CAC5F,IAAMC,CAAAA,CAAQD,CAAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CACjBE,CAAAA,CAAMD,CAAAA,CAAM,OAAA,CAAQ,IAAI,E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a,+FAAA,CACb,YAAa,CACX,GAAA,CAAK,CACH,IAAA,CAAM,QAAA,CACN,QAAA,CAAU,IAAA,CACV,WAAA,CAAa,8FACf,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,SACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,sDACf,EACA,GAAA,CAAK,CACH,IAAA,CAAM,QAAA,CACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,6DACf,EACA,QAAA,CAAU,CACR,IAAA,CAAM,QAAA,CACN,SAAU,KAAA,CACV,WAAA,CAAa,6CACf,CACF,EACA,WAAA,CAAa,8CACf,CACF,CACF,CAAA,CAMMC,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACtBA,CAAAA,GAAQ,kBAAA,CACV5B,CAAAA,CAAe,QAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,EAC3B4B,CAAAA,GAAQ,uBAAA,CACjB,OAAA,CAAQ,GAAA,CAAI,KAAK,SAAA,CAAUD,CAAAA,CAAc,IAAA,CAAM,CAAC,CAAC,CAAA,EAEjD,OAAA,CAAQ,IAAA,CAAK,CAAA,+CAAA,EAAkDC,GAAO,QAAQ,CAAA,CAAE,CAAA,CAChF,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA","file":"source-cli-task-executor.cjs","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: ::kind::value\n * - parseRef() parse a ::kind::value string\n * - serializeRef() produce a ::kind::value string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (::kind::value) into a KindValueRef. */\nexport function parseRef(s: string): KindValueRef {\n if (!s.startsWith('::')) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n const inner = s.slice(2);\n const idx = inner.indexOf('::');\n if (idx === -1) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n return { kind: inner.slice(0, idx), value: inner.slice(idx + 2) };\n}\n\n/** Serialize a KindValueRef to the wire format: ::kind::value */\nexport function serializeRef(ref: KindValueRef): string {\n return `::${ref.kind}::${ref.value}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun ::kind::value wire string.\n * Falls back to the raw string if it isn’t in ::kind::value form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n","#!/usr/bin/env node\n/**\n * source-cli-task-executor.ts — Built-in task executor for `source.cli` sources.\n *\n * Implements the standard task-executor protocol so the board CLI always dispatches\n * source fetches through the same per-source path, whether or not a custom\n * .task-executor is configured.\n *\n * Subcommands:\n * run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]\n * describe-capabilities\n *\n * Supported source kind:\n * cli — executes source_def.cli synchronously and writes stdout to --out-ref.\n *\n * In-ref envelope (written by board CLI dispatcher):\n * { source_def: { cli, cwd?, boardDir?, timeout?, ... }, callback: { token, via } }\n *\n * The executor writes the trimmed stdout to --out-ref, then calls reportComplete()\n * which invokes `board-live-cards source-data-fetched` back-channel via the board CLI.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\nimport type { KindValueRef, TaskCallback } from './public-storage-adapter.js';\n\n// ============================================================================\n// Command splitting — minimal implementation for source.cli strings.\n// Handles single- and double-quoted segments. No glob/brace expansion.\n// ============================================================================\n\nfunction splitCommand(cmd: string): string[] {\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n let inDouble = false;\n for (const ch of cmd) {\n if (ch === \"'\" && !inDouble) { inSingle = !inSingle; continue; }\n if (ch === '\"' && !inSingle) { inDouble = !inDouble; continue; }\n if (ch === ' ' && !inSingle && !inDouble) {\n if (current) { parts.push(current); current = ''; }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n}\n\n/**\n * On Windows, execFileSync cannot find npm .cmd shims by bare name.\n * Check PATH for <name>.cmd / <name>.bat and return the resolved path.\n * Falls back to the original name (works for node.exe, python.exe, etc.).\n */\nfunction resolveExecutable(rawCmd: string): string {\n if (process.platform !== 'win32') return rawCmd;\n if (path.isAbsolute(rawCmd) || rawCmd.includes('/') || rawCmd.includes('\\\\')) return rawCmd;\n const pathEnv = process.env.PATH ?? '';\n for (const dir of pathEnv.split(path.delimiter)) {\n for (const ext of ['.cmd', '.bat']) {\n const candidate = path.join(dir, rawCmd + ext);\n if (fs.existsSync(candidate)) return candidate;\n }\n }\n return rawCmd;\n}\n\n// ============================================================================\n// run-source-fetch\n// ============================================================================\n\nfunction runSourceFetch(argv: string[]): void {\n const inIdx = argv.indexOf('--in-ref');\n const outIdx = argv.indexOf('--out-ref');\n const errIdx = argv.indexOf('--err-ref');\n const inRefStr = inIdx !== -1 ? argv[inIdx + 1] : undefined;\n const outRefStr = outIdx !== -1 ? argv[outIdx + 1] : undefined;\n const errRefStr = errIdx !== -1 ? argv[errIdx + 1] : undefined;\n\n if (!inRefStr || !outRefStr) {\n console.error('[source-cli-task-executor] Usage: run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]');\n process.exit(1);\n }\n\n let inRef: KindValueRef;\n let outRef: KindValueRef;\n let errRef: KindValueRef | undefined;\n try {\n inRef = parseRef(inRefStr);\n outRef = parseRef(outRefStr);\n if (errRefStr) errRef = parseRef(errRefStr);\n } catch (e) {\n console.error(`[source-cli-task-executor] invalid ref: ${(e as Error).message}`);\n process.exit(1);\n }\n\n const inStorage = blobStorageForRef(inRef!);\n const outStorage = blobStorageForRef(outRef!);\n const errStorage = errRef ? blobStorageForRef(errRef) : undefined;\n\n function fail(msg: string, callback?: TaskCallback): never {\n if (errStorage && errRef) { try { errStorage.write(errRef.value, msg); } catch { /* best-effort */ } }\n console.error(`[source-cli-task-executor] ${msg}`);\n if (callback) { try { reportFailed(callback, msg); } catch { /* best-effort */ } }\n process.exit(1);\n }\n\n const rawIn = inStorage.read(inRef!.value);\n if (rawIn === null) fail(`Input not found: ${inRefStr}`);\n\n let envelope: { source_def?: Record<string, unknown>; callback?: TaskCallback };\n try {\n envelope = JSON.parse(rawIn!) as typeof envelope;\n } catch (e) {\n fail(`Cannot parse input envelope: ${(e as Error).message}`);\n }\n\n // Support both new { source_def, callback } envelope and legacy raw source_def.\n const callback = envelope!.source_def != null ? envelope!.callback : undefined;\n const sourceDef = (envelope!.source_def ?? envelope!) as Record<string, unknown>;\n\n if (!sourceDef.cli || typeof sourceDef.cli !== 'string') {\n fail('source_def missing required field: cli (source-cli-task-executor only handles source.cli)', callback);\n }\n\n const timeout = typeof sourceDef.timeout === 'number' ? sourceDef.timeout : 120_000;\n const boardDir = typeof sourceDef.boardDir === 'string' && sourceDef.boardDir ? sourceDef.boardDir : undefined;\n const cwd = boardDir ?? process.cwd();\n const bindTo = typeof sourceDef.bindTo === 'string' ? sourceDef.bindTo : 'unknown';\n\n const parts = splitCommand(sourceDef.cli);\n if (parts.length === 0) fail('source_def.cli is empty', callback);\n\n const cmd = resolveExecutable(parts[0]);\n const cliArgs = parts.slice(1);\n\n console.log(`[source-cli-task-executor] ${bindTo}: ${sourceDef.cli}`);\n\n let stdout: string;\n try {\n stdout = execFileSync(cmd, cliArgs, {\n shell: false,\n encoding: 'utf-8',\n timeout,\n cwd,\n env: { ...process.env, ...(boardDir ? { BOARD_DIR: boardDir } : {}) },\n maxBuffer: 50 * 1024 * 1024,\n }) as string;\n } catch (err) {\n fail(`cli execution failed: ${(err as Error).message}`, callback);\n }\n\n try {\n outStorage.write(outRef!.value, stdout!.trim());\n } catch (err) {\n fail(`Cannot write output: ${(err as Error).message}`, callback);\n }\n\n if (callback) {\n try {\n reportComplete(callback, outRef!);\n } catch (err) {\n console.error(`[source-cli-task-executor] reportComplete failed: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n}\n\n// ============================================================================\n// describe-capabilities\n// ============================================================================\n\nconst CAPABILITIES = {\n version: '1.0',\n executor: 'source-cli-task-executor',\n subcommands: ['run-source-fetch', 'describe-capabilities'],\n sourceKinds: {\n cli: {\n description: 'Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.',\n inputSchema: {\n cli: {\n type: 'string',\n required: true,\n description: 'Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell).',\n },\n timeout: {\n type: 'number',\n required: false,\n description: 'Execution timeout in milliseconds (default: 120000).',\n },\n cwd: {\n type: 'string',\n required: false,\n description: 'Working directory for the command (default: process.cwd()).',\n },\n boardDir: {\n type: 'string',\n required: false,\n description: 'Injected as BOARD_DIR environment variable.',\n },\n },\n outputShape: 'string — trimmed stdout of the command.',\n },\n },\n};\n\n// ============================================================================\n// Entry point\n// ============================================================================\n\nconst sub = process.argv[2];\nif (sub === 'run-source-fetch') {\n runSourceFetch(process.argv.slice(3));\n} else if (sub === 'describe-capabilities') {\n console.log(JSON.stringify(CAPABILITIES, null, 2));\n} else {\n console.warn(`[source-cli-task-executor] Unknown subcommand: ${sub ?? '(none)'}`);\n process.exit(1);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import*as l from'fs';import*as f from'path';import {execFileSync,spawnSync}from'child_process';function w(e){if(!e.startsWith("::"))throw new Error(`Invalid ref format (expected ::kind::value): ${e}`);let r=e.slice(2),n=r.indexOf("::");if(n===-1)throw new Error(`Invalid ref format (expected ::kind::value): ${e}`);return {kind:r.slice(0,n),value:r.slice(n+2)}}function I(e){return `::${e.kind}::${e.value}`}function P(){return {read(e){if(!l.existsSync(e))return null;try{return l.readFileSync(e,"utf-8")}catch{return null}},write(e,r){l.mkdirSync(f.dirname(e),{recursive:true}),l.writeFileSync(e,r,"utf-8");}}}function b(e){if(e.kind==="fs-path")return P();throw new Error(`Unsupported storage kind: "${e.kind}". Supported kinds: fs-path`)}function y(e){try{return w(e).value}catch{return e}}function _(e){let r=e.extra?.notifyChannel;return typeof r=="string"&&r.length>0?r:void 0}function F(e){if(!e.endsWith(".ts"))return {cmd:process.execPath,args:[e]};let r=f.dirname(e),n=[];for(let o=1;o<=5;o++){let s=f.join(r,...Array(o).fill(".."),"node_modules");n.push(f.join(s,"tsx","dist","cli.mjs")),n.push(f.join(s,".bin","tsx"));}let t=n.find(o=>l.existsSync(o));return t?{cmd:process.execPath,args:[t,e]}:{cmd:"npx",args:["tsx",e]}}function O(e,r){let{token:n,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let o=y(t.whatToRun),{cmd:s,args:p}=F(o),u=_(t),d=[...p,"source-data-fetched","--ref",I(r),"--token",n,...u?["--notify-channel",u]:[]],i=spawnSync(s,d,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportComplete: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let o=y(t.whatToRun),s=JSON.stringify({status:"complete",ref:I(r),token:n});D(o,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${t.howToRun}"`)}function q(e,r){let{token:n,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let o=y(t.whatToRun),{cmd:s,args:p}=F(o),u=_(t),d=[...p,"source-data-fetch-failure","--token",n,"--reason",r,...u?["--notify-channel",u]:[]],i=spawnSync(s,d,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportFailed: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let o=y(t.whatToRun),s=JSON.stringify({status:"failed",reason:r,token:n});D(o,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${t.howToRun}"`)}function D(e,r){let n=`
|
|
3
|
+
const {request} = require(new URL('${e}').protocol === 'https:' ? 'https' : 'http');
|
|
4
|
+
const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)})};
|
|
5
|
+
const u = new URL('${e}');
|
|
6
|
+
const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
|
|
7
|
+
req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
|
|
8
|
+
req.write(${JSON.stringify(r)});
|
|
9
|
+
req.end();
|
|
10
|
+
`,t=spawnSync(process.execPath,["-e",n],{encoding:"utf-8",windowsHide:true});if(t.status!==0)throw new Error(`http-post failed: ${t.stderr?.trim()}`)}function H(e){let r=[],n="",t=false,o=false;for(let s of e){if(s==="'"&&!o){t=!t;continue}if(s==='"'&&!t){o=!o;continue}s===" "&&!t&&!o?n&&(r.push(n),n=""):n+=s;}return n&&r.push(n),r}function W(e){if(process.platform!=="win32"||f.isAbsolute(e)||e.includes("/")||e.includes("\\"))return e;let r=process.env.PATH??"";for(let n of r.split(f.delimiter))for(let t of [".cmd",".bat"]){let o=f.join(n,e+t);if(l.existsSync(o))return o}return e}function z(e){let r=e.indexOf("--in-ref"),n=e.indexOf("--out-ref"),t=e.indexOf("--err-ref"),o=r!==-1?e[r+1]:void 0,s=n!==-1?e[n+1]:void 0,p=t!==-1?e[t+1]:void 0;(!o||!s)&&(console.error("[source-cli-task-executor] Usage: run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]"),process.exit(1));let u,d,i;try{u=w(o),d=w(s),p&&(i=w(p));}catch(c){console.error(`[source-cli-task-executor] invalid ref: ${c.message}`),process.exit(1);}let K=b(u),V=b(d),T=i?b(i):void 0;function h(c,C){if(T&&i)try{T.write(i.value,c);}catch{}if(console.error(`[source-cli-task-executor] ${c}`),C)try{q(C,c);}catch{}process.exit(1);}let $=K.read(u.value);$===null&&h(`Input not found: ${o}`);let x;try{x=JSON.parse($);}catch(c){h(`Cannot parse input envelope: ${c.message}`);}let g=x.source_def!=null?x.callback:void 0,a=x.source_def??x;(!a.cli||typeof a.cli!="string")&&h("source_def missing required field: cli (source-cli-task-executor only handles source.cli)",g);let B=typeof a.timeout=="number"?a.timeout:12e4,k=typeof a.boardDir=="string"&&a.boardDir?a.boardDir:void 0,j=k??process.cwd(),L=typeof a.bindTo=="string"?a.bindTo:"unknown",R=H(a.cli);R.length===0&&h("source_def.cli is empty",g);let N=W(R[0]),J=R.slice(1);console.log(`[source-cli-task-executor] ${L}: ${a.cli}`);let E;try{E=execFileSync(N,J,{shell:!1,encoding:"utf-8",timeout:B,cwd:j,env:{...process.env,...k?{BOARD_DIR:k}:{}},maxBuffer:50*1024*1024});}catch(c){h(`cli execution failed: ${c.message}`,g);}try{V.write(d.value,E.trim());}catch(c){h(`Cannot write output: ${c.message}`,g);}if(g)try{O(g,d);}catch(c){console.error(`[source-cli-task-executor] reportComplete failed: ${c.message}`),process.exit(1);}}var Q={version:"1.0",executor:"source-cli-task-executor",subcommands:["run-source-fetch","describe-capabilities"],sourceKinds:{cli:{description:"Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.",inputSchema:{cli:{type:"string",required:true,description:"Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell)."},timeout:{type:"number",required:false,description:"Execution timeout in milliseconds (default: 120000)."},cwd:{type:"string",required:false,description:"Working directory for the command (default: process.cwd())."},boardDir:{type:"string",required:false,description:"Injected as BOARD_DIR environment variable."}},outputShape:"string \u2014 trimmed stdout of the command."}}},S=process.argv[2];S==="run-source-fetch"?z(process.argv.slice(3)):S==="describe-capabilities"?console.log(JSON.stringify(Q,null,2)):(console.warn(`[source-cli-task-executor] Unknown subcommand: ${S??"(none)"}`),process.exit(1));//# sourceMappingURL=source-cli-task-executor.js.map
|
|
11
|
+
//# sourceMappingURL=source-cli-task-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/node/public-storage-adapter.ts","../../../src/cli/node/source-cli-task-executor.ts"],"names":["parseRef","s","inner","idx","serializeRef","ref","createFsPathBlobStorage","key","content","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","candidate","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script","splitCommand","parts","current","inSingle","inDouble","ch","resolveExecutable","rawCmd","m","pathEnv","ext","A","runSourceFetch","argv","inIdx","outIdx","errIdx","inRefStr","outRefStr","errRefStr","inRef","errRef","e","inStorage","outStorage","errStorage","fail","msg","rawIn","envelope","sourceDef","timeout","boardDir","cwd","bindTo","cliArgs","stdout","execFileSync","err","CAPABILITIES","sub"],"mappings":";+FA8CO,SAASA,CAAAA,CAASC,CAAAA,CAAyB,CAChD,GAAI,CAACA,CAAAA,CAAE,UAAA,CAAW,IAAI,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,6CAAA,EAAgDA,CAAC,CAAA,CAAE,CAAA,CAC5F,IAAMC,CAAAA,CAAQD,CAAAA,CAAE,KAAA,CAAM,CAAC,CA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Aa,CACX,GAAA,CAAK,CACH,WAAA,CAAa,+FAAA,CACb,YAAa,CACX,GAAA,CAAK,CACH,IAAA,CAAM,QAAA,CACN,QAAA,CAAU,IAAA,CACV,WAAA,CAAa,8FACf,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,SACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,sDACf,EACA,GAAA,CAAK,CACH,IAAA,CAAM,QAAA,CACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,6DACf,EACA,QAAA,CAAU,CACR,IAAA,CAAM,QAAA,CACN,SAAU,KAAA,CACV,WAAA,CAAa,6CACf,CACF,EACA,WAAA,CAAa,8CACf,CACF,CACF,CAAA,CAMMC,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACtBA,CAAAA,GAAQ,kBAAA,CACV5B,CAAAA,CAAe,QAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,EAC3B4B,CAAAA,GAAQ,uBAAA,CACjB,OAAA,CAAQ,GAAA,CAAI,KAAK,SAAA,CAAUD,CAAAA,CAAc,IAAA,CAAM,CAAC,CAAC,CAAA,EAEjD,OAAA,CAAQ,IAAA,CAAK,CAAA,+CAAA,EAAkDC,GAAO,QAAQ,CAAA,CAAE,CAAA,CAChF,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA","file":"source-cli-task-executor.js","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: ::kind::value\n * - parseRef() parse a ::kind::value string\n * - serializeRef() produce a ::kind::value string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (::kind::value) into a KindValueRef. */\nexport function parseRef(s: string): KindValueRef {\n if (!s.startsWith('::')) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n const inner = s.slice(2);\n const idx = inner.indexOf('::');\n if (idx === -1) throw new Error(`Invalid ref format (expected ::kind::value): ${s}`);\n return { kind: inner.slice(0, idx), value: inner.slice(idx + 2) };\n}\n\n/** Serialize a KindValueRef to the wire format: ::kind::value */\nexport function serializeRef(ref: KindValueRef): string {\n return `::${ref.kind}::${ref.value}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in ::kind::value wire form (e.g. ::fs-path::/path/to/cli.js). */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun ::kind::value wire string.\n * Falls back to the raw string if it isn’t in ::kind::value form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n","#!/usr/bin/env node\n/**\n * source-cli-task-executor.ts — Built-in task executor for `source.cli` sources.\n *\n * Implements the standard task-executor protocol so the board CLI always dispatches\n * source fetches through the same per-source path, whether or not a custom\n * .task-executor is configured.\n *\n * Subcommands:\n * run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]\n * describe-capabilities\n *\n * Supported source kind:\n * cli — executes source_def.cli synchronously and writes stdout to --out-ref.\n *\n * In-ref envelope (written by board CLI dispatcher):\n * { source_def: { cli, cwd?, boardDir?, timeout?, ... }, callback: { token, via } }\n *\n * The executor writes the trimmed stdout to --out-ref, then calls reportComplete()\n * which invokes `board-live-cards source-data-fetched` back-channel via the board CLI.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\nimport type { KindValueRef, TaskCallback } from './public-storage-adapter.js';\n\n// ============================================================================\n// Command splitting — minimal implementation for source.cli strings.\n// Handles single- and double-quoted segments. No glob/brace expansion.\n// ============================================================================\n\nfunction splitCommand(cmd: string): string[] {\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n let inDouble = false;\n for (const ch of cmd) {\n if (ch === \"'\" && !inDouble) { inSingle = !inSingle; continue; }\n if (ch === '\"' && !inSingle) { inDouble = !inDouble; continue; }\n if (ch === ' ' && !inSingle && !inDouble) {\n if (current) { parts.push(current); current = ''; }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n}\n\n/**\n * On Windows, execFileSync cannot find npm .cmd shims by bare name.\n * Check PATH for <name>.cmd / <name>.bat and return the resolved path.\n * Falls back to the original name (works for node.exe, python.exe, etc.).\n */\nfunction resolveExecutable(rawCmd: string): string {\n if (process.platform !== 'win32') return rawCmd;\n if (path.isAbsolute(rawCmd) || rawCmd.includes('/') || rawCmd.includes('\\\\')) return rawCmd;\n const pathEnv = process.env.PATH ?? '';\n for (const dir of pathEnv.split(path.delimiter)) {\n for (const ext of ['.cmd', '.bat']) {\n const candidate = path.join(dir, rawCmd + ext);\n if (fs.existsSync(candidate)) return candidate;\n }\n }\n return rawCmd;\n}\n\n// ============================================================================\n// run-source-fetch\n// ============================================================================\n\nfunction runSourceFetch(argv: string[]): void {\n const inIdx = argv.indexOf('--in-ref');\n const outIdx = argv.indexOf('--out-ref');\n const errIdx = argv.indexOf('--err-ref');\n const inRefStr = inIdx !== -1 ? argv[inIdx + 1] : undefined;\n const outRefStr = outIdx !== -1 ? argv[outIdx + 1] : undefined;\n const errRefStr = errIdx !== -1 ? argv[errIdx + 1] : undefined;\n\n if (!inRefStr || !outRefStr) {\n console.error('[source-cli-task-executor] Usage: run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> [--err-ref <::kind::value>]');\n process.exit(1);\n }\n\n let inRef: KindValueRef;\n let outRef: KindValueRef;\n let errRef: KindValueRef | undefined;\n try {\n inRef = parseRef(inRefStr);\n outRef = parseRef(outRefStr);\n if (errRefStr) errRef = parseRef(errRefStr);\n } catch (e) {\n console.error(`[source-cli-task-executor] invalid ref: ${(e as Error).message}`);\n process.exit(1);\n }\n\n const inStorage = blobStorageForRef(inRef!);\n const outStorage = blobStorageForRef(outRef!);\n const errStorage = errRef ? blobStorageForRef(errRef) : undefined;\n\n function fail(msg: string, callback?: TaskCallback): never {\n if (errStorage && errRef) { try { errStorage.write(errRef.value, msg); } catch { /* best-effort */ } }\n console.error(`[source-cli-task-executor] ${msg}`);\n if (callback) { try { reportFailed(callback, msg); } catch { /* best-effort */ } }\n process.exit(1);\n }\n\n const rawIn = inStorage.read(inRef!.value);\n if (rawIn === null) fail(`Input not found: ${inRefStr}`);\n\n let envelope: { source_def?: Record<string, unknown>; callback?: TaskCallback };\n try {\n envelope = JSON.parse(rawIn!) as typeof envelope;\n } catch (e) {\n fail(`Cannot parse input envelope: ${(e as Error).message}`);\n }\n\n // Support both new { source_def, callback } envelope and legacy raw source_def.\n const callback = envelope!.source_def != null ? envelope!.callback : undefined;\n const sourceDef = (envelope!.source_def ?? envelope!) as Record<string, unknown>;\n\n if (!sourceDef.cli || typeof sourceDef.cli !== 'string') {\n fail('source_def missing required field: cli (source-cli-task-executor only handles source.cli)', callback);\n }\n\n const timeout = typeof sourceDef.timeout === 'number' ? sourceDef.timeout : 120_000;\n const boardDir = typeof sourceDef.boardDir === 'string' && sourceDef.boardDir ? sourceDef.boardDir : undefined;\n const cwd = boardDir ?? process.cwd();\n const bindTo = typeof sourceDef.bindTo === 'string' ? sourceDef.bindTo : 'unknown';\n\n const parts = splitCommand(sourceDef.cli);\n if (parts.length === 0) fail('source_def.cli is empty', callback);\n\n const cmd = resolveExecutable(parts[0]);\n const cliArgs = parts.slice(1);\n\n console.log(`[source-cli-task-executor] ${bindTo}: ${sourceDef.cli}`);\n\n let stdout: string;\n try {\n stdout = execFileSync(cmd, cliArgs, {\n shell: false,\n encoding: 'utf-8',\n timeout,\n cwd,\n env: { ...process.env, ...(boardDir ? { BOARD_DIR: boardDir } : {}) },\n maxBuffer: 50 * 1024 * 1024,\n }) as string;\n } catch (err) {\n fail(`cli execution failed: ${(err as Error).message}`, callback);\n }\n\n try {\n outStorage.write(outRef!.value, stdout!.trim());\n } catch (err) {\n fail(`Cannot write output: ${(err as Error).message}`, callback);\n }\n\n if (callback) {\n try {\n reportComplete(callback, outRef!);\n } catch (err) {\n console.error(`[source-cli-task-executor] reportComplete failed: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n}\n\n// ============================================================================\n// describe-capabilities\n// ============================================================================\n\nconst CAPABILITIES = {\n version: '1.0',\n executor: 'source-cli-task-executor',\n subcommands: ['run-source-fetch', 'describe-capabilities'],\n sourceKinds: {\n cli: {\n description: 'Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.',\n inputSchema: {\n cli: {\n type: 'string',\n required: true,\n description: 'Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell).',\n },\n timeout: {\n type: 'number',\n required: false,\n description: 'Execution timeout in milliseconds (default: 120000).',\n },\n cwd: {\n type: 'string',\n required: false,\n description: 'Working directory for the command (default: process.cwd()).',\n },\n boardDir: {\n type: 'string',\n required: false,\n description: 'Injected as BOARD_DIR environment variable.',\n },\n },\n outputShape: 'string — trimmed stdout of the command.',\n },\n },\n};\n\n// ============================================================================\n// Entry point\n// ============================================================================\n\nconst sub = process.argv[2];\nif (sub === 'run-source-fetch') {\n runSourceFetch(process.argv.slice(3));\n} else if (sub === 'describe-capabilities') {\n console.log(JSON.stringify(CAPABILITIES, null, 2));\n} else {\n console.warn(`[source-cli-task-executor] Unknown subcommand: ${sub ?? '(none)'}`);\n process.exit(1);\n}\n"]}
|
package/dist/config/index.cjs
CHANGED
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/config/resolve-variables.ts
|
|
4
|
-
function interpolateString(template, vars) {
|
|
5
|
-
return template.replace(/\$\{([^}]+)\}/g, (match, key) => {
|
|
6
|
-
const value = vars[key.trim()];
|
|
7
|
-
return value !== void 0 ? String(value) : match;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
function walkAndInterpolate(value, vars) {
|
|
11
|
-
if (typeof value === "string") {
|
|
12
|
-
return interpolateString(value, vars);
|
|
13
|
-
}
|
|
14
|
-
if (Array.isArray(value)) {
|
|
15
|
-
return value.map((item) => walkAndInterpolate(item, vars));
|
|
16
|
-
}
|
|
17
|
-
if (value !== null && typeof value === "object") {
|
|
18
|
-
const result = {};
|
|
19
|
-
for (const [k, v] of Object.entries(value)) {
|
|
20
|
-
result[k] = walkAndInterpolate(v, vars);
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
function resolveVariables(config, variables) {
|
|
27
|
-
return walkAndInterpolate(config, variables);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/config/resolve-config-templates.ts
|
|
31
|
-
function mergeConfigs(template, taskConfig) {
|
|
32
|
-
const merged = { ...template };
|
|
33
|
-
for (const [key, value] of Object.entries(taskConfig)) {
|
|
34
|
-
if (key === "config-template") continue;
|
|
35
|
-
if (value !== null && typeof value === "object" && !Array.isArray(value) && merged[key] !== null && typeof merged[key] === "object" && !Array.isArray(merged[key])) {
|
|
36
|
-
merged[key] = {
|
|
37
|
-
...merged[key],
|
|
38
|
-
...value
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
merged[key] = value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return merged;
|
|
45
|
-
}
|
|
46
|
-
function resolveConfigTemplates(config) {
|
|
47
|
-
const templates = config["configTemplates"] ?? config["config-templates"] ?? {};
|
|
48
|
-
const tasksKey = "tasks" in config ? "tasks" : "steps" in config ? "steps" : null;
|
|
49
|
-
if (!tasksKey) return config;
|
|
50
|
-
const tasks = config[tasksKey];
|
|
51
|
-
if (!tasks || typeof tasks !== "object") return config;
|
|
52
|
-
const resolvedTasks = {};
|
|
53
|
-
for (const [name, task] of Object.entries(tasks)) {
|
|
54
|
-
const taskConfig = task["config"];
|
|
55
|
-
const templateName = taskConfig?.["config-template"];
|
|
56
|
-
if (!templateName || !taskConfig) {
|
|
57
|
-
resolvedTasks[name] = task;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const template = templates[templateName];
|
|
61
|
-
if (!template) {
|
|
62
|
-
const { "config-template": _, ...rest } = taskConfig;
|
|
63
|
-
resolvedTasks[name] = { ...task, config: rest };
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
resolvedTasks[name] = {
|
|
67
|
-
...task,
|
|
68
|
-
config: mergeConfigs(template, taskConfig)
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const result = { ...config, [tasksKey]: resolvedTasks };
|
|
72
|
-
delete result["configTemplates"];
|
|
73
|
-
delete result["config-templates"];
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.resolveConfigTemplates = resolveConfigTemplates;
|
|
78
|
-
exports.resolveVariables = resolveVariables;
|
|
79
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';function u(e,s){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{let r=s[t.trim()];return r!==void 0?String(r):n})}function f(e,s){if(typeof e=="string")return u(e,s);if(Array.isArray(e))return e.map(n=>f(n,s));if(e!==null&&typeof e=="object"){let n={};for(let[t,r]of Object.entries(e))n[t]=f(r,s);return n}return e}function d(e,s){return f(e,s)}function m(e,s){let n={...e};for(let[t,r]of Object.entries(s))t!=="config-template"&&(r!==null&&typeof r=="object"&&!Array.isArray(r)&&n[t]!==null&&typeof n[t]=="object"&&!Array.isArray(n[t])?n[t]={...n[t],...r}:n[t]=r);return n}function k(e){let s=e.configTemplates??e["config-templates"]??{},n="tasks"in e?"tasks":"steps"in e?"steps":null;if(!n)return e;let t=e[n];if(!t||typeof t!="object")return e;let r={};for(let[c,o]of Object.entries(t)){let i=o.config,l=i?.["config-template"];if(!l||!i){r[c]=o;continue}let g=s[l];if(!g){let{"config-template":T,...p}=i;r[c]={...o,config:p};continue}r[c]={...o,config:m(g,i)};}let a={...e,[n]:r};return delete a.configTemplates,delete a["config-templates"],a}exports.resolveConfigTemplates=k;exports.resolveVariables=d;//# sourceMappingURL=index.cjs.map
|
|
80
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":["interpolateString","template","vars","match","key","value","walkAndInterpolate","item","result","k","v","resolveVariables","config","variables","mergeConfigs","taskConfig","merged","resolveConfigTemplates","templates","tasksKey","tasks","resolvedTasks","name","task","templateName","_","rest"],"mappings":"aAuBA,SAASA,CAAAA,CAAkBC,CAAAA,CAAkBC,CAAAA,CAAyB,CACpE,OAAOD,CAAAA,CAAS,OAAA,CAAQ,gBAAA,CAAkB,CAACE,CAAAA,CAAOC,CAAAA,GAAgB,CAChE,IAAMC,EAAQH,CAAAA,CAAKE,CAAAA,CAAI,IAAA,EAAM,CAAA,CAC7B,OAAOC,CAAAA,GAAU,MAAA,CAAY,OAAOA,CAAK,CAAA,CAAIF,CAC/C,CAAC,CACH,CAMA,SAASG,CAAAA,CAAsBD,CAAAA,CAAUH,EAAoB,CAC3D,GAAI,OAAOG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AA,OAAOb,EAAO,eAAA,CACd,OAAOA,CAAAA,CAAO,kBAAkB,EACzBA,CACT","file":"index.cjs","sourcesContent":["/**\n * Variable interpolation for workflow configs.\n *\n * Walks any object/array and replaces `${KEY}` patterns with values from\n * a variables map. Pure function — returns a new object, never mutates.\n *\n * Works on both GraphConfig and StepFlowConfig (or any plain object).\n *\n * @example\n * ```ts\n * const resolved = resolveVariables(config, {\n * ENTITY_ID: 'ticket-42',\n * TOOLS_DIR: '/opt/tools',\n * });\n * ```\n */\n\nexport type Variables = Record<string, string | number | boolean>;\n\n/**\n * Replace `${KEY}` patterns in a string with values from the variables map.\n * Unmatched variables are left as-is.\n */\nfunction interpolateString(template: string, vars: Variables): string {\n return template.replace(/\\$\\{([^}]+)\\}/g, (match, key: string) => {\n const value = vars[key.trim()];\n return value !== undefined ? String(value) : match;\n });\n}\n\n/**\n * Recursively walk a value and interpolate any `${KEY}` patterns found in strings.\n * Returns a new object/array — never mutates the input.\n */\nfunction walkAndInterpolate<T>(value: T, vars: Variables): T {\n if (typeof value === 'string') {\n return interpolateString(value, vars) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => walkAndInterpolate(item, vars)) as unknown as T;\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = walkAndInterpolate(v, vars);\n }\n return result as T;\n }\n // numbers, booleans, null, undefined — pass through\n return value;\n}\n\n/**\n * Resolve `${KEY}` variable references in a workflow config object.\n *\n * Pure function: config in → new config out. Works on any shape\n * (GraphConfig, StepFlowConfig, or arbitrary objects).\n *\n * @param config - The config object to interpolate\n * @param variables - Key-value pairs to substitute\n * @returns A new config with all `${KEY}` patterns replaced\n */\nexport function resolveVariables<T extends Record<string, unknown>>(\n config: T,\n variables: Variables,\n): T {\n return walkAndInterpolate(config, variables);\n}\n","/**\n * Config template resolution for workflow configs.\n *\n * In large graphs, many tasks share the same base config (cmd, timeout, cwd, headers, etc.).\n * Instead of duplicating, tasks reference a named template via `config-template`.\n * This function deep-merges the template into each task's config, then removes the reference.\n *\n * Pure function — returns a new config, never mutates.\n *\n * @example\n * ```ts\n * const config = {\n * configTemplates: {\n * PYTHON_TOOL: { cmd: 'python', timeout: 30000, cwd: '/workdata' }\n * },\n * tasks: {\n * analyze: {\n * provides: ['analysis'],\n * config: { 'config-template': 'PYTHON_TOOL', 'cmd-args': 'analyze.py' }\n * }\n * }\n * };\n * const resolved = resolveConfigTemplates(config);\n * // analyze.config → { cmd: 'python', timeout: 30000, cwd: '/workdata', 'cmd-args': 'analyze.py' }\n * ```\n */\n\n/** Shape of a config-templates block */\nexport type ConfigTemplates = Record<string, Record<string, unknown>>;\n\n/**\n * Deep-merge template into task config.\n * Task-level values override template values.\n * Nested objects are merged one level deep (like SwarmX's pattern).\n */\nfunction mergeConfigs(\n template: Record<string, unknown>,\n taskConfig: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...template };\n\n for (const [key, value] of Object.entries(taskConfig)) {\n if (key === 'config-template') continue; // strip the reference\n\n // One-level deep merge for nested objects (both sides must be plain objects)\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n merged[key] !== null &&\n typeof merged[key] === 'object' &&\n !Array.isArray(merged[key])\n ) {\n merged[key] = {\n ...(merged[key] as Record<string, unknown>),\n ...(value as Record<string, unknown>),\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n}\n\n/**\n * Resolve `config-template` references in task configs against a `configTemplates` map.\n *\n * Accepts any config object that may contain:\n * - `configTemplates` (camelCase) or `config-templates` (kebab-case) at the top level\n * - `tasks` (event-graph) or `steps` (step-machine) containing task/step objects\n * - Each task/step may have a `config` sub-object with a `config-template` key\n *\n * Returns a new config with templates merged and references removed.\n * The `configTemplates` / `config-templates` key is also removed from the output.\n */\nexport function resolveConfigTemplates<T extends Record<string, unknown>>(config: T): T {\n // Find templates — support both naming conventions\n const templates: ConfigTemplates =\n (config['configTemplates'] as ConfigTemplates) ??\n (config['config-templates'] as ConfigTemplates) ??\n {};\n\n // Find the tasks/steps container\n const tasksKey = 'tasks' in config ? 'tasks' : 'steps' in config ? 'steps' : null;\n if (!tasksKey) return config; // nothing to resolve\n\n const tasks = config[tasksKey] as Record<string, Record<string, unknown>> | undefined;\n if (!tasks || typeof tasks !== 'object') return config;\n\n const resolvedTasks: Record<string, Record<string, unknown>> = {};\n\n for (const [name, task] of Object.entries(tasks)) {\n const taskConfig = task['config'] as Record<string, unknown> | undefined;\n const templateName = taskConfig?.['config-template'] as string | undefined;\n\n if (!templateName || !taskConfig) {\n resolvedTasks[name] = task;\n continue;\n }\n\n const template = templates[templateName];\n if (!template) {\n // Template not found — leave as-is but strip the reference\n const { 'config-template': _, ...rest } = taskConfig;\n resolvedTasks[name] = { ...task, config: rest };\n continue;\n }\n\n resolvedTasks[name] = {\n ...task,\n config: mergeConfigs(template, taskConfig),\n };\n }\n\n // Build result — remove the templates key from output\n const result = { ...config, [tasksKey]: resolvedTasks };\n delete result['configTemplates'];\n delete result['config-templates'];\n return result as T;\n}\n"]}
|
package/dist/config/index.js
CHANGED
|
@@ -1,77 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function interpolateString(template, vars) {
|
|
3
|
-
return template.replace(/\$\{([^}]+)\}/g, (match, key) => {
|
|
4
|
-
const value = vars[key.trim()];
|
|
5
|
-
return value !== void 0 ? String(value) : match;
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
function walkAndInterpolate(value, vars) {
|
|
9
|
-
if (typeof value === "string") {
|
|
10
|
-
return interpolateString(value, vars);
|
|
11
|
-
}
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
return value.map((item) => walkAndInterpolate(item, vars));
|
|
14
|
-
}
|
|
15
|
-
if (value !== null && typeof value === "object") {
|
|
16
|
-
const result = {};
|
|
17
|
-
for (const [k, v] of Object.entries(value)) {
|
|
18
|
-
result[k] = walkAndInterpolate(v, vars);
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
function resolveVariables(config, variables) {
|
|
25
|
-
return walkAndInterpolate(config, variables);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/config/resolve-config-templates.ts
|
|
29
|
-
function mergeConfigs(template, taskConfig) {
|
|
30
|
-
const merged = { ...template };
|
|
31
|
-
for (const [key, value] of Object.entries(taskConfig)) {
|
|
32
|
-
if (key === "config-template") continue;
|
|
33
|
-
if (value !== null && typeof value === "object" && !Array.isArray(value) && merged[key] !== null && typeof merged[key] === "object" && !Array.isArray(merged[key])) {
|
|
34
|
-
merged[key] = {
|
|
35
|
-
...merged[key],
|
|
36
|
-
...value
|
|
37
|
-
};
|
|
38
|
-
} else {
|
|
39
|
-
merged[key] = value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return merged;
|
|
43
|
-
}
|
|
44
|
-
function resolveConfigTemplates(config) {
|
|
45
|
-
const templates = config["configTemplates"] ?? config["config-templates"] ?? {};
|
|
46
|
-
const tasksKey = "tasks" in config ? "tasks" : "steps" in config ? "steps" : null;
|
|
47
|
-
if (!tasksKey) return config;
|
|
48
|
-
const tasks = config[tasksKey];
|
|
49
|
-
if (!tasks || typeof tasks !== "object") return config;
|
|
50
|
-
const resolvedTasks = {};
|
|
51
|
-
for (const [name, task] of Object.entries(tasks)) {
|
|
52
|
-
const taskConfig = task["config"];
|
|
53
|
-
const templateName = taskConfig?.["config-template"];
|
|
54
|
-
if (!templateName || !taskConfig) {
|
|
55
|
-
resolvedTasks[name] = task;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const template = templates[templateName];
|
|
59
|
-
if (!template) {
|
|
60
|
-
const { "config-template": _, ...rest } = taskConfig;
|
|
61
|
-
resolvedTasks[name] = { ...task, config: rest };
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
resolvedTasks[name] = {
|
|
65
|
-
...task,
|
|
66
|
-
config: mergeConfigs(template, taskConfig)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const result = { ...config, [tasksKey]: resolvedTasks };
|
|
70
|
-
delete result["configTemplates"];
|
|
71
|
-
delete result["config-templates"];
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { resolveConfigTemplates, resolveVariables };
|
|
76
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
function u(e,s){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{let r=s[t.trim()];return r!==void 0?String(r):n})}function f(e,s){if(typeof e=="string")return u(e,s);if(Array.isArray(e))return e.map(n=>f(n,s));if(e!==null&&typeof e=="object"){let n={};for(let[t,r]of Object.entries(e))n[t]=f(r,s);return n}return e}function d(e,s){return f(e,s)}function m(e,s){let n={...e};for(let[t,r]of Object.entries(s))t!=="config-template"&&(r!==null&&typeof r=="object"&&!Array.isArray(r)&&n[t]!==null&&typeof n[t]=="object"&&!Array.isArray(n[t])?n[t]={...n[t],...r}:n[t]=r);return n}function k(e){let s=e.configTemplates??e["config-templates"]??{},n="tasks"in e?"tasks":"steps"in e?"steps":null;if(!n)return e;let t=e[n];if(!t||typeof t!="object")return e;let r={};for(let[c,o]of Object.entries(t)){let i=o.config,l=i?.["config-template"];if(!l||!i){r[c]=o;continue}let g=s[l];if(!g){let{"config-template":T,...p}=i;r[c]={...o,config:p};continue}r[c]={...o,config:m(g,i)};}let a={...e,[n]:r};return delete a.configTemplates,delete a["config-templates"],a}export{k as resolveConfigTemplates,d as resolveVariables};//# sourceMappingURL=index.js.map
|
|
77
2
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":["interpolateString","template","vars","match","key","value","walkAndInterpolate","item","result","k","v","resolveVariables","config","variables","mergeConfigs","taskConfig","merged","resolveConfigTemplates","templates","tasksKey","tasks","resolvedTasks","name","task","templateName","_","rest"],"mappings":"AAuBA,SAASA,CAAAA,CAAkBC,CAAAA,CAAkBC,CAAAA,CAAyB,CACpE,OAAOD,CAAAA,CAAS,OAAA,CAAQ,gBAAA,CAAkB,CAACE,CAAAA,CAAOC,CAAAA,GAAgB,CAChE,IAAMC,EAAQH,CAAAA,CAAKE,CAAAA,CAAI,IAAA,EAAM,CAAA,CAC7B,OAAOC,CAAAA,GAAU,MAAA,CAAY,OAAOA,CAAK,CAAA,CAAIF,CAC/C,CAAC,CACH,CAMA,SAASG,CAAAA,CAAsBD,CAAAA,CAAUH,EAAoB,CAC3D,GAAI,OAAOG,CAAAA,EAAU,QAAA,CACnB,OAAOL,CAAAA,CAAkBK,CAAAA,CAAOH,CAAI,CAAA,CAEtC,GAAI,KAAA,CAAM,OAAA,CAAQG,CAAK,CAAA,CACrB,OAAOA,CAAAA,CAAM,GAAA,CAAKE,GAASD,CAAAA,CAAmBC,CAAAA,CAAML,CAAI,CAAC,CAAA,CAE3D,GAAIG,CAAAA,GAAU,IAAA,EAAQ,OAAOA,CAAAA,EAAU,QAAA,CAAU,CAC/C,IAAMG,EAAkC,EAAC,CACzC,IAAA,GAAW,CAACC,EAAGC,CAAC,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQL,CAAK,CAAA,CACvCG,CAAAA,CAAOC,CAAC,EAAIH,CAAAA,CAAmBI,CAAAA,CAAGR,CAAI,CAAA,CAExC,OAAOM,CACT,CAEA,OAAOH,CACT,CAYO,SAASM,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACG,CACH,OAAOP,CAAAA,CAAmBM,CAAAA,CAAQC,CAAS,CAC7C,CChCA,SAASC,CAAAA,CACPb,EACAc,CAAAA,CACyB,CACzB,IAAMC,CAAAA,CAAkC,CAAE,GAAGf,CAAS,CAAA,CAEtD,IAAA,GAAW,CAACG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CACtB,QACF,CAEA,IAAMtB,CAAAA,CAAWiB,CAAAA,CAAUM,CAAY,CAAA,CACvC,GAAI,CAACvB,CAAAA,CAAU,CAEb,GAAM,CAAE,iBAAA,CAAmBwB,CAAAA,CAAG,GAAGC,CAAK,CAAA,CAAIX,CAAAA,CAC1CM,CAAAA,CAAcC,CAAI,EAAI,CAAE,GAAGC,CAAAA,CAAM,MAAA,CAAQG,CAAK,CAAA,CAC9C,QACF,CAEAL,EAAcC,CAAI,CAAA,CAAI,CACpB,GAAGC,EACH,MAAA,CAAQT,CAAAA,CAAab,CAAAA,CAAUc,CAAU,CAC3C,EACF,CAGA,IAAMP,CAAAA,CAAS,CAAE,GAAGI,CAAAA,CAAQ,CAACO,CAAQ,EAAGE,CAAc,CAAA,CACtD,OAAA,OAAOb,EAAO,eAAA,CACd,OAAOA,CAAAA,CAAO,kBAAkB,EACzBA,CACT","file":"index.js","sourcesContent":["/**\n * Variable interpolation for workflow configs.\n *\n * Walks any object/array and replaces `${KEY}` patterns with values from\n * a variables map. Pure function — returns a new object, never mutates.\n *\n * Works on both GraphConfig and StepFlowConfig (or any plain object).\n *\n * @example\n * ```ts\n * const resolved = resolveVariables(config, {\n * ENTITY_ID: 'ticket-42',\n * TOOLS_DIR: '/opt/tools',\n * });\n * ```\n */\n\nexport type Variables = Record<string, string | number | boolean>;\n\n/**\n * Replace `${KEY}` patterns in a string with values from the variables map.\n * Unmatched variables are left as-is.\n */\nfunction interpolateString(template: string, vars: Variables): string {\n return template.replace(/\\$\\{([^}]+)\\}/g, (match, key: string) => {\n const value = vars[key.trim()];\n return value !== undefined ? String(value) : match;\n });\n}\n\n/**\n * Recursively walk a value and interpolate any `${KEY}` patterns found in strings.\n * Returns a new object/array — never mutates the input.\n */\nfunction walkAndInterpolate<T>(value: T, vars: Variables): T {\n if (typeof value === 'string') {\n return interpolateString(value, vars) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => walkAndInterpolate(item, vars)) as unknown as T;\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = walkAndInterpolate(v, vars);\n }\n return result as T;\n }\n // numbers, booleans, null, undefined — pass through\n return value;\n}\n\n/**\n * Resolve `${KEY}` variable references in a workflow config object.\n *\n * Pure function: config in → new config out. Works on any shape\n * (GraphConfig, StepFlowConfig, or arbitrary objects).\n *\n * @param config - The config object to interpolate\n * @param variables - Key-value pairs to substitute\n * @returns A new config with all `${KEY}` patterns replaced\n */\nexport function resolveVariables<T extends Record<string, unknown>>(\n config: T,\n variables: Variables,\n): T {\n return walkAndInterpolate(config, variables);\n}\n","/**\n * Config template resolution for workflow configs.\n *\n * In large graphs, many tasks share the same base config (cmd, timeout, cwd, headers, etc.).\n * Instead of duplicating, tasks reference a named template via `config-template`.\n * This function deep-merges the template into each task's config, then removes the reference.\n *\n * Pure function — returns a new config, never mutates.\n *\n * @example\n * ```ts\n * const config = {\n * configTemplates: {\n * PYTHON_TOOL: { cmd: 'python', timeout: 30000, cwd: '/workdata' }\n * },\n * tasks: {\n * analyze: {\n * provides: ['analysis'],\n * config: { 'config-template': 'PYTHON_TOOL', 'cmd-args': 'analyze.py' }\n * }\n * }\n * };\n * const resolved = resolveConfigTemplates(config);\n * // analyze.config → { cmd: 'python', timeout: 30000, cwd: '/workdata', 'cmd-args': 'analyze.py' }\n * ```\n */\n\n/** Shape of a config-templates block */\nexport type ConfigTemplates = Record<string, Record<string, unknown>>;\n\n/**\n * Deep-merge template into task config.\n * Task-level values override template values.\n * Nested objects are merged one level deep (like SwarmX's pattern).\n */\nfunction mergeConfigs(\n template: Record<string, unknown>,\n taskConfig: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...template };\n\n for (const [key, value] of Object.entries(taskConfig)) {\n if (key === 'config-template') continue; // strip the reference\n\n // One-level deep merge for nested objects (both sides must be plain objects)\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n merged[key] !== null &&\n typeof merged[key] === 'object' &&\n !Array.isArray(merged[key])\n ) {\n merged[key] = {\n ...(merged[key] as Record<string, unknown>),\n ...(value as Record<string, unknown>),\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n}\n\n/**\n * Resolve `config-template` references in task configs against a `configTemplates` map.\n *\n * Accepts any config object that may contain:\n * - `configTemplates` (camelCase) or `config-templates` (kebab-case) at the top level\n * - `tasks` (event-graph) or `steps` (step-machine) containing task/step objects\n * - Each task/step may have a `config` sub-object with a `config-template` key\n *\n * Returns a new config with templates merged and references removed.\n * The `configTemplates` / `config-templates` key is also removed from the output.\n */\nexport function resolveConfigTemplates<T extends Record<string, unknown>>(config: T): T {\n // Find templates — support both naming conventions\n const templates: ConfigTemplates =\n (config['configTemplates'] as ConfigTemplates) ??\n (config['config-templates'] as ConfigTemplates) ??\n {};\n\n // Find the tasks/steps container\n const tasksKey = 'tasks' in config ? 'tasks' : 'steps' in config ? 'steps' : null;\n if (!tasksKey) return config; // nothing to resolve\n\n const tasks = config[tasksKey] as Record<string, Record<string, unknown>> | undefined;\n if (!tasks || typeof tasks !== 'object') return config;\n\n const resolvedTasks: Record<string, Record<string, unknown>> = {};\n\n for (const [name, task] of Object.entries(tasks)) {\n const taskConfig = task['config'] as Record<string, unknown> | undefined;\n const templateName = taskConfig?.['config-template'] as string | undefined;\n\n if (!templateName || !taskConfig) {\n resolvedTasks[name] = task;\n continue;\n }\n\n const template = templates[templateName];\n if (!template) {\n // Template not found — leave as-is but strip the reference\n const { 'config-template': _, ...rest } = taskConfig;\n resolvedTasks[name] = { ...task, config: rest };\n continue;\n }\n\n resolvedTasks[name] = {\n ...task,\n config: mergeConfigs(template, taskConfig),\n };\n }\n\n // Build result — remove the templates key from output\n const result = { ...config, [tasksKey]: resolvedTasks };\n delete result['configTemplates'];\n delete result['config-templates'];\n return result as T;\n}\n"]}
|