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.
- package/board-live-cards-cli.js +2 -2
- package/board-livecards-server-runtime.js +488 -551
- package/browser/asset-integrity.json +10 -0
- package/browser/board-livecards-runtime-client.js +0 -6
- 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 +19 -34
- package/examples/example-board/demo-shell-browser.html +5 -4
- package/examples/example-board/demo-shell-with-server.html +10 -6
- 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 -10644
- 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 -10592
- 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,201 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""portfolio-tracker-fetch-prices.py
|
|
3
|
+
|
|
4
|
+
Task executor for the portfolio board demo.
|
|
5
|
+
Handles run-source-fetch requests for source_defs with kind: "mock-quotes".
|
|
6
|
+
Generates random prices (2dp, 10.00-999.99) for each projected ticker.
|
|
7
|
+
|
|
8
|
+
Subcommands:
|
|
9
|
+
run-source-fetch --in-ref <::kind::value> --out-ref <::kind::value> --err-ref <::kind::value>
|
|
10
|
+
validate-source-def --in <source.json>
|
|
11
|
+
describe-capabilities
|
|
12
|
+
|
|
13
|
+
Uses the public storage adapter for all storage and callback operations.
|
|
14
|
+
The executor does NOT contain transport-specific callback logic.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import random
|
|
23
|
+
import sys
|
|
24
|
+
import time
|
|
25
|
+
from typing import Any
|
|
26
|
+
|
|
27
|
+
# Add pycli to path so we can import the public storage adapter.
|
|
28
|
+
_REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..'))
|
|
29
|
+
if _REPO_ROOT not in sys.path:
|
|
30
|
+
sys.path.insert(0, _REPO_ROOT)
|
|
31
|
+
|
|
32
|
+
from pycli.sub.public_storage_adapter import ( # noqa: E402
|
|
33
|
+
parse_ref,
|
|
34
|
+
serialize_ref,
|
|
35
|
+
blob_storage_for_ref,
|
|
36
|
+
report_complete,
|
|
37
|
+
report_failed,
|
|
38
|
+
KindValueRef,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _parse_ref_str(ref: str) -> KindValueRef:
|
|
43
|
+
"""Convenience: parse a CLI ref string."""
|
|
44
|
+
return parse_ref(ref)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def validate_source_def(source_def: dict[str, Any]) -> dict[str, Any]:
|
|
48
|
+
errors: list[str] = []
|
|
49
|
+
|
|
50
|
+
if source_def.get("kind") != "mock-quotes":
|
|
51
|
+
errors.append(f"kind must be \"mock-quotes\"; got \"{source_def.get('kind')}\".")
|
|
52
|
+
if not isinstance(source_def.get("bindTo"), str) or not source_def.get("bindTo"):
|
|
53
|
+
errors.append("bindTo is required and must be a string.")
|
|
54
|
+
if not isinstance(source_def.get("outputFile"), str) or not source_def.get("outputFile"):
|
|
55
|
+
errors.append("outputFile is required and must be a string.")
|
|
56
|
+
projections = source_def.get("projections")
|
|
57
|
+
if not isinstance(projections, dict) or not isinstance(projections.get("tickers"), str):
|
|
58
|
+
errors.append("projections.tickers is required and must be a JSONata expression string.")
|
|
59
|
+
|
|
60
|
+
return {"ok": len(errors) == 0, "errors": errors}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def cmd_validate_source_def(args: argparse.Namespace) -> int:
|
|
64
|
+
if not os.path.exists(args.input):
|
|
65
|
+
print(json.dumps({"ok": False, "errors": [f"Input file not found: {args.input}"]}))
|
|
66
|
+
return 1
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
with open(args.input, "r", encoding="utf-8") as f:
|
|
70
|
+
source_def = json.load(f)
|
|
71
|
+
except Exception as e:
|
|
72
|
+
print(json.dumps({"ok": False, "errors": [f"Cannot parse source file: {e}"]}))
|
|
73
|
+
return 1
|
|
74
|
+
|
|
75
|
+
result = validate_source_def(source_def if isinstance(source_def, dict) else {})
|
|
76
|
+
print(json.dumps(result))
|
|
77
|
+
return 0 if result["ok"] else 1
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def cmd_describe_capabilities(_: argparse.Namespace) -> int:
|
|
81
|
+
capabilities = {
|
|
82
|
+
"version": "1.0",
|
|
83
|
+
"executor": "portfolio-tracker-fetch-prices",
|
|
84
|
+
"subcommands": ["run-source-fetch", "validate-source-def", "describe-capabilities"],
|
|
85
|
+
"sourceKinds": {
|
|
86
|
+
"mock-quotes": {
|
|
87
|
+
"description": "Generates random mock market prices (10.00-999.99) for each ticker in _projections.tickers.",
|
|
88
|
+
"inputSchema": {
|
|
89
|
+
"kind": {"type": "string", "required": True, "description": "Must be \"mock-quotes\"."},
|
|
90
|
+
"bindTo": {"type": "string", "required": True, "description": "Token name for the output binding."},
|
|
91
|
+
"outputFile": {"type": "string", "required": True, "description": "Relative path to write prices JSON."},
|
|
92
|
+
"projections": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"required": True,
|
|
95
|
+
"properties": {
|
|
96
|
+
"tickers": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"required": True,
|
|
99
|
+
"description": "JSONata expression resolving to a string[] of ticker symbols.",
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
"outputShape": "{ [ticker: string]: number }",
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
print(json.dumps(capabilities, indent=2, ensure_ascii=True))
|
|
109
|
+
return 0
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def cmd_run_source_fetch(args: argparse.Namespace) -> int:
|
|
113
|
+
in_ref = _parse_ref_str(args.in_ref)
|
|
114
|
+
out_ref = _parse_ref_str(args.out_ref)
|
|
115
|
+
err_ref = _parse_ref_str(args.err_ref)
|
|
116
|
+
|
|
117
|
+
in_storage = blob_storage_for_ref(in_ref)
|
|
118
|
+
out_storage = blob_storage_for_ref(out_ref)
|
|
119
|
+
err_storage = blob_storage_for_ref(err_ref)
|
|
120
|
+
|
|
121
|
+
raw_in = in_storage.read(in_ref.value)
|
|
122
|
+
if not raw_in:
|
|
123
|
+
print(f"[portfolio-tracker-fetch-prices] input envelope not found at: {args.in_ref}", file=sys.stderr)
|
|
124
|
+
return 1
|
|
125
|
+
|
|
126
|
+
envelope = json.loads(raw_in)
|
|
127
|
+
callback = envelope.get("callback") if isinstance(envelope, dict) else None
|
|
128
|
+
|
|
129
|
+
def safe_fail(msg: str) -> int:
|
|
130
|
+
try:
|
|
131
|
+
err_storage.write(err_ref.value, msg)
|
|
132
|
+
except Exception:
|
|
133
|
+
pass
|
|
134
|
+
if isinstance(callback, dict):
|
|
135
|
+
try:
|
|
136
|
+
report_failed(callback, msg)
|
|
137
|
+
return 0
|
|
138
|
+
except Exception as e:
|
|
139
|
+
print(f"[portfolio-tracker-fetch-prices] callback fail: {e}", file=sys.stderr)
|
|
140
|
+
return 1
|
|
141
|
+
return 1
|
|
142
|
+
|
|
143
|
+
try:
|
|
144
|
+
source_def = envelope.get("source_def") if isinstance(envelope, dict) else None
|
|
145
|
+
if not isinstance(source_def, dict):
|
|
146
|
+
source_def = envelope if isinstance(envelope, dict) else {}
|
|
147
|
+
|
|
148
|
+
if source_def.get("kind") != "mock-quotes":
|
|
149
|
+
raise ValueError(f"Unsupported source kind: expected \"mock-quotes\", got \"{source_def.get('kind')}\"")
|
|
150
|
+
|
|
151
|
+
projections = source_def.get("_projections")
|
|
152
|
+
tickers = projections.get("tickers") if isinstance(projections, dict) else None
|
|
153
|
+
if not isinstance(tickers, list):
|
|
154
|
+
raise ValueError("sourceDef._projections.tickers is missing or not an array")
|
|
155
|
+
|
|
156
|
+
time.sleep(0.2 + random.random() * 0.1)
|
|
157
|
+
|
|
158
|
+
prices: dict[str, float] = {}
|
|
159
|
+
for ticker in tickers:
|
|
160
|
+
prices[str(ticker)] = round(10 + random.random() * 989.99, 2)
|
|
161
|
+
|
|
162
|
+
out_storage.write(out_ref.value, json.dumps(prices, ensure_ascii=True))
|
|
163
|
+
print(f"[portfolio-tracker-fetch-prices] wrote prices for: {', '.join([str(t) for t in tickers])}")
|
|
164
|
+
|
|
165
|
+
if isinstance(callback, dict):
|
|
166
|
+
report_complete(callback, out_ref)
|
|
167
|
+
return 0
|
|
168
|
+
except Exception as e:
|
|
169
|
+
msg = str(e)
|
|
170
|
+
print(f"[portfolio-tracker-fetch-prices] error: {msg}", file=sys.stderr)
|
|
171
|
+
return safe_fail(msg)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
175
|
+
parser = argparse.ArgumentParser(prog="portfolio-tracker-fetch-prices")
|
|
176
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
177
|
+
|
|
178
|
+
run_cmd = sub.add_parser("run-source-fetch")
|
|
179
|
+
run_cmd.add_argument("--in-ref", required=True)
|
|
180
|
+
run_cmd.add_argument("--out-ref", required=True)
|
|
181
|
+
run_cmd.add_argument("--err-ref", required=True)
|
|
182
|
+
run_cmd.set_defaults(handler=cmd_run_source_fetch)
|
|
183
|
+
|
|
184
|
+
val_cmd = sub.add_parser("validate-source-def")
|
|
185
|
+
val_cmd.add_argument("--in", dest="input", required=True)
|
|
186
|
+
val_cmd.set_defaults(handler=cmd_validate_source_def)
|
|
187
|
+
|
|
188
|
+
cap_cmd = sub.add_parser("describe-capabilities")
|
|
189
|
+
cap_cmd.set_defaults(handler=cmd_describe_capabilities)
|
|
190
|
+
|
|
191
|
+
return parser
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def main(argv: list[str] | None = None) -> int:
|
|
195
|
+
parser = build_parser()
|
|
196
|
+
args = parser.parse_args(argv)
|
|
197
|
+
return args.handler(args)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
raise SystemExit(main())
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import * as fs from 'node:fs';
|
|
4
3
|
import * as path from 'node:path';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import { parseRef, blobStorageForRef } from 'yaml-flow/storage-refs';
|
|
5
6
|
|
|
6
7
|
function parseArgs(argv) {
|
|
7
|
-
const inIdx
|
|
8
|
-
const outIdx = argv.indexOf('--out');
|
|
9
|
-
const errIdx = argv.indexOf('--err');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
console.error('Usage: <adapter> run-inference --in
|
|
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>');
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
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 };
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
const envBoardDir = (process.env.BOARD_DIR ?? '').trim();
|
|
@@ -144,10 +151,12 @@ async function main() {
|
|
|
144
151
|
process.exit(1);
|
|
145
152
|
}
|
|
146
153
|
|
|
147
|
-
const {
|
|
154
|
+
const { inRef, outRef, errRef, inStorage, outStorage, errStorage } = parseArgs(process.argv.slice(3));
|
|
148
155
|
|
|
149
156
|
try {
|
|
150
|
-
const
|
|
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);
|
|
151
160
|
const tmpCandidates = resolveSyncTmpFileCandidates(payload);
|
|
152
161
|
if (tmpCandidates.length > 0) {
|
|
153
162
|
await waitForTmpSyncInput(tmpCandidates);
|
|
@@ -174,12 +183,12 @@ async function main() {
|
|
|
174
183
|
};
|
|
175
184
|
}
|
|
176
185
|
|
|
177
|
-
|
|
178
|
-
|
|
186
|
+
outStorage.write(outRef.value, JSON.stringify(result));
|
|
187
|
+
errStorage.write(errRef.value, '');
|
|
179
188
|
} catch (err) {
|
|
180
189
|
const message = err instanceof Error ? err.message : String(err);
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
errStorage.write(errRef.value, message);
|
|
191
|
+
outStorage.write(outRef.value, JSON.stringify({ isTaskCompleted: false, reason: message, evidence: '' }));
|
|
183
192
|
process.exit(1);
|
|
184
193
|
}
|
|
185
194
|
}
|