yaml-flow 7.1.0 → 8.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/browser/asset-integrity.json +8 -4
- package/browser/board-livecards-client.js +1 -1
- package/browser/board-livecards-localstorage.js +5 -5
- package/browser/live-cards.js +19 -3309
- package/cli/board-live-cards-lib-tjYsPt5U.d.ts +321 -0
- package/{dist/cli → cli}/browser-api/board-live-cards-browser-adapter.d.ts +3 -5
- package/{dist/cli → cli}/browser-api/card-store-browser-api.d.ts +1 -2
- package/{dist/cli → cli}/browser-api/card-store-browser-api.js +1 -1
- package/cli/execution-interface-C_A6WCiK.d.ts +284 -0
- package/{dist/cli → cli}/node/artifacts-store-cli.js +2 -2
- package/cli/node/batch-runner-cli.js +3 -0
- package/cli/node/board-live-cards-cli.js +15 -0
- package/{dist/cli → cli}/node/execution-adapter.d.ts +3 -3
- package/cli/node/execution-adapter.js +3 -0
- package/{dist/cli → cli}/node/fs-board-adapter.d.ts +24 -11
- package/cli/node/fs-board-adapter.js +14 -0
- package/cli/node/step-machine-cli.d.ts +7 -0
- package/cli/node/step-machine-cli.js +5 -0
- package/{dist/board-live-cards-public-5n1-syA3.d.cts → cli/types-CziUxkiv.d.ts} +68 -5
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/card-store-ref.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/chat-handler.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/outputs-store-ref.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/task-executor.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/graph.json +29 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/lastJournalProcessedId.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime-out/.outputs/status.json +25 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-market-prices/computed_values.json +67 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio/computed_values.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio-value/computed_values.json +52 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/holdings.json +22 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/positions.json +46 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/quotes.json +35 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/status.json +113 -0
- package/examples/{example-board → board}/demo-server-config.json +0 -1
- package/examples/{example-board → board}/demo-server.js +23 -48
- package/examples/{example-board → board}/demo-shell-with-server.html +3 -3
- package/examples/{example-board → board}/demo-task-executor.js +71 -24
- package/examples/board/gandalf-cards/card-source-kinds.json +36 -0
- package/examples/board/gandalf-cards/cards/_index.json +7 -0
- package/examples/board/gandalf-cards/cards/card-source-kinds.json +64 -0
- package/examples/board/source-def-flows/copilot.flow.json +33 -0
- package/examples/board/source-def-flows/mock.flow.json +35 -0
- package/examples/board/source-def-flows/url-list.flow.json +33 -0
- package/examples/board/source-def-flows/url.flow.json +33 -0
- package/examples/board/source-def-flows/workiq.flow.json +34 -0
- package/examples/board/source-def-handlers/copilot-source-handler.js +141 -0
- package/examples/board/source-def-handlers/http-source-handler.js +145 -0
- package/examples/board/source_def_flows.json +249 -0
- package/examples/board/test/demo-http-test.js +317 -0
- package/examples/{example-board → board-local}/demo-shell-localstorage.html +4 -4
- package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/handlers}/portfolio-tracker-fetch-prices.js +1 -1
- package/examples/{browser/boards/portfolio-tracker/portfolio-tracker-public.js → portfolio-tracker/portfolio-tracker.js} +11 -14
- package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/test}/portfolio-t4.js +32 -50
- package/lib/artifacts-store-lib-public-BABrgFkV.d.ts +119 -0
- package/lib/artifacts-store-lib-public-DGa8BpJT.d.cts +119 -0
- package/lib/artifacts-store-public.cjs +2 -0
- package/lib/artifacts-store-public.d.cts +5 -0
- package/lib/artifacts-store-public.d.ts +5 -0
- package/lib/artifacts-store-public.js +2 -0
- package/lib/board-live-cards-node.cjs +14 -0
- package/{dist/cli/node/execution-adapter.d.cts → lib/board-live-cards-node.d.cts} +45 -85
- package/lib/board-live-cards-node.d.ts +134 -0
- package/lib/board-live-cards-node.js +14 -0
- package/lib/board-live-cards-public-BnmRAbQV.d.cts +383 -0
- package/{dist/board-live-cards-public-CK_J8uv0.d.ts → lib/board-live-cards-public-CsmYrvpd.d.ts} +142 -76
- package/lib/board-live-cards-public.cjs +3 -0
- package/lib/board-live-cards-public.d.cts +4 -0
- package/lib/board-live-cards-public.d.ts +4 -0
- package/lib/board-live-cards-public.js +3 -0
- package/lib/board-live-cards-server-runtime.cjs +9 -0
- package/lib/board-live-cards-server-runtime.d.cts +6 -0
- package/lib/board-live-cards-server-runtime.d.ts +6 -0
- package/lib/board-live-cards-server-runtime.js +9 -0
- package/lib/board-livegraph-runtime/index.cjs +3 -0
- package/{dist → lib}/board-livegraph-runtime/index.d.cts +1 -2
- package/{dist → lib}/board-livegraph-runtime/index.d.ts +1 -2
- package/lib/board-livegraph-runtime/index.js +3 -0
- package/{dist/storage-refs.cjs → lib/board-worker-adapter.cjs} +2 -2
- package/{dist/storage-refs.d.cts → lib/board-worker-adapter.d.cts} +4 -3
- package/{dist/storage-refs.d.ts → lib/board-worker-adapter.d.ts} +4 -3
- package/{dist/storage-refs.js → lib/board-worker-adapter.js} +2 -2
- package/{dist → lib}/card-compute/index.cjs +1 -1
- package/{dist → lib}/card-compute/index.js +1 -1
- package/lib/card-store-public.cjs +2 -0
- package/lib/card-store-public.d.cts +61 -0
- package/lib/card-store-public.d.ts +61 -0
- package/lib/card-store-public.js +2 -0
- package/lib/card-validation.cjs +10 -0
- package/lib/card-validation.d.cts +35 -0
- package/lib/card-validation.d.ts +35 -0
- package/lib/card-validation.js +10 -0
- package/{dist/constants-oCEbNpul.d.ts → lib/constants-BPVLb3Es.d.ts} +1 -1
- package/{dist/constants-BzZUyYlp.d.cts → lib/constants-DXxsRN9y.d.cts} +1 -1
- package/{dist → lib}/continuous-event-graph/index.cjs +2 -2
- package/{dist → lib}/continuous-event-graph/index.d.cts +3 -5
- package/{dist → lib}/continuous-event-graph/index.d.ts +3 -5
- package/{dist → lib}/continuous-event-graph/index.js +2 -2
- package/{dist → lib}/event-graph/index.d.cts +2 -2
- package/{dist → lib}/event-graph/index.d.ts +2 -2
- package/{dist → lib}/execution-refs.d.cts +29 -10
- package/{dist → lib}/execution-refs.d.ts +29 -10
- package/lib/index.cjs +25 -0
- package/{dist → lib}/index.d.cts +7 -8
- package/{dist → lib}/index.d.ts +7 -8
- package/lib/index.js +25 -0
- package/{dist/live-cards-bridge-BXbVTsna.d.cts → lib/live-cards-bridge-DC_ZU0eS.d.ts} +134 -3
- package/{dist/live-cards-bridge-Ds28XR15.d.ts → lib/live-cards-bridge-b25aAVvE.d.cts} +134 -3
- package/lib/loader-CuuLjxVA.d.cts +42 -0
- package/lib/loader-Zborm2pq.d.ts +42 -0
- package/lib/server-runtime/index.cjs +9 -0
- package/{dist → lib}/server-runtime/index.d.cts +4 -4
- package/{dist → lib}/server-runtime/index.d.ts +4 -4
- package/lib/server-runtime/index.js +9 -0
- package/lib/step-machine/index.d.cts +64 -0
- package/lib/step-machine/index.d.ts +64 -0
- package/lib/step-machine-public/index.cjs +5 -0
- package/{dist → lib}/step-machine-public/index.d.cts +14 -1
- package/{dist → lib}/step-machine-public/index.d.ts +14 -1
- package/lib/step-machine-public/index.js +5 -0
- package/lib/storage-interface-BhAON-gW.d.cts +84 -0
- package/lib/storage-interface-BhAON-gW.d.ts +84 -0
- package/lib/stores/index.cjs +3 -0
- package/lib/stores/index.d.cts +4 -0
- package/lib/stores/index.d.ts +4 -0
- package/lib/stores/index.js +3 -0
- package/lib/stores/kv.cjs +3 -0
- package/lib/stores/kv.d.cts +32 -0
- package/lib/stores/kv.d.ts +32 -0
- package/lib/stores/kv.js +3 -0
- package/{dist → lib}/stores/memory.d.cts +1 -1
- package/{dist → lib}/stores/memory.d.ts +1 -1
- package/{dist/types-HGDTWIun.d.ts → lib/types-CBxkYuLY.d.ts} +2 -1
- package/{dist/types-ycun84cq.d.cts → lib/types-DQ1bKuB1.d.cts} +11 -0
- package/{dist/types-ycun84cq.d.ts → lib/types-DQ1bKuB1.d.ts} +11 -0
- package/{dist/types-CU3DjTKL.d.cts → lib/types-DkFvgxwq.d.cts} +2 -1
- package/package.json +79 -119
- package/board-live-cards-cli.js +0 -37
- package/browser/board-livecards-client.js.map +0 -1
- package/browser/board-livecards-localstorage.js.map +0 -1
- package/browser/board-livegraph-engine.js +0 -3
- package/browser/board-livegraph-engine.js.map +0 -1
- package/browser/card-compute.js +0 -266
- package/browser/compute-jsonata.js.map +0 -1
- package/card-store.js +0 -37
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.js.map +0 -1
- package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +0 -136
- package/dist/board-live-cards-lib-jM2uYG1v.d.ts +0 -136
- package/dist/board-livegraph-runtime/index.cjs +0 -3
- package/dist/board-livegraph-runtime/index.cjs.map +0 -1
- package/dist/board-livegraph-runtime/index.js +0 -3
- package/dist/board-livegraph-runtime/index.js.map +0 -1
- package/dist/card-compute/index.cjs.map +0 -1
- package/dist/card-compute/index.js.map +0 -1
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +0 -3
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +0 -1
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +0 -37
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +0 -1
- package/dist/cli/browser-api/card-store-browser-api.cjs +0 -2
- package/dist/cli/browser-api/card-store-browser-api.cjs.map +0 -1
- package/dist/cli/browser-api/card-store-browser-api.d.cts +0 -26
- package/dist/cli/browser-api/card-store-browser-api.js.map +0 -1
- package/dist/cli/node/artifacts-store-cli.cjs +0 -11
- package/dist/cli/node/artifacts-store-cli.cjs.map +0 -1
- package/dist/cli/node/artifacts-store-cli.d.cts +0 -8
- package/dist/cli/node/artifacts-store-cli.js.map +0 -1
- package/dist/cli/node/board-live-cards-cli.cjs +0 -15
- package/dist/cli/node/board-live-cards-cli.cjs.map +0 -1
- package/dist/cli/node/board-live-cards-cli.d.cts +0 -20
- package/dist/cli/node/board-live-cards-cli.js +0 -15
- package/dist/cli/node/board-live-cards-cli.js.map +0 -1
- package/dist/cli/node/card-store-cli.cjs +0 -8
- package/dist/cli/node/card-store-cli.cjs.map +0 -1
- package/dist/cli/node/card-store-cli.d.cts +0 -15
- package/dist/cli/node/card-store-cli.js.map +0 -1
- package/dist/cli/node/execution-adapter.cjs +0 -3
- package/dist/cli/node/execution-adapter.cjs.map +0 -1
- package/dist/cli/node/execution-adapter.js +0 -3
- package/dist/cli/node/execution-adapter.js.map +0 -1
- package/dist/cli/node/fs-board-adapter.cjs +0 -14
- package/dist/cli/node/fs-board-adapter.cjs.map +0 -1
- package/dist/cli/node/fs-board-adapter.d.cts +0 -204
- package/dist/cli/node/fs-board-adapter.js +0 -14
- package/dist/cli/node/fs-board-adapter.js.map +0 -1
- package/dist/cli/node/source-cli-task-executor.cjs +0 -11
- package/dist/cli/node/source-cli-task-executor.cjs.map +0 -1
- package/dist/cli/node/source-cli-task-executor.js.map +0 -1
- package/dist/config/index.cjs.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/continuous-event-graph/index.cjs.map +0 -1
- package/dist/continuous-event-graph/index.js.map +0 -1
- package/dist/event-graph/index.cjs.map +0 -1
- package/dist/event-graph/index.js.map +0 -1
- package/dist/execution-refs.cjs.map +0 -1
- package/dist/execution-refs.js.map +0 -1
- package/dist/index.cjs +0 -30
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/inference/index.cjs +0 -7
- package/dist/inference/index.cjs.map +0 -1
- package/dist/inference/index.d.cts +0 -229
- package/dist/inference/index.d.ts +0 -229
- package/dist/inference/index.js +0 -7
- package/dist/inference/index.js.map +0 -1
- package/dist/server-runtime/index.cjs +0 -9
- package/dist/server-runtime/index.cjs.map +0 -1
- package/dist/server-runtime/index.js +0 -9
- package/dist/server-runtime/index.js.map +0 -1
- package/dist/step-machine/index.cjs.map +0 -1
- package/dist/step-machine/index.d.cts +0 -102
- package/dist/step-machine/index.d.ts +0 -102
- package/dist/step-machine/index.js.map +0 -1
- package/dist/step-machine-public/index.cjs +0 -3
- package/dist/step-machine-public/index.cjs.map +0 -1
- package/dist/step-machine-public/index.js +0 -3
- package/dist/step-machine-public/index.js.map +0 -1
- package/dist/storage-refs.cjs.map +0 -1
- package/dist/storage-refs.js.map +0 -1
- package/dist/stores/file.cjs +0 -2
- package/dist/stores/file.cjs.map +0 -1
- package/dist/stores/file.d.cts +0 -36
- package/dist/stores/file.d.ts +0 -36
- package/dist/stores/file.js +0 -2
- package/dist/stores/file.js.map +0 -1
- package/dist/stores/index.cjs +0 -2
- package/dist/stores/index.cjs.map +0 -1
- package/dist/stores/index.d.cts +0 -4
- package/dist/stores/index.d.ts +0 -4
- package/dist/stores/index.js +0 -2
- package/dist/stores/index.js.map +0 -1
- package/dist/stores/localStorage.cjs +0 -2
- package/dist/stores/localStorage.cjs.map +0 -1
- package/dist/stores/localStorage.d.cts +0 -34
- package/dist/stores/localStorage.d.ts +0 -34
- package/dist/stores/localStorage.js +0 -2
- package/dist/stores/localStorage.js.map +0 -1
- package/dist/stores/memory.cjs.map +0 -1
- package/dist/stores/memory.js.map +0 -1
- package/dist/types-CHSdoAAA.d.cts +0 -135
- package/dist/types-CoW0gQl3.d.ts +0 -135
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +0 -201
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +0 -370
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.py +0 -398
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +0 -196
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +0 -300
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +0 -617
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +0 -366
- package/examples/browser/livecards-browser/index.html +0 -41
- package/examples/browser/step-machine-browser/index.html +0 -367
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +0 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +0 -32
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -125
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -32
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -26
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +0 -49
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -25
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -23
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -21
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -38
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -48
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -31
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +0 -107
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +0 -51
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +0 -45
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +0 -71
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +0 -36
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +0 -26
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +0 -39
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +0 -80
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -76
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -44
- package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +0 -43
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +0 -77
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
- package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +0 -31
- package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +0 -54
- package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +0 -21
- package/examples/cli/step-machine-demo/step-cli-echo-y.js +0 -15
- package/examples/cli/step-machine-demo/step2-double-cli.js +0 -33
- package/examples/cli/step-machine-demo/two-step-math.flow.yaml +0 -93
- package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +0 -43
- package/examples/example-board/agent-instructions-cardlayout.md +0 -56
- package/examples/example-board/agent-instructions.md +0 -834
- package/examples/example-board/demo-shell.html +0 -63
- package/examples/index.html +0 -785
- package/examples/npm-libs/batch/batch-step-machine.ts +0 -121
- package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +0 -215
- package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +0 -555
- package/examples/npm-libs/continuous-event-graph/portfolio-tracker.ts +0 -287
- package/examples/npm-libs/continuous-event-graph/reactive-monitoring.ts +0 -265
- package/examples/npm-libs/continuous-event-graph/reactive-pipeline.ts +0 -168
- package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +0 -287
- package/examples/npm-libs/continuous-event-graph/stock-dashboard.ts +0 -229
- package/examples/npm-libs/event-graph/ci-cd-pipeline.ts +0 -243
- package/examples/npm-libs/event-graph/executor-diamond.ts +0 -165
- package/examples/npm-libs/event-graph/executor-pipeline.ts +0 -161
- package/examples/npm-libs/event-graph/research-pipeline.ts +0 -137
- package/examples/npm-libs/flows/ai-conversation.yaml +0 -116
- package/examples/npm-libs/flows/order-processing.yaml +0 -143
- package/examples/npm-libs/flows/simple-greeting.yaml +0 -54
- package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +0 -307
- package/examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts +0 -254
- package/examples/npm-libs/inference/azure-deployment.ts +0 -149
- package/examples/npm-libs/inference/copilot-cli.ts +0 -138
- package/examples/npm-libs/inference/data-pipeline.ts +0 -145
- package/examples/npm-libs/inference/pluggable-adapters.ts +0 -254
- package/examples/npm-libs/node/ai-conversation.ts +0 -195
- package/examples/npm-libs/node/simple-greeting.ts +0 -101
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -57
- package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -27
- package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -25
- package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -29
- package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -27
- package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -25
- package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -37
- package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -53
- package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -35
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -227
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -38
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
- package/step-machine-cli.js +0 -407
- /package/{dist/cli → cli}/browser-api/board-live-cards-browser-adapter.js +0 -0
- /package/{dist/board-livegraph-runtime → cli/browser-api}/jsonata-sync.cjs +0 -0
- /package/{dist/cli → cli}/node/artifacts-store-cli.d.ts +0 -0
- /package/{dist/cli/node/source-cli-task-executor.d.cts → cli/node/batch-runner-cli.d.ts} +0 -0
- /package/{dist/cli → cli}/node/board-live-cards-cli.d.ts +0 -0
- /package/{dist/cli → cli}/node/card-store-cli.d.ts +0 -0
- /package/{dist/cli → cli}/node/card-store-cli.js +0 -0
- /package/{dist/card-compute → cli/node}/jsonata-sync.cjs +0 -0
- /package/{dist/cli → cli}/node/source-cli-task-executor.d.ts +0 -0
- /package/{dist/cli → cli}/node/source-cli-task-executor.js +0 -0
- /package/examples/{example-board → board}/cards/card-concentration.json +0 -0
- /package/examples/{example-board → board}/cards/card-my-identity.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-action.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-intelligence.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-risks.json +0 -0
- /package/examples/{example-board → board}/cards/card-rebalance-impact.json +0 -0
- /package/examples/{example-board → board}/cards/card-rebalance-sim.json +0 -0
- /package/examples/{example-board → board}/cards/cardT-market-prices.json +0 -0
- /package/examples/{example-board → board}/cards/cardT-portfolio-value.json +0 -0
- /package/examples/{example-board → board}/cards/cardT-portfolio.json +0 -0
- /package/examples/{example-board → board}/demo-chat-handler.js +0 -0
- /package/examples/{example-board → board}/scripts/copilot_wrapper.bat +0 -0
- /package/examples/{example-board → board}/scripts/copilot_wrapper_helper.ps1 +0 -0
- /package/examples/{example-board → board}/scripts/workiq_wrapper.mjs +0 -0
- /package/examples/{browser/boards/portfolio-tracker → board/test}/portfolio-tracker-sse-worker.js +0 -0
- /package/{dist → lib}/batch/index.cjs +0 -0
- /package/{dist → lib}/batch/index.d.cts +0 -0
- /package/{dist → lib}/batch/index.d.ts +0 -0
- /package/{dist → lib}/batch/index.js +0 -0
- /package/{dist/cli/browser-api → lib/board-livegraph-runtime}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/card-compute/index.d.cts +0 -0
- /package/{dist → lib}/card-compute/index.d.ts +0 -0
- /package/{dist/cli/node → lib/card-compute}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/config/index.cjs +0 -0
- /package/{dist → lib}/config/index.d.cts +0 -0
- /package/{dist → lib}/config/index.d.ts +0 -0
- /package/{dist → lib}/config/index.js +0 -0
- /package/{dist → lib}/continuous-event-graph/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/event-graph/index.cjs +0 -0
- /package/{dist → lib}/event-graph/index.js +0 -0
- /package/{dist → lib}/execution-refs.cjs +0 -0
- /package/{dist → lib}/execution-refs.js +0 -0
- /package/{dist → lib}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/server-runtime/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/step-machine/index.cjs +0 -0
- /package/{dist → lib}/step-machine/index.js +0 -0
- /package/{dist → lib}/step-machine-public/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/stores/memory.cjs +0 -0
- /package/{dist → lib}/stores/memory.js +0 -0
- /package/{dist → lib}/types-BBhqYGhE.d.cts +0 -0
- /package/{dist → lib}/types-BBhqYGhE.d.ts +0 -0
- /package/{dist → lib}/validate-BAVzUJWa.d.ts +0 -0
- /package/{dist → lib}/validate-Dbu7ygys.d.cts +0 -0
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""portfolio-tracker-http-test.py
|
|
3
|
-
|
|
4
|
-
E2E test for the portfolio-tracker board via HTTP + SSE.
|
|
5
|
-
|
|
6
|
-
Architecture mirrors portfolio-tracker-http-test.js:
|
|
7
|
-
- background SSE consumer thread accumulates NotificationState (NS)
|
|
8
|
-
- main thread drives HTTP PATCH/GET and polls NS for waits
|
|
9
|
-
|
|
10
|
-
Usage:
|
|
11
|
-
python portfolio-tracker-http-test.py [--port 7801] [--server node|py]
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
from __future__ import annotations
|
|
15
|
-
|
|
16
|
-
import argparse
|
|
17
|
-
import json
|
|
18
|
-
import os
|
|
19
|
-
import socket
|
|
20
|
-
import subprocess
|
|
21
|
-
import sys
|
|
22
|
-
import threading
|
|
23
|
-
import time
|
|
24
|
-
import urllib.error
|
|
25
|
-
import urllib.request
|
|
26
|
-
from pathlib import Path
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
HERE = Path(__file__).resolve().parent
|
|
30
|
-
SERVER_SCRIPT = HERE / "portfolio-tracker-server.js"
|
|
31
|
-
PY_SERVER_SCRIPT = HERE / "portfolio-tracker-server.py"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def parse_args() -> argparse.Namespace:
|
|
35
|
-
parser = argparse.ArgumentParser()
|
|
36
|
-
parser.add_argument("--port", type=int, default=None)
|
|
37
|
-
parser.add_argument("--server", choices=["node", "py"], default="py")
|
|
38
|
-
return parser.parse_args()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ARGS = parse_args()
|
|
42
|
-
PORT = ARGS.port if ARGS.port is not None else (7801 if ARGS.server == "py" else 7800)
|
|
43
|
-
BASE = f"http://127.0.0.1:{PORT}/api/board"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class TestFailure(RuntimeError):
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def assert_true(condition: bool, message: str) -> None:
|
|
51
|
-
if not condition:
|
|
52
|
-
raise TestFailure(message)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
NS_LOCK = threading.Lock()
|
|
56
|
-
NS = {
|
|
57
|
-
"initialPayload": None,
|
|
58
|
-
"statusSummary": None,
|
|
59
|
-
"statusGeneration": 0,
|
|
60
|
-
"dataObjects": {},
|
|
61
|
-
"computedValues": {},
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def apply_frame(payload: dict) -> None:
|
|
66
|
-
with NS_LOCK:
|
|
67
|
-
if isinstance(payload, dict) and payload.get("cardDefinitions") is not None:
|
|
68
|
-
NS["initialPayload"] = payload
|
|
69
|
-
status = payload.get("statusSnapshot") or {}
|
|
70
|
-
if isinstance(status, dict) and isinstance(status.get("summary"), dict):
|
|
71
|
-
NS["statusSummary"] = status["summary"]
|
|
72
|
-
NS["statusGeneration"] += 1
|
|
73
|
-
|
|
74
|
-
dot = payload.get("dataObjectsByToken")
|
|
75
|
-
if isinstance(dot, dict):
|
|
76
|
-
NS["dataObjects"].update(dot)
|
|
77
|
-
|
|
78
|
-
runtimes = payload.get("cardRuntimeById")
|
|
79
|
-
if isinstance(runtimes, dict):
|
|
80
|
-
for card_id, runtime in runtimes.items():
|
|
81
|
-
if not isinstance(runtime, dict):
|
|
82
|
-
continue
|
|
83
|
-
cv = runtime.get("computed_values")
|
|
84
|
-
if isinstance(cv, dict) and cv:
|
|
85
|
-
NS["computedValues"][card_id] = cv
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
isinstance(payload, dict)
|
|
90
|
-
and payload.get("kind") == "notification-batch"
|
|
91
|
-
and isinstance(payload.get("notifications"), list)
|
|
92
|
-
):
|
|
93
|
-
for note in payload["notifications"]:
|
|
94
|
-
if not isinstance(note, dict):
|
|
95
|
-
continue
|
|
96
|
-
kind = note.get("kind")
|
|
97
|
-
if kind == "status" and isinstance((note.get("status") or {}).get("summary"), dict):
|
|
98
|
-
NS["statusSummary"] = note["status"]["summary"]
|
|
99
|
-
NS["statusGeneration"] += 1
|
|
100
|
-
elif kind == "data_object" and isinstance(note.get("key"), str):
|
|
101
|
-
NS["dataObjects"][note["key"]] = note.get("payload")
|
|
102
|
-
elif kind == "computed_values" and isinstance(note.get("cardId"), str):
|
|
103
|
-
NS["computedValues"][note["cardId"]] = note.get("values")
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def get_ns_snapshot() -> dict:
|
|
107
|
-
with NS_LOCK:
|
|
108
|
-
return {
|
|
109
|
-
"initialPayload": NS["initialPayload"],
|
|
110
|
-
"statusSummary": NS["statusSummary"],
|
|
111
|
-
"statusGeneration": NS["statusGeneration"],
|
|
112
|
-
"dataObjects": dict(NS["dataObjects"]),
|
|
113
|
-
"computedValues": dict(NS["computedValues"]),
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def wait_until(predicate, timeout_s: float, label: str):
|
|
118
|
-
deadline = time.monotonic() + timeout_s
|
|
119
|
-
while time.monotonic() < deadline:
|
|
120
|
-
try:
|
|
121
|
-
result = predicate()
|
|
122
|
-
except Exception:
|
|
123
|
-
result = None
|
|
124
|
-
if result not in (None, False):
|
|
125
|
-
return result
|
|
126
|
-
time.sleep(0.15)
|
|
127
|
-
|
|
128
|
-
snap = get_ns_snapshot()
|
|
129
|
-
raise TestFailure(
|
|
130
|
-
f"Timeout ({timeout_s}s) waiting for: {label}\n"
|
|
131
|
-
f" NS.statusSummary={json.dumps(snap['statusSummary'])}\n"
|
|
132
|
-
f" dataObjects={json.dumps(sorted(snap['dataObjects'].keys()))}"
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def wait_for_initial_payload(timeout_s: float = 15.0):
|
|
137
|
-
return wait_until(lambda: get_ns_snapshot()["initialPayload"], timeout_s, "initial SSE payload")
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def wait_for_all_completed(timeout_s: float = 60.0, label: str = "all completed"):
|
|
141
|
-
def _pred():
|
|
142
|
-
s = get_ns_snapshot()["statusSummary"]
|
|
143
|
-
if isinstance(s, dict) and s.get("card_count", 0) > 0 and s.get("completed") == s.get("card_count"):
|
|
144
|
-
return s
|
|
145
|
-
return False
|
|
146
|
-
|
|
147
|
-
return wait_until(_pred, timeout_s, label)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def wait_for_price_symbols(expected_symbols: list[str], timeout_s: float = 30.0, label: str = "price symbols"):
|
|
151
|
-
expected = ",".join(sorted(expected_symbols))
|
|
152
|
-
|
|
153
|
-
def _pred():
|
|
154
|
-
prices = get_ns_snapshot()["dataObjects"].get("prices")
|
|
155
|
-
if not isinstance(prices, dict):
|
|
156
|
-
return False
|
|
157
|
-
actual = ",".join(sorted(prices.keys()))
|
|
158
|
-
return prices if actual == expected else False
|
|
159
|
-
|
|
160
|
-
return wait_until(_pred, timeout_s, f"{label}: expected [{expected}]")
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def http_json(method: str, path: str, payload: dict | None = None) -> tuple[int, object]:
|
|
164
|
-
data = None
|
|
165
|
-
headers = {}
|
|
166
|
-
if payload is not None:
|
|
167
|
-
data = json.dumps(payload).encode("utf-8")
|
|
168
|
-
headers = {
|
|
169
|
-
"Content-Type": "application/json",
|
|
170
|
-
"Content-Length": str(len(data)),
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
req = urllib.request.Request(f"{BASE}{path}", data=data, method=method.upper(), headers=headers)
|
|
174
|
-
try:
|
|
175
|
-
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
176
|
-
raw = resp.read().decode("utf-8")
|
|
177
|
-
try:
|
|
178
|
-
body = json.loads(raw) if raw else {}
|
|
179
|
-
except json.JSONDecodeError:
|
|
180
|
-
body = raw
|
|
181
|
-
return resp.status, body
|
|
182
|
-
except urllib.error.HTTPError as e:
|
|
183
|
-
raw = e.read().decode("utf-8", errors="replace")
|
|
184
|
-
try:
|
|
185
|
-
body = json.loads(raw)
|
|
186
|
-
except json.JSONDecodeError:
|
|
187
|
-
body = raw
|
|
188
|
-
return e.code, body
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
def make_holdings_patch(holdings_map: dict[str, int]) -> dict:
|
|
192
|
-
return {
|
|
193
|
-
"card_data": {
|
|
194
|
-
"holdings": [{"symbol": symbol, "qty": qty} for symbol, qty in holdings_map.items()]
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
def start_server() -> subprocess.Popen:
|
|
200
|
-
if ARGS.server == "py":
|
|
201
|
-
python = sys.executable or "python"
|
|
202
|
-
cmd = [python, str(PY_SERVER_SCRIPT), "--port", str(PORT), "--reset"]
|
|
203
|
-
else:
|
|
204
|
-
cmd = ["node", str(SERVER_SCRIPT), "--port", str(PORT), "--reset"]
|
|
205
|
-
|
|
206
|
-
proc = subprocess.Popen(
|
|
207
|
-
cmd,
|
|
208
|
-
stdin=subprocess.DEVNULL,
|
|
209
|
-
stdout=subprocess.PIPE,
|
|
210
|
-
stderr=subprocess.PIPE,
|
|
211
|
-
text=True,
|
|
212
|
-
bufsize=1,
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
def _pump_stdout():
|
|
216
|
-
assert proc.stdout is not None
|
|
217
|
-
for line in proc.stdout:
|
|
218
|
-
print(f"[server] {line}", end="")
|
|
219
|
-
|
|
220
|
-
def _pump_stderr():
|
|
221
|
-
assert proc.stderr is not None
|
|
222
|
-
for line in proc.stderr:
|
|
223
|
-
print(f"[server:err] {line}", end="", file=sys.stderr)
|
|
224
|
-
|
|
225
|
-
threading.Thread(target=_pump_stdout, daemon=True).start()
|
|
226
|
-
threading.Thread(target=_pump_stderr, daemon=True).start()
|
|
227
|
-
|
|
228
|
-
deadline = time.monotonic() + 15
|
|
229
|
-
ready = False
|
|
230
|
-
while time.monotonic() < deadline:
|
|
231
|
-
if proc.poll() is not None:
|
|
232
|
-
break
|
|
233
|
-
try:
|
|
234
|
-
with socket.create_connection(("127.0.0.1", PORT), timeout=0.5):
|
|
235
|
-
ready = True
|
|
236
|
-
break
|
|
237
|
-
except OSError:
|
|
238
|
-
time.sleep(0.2)
|
|
239
|
-
|
|
240
|
-
if not ready:
|
|
241
|
-
proc.terminate()
|
|
242
|
-
raise TestFailure("Server startup timeout (15s)")
|
|
243
|
-
|
|
244
|
-
return proc
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def start_sse_consumer(stop_event: threading.Event) -> threading.Thread:
|
|
248
|
-
def _run():
|
|
249
|
-
req = urllib.request.Request(f"{BASE}/sse", headers={"Accept": "text/event-stream"})
|
|
250
|
-
try:
|
|
251
|
-
with urllib.request.urlopen(req, timeout=60) as resp:
|
|
252
|
-
block_lines: list[str] = []
|
|
253
|
-
while not stop_event.is_set():
|
|
254
|
-
raw = resp.readline()
|
|
255
|
-
if not raw:
|
|
256
|
-
break
|
|
257
|
-
line = raw.decode("utf-8", errors="replace").rstrip("\r\n")
|
|
258
|
-
if line == "":
|
|
259
|
-
data_lines = [l[6:] for l in block_lines if l.startswith("data: ")]
|
|
260
|
-
block_lines = []
|
|
261
|
-
if not data_lines:
|
|
262
|
-
continue
|
|
263
|
-
data_text = "\n".join(data_lines)
|
|
264
|
-
try:
|
|
265
|
-
payload = json.loads(data_text)
|
|
266
|
-
except json.JSONDecodeError:
|
|
267
|
-
continue
|
|
268
|
-
apply_frame(payload)
|
|
269
|
-
else:
|
|
270
|
-
block_lines.append(line)
|
|
271
|
-
except Exception as err:
|
|
272
|
-
if not stop_event.is_set():
|
|
273
|
-
print(f"[sse] error: {err}", file=sys.stderr)
|
|
274
|
-
|
|
275
|
-
th = threading.Thread(target=_run, daemon=True)
|
|
276
|
-
th.start()
|
|
277
|
-
return th
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
def run() -> None:
|
|
281
|
-
print("\n=== portfolio-tracker HTTP E2E test (python) ===")
|
|
282
|
-
print(f"target: {BASE} [server: {ARGS.server}]")
|
|
283
|
-
print("architecture: main-thread (driver) + background SSE consumer\n")
|
|
284
|
-
|
|
285
|
-
server_proc = start_server()
|
|
286
|
-
time.sleep(0.3)
|
|
287
|
-
|
|
288
|
-
sse_stop = threading.Event()
|
|
289
|
-
try:
|
|
290
|
-
print("\n=== Step 1: init-board ===")
|
|
291
|
-
status, _ = http_json("GET", "/init-board")
|
|
292
|
-
assert_true(status == 200, f"init-board returned {status}")
|
|
293
|
-
print("[step1] ok")
|
|
294
|
-
|
|
295
|
-
print("\n=== Step 2: Start SSE consumer ===")
|
|
296
|
-
start_sse_consumer(sse_stop)
|
|
297
|
-
initial_payload = wait_for_initial_payload(15.0)
|
|
298
|
-
snap = get_ns_snapshot()
|
|
299
|
-
print(f"[step2] SSE online — initial payload ({len(initial_payload.get('cardDefinitions', []))} cards)")
|
|
300
|
-
print(f" statusGen={snap['statusGeneration']}, dataObjects={json.dumps(sorted(snap['dataObjects'].keys()))}")
|
|
301
|
-
|
|
302
|
-
print("\n=== T1: Wait for initial completion ===")
|
|
303
|
-
t1_summary = wait_for_all_completed(60.0, "T1 initial drain")
|
|
304
|
-
print(f"[T1] board completed — {json.dumps(t1_summary)}")
|
|
305
|
-
|
|
306
|
-
t1_prices = wait_for_price_symbols(["AAPL", "MSFT"], 30.0, "T1 prices")
|
|
307
|
-
assert_true(all(isinstance(v, (int, float)) for v in t1_prices.values()), "T1: all prices must be numbers")
|
|
308
|
-
t1_table = (get_ns_snapshot()["computedValues"].get("holdings-table") or {}).get("table")
|
|
309
|
-
assert_true(isinstance(t1_table, dict) and isinstance(t1_table.get("rows"), list) and len(t1_table["rows"]) == 2,
|
|
310
|
-
f"T1: expected 2 rows, got {len(t1_table.get('rows', [])) if isinstance(t1_table, dict) else 'n/a'}")
|
|
311
|
-
t1_total = (get_ns_snapshot()["computedValues"].get("portfolio-value") or {}).get("totalValue")
|
|
312
|
-
assert_true(isinstance(t1_total, (int, float)) and t1_total > 0, f"T1: totalValue must be positive, got {t1_total}")
|
|
313
|
-
print(f"[T1] passed: prices=[AAPL,MSFT], rows=2, totalValue={float(t1_total):.2f}")
|
|
314
|
-
|
|
315
|
-
print("\n=== T2a: Update holdings — add GOOG ===")
|
|
316
|
-
status, _ = http_json("PATCH", "/cards/portfolio-form", make_holdings_patch({"AAPL": 50, "MSFT": 30, "GOOG": 100}))
|
|
317
|
-
assert_true(status == 200, f"PATCH portfolio-form returned {status}")
|
|
318
|
-
print("[T2a] PATCH ok — consumer will receive SSE notifications")
|
|
319
|
-
|
|
320
|
-
print("\n=== T2b: Wait for 3-ticker completion ===")
|
|
321
|
-
t2_summary = wait_for_all_completed(60.0, "T2b 3-ticker drain")
|
|
322
|
-
print(f"[T2b] completed — {json.dumps(t2_summary)}")
|
|
323
|
-
|
|
324
|
-
wait_for_price_symbols(["AAPL", "GOOG", "MSFT"], 30.0, "T2b prices")
|
|
325
|
-
t2_table = (get_ns_snapshot()["computedValues"].get("holdings-table") or {}).get("table")
|
|
326
|
-
assert_true(isinstance(t2_table, dict) and isinstance(t2_table.get("rows"), list) and len(t2_table["rows"]) == 3,
|
|
327
|
-
f"T2b: expected 3 rows, got {len(t2_table.get('rows', [])) if isinstance(t2_table, dict) else 'n/a'}")
|
|
328
|
-
t2_total = (get_ns_snapshot()["computedValues"].get("portfolio-value") or {}).get("totalValue")
|
|
329
|
-
assert_true(isinstance(t2_total, (int, float)) and t2_total > 0, "T2b: totalValue must be positive")
|
|
330
|
-
print(f"[T2b] passed: prices=[AAPL,GOOG,MSFT], rows=3, totalValue={float(t2_total):.2f}")
|
|
331
|
-
|
|
332
|
-
print("\n=== T3: Rapid 3x holdings updates ===")
|
|
333
|
-
rapid_updates = [
|
|
334
|
-
{"AAPL": 45, "MSFT": 30, "GOOG": 110, "TSLA": 60},
|
|
335
|
-
{"AAPL": 45, "MSFT": 30, "GOOG": 110, "AMZN": 100},
|
|
336
|
-
{"AAPL": 40, "MSFT": 35, "GOOG": 120, "TSLA": 70},
|
|
337
|
-
]
|
|
338
|
-
for holdings in rapid_updates:
|
|
339
|
-
http_json("PATCH", "/cards/portfolio-form", make_holdings_patch(holdings))
|
|
340
|
-
print("[T3] rapid PATCHes sent — SSE state continues to accumulate")
|
|
341
|
-
|
|
342
|
-
wait_for_all_completed(60.0, "T3 rapid-update drain")
|
|
343
|
-
t3_prices = wait_for_price_symbols(["AAPL", "GOOG", "MSFT", "TSLA"], 30.0, "T3 final prices")
|
|
344
|
-
t3_table = (get_ns_snapshot()["computedValues"].get("holdings-table") or {}).get("table")
|
|
345
|
-
assert_true(isinstance(t3_table, dict) and isinstance(t3_table.get("rows"), list) and len(t3_table["rows"]) == 4,
|
|
346
|
-
f"T3: expected 4 rows, got {len(t3_table.get('rows', [])) if isinstance(t3_table, dict) else 'n/a'}")
|
|
347
|
-
assert_true("AMZN" not in t3_prices, f"T3: AMZN must not be present (got {json.dumps(sorted(t3_prices.keys()))})")
|
|
348
|
-
print(f"[T3] passed: prices={json.dumps(sorted(t3_prices.keys()))}, rows=4, AMZN absent")
|
|
349
|
-
|
|
350
|
-
print("\n=== T4: Cross-verify totalValue ===")
|
|
351
|
-
t4_total = (get_ns_snapshot()["computedValues"].get("portfolio-value") or {}).get("totalValue")
|
|
352
|
-
assert_true(isinstance(t4_total, (int, float)) and t4_total > 0, f"T4: totalValue must be positive, got {t4_total}")
|
|
353
|
-
sum_rows = sum(float(r.get("value", 0)) for r in t3_table["rows"])
|
|
354
|
-
assert_true(abs(sum_rows - float(t4_total)) < 0.01, f"T4: mismatch: sumRows={sum_rows}, totalValue={t4_total}")
|
|
355
|
-
print(f"[T4] passed: totalValue={float(t4_total):.2f}, sumRows={sum_rows:.2f}")
|
|
356
|
-
|
|
357
|
-
print("\n=== T5: board-status HTTP cross-check ===")
|
|
358
|
-
status, t5_body = http_json("GET", "/board-status")
|
|
359
|
-
assert_true(status == 200, f"board-status returned {status}")
|
|
360
|
-
assert_true(isinstance(t5_body, dict), "T5: board-status body is not JSON object")
|
|
361
|
-
t5_summary = ((t5_body.get("statusSnapshot") or {}).get("summary") if isinstance(t5_body, dict) else None)
|
|
362
|
-
assert_true(isinstance(t5_summary, dict), "T5: statusSnapshot.summary missing from board-status")
|
|
363
|
-
assert_true(t5_summary.get("completed") == t5_summary.get("card_count"),
|
|
364
|
-
f"T5: completed={t5_summary.get('completed')} != card_count={t5_summary.get('card_count')}")
|
|
365
|
-
assert_true(t5_summary.get("failed") == 0, f"T5: failed={t5_summary.get('failed')} (expected 0)")
|
|
366
|
-
|
|
367
|
-
http_keys = sorted(((t5_body.get("dataObjectsByToken") or {}).keys()))
|
|
368
|
-
worker_keys = sorted(get_ns_snapshot()["dataObjects"].keys())
|
|
369
|
-
assert_true(http_keys == worker_keys,
|
|
370
|
-
f"T5: HTTP dataObjects keys {http_keys} differ from SSE-accumulated {worker_keys}")
|
|
371
|
-
|
|
372
|
-
print(f"[T5] summary: {json.dumps(t5_summary)}")
|
|
373
|
-
print(f"[T5] HTTP vs SSE dataObjects agree: {json.dumps(worker_keys)}")
|
|
374
|
-
print(f"[T5] statusGen at end: {get_ns_snapshot()['statusGeneration']}")
|
|
375
|
-
print("[T5] all assertions passed")
|
|
376
|
-
|
|
377
|
-
print("\n=== All tests passed ===\n")
|
|
378
|
-
|
|
379
|
-
finally:
|
|
380
|
-
sse_stop.set()
|
|
381
|
-
server_proc.terminate()
|
|
382
|
-
try:
|
|
383
|
-
server_proc.wait(timeout=10)
|
|
384
|
-
except subprocess.TimeoutExpired:
|
|
385
|
-
server_proc.kill()
|
|
386
|
-
server_proc.wait(timeout=5)
|
|
387
|
-
print(f"[portfolio-tracker-http-test.py] server stopped ({ARGS.server})")
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if __name__ == "__main__":
|
|
391
|
-
try:
|
|
392
|
-
run()
|
|
393
|
-
except TestFailure as e:
|
|
394
|
-
print(f"\n[ASSERT FAILED] {e}", file=sys.stderr)
|
|
395
|
-
sys.exit(1)
|
|
396
|
-
except KeyboardInterrupt:
|
|
397
|
-
print("\nInterrupted.", file=sys.stderr)
|
|
398
|
-
sys.exit(130)
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import * as fs from 'node:fs';
|
|
5
|
-
import { parseRef, blobStorageForRef } from 'yaml-flow/storage-refs';
|
|
6
|
-
|
|
7
|
-
function parseArgs(argv) {
|
|
8
|
-
const inIdx = argv.indexOf('--in-ref');
|
|
9
|
-
const outIdx = argv.indexOf('--out-ref');
|
|
10
|
-
const errIdx = argv.indexOf('--err-ref');
|
|
11
|
-
const inRefStr = inIdx !== -1 ? argv[inIdx + 1] : undefined;
|
|
12
|
-
const outRefStr = outIdx !== -1 ? argv[outIdx + 1] : undefined;
|
|
13
|
-
const errRefStr = errIdx !== -1 ? argv[errIdx + 1] : undefined;
|
|
14
|
-
if (!inRefStr || !outRefStr || !errRefStr) {
|
|
15
|
-
console.error('Usage: <adapter> run-inference --in-ref <::kind::value> --out-ref <::kind::value> --err-ref <::kind::value>');
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const inRef = parseRef(inRefStr);
|
|
19
|
-
const outRef = parseRef(outRefStr);
|
|
20
|
-
const errRef = parseRef(errRefStr);
|
|
21
|
-
const inStorage = blobStorageForRef(inRef);
|
|
22
|
-
const outStorage = blobStorageForRef(outRef);
|
|
23
|
-
const errStorage = blobStorageForRef(errRef);
|
|
24
|
-
return { inRef, outRef, errRef, inStorage, outStorage, errStorage };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const envBoardDir = (process.env.BOARD_DIR ?? '').trim();
|
|
28
|
-
|
|
29
|
-
function resolveSyncTmpFileCandidates(payload) {
|
|
30
|
-
const fileName = payload?.context?.card_data?.llm_task_completion_inference?.sync_tmp_file;
|
|
31
|
-
if (typeof fileName !== 'string' || !fileName.trim()) return [];
|
|
32
|
-
|
|
33
|
-
const cleaned = fileName.trim();
|
|
34
|
-
if (path.isAbsolute(cleaned)) {
|
|
35
|
-
return [cleaned];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return [
|
|
39
|
-
envBoardDir ? path.join(envBoardDir, cleaned) : '',
|
|
40
|
-
path.join(process.cwd(), cleaned),
|
|
41
|
-
path.join(process.cwd(), 'board-runtime', cleaned),
|
|
42
|
-
path.join(process.cwd(), '..', 'board-runtime', cleaned),
|
|
43
|
-
].filter(Boolean);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getReadableTmpFile(tmpCandidates) {
|
|
47
|
-
for (const tmpFile of tmpCandidates) {
|
|
48
|
-
if (!fs.existsSync(tmpFile)) continue;
|
|
49
|
-
const content = fs.readFileSync(tmpFile, 'utf-8').trim();
|
|
50
|
-
if (content) return { tmpFile, content };
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function waitForTmpSyncInput(tmpCandidates, timeoutMs = 120000) {
|
|
56
|
-
const started = Date.now();
|
|
57
|
-
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
const interval = setInterval(() => {
|
|
60
|
-
if (Date.now() - started > timeoutMs) {
|
|
61
|
-
clearInterval(interval);
|
|
62
|
-
reject(new Error('Timed out waiting for sync tmp input'));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const ready = getReadableTmpFile(tmpCandidates);
|
|
66
|
-
if (!ready) return;
|
|
67
|
-
|
|
68
|
-
clearInterval(interval);
|
|
69
|
-
fs.writeFileSync(ready.tmpFile, '', 'utf-8');
|
|
70
|
-
resolve(ready);
|
|
71
|
-
}, 250);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function toNumber(value) {
|
|
76
|
-
const n = Number(value);
|
|
77
|
-
return Number.isFinite(n) ? n : 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function buildRiskAssessment(table, totalValue) {
|
|
81
|
-
const rows = Array.isArray(table) ? table : [];
|
|
82
|
-
const total = toNumber(totalValue);
|
|
83
|
-
const withWeights = rows.map((row) => {
|
|
84
|
-
const v = toNumber(row?.value);
|
|
85
|
-
return { symbol: String(row?.symbol ?? ''), value: v, weight: total > 0 ? v / total : 0 };
|
|
86
|
-
});
|
|
87
|
-
withWeights.sort((a, b) => b.weight - a.weight);
|
|
88
|
-
const largest = withWeights[0] ?? { symbol: 'N/A', weight: 0, value: 0 };
|
|
89
|
-
const concentrationPct = Math.round(largest.weight * 1000) / 10;
|
|
90
|
-
const concentrationFlag = largest.weight > 0.6;
|
|
91
|
-
const breadthFlag = withWeights.length < 3;
|
|
92
|
-
|
|
93
|
-
const statusText = concentrationFlag
|
|
94
|
-
? `High concentration risk: ${largest.symbol} at ${concentrationPct}% of portfolio value.`
|
|
95
|
-
: `Risk appears moderate: largest position ${largest.symbol} at ${concentrationPct}% of portfolio value.`;
|
|
96
|
-
|
|
97
|
-
const evidence = [
|
|
98
|
-
`positions=${withWeights.length}`,
|
|
99
|
-
`largest=${largest.symbol}`,
|
|
100
|
-
`largest_weight=${concentrationPct}%`,
|
|
101
|
-
`total_value=${Math.round(total * 100) / 100}`,
|
|
102
|
-
`breadth_ok=${withWeights.length >= 3}`,
|
|
103
|
-
`concentration_ok=${largest.weight <= 0.6}`,
|
|
104
|
-
`risk_flag=${breadthFlag || concentrationFlag}`,
|
|
105
|
-
].join('; ');
|
|
106
|
-
|
|
107
|
-
return { isTaskCompleted: true, reason: statusText, evidence };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function buildRebalancingPlan(table, totalValue, riskAssessment) {
|
|
111
|
-
const rows = Array.isArray(table) ? table : [];
|
|
112
|
-
const total = toNumber(totalValue);
|
|
113
|
-
const targetWeight = rows.length > 0 ? 1 / rows.length : 0;
|
|
114
|
-
const moves = rows
|
|
115
|
-
.map((row) => {
|
|
116
|
-
const symbol = String(row?.symbol ?? 'UNKNOWN');
|
|
117
|
-
const currentValue = toNumber(row?.value);
|
|
118
|
-
const currentWeight = total > 0 ? currentValue / total : 0;
|
|
119
|
-
const deltaWeight = targetWeight - currentWeight;
|
|
120
|
-
return {
|
|
121
|
-
symbol,
|
|
122
|
-
currentWeight,
|
|
123
|
-
deltaWeight,
|
|
124
|
-
action: deltaWeight > 0.03 ? 'BUY' : (deltaWeight < -0.03 ? 'SELL' : 'HOLD'),
|
|
125
|
-
};
|
|
126
|
-
})
|
|
127
|
-
.sort((a, b) => Math.abs(b.deltaWeight) - Math.abs(a.deltaWeight));
|
|
128
|
-
|
|
129
|
-
const topMoves = moves
|
|
130
|
-
.filter((m) => m.action !== 'HOLD')
|
|
131
|
-
.slice(0, 3)
|
|
132
|
-
.map((m) => `${m.action} ${m.symbol} (${Math.round(m.deltaWeight * 1000) / 10}pp)`);
|
|
133
|
-
|
|
134
|
-
const summary = topMoves.length > 0
|
|
135
|
-
? `Rebalance toward equal-weight profile: ${topMoves.join(', ')}.`
|
|
136
|
-
: 'Current allocations are close to equal-weight; no major rebalance needed.';
|
|
137
|
-
|
|
138
|
-
const evidence = [
|
|
139
|
-
`positions=${rows.length}`,
|
|
140
|
-
`target_weight=${Math.round(targetWeight * 1000) / 10}%`,
|
|
141
|
-
`risk_assessment=${typeof riskAssessment === 'string' ? riskAssessment : 'n/a'}`,
|
|
142
|
-
].join('; ');
|
|
143
|
-
|
|
144
|
-
return { isTaskCompleted: true, reason: summary, evidence };
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function main() {
|
|
148
|
-
const command = process.argv[2];
|
|
149
|
-
if (command !== 'run-inference') {
|
|
150
|
-
console.error(`Unknown command: ${command ?? '(none)'}`);
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const { inRef, outRef, errRef, inStorage, outStorage, errStorage } = parseArgs(process.argv.slice(3));
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
const rawIn = inStorage.read(inRef.value);
|
|
158
|
-
if (rawIn === null) throw new Error(`Input not found: ${inRef.value}`);
|
|
159
|
-
const payload = JSON.parse(rawIn);
|
|
160
|
-
const tmpCandidates = resolveSyncTmpFileCandidates(payload);
|
|
161
|
-
if (tmpCandidates.length > 0) {
|
|
162
|
-
await waitForTmpSyncInput(tmpCandidates);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const taskName = String(payload?.taskName ?? '');
|
|
166
|
-
const context = payload?.context ?? {};
|
|
167
|
-
// Inputs arrive under context.requires (the card's declared dependencies)
|
|
168
|
-
const requires = context?.requires ?? {};
|
|
169
|
-
const table = requires?.table?.rows ?? requires?.table;
|
|
170
|
-
const totalValue = requires?.totalValue;
|
|
171
|
-
const riskAssessment = requires?.riskAssessment;
|
|
172
|
-
|
|
173
|
-
let result;
|
|
174
|
-
if (taskName === 'portfolio-risk-assessment') {
|
|
175
|
-
result = buildRiskAssessment(table, totalValue);
|
|
176
|
-
} else if (taskName === 'rebalancing-strategy') {
|
|
177
|
-
result = buildRebalancingPlan(table, totalValue, riskAssessment);
|
|
178
|
-
} else {
|
|
179
|
-
result = {
|
|
180
|
-
isTaskCompleted: true,
|
|
181
|
-
reason: `Inference completed for ${taskName || 'unknown-task'}`,
|
|
182
|
-
evidence: 'deterministic-demo-adapter',
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
outStorage.write(outRef.value, JSON.stringify(result));
|
|
187
|
-
errStorage.write(errRef.value, '');
|
|
188
|
-
} catch (err) {
|
|
189
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
190
|
-
errStorage.write(errRef.value, message);
|
|
191
|
-
outStorage.write(outRef.value, JSON.stringify({ isTaskCompleted: false, reason: message, evidence: '' }));
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
void main();
|