yaml-flow 5.4.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/board-live-cards-cli.js +2 -2
  2. package/board-livecards-server-runtime.js +488 -551
  3. package/browser/asset-integrity.json +10 -0
  4. package/browser/board-livecards-runtime-client.js +0 -6
  5. package/browser/board-livegraph-engine.js +2 -1676
  6. package/browser/board-livegraph-engine.js.map +1 -1
  7. package/browser/live-cards.js +347 -26
  8. package/browser/live-cards.schema.json +418 -132
  9. package/card-store.js +37 -0
  10. package/dist/batch/index.cjs +1 -108
  11. package/dist/batch/index.cjs.map +1 -1
  12. package/dist/batch/index.js +1 -106
  13. package/dist/batch/index.js.map +1 -1
  14. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  15. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  16. package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
  17. package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
  18. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  19. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  20. package/dist/board-livegraph-runtime/index.d.cts +1 -2
  21. package/dist/board-livegraph-runtime/index.d.ts +1 -2
  22. package/dist/board-livegraph-runtime/index.js +2 -1662
  23. package/dist/board-livegraph-runtime/index.js.map +1 -1
  24. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
  25. package/dist/card-compute/index.cjs +9 -7159
  26. package/dist/card-compute/index.cjs.map +1 -1
  27. package/dist/card-compute/index.d.cts +22 -0
  28. package/dist/card-compute/index.d.ts +22 -0
  29. package/dist/card-compute/index.js +9 -7145
  30. package/dist/card-compute/index.js.map +1 -1
  31. package/dist/card-compute/jsonata-sync.cjs +7587 -0
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
  36. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
  37. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  38. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  39. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  40. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  41. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  42. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  43. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  44. package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
  45. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  46. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  47. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  48. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  49. package/dist/cli/node/artifacts-store-cli.js +11 -0
  50. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  51. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  52. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  53. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  54. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  55. package/dist/cli/node/board-live-cards-cli.js +15 -0
  56. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  57. package/dist/cli/node/card-store-cli.cjs +8 -0
  58. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  59. package/dist/cli/node/card-store-cli.d.cts +15 -0
  60. package/dist/cli/node/card-store-cli.d.ts +15 -0
  61. package/dist/cli/node/card-store-cli.js +8 -0
  62. package/dist/cli/node/card-store-cli.js.map +1 -0
  63. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  64. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  65. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  66. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  67. package/dist/cli/node/fs-board-adapter.js +14 -0
  68. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  69. package/dist/cli/node/jsonata-sync.cjs +7587 -0
  70. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  71. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  72. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  73. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  74. package/dist/cli/node/source-cli-task-executor.js +11 -0
  75. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  76. package/dist/config/index.cjs +1 -79
  77. package/dist/config/index.cjs.map +1 -1
  78. package/dist/config/index.js +1 -76
  79. package/dist/config/index.js.map +1 -1
  80. package/dist/continuous-event-graph/index.cjs +2 -2129
  81. package/dist/continuous-event-graph/index.cjs.map +1 -1
  82. package/dist/continuous-event-graph/index.d.cts +81 -5
  83. package/dist/continuous-event-graph/index.d.ts +81 -5
  84. package/dist/continuous-event-graph/index.js +2 -2088
  85. package/dist/continuous-event-graph/index.js.map +1 -1
  86. package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
  87. package/dist/event-graph/index.cjs +22 -8292
  88. package/dist/event-graph/index.cjs.map +1 -1
  89. package/dist/event-graph/index.js +22 -8237
  90. package/dist/event-graph/index.js.map +1 -1
  91. package/dist/execution-refs.cjs +2 -0
  92. package/dist/execution-refs.cjs.map +1 -0
  93. package/dist/execution-refs.d.cts +222 -0
  94. package/dist/execution-refs.d.ts +222 -0
  95. package/dist/execution-refs.js +2 -0
  96. package/dist/execution-refs.js.map +1 -0
  97. package/dist/index.cjs +29 -13221
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +2 -4
  100. package/dist/index.d.ts +2 -4
  101. package/dist/index.js +29 -13112
  102. package/dist/index.js.map +1 -1
  103. package/dist/inference/index.cjs +5 -617
  104. package/dist/inference/index.cjs.map +1 -1
  105. package/dist/inference/index.js +5 -610
  106. package/dist/inference/index.js.map +1 -1
  107. package/dist/jsonata-sync.cjs +7587 -0
  108. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  109. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  110. package/dist/pycli/quickjs-board-runtime.global.js +9 -0
  111. package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
  112. package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
  113. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
  114. package/dist/step-machine/index.cjs +11 -7129
  115. package/dist/step-machine/index.cjs.map +1 -1
  116. package/dist/step-machine/index.js +11 -7113
  117. package/dist/step-machine/index.js.map +1 -1
  118. package/dist/storage-refs.cjs +10 -0
  119. package/dist/storage-refs.cjs.map +1 -0
  120. package/dist/storage-refs.d.cts +92 -0
  121. package/dist/storage-refs.d.ts +92 -0
  122. package/dist/storage-refs.js +10 -0
  123. package/dist/storage-refs.js.map +1 -0
  124. package/dist/stores/file.cjs +1 -114
  125. package/dist/stores/file.cjs.map +1 -1
  126. package/dist/stores/file.js +1 -112
  127. package/dist/stores/file.js.map +1 -1
  128. package/dist/stores/index.cjs +1 -231
  129. package/dist/stores/index.cjs.map +1 -1
  130. package/dist/stores/index.js +1 -227
  131. package/dist/stores/index.js.map +1 -1
  132. package/dist/stores/localStorage.cjs +1 -76
  133. package/dist/stores/localStorage.cjs.map +1 -1
  134. package/dist/stores/localStorage.js +1 -74
  135. package/dist/stores/localStorage.js.map +1 -1
  136. package/dist/stores/memory.cjs +1 -47
  137. package/dist/stores/memory.cjs.map +1 -1
  138. package/dist/stores/memory.js +1 -45
  139. package/dist/stores/memory.js.map +1 -1
  140. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
  141. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  142. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  143. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  144. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
  145. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
  146. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  147. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  148. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
  149. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
  150. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
  151. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
  152. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
  153. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
  154. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
  155. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
  156. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
  157. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
  158. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
  159. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
  160. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  161. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  162. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  163. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  164. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
  165. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  166. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
  167. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  168. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  169. package/examples/example-board/agent-instructions.md +11 -5
  170. package/examples/example-board/demo-chat-handler.js +14 -4
  171. package/examples/example-board/demo-server-config.json +1 -0
  172. package/examples/example-board/demo-server.js +19 -34
  173. package/examples/example-board/demo-shell-browser.html +5 -4
  174. package/examples/example-board/demo-shell-with-server.html +10 -6
  175. package/examples/example-board/demo-task-executor.js +81 -35
  176. package/examples/index.html +0 -14
  177. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  178. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  179. package/package.json +39 -3
  180. package/schema/live-cards.schema.json +418 -132
  181. package/dist/cli/board-live-cards-cli.cjs +0 -10644
  182. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  183. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  184. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  185. package/dist/cli/board-live-cards-cli.js +0 -10592
  186. package/dist/cli/board-live-cards-cli.js.map +0 -1
  187. package/dist/journal-9HEgs7dU.d.ts +0 -28
  188. package/dist/journal-B-JCfQnh.d.cts +0 -28
  189. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  190. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  191. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  192. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  193. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  194. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  195. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  196. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  197. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  198. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  199. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  200. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
@@ -1,28 +0,0 @@
1
- import { f as GraphEvent } from './types-BBhqYGhE.js';
2
-
3
- /**
4
- * Continuous Event Graph — Journal
5
- *
6
- * Append-only event log for the reactive layer.
7
- * Handlers append events here; drain() reads and clears atomically.
8
- *
9
- * Adapter:
10
- * - MemoryJournal: in-process array (default)
11
- */
12
-
13
- interface Journal {
14
- /** Append an event to the journal. Safe to call from concurrent callbacks. */
15
- append(event: GraphEvent): void;
16
- /** Read all pending events and clear the journal atomically. */
17
- drain(): GraphEvent[];
18
- /** Number of pending events (for observability). */
19
- readonly size: number;
20
- }
21
- declare class MemoryJournal implements Journal {
22
- private buffer;
23
- append(event: GraphEvent): void;
24
- drain(): GraphEvent[];
25
- get size(): number;
26
- }
27
-
28
- export { type Journal as J, MemoryJournal as M };
@@ -1,28 +0,0 @@
1
- import { f as GraphEvent } from './types-BBhqYGhE.cjs';
2
-
3
- /**
4
- * Continuous Event Graph — Journal
5
- *
6
- * Append-only event log for the reactive layer.
7
- * Handlers append events here; drain() reads and clears atomically.
8
- *
9
- * Adapter:
10
- * - MemoryJournal: in-process array (default)
11
- */
12
-
13
- interface Journal {
14
- /** Append an event to the journal. Safe to call from concurrent callbacks. */
15
- append(event: GraphEvent): void;
16
- /** Read all pending events and clear the journal atomically. */
17
- drain(): GraphEvent[];
18
- /** Number of pending events (for observability). */
19
- readonly size: number;
20
- }
21
- declare class MemoryJournal implements Journal {
22
- private buffer;
23
- append(event: GraphEvent): void;
24
- drain(): GraphEvent[];
25
- get size(): number;
26
- }
27
-
28
- export { type Journal as J, MemoryJournal as M };
@@ -1,21 +0,0 @@
1
- import { L as LiveGraph, S as ScheduleResult } from './types-CoW0gQl3.js';
2
-
3
- /**
4
- * Continuous Event Graph — Schedule
5
- *
6
- * Pure read-only projection: LiveGraph → ScheduleResult
7
- *
8
- * Classifies every non-terminal task into one of:
9
- * - eligible: all requires satisfied, ready to dispatch
10
- * - pending: requires not yet met, but a viable producer exists (normal waiting)
11
- * - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
12
- * - blocked: requires not met because the producing task FAILED (caller's problem)
13
- */
14
-
15
- /**
16
- * Compute the scheduling status of every task in the live graph.
17
- * Pure function — no side effects.
18
- */
19
- declare function schedule(live: LiveGraph): ScheduleResult;
20
-
21
- export { schedule as s };
@@ -1,21 +0,0 @@
1
- import { L as LiveGraph, S as ScheduleResult } from './types-CHSdoAAA.cjs';
2
-
3
- /**
4
- * Continuous Event Graph — Schedule
5
- *
6
- * Pure read-only projection: LiveGraph → ScheduleResult
7
- *
8
- * Classifies every non-terminal task into one of:
9
- * - eligible: all requires satisfied, ready to dispatch
10
- * - pending: requires not yet met, but a viable producer exists (normal waiting)
11
- * - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
12
- * - blocked: requires not met because the producing task FAILED (caller's problem)
13
- */
14
-
15
- /**
16
- * Compute the scheduling status of every task in the live graph.
17
- * Pure function — no side effects.
18
- */
19
- declare function schedule(live: LiveGraph): ScheduleResult;
20
-
21
- export { schedule as s };
@@ -1,22 +0,0 @@
1
- {
2
- "id": "holdings-table",
3
- "meta": { "title": "Holdings Table" },
4
- "requires": ["holdings", "prices"],
5
- "provides": [{ "bindTo": "table", "ref": "computed_values.table" }],
6
- "card_data": {},
7
- "compute": [
8
- {
9
- "bindTo": "table",
10
- "expr": "{ \"rows\": $map(requires.holdings, function($h) { { \"symbol\": $h.symbol, \"qty\": $h.qty, \"price\": $lookup(requires.prices, $h.symbol), \"value\": $h.qty * $lookup(requires.prices, $h.symbol) } }) }"
11
- }
12
- ],
13
- "view": {
14
- "elements": [
15
- {
16
- "kind": "table",
17
- "label": "Portfolio Positions",
18
- "data": { "bind": "computed_values.table.rows", "columns": ["symbol", "qty", "price", "value"] }
19
- }
20
- ]
21
- }
22
- }
@@ -1,16 +0,0 @@
1
- {
2
- "id": "portfolio-form",
3
- "meta": { "title": "Portfolio Holdings Form" },
4
- "provides": [{ "bindTo": "holdings", "ref": "card_data.holdings" }],
5
- "card_data": {
6
- "holdings": [
7
- { "symbol": "AAPL", "qty": 50 },
8
- { "symbol": "MSFT", "qty": 30 }
9
- ]
10
- },
11
- "view": {
12
- "elements": [
13
- { "kind": "table", "label": "Holdings", "data": { "bind": "card_data.holdings", "columns": ["symbol", "qty"] } }
14
- ]
15
- }
16
- }
@@ -1,28 +0,0 @@
1
- {
2
- "id": "portfolio-risk-assessment",
3
- "meta": { "title": "Portfolio Risk Assessment" },
4
- "requires": ["table", "totalValue"],
5
- "provides": [
6
- { "bindTo": "riskAssessment", "ref": "card_data.llm_task_completion_inference.reason" }
7
- ],
8
- "card_data": {
9
- "llm_task_completion_inference": {
10
- "sync_tmp_file": "tmp_file2"
11
- }
12
- },
13
- "when_is_task_completed": "Complete this task only when the portfolio has at least 3 positions and no single holding exceeds 60 percent of the total portfolio value.",
14
- "view": {
15
- "elements": [
16
- {
17
- "kind": "text",
18
- "label": "Risk Assessment",
19
- "data": { "bind": "card_data.llm_task_completion_inference.reason" }
20
- },
21
- {
22
- "kind": "text",
23
- "label": "Risk Evidence",
24
- "data": { "bind": "card_data.llm_task_completion_inference.evidence" }
25
- }
26
- ]
27
- }
28
- }
@@ -1,15 +0,0 @@
1
- {
2
- "id": "portfolio-value",
3
- "meta": { "title": "Portfolio Total Value" },
4
- "requires": ["table"],
5
- "provides": [{ "bindTo": "totalValue", "ref": "computed_values.totalValue" }],
6
- "card_data": {},
7
- "compute": [
8
- { "bindTo": "totalValue", "expr": "$sum(requires.table.rows.value)" }
9
- ],
10
- "view": {
11
- "elements": [
12
- { "kind": "metric", "label": "Total Portfolio Value", "data": { "bind": "computed_values.totalValue" } }
13
- ]
14
- }
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "id": "price-fetch",
3
- "meta": { "title": "Fetch Market Prices" },
4
- "requires": ["holdings"],
5
- "provides": [{ "bindTo": "prices", "ref": "fetched_sources.prices" }],
6
- "card_data": {},
7
- "source_defs": [
8
- { "cli": "node ../fetch-prices.js", "bindTo": "prices", "outputFile": "prices.json" }
9
- ],
10
- "view": {
11
- "elements": [
12
- { "kind": "table", "label": "Market Prices", "data": { "bind": "fetched_sources.prices" } }
13
- ]
14
- }
15
- }
@@ -1,28 +0,0 @@
1
- {
2
- "id": "rebalancing-strategy",
3
- "meta": { "title": "Rebalancing Strategy" },
4
- "requires": ["table", "totalValue", "riskAssessment"],
5
- "provides": [
6
- { "bindTo": "rebalancingPlan", "ref": "card_data.llm_task_completion_inference.reason" }
7
- ],
8
- "card_data": {
9
- "llm_task_completion_inference": {
10
- "sync_tmp_file": "tmp_file3"
11
- }
12
- },
13
- "when_is_task_completed": "Complete this task when a concrete rebalancing recommendation can be produced from the current holdings table, total value, and risk assessment.",
14
- "view": {
15
- "elements": [
16
- {
17
- "kind": "text",
18
- "label": "Rebalancing Recommendation",
19
- "data": { "bind": "card_data.llm_task_completion_inference.reason" }
20
- },
21
- {
22
- "kind": "text",
23
- "label": "Suggested Moves",
24
- "data": { "bind": "card_data.llm_task_completion_inference.evidence" }
25
- }
26
- ]
27
- }
28
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * fetch-prices.js
3
- * Polls for tmp_file1 payload and outputs JSON to stdout once available.
4
- */
5
- import * as fs from 'node:fs';
6
- import * as path from 'node:path';
7
-
8
- const envBoardDir = (process.env.BOARD_DIR ?? '').trim();
9
- const tmpFileCandidates = [
10
- envBoardDir ? path.join(envBoardDir, 'tmp_file1') : '',
11
- path.join(process.cwd(), 'tmp_file1'),
12
- path.join(process.cwd(), 'board-runtime', 'tmp_file1'),
13
- path.join(process.cwd(), '..', 'board-runtime', 'tmp_file1'),
14
- ].filter(Boolean);
15
-
16
- function getReadableTmpFile() {
17
- for (const tmpFile of tmpFileCandidates) {
18
- if (!fs.existsSync(tmpFile)) continue;
19
- const content = fs.readFileSync(tmpFile, 'utf-8').trim();
20
- if (content) return { tmpFile, content };
21
- }
22
- return undefined;
23
- }
24
-
25
- function waitForFile(timeoutMs = 120000) {
26
- const started = Date.now();
27
- const interval = setInterval(() => {
28
- if (Date.now() - started > timeoutMs) {
29
- clearInterval(interval);
30
- console.error('Timed out waiting for tmp_file1 market prices input.');
31
- process.exit(1);
32
- }
33
-
34
- const ready = getReadableTmpFile();
35
- if (!ready) return;
36
-
37
- clearInterval(interval);
38
- fs.writeFileSync(ready.tmpFile, '', 'utf-8');
39
- process.stdout.write(`${ready.content}\n`);
40
- }, 250);
41
- }
42
-
43
- waitForFile();
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Portfolio Tracker Task-Executor
4
- *
5
- * Implements the run-source-fetch protocol for board-live-cards.
6
- * This script acts as an external task-executor that can be registered via .task-executor file.
7
- *
8
- * Contract:
9
- * portfolio-tracker-task-executor.js run-source-fetch --in <defFile> --out <resultFile> --err <errFile>
10
- *
11
- * Input (--in file):
12
- * JSON source definition with { cli: "...", bindTo: "...", outputFile: "...", ... }
13
- *
14
- * Output (on success):
15
- * --out file contains the execution result
16
- * Exit code: 0
17
- *
18
- * Output (on error):
19
- * --err file contains error message
20
- * Exit code: 1
21
- */
22
-
23
- const fs = require('fs');
24
- const path = require('path');
25
- const { execSync } = require('child_process');
26
-
27
- // Parse command line arguments
28
- const args = process.argv.slice(2);
29
- let subcommand = '';
30
- let inFile = '';
31
- let outFile = '';
32
- let errFile = '';
33
-
34
- for (let i = 0; i < args.length; i++) {
35
- if (args[i] === 'run-source-fetch') {
36
- subcommand = 'run-source-fetch';
37
- } else if (args[i] === '--in' && i + 1 < args.length) {
38
- inFile = args[i + 1];
39
- } else if (args[i] === '--out' && i + 1 < args.length) {
40
- outFile = args[i + 1];
41
- } else if (args[i] === '--err' && i + 1 < args.length) {
42
- errFile = args[i + 1];
43
- }
44
- }
45
-
46
- if (subcommand !== 'run-source-fetch' || !inFile || !outFile || !errFile) {
47
- console.error('Usage: portfolio-tracker-task-executor.js run-source-fetch --in <defFile> --out <resultFile> --err <errFile>');
48
- process.exit(1);
49
- }
50
-
51
- try {
52
- // 1. Read source definition from --in file
53
- console.log(`[portfolio-tracker-task-executor] Reading source definition from ${inFile}`);
54
- const sourceDefStr = fs.readFileSync(inFile, 'utf-8');
55
- const sourceDef = JSON.parse(sourceDefStr);
56
-
57
- // 2. Extract cli command from source definition
58
- const { cli: sourceCliCommand } = sourceDef;
59
- if (!sourceCliCommand) {
60
- throw new Error('cli is required in source definition');
61
- }
62
-
63
- console.log(`[portfolio-tracker-task-executor] Executing: ${sourceCliCommand}`);
64
-
65
- // 3. Execute source.cli synchronously and capture output
66
- let output;
67
- try {
68
- output = execSync(sourceCliCommand, {
69
- encoding: 'utf-8',
70
- timeout: (sourceDef.timeout ?? 120) * 1000, // Convert to ms
71
- cwd: sourceDef.cwd,
72
- shell: true,
73
- stdio: ['pipe', 'pipe', 'pipe'], // Capture stdout/stderr
74
- });
75
- } catch (execErr) {
76
- // Even on error, try to use what output we got
77
- output = execErr.stdout || '';
78
- if (!output) {
79
- throw new Error(`Command execution failed: ${execErr.message}`);
80
- }
81
- }
82
-
83
- // 4. Write output to --out file
84
- console.log(`[portfolio-tracker-task-executor] Writing result to ${outFile}`);
85
- fs.writeFileSync(outFile, output.trim(), 'utf-8');
86
-
87
- console.log(`[portfolio-tracker-task-executor] Success`);
88
- process.exit(0);
89
- } catch (error) {
90
- // 3a. On error: write error message to --err file and exit non-zero
91
- const errorMsg = error instanceof Error ? error.message : String(error);
92
- console.error(`[portfolio-tracker-task-executor] Error:`, errorMsg);
93
-
94
- fs.writeFileSync(errFile, errorMsg, 'utf-8');
95
- process.exit(1);
96
- }
@@ -1,7 +0,0 @@
1
- @echo off
2
- setlocal
3
-
4
- set "BOARD_LIVE_CARDS_NO_SPAWN=1"
5
- node "%~dp0portfolio-tracker.js"
6
-
7
- endlocal