@xyne/workflow-sdk 3.2.40 → 3.2.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +1 -0
  2. package/dist/agents/agent-step.d.ts.map +1 -1
  3. package/dist/agents/agent-step.js +8 -5
  4. package/dist/agents/agent-step.js.map +1 -1
  5. package/dist/agents/contract.d.ts +21 -4
  6. package/dist/agents/contract.d.ts.map +1 -1
  7. package/dist/agents/contract.js +95 -5
  8. package/dist/agents/contract.js.map +1 -1
  9. package/dist/agents/host-agent-step.d.ts +20 -4
  10. package/dist/agents/host-agent-step.d.ts.map +1 -1
  11. package/dist/agents/host-agent-step.js +77 -18
  12. package/dist/agents/host-agent-step.js.map +1 -1
  13. package/dist/agents/provider.d.ts +17 -0
  14. package/dist/agents/provider.d.ts.map +1 -1
  15. package/dist/agents/provider.js.map +1 -1
  16. package/dist/client/index.d.ts +3 -1
  17. package/dist/client/index.d.ts.map +1 -1
  18. package/dist/client/types.d.ts +50 -0
  19. package/dist/client/types.d.ts.map +1 -1
  20. package/dist/client/workflow-client.d.ts.map +1 -1
  21. package/dist/client/workflow-client.js +48 -0
  22. package/dist/client/workflow-client.js.map +1 -1
  23. package/dist/common/expression-eval.d.ts +35 -0
  24. package/dist/common/expression-eval.d.ts.map +1 -0
  25. package/dist/common/expression-eval.js +214 -0
  26. package/dist/common/expression-eval.js.map +1 -0
  27. package/dist/common/principal.d.ts +45 -0
  28. package/dist/common/principal.d.ts.map +1 -0
  29. package/dist/common/principal.js +9 -0
  30. package/dist/common/principal.js.map +1 -0
  31. package/dist/connectors/builtin/builtin-connector.d.ts.map +1 -1
  32. package/dist/connectors/builtin/builtin-connector.js +5 -0
  33. package/dist/connectors/builtin/builtin-connector.js.map +1 -1
  34. package/dist/connectors/builtin/steps/cycle.step.d.ts +126 -0
  35. package/dist/connectors/builtin/steps/cycle.step.d.ts.map +1 -0
  36. package/dist/connectors/builtin/steps/cycle.step.js +144 -0
  37. package/dist/connectors/builtin/steps/cycle.step.js.map +1 -0
  38. package/dist/connectors/builtin/steps/jump.step.d.ts +64 -0
  39. package/dist/connectors/builtin/steps/jump.step.d.ts.map +1 -0
  40. package/dist/connectors/builtin/steps/jump.step.js +57 -0
  41. package/dist/connectors/builtin/steps/jump.step.js.map +1 -0
  42. package/dist/connectors/builtin/steps/loop.step.d.ts +5 -0
  43. package/dist/connectors/builtin/steps/loop.step.d.ts.map +1 -1
  44. package/dist/connectors/builtin/steps/loop.step.js +16 -0
  45. package/dist/connectors/builtin/steps/loop.step.js.map +1 -1
  46. package/dist/connectors/builtin/steps/map.step.d.ts +6 -0
  47. package/dist/connectors/builtin/steps/map.step.d.ts.map +1 -1
  48. package/dist/connectors/builtin/steps/map.step.js +21 -0
  49. package/dist/connectors/builtin/steps/map.step.js.map +1 -1
  50. package/dist/connectors/builtin/steps/parallel.step.d.ts +7 -0
  51. package/dist/connectors/builtin/steps/parallel.step.d.ts.map +1 -1
  52. package/dist/connectors/builtin/steps/parallel.step.js +19 -1
  53. package/dist/connectors/builtin/steps/parallel.step.js.map +1 -1
  54. package/dist/connectors/builtin/steps/repeat.step.d.ts +126 -0
  55. package/dist/connectors/builtin/steps/repeat.step.d.ts.map +1 -0
  56. package/dist/connectors/builtin/steps/repeat.step.js +144 -0
  57. package/dist/connectors/builtin/steps/repeat.step.js.map +1 -0
  58. package/dist/conversational-flow/create.d.ts +31 -0
  59. package/dist/conversational-flow/create.d.ts.map +1 -0
  60. package/dist/conversational-flow/create.js +94 -0
  61. package/dist/conversational-flow/create.js.map +1 -0
  62. package/dist/conversational-flow/edit.d.ts +98 -0
  63. package/dist/conversational-flow/edit.d.ts.map +1 -0
  64. package/dist/conversational-flow/edit.js +814 -0
  65. package/dist/conversational-flow/edit.js.map +1 -0
  66. package/dist/conversational-flow/index.d.ts +17 -0
  67. package/dist/conversational-flow/index.d.ts.map +1 -0
  68. package/dist/conversational-flow/index.js +7 -0
  69. package/dist/conversational-flow/index.js.map +1 -0
  70. package/dist/conversational-flow/read.d.ts +22 -0
  71. package/dist/conversational-flow/read.d.ts.map +1 -0
  72. package/dist/conversational-flow/read.js +418 -0
  73. package/dist/conversational-flow/read.js.map +1 -0
  74. package/dist/conversational-flow/server/conversation-service.d.ts +70 -0
  75. package/dist/conversational-flow/server/conversation-service.d.ts.map +1 -0
  76. package/dist/conversational-flow/server/conversation-service.js +181 -0
  77. package/dist/conversational-flow/server/conversation-service.js.map +1 -0
  78. package/dist/conversational-flow/server/routes.d.ts +16 -0
  79. package/dist/conversational-flow/server/routes.d.ts.map +1 -0
  80. package/dist/conversational-flow/server/routes.js +140 -0
  81. package/dist/conversational-flow/server/routes.js.map +1 -0
  82. package/dist/conversational-flow/tree.d.ts +11 -0
  83. package/dist/conversational-flow/tree.d.ts.map +1 -0
  84. package/dist/conversational-flow/tree.js +39 -0
  85. package/dist/conversational-flow/tree.js.map +1 -0
  86. package/dist/conversational-flow/turn.d.ts +184 -0
  87. package/dist/conversational-flow/turn.d.ts.map +1 -0
  88. package/dist/conversational-flow/turn.js +408 -0
  89. package/dist/conversational-flow/turn.js.map +1 -0
  90. package/dist/conversational-flow/types.d.ts +152 -0
  91. package/dist/conversational-flow/types.d.ts.map +1 -0
  92. package/dist/conversational-flow/types.js +22 -0
  93. package/dist/conversational-flow/types.js.map +1 -0
  94. package/dist/engine/available-context.js +11 -0
  95. package/dist/engine/available-context.js.map +1 -1
  96. package/dist/engine/branch-signal.d.ts +72 -0
  97. package/dist/engine/branch-signal.d.ts.map +1 -0
  98. package/dist/engine/branch-signal.js +42 -0
  99. package/dist/engine/branch-signal.js.map +1 -0
  100. package/dist/engine/config-validator.d.ts +7 -0
  101. package/dist/engine/config-validator.d.ts.map +1 -1
  102. package/dist/engine/config-validator.js +73 -11
  103. package/dist/engine/config-validator.js.map +1 -1
  104. package/dist/engine/workflow-executor.d.ts.map +1 -1
  105. package/dist/engine/workflow-executor.js +30 -3
  106. package/dist/engine/workflow-executor.js.map +1 -1
  107. package/dist/events/types.d.ts +2 -0
  108. package/dist/events/types.d.ts.map +1 -1
  109. package/dist/events/types.js.map +1 -1
  110. package/dist/index.d.ts +7 -1
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +3 -0
  113. package/dist/index.js.map +1 -1
  114. package/dist/ingest/start-policy.d.ts +2 -2
  115. package/dist/router/workflow-router.d.ts.map +1 -1
  116. package/dist/router/workflow-router.js +3 -0
  117. package/dist/router/workflow-router.js.map +1 -1
  118. package/dist/runtime/execution-event-bus.d.ts +38 -0
  119. package/dist/runtime/execution-event-bus.d.ts.map +1 -0
  120. package/dist/runtime/execution-event-bus.js +87 -0
  121. package/dist/runtime/execution-event-bus.js.map +1 -0
  122. package/dist/runtime/workflow-runtime.d.ts.map +1 -1
  123. package/dist/runtime/workflow-runtime.js +5 -0
  124. package/dist/runtime/workflow-runtime.js.map +1 -1
  125. package/dist/steps/base-step.d.ts +40 -3
  126. package/dist/steps/base-step.d.ts.map +1 -1
  127. package/dist/steps/base-step.js +6 -0
  128. package/dist/steps/base-step.js.map +1 -1
  129. package/dist/steps/builtin/code.step.d.ts +99 -0
  130. package/dist/steps/builtin/code.step.d.ts.map +1 -0
  131. package/dist/steps/builtin/code.step.js +152 -0
  132. package/dist/steps/builtin/code.step.js.map +1 -0
  133. package/dist/steps/builtin/conditional.step.d.ts +182 -0
  134. package/dist/steps/builtin/conditional.step.d.ts.map +1 -0
  135. package/dist/steps/builtin/conditional.step.js +82 -0
  136. package/dist/steps/builtin/conditional.step.js.map +1 -0
  137. package/dist/steps/builtin/dedup.step.d.ts +65 -0
  138. package/dist/steps/builtin/dedup.step.d.ts.map +1 -0
  139. package/dist/steps/builtin/dedup.step.js +61 -0
  140. package/dist/steps/builtin/dedup.step.js.map +1 -0
  141. package/dist/steps/builtin/http-request.step.d.ts +1020 -0
  142. package/dist/steps/builtin/http-request.step.d.ts.map +1 -0
  143. package/dist/steps/builtin/http-request.step.js +491 -0
  144. package/dist/steps/builtin/http-request.step.js.map +1 -0
  145. package/dist/steps/builtin/loop.step.d.ts +100 -0
  146. package/dist/steps/builtin/loop.step.d.ts.map +1 -0
  147. package/dist/steps/builtin/loop.step.js +73 -0
  148. package/dist/steps/builtin/loop.step.js.map +1 -0
  149. package/dist/steps/builtin/map.step.d.ts +148 -0
  150. package/dist/steps/builtin/map.step.d.ts.map +1 -0
  151. package/dist/steps/builtin/map.step.js +111 -0
  152. package/dist/steps/builtin/map.step.js.map +1 -0
  153. package/dist/steps/builtin/parallel.step.d.ts +246 -0
  154. package/dist/steps/builtin/parallel.step.d.ts.map +1 -0
  155. package/dist/steps/builtin/parallel.step.js +175 -0
  156. package/dist/steps/builtin/parallel.step.js.map +1 -0
  157. package/dist/steps/builtin/ssrf-guard.d.ts +9 -0
  158. package/dist/steps/builtin/ssrf-guard.d.ts.map +1 -0
  159. package/dist/steps/builtin/ssrf-guard.js +115 -0
  160. package/dist/steps/builtin/ssrf-guard.js.map +1 -0
  161. package/dist/steps/builtin/switch.step.d.ts +235 -0
  162. package/dist/steps/builtin/switch.step.d.ts.map +1 -0
  163. package/dist/steps/builtin/switch.step.js +101 -0
  164. package/dist/steps/builtin/switch.step.js.map +1 -0
  165. package/dist/steps/builtin/transform.step.d.ts +247 -0
  166. package/dist/steps/builtin/transform.step.d.ts.map +1 -0
  167. package/dist/steps/builtin/transform.step.js +135 -0
  168. package/dist/steps/builtin/transform.step.js.map +1 -0
  169. package/dist/steps/builtin/wait.step.d.ts +1072 -0
  170. package/dist/steps/builtin/wait.step.d.ts.map +1 -0
  171. package/dist/steps/builtin/wait.step.js +254 -0
  172. package/dist/steps/builtin/wait.step.js.map +1 -0
  173. package/dist/steps/step-descriptor.d.ts +3 -1
  174. package/dist/steps/step-descriptor.d.ts.map +1 -1
  175. package/dist/steps/step-descriptor.js +1 -1
  176. package/dist/steps/step-descriptor.js.map +1 -1
  177. package/dist/steps/step-registry.d.ts +62 -0
  178. package/dist/steps/step-registry.d.ts.map +1 -0
  179. package/dist/steps/step-registry.js +103 -0
  180. package/dist/steps/step-registry.js.map +1 -0
  181. package/dist/triggers/builtin/default-cron-trigger.d.ts +44 -0
  182. package/dist/triggers/builtin/default-cron-trigger.d.ts.map +1 -0
  183. package/dist/triggers/builtin/default-cron-trigger.js +31 -0
  184. package/dist/triggers/builtin/default-cron-trigger.js.map +1 -0
  185. package/dist/triggers/builtin/default-event-trigger.d.ts +32 -0
  186. package/dist/triggers/builtin/default-event-trigger.d.ts.map +1 -0
  187. package/dist/triggers/builtin/default-event-trigger.js +21 -0
  188. package/dist/triggers/builtin/default-event-trigger.js.map +1 -0
  189. package/dist/triggers/builtin/default-manual-trigger.d.ts +45 -0
  190. package/dist/triggers/builtin/default-manual-trigger.d.ts.map +1 -0
  191. package/dist/triggers/builtin/default-manual-trigger.js +51 -0
  192. package/dist/triggers/builtin/default-manual-trigger.js.map +1 -0
  193. package/dist/triggers/builtin/default-webhook-trigger.d.ts +72 -0
  194. package/dist/triggers/builtin/default-webhook-trigger.d.ts.map +1 -0
  195. package/dist/triggers/builtin/default-webhook-trigger.js +91 -0
  196. package/dist/triggers/builtin/default-webhook-trigger.js.map +1 -0
  197. package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts +29 -0
  198. package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts.map +1 -0
  199. package/dist/triggers/builtin/default-webhook-v2-trigger.js +38 -0
  200. package/dist/triggers/builtin/default-webhook-v2-trigger.js.map +1 -0
  201. package/dist/triggers/trigger-registry.d.ts +48 -0
  202. package/dist/triggers/trigger-registry.d.ts.map +1 -0
  203. package/dist/triggers/trigger-registry.js +83 -0
  204. package/dist/triggers/trigger-registry.js.map +1 -0
  205. package/dist/types/attachment.d.ts +23 -0
  206. package/dist/types/attachment.d.ts.map +1 -0
  207. package/dist/types/attachment.js +2 -0
  208. package/dist/types/attachment.js.map +1 -0
  209. package/dist/types/known-types.d.ts +6 -3
  210. package/dist/types/known-types.d.ts.map +1 -1
  211. package/dist/types/known-types.js +5 -0
  212. package/dist/types/known-types.js.map +1 -1
  213. package/dist/types/resume-payload.d.ts +34 -0
  214. package/dist/types/resume-payload.d.ts.map +1 -0
  215. package/dist/types/resume-payload.js +12 -0
  216. package/dist/types/resume-payload.js.map +1 -0
  217. package/dist/types/validation.d.ts +2 -1
  218. package/dist/types/validation.d.ts.map +1 -1
  219. package/dist/types/validation.js +1 -0
  220. package/dist/types/validation.js.map +1 -1
  221. package/dist/util/executable-check.d.ts +42 -0
  222. package/dist/util/executable-check.d.ts.map +1 -0
  223. package/dist/util/executable-check.js +115 -0
  224. package/dist/util/executable-check.js.map +1 -0
  225. package/dist/util/schema-marks.d.ts.map +1 -1
  226. package/dist/util/schema-marks.js +19 -21
  227. package/dist/util/schema-marks.js.map +1 -1
  228. package/dist/util/variable-ref.d.ts +4 -1
  229. package/dist/util/variable-ref.d.ts.map +1 -1
  230. package/dist/util/variable-ref.js +10 -5
  231. package/dist/util/variable-ref.js.map +1 -1
  232. package/package.json +5 -1
  233. package/dist/types/config-path.d.ts +0 -24
  234. package/dist/types/config-path.d.ts.map +0 -1
  235. package/dist/types/config-path.js +0 -18
  236. package/dist/types/config-path.js.map +0 -1
  237. package/dist/util/option-mark.d.ts +0 -44
  238. package/dist/util/option-mark.d.ts.map +0 -1
  239. package/dist/util/option-mark.js +0 -132
  240. package/dist/util/option-mark.js.map +0 -1
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Recomputing an agent's arithmetic, safely.
3
+ *
4
+ * A derived value (a growth rate, a ratio, a total) appears **nowhere** in the
5
+ * source, so there is no passage to quote and no page to open — the only honest
6
+ * provenance is *these inputs, combined this way*. Given both, the arithmetic
7
+ * stops being a claim and becomes checkable: the reader is shown a ✓ when the
8
+ * numbers reproduce and a ⚠ when they don't. LLM arithmetic is the least reliable
9
+ * step in the pipeline, and this makes it the most verified.
10
+ *
11
+ * Inputs are referenced **positionally** (`#1`, `#2`) rather than by name or cell.
12
+ * That is the security property, not a convenience: the grammar then contains no
13
+ * identifiers at all, so an expression *cannot* name anything outside the inputs
14
+ * array. No `eval`, no `Function`, no scope to escape into — the worst a
15
+ * malformed expression can do is fail to parse.
16
+ */
17
+ /**
18
+ * Evaluate `expr` over `inputs`, or `undefined` when it cannot be evaluated
19
+ * with certainty.
20
+ *
21
+ * `undefined` is deliberately indistinguishable between "malformed" and
22
+ * "unsupported": in either case the UI shows the expression without a verdict.
23
+ * Showing a wrong ✓ would be worse than showing none.
24
+ */
25
+ export declare function evaluateExpression(expr: string, inputs: number[]): number | undefined;
26
+ /**
27
+ * Parse a number out of a cited value as it appears in a document —
28
+ * `"₹36,816.00"`, `"1 234,5"`, `"(1,200)"` (accounting negative), `"12%"`.
29
+ *
30
+ * Needed because an input's value arrives as source text, not a number, and a
31
+ * verification that only worked on already-clean numbers would rarely fire on
32
+ * real documents. Returns `undefined` when there is no unambiguous number.
33
+ */
34
+ export declare function parseNumericValue(value: unknown): number | undefined;
35
+ //# sourceMappingURL=expression-eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression-eval.d.ts","sourceRoot":"","sources":["../../src/common/expression-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAwHH;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAIrF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAyCpE"}
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Recomputing an agent's arithmetic, safely.
3
+ *
4
+ * A derived value (a growth rate, a ratio, a total) appears **nowhere** in the
5
+ * source, so there is no passage to quote and no page to open — the only honest
6
+ * provenance is *these inputs, combined this way*. Given both, the arithmetic
7
+ * stops being a claim and becomes checkable: the reader is shown a ✓ when the
8
+ * numbers reproduce and a ⚠ when they don't. LLM arithmetic is the least reliable
9
+ * step in the pipeline, and this makes it the most verified.
10
+ *
11
+ * Inputs are referenced **positionally** (`#1`, `#2`) rather than by name or cell.
12
+ * That is the security property, not a convenience: the grammar then contains no
13
+ * identifiers at all, so an expression *cannot* name anything outside the inputs
14
+ * array. No `eval`, no `Function`, no scope to escape into — the worst a
15
+ * malformed expression can do is fail to parse.
16
+ */
17
+ function tokenize(expr) {
18
+ const out = [];
19
+ let i = 0;
20
+ while (i < expr.length) {
21
+ const ch = expr[i];
22
+ if (/\s/.test(ch)) {
23
+ i++;
24
+ continue;
25
+ }
26
+ if (ch === '#') {
27
+ const m = /^#(\d+)/.exec(expr.slice(i));
28
+ if (!m)
29
+ return null;
30
+ const idx = Number(m[1]);
31
+ if (!Number.isInteger(idx) || idx < 1)
32
+ return null;
33
+ out.push({ t: 'ref', i: idx - 1 }); // `#1` is inputs[0] — 1-based reads naturally
34
+ i += m[0].length;
35
+ continue;
36
+ }
37
+ if (/[0-9.]/.test(ch)) {
38
+ const m = /^\d*\.?\d+/.exec(expr.slice(i));
39
+ if (!m)
40
+ return null;
41
+ out.push({ t: 'num', v: Number(m[0]) });
42
+ i += m[0].length;
43
+ continue;
44
+ }
45
+ if (ch === '+' || ch === '-' || ch === '*' || ch === '/') {
46
+ out.push({ t: 'op', v: ch });
47
+ i++;
48
+ continue;
49
+ }
50
+ if (ch === '(') {
51
+ out.push({ t: 'lparen' });
52
+ i++;
53
+ continue;
54
+ }
55
+ if (ch === ')') {
56
+ out.push({ t: 'rparen' });
57
+ i++;
58
+ continue;
59
+ }
60
+ // Anything else — a letter, a call, a property access — is not in the
61
+ // language. Refuse rather than try to interpret it.
62
+ return null;
63
+ }
64
+ return out.length > 0 ? out : null;
65
+ }
66
+ /**
67
+ * Recursive-descent over `expr := term (('+'|'-') term)*`,
68
+ * `term := factor (('*'|'/') factor)*`, `factor := '-'? (num | ref | '(' expr ')')`.
69
+ */
70
+ function parseAndEval(tokens, inputs) {
71
+ let pos = 0;
72
+ let failed = false;
73
+ const fail = () => { failed = true; return undefined; };
74
+ const factor = () => {
75
+ const tok = tokens[pos];
76
+ if (!tok)
77
+ return fail();
78
+ if (tok.t === 'op' && tok.v === '-') { // unary minus
79
+ pos++;
80
+ const v = factor();
81
+ return v === undefined ? undefined : -v;
82
+ }
83
+ if (tok.t === 'num') {
84
+ pos++;
85
+ return tok.v;
86
+ }
87
+ if (tok.t === 'ref') {
88
+ pos++;
89
+ const v = inputs[tok.i];
90
+ // A reference past the inputs it was given is a malformed citation, not a zero.
91
+ return v === undefined || !Number.isFinite(v) ? fail() : v;
92
+ }
93
+ if (tok.t === 'lparen') {
94
+ pos++;
95
+ const v = expression();
96
+ if (failed)
97
+ return undefined;
98
+ if (tokens[pos]?.t !== 'rparen')
99
+ return fail();
100
+ pos++;
101
+ return v;
102
+ }
103
+ return fail();
104
+ };
105
+ const term = () => {
106
+ let left = factor();
107
+ if (left === undefined)
108
+ return undefined;
109
+ for (;;) {
110
+ const tok = tokens[pos];
111
+ if (!tok || tok.t !== 'op' || (tok.v !== '*' && tok.v !== '/'))
112
+ return left;
113
+ pos++;
114
+ const right = factor();
115
+ if (right === undefined)
116
+ return undefined;
117
+ // Division by zero yields Infinity/NaN — not a number a reader can verify.
118
+ if (tok.v === '/' && right === 0)
119
+ return fail();
120
+ left = tok.v === '*' ? left * right : left / right;
121
+ }
122
+ };
123
+ const expression = () => {
124
+ let left = term();
125
+ if (left === undefined)
126
+ return undefined;
127
+ for (;;) {
128
+ const tok = tokens[pos];
129
+ if (!tok || tok.t !== 'op' || (tok.v !== '+' && tok.v !== '-'))
130
+ return left;
131
+ pos++;
132
+ const right = term();
133
+ if (right === undefined)
134
+ return undefined;
135
+ left = tok.v === '+' ? left + right : left - right;
136
+ }
137
+ };
138
+ const result = expression();
139
+ // Trailing tokens mean we understood only a prefix — that is a parse failure,
140
+ // not a partial answer.
141
+ if (failed || pos !== tokens.length || result === undefined)
142
+ return undefined;
143
+ return Number.isFinite(result) ? result : undefined;
144
+ }
145
+ /**
146
+ * Evaluate `expr` over `inputs`, or `undefined` when it cannot be evaluated
147
+ * with certainty.
148
+ *
149
+ * `undefined` is deliberately indistinguishable between "malformed" and
150
+ * "unsupported": in either case the UI shows the expression without a verdict.
151
+ * Showing a wrong ✓ would be worse than showing none.
152
+ */
153
+ export function evaluateExpression(expr, inputs) {
154
+ const tokens = tokenize(expr);
155
+ if (!tokens)
156
+ return undefined;
157
+ return parseAndEval(tokens, inputs);
158
+ }
159
+ /**
160
+ * Parse a number out of a cited value as it appears in a document —
161
+ * `"₹36,816.00"`, `"1 234,5"`, `"(1,200)"` (accounting negative), `"12%"`.
162
+ *
163
+ * Needed because an input's value arrives as source text, not a number, and a
164
+ * verification that only worked on already-clean numbers would rarely fire on
165
+ * real documents. Returns `undefined` when there is no unambiguous number.
166
+ */
167
+ export function parseNumericValue(value) {
168
+ if (typeof value === 'number')
169
+ return Number.isFinite(value) ? value : undefined;
170
+ if (typeof value !== 'string')
171
+ return undefined;
172
+ let s = value.trim();
173
+ if (!s)
174
+ return undefined;
175
+ // Accounting negatives: (1,200) === -1200
176
+ let negative = false;
177
+ if (/^\(.*\)$/.test(s)) {
178
+ negative = true;
179
+ s = s.slice(1, -1);
180
+ }
181
+ // Strip currency symbols, spaces and percent — keep digits, separators, sign.
182
+ s = s.replace(/[^\d.,\-+]/g, '');
183
+ if (!s)
184
+ return undefined;
185
+ // Which separator is the decimal point?
186
+ // both present → the LAST one ("1.234,5" European, "1,234.5" Anglo)
187
+ // one, repeated → thousands ("1,234,567")
188
+ // one, followed by exactly 3 digits → thousands ("1,200" is twelve hundred,
189
+ // not 1.2 — the case that makes a lone
190
+ // separator genuinely ambiguous)
191
+ // otherwise → decimal ("1,5" European, "1.5" Anglo)
192
+ const lastComma = s.lastIndexOf(',');
193
+ const lastDot = s.lastIndexOf('.');
194
+ if (lastComma !== -1 && lastDot !== -1) {
195
+ if (lastComma > lastDot)
196
+ s = s.replace(/\./g, '').replace(',', '.');
197
+ else
198
+ s = s.replace(/,/g, '');
199
+ }
200
+ else if (lastComma !== -1 || lastDot !== -1) {
201
+ const sep = lastComma !== -1 ? ',' : '.';
202
+ const occurrences = s.split(sep).length - 1;
203
+ const tail = s.slice(s.lastIndexOf(sep) + 1);
204
+ const isThousands = occurrences > 1 || /^\d{3}$/.test(tail);
205
+ s = isThousands
206
+ ? s.split(sep).join('')
207
+ : s.replace(sep, '.');
208
+ }
209
+ const n = Number(s);
210
+ if (!Number.isFinite(n))
211
+ return undefined;
212
+ return negative ? -n : n;
213
+ }
214
+ //# sourceMappingURL=expression-eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression-eval.js","sourceRoot":"","sources":["../../src/common/expression-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACpB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAAC,CAAC,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QAErC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,IAAI,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAC;YACpB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YACnD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,GAAG,CAA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AAG,CAAC;QACzC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7C,MAAM,WAAW,GAAG,WAAW,GAAG,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,CAAC,GAAG,WAAW;YACb,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Principal + authorization descriptors — browser-safe shared types.
3
+ *
4
+ * The host authenticates a request into an {@link AuthContext} (the principal).
5
+ * The SDK never interprets `metadata` — it's an opaque claims bag (teamIds,
6
+ * roles, deptId, …). Scoping is derived from the principal by host hooks.
7
+ */
8
+ /** The authenticated principal, produced by the host's `authenticate()` hook. */
9
+ export interface AuthContext {
10
+ userId: string;
11
+ /** Host-defined claims — workspaceId, tenantId, teamIds, roles, etc. Opaque to the SDK. */
12
+ metadata: Record<string, unknown>;
13
+ }
14
+ /** Verbs the scope hooks can differentiate on. Resource types extend this over time. */
15
+ export type WorkflowAction = 'workflow.list' | 'workflow.read' | 'workflow.write' | 'workflow.trigger' | 'execution.list' | 'execution.read' | 'execution.write';
16
+ /**
17
+ * One node in the host's scope hierarchy — what the UI renders in the scope
18
+ * navigator. The host (not the SDK) decides what a node represents
19
+ * (department, team, project); `kind` is a display label only.
20
+ */
21
+ export interface ScopeNode {
22
+ /** Opaque scope id — matches `WorkflowRecord.scope`. */
23
+ id: string;
24
+ label: string;
25
+ /** Display grouping/icon hint, e.g. 'Department' | 'Team'. Not used for routing. */
26
+ kind?: string;
27
+ parentId?: string | null;
28
+ hasChildren?: boolean;
29
+ counts?: {
30
+ workflows?: number;
31
+ running?: number;
32
+ };
33
+ }
34
+ /**
35
+ * What the UI bootstraps from on load. Drives the scope navigator and gates
36
+ * cross-scope ("admin") affordances.
37
+ */
38
+ export interface SessionDescriptor {
39
+ userId: string;
40
+ /** Top-level scopes the principal can reach. */
41
+ scopes: ScopeNode[];
42
+ /** Opaque capability flags, e.g. 'workflow.list.crossScope' for an admin view. */
43
+ capabilities: string[];
44
+ }
45
+ //# sourceMappingURL=principal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.d.ts","sourceRoot":"","sources":["../../src/common/principal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wFAAwF;AACxF,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,kFAAkF;IAClF,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Principal + authorization descriptors — browser-safe shared types.
3
+ *
4
+ * The host authenticates a request into an {@link AuthContext} (the principal).
5
+ * The SDK never interprets `metadata` — it's an opaque claims bag (teamIds,
6
+ * roles, deptId, …). Scoping is derived from the principal by host hooks.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=principal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["../../src/common/principal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-connector.d.ts","sourceRoot":"","sources":["../../../src/connectors/builtin/builtin-connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmBnE,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,SAAkB,EAAE,aAAa;IACjC,SAAkB,OAAO,WAAW;IACpC,SAAkB,IAAI,cAAc;IACpC,SAAkB,WAAW,mGACgE;IAC7F,SAAkB,IAAI,YAAY;IAIlC,uEAAuE;IACvE,SAAkB,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAE5D;IAEF;;;;OAIG;IACH,SAAkB,KAAK,EAAE,SAAS,OAAO,EAAE,CAUxC;IAEH,SAAkB,QAAQ,EAAE,SAAS,UAAU,EAAE,CAK/C;CACH"}
1
+ {"version":3,"file":"builtin-connector.d.ts","sourceRoot":"","sources":["../../../src/connectors/builtin/builtin-connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAqBnE,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,SAAkB,EAAE,aAAa;IACjC,SAAkB,OAAO,WAAW;IACpC,SAAkB,IAAI,cAAc;IACpC,SAAkB,WAAW,mGACgE;IAC7F,SAAkB,IAAI,YAAY;IAIlC,uEAAuE;IACvE,SAAkB,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAE5D;IAEF;;;;OAIG;IACH,SAAkB,KAAK,EAAE,SAAS,OAAO,EAAE,CAaxC;IAEH,SAAkB,QAAQ,EAAE,SAAS,UAAU,EAAE,CAK/C;CACH"}
@@ -18,9 +18,11 @@ import { CodeStep } from './steps/code.step.js';
18
18
  import { ConditionalStep } from './steps/conditional.step.js';
19
19
  import { DedupStep } from './steps/dedup.step.js';
20
20
  import { HttpRequestStep } from './steps/http-request.step.js';
21
+ import { FinishStep, GoToStep } from './steps/jump.step.js';
21
22
  import { LoopStep } from './steps/loop.step.js';
22
23
  import { MapStep } from './steps/map.step.js';
23
24
  import { ParallelStep } from './steps/parallel.step.js';
25
+ import { CycleStep } from './steps/cycle.step.js';
24
26
  import { SwitchStep } from './steps/switch.step.js';
25
27
  import { WaitStep } from './steps/wait.step.js';
26
28
  import { DefaultManualTrigger } from './triggers/default-manual-trigger.js';
@@ -43,13 +45,16 @@ export class BuiltinConnector extends BaseConnector {
43
45
  * old array needed are gone with it.
44
46
  */
45
47
  steps = declareSteps(BUILTIN_CREDENTIALS, [
48
+ new FinishStep(),
46
49
  new CodeStep(),
47
50
  new ConditionalStep(),
51
+ new GoToStep(),
48
52
  new DedupStep(),
49
53
  new HttpRequestStep(),
50
54
  new LoopStep(),
51
55
  new MapStep(),
52
56
  new ParallelStep(),
57
+ new CycleStep(),
53
58
  new SwitchStep(),
54
59
  new WaitStep(),
55
60
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-connector.js","sourceRoot":"","sources":["../../../src/connectors/builtin/builtin-connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAC/B,EAAE,GAAG,SAAS,CAAC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C5C,CAAC;CACH"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * CYCLE step — run a body in rounds until it finishes without jumping back.
3
+ *
4
+ * LOOP walks an array known up front. CYCLE is for when the next round depends
5
+ * on what happened in this one — a menu the user moves around in, a check that
6
+ * waits until something is ready. Each round walks `body` as its own node-path
7
+ * frame `<cycleStepId>:body#<round>`:
8
+ *
9
+ * - a GO_TO aimed at this step, at any depth inside the body, ends the round
10
+ * and starts the next one with the GO_TO's value as the new `input`
11
+ * - a FINISH aimed at it ends the CYCLE, its value becoming the result
12
+ * - the body finishing normally ends the CYCLE
13
+ *
14
+ * `__loop.output = { currentIndex, input }` is visible inside the body, like
15
+ * LOOP's `__loop`. A round's input only ever comes from the jump that ended the
16
+ * round before, and the executor saves that jump on its step records — so a
17
+ * resumed execution replays into the same round with the same input.
18
+ *
19
+ * Output: `{ rounds, exit, result }`
20
+ */
21
+ import { z } from 'zod';
22
+ import { BaseControlFlowStep } from '../../../steps/base-step.js';
23
+ import type { ControlFlowExecutionContext } from '../../../steps/base-step.js';
24
+ import { BuiltinStepType } from '../../../types/known-types.js';
25
+ import type { WorkflowStepConfig } from '../../../types/workflow-config.js';
26
+ import type { JumpKind } from '../../../engine/branch-signal.js';
27
+ export declare const CycleStepConfigSchema: z.ZodObject<{
28
+ input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
29
+ body: z.ZodArray<z.ZodObject<{
30
+ id: z.ZodString;
31
+ type: z.ZodString;
32
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
33
+ id: z.ZodString;
34
+ type: z.ZodString;
35
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
36
+ id: z.ZodString;
37
+ type: z.ZodString;
38
+ }, z.ZodTypeAny, "passthrough">>, "many">;
39
+ maxIterations: z.ZodDefault<z.ZodNumber>;
40
+ }, "strip", z.ZodTypeAny, {
41
+ body: z.objectOutputType<{
42
+ id: z.ZodString;
43
+ type: z.ZodString;
44
+ }, z.ZodTypeAny, "passthrough">[];
45
+ maxIterations: number;
46
+ input: Record<string, unknown>;
47
+ }, {
48
+ body: z.objectInputType<{
49
+ id: z.ZodString;
50
+ type: z.ZodString;
51
+ }, z.ZodTypeAny, "passthrough">[];
52
+ maxIterations?: number | undefined;
53
+ input?: Record<string, unknown> | undefined;
54
+ }>;
55
+ export type CycleStepConfig = z.infer<typeof CycleStepConfigSchema>;
56
+ export interface CycleStepOutput extends Record<string, unknown> {
57
+ /** How many rounds ran. */
58
+ rounds: number;
59
+ /** Why the CYCLE ended. */
60
+ exit: 'completed' | 'finish' | 'max_iterations';
61
+ /** A FINISH's value; otherwise the last round's input. */
62
+ result: Record<string, unknown>;
63
+ }
64
+ export declare class CycleStep extends BaseControlFlowStep<typeof CycleStepConfigSchema, CycleStepOutput> {
65
+ readonly type = BuiltinStepType.CYCLE;
66
+ readonly name = "Cycle";
67
+ readonly description = "Runs its steps in rounds, carrying state from one to the next. A Go to inside jumps back here and starts the next round from the top with a new input \u2014 it restarts the round rather than resuming where it left off. A Finish ends the cycle, and the value it carries becomes the result. Use it when the flow returns to the same steps again and again: a chat that shows a menu each turn, a retry until approved, a check until something is ready";
68
+ readonly configSchema: z.ZodObject<{
69
+ input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
70
+ body: z.ZodArray<z.ZodObject<{
71
+ id: z.ZodString;
72
+ type: z.ZodString;
73
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
74
+ id: z.ZodString;
75
+ type: z.ZodString;
76
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
77
+ id: z.ZodString;
78
+ type: z.ZodString;
79
+ }, z.ZodTypeAny, "passthrough">>, "many">;
80
+ maxIterations: z.ZodDefault<z.ZodNumber>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ body: z.objectOutputType<{
83
+ id: z.ZodString;
84
+ type: z.ZodString;
85
+ }, z.ZodTypeAny, "passthrough">[];
86
+ maxIterations: number;
87
+ input: Record<string, unknown>;
88
+ }, {
89
+ body: z.objectInputType<{
90
+ id: z.ZodString;
91
+ type: z.ZodString;
92
+ }, z.ZodTypeAny, "passthrough">[];
93
+ maxIterations?: number | undefined;
94
+ input?: Record<string, unknown> | undefined;
95
+ }>;
96
+ readonly outputSchema: z.ZodObject<{
97
+ rounds: z.ZodNumber;
98
+ exit: z.ZodEnum<["completed", "finish", "max_iterations"]>;
99
+ result: z.ZodRecord<z.ZodString, z.ZodUnknown>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ result: Record<string, unknown>;
102
+ rounds: number;
103
+ exit: "finish" | "completed" | "max_iterations";
104
+ }, {
105
+ result: Record<string, unknown>;
106
+ rounds: number;
107
+ exit: "finish" | "completed" | "max_iterations";
108
+ }>;
109
+ readonly category: "control";
110
+ readonly branchModel: "iterate";
111
+ readonly jumps: "catch";
112
+ readonly icon = "repeat";
113
+ readonly declaredOutputs: readonly [{
114
+ readonly key: "body";
115
+ readonly label: "Each round";
116
+ }];
117
+ getBranches(config: Record<string, unknown>): Record<string, WorkflowStepConfig[]>;
118
+ branchScopeSchemas(config: Record<string, unknown>): Record<string, Record<string, unknown>>;
119
+ /** A GO_TO starts a round, so it must carry exactly the keys `input` declares. */
120
+ checkJump(config: Record<string, unknown>, jump: {
121
+ kind: JumpKind;
122
+ value: unknown;
123
+ }): string | null;
124
+ execute(config: CycleStepConfig, ctx: ControlFlowExecutionContext): Promise<CycleStepOutput>;
125
+ }
126
+ //# sourceMappingURL=cycle.step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cycle.step.d.ts","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/cycle.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC/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AM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAY1C,kFAAkF;IACzE,SAAS,CAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,GACvC,MAAM,GAAG,IAAI;IAgBD,OAAO,CACpB,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,2BAA2B,GAC/B,OAAO,CAAC,eAAe,CAAC;CAkC5B"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * CYCLE step — run a body in rounds until it finishes without jumping back.
3
+ *
4
+ * LOOP walks an array known up front. CYCLE is for when the next round depends
5
+ * on what happened in this one — a menu the user moves around in, a check that
6
+ * waits until something is ready. Each round walks `body` as its own node-path
7
+ * frame `<cycleStepId>:body#<round>`:
8
+ *
9
+ * - a GO_TO aimed at this step, at any depth inside the body, ends the round
10
+ * and starts the next one with the GO_TO's value as the new `input`
11
+ * - a FINISH aimed at it ends the CYCLE, its value becoming the result
12
+ * - the body finishing normally ends the CYCLE
13
+ *
14
+ * `__loop.output = { currentIndex, input }` is visible inside the body, like
15
+ * LOOP's `__loop`. A round's input only ever comes from the jump that ended the
16
+ * round before, and the executor saves that jump on its step records — so a
17
+ * resumed execution replays into the same round with the same input.
18
+ *
19
+ * Output: `{ rounds, exit, result }`
20
+ */
21
+ import { z } from 'zod';
22
+ import { BaseControlFlowStep, cloneScope } from '../../../steps/base-step.js';
23
+ import { BuiltinStepType } from '../../../types/known-types.js';
24
+ import { VariableResolver } from '../../../engine/variable-resolver.js';
25
+ import { BranchSignal } from '../../../engine/branch-signal.js';
26
+ import { isPureRef } from '../../../util/variable-ref.js';
27
+ // ─── Config ───
28
+ export const CycleStepConfigSchema = z.object({
29
+ input: z.record(z.unknown()).default({}).describe('The state each round starts with — the first round gets this, and every Go to replaces it for the next one. Read it in the body as steps.__loop.output.input.<key>; the keys you put here are the keys a Go to must carry. Supports {{variable}} refs'),
30
+ body: z.array(z.object({ id: z.string(), type: z.string() }).passthrough()).describe('Steps to run each round. They start again from the first one on every round'),
31
+ maxIterations: z.number().int().positive().default(100).describe('Safety limit: how many rounds before the cycle stops on its own (exit: max_iterations)'),
32
+ });
33
+ const CycleStepOutputSchema = z.object({
34
+ rounds: z.number(),
35
+ exit: z.enum(['completed', 'finish', 'max_iterations']),
36
+ result: z.record(z.unknown()),
37
+ });
38
+ // ─── Step ───
39
+ export class CycleStep extends BaseControlFlowStep {
40
+ type = BuiltinStepType.CYCLE;
41
+ name = 'Cycle';
42
+ description = 'Runs its steps in rounds, carrying state from one to the next. A Go to inside jumps back here and starts the next round from the top with a new input — it restarts the round rather than resuming where it left off. A Finish ends the cycle, and the value it carries becomes the result. Use it when the flow returns to the same steps again and again: a chat that shows a menu each turn, a retry until approved, a check until something is ready';
43
+ configSchema = CycleStepConfigSchema;
44
+ outputSchema = CycleStepOutputSchema;
45
+ category = 'control';
46
+ branchModel = 'iterate';
47
+ jumps = 'catch';
48
+ icon = 'repeat';
49
+ declaredOutputs = [
50
+ { key: 'body', label: 'Each round' },
51
+ ];
52
+ getBranches(config) {
53
+ return {
54
+ body: (config['body'] ?? []),
55
+ };
56
+ }
57
+ branchScopeSchemas(config) {
58
+ return {
59
+ '__loop.output': {
60
+ type: 'object',
61
+ properties: {
62
+ currentIndex: { type: 'number' },
63
+ input: inputJsonSchema(config['input']),
64
+ },
65
+ },
66
+ };
67
+ }
68
+ /** A GO_TO starts a round, so it must carry exactly the keys `input` declares. */
69
+ checkJump(config, jump) {
70
+ if (jump.kind !== 'goto')
71
+ return null;
72
+ const expected = Object.keys(asRecord(config['input']));
73
+ const given = Object.keys(asRecord(jump.value));
74
+ const missing = expected.filter((key) => !given.includes(key));
75
+ if (missing.length > 0) {
76
+ return `GO_TO must set ${quoteList(missing)}: every round starts from the CYCLE's input.`;
77
+ }
78
+ const unknown = given.filter((key) => !expected.includes(key));
79
+ if (unknown.length > 0) {
80
+ return `${quoteList(unknown)} ${unknown.length === 1 ? 'is' : 'are'} not in the CYCLE's input. Add ${unknown.length === 1 ? 'it' : 'them'} there first.`;
81
+ }
82
+ return null;
83
+ }
84
+ async execute(config, ctx) {
85
+ const self = ctx.runtime.stepId;
86
+ // Control-step configs reach execute() unresolved, so resolve refs here.
87
+ let input = asRecord(new VariableResolver().resolve(config.input, ctx.workflow));
88
+ for (let round = 0; round < config.maxIterations; round++) {
89
+ // Each round runs in its own scope, keyed by node-path frame
90
+ // `repeat_x:body#<round>`, so a WAIT in round N resumes round N.
91
+ const roundScope = cloneScope(ctx.workflow);
92
+ roundScope.steps['__loop'] = {
93
+ type: 'CYCLE',
94
+ output: { currentIndex: round, input },
95
+ };
96
+ try {
97
+ await ctx.walkBranch(config.body, roundScope, 'body', round);
98
+ return { rounds: round + 1, exit: 'completed', result: input };
99
+ }
100
+ catch (err) {
101
+ // Pauses, failures and jumps aimed at a loop further out keep unwinding.
102
+ if (!BranchSignal.is(err) || err.signal.target !== self)
103
+ throw err;
104
+ if (err.signal.kind === 'finish') {
105
+ return { rounds: round + 1, exit: 'finish', result: err.signal.value };
106
+ }
107
+ input = err.signal.value;
108
+ }
109
+ }
110
+ return { rounds: config.maxIterations, exit: 'max_iterations', result: input };
111
+ }
112
+ }
113
+ // ─── Helpers ───
114
+ function asRecord(value) {
115
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
116
+ ? value
117
+ : {};
118
+ }
119
+ /** JSON Schema for the round input, typed from the literal values in `input`. */
120
+ function inputJsonSchema(input) {
121
+ const properties = {};
122
+ for (const [key, value] of Object.entries(asRecord(input))) {
123
+ properties[key] = valueJsonSchema(value);
124
+ }
125
+ return { type: 'object', properties };
126
+ }
127
+ function valueJsonSchema(value) {
128
+ // A ref's type isn't known until it resolves, so leave that property open.
129
+ if (typeof value === 'string')
130
+ return isPureRef(value) ? {} : { type: 'string' };
131
+ if (typeof value === 'number')
132
+ return { type: 'number' };
133
+ if (typeof value === 'boolean')
134
+ return { type: 'boolean' };
135
+ if (Array.isArray(value))
136
+ return { type: 'array' };
137
+ if (value !== null && typeof value === 'object')
138
+ return { type: 'object', additionalProperties: true };
139
+ return {};
140
+ }
141
+ function quoteList(keys) {
142
+ return keys.map((key) => `"${key}"`).join(', ');
143
+ }
144
+ //# sourceMappingURL=cycle.step.js.map