@accio-ai/workflow-builder-cli 0.2.1-rc.1 → 0.2.22

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.
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -25,10 +28,418 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
25
28
  mod
26
29
  ));
27
30
 
31
+ // <define:__WORKFLOW_BUILDER_BRIDGE__>
32
+ var define_WORKFLOW_BUILDER_BRIDGE_default;
33
+ var init_define_WORKFLOW_BUILDER_BRIDGE = __esm({
34
+ "<define:__WORKFLOW_BUILDER_BRIDGE__>"() {
35
+ define_WORKFLOW_BUILDER_BRIDGE_default = { "draft_mcp.py": '"""Host adapter for Workflow Builder. One scoped request on stdin, one receipt on stdout."""\nimport hashlib\nimport json\nimport os\nfrom pathlib import Path\nimport sys\nimport time\n\nfrom resource_snapshot import BusinessError, DRAFT_TOOLS, Discovery, DiscoveryError, host_space\n\n\ndef context():\n space = host_space()\n trace = json.loads(os.environ.get("ACCIO_TRACE_CONTEXT", "{}"))\n if not trace.get("conversationId") or space.get("kind") != "team" or not space.get("accountId") or not space.get("teamId"):\n raise DiscoveryError("HOST_TEAM_CONTEXT_REQUIRED")\n team = str(space["teamId"])\n if trace.get("teamId") and str(trace["teamId"]) != team:\n raise DiscoveryError("TEAM_CONTEXT_MISMATCH")\n env = os.getenv("ACCIO_ENVIRONMENT") or os.getenv("PHOENIX_ENVIRONMENT")\n if not env:\n try:\n settings = json.loads((Path.home() / ".accio/settings.jsonc").read_text(encoding="utf-8"))\n env = settings.get("dev", {}).get("environment")\n except (OSError, ValueError):\n pass\n origins = {"pre": "https://pre-www.accio.com", "prod": "https://www.accio.com"}\n if env not in origins:\n raise DiscoveryError("HOST_ENVIRONMENT_REQUIRED")\n return {"teamId": team, "environment": env, "canvasBase": origins[env] + "/fde",\n "operator": hashlib.sha256(str(space["accountId"]).encode()).hexdigest()}\n\n\ndef dispatch(request):\n scope = context()\n if request["method"] == "context":\n return scope\n if request.get("scope") != scope:\n raise DiscoveryError("HOST_SCOPE_CHANGED")\n name = "fde_workflow_" + request["method"]\n if name not in DRAFT_TOOLS:\n raise DiscoveryError("UNKNOWN_DRAFT_TOOL")\n client = Discovery(scope["teamId"], None)\n schemas = client.catalog()\n if name not in schemas:\n # A task may have cached the older five-tool catalog before the rollout.\n client.catalog_path.unlink(missing_ok=True)\n client.schemas = None\n schemas = client.catalog()\n schema = schemas.get(name)\n if not schema:\n raise DiscoveryError("MCP_TOOL_NOT_VISIBLE")\n args = request["arguments"]\n if set(args) - set(schema.get("properties", {})) or set(schema.get("required", [])) - set(args):\n raise DiscoveryError("MCP_SCHEMA_MISMATCH")\n write = request["method"] in ("create_draft", "update_draft")\n try:\n result = client.query(name, args, write=write)\n except BusinessError:\n raise\n except DiscoveryError as error:\n retryable = str(error) == "MCP_INVALID_RESPONSE" or (not write and str(error) == "MCP_BUSINESS_RECEIPT_MISSING")\n if not retryable or (write and not args.get("idempotencyKey")):\n raise\n time.sleep(1)\n if context() != scope:\n raise DiscoveryError("HOST_SCOPE_CHANGED") from None\n # Replay the exact payload/key after an ambiguous response. A write\n # still needs a valid receipt and a separate revision-checked readback.\n result = client.query(name, args, write=write)\n if context() != scope:\n raise DiscoveryError("HOST_SCOPE_CHANGED")\n return result\n\n\nif __name__ == "__main__":\n try:\n print(json.dumps({"ok": True, "data": dispatch(json.load(sys.stdin))}, ensure_ascii=False))\n except DiscoveryError as error:\n print(json.dumps({"ok": False, "code": str(error), "definitive": isinstance(error, BusinessError),\n **({"issues": error.issues} if getattr(error, "issues", None) else {})}))\n except OSError as error:\n print(json.dumps({"ok": False, "code": "HOST_IO_ERROR", "errno": error.errno}))\n except (KeyError, TypeError, ValueError):\n print(json.dumps({"ok": False, "code": "MCP_INVALID_RESPONSE"}))\n', "resource_snapshot.py": `#!/usr/bin/env python3
36
+ """Read scoped workflow resource directories through the Accio host."""
37
+
38
+ import argparse
39
+ import base64
40
+ from datetime import datetime, timezone
41
+ import hashlib
42
+ from http.client import HTTPConnection, HTTPSConnection, HTTPException
43
+ import json
44
+ import os
45
+ from pathlib import Path
46
+ import re
47
+ import subprocess
48
+ import tempfile
49
+ import time
50
+ from urllib.parse import urlsplit
51
+ from uuid import uuid4
52
+
53
+ TOOLKIT = "union_saas_fde_workflow_generation"
54
+ DRAFT_TOOLS = {"fde_workflow_" + verb for verb in (
55
+ "list_workflows", "get_draft", "create_draft", "update_draft",
56
+ )}
57
+ DIRECTORIES = {
58
+ "teams": ("fde_workflow_list_my_teams", "teamId", False),
59
+ "experts": ("fde_workflow_list_agents", "instanceId", True),
60
+ "members": ("fde_workflow_list_members", "userId", True),
61
+ "groups": ("fde_workflow_list_wechat_groups", "groupId", False),
62
+ "subworkflows": ("fde_workflow_list_subworkflows", "workflowId", True),
63
+ }
64
+ CATALOG_ERRORS = {
65
+ "PHOENIX_TOOL_METADATA_UNAVAILABLE", "MCP_TOOLS_INITIALIZING", "MCP_TOOL_NOT_VISIBLE",
66
+ }
67
+
68
+
69
+ def expert_choices(records):
70
+ """Expose directory duties together with IDs so differently named experts are discoverable."""
71
+ return [{"name": row.get("name"), "instanceId": row.get("instanceId"), "versionNo": row.get("currentVersionNo"),
72
+ "duties": str(row.get("shortDescription") or "")[:220]} for row in records[:48]]
73
+
74
+
75
+ def json_objects(value):
76
+ """Find JSON objects in CLI, MCP content, and serialized business envelopes."""
77
+ if isinstance(value, str):
78
+ if not value.lstrip().startswith(("{", "[")):
79
+ return
80
+ value = json.loads(value)
81
+ if isinstance(value, dict):
82
+ yield value
83
+ for key, child in value.items():
84
+ if isinstance(child, (dict, list)) or key in ("text", "output", "result", "structuredContent", "tools"):
85
+ yield from json_objects(child)
86
+ elif isinstance(value, list):
87
+ for child in value:
88
+ yield from json_objects(child)
89
+
90
+
91
+ def write_json(path, data):
92
+ path.parent.mkdir(parents=True, mode=0o700, exist_ok=True)
93
+ descriptor, name = tempfile.mkstemp(dir=path.parent)
94
+ temporary = Path(name)
95
+ try:
96
+ with os.fdopen(descriptor, "w", encoding="utf-8") as stream:
97
+ json.dump(data, stream, ensure_ascii=False, allow_nan=False)
98
+ stream.write("\\n")
99
+ temporary.replace(path)
100
+ finally:
101
+ temporary.unlink(missing_ok=True)
102
+
103
+
104
+ def read_json(path):
105
+ try:
106
+ return json.loads(path.read_text(encoding="utf-8"))
107
+ except FileNotFoundError:
108
+ return None
109
+
110
+
111
+ class DiscoveryError(ValueError):
112
+ pass
113
+
114
+
115
+ class BusinessError(DiscoveryError):
116
+ """The host returned an explicit, negative business acknowledgement."""
117
+
118
+ def __init__(self, code, issues=()):
119
+ super().__init__(code)
120
+ self.issues = [{"path": issue["path"], "code": issue["code"]}
121
+ for issue in issues if isinstance(issue, dict)
122
+ and isinstance(issue.get("path"), str) and issue["path"].startswith("/")
123
+ and len(issue["path"]) <= 256 and isinstance(issue.get("code"), str)
124
+ and re.fullmatch(r"[A-Z0-9_]{1,80}", issue["code"])]
125
+
126
+
127
+
128
+ def host_space():
129
+ """Use the desktop gateway when its shell trace omits the selected Team."""
130
+ origin = os.environ.get("ACCIO_HOST_RUNTIME_GATEWAY_URL") or os.environ.get("ACCIO_LOCAL_GATEWAY_URL")
131
+ if not origin:
132
+ host = os.environ.get("ACCIO_GATEWAY_HOST") or os.environ.get("GATEWAY_HOST") or "localhost"
133
+ origin = f"http://{host}:{os.environ.get('GATEWAY_PORT', '4097')}"
134
+ try:
135
+ url = urlsplit(origin)
136
+ if (url.scheme not in ("http", "https") or url.hostname not in ("localhost", "127.0.0.1", "::1")
137
+ or url.username or url.password):
138
+ return {}
139
+ token = os.environ.get("ACCIO_GATEWAY_TOKEN") or os.environ.get("PHOENIX_TELEMETRY_DEBUG_GATEWAY_PASSWORD")
140
+ headers = {}
141
+ if token:
142
+ username = os.environ.get("ACCIO_GATEWAY_USERNAME", "phoenix")
143
+ authorization = base64.b64encode(f"{username}:{token}".encode()).decode("ascii")
144
+ headers["Authorization"] = f"Basic {authorization}"
145
+ connection_type = HTTPSConnection if url.scheme == "https" else HTTPConnection
146
+ connection = connection_type(url.hostname, url.port, timeout=3)
147
+ try:
148
+ connection.request("GET", "/space/current", headers=headers)
149
+ response = connection.getresponse()
150
+ if response.status == 200:
151
+ payload = json.loads(response.read(16_384))
152
+ if payload.get("success") is True and isinstance(payload.get("data"), dict):
153
+ return payload["data"]
154
+ finally:
155
+ connection.close()
156
+ except (OSError, ValueError, HTTPException):
157
+ pass
158
+ return {}
159
+
160
+
161
+ class Discovery:
162
+ def __init__(self, team, build, workspace=None):
163
+ trace = json.loads(os.environ.get("ACCIO_TRACE_CONTEXT", "{}"))
164
+ conversation = trace.get("conversationId")
165
+ if not isinstance(conversation, str) or not conversation:
166
+ raise DiscoveryError("HOST_CONVERSATION_REQUIRED")
167
+ space = host_space() if not trace.get("teamId") else {}
168
+ active_team = trace.get("teamId") or space.get("teamId")
169
+ self.host_team = str(active_team) if active_team else None
170
+ self.team = team or self.host_team
171
+ if team and (self.host_team and team != self.host_team or space.get("kind") == "personal"):
172
+ raise DiscoveryError("TEAM_CONTEXT_MISMATCH")
173
+ workspace = Path.cwd() if workspace is None else workspace.resolve()
174
+ if not workspace.is_dir():
175
+ raise DiscoveryError("WORKSPACE_NOT_FOUND")
176
+ scope = [TOOLKIT, space.get("accountId"), conversation, trace.get("agentId"), self.team]
177
+ root = workspace / ".workflow-resource-discovery" / hashlib.sha256(json.dumps(scope).encode()).hexdigest()
178
+ self.root = root / hashlib.sha256(json.dumps(build).encode()).hexdigest()
179
+ self.catalog_path = root / "catalog.json"
180
+ self.calls = []
181
+ self.schemas = None
182
+ self.catalog_error = None
183
+
184
+ def run_cli(self, args, receipt, *, parse_output=True):
185
+ self.calls.append(receipt)
186
+ try:
187
+ response = subprocess.run(
188
+ ["accio-mcp-cli", *args, "--server", "accio", "--raw"],
189
+ capture_output=True, encoding="utf-8", timeout=45, check=False,
190
+ )
191
+ except FileNotFoundError:
192
+ raise DiscoveryError("MCP_CLI_UNAVAILABLE") from None
193
+ except subprocess.TimeoutExpired:
194
+ raise DiscoveryError("MCP_TIMEOUT") from None
195
+ if response.returncode:
196
+ # Only emit a stable code, since CLI output can include business data.
197
+ output = response.stderr + response.stdout
198
+ for fragment, code in (
199
+ ("PHOENIX_TOOL_METADATA_UNAVAILABLE", "PHOENIX_TOOL_METADATA_UNAVAILABLE"),
200
+ ("still initializing", "MCP_TOOLS_INITIALIZING"),
201
+ ("not visible on scoped Phoenix server", "MCP_TOOL_NOT_VISIBLE"),
202
+ ("Unauthorized", "UNAUTHORIZED"),
203
+ ("FORBIDDEN", "FORBIDDEN"),
204
+ ):
205
+ if fragment in output:
206
+ raise DiscoveryError(code)
207
+ status = re.search(r"\\bHTTP\\D{0,12}(\\d{3})\\b", output)
208
+ raise DiscoveryError(f"HTTP_{status[1]}" if status else "MCP_CLI_FAILED")
209
+ if not parse_output:
210
+ return
211
+ try:
212
+ return json.loads(response.stdout)
213
+ except ValueError:
214
+ raise DiscoveryError("MCP_INVALID_RESPONSE") from None
215
+
216
+ def call(self, name, args):
217
+ receipt = {"method": name}
218
+ if "tool_name" in args:
219
+ receipt["tool"] = args["tool_name"]
220
+ if "pageNo" in args["arguments"]:
221
+ receipt.update({key: args["arguments"][key] for key in ("pageNo", "pageSize")})
222
+ return self.run_cli(["call", name, "--json", json.dumps(args)], receipt)
223
+
224
+ def catalog(self):
225
+ if self.catalog_error is not None:
226
+ raise self.catalog_error
227
+ if self.schemas is not None:
228
+ return self.schemas
229
+ try:
230
+ self.schemas = self.read_catalog()
231
+ return self.schemas
232
+ except DiscoveryError as error:
233
+ self.catalog_error = error
234
+ raise
235
+
236
+ def read_catalog(self):
237
+ saved = read_json(self.catalog_path)
238
+ if saved is not None:
239
+ return saved
240
+ # Cold sessions can expose the catalog only after scoped discovery completes.
241
+ # Refresh metadata once and poll only the read, never the delegated write.
242
+ for delay in (0, 1, 2, 4, 8):
243
+ if delay:
244
+ time.sleep(delay)
245
+ try:
246
+ raw = self.call("yuanzhou_list_tools", {"toolkit": TOOLKIT})
247
+ break
248
+ except DiscoveryError as error:
249
+ if str(error) not in CATALOG_ERRORS or delay == 8:
250
+ raise
251
+ if delay == 0:
252
+ try:
253
+ self.run_cli(["search", "yuanzhou", "--refresh"], {"method": "refresh_catalog"}, parse_output=False)
254
+ except DiscoveryError as refresh_error:
255
+ if str(refresh_error) not in CATALOG_ERRORS:
256
+ raise
257
+ names = {tool for tool, _, _ in DIRECTORIES.values()} | DRAFT_TOOLS
258
+ schemas = {}
259
+ for item in json_objects(raw):
260
+ name = item.get("name") or item.get("toolName") or item.get("tool_name")
261
+ if not isinstance(name, str) or name not in names:
262
+ continue
263
+ schema = item.get("inputSchema") or item.get("input_schema")
264
+ if isinstance(schema, str):
265
+ schema = json.loads(schema)
266
+ if isinstance(schema, dict):
267
+ schemas[name] = schema
268
+ if not schemas:
269
+ raise DiscoveryError("MCP_SCHEMA_UNAVAILABLE")
270
+ write_json(self.catalog_path, schemas)
271
+ return schemas
272
+
273
+ def query(self, tool, args, *, write=False):
274
+ payload = {"toolkit": TOOLKIT, "tool_name": tool, "arguments": args}
275
+ if write:
276
+ with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", suffix=".json", delete=False) as stream:
277
+ filename = stream.name
278
+ json.dump(payload, stream, ensure_ascii=False)
279
+ try:
280
+ raw = self.run_cli(["call", "yuanzhou_call_tool", "--json-file", filename],
281
+ {"method": "yuanzhou_call_tool", "tool": tool})
282
+ finally:
283
+ Path(filename).unlink(missing_ok=True)
284
+ else:
285
+ raw = self.call("yuanzhou_call_tool", payload)
286
+ for result in json_objects(raw):
287
+ code = result.get("code")
288
+ if type(result.get("success")) is not bool or not isinstance(code, str):
289
+ continue
290
+ if not result["success"]:
291
+ raise BusinessError(code if re.fullmatch(r"[A-Z0-9_]{1,80}", code) else "MCP_BUSINESS_ERROR",
292
+ result["issues"] if isinstance(result.get("issues"), list) else ())
293
+ if code != ("SUCCESS" if write else "OK"):
294
+ raise DiscoveryError("MCP_INVALID_RESPONSE")
295
+ if write and isinstance(result.get("data"), dict):
296
+ return result["data"]
297
+ if not write and "dataJson" in result:
298
+ data = result["dataJson"]
299
+ return json.loads(data) if isinstance(data, str) else data
300
+ if any(item.get("type") == "text" and str(item.get("text", "")).strip().rstrip(".") == "Tool executed successfully"
301
+ for item in json_objects(raw)):
302
+ raise DiscoveryError("MCP_BUSINESS_RECEIPT_MISSING")
303
+ raise DiscoveryError("MCP_INVALID_RESPONSE")
304
+
305
+ def read_directory(self, tool, args):
306
+ # A transient host response may omit the business envelope. Retry only
307
+ # this read, before adding any rows to the snapshot.
308
+ try:
309
+ return self.query(tool, args)
310
+ except BusinessError:
311
+ raise
312
+ except DiscoveryError as error:
313
+ if str(error) not in {"MCP_INVALID_RESPONSE", "MCP_BUSINESS_RECEIPT_MISSING"}:
314
+ raise
315
+ time.sleep(1)
316
+ return self.query(tool, args)
317
+
318
+ def fetch(self, kind):
319
+ tool, identity, paginated = DIRECTORIES[kind]
320
+ if kind != "teams" and not self.team:
321
+ raise DiscoveryError("TEAM_CONTEXT_REQUIRED")
322
+ schema = self.catalog().get(tool)
323
+ if schema is None:
324
+ raise DiscoveryError("MCP_SCHEMA_UNAVAILABLE")
325
+ props = schema.get("properties", {})
326
+ args = {}
327
+ if kind != "teams":
328
+ if "teamId" in props:
329
+ args["teamId"] = int(self.team) if props["teamId"].get("type") == "integer" else self.team
330
+ elif not self.host_team and not paginated:
331
+ raise DiscoveryError("HOST_TEAM_CONTEXT_REQUIRED")
332
+
333
+ pages, records, ids = [], [], set()
334
+ if not paginated:
335
+ rows = self.read_directory(tool, args)
336
+ total = len(rows) if isinstance(rows, list) else None
337
+ self.add_rows(rows, identity, total, ids, records)
338
+ return records, pages
339
+
340
+ if not {"pageNo", "pageSize"} <= props.keys():
341
+ raise DiscoveryError("MCP_PAGINATION_SCHEMA_UNAVAILABLE")
342
+ size = min(50, int(props["pageSize"].get("maximum", 50)))
343
+ if size < 1:
344
+ raise DiscoveryError("MCP_PAGINATION_SCHEMA_INVALID")
345
+ total = None
346
+ for number in range(1, 501):
347
+ result = self.read_directory(tool, {**args, "pageNo": number, "pageSize": size})
348
+ if not isinstance(result, dict):
349
+ raise DiscoveryError("MCP_INVALID_RESPONSE")
350
+ if ("teamId" in result and str(result["teamId"]) != self.team
351
+ or "teamId" not in result and not self.host_team and "teamId" not in args):
352
+ raise DiscoveryError("RESPONSE_TEAM_MISMATCH")
353
+ reported_size = int(result["pageSize"])
354
+ reported_total = int(result["totalCount"])
355
+ if total is None and 0 < reported_size <= size:
356
+ total, size = reported_total, reported_size
357
+ if total is None or total < 0 or reported_total != total or reported_size != size:
358
+ raise DiscoveryError("MCP_PAGINATION_INCONSISTENT")
359
+ if int(result.get("currentPage", result.get("pageNo"))) != number:
360
+ raise DiscoveryError("MCP_PAGINATION_INCONSISTENT")
361
+ rows = result.get("list", result.get("items"))
362
+ self.add_rows(rows, identity, min(size, total - len(records)), ids, records)
363
+ pages.append({"pageNo": number, "pageSize": size, "rowCount": len(rows)})
364
+ if len(records) == total:
365
+ return records, pages
366
+ raise DiscoveryError("MCP_PAGINATION_LIMIT")
367
+
368
+ @staticmethod
369
+ def add_rows(rows, identity, expected, ids, records):
370
+ if not isinstance(rows, list) or len(rows) != expected:
371
+ raise DiscoveryError("MCP_PAGINATION_INCOMPLETE")
372
+ for row in rows:
373
+ value = row.get(identity) if isinstance(row, dict) else None
374
+ if type(value) not in (str, int) or not str(value).strip() or str(value) in ids:
375
+ raise DiscoveryError("MCP_RESOURCE_ID_INVALID_OR_DUPLICATE")
376
+ ids.add(str(value))
377
+ records.append(row)
378
+
379
+ def resolve(self, kind, refresh):
380
+ pointer = self.root / f"{kind}.json"
381
+ if refresh:
382
+ pointer.unlink(missing_ok=True)
383
+ summary = read_json(pointer)
384
+ if summary is not None and (self.root / summary["snapshotPath"]).is_file():
385
+ return {**summary, "snapshotFile": str(self.root / summary["snapshotPath"]), "cache": "hit"}
386
+ rows, pages = self.fetch(kind)
387
+ snapshot_id = uuid4().hex
388
+ snapshot_path = Path("snapshots") / f"{kind}-{snapshot_id}.json"
389
+ summary = {
390
+ "snapshotId": snapshot_id, "snapshotPath": snapshot_path.as_posix(),
391
+ "tool": DIRECTORIES[kind][0], "teamId": self.team, "totalCount": len(rows),
392
+ "collectedAt": datetime.now(timezone.utc).isoformat(timespec="seconds"),
393
+ }
394
+ write_json(self.root / snapshot_path, {**summary, "pages": pages, "records": rows})
395
+ write_json(pointer, summary)
396
+ return {**summary, "snapshotFile": str(self.root / snapshot_path), "cache": "miss"}
397
+
398
+
399
+ def main():
400
+ parser = argparse.ArgumentParser(description=__doc__)
401
+ parser.add_argument("--team", help="Confirmed Team ID; defaults to the host Team")
402
+ parser.add_argument("--build", help="Builder workflow ID; omit for standalone discovery")
403
+ parser.add_argument("--workspace", type=Path, help="Accio conversation workspace; defaults to the current directory")
404
+ parser.add_argument("--refresh", action="store_true", help="Refetch only the requested directories")
405
+ parser.add_argument("kinds", nargs="+", choices=tuple(DIRECTORIES))
406
+ args = parser.parse_args()
407
+ report = {"ok": False, "directories": {}, "mcpCalls": []}
408
+ try:
409
+ discovery = Discovery(args.team, args.build, args.workspace)
410
+ report.update(snapshotRoot=str(discovery.root), mcpCalls=discovery.calls)
411
+ for kind in dict.fromkeys(args.kinds):
412
+ try:
413
+ result = discovery.resolve(kind, args.refresh)
414
+ if kind == "experts":
415
+ snapshot = read_json(Path(result["snapshotFile"]))
416
+ result["choices"] = expert_choices(snapshot["records"])
417
+ report["directories"][kind] = result
418
+ except DiscoveryError as error:
419
+ report["directories"][kind] = {"error": str(error)}
420
+ except (ValueError, TypeError, KeyError, OSError):
421
+ report["directories"][kind] = {"error": "DISCOVERY_DATA_UNAVAILABLE"}
422
+ report["ok"] = all("error" not in result for result in report["directories"].values())
423
+ except DiscoveryError as error:
424
+ report["error"] = str(error)
425
+ except (AttributeError, ValueError, TypeError):
426
+ report["error"] = "HOST_CONTEXT_INVALID"
427
+ report["mcpCallCount"] = len(report["mcpCalls"])
428
+ print(json.dumps(report, ensure_ascii=False))
429
+ return 0 if report["ok"] else 1
430
+
431
+
432
+ if __name__ == "__main__":
433
+ raise SystemExit(main())
434
+ ` };
435
+ }
436
+ });
437
+
28
438
  // node_modules/ajv/dist/compile/codegen/code.js
29
439
  var require_code = __commonJS({
30
440
  "node_modules/ajv/dist/compile/codegen/code.js"(exports2) {
31
441
  "use strict";
442
+ init_define_WORKFLOW_BUILDER_BRIDGE();
32
443
  Object.defineProperty(exports2, "__esModule", { value: true });
33
444
  exports2.regexpCode = exports2.getEsmExportName = exports2.getProperty = exports2.safeStringify = exports2.stringify = exports2.strConcat = exports2.addCodeArg = exports2.str = exports2._ = exports2.nil = exports2._Code = exports2.Name = exports2.IDENTIFIER = exports2._CodeOrName = void 0;
34
445
  var _CodeOrName = class {
@@ -183,6 +594,7 @@ var require_code = __commonJS({
183
594
  var require_scope = __commonJS({
184
595
  "node_modules/ajv/dist/compile/codegen/scope.js"(exports2) {
185
596
  "use strict";
597
+ init_define_WORKFLOW_BUILDER_BRIDGE();
186
598
  Object.defineProperty(exports2, "__esModule", { value: true });
187
599
  exports2.ValueScope = exports2.ValueScopeName = exports2.Scope = exports2.varKinds = exports2.UsedValueState = void 0;
188
600
  var code_1 = require_code();
@@ -328,6 +740,7 @@ var require_scope = __commonJS({
328
740
  var require_codegen = __commonJS({
329
741
  "node_modules/ajv/dist/compile/codegen/index.js"(exports2) {
330
742
  "use strict";
743
+ init_define_WORKFLOW_BUILDER_BRIDGE();
331
744
  Object.defineProperty(exports2, "__esModule", { value: true });
332
745
  exports2.or = exports2.and = exports2.not = exports2.CodeGen = exports2.operators = exports2.varKinds = exports2.ValueScopeName = exports2.ValueScope = exports2.Scope = exports2.Name = exports2.regexpCode = exports2.stringify = exports2.getProperty = exports2.nil = exports2.strConcat = exports2.str = exports2._ = void 0;
333
746
  var code_1 = require_code();
@@ -1048,6 +1461,7 @@ var require_codegen = __commonJS({
1048
1461
  var require_util = __commonJS({
1049
1462
  "node_modules/ajv/dist/compile/util.js"(exports2) {
1050
1463
  "use strict";
1464
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1051
1465
  Object.defineProperty(exports2, "__esModule", { value: true });
1052
1466
  exports2.checkStrictMode = exports2.getErrorPath = exports2.Type = exports2.useFunc = exports2.setEvaluated = exports2.evaluatedPropsToName = exports2.mergeEvaluated = exports2.eachItem = exports2.unescapeJsonPointer = exports2.escapeJsonPointer = exports2.escapeFragment = exports2.unescapeFragment = exports2.schemaRefOrVal = exports2.schemaHasRulesButRef = exports2.schemaHasRules = exports2.checkUnknownRules = exports2.alwaysValidSchema = exports2.toHash = void 0;
1053
1467
  var codegen_1 = require_codegen();
@@ -1215,6 +1629,7 @@ var require_util = __commonJS({
1215
1629
  var require_names = __commonJS({
1216
1630
  "node_modules/ajv/dist/compile/names.js"(exports2) {
1217
1631
  "use strict";
1632
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1218
1633
  Object.defineProperty(exports2, "__esModule", { value: true });
1219
1634
  var codegen_1 = require_codegen();
1220
1635
  var names = {
@@ -1254,6 +1669,7 @@ var require_names = __commonJS({
1254
1669
  var require_errors = __commonJS({
1255
1670
  "node_modules/ajv/dist/compile/errors.js"(exports2) {
1256
1671
  "use strict";
1672
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1257
1673
  Object.defineProperty(exports2, "__esModule", { value: true });
1258
1674
  exports2.extendErrors = exports2.resetErrorsCount = exports2.reportExtraError = exports2.reportError = exports2.keyword$DataError = exports2.keywordError = void 0;
1259
1675
  var codegen_1 = require_codegen();
@@ -1376,6 +1792,7 @@ var require_errors = __commonJS({
1376
1792
  var require_boolSchema = __commonJS({
1377
1793
  "node_modules/ajv/dist/compile/validate/boolSchema.js"(exports2) {
1378
1794
  "use strict";
1795
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1379
1796
  Object.defineProperty(exports2, "__esModule", { value: true });
1380
1797
  exports2.boolOrEmptySchema = exports2.topBoolOrEmptySchema = void 0;
1381
1798
  var errors_1 = require_errors();
@@ -1427,6 +1844,7 @@ var require_boolSchema = __commonJS({
1427
1844
  var require_rules = __commonJS({
1428
1845
  "node_modules/ajv/dist/compile/rules.js"(exports2) {
1429
1846
  "use strict";
1847
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1430
1848
  Object.defineProperty(exports2, "__esModule", { value: true });
1431
1849
  exports2.getRules = exports2.isJSONType = void 0;
1432
1850
  var _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
@@ -1458,6 +1876,7 @@ var require_rules = __commonJS({
1458
1876
  var require_applicability = __commonJS({
1459
1877
  "node_modules/ajv/dist/compile/validate/applicability.js"(exports2) {
1460
1878
  "use strict";
1879
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1461
1880
  Object.defineProperty(exports2, "__esModule", { value: true });
1462
1881
  exports2.shouldUseRule = exports2.shouldUseGroup = exports2.schemaHasRulesForType = void 0;
1463
1882
  function schemaHasRulesForType({ schema, self }, type) {
@@ -1481,6 +1900,7 @@ var require_applicability = __commonJS({
1481
1900
  var require_dataType = __commonJS({
1482
1901
  "node_modules/ajv/dist/compile/validate/dataType.js"(exports2) {
1483
1902
  "use strict";
1903
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1484
1904
  Object.defineProperty(exports2, "__esModule", { value: true });
1485
1905
  exports2.reportTypeError = exports2.checkDataTypes = exports2.checkDataType = exports2.coerceAndCheckDataType = exports2.getJSONTypes = exports2.getSchemaTypes = exports2.DataType = void 0;
1486
1906
  var rules_1 = require_rules();
@@ -1665,6 +2085,7 @@ var require_dataType = __commonJS({
1665
2085
  var require_defaults = __commonJS({
1666
2086
  "node_modules/ajv/dist/compile/validate/defaults.js"(exports2) {
1667
2087
  "use strict";
2088
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1668
2089
  Object.defineProperty(exports2, "__esModule", { value: true });
1669
2090
  exports2.assignDefaults = void 0;
1670
2091
  var codegen_1 = require_codegen();
@@ -1702,6 +2123,7 @@ var require_defaults = __commonJS({
1702
2123
  var require_code2 = __commonJS({
1703
2124
  "node_modules/ajv/dist/vocabularies/code.js"(exports2) {
1704
2125
  "use strict";
2126
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1705
2127
  Object.defineProperty(exports2, "__esModule", { value: true });
1706
2128
  exports2.validateUnion = exports2.validateArray = exports2.usePattern = exports2.callValidateCode = exports2.schemaProperties = exports2.allSchemaProperties = exports2.noPropertyInData = exports2.propertyInData = exports2.isOwnProperty = exports2.hasPropFunc = exports2.reportMissingProp = exports2.checkMissingProp = exports2.checkReportMissingProp = void 0;
1707
2129
  var codegen_1 = require_codegen();
@@ -1835,6 +2257,7 @@ var require_code2 = __commonJS({
1835
2257
  var require_keyword = __commonJS({
1836
2258
  "node_modules/ajv/dist/compile/validate/keyword.js"(exports2) {
1837
2259
  "use strict";
2260
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1838
2261
  Object.defineProperty(exports2, "__esModule", { value: true });
1839
2262
  exports2.validateKeywordUsage = exports2.validSchemaType = exports2.funcKeywordCode = exports2.macroKeywordCode = void 0;
1840
2263
  var codegen_1 = require_codegen();
@@ -1953,6 +2376,7 @@ var require_keyword = __commonJS({
1953
2376
  var require_subschema = __commonJS({
1954
2377
  "node_modules/ajv/dist/compile/validate/subschema.js"(exports2) {
1955
2378
  "use strict";
2379
+ init_define_WORKFLOW_BUILDER_BRIDGE();
1956
2380
  Object.defineProperty(exports2, "__esModule", { value: true });
1957
2381
  exports2.extendSubschemaMode = exports2.extendSubschemaData = exports2.getSubschema = void 0;
1958
2382
  var codegen_1 = require_codegen();
@@ -2036,6 +2460,7 @@ var require_subschema = __commonJS({
2036
2460
  var require_fast_deep_equal = __commonJS({
2037
2461
  "node_modules/fast-deep-equal/index.js"(exports2, module2) {
2038
2462
  "use strict";
2463
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2039
2464
  module2.exports = function equal2(a, b) {
2040
2465
  if (a === b) return true;
2041
2466
  if (a && b && typeof a == "object" && typeof b == "object") {
@@ -2071,6 +2496,7 @@ var require_fast_deep_equal = __commonJS({
2071
2496
  var require_json_schema_traverse = __commonJS({
2072
2497
  "node_modules/json-schema-traverse/index.js"(exports2, module2) {
2073
2498
  "use strict";
2499
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2074
2500
  var traverse = module2.exports = function(schema, opts, cb) {
2075
2501
  if (typeof opts == "function") {
2076
2502
  cb = opts;
@@ -2159,6 +2585,7 @@ var require_json_schema_traverse = __commonJS({
2159
2585
  var require_resolve = __commonJS({
2160
2586
  "node_modules/ajv/dist/compile/resolve.js"(exports2) {
2161
2587
  "use strict";
2588
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2162
2589
  Object.defineProperty(exports2, "__esModule", { value: true });
2163
2590
  exports2.getSchemaRefs = exports2.resolveUrl = exports2.normalizeId = exports2._getFullPath = exports2.getFullPath = exports2.inlineRef = void 0;
2164
2591
  var util_1 = require_util();
@@ -2315,6 +2742,7 @@ var require_resolve = __commonJS({
2315
2742
  var require_validate = __commonJS({
2316
2743
  "node_modules/ajv/dist/compile/validate/index.js"(exports2) {
2317
2744
  "use strict";
2745
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2318
2746
  Object.defineProperty(exports2, "__esModule", { value: true });
2319
2747
  exports2.getData = exports2.KeywordCxt = exports2.validateFunctionCode = void 0;
2320
2748
  var boolSchema_1 = require_boolSchema();
@@ -2823,6 +3251,7 @@ var require_validate = __commonJS({
2823
3251
  var require_validation_error = __commonJS({
2824
3252
  "node_modules/ajv/dist/runtime/validation_error.js"(exports2) {
2825
3253
  "use strict";
3254
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2826
3255
  Object.defineProperty(exports2, "__esModule", { value: true });
2827
3256
  var ValidationError = class extends Error {
2828
3257
  constructor(errors) {
@@ -2839,6 +3268,7 @@ var require_validation_error = __commonJS({
2839
3268
  var require_ref_error = __commonJS({
2840
3269
  "node_modules/ajv/dist/compile/ref_error.js"(exports2) {
2841
3270
  "use strict";
3271
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2842
3272
  Object.defineProperty(exports2, "__esModule", { value: true });
2843
3273
  var resolve_1 = require_resolve();
2844
3274
  var MissingRefError = class extends Error {
@@ -2856,6 +3286,7 @@ var require_ref_error = __commonJS({
2856
3286
  var require_compile = __commonJS({
2857
3287
  "node_modules/ajv/dist/compile/index.js"(exports2) {
2858
3288
  "use strict";
3289
+ init_define_WORKFLOW_BUILDER_BRIDGE();
2859
3290
  Object.defineProperty(exports2, "__esModule", { value: true });
2860
3291
  exports2.resolveSchema = exports2.getCompilingSchema = exports2.resolveRef = exports2.compileSchema = exports2.SchemaEnv = void 0;
2861
3292
  var codegen_1 = require_codegen();
@@ -2976,7 +3407,7 @@ var require_compile = __commonJS({
2976
3407
  const schOrFunc = root.refs[ref];
2977
3408
  if (schOrFunc)
2978
3409
  return schOrFunc;
2979
- let _sch = resolve2.call(this, root, ref);
3410
+ let _sch = resolve3.call(this, root, ref);
2980
3411
  if (_sch === void 0) {
2981
3412
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
2982
3413
  const { schemaId } = this.opts;
@@ -3003,7 +3434,7 @@ var require_compile = __commonJS({
3003
3434
  function sameSchemaEnv(s1, s2) {
3004
3435
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3005
3436
  }
3006
- function resolve2(root, ref) {
3437
+ function resolve3(root, ref) {
3007
3438
  let sch;
3008
3439
  while (typeof (sch = this.refs[ref]) == "string")
3009
3440
  ref = sch;
@@ -3099,6 +3530,7 @@ var require_data = __commonJS({
3099
3530
  var require_utils = __commonJS({
3100
3531
  "node_modules/fast-uri/lib/utils.js"(exports2, module2) {
3101
3532
  "use strict";
3533
+ init_define_WORKFLOW_BUILDER_BRIDGE();
3102
3534
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3103
3535
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3104
3536
  var isPort = RegExp.prototype.test.bind(/^\d*$/u);
@@ -3633,6 +4065,7 @@ var require_utils = __commonJS({
3633
4065
  var require_schemes = __commonJS({
3634
4066
  "node_modules/fast-uri/lib/schemes.js"(exports2, module2) {
3635
4067
  "use strict";
4068
+ init_define_WORKFLOW_BUILDER_BRIDGE();
3636
4069
  var { isUUID } = require_utils();
3637
4070
  var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3638
4071
  var supportedSchemeNames = (
@@ -3844,6 +4277,7 @@ var require_schemes = __commonJS({
3844
4277
  var require_fast_uri = __commonJS({
3845
4278
  "node_modules/fast-uri/index.js"(exports2, module2) {
3846
4279
  "use strict";
4280
+ init_define_WORKFLOW_BUILDER_BRIDGE();
3847
4281
  var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3848
4282
  var { SCHEMES, getSchemeHandler } = require_schemes();
3849
4283
  var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
@@ -3867,7 +4301,7 @@ var require_fast_uri = __commonJS({
3867
4301
  }
3868
4302
  return uri;
3869
4303
  }
3870
- function resolve2(baseURI, relativeURI, options) {
4304
+ function resolve3(baseURI, relativeURI, options) {
3871
4305
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3872
4306
  const {
3873
4307
  parsed: baseParsed,
@@ -4258,7 +4692,7 @@ var require_fast_uri = __commonJS({
4258
4692
  var fastUri = {
4259
4693
  SCHEMES,
4260
4694
  normalize,
4261
- resolve: resolve2,
4695
+ resolve: resolve3,
4262
4696
  resolveComponent,
4263
4697
  equal: equal2,
4264
4698
  serialize,
@@ -4274,6 +4708,7 @@ var require_fast_uri = __commonJS({
4274
4708
  var require_uri = __commonJS({
4275
4709
  "node_modules/ajv/dist/runtime/uri.js"(exports2) {
4276
4710
  "use strict";
4711
+ init_define_WORKFLOW_BUILDER_BRIDGE();
4277
4712
  Object.defineProperty(exports2, "__esModule", { value: true });
4278
4713
  var uri = require_fast_uri();
4279
4714
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -4285,6 +4720,7 @@ var require_uri = __commonJS({
4285
4720
  var require_core = __commonJS({
4286
4721
  "node_modules/ajv/dist/core.js"(exports2) {
4287
4722
  "use strict";
4723
+ init_define_WORKFLOW_BUILDER_BRIDGE();
4288
4724
  Object.defineProperty(exports2, "__esModule", { value: true });
4289
4725
  exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = void 0;
4290
4726
  var validate_1 = require_validate();
@@ -4896,6 +5332,7 @@ var require_core = __commonJS({
4896
5332
  var require_id = __commonJS({
4897
5333
  "node_modules/ajv/dist/vocabularies/core/id.js"(exports2) {
4898
5334
  "use strict";
5335
+ init_define_WORKFLOW_BUILDER_BRIDGE();
4899
5336
  Object.defineProperty(exports2, "__esModule", { value: true });
4900
5337
  var def = {
4901
5338
  keyword: "id",
@@ -4911,6 +5348,7 @@ var require_id = __commonJS({
4911
5348
  var require_ref = __commonJS({
4912
5349
  "node_modules/ajv/dist/vocabularies/core/ref.js"(exports2) {
4913
5350
  "use strict";
5351
+ init_define_WORKFLOW_BUILDER_BRIDGE();
4914
5352
  Object.defineProperty(exports2, "__esModule", { value: true });
4915
5353
  exports2.callRef = exports2.getValidate = void 0;
4916
5354
  var ref_error_1 = require_ref_error();
@@ -5033,6 +5471,7 @@ var require_ref = __commonJS({
5033
5471
  var require_core2 = __commonJS({
5034
5472
  "node_modules/ajv/dist/vocabularies/core/index.js"(exports2) {
5035
5473
  "use strict";
5474
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5036
5475
  Object.defineProperty(exports2, "__esModule", { value: true });
5037
5476
  var id_1 = require_id();
5038
5477
  var ref_1 = require_ref();
@@ -5054,6 +5493,7 @@ var require_core2 = __commonJS({
5054
5493
  var require_limitNumber = __commonJS({
5055
5494
  "node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports2) {
5056
5495
  "use strict";
5496
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5057
5497
  Object.defineProperty(exports2, "__esModule", { value: true });
5058
5498
  var codegen_1 = require_codegen();
5059
5499
  var ops = codegen_1.operators;
@@ -5086,6 +5526,7 @@ var require_limitNumber = __commonJS({
5086
5526
  var require_multipleOf = __commonJS({
5087
5527
  "node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports2) {
5088
5528
  "use strict";
5529
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5089
5530
  Object.defineProperty(exports2, "__esModule", { value: true });
5090
5531
  var codegen_1 = require_codegen();
5091
5532
  var error = {
@@ -5114,6 +5555,7 @@ var require_multipleOf = __commonJS({
5114
5555
  var require_ucs2length = __commonJS({
5115
5556
  "node_modules/ajv/dist/runtime/ucs2length.js"(exports2) {
5116
5557
  "use strict";
5558
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5117
5559
  Object.defineProperty(exports2, "__esModule", { value: true });
5118
5560
  function ucs2length(str) {
5119
5561
  const len = str.length;
@@ -5140,6 +5582,7 @@ var require_ucs2length = __commonJS({
5140
5582
  var require_limitLength = __commonJS({
5141
5583
  "node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports2) {
5142
5584
  "use strict";
5585
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5143
5586
  Object.defineProperty(exports2, "__esModule", { value: true });
5144
5587
  var codegen_1 = require_codegen();
5145
5588
  var util_1 = require_util();
@@ -5172,6 +5615,7 @@ var require_limitLength = __commonJS({
5172
5615
  var require_pattern = __commonJS({
5173
5616
  "node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports2) {
5174
5617
  "use strict";
5618
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5175
5619
  Object.defineProperty(exports2, "__esModule", { value: true });
5176
5620
  var code_1 = require_code2();
5177
5621
  var codegen_1 = require_codegen();
@@ -5200,6 +5644,7 @@ var require_pattern = __commonJS({
5200
5644
  var require_limitProperties = __commonJS({
5201
5645
  "node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports2) {
5202
5646
  "use strict";
5647
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5203
5648
  Object.defineProperty(exports2, "__esModule", { value: true });
5204
5649
  var codegen_1 = require_codegen();
5205
5650
  var error = {
@@ -5229,6 +5674,7 @@ var require_limitProperties = __commonJS({
5229
5674
  var require_required = __commonJS({
5230
5675
  "node_modules/ajv/dist/vocabularies/validation/required.js"(exports2) {
5231
5676
  "use strict";
5677
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5232
5678
  Object.defineProperty(exports2, "__esModule", { value: true });
5233
5679
  var code_1 = require_code2();
5234
5680
  var codegen_1 = require_codegen();
@@ -5311,6 +5757,7 @@ var require_required = __commonJS({
5311
5757
  var require_limitItems = __commonJS({
5312
5758
  "node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports2) {
5313
5759
  "use strict";
5760
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5314
5761
  Object.defineProperty(exports2, "__esModule", { value: true });
5315
5762
  var codegen_1 = require_codegen();
5316
5763
  var error = {
@@ -5340,6 +5787,7 @@ var require_limitItems = __commonJS({
5340
5787
  var require_equal = __commonJS({
5341
5788
  "node_modules/ajv/dist/runtime/equal.js"(exports2) {
5342
5789
  "use strict";
5790
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5343
5791
  Object.defineProperty(exports2, "__esModule", { value: true });
5344
5792
  var equal2 = require_fast_deep_equal();
5345
5793
  equal2.code = 'require("ajv/dist/runtime/equal").default';
@@ -5351,6 +5799,7 @@ var require_equal = __commonJS({
5351
5799
  var require_uniqueItems = __commonJS({
5352
5800
  "node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports2) {
5353
5801
  "use strict";
5802
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5354
5803
  Object.defineProperty(exports2, "__esModule", { value: true });
5355
5804
  var dataType_1 = require_dataType();
5356
5805
  var codegen_1 = require_codegen();
@@ -5418,6 +5867,7 @@ var require_uniqueItems = __commonJS({
5418
5867
  var require_const = __commonJS({
5419
5868
  "node_modules/ajv/dist/vocabularies/validation/const.js"(exports2) {
5420
5869
  "use strict";
5870
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5421
5871
  Object.defineProperty(exports2, "__esModule", { value: true });
5422
5872
  var codegen_1 = require_codegen();
5423
5873
  var util_1 = require_util();
@@ -5447,6 +5897,7 @@ var require_const = __commonJS({
5447
5897
  var require_enum = __commonJS({
5448
5898
  "node_modules/ajv/dist/vocabularies/validation/enum.js"(exports2) {
5449
5899
  "use strict";
5900
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5450
5901
  Object.defineProperty(exports2, "__esModule", { value: true });
5451
5902
  var codegen_1 = require_codegen();
5452
5903
  var util_1 = require_util();
@@ -5496,6 +5947,7 @@ var require_enum = __commonJS({
5496
5947
  var require_validation = __commonJS({
5497
5948
  "node_modules/ajv/dist/vocabularies/validation/index.js"(exports2) {
5498
5949
  "use strict";
5950
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5499
5951
  Object.defineProperty(exports2, "__esModule", { value: true });
5500
5952
  var limitNumber_1 = require_limitNumber();
5501
5953
  var multipleOf_1 = require_multipleOf();
@@ -5534,6 +5986,7 @@ var require_validation = __commonJS({
5534
5986
  var require_additionalItems = __commonJS({
5535
5987
  "node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports2) {
5536
5988
  "use strict";
5989
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5537
5990
  Object.defineProperty(exports2, "__esModule", { value: true });
5538
5991
  exports2.validateAdditionalItems = void 0;
5539
5992
  var codegen_1 = require_codegen();
@@ -5587,6 +6040,7 @@ var require_additionalItems = __commonJS({
5587
6040
  var require_items = __commonJS({
5588
6041
  "node_modules/ajv/dist/vocabularies/applicator/items.js"(exports2) {
5589
6042
  "use strict";
6043
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5590
6044
  Object.defineProperty(exports2, "__esModule", { value: true });
5591
6045
  exports2.validateTuple = void 0;
5592
6046
  var codegen_1 = require_codegen();
@@ -5644,6 +6098,7 @@ var require_items = __commonJS({
5644
6098
  var require_prefixItems = __commonJS({
5645
6099
  "node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports2) {
5646
6100
  "use strict";
6101
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5647
6102
  Object.defineProperty(exports2, "__esModule", { value: true });
5648
6103
  var items_1 = require_items();
5649
6104
  var def = {
@@ -5661,6 +6116,7 @@ var require_prefixItems = __commonJS({
5661
6116
  var require_items2020 = __commonJS({
5662
6117
  "node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports2) {
5663
6118
  "use strict";
6119
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5664
6120
  Object.defineProperty(exports2, "__esModule", { value: true });
5665
6121
  var codegen_1 = require_codegen();
5666
6122
  var util_1 = require_util();
@@ -5696,6 +6152,7 @@ var require_items2020 = __commonJS({
5696
6152
  var require_contains = __commonJS({
5697
6153
  "node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports2) {
5698
6154
  "use strict";
6155
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5699
6156
  Object.defineProperty(exports2, "__esModule", { value: true });
5700
6157
  var codegen_1 = require_codegen();
5701
6158
  var util_1 = require_util();
@@ -5790,6 +6247,7 @@ var require_contains = __commonJS({
5790
6247
  var require_dependencies = __commonJS({
5791
6248
  "node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports2) {
5792
6249
  "use strict";
6250
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5793
6251
  Object.defineProperty(exports2, "__esModule", { value: true });
5794
6252
  exports2.validateSchemaDeps = exports2.validatePropertyDeps = exports2.error = void 0;
5795
6253
  var codegen_1 = require_codegen();
@@ -5884,6 +6342,7 @@ var require_dependencies = __commonJS({
5884
6342
  var require_propertyNames = __commonJS({
5885
6343
  "node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports2) {
5886
6344
  "use strict";
6345
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5887
6346
  Object.defineProperty(exports2, "__esModule", { value: true });
5888
6347
  var codegen_1 = require_codegen();
5889
6348
  var util_1 = require_util();
@@ -5927,6 +6386,7 @@ var require_propertyNames = __commonJS({
5927
6386
  var require_additionalProperties = __commonJS({
5928
6387
  "node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports2) {
5929
6388
  "use strict";
6389
+ init_define_WORKFLOW_BUILDER_BRIDGE();
5930
6390
  Object.defineProperty(exports2, "__esModule", { value: true });
5931
6391
  var code_1 = require_code2();
5932
6392
  var codegen_1 = require_codegen();
@@ -6033,6 +6493,7 @@ var require_additionalProperties = __commonJS({
6033
6493
  var require_properties = __commonJS({
6034
6494
  "node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports2) {
6035
6495
  "use strict";
6496
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6036
6497
  Object.defineProperty(exports2, "__esModule", { value: true });
6037
6498
  var validate_1 = require_validate();
6038
6499
  var code_1 = require_code2();
@@ -6091,6 +6552,7 @@ var require_properties = __commonJS({
6091
6552
  var require_patternProperties = __commonJS({
6092
6553
  "node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports2) {
6093
6554
  "use strict";
6555
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6094
6556
  Object.defineProperty(exports2, "__esModule", { value: true });
6095
6557
  var code_1 = require_code2();
6096
6558
  var codegen_1 = require_codegen();
@@ -6165,6 +6627,7 @@ var require_patternProperties = __commonJS({
6165
6627
  var require_not = __commonJS({
6166
6628
  "node_modules/ajv/dist/vocabularies/applicator/not.js"(exports2) {
6167
6629
  "use strict";
6630
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6168
6631
  Object.defineProperty(exports2, "__esModule", { value: true });
6169
6632
  var util_1 = require_util();
6170
6633
  var def = {
@@ -6196,6 +6659,7 @@ var require_not = __commonJS({
6196
6659
  var require_anyOf = __commonJS({
6197
6660
  "node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports2) {
6198
6661
  "use strict";
6662
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6199
6663
  Object.defineProperty(exports2, "__esModule", { value: true });
6200
6664
  var code_1 = require_code2();
6201
6665
  var def = {
@@ -6213,6 +6677,7 @@ var require_anyOf = __commonJS({
6213
6677
  var require_oneOf = __commonJS({
6214
6678
  "node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports2) {
6215
6679
  "use strict";
6680
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6216
6681
  Object.defineProperty(exports2, "__esModule", { value: true });
6217
6682
  var codegen_1 = require_codegen();
6218
6683
  var util_1 = require_util();
@@ -6271,6 +6736,7 @@ var require_oneOf = __commonJS({
6271
6736
  var require_allOf = __commonJS({
6272
6737
  "node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports2) {
6273
6738
  "use strict";
6739
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6274
6740
  Object.defineProperty(exports2, "__esModule", { value: true });
6275
6741
  var util_1 = require_util();
6276
6742
  var def = {
@@ -6298,6 +6764,7 @@ var require_allOf = __commonJS({
6298
6764
  var require_if = __commonJS({
6299
6765
  "node_modules/ajv/dist/vocabularies/applicator/if.js"(exports2) {
6300
6766
  "use strict";
6767
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6301
6768
  Object.defineProperty(exports2, "__esModule", { value: true });
6302
6769
  var codegen_1 = require_codegen();
6303
6770
  var util_1 = require_util();
@@ -6367,6 +6834,7 @@ var require_if = __commonJS({
6367
6834
  var require_thenElse = __commonJS({
6368
6835
  "node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports2) {
6369
6836
  "use strict";
6837
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6370
6838
  Object.defineProperty(exports2, "__esModule", { value: true });
6371
6839
  var util_1 = require_util();
6372
6840
  var def = {
@@ -6385,6 +6853,7 @@ var require_thenElse = __commonJS({
6385
6853
  var require_applicator = __commonJS({
6386
6854
  "node_modules/ajv/dist/vocabularies/applicator/index.js"(exports2) {
6387
6855
  "use strict";
6856
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6388
6857
  Object.defineProperty(exports2, "__esModule", { value: true });
6389
6858
  var additionalItems_1 = require_additionalItems();
6390
6859
  var prefixItems_1 = require_prefixItems();
@@ -6433,6 +6902,7 @@ var require_applicator = __commonJS({
6433
6902
  var require_dynamicAnchor = __commonJS({
6434
6903
  "node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js"(exports2) {
6435
6904
  "use strict";
6905
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6436
6906
  Object.defineProperty(exports2, "__esModule", { value: true });
6437
6907
  exports2.dynamicAnchor = void 0;
6438
6908
  var codegen_1 = require_codegen();
@@ -6468,6 +6938,7 @@ var require_dynamicAnchor = __commonJS({
6468
6938
  var require_dynamicRef = __commonJS({
6469
6939
  "node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js"(exports2) {
6470
6940
  "use strict";
6941
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6471
6942
  Object.defineProperty(exports2, "__esModule", { value: true });
6472
6943
  exports2.dynamicRef = void 0;
6473
6944
  var codegen_1 = require_codegen();
@@ -6514,6 +6985,7 @@ var require_dynamicRef = __commonJS({
6514
6985
  var require_recursiveAnchor = __commonJS({
6515
6986
  "node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js"(exports2) {
6516
6987
  "use strict";
6988
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6517
6989
  Object.defineProperty(exports2, "__esModule", { value: true });
6518
6990
  var dynamicAnchor_1 = require_dynamicAnchor();
6519
6991
  var util_1 = require_util();
@@ -6535,6 +7007,7 @@ var require_recursiveAnchor = __commonJS({
6535
7007
  var require_recursiveRef = __commonJS({
6536
7008
  "node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js"(exports2) {
6537
7009
  "use strict";
7010
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6538
7011
  Object.defineProperty(exports2, "__esModule", { value: true });
6539
7012
  var dynamicRef_1 = require_dynamicRef();
6540
7013
  var def = {
@@ -6550,6 +7023,7 @@ var require_recursiveRef = __commonJS({
6550
7023
  var require_dynamic = __commonJS({
6551
7024
  "node_modules/ajv/dist/vocabularies/dynamic/index.js"(exports2) {
6552
7025
  "use strict";
7026
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6553
7027
  Object.defineProperty(exports2, "__esModule", { value: true });
6554
7028
  var dynamicAnchor_1 = require_dynamicAnchor();
6555
7029
  var dynamicRef_1 = require_dynamicRef();
@@ -6564,6 +7038,7 @@ var require_dynamic = __commonJS({
6564
7038
  var require_dependentRequired = __commonJS({
6565
7039
  "node_modules/ajv/dist/vocabularies/validation/dependentRequired.js"(exports2) {
6566
7040
  "use strict";
7041
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6567
7042
  Object.defineProperty(exports2, "__esModule", { value: true });
6568
7043
  var dependencies_1 = require_dependencies();
6569
7044
  var def = {
@@ -6581,6 +7056,7 @@ var require_dependentRequired = __commonJS({
6581
7056
  var require_dependentSchemas = __commonJS({
6582
7057
  "node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js"(exports2) {
6583
7058
  "use strict";
7059
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6584
7060
  Object.defineProperty(exports2, "__esModule", { value: true });
6585
7061
  var dependencies_1 = require_dependencies();
6586
7062
  var def = {
@@ -6597,6 +7073,7 @@ var require_dependentSchemas = __commonJS({
6597
7073
  var require_limitContains = __commonJS({
6598
7074
  "node_modules/ajv/dist/vocabularies/validation/limitContains.js"(exports2) {
6599
7075
  "use strict";
7076
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6600
7077
  Object.defineProperty(exports2, "__esModule", { value: true });
6601
7078
  var util_1 = require_util();
6602
7079
  var def = {
@@ -6617,6 +7094,7 @@ var require_limitContains = __commonJS({
6617
7094
  var require_next = __commonJS({
6618
7095
  "node_modules/ajv/dist/vocabularies/next.js"(exports2) {
6619
7096
  "use strict";
7097
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6620
7098
  Object.defineProperty(exports2, "__esModule", { value: true });
6621
7099
  var dependentRequired_1 = require_dependentRequired();
6622
7100
  var dependentSchemas_1 = require_dependentSchemas();
@@ -6630,6 +7108,7 @@ var require_next = __commonJS({
6630
7108
  var require_unevaluatedProperties = __commonJS({
6631
7109
  "node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js"(exports2) {
6632
7110
  "use strict";
7111
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6633
7112
  Object.defineProperty(exports2, "__esModule", { value: true });
6634
7113
  var codegen_1 = require_codegen();
6635
7114
  var util_1 = require_util();
@@ -6696,6 +7175,7 @@ var require_unevaluatedProperties = __commonJS({
6696
7175
  var require_unevaluatedItems = __commonJS({
6697
7176
  "node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js"(exports2) {
6698
7177
  "use strict";
7178
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6699
7179
  Object.defineProperty(exports2, "__esModule", { value: true });
6700
7180
  var codegen_1 = require_codegen();
6701
7181
  var util_1 = require_util();
@@ -6740,6 +7220,7 @@ var require_unevaluatedItems = __commonJS({
6740
7220
  var require_unevaluated = __commonJS({
6741
7221
  "node_modules/ajv/dist/vocabularies/unevaluated/index.js"(exports2) {
6742
7222
  "use strict";
7223
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6743
7224
  Object.defineProperty(exports2, "__esModule", { value: true });
6744
7225
  var unevaluatedProperties_1 = require_unevaluatedProperties();
6745
7226
  var unevaluatedItems_1 = require_unevaluatedItems();
@@ -6752,6 +7233,7 @@ var require_unevaluated = __commonJS({
6752
7233
  var require_format = __commonJS({
6753
7234
  "node_modules/ajv/dist/vocabularies/format/format.js"(exports2) {
6754
7235
  "use strict";
7236
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6755
7237
  Object.defineProperty(exports2, "__esModule", { value: true });
6756
7238
  var codegen_1 = require_codegen();
6757
7239
  var error = {
@@ -6842,6 +7324,7 @@ var require_format = __commonJS({
6842
7324
  var require_format2 = __commonJS({
6843
7325
  "node_modules/ajv/dist/vocabularies/format/index.js"(exports2) {
6844
7326
  "use strict";
7327
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6845
7328
  Object.defineProperty(exports2, "__esModule", { value: true });
6846
7329
  var format_1 = require_format();
6847
7330
  var format = [format_1.default];
@@ -6853,6 +7336,7 @@ var require_format2 = __commonJS({
6853
7336
  var require_metadata = __commonJS({
6854
7337
  "node_modules/ajv/dist/vocabularies/metadata.js"(exports2) {
6855
7338
  "use strict";
7339
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6856
7340
  Object.defineProperty(exports2, "__esModule", { value: true });
6857
7341
  exports2.contentVocabulary = exports2.metadataVocabulary = void 0;
6858
7342
  exports2.metadataVocabulary = [
@@ -6876,6 +7360,7 @@ var require_metadata = __commonJS({
6876
7360
  var require_draft2020 = __commonJS({
6877
7361
  "node_modules/ajv/dist/vocabularies/draft2020.js"(exports2) {
6878
7362
  "use strict";
7363
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6879
7364
  Object.defineProperty(exports2, "__esModule", { value: true });
6880
7365
  var core_1 = require_core2();
6881
7366
  var validation_1 = require_validation();
@@ -6904,6 +7389,7 @@ var require_draft2020 = __commonJS({
6904
7389
  var require_types = __commonJS({
6905
7390
  "node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports2) {
6906
7391
  "use strict";
7392
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6907
7393
  Object.defineProperty(exports2, "__esModule", { value: true });
6908
7394
  exports2.DiscrError = void 0;
6909
7395
  var DiscrError;
@@ -6918,6 +7404,7 @@ var require_types = __commonJS({
6918
7404
  var require_discriminator = __commonJS({
6919
7405
  "node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports2) {
6920
7406
  "use strict";
7407
+ init_define_WORKFLOW_BUILDER_BRIDGE();
6921
7408
  Object.defineProperty(exports2, "__esModule", { value: true });
6922
7409
  var codegen_1 = require_codegen();
6923
7410
  var types_1 = require_types();
@@ -7388,6 +7875,7 @@ var require_validation2 = __commonJS({
7388
7875
  var require_json_schema_2020_12 = __commonJS({
7389
7876
  "node_modules/ajv/dist/refs/json-schema-2020-12/index.js"(exports2) {
7390
7877
  "use strict";
7878
+ init_define_WORKFLOW_BUILDER_BRIDGE();
7391
7879
  Object.defineProperty(exports2, "__esModule", { value: true });
7392
7880
  var metaSchema = require_schema();
7393
7881
  var applicator = require_applicator2();
@@ -7423,6 +7911,7 @@ var require_json_schema_2020_12 = __commonJS({
7423
7911
  var require__ = __commonJS({
7424
7912
  "node_modules/ajv/dist/2020.js"(exports2, module2) {
7425
7913
  "use strict";
7914
+ init_define_WORKFLOW_BUILDER_BRIDGE();
7426
7915
  Object.defineProperty(exports2, "__esModule", { value: true });
7427
7916
  exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = exports2.Ajv2020 = void 0;
7428
7917
  var core_1 = require_core();
@@ -7497,32 +7986,34 @@ var require__ = __commonJS({
7497
7986
  });
7498
7987
 
7499
7988
  // src/cli.mjs
7989
+ init_define_WORKFLOW_BUILDER_BRIDGE();
7500
7990
  var import_consumers = require("node:stream/consumers");
7501
7991
  var import_node_util = require("node:util");
7502
7992
  var import_node_path3 = require("node:path");
7503
7993
 
7504
7994
  // package.json
7505
7995
  var package_default = {
7506
- name: "@accio-ai/workflow-builder-cli",
7507
- version: "0.2.1-rc.1",
7996
+ name: "accio-workflow-builder-cli",
7997
+ version: "0.2.22",
7998
+ private: true,
7508
7999
  description: "Revisioned CLI for building and validating fde.workflow v2 definitions",
7509
8000
  type: "module",
7510
- engines: {
7511
- node: ">=22"
8001
+ engines: { node: ">=22" },
8002
+ bin: { "workflow-builder": "dist/workflow-builder.cjs" },
8003
+ files: ["dist/workflow-builder.cjs", "docs", "scripts/reproduce-orders.sh", "src/schemas/*.schema.json"],
8004
+ scripts: {
8005
+ build: "node scripts/build.mjs",
8006
+ test: "npm run build && node --test test/*.test.mjs",
8007
+ prepack: "npm run build"
7512
8008
  },
7513
- bin: {
7514
- "workflow-builder": "dist/workflow-builder.cjs"
7515
- },
7516
- files: [
7517
- "dist/workflow-builder.cjs"
7518
- ],
7519
- publishConfig: {
7520
- registry: "https://registry.npmjs.org/",
7521
- access: "public"
8009
+ devDependencies: {
8010
+ ajv: "8.17.1",
8011
+ esbuild: "0.27.7"
7522
8012
  }
7523
8013
  };
7524
8014
 
7525
8015
  // src/compile.mjs
8016
+ init_define_WORKFLOW_BUILDER_BRIDGE();
7526
8017
  var import__ = __toESM(require__(), 1);
7527
8018
 
7528
8019
  // src/schemas/fde.workflow.v2.schema.json
@@ -7936,12 +8427,20 @@ var fde_workflow_v2_schema_default = {
7936
8427
  "PRIVATE",
7937
8428
  "GROUP"
7938
8429
  ]
8430
+ },
8431
+ channel: {
8432
+ $ref: "#/$defs/deliveryChannel"
7939
8433
  }
7940
8434
  },
7941
8435
  required: [
7942
8436
  "mode"
7943
8437
  ],
7944
- additionalProperties: false
8438
+ additionalProperties: false,
8439
+ allOf: [
8440
+ {
8441
+ $ref: "#/$defs/channelOnlyInPrivateDelivery"
8442
+ }
8443
+ ]
7945
8444
  }
7946
8445
  },
7947
8446
  required: [
@@ -8176,7 +8675,7 @@ var fde_workflow_v2_schema_default = {
8176
8675
  maxLength: 2e3
8177
8676
  },
8178
8677
  delivery: {
8179
- $ref: "#/$defs/humanDelivery"
8678
+ $ref: "#/$defs/notificationDelivery"
8180
8679
  },
8181
8680
  assigneeRefs: {
8182
8681
  type: "array",
@@ -8433,6 +8932,9 @@ var fde_workflow_v2_schema_default = {
8433
8932
  "GROUP"
8434
8933
  ]
8435
8934
  },
8935
+ channel: {
8936
+ $ref: "#/$defs/deliveryChannel"
8937
+ },
8436
8938
  groupId: {
8437
8939
  type: "string",
8438
8940
  minLength: 1,
@@ -8445,6 +8947,9 @@ var fde_workflow_v2_schema_default = {
8445
8947
  ],
8446
8948
  additionalProperties: false,
8447
8949
  allOf: [
8950
+ {
8951
+ $ref: "#/$defs/channelOnlyInPrivateDelivery"
8952
+ },
8448
8953
  {
8449
8954
  if: {
8450
8955
  properties: {
@@ -8470,11 +8975,87 @@ var fde_workflow_v2_schema_default = {
8470
8975
  }
8471
8976
  }
8472
8977
  ]
8978
+ },
8979
+ notificationDelivery: {
8980
+ description: "\u901A\u77E5\u8282\u70B9\u6295\u9012\u914D\u7F6E\uFF1B\u7FA4\u804A\u7F3A\u7701\u7FA4\u5F15\u7528\u8868\u793A\u6D3E\u53D1\u65F6\u89E3\u6790\u5DE5\u4F5C\u6D41\u5F53\u524D\u6D3B\u8DC3\u7FA4\u7ED1\u5B9A\u3002",
8981
+ type: "object",
8982
+ properties: {
8983
+ mode: {
8984
+ enum: [
8985
+ "PRIVATE",
8986
+ "GROUP"
8987
+ ]
8988
+ },
8989
+ channel: {
8990
+ $ref: "#/$defs/deliveryChannel"
8991
+ },
8992
+ groupId: {
8993
+ type: "string",
8994
+ minLength: 1,
8995
+ maxLength: 128,
8996
+ pattern: "^\\S+$"
8997
+ }
8998
+ },
8999
+ required: [
9000
+ "mode"
9001
+ ],
9002
+ additionalProperties: false,
9003
+ allOf: [
9004
+ {
9005
+ $ref: "#/$defs/channelOnlyInPrivateDelivery"
9006
+ },
9007
+ {
9008
+ if: {
9009
+ properties: {
9010
+ mode: {
9011
+ const: "PRIVATE"
9012
+ }
9013
+ },
9014
+ required: [
9015
+ "mode"
9016
+ ]
9017
+ },
9018
+ then: {
9019
+ not: {
9020
+ required: [
9021
+ "groupId"
9022
+ ]
9023
+ }
9024
+ }
9025
+ }
9026
+ ]
9027
+ },
9028
+ deliveryChannel: {
9029
+ type: "string",
9030
+ description: "\u79C1\u804A\u901A\u77E5\u6E20\u9053\uFF1A\u4F01\u5FAE\u3001\u4E2A\u5FAE\u6216\u53CC\u53D1\uFF1B\u7F3A\u7701\u4F01\u5FAE\u5E76\u6309\u6210\u5458\u7ED1\u5B9A\u56DE\u843D\u4E2A\u5FAE\u3002\u4EC5\u79C1\u804A\u53EF\u914D\u7F6E\uFF0C\u7FA4\u804A\u6E20\u9053\u968F\u5DE5\u4F5C\u6D41\u7ED1\u5B9A\u7684\u7FA4\u3002",
9031
+ enum: [
9032
+ "WECOM",
9033
+ "WECHAT",
9034
+ "BOTH"
9035
+ ]
9036
+ },
9037
+ channelOnlyInPrivateDelivery: {
9038
+ if: {
9039
+ properties: {
9040
+ mode: {
9041
+ const: "GROUP"
9042
+ }
9043
+ },
9044
+ required: [
9045
+ "mode"
9046
+ ]
9047
+ },
9048
+ then: {
9049
+ properties: {
9050
+ channel: false
9051
+ }
9052
+ }
8473
9053
  }
8474
9054
  }
8475
9055
  };
8476
9056
 
8477
9057
  // src/input.mjs
9058
+ init_define_WORKFLOW_BUILDER_BRIDGE();
8478
9059
  var import_node_crypto = require("node:crypto");
8479
9060
  var ID = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/;
8480
9061
  var TERMINALS = /* @__PURE__ */ new Set(["$succeeded", "$failed", "$cancelled"]);
@@ -8604,6 +9185,7 @@ function parseRequest(source) {
8604
9185
  }
8605
9186
 
8606
9187
  // src/graph.mjs
9188
+ init_define_WORKFLOW_BUILDER_BRIDGE();
8607
9189
  function orderedNodes(graph) {
8608
9190
  const ids = Object.keys(graph.nodes).sort();
8609
9191
  if (graph.entry && own(graph.nodes, graph.entry)) {
@@ -8673,6 +9255,7 @@ function matchesAssignees(assignees, approver, completionPolicy) {
8673
9255
  return (assignees ?? []).includes(approver) && (completionPolicy === "ALL" || completionPolicy === "ANY" && assignees.length === 1);
8674
9256
  }
8675
9257
  function qualifiesDraft(node, rule) {
9258
+ if (rule.approvalNodeId) return node.action === "human_approval" && node.id === rule.approvalNodeId;
8676
9259
  return node.action === "human_approval" && (node.assigneeMode ?? "FIXED") === "FIXED" && matchesAssignees(node.assignees, rule.approver, node.completionPolicy);
8677
9260
  }
8678
9261
  function bypassPath(graph, rule, qualifies) {
@@ -8715,6 +9298,51 @@ function firstBypass(graph, qualifies) {
8715
9298
  }
8716
9299
  }
8717
9300
  }
9301
+ function checkParallelFragments(graph, plan, firstSave) {
9302
+ const pending = Object.values(graph.pending);
9303
+ const forks = pending.filter((item) => item.code === "UNSUPPORTED_PARALLEL_FORK");
9304
+ const joins = pending.filter((item) => item.code === "UNSUPPORTED_ALL_JOIN");
9305
+ if (!plan && !(firstSave && forks.length && joins.length)) return;
9306
+ function fail2(reason, details = {}) {
9307
+ throw new CliError(5, "INVALID_PARALLEL_FRAGMENTS", reason, details);
9308
+ }
9309
+ if (!plan || !Array.isArray(plan.branches) || plan.branches.length < 2 || !plan.branches.every((chain) => Array.isArray(chain) && chain.length) || !Array.isArray(plan.after) || !plan.after.length) {
9310
+ fail2("Supply parallelFragments {entry,branches,after} from the requested handoffs. For private steps use the Builder skill's prepare_private_draft.py.");
9311
+ }
9312
+ if (!forks.some((item) => item.nodeId === plan.entry) || !joins.some((item) => item.nodeId === plan.after[0])) {
9313
+ fail2("Mark the actual fork and the first post-join step with their structured pending items.");
9314
+ }
9315
+ const ids = [plan.entry, ...plan.branches.flat(), ...plan.after];
9316
+ if (new Set(ids).size !== ids.length || ids.some((id) => typeof id !== "string" || !own(graph.nodes, id))) {
9317
+ fail2("Each declared fragment step must identify a distinct node in the draft.");
9318
+ }
9319
+ if (plan.afterMode !== void 0 && plan.afterMode !== "routed") fail2("Unknown post-join routing mode.");
9320
+ if (plan.afterMode === "routed") {
9321
+ const region = new Set(plan.after);
9322
+ const visited = reachable(graph, plan.after[0]);
9323
+ if (visited.size !== region.size || [...region].some((id) => !visited.has(id))) {
9324
+ fail2("The post-join decisions must reach every declared continuation and stay within that fragment.");
9325
+ }
9326
+ for (const node of Object.values(graph.nodes)) {
9327
+ if (!region.has(node.id) && edges(node).some((edge) => region.has(edge.to))) {
9328
+ fail2("A transition cannot enter the continuation before the missing all-join.", { nodeId: node.id });
9329
+ }
9330
+ }
9331
+ }
9332
+ const chains = plan.afterMode === "routed" ? plan.branches : [...plan.branches, plan.after];
9333
+ for (const chain of chains) {
9334
+ for (const [index, id] of chain.entries()) {
9335
+ const next = chain[index + 1];
9336
+ const outgoing = edges(graph.nodes[id]);
9337
+ if (next && !outgoing.some((edge) => edge.to === next)) {
9338
+ fail2("Connect the confirmed handoff within this fragment.", { nodeId: id, target: next });
9339
+ }
9340
+ if (!next && chain !== plan.after && outgoing.some((edge) => !TERMINALS.has(edge.to) || edge.to === "$succeeded")) {
9341
+ fail2("Leave the last forward transition of each independent branch open.", { nodeId: id });
9342
+ }
9343
+ }
9344
+ }
9345
+ }
8718
9346
  function assertDraft(graph) {
8719
9347
  function fail2(code, message, details = {}) {
8720
9348
  throw new CliError(5, code, message, details);
@@ -8768,6 +9396,12 @@ function assertDraft(graph) {
8768
9396
  fail2("APPROVAL_OUTCOME_REMOVED", "The approval rule still depends on this outcome.", location);
8769
9397
  }
8770
9398
  exists(rule.protect, { ruleId: rule.id, path: `/approvalRules/${rule.id}/protect` });
9399
+ if (rule.approvalNodeId) {
9400
+ if (own(graph.nodes, rule.approvalNodeId)?.action !== "human_approval") {
9401
+ fail2("APPROVAL_NODE_REQUIRED", "The rule requires its original human approval node.", location);
9402
+ }
9403
+ continue;
9404
+ }
8771
9405
  const approver = own(graph.bindings, rule.approver);
8772
9406
  if (approver && (approver.kind !== "member" || approver.scope !== rule.scope)) {
8773
9407
  fail2("APPROVER_SCOPE_MISMATCH", "The member binding does not prove the required approval scope.", {
@@ -8778,8 +9412,31 @@ function assertDraft(graph) {
8778
9412
  }
8779
9413
  }
8780
9414
  for (const item of Object.values(graph.pending)) {
9415
+ const fork = item.code === "UNSUPPORTED_PARALLEL_FORK";
9416
+ const join4 = item.code === "UNSUPPORTED_ALL_JOIN";
9417
+ if ((fork || join4) && !item.nodeId) {
9418
+ fail2("PENDING_NODE_REQUIRED", "Identify the node at the unsupported transition.", { pendingKey: item.key });
9419
+ }
8781
9420
  if (!item.nodeId) continue;
8782
9421
  exists(item.nodeId, { pendingKey: item.key, path: `/pending/${item.key}/nodeId` });
9422
+ if (fork || join4) {
9423
+ for (const node of fork ? [graph.nodes[item.nodeId]] : nodes) {
9424
+ for (const [outcome, edge] of Object.entries(node.outcomes)) {
9425
+ const continuesFromFork = edge.to && edge.to !== "$failed" && edge.to !== "$cancelled";
9426
+ if (fork ? continuesFromFork : edge.to === item.nodeId) {
9427
+ fail2("UNSUPPORTED_PARALLEL_TRANSITION", "Leave the unsupported transition disconnected in the draft.", {
9428
+ pendingKey: item.key,
9429
+ nodeId: node.id,
9430
+ outcome,
9431
+ target: edge.to
9432
+ });
9433
+ }
9434
+ }
9435
+ }
9436
+ if (join4 && graph.entry === item.nodeId) {
9437
+ fail2("UNSUPPORTED_PARALLEL_TRANSITION", "An all-input join cannot be the entry.", { nodeId: item.nodeId });
9438
+ }
9439
+ }
8783
9440
  if (item.outcome && !own(graph.nodes[item.nodeId].outcomes, item.outcome)) {
8784
9441
  fail2("PENDING_OUTCOME_REMOVED", "The pending item still references this outcome.", {
8785
9442
  pendingKey: item.key,
@@ -8845,6 +9502,7 @@ function compiledGraphIssues(graph, definition) {
8845
9502
  const compiled = { ...graph, entry: definition.entryStepId, nodes };
8846
9503
  const issues = publicationGraphIssues(compiled);
8847
9504
  const bypass = firstBypass(compiled, (step, rule) => {
9505
+ if (rule.approvalNodeId) return step.type === "HUMAN" && step.mode === "APPROVAL" && step.id === rule.approvalNodeId;
8848
9506
  const member = own(graph.bindings, rule.approver);
8849
9507
  return step.type === "HUMAN" && step.mode === "APPROVAL" && (step.assigneeMode ?? "FIXED") === "FIXED" && member?.kind === "member" && member.scope === rule.scope && matchesAssignees(step.assigneeRefs?.map(({ userId }) => userId), member.userId, step.completionPolicy);
8850
9508
  });
@@ -8873,9 +9531,11 @@ function schemaIssues(definition, known) {
8873
9531
  const outcome = match?.[2];
8874
9532
  path ||= "/";
8875
9533
  if (known.some((issue) => issue.path === path || issue.path?.startsWith(`${path}/`))) continue;
9534
+ const step = match && definition.steps[Number(match[1])];
9535
+ const privateRecipients = step?.type === "NOTIFICATION" && step.delivery?.mode === "PRIVATE" && path.endsWith("/assigneeRefs") && step.assigneeMode !== "DYNAMIC";
8876
9536
  issues.set(path, {
8877
9537
  code: "V2_SCHEMA",
8878
- message: `Field ${error.message}.`,
9538
+ message: privateRecipients ? 'Set node.assignees to the intended member binding keys, or ["$runCreator"] for the run creator.' : `Field ${error.message}.`,
8879
9539
  path,
8880
9540
  ...nodeId ? { nodeId } : {},
8881
9541
  ...outcome ? { outcome } : {}
@@ -8888,7 +9548,7 @@ function schemaIssues(definition, known) {
8888
9548
  }
8889
9549
  function preview(graph) {
8890
9550
  const issues = [];
8891
- function resolve2(key, kind, path, nodeId) {
9551
+ function resolve3(key, kind, path, nodeId) {
8892
9552
  if (key === void 0) return;
8893
9553
  const binding = own(graph.bindings, key);
8894
9554
  if (binding?.kind === kind) return binding;
@@ -8908,7 +9568,7 @@ function preview(graph) {
8908
9568
  on: Object.fromEntries(Object.entries(node.outcomes).flatMap(([key, { to }]) => to ? [[key, to]] : [])),
8909
9569
  rollback: node.rollback ? select(node.rollback, ["mode", "returnToStepId"]) : { mode: "MANUAL" }
8910
9570
  };
8911
- const bound = (key, kind, field) => resolve2(key, kind, `${path}/${field}`, node.id);
9571
+ const bound = (key, kind, field) => resolve3(key, kind, `${path}/${field}`, node.id);
8912
9572
  if (node.rollback?.compensator) {
8913
9573
  const ref = bound(node.rollback.compensator, "compensator", "rollback/compensatorRef");
8914
9574
  if (ref) step.rollback.compensatorRef = select(ref, ["code", "version"]);
@@ -8922,7 +9582,7 @@ function preview(graph) {
8922
9582
  }
8923
9583
  }
8924
9584
  if (node.delivery) {
8925
- step.delivery = select(node.delivery, ["mode"]);
9585
+ step.delivery = select(node.delivery, ["mode", "channel"]);
8926
9586
  const ref = bound(node.delivery.group, "group", "delivery/groupId");
8927
9587
  if (ref) step.delivery.groupId = ref.groupId;
8928
9588
  if (node.delivery.group && node.delivery.mode !== "GROUP" && !ref) {
@@ -9013,12 +9673,14 @@ function preview(graph) {
9013
9673
  ...select(graph.settings, ["name", "description"]),
9014
9674
  ...graph.entry ? { entryStepId: graph.entry } : {}
9015
9675
  };
9016
- const planner = resolve2(graph.settings.planner, "planner", "/plannerRef");
9676
+ const planner = resolve3(graph.settings.planner, "planner", "/plannerRef");
9017
9677
  if (planner) definition.plannerRef = select(planner, ["instanceId", "versionNo"]);
9018
9678
  definition.steps = orderedNodes(graph).map(compileNode);
9019
9679
  Object.assign(definition, select(graph.settings, ["artifactStorage", "layout"]));
9020
9680
  if (graph.settings.planner === void 0 && definition.steps.some((step) => step.type === "AGENT" || step.type === "HUMAN" || step.notificationContentVersion === 1 || step.notificationConditionVersion === 1)) {
9021
- issues.push({ code: "MISSING_PLANNER", message: "This workflow requires a fixed Planner version.", path: "/plannerRef" });
9681
+ const dynamic = definition.steps.filter((step) => step.notificationContentVersion === 1 || step.notificationConditionVersion === 1);
9682
+ const message = dynamic.length ? "Bind a fixed Planner for generated content or conditions on " + dynamic.map((step) => step.id).join(", ") + ". For fixed unconditional text, use content and omit both notification version fields." : "This workflow requires a fixed Planner version.";
9683
+ issues.push({ code: "MISSING_PLANNER", message, path: "/plannerRef" });
9022
9684
  }
9023
9685
  if (definition.artifactStorage?.type === "NAS" && typeof definition.artifactStorage.rootPath === "string") {
9024
9686
  const root = definition.artifactStorage.rootPath;
@@ -9031,8 +9693,8 @@ function preview(graph) {
9031
9693
  }
9032
9694
  }
9033
9695
  for (const rule of Object.values(graph.approvalRules)) {
9034
- if (!own(graph.bindings, rule.approver)) {
9035
- resolve2(rule.approver, "member", `/approvalRules/${rule.id}/approver`, rule.edge.from);
9696
+ if (rule.approver && !own(graph.bindings, rule.approver)) {
9697
+ resolve3(rule.approver, "member", `/approvalRules/${rule.id}/approver`, rule.edge.from);
9036
9698
  }
9037
9699
  }
9038
9700
  const structural = schemaIssues(definition, issues);
@@ -9047,6 +9709,7 @@ function preview(graph) {
9047
9709
  }
9048
9710
 
9049
9711
  // src/edit.mjs
9712
+ init_define_WORKFLOW_BUILDER_BRIDGE();
9050
9713
  var COMMON = ["name", "instructions", "rollback"];
9051
9714
  var ASSIGNMENT = ["assignees", "assigneeMode", "assigneeDescription", "completionPolicy", "delivery"];
9052
9715
  var NODE_FIELDS = {
@@ -9095,7 +9758,7 @@ function emptyGraph(workflowId, options) {
9095
9758
  };
9096
9759
  }
9097
9760
  function checkRequest(request) {
9098
- fields(request, ["expectedRevision", "requestId", "bindings", "operations"], "");
9761
+ fields(request, ["expectedRevision", "requestId", "bindings", "operations", "parallelFragments"], "");
9099
9762
  if (!Number.isSafeInteger(request.expectedRevision) || request.expectedRevision < 1) {
9100
9763
  invalid("/expectedRevision", "Expected a positive safe integer.");
9101
9764
  }
@@ -9179,6 +9842,9 @@ function checkOutcome(outcome, path) {
9179
9842
  function checkNodeFields(action, patch, path, extra = []) {
9180
9843
  const allowed = typeof action === "string" && own(NODE_FIELDS, action);
9181
9844
  if (!allowed) invalid(`${path}/action`, "Unknown node action.");
9845
+ if (allowed.includes("assignees") && Object.hasOwn(patch, "assigneeRefs")) {
9846
+ invalid(path + "/assigneeRefs", 'Use assignees with member binding keys, or ["$runCreator"] for the run creator.');
9847
+ }
9182
9848
  fields(patch, [...COMMON, ...allowed, ...extra], path);
9183
9849
  for (const field of ["agent", "responsible", "workflow", "rejectionReturnToStepId"]) {
9184
9850
  const value = own(patch, field);
@@ -9192,7 +9858,13 @@ function checkNodeFields(action, patch, path, extra = []) {
9192
9858
  });
9193
9859
  }
9194
9860
  if (patch.delivery != null) {
9195
- fields(patch.delivery, ["mode", ...action === "agent_task" ? [] : ["group"]], `${path}/delivery`);
9861
+ fields(patch.delivery, ["mode", "channel", ...action === "agent_task" ? [] : ["group"]], `${path}/delivery`);
9862
+ if (Object.hasOwn(patch.delivery, "channel")) {
9863
+ if (patch.delivery.mode !== "PRIVATE") invalid(`${path}/delivery/channel`, "Only PRIVATE delivery accepts a channel.");
9864
+ if (!["WECOM", "WECHAT", "BOTH"].includes(patch.delivery.channel)) {
9865
+ invalid(`${path}/delivery/channel`, "Expected WECOM, WECHAT or BOTH.");
9866
+ }
9867
+ }
9196
9868
  if (patch.delivery.group !== void 0) identifier(patch.delivery.group, `${path}/delivery/group`);
9197
9869
  }
9198
9870
  if (patch.rollback != null) {
@@ -9228,9 +9900,14 @@ function checkEdge(edge, path) {
9228
9900
  identifier(edge.outcome, `${path}/outcome`);
9229
9901
  }
9230
9902
  function setRule(graph, rule, path) {
9231
- fields(rule, ["id", "edge", "protect", "approver", "scope", "source"], path);
9903
+ fields(rule, ["id", "edge", "protect", "approver", "approvalNodeId", "scope", "source"], path);
9232
9904
  checkEdge(rule.edge, `${path}/edge`);
9233
- for (const key of ["id", "protect", "approver"]) identifier(rule[key], `${path}/${key}`);
9905
+ if (Object.hasOwn(rule, "approver") === Object.hasOwn(rule, "approvalNodeId")) {
9906
+ invalid(path, "Identify either the required member binding or the required approval node.");
9907
+ }
9908
+ for (const key of ["id", "protect", rule.approvalNodeId !== void 0 ? "approvalNodeId" : "approver"]) {
9909
+ identifier(rule[key], `${path}/${key}`);
9910
+ }
9234
9911
  nonblank(rule.scope, `${path}/scope`, 128);
9235
9912
  if (rule.source !== void 0) nonblank(rule.source, `${path}/source`);
9236
9913
  graph.approvalRules[rule.id] = rule;
@@ -9441,6 +10118,7 @@ function diff(before, after) {
9441
10118
  }
9442
10119
 
9443
10120
  // src/store.mjs
10121
+ init_define_WORKFLOW_BUILDER_BRIDGE();
9444
10122
  var import_node_crypto2 = require("node:crypto");
9445
10123
  var import_promises = require("node:fs/promises");
9446
10124
  var import_node_path = require("node:path");
@@ -9449,8 +10127,13 @@ var REVISION_FILE = /^revision-([1-9][0-9]*)\.json$/;
9449
10127
  function revisionFile(directory, revision) {
9450
10128
  return (0, import_node_path.join)(directory, `revision-${revision}.json`);
9451
10129
  }
9452
- function missingWorkflow(workflowId) {
9453
- return new CliError(4, "WORKFLOW_NOT_FOUND", "The workflow does not exist.", { workflowId });
10130
+ function missingWorkflow(workflowId, store) {
10131
+ return new CliError(
10132
+ 4,
10133
+ "WORKFLOW_NOT_FOUND",
10134
+ "No local revisions in this store. Retry with the same --store used for create or apply.",
10135
+ { source: "local_store", store, workflowId }
10136
+ );
9454
10137
  }
9455
10138
  async function syncDirectory(directory) {
9456
10139
  if (process.platform === "win32") return;
@@ -9501,14 +10184,14 @@ var Store = class {
9501
10184
  try {
9502
10185
  names = await (0, import_promises.readdir)(this.directory);
9503
10186
  } catch (error) {
9504
- if (error.code === "ENOENT") throw missingWorkflow(this.workflowId);
10187
+ if (error.code === "ENOENT") throw missingWorkflow(this.workflowId, (0, import_node_path.dirname)(this.workflows));
9505
10188
  throw error;
9506
10189
  }
9507
10190
  const revisions = names.flatMap((name) => {
9508
10191
  const match = REVISION_FILE.exec(name);
9509
10192
  return match ? [Number(match[1])] : [];
9510
10193
  }).sort((a, b) => b - a);
9511
- if (!revisions.length) throw missingWorkflow(this.workflowId);
10194
+ if (!revisions.length) throw missingWorkflow(this.workflowId, (0, import_node_path.dirname)(this.workflows));
9512
10195
  return revisions;
9513
10196
  }
9514
10197
  async read(revision) {
@@ -9518,6 +10201,8 @@ var Store = class {
9518
10201
  } catch (error) {
9519
10202
  if (error.code === "ENOENT") {
9520
10203
  throw new CliError(4, "REVISION_NOT_FOUND", "The revision does not exist.", {
10204
+ source: "local_store",
10205
+ store: (0, import_node_path.dirname)(this.workflows),
9521
10206
  workflowId: this.workflowId,
9522
10207
  revision
9523
10208
  });
@@ -9532,18 +10217,40 @@ var Store = class {
9532
10217
  }
9533
10218
  return data;
9534
10219
  }
9535
- async create(graph) {
10220
+ async create(graph, creationKey) {
9536
10221
  await (0, import_promises.mkdir)(this.directory, { recursive: true, mode: 448 });
9537
- if (!await this.commit(1, graph)) {
10222
+ if (!await this.commit(1, graph, void 0, creationKey)) {
10223
+ if (creationKey && (await this.read(1)).creationKey === creationKey) return;
9538
10224
  throw new CliError(3, "WORKFLOW_EXISTS", "The workflow already exists.", { workflowId: this.workflowId });
9539
10225
  }
9540
10226
  }
9541
- async commit(revision, graph, request) {
10227
+ // Publish the remote baseline and its edit token together. A concurrent
10228
+ // reader must never see this graph as a local, unsynced creation.
10229
+ async importDraft(graph, state) {
10230
+ await (0, import_promises.mkdir)(this.workflows, { recursive: true, mode: 448 });
10231
+ const staging = await (0, import_promises.mkdtemp)((0, import_node_path.join)(this.workflows, ".import-"));
10232
+ try {
10233
+ await atomicJson(revisionFile(staging, 1), { storageVersion: STORAGE_VERSION, revision: 1, graph }, false);
10234
+ await atomicJson((0, import_node_path.join)(staging, "sync-1.json"), state, false);
10235
+ try {
10236
+ await (0, import_promises.rename)(staging, this.directory);
10237
+ } catch (error) {
10238
+ if (["ENOTEMPTY", "EEXIST"].includes(error.code)) return false;
10239
+ throw error;
10240
+ }
10241
+ await syncDirectory(this.workflows);
10242
+ return true;
10243
+ } finally {
10244
+ await (0, import_promises.rm)(staging, { recursive: true, force: true });
10245
+ }
10246
+ }
10247
+ async commit(revision, graph, request, creationKey) {
9542
10248
  return atomicJson(revisionFile(this.directory, revision), {
9543
10249
  storageVersion: STORAGE_VERSION,
9544
10250
  revision,
9545
10251
  graph,
9546
- ...request ? { request } : {}
10252
+ request,
10253
+ creationKey
9547
10254
  }, false);
9548
10255
  }
9549
10256
  async exportFile(output, definition) {
@@ -9560,6 +10267,7 @@ var Store = class {
9560
10267
  };
9561
10268
 
9562
10269
  // src/draft.mjs
10270
+ init_define_WORKFLOW_BUILDER_BRIDGE();
9563
10271
  var import__2 = __toESM(require__(), 1);
9564
10272
 
9565
10273
  // src/schemas/fde.workflow.draft.v2.schema.json
@@ -9748,6 +10456,10 @@ function mergeDraft(base, desired, remote) {
9748
10456
  function merge(a, b, c, path) {
9749
10457
  if (equal(a, b) || equal(b, c)) return c;
9750
10458
  if (equal(a, c)) return b;
10459
+ if (/^\/steps\/[^/]+\/delivery$/.test(path) && b?.mode !== c?.mode) {
10460
+ conflicts.push({ path, previous: a, current: c, proposed: b });
10461
+ return c;
10462
+ }
9751
10463
  if (object(a) && object(b) && object(c)) {
9752
10464
  const entries = [];
9753
10465
  for (const k of /* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(b), ...Object.keys(a)])) {
@@ -9845,6 +10557,7 @@ function projectGraph(graph, definition) {
9845
10557
  if (!equal(old.delivery, step.delivery)) {
9846
10558
  assign(node, "delivery", step.delivery && {
9847
10559
  mode: step.delivery.mode,
10560
+ ...Object.hasOwn(step.delivery, "channel") && { channel: step.delivery.channel },
9848
10561
  ...step.delivery.groupId && { group: binding("group", { groupId: step.delivery.groupId }, ["groupId"]) }
9849
10562
  });
9850
10563
  }
@@ -9884,13 +10597,30 @@ function projectGraph(graph, definition) {
9884
10597
  }
9885
10598
 
9886
10599
  // src/draft-sync.mjs
10600
+ init_define_WORKFLOW_BUILDER_BRIDGE();
9887
10601
  var import_node_crypto3 = require("node:crypto");
9888
10602
  var import_promises2 = require("node:fs/promises");
10603
+ var import_node_os = require("node:os");
9889
10604
  var import_node_child_process = require("node:child_process");
9890
10605
  var import_node_path2 = require("node:path");
9891
- function hostTransport(path) {
9892
- const adapter = path ?? (0, import_node_path2.join)((0, import_node_path2.dirname)(process.argv[1]), "../skills/workflow-resource-discovery/scripts/draft_mcp.py");
9893
- return (method, args = {}, scope) => new Promise((resolve2, reject) => {
10606
+ async function withHostTransport(path, operation) {
10607
+ const embedded = typeof define_WORKFLOW_BUILDER_BRIDGE_default === "undefined" ? null : define_WORKFLOW_BUILDER_BRIDGE_default;
10608
+ if (path || !embedded) {
10609
+ const legacy = (0, import_node_path2.join)((0, import_node_path2.dirname)(process.argv[1]), "../skills/workflow-resource-discovery/scripts/draft_mcp.py");
10610
+ return operation(hostTransport(path ?? legacy));
10611
+ }
10612
+ const directory = await (0, import_promises2.mkdtemp)((0, import_node_path2.join)((0, import_node_os.tmpdir)(), "workflow-builder-bridge-"));
10613
+ try {
10614
+ for (const [name, source] of Object.entries(embedded)) {
10615
+ await (0, import_promises2.writeFile)((0, import_node_path2.join)(directory, name), source, { flag: "wx", mode: 384 });
10616
+ }
10617
+ return await operation(hostTransport((0, import_node_path2.join)(directory, "draft_mcp.py")));
10618
+ } finally {
10619
+ await (0, import_promises2.rm)(directory, { recursive: true, force: true });
10620
+ }
10621
+ }
10622
+ function hostTransport(adapter) {
10623
+ return (method, args = {}, scope) => new Promise((resolve3, reject) => {
9894
10624
  const child = (0, import_node_child_process.spawn)("python3", ["-B", adapter], { stdio: ["pipe", "pipe", "ignore"], timeout: 18e4 });
9895
10625
  const chunks = [];
9896
10626
  child.stdout.on("data", (chunk) => chunks.push(chunk));
@@ -9901,12 +10631,27 @@ function hostTransport(path) {
9901
10631
  try {
9902
10632
  if (status !== 0) fail("HOST_ADAPTER_UNAVAILABLE", "Load the Workflow Builder plugin and pass --bridge with its draft_mcp.py path.");
9903
10633
  const result = JSON.parse(Buffer.concat(chunks).toString());
9904
- if (result.ok !== true) fail(
9905
- result.code || "MCP_INVALID_RESPONSE",
9906
- "The host could not complete the workflow MCP request.",
9907
- { definitive: result.definitive === true }
9908
- );
9909
- resolve2(result.data);
10634
+ if (result.ok !== true) {
10635
+ if (result.code === "MCP_BUSINESS_RECEIPT_MISSING") {
10636
+ fail(
10637
+ result.code,
10638
+ "MCP returned only 'Tool executed successfully'. Report the unverified draft and stop this turn. A later sync can resume the saved request.",
10639
+ { method, canDisplayCanvas: false, retryThisTurn: false, definitive: false }
10640
+ );
10641
+ }
10642
+ const message = result.code === "MCP_INVALID_RESPONSE" ? "The host returned no usable business receipt. Report this method and code. For an uncertain write, resume sync-draft with the same store and revision." : "The host could not complete the workflow MCP request.";
10643
+ const issues = Array.isArray(result.issues) ? result.issues.map((issue) => {
10644
+ const match = /^\/steps\/(\d+)\/agentRef$/.exec(issue.path);
10645
+ const step = match && args.draftJson ? JSON.parse(args.draftJson).steps[Number(match[1])] : null;
10646
+ return step ? { ...issue, nodeId: step.id, instanceId: step.agentRef?.instanceId } : issue;
10647
+ }) : [];
10648
+ fail(result.code || "MCP_INVALID_RESPONSE", message, {
10649
+ method,
10650
+ definitive: result.definitive === true,
10651
+ ...issues.length ? { issues } : {}
10652
+ });
10653
+ }
10654
+ resolve3(result.data);
9910
10655
  } catch (error) {
9911
10656
  reject(error);
9912
10657
  }
@@ -9933,7 +10678,10 @@ async function save(store, prior, fields2) {
9933
10678
  return state;
9934
10679
  }
9935
10680
  function canvas(scope, id) {
9936
- return scope.canvasBase + "/workflows/" + encodeURIComponent(id) + "?teamId=" + encodeURIComponent(scope.teamId);
10681
+ const url = new URL("/fde/aw/workbench/edit", scope.canvasBase);
10682
+ url.searchParams.set("teamId", scope.teamId);
10683
+ url.searchParams.set("workflowId", id);
10684
+ return url.href;
9937
10685
  }
9938
10686
  async function getRemote(io, scope, workflowId) {
9939
10687
  const result = await io("get_draft", { workflowId }, scope);
@@ -9944,29 +10692,42 @@ async function getRemote(io, scope, workflowId) {
9944
10692
  return { draftRevision: result.draftRevision, definition: result.definition };
9945
10693
  }
9946
10694
  function checkScope(state, scope) {
9947
- if (state.scope && canonical(state.scope) !== canonical(scope)) fail("HOST_SCOPE_CHANGED", "Use the original team, environment and operator.");
10695
+ if (!state.scope) return;
10696
+ const saved = { ...state.scope, canvasBase: scope.canvasBase };
10697
+ if (canonical(saved) !== canonical(scope)) fail("HOST_SCOPE_CHANGED", "Use the original team, environment and operator.");
9948
10698
  }
9949
10699
  function checkTeam(graph, scope) {
9950
10700
  if (graph.settings.teamId !== scope.teamId) fail("TEAM_CONTEXT_MISMATCH", "Local graph and active host Team must match.");
9951
10701
  }
9952
- async function pullDraft(store, io, scope, useCanvas) {
10702
+ async function pullDraft(store, io, scope, useCanvas, previewOnly = false) {
9953
10703
  const id = store.workflowId;
9954
10704
  let state = await syncState(store);
9955
10705
  checkScope(state, scope);
10706
+ if (previewOnly) {
10707
+ const remote2 = await getRemote(io, scope, id);
10708
+ return { ok: true, workflowId: id, ...remote2, canvasUrl: canvas(scope, id), editable: false, readMode: "preview" };
10709
+ }
9956
10710
  if (state.attempt) fail("SYNC_PENDING", "Resume the outstanding sync before editing.", { revision: state.attempt.revision });
9957
10711
  if (state.synced) state = await save(store, state, { pull: null });
9958
10712
  const remote = await getRemote(io, scope, id);
9959
- const result = { ok: true, workflowId: id, ...remote, canvasUrl: canvas(scope, id), editable: false };
9960
- if (!state.synced) return result;
9961
- const [revision] = await store.revisions();
9962
- const { graph } = await store.read(revision);
10713
+ const result = { ok: true, workflowId: id, ...remote, canvasUrl: canvas(scope, id), editable: false, readMode: "edit" };
10714
+ const importing = !state.synced;
10715
+ const revision = importing ? 1 : (await store.revisions())[0];
10716
+ const graph = importing ? emptyGraph(id, { team: scope.teamId }) : (await store.read(revision)).graph;
9963
10717
  checkTeam(graph, scope);
9964
- const changes2 = draftChanges(state.synced.remote.definition, remote.definition);
10718
+ const changes2 = importing ? [] : draftChanges(state.synced.remote.definition, remote.definition);
9965
10719
  try {
9966
- const desired = useCanvas ? remote.definition : mergeDraft(state.synced.localDefinition, preview(graph).definition, remote.definition);
10720
+ const desired = importing || useCanvas ? remote.definition : mergeDraft(state.synced.localDefinition, preview(graph).definition, remote.definition);
9967
10721
  const prepared = projectGraph(graph, desired);
9968
10722
  const pull = { token: (0, import_node_crypto3.randomUUID)(), revision, remote, desired, graph: prepared, changes: changes2 };
9969
- await save(store, state, { pull });
10723
+ if (importing) {
10724
+ const synced = { revision, submittedRevision: revision, localDefinition: preview(prepared).definition, remote };
10725
+ if (!await store.importDraft(prepared, { serial: 1, scope, synced, pull })) {
10726
+ fail("LOCAL_BASELINE_EXISTS", "This store already contains a local graph. Use its original sync state or pull in a fresh workspace.");
10727
+ }
10728
+ } else {
10729
+ await save(store, state, { pull });
10730
+ }
9970
10731
  return {
9971
10732
  ...result,
9972
10733
  revision,
@@ -10030,6 +10791,7 @@ async function syncDraft(store, io, scope, revision, token, confirmedRevision) {
10030
10791
  const receipt = (remote) => ({
10031
10792
  ok: true,
10032
10793
  workflowId: id,
10794
+ name: remote.definition.name,
10033
10795
  revision,
10034
10796
  draftRevision: remote.draftRevision,
10035
10797
  canvasUrl: canvas(scope, id),
@@ -10158,25 +10920,50 @@ async function syncDraft(store, io, scope, revision, token, confirmedRevision) {
10158
10920
  var HELP = `workflow-builder ${package_default.version}
10159
10921
 
10160
10922
  Usage:
10161
- workflow-builder create <workflowId> [--name <name>] [--team <teamId>]
10923
+ workflow-builder create <workflowId> [--name <name>] [--team <teamId> | --current-team]
10924
+ workflow-builder create-notice [workflowId] --name <name> --content <fixed text> [--channel WECHAT|WECOM|BOTH]
10162
10925
  workflow-builder show <workflowId> [--revision <number>] [--node <nodeId>]
10163
- workflow-builder apply <workflowId> --stdin [--base-draft <token>]
10926
+ workflow-builder apply <workflowId> --stdin [--base-draft <token>] [--sync] [--require-connected]
10164
10927
  workflow-builder export <workflowId> --revision <number> [--output <file>]
10165
10928
  workflow-builder export-draft <workflowId> --revision <number> [--output <file>]
10166
10929
  workflow-builder list-workflows [--keyword <name>] [--status <status>] [--page <n>] [--page-size <n>]
10167
- workflow-builder pull-draft <workflowId> [--use-canvas]
10930
+ workflow-builder pull-draft <workflowId> [--summary | --notifications | --preview | --use-canvas]
10168
10931
  workflow-builder sync-draft <workflowId> --revision <n> [--base-draft <token>] [--confirm-revision <n>]
10169
10932
  workflow-builder --version
10170
10933
 
10171
- All workflow commands accept --store <directory> before or after the subcommand.
10172
- See docs/cli-contract.md for input and receipt formats.`;
10934
+ Reuse the same --store <directory> for create, apply, show and sync-draft.
10935
+ Known workflow ID: use --summary for the canvas, --notifications for notice text, --preview for full details.
10936
+ Online commands use the bundled adapter; --bridge <draft_mcp.py> overrides it.
10937
+ For the apply request format and a working example, use workflow-builder apply --help.`;
10938
+ var APPLY_HELP = `workflow-builder apply <workflowId> --stdin [--base-draft <token>] [--sync] [--require-connected] [--store <directory>]
10939
+ Read one JSON request on stdin. Use the current local revision and a unique requestId.
10940
+ For first online save, use --sync after create. For an online edit, pull the latest draft first and use --base-draft <token> --sync to apply, save and verify the edit.
10941
+ Fixed private notification to the run creator (replace the text and IDs as needed):
10942
+ {
10943
+ "expectedRevision": 1,
10944
+ "requestId": "add-fixed-notice",
10945
+ "operations": [
10946
+ {"op": "add_node", "node": {"id": "notice", "action": "notification", "name": "\u901A\u77E5\u53D1\u8D77\u4EBA",
10947
+ "instructions": "\u5C06\u901A\u77E5\u79C1\u53D1\u7ED9\u672C\u6B21\u6D41\u7A0B\u7684\u53D1\u8D77\u4EBA\u3002", "content": "\u6D4B\u8BD5\u6210\u529F",
10948
+ "delivery": {"mode": "PRIVATE"}, "assignees": ["$runCreator"],
10949
+ "outcomes": {"completed": {"to": "$succeeded"}}}},
10950
+ {"op": "set_entry", "nodeId": "notice"}
10951
+ ]
10952
+ }`;
10173
10953
  var CONFIG = {
10174
- create: { name: { type: "string" }, team: { type: "string" } },
10954
+ create: { "current-team": { type: "boolean" }, name: { type: "string" }, team: { type: "string" } },
10955
+ "create-notice": { name: { type: "string" }, content: { type: "string" }, channel: { type: "string" }, bridge: { type: "string" } },
10175
10956
  show: { revision: { type: "string" }, node: { type: "string" } },
10176
- apply: { stdin: { type: "boolean" }, "base-draft": { type: "string" } },
10957
+ apply: { "require-connected": { type: "boolean" }, sync: { type: "boolean" }, bridge: { type: "string" }, stdin: { type: "boolean" }, "base-draft": { type: "string" } },
10177
10958
  export: { revision: { type: "string" }, output: { type: "string" } },
10178
10959
  "export-draft": { revision: { type: "string" }, output: { type: "string" } },
10179
- "pull-draft": { bridge: { type: "string" }, "use-canvas": { type: "boolean" } },
10960
+ "pull-draft": {
10961
+ preview: { type: "boolean" },
10962
+ summary: { type: "boolean" },
10963
+ notifications: { type: "boolean" },
10964
+ bridge: { type: "string" },
10965
+ "use-canvas": { type: "boolean" }
10966
+ },
10180
10967
  "sync-draft": {
10181
10968
  bridge: { type: "string" },
10182
10969
  revision: { type: "string" },
@@ -10195,15 +10982,19 @@ function usage(message) {
10195
10982
  throw new CliError(2, "INVALID_ARGUMENTS", message);
10196
10983
  }
10197
10984
  function parseCommand(args) {
10198
- let storePrefix = 0;
10199
- if (args[0] === "--store") storePrefix = 2;
10200
- else if (args[0]?.startsWith("--store=")) storePrefix = 1;
10201
- const command = args[storePrefix];
10985
+ let commandIndex = 0;
10986
+ while (/^--(?:store|bridge)(?:=|$)/.test(args[commandIndex] ?? "")) {
10987
+ commandIndex += args[commandIndex].includes("=") ? 1 : 2;
10988
+ }
10989
+ const command = args[commandIndex];
10202
10990
  if (!Object.hasOwn(CONFIG, command)) usage("Unknown command. See --help.");
10991
+ if (!CONFIG[command].bridge && args.some((arg) => arg === "--bridge" || arg.startsWith("--bridge="))) {
10992
+ usage(command + " uses local storage. Omit --bridge. Online list-workflows, pull-draft and sync-draft use the bundled adapter.");
10993
+ }
10203
10994
  let parsed;
10204
10995
  try {
10205
10996
  parsed = (0, import_node_util.parseArgs)({
10206
- args: [...args.slice(0, storePrefix), ...args.slice(storePrefix + 1)],
10997
+ args: [...args.slice(0, commandIndex), ...args.slice(commandIndex + 1)],
10207
10998
  allowPositionals: true,
10208
10999
  tokens: true,
10209
11000
  options: { ...CONFIG[command], store: { type: "string" } }
@@ -10214,7 +11005,8 @@ function parseCommand(args) {
10214
11005
  const { values, positionals, tokens } = parsed;
10215
11006
  const keys = tokens.filter(({ kind }) => kind === "option").map(({ name }) => name);
10216
11007
  if (new Set(keys).size !== keys.length) usage("Each option can be provided only once.");
10217
- if (positionals.length !== (command === "list-workflows" ? 0 : 1)) usage("Unexpected workflow ID count.");
11008
+ const idOptional = command === "create-notice" && positionals.length === 0;
11009
+ if (!idOptional && positionals.length !== (command === "list-workflows" ? 0 : 1)) usage("Unexpected workflow ID count.");
10218
11010
  const [workflowId] = positionals;
10219
11011
  if (workflowId !== void 0) identifier(workflowId, "/workflowId");
10220
11012
  if (values.node !== void 0) identifier(values.node, "/nodeId");
@@ -10226,14 +11018,32 @@ function parseCommand(args) {
10226
11018
  }
10227
11019
  values[key] = revision;
10228
11020
  }
11021
+ if (values["current-team"] && values.team !== void 0) usage("Choose --team or --current-team.");
11022
+ if ([values.preview, values.summary, values.notifications, values["use-canvas"]].filter(Boolean).length > 1) {
11023
+ usage("Choose only one of --summary, --notifications, --preview or --use-canvas.");
11024
+ }
11025
+ if (command === "create-notice") {
11026
+ nonblank(values.name, "/name", 128);
11027
+ nonblank(values.content, "/content");
11028
+ }
11029
+ if (command === "apply" && values.bridge && !values.sync) usage("Local apply uses local storage. Omit --bridge or use --sync.");
10229
11030
  if (command === "apply" && !values.stdin) usage("apply requires --stdin.");
10230
11031
  if (["export", "export-draft", "sync-draft"].includes(command) && !values.revision) usage(command + " requires --revision.");
10231
11032
  if (values["page-size"] > 100) usage("Maximum page size is 100.");
10232
11033
  if (values.status && !["DRAFT", "ENABLED", "DISABLED"].includes(values.status)) usage("Unknown workflow status.");
10233
- if (values.store === "" || values.output === "") usage("Path options require a nonempty path.");
11034
+ if (values.store === "" || values.output === "" || values.bridge === "") usage("Path options require a nonempty path.");
10234
11035
  return { command, workflowId, values };
10235
11036
  }
10236
- async function apply(store, token) {
11037
+ function checkOnlineEdit(graph, pending, options) {
11038
+ if (options.sync && !graph.settings.name?.trim()) {
11039
+ throw new CliError(5, "DRAFT_NAME_REQUIRED", "Set the workflow name with set_workflow.changes.name.", { path: "/name" });
11040
+ }
11041
+ if (options["require-connected"]) {
11042
+ const issues = pending.filter((item) => item.code === "UNREACHABLE_NODE");
11043
+ if (issues.length) throw new CliError(5, "DISCONNECTED_DRAFT", "Connect all requested paths to the entry.", { issues });
11044
+ }
11045
+ }
11046
+ async function apply(store, token, options) {
10237
11047
  const request = parseRequest(await (0, import_consumers.text)(process.stdin));
10238
11048
  checkRequest(request);
10239
11049
  const digest = requestDigest(token ? { request, baseDraft: token } : request);
@@ -10252,6 +11062,8 @@ async function apply(store, token) {
10252
11062
  revision: revision2
10253
11063
  });
10254
11064
  }
11065
+ checkParallelFragments(record.graph, request.parallelFragments, options.sync && !token);
11066
+ checkOnlineEdit(record.graph, record.request.receipt.pending, options);
10255
11067
  return record.request.receipt;
10256
11068
  }
10257
11069
  if (expectedRevision !== actualRevision) {
@@ -10265,6 +11077,8 @@ async function apply(store, token) {
10265
11077
  const graph = applyOperations(baseGraph, request);
10266
11078
  assertDraft(graph);
10267
11079
  const { pending } = preview(graph);
11080
+ checkParallelFragments(graph, request.parallelFragments, options.sync && !token);
11081
+ checkOnlineEdit(graph, pending, options);
10268
11082
  const revision = actualRevision + 1;
10269
11083
  const receipt = {
10270
11084
  ok: true,
@@ -10278,13 +11092,39 @@ async function apply(store, token) {
10278
11092
  if (await store.commit(revision, graph, { digest, receipt, ...token && { baseDraft: token } })) return receipt;
10279
11093
  }
10280
11094
  }
10281
- async function run(args) {
10282
- if (args.length === 1 && ["--version", "-v"].includes(args[0])) return package_default.version;
10283
- if (!args.length || args.length === 1 && ["--help", "-h"].includes(args[0])) return HELP;
10284
- const { command, workflowId, values } = parseCommand(args);
11095
+ async function createNotice(root, workflowId, values, io, scope) {
11096
+ const { name, content, channel } = values;
11097
+ const channelOption = channel === void 0 ? {} : { channel };
11098
+ const id = workflowId ?? "notice-" + requestDigest({ root: (0, import_node_path3.resolve)(root), scope, name }).slice(0, 24);
11099
+ const store = new Store(root, id);
11100
+ const graph = applyOperations(emptyGraph(store.workflowId, { name, team: scope.teamId }), { operations: [
11101
+ { op: "add_node", node: {
11102
+ id: "notice",
11103
+ action: "notification",
11104
+ name: "\u901A\u77E5\u53D1\u8D77\u4EBA",
11105
+ instructions: "\u5C06\u901A\u77E5\u79C1\u53D1\u7ED9\u672C\u6B21\u6D41\u7A0B\u7684\u53D1\u8D77\u4EBA\u3002",
11106
+ content,
11107
+ delivery: { mode: "PRIVATE", ...channelOption },
11108
+ assignees: ["$runCreator"],
11109
+ outcomes: { completed: { to: "$succeeded" } }
11110
+ } },
11111
+ { op: "set_entry", nodeId: "notice" }
11112
+ ] });
11113
+ assertDraft(graph);
11114
+ const { pending } = preview(graph);
11115
+ if (pending.length) throw new CliError(5, "INVALID_DRAFT", "The notice draft is incomplete.", { issues: pending });
11116
+ await store.create(graph, requestDigest({ command: "create-notice", scope, name, content, ...channelOption }));
11117
+ try {
11118
+ return await syncDraft(store, io, scope, 1);
11119
+ } catch (error) {
11120
+ if (error instanceof CliError) Object.assign(error.receipt.error, { workflowId: store.workflowId, submittedRevision: 1 });
11121
+ throw error;
11122
+ }
11123
+ }
11124
+ async function online(command, root, workflowId, values, io) {
11125
+ const scope = await io("context");
11126
+ if (command === "create-notice") return createNotice(root, workflowId, values, io, scope);
10285
11127
  if (command === "list-workflows") {
10286
- const io = hostTransport(values.bridge);
10287
- const scope = await io("context");
10288
11128
  const page = await io("list_workflows", {
10289
11129
  pageNo: values.page ?? 1,
10290
11130
  pageSize: values["page-size"] ?? 20,
@@ -10296,18 +11136,51 @@ async function run(args) {
10296
11136
  }
10297
11137
  return { ok: true, teamId: scope.teamId, ...page };
10298
11138
  }
11139
+ const store = new Store(root, workflowId);
11140
+ if (command === "apply") {
11141
+ const token = values["base-draft"];
11142
+ const local = await apply(store, token, values);
11143
+ try {
11144
+ return await syncDraft(store, io, scope, local.revision, token);
11145
+ } catch (error) {
11146
+ if (error instanceof CliError) Object.assign(error.receipt.error, { workflowId, submittedRevision: local.revision });
11147
+ throw error;
11148
+ }
11149
+ }
11150
+ if (command === "pull-draft") {
11151
+ const compact = values.summary || values.notifications;
11152
+ const result = await pullDraft(store, io, scope, values["use-canvas"], values.preview || compact);
11153
+ if (!compact) return result;
11154
+ const { definition, ...receipt } = result;
11155
+ receipt.name = definition.name;
11156
+ if (values.notifications) {
11157
+ receipt.notifications = definition.steps.filter((step) => step.type === "NOTIFICATION").map(({ id, name, content, notificationContentVersion }) => ({ id, name, content, notificationContentVersion }));
11158
+ }
11159
+ return receipt;
11160
+ }
11161
+ return syncDraft(store, io, scope, values.revision, values["base-draft"], values["confirm-revision"]);
11162
+ }
11163
+ async function run(args) {
11164
+ if (args.length === 1 && ["--version", "-v"].includes(args[0])) return package_default.version;
11165
+ if (!args.length || args.length === 1 && ["--help", "-h"].includes(args[0])) return HELP;
11166
+ if (args.length === 2 && Object.hasOwn(CONFIG, args[0]) && ["--help", "-h"].includes(args[1])) {
11167
+ return args[0] === "apply" ? APPLY_HELP : HELP.split("\n").find((line) => line.startsWith(" workflow-builder " + args[0] + " "));
11168
+ }
11169
+ const { command, workflowId, values } = parseCommand(args);
10299
11170
  const root = values.store ?? (process.env.WORKFLOW_BUILDER_HOME || (0, import_node_path3.join)(process.cwd(), ".workflow-builder"));
11171
+ if (command === "apply" && !values.sync) {
11172
+ const local = await apply(new Store(root, workflowId), values["base-draft"], values);
11173
+ return { ...local, status: "local_only", nextOnlineCommand: values["base-draft"] ? "sync-draft <workflowId> --revision <revision> --base-draft <baseDraft>" : "sync-draft <workflowId> --revision <revision>" };
11174
+ }
11175
+ if (CONFIG[command].bridge) return withHostTransport(values.bridge, (io) => online(command, root, workflowId, values, io));
10300
11176
  const store = new Store(root, workflowId);
10301
11177
  if (command === "create") {
11178
+ if (values["current-team"]) {
11179
+ const scope = await withHostTransport(void 0, (io) => io("context"));
11180
+ values.team = scope.teamId;
11181
+ }
10302
11182
  await store.create(emptyGraph(workflowId, values));
10303
- return { ok: true, workflowId, revision: 1 };
10304
- }
10305
- if (command === "apply") return apply(store, values["base-draft"]);
10306
- if (command === "pull-draft" || command === "sync-draft") {
10307
- const io = hostTransport(values.bridge);
10308
- const scope = await io("context");
10309
- if (command === "pull-draft") return pullDraft(store, io, scope, values["use-canvas"]);
10310
- return syncDraft(store, io, scope, values.revision, values["base-draft"], values["confirm-revision"]);
11183
+ return { ok: true, workflowId, revision: 1, ...values["current-team"] && { teamId: values.team } };
10311
11184
  }
10312
11185
  const [latest] = await store.revisions();
10313
11186
  const { graph, revision } = await store.read(values.revision ?? latest);