@xyne/workflow-sdk 3.2.41 → 3.2.43

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 (237) 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 +27 -4
  10. package/dist/agents/host-agent-step.d.ts.map +1 -1
  11. package/dist/agents/host-agent-step.js +98 -18
  12. package/dist/agents/host-agent-step.js.map +1 -1
  13. package/dist/agents/provider.d.ts +24 -5
  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 +95 -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 +157 -0
  91. package/dist/conversational-flow/types.d.ts.map +1 -0
  92. package/dist/conversational-flow/types.js +27 -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/variable-ref.d.ts +4 -1
  226. package/dist/util/variable-ref.d.ts.map +1 -1
  227. package/dist/util/variable-ref.js +10 -5
  228. package/dist/util/variable-ref.js.map +1 -1
  229. package/package.json +5 -1
  230. package/dist/types/config-path.d.ts +0 -24
  231. package/dist/types/config-path.d.ts.map +0 -1
  232. package/dist/types/config-path.js +0 -18
  233. package/dist/types/config-path.js.map +0 -1
  234. package/dist/util/option-mark.d.ts +0 -44
  235. package/dist/util/option-mark.d.ts.map +0 -1
  236. package/dist/util/option-mark.js +0 -132
  237. package/dist/util/option-mark.js.map +0 -1
@@ -0,0 +1,126 @@
1
+ /**
2
+ * REPEAT step — run a body in rounds until it finishes without jumping back.
3
+ *
4
+ * LOOP walks an array known up front. REPEAT 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 `repeat_x:body#<round>`:
8
+ *
9
+ * - a CONTINUE aimed at this step, at any depth inside the body, ends the round
10
+ * and starts the next one with the CONTINUE's value as the new `input`
11
+ * - a BREAK aimed at it ends the REPEAT, its value becoming the result
12
+ * - the body finishing normally ends the REPEAT
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 RepeatStepConfigSchema: 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 RepeatStepConfig = z.infer<typeof RepeatStepConfigSchema>;
56
+ export interface RepeatStepOutput extends Record<string, unknown> {
57
+ /** How many rounds ran. */
58
+ rounds: number;
59
+ /** Why the REPEAT ended. */
60
+ exit: 'completed' | 'break' | 'max_iterations';
61
+ /** A BREAK's value; otherwise the last round's input. */
62
+ result: Record<string, unknown>;
63
+ }
64
+ export declare class RepeatStep extends BaseControlFlowStep<typeof RepeatStepConfigSchema, RepeatStepOutput> {
65
+ readonly type = BuiltinStepType.REPEAT;
66
+ readonly name = "Repeat";
67
+ readonly description = "Run steps in rounds; a Continue step inside starts the next round with a new input";
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", "break", "max_iterations"]>;
99
+ result: z.ZodRecord<z.ZodString, z.ZodUnknown>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ result: Record<string, unknown>;
102
+ rounds: number;
103
+ exit: "break" | "completed" | "max_iterations";
104
+ }, {
105
+ result: Record<string, unknown>;
106
+ rounds: number;
107
+ exit: "break" | "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 CONTINUE 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: RepeatStepConfig, ctx: ControlFlowExecutionContext): Promise<RepeatStepOutput>;
125
+ }
126
+ //# sourceMappingURL=repeat.step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repeat.step.d.ts","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/repeat.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/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAKjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,gBAAgB,CAAC;IAC/C,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAUD,qBAAa,UAAW,SAAQ,mBAAmB,CACjD,OAAO,sBAAsB,EAC7B,gBAAgB,CACjB;IACC,SAAkB,IAAI,0BAA0B;IAChD,SAAkB,IAAI,YAAY;IAClC,SAAkB,WAAW,wFAAwF;IACrH,SAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA0B;IACxD,SAAkB,YAAY;;;;;;;;;;;;OAA0B;IACxD,SAAkB,QAAQ,EAAG,SAAS,CAAU;IAChD,SAAkB,WAAW,EAAG,SAAS,CAAU;IACnD,SAAkB,KAAK,EAAG,OAAO,CAAU;IAC3C,SAAkB,IAAI,YAAY;IAClC,SAAkB,eAAe;;;OAEtB;IAEF,WAAW,CAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAM9B,kBAAkB,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAY1C,qFAAqF;IAC5E,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,gBAAgB,EACxB,GAAG,EAAE,2BAA2B,GAC/B,OAAO,CAAC,gBAAgB,CAAC;CAkC7B"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * REPEAT step — run a body in rounds until it finishes without jumping back.
3
+ *
4
+ * LOOP walks an array known up front. REPEAT 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 `repeat_x:body#<round>`:
8
+ *
9
+ * - a CONTINUE aimed at this step, at any depth inside the body, ends the round
10
+ * and starts the next one with the CONTINUE's value as the new `input`
11
+ * - a BREAK aimed at it ends the REPEAT, its value becoming the result
12
+ * - the body finishing normally ends the REPEAT
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 RepeatStepConfigSchema = z.object({
29
+ input: z.record(z.unknown()).default({}).describe('Input for the first round, read in the body as steps.__loop.output.input. A Continue step sets it for the next round. Supports {{variable}} refs'),
30
+ body: z.array(z.object({ id: z.string(), type: z.string() }).passthrough()).describe('Steps to run each round'),
31
+ maxIterations: z.number().int().positive().default(100).describe('Maximum number of rounds as a safety limit'),
32
+ });
33
+ const RepeatStepOutputSchema = z.object({
34
+ rounds: z.number(),
35
+ exit: z.enum(['completed', 'break', 'max_iterations']),
36
+ result: z.record(z.unknown()),
37
+ });
38
+ // ─── Step ───
39
+ export class RepeatStep extends BaseControlFlowStep {
40
+ type = BuiltinStepType.REPEAT;
41
+ name = 'Repeat';
42
+ description = 'Run steps in rounds; a Continue step inside starts the next round with a new input';
43
+ configSchema = RepeatStepConfigSchema;
44
+ outputSchema = RepeatStepOutputSchema;
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 CONTINUE starts a round, so it must carry exactly the keys `input` declares. */
69
+ checkJump(config, jump) {
70
+ if (jump.kind !== 'continue')
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 `CONTINUE must set ${quoteList(missing)}: every round starts from the REPEAT'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 REPEAT'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: 'REPEAT',
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 === 'break') {
105
+ return { rounds: round + 1, exit: 'break', 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=repeat.step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repeat.step.js","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/repeat.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,iBAAiB;AAEjB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,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AO,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACnD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;IACvG,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,SAAS,CAAC,IAAc;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A new conversational flow: the smallest conversation that runs.
3
+ *
4
+ * CYCLE conversation input { screen: 'start', text: '' }
5
+ * └ SWITCH route on screen
6
+ * ├ start — the first screen: a greeting, no options yet
7
+ * ├ ai_router — typed text → an agent picks the screen
8
+ * ├ done — Finish
9
+ * └ default → start
10
+ *
11
+ * Everything after this is built on the map. This is the one place that names
12
+ * the fields (`choice`, `message`) and inputs (`screen`, `text`); every later
13
+ * edit copies whatever shape the flow already has.
14
+ */
15
+ import type { WorkflowConfig } from '../types/workflow-config.js';
16
+ export declare const CONVERSATIONAL_FLOW_KIND = "conversational_flow";
17
+ export interface NewConversationalFlow {
18
+ config: WorkflowConfig;
19
+ /** Stored on the workflow so it opens in the conversational-flow editor. */
20
+ metadata: {
21
+ kind: typeof CONVERSATIONAL_FLOW_KIND;
22
+ };
23
+ }
24
+ export declare function createConversationalFlow(options?: {
25
+ /** The agent that routes typed messages; can be set later. */
26
+ agentSlug?: string;
27
+ greeting?: string;
28
+ /** Title of the first screen, and the conversation header on it. */
29
+ title?: string;
30
+ }): NewConversationalFlow;
31
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAIlE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,EAAE;QAAE,IAAI,EAAE,OAAO,wBAAwB,CAAA;KAAE,CAAC;CACrD;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAChD,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,GAAG,qBAAqB,CA4F7B"}
@@ -0,0 +1,95 @@
1
+ import { AGENT_STEP_TYPE } from './types.js';
2
+ import { refreshDerived } from './edit.js';
3
+ export const CONVERSATIONAL_FLOW_KIND = 'conversational_flow';
4
+ export function createConversationalFlow(options = {}) {
5
+ const title = options.title?.trim() || 'Start';
6
+ const greeting = options.greeting?.trim() || 'Hi! How can I help?';
7
+ const cycle = 'conversation';
8
+ const screenRef = '{{steps.__loop.output.input.screen}}';
9
+ const choice = (wait) => `{{steps.${wait}.output.resumeData.data.choice}}`;
10
+ const message = (wait) => `{{steps.${wait}.output.resumeData.data.message}}`;
11
+ const go = (id, screen, text = '') => ({
12
+ id,
13
+ type: 'GO_TO',
14
+ config: { target: cycle, with: { screen, text } },
15
+ });
16
+ const config = {
17
+ trigger: { type: 'MANUAL', config: {} },
18
+ steps: [
19
+ {
20
+ id: cycle,
21
+ type: 'CYCLE',
22
+ config: {
23
+ input: { screen: 'start', text: '' },
24
+ maxIterations: 200,
25
+ body: [
26
+ {
27
+ id: 'route',
28
+ type: 'SWITCH',
29
+ config: {
30
+ cases: [
31
+ {
32
+ label: title,
33
+ condition: { variable: screenRef, operator: 'eq', value: 'start' },
34
+ steps: [
35
+ {
36
+ id: 'ask_start',
37
+ type: 'WAIT',
38
+ config: {
39
+ mode: 'approval',
40
+ reason: title,
41
+ prompt: greeting,
42
+ form: {
43
+ fields: [
44
+ { type: 'select', name: 'choice', label: 'Choose one', options: [] },
45
+ { type: 'text', name: 'message', label: 'Or type your question' },
46
+ ],
47
+ },
48
+ },
49
+ },
50
+ {
51
+ id: 'typed_start',
52
+ type: 'CONDITIONAL',
53
+ config: {
54
+ condition: {
55
+ all: [
56
+ { variable: message('ask_start'), operator: 'exists' },
57
+ { variable: message('ask_start'), operator: 'neq', value: '' },
58
+ ],
59
+ },
60
+ if_true: [go('route_start', 'ai_router', message('ask_start'))],
61
+ if_false: [go('go_start', choice('ask_start'))],
62
+ },
63
+ },
64
+ ],
65
+ },
66
+ {
67
+ label: 'AI router',
68
+ condition: { variable: screenRef, operator: 'eq', value: 'ai_router' },
69
+ steps: [
70
+ {
71
+ id: 'classify',
72
+ type: AGENT_STEP_TYPE,
73
+ config: { agentSlug: options.agentSlug?.trim() ?? '', task: '', outputType: 'json' },
74
+ },
75
+ go('go_classified', '{{steps.classify.output.response.screen}}'),
76
+ ],
77
+ },
78
+ {
79
+ label: 'Finish',
80
+ condition: { variable: screenRef, operator: 'eq', value: 'done' },
81
+ steps: [{ id: 'finish', type: 'FINISH', config: { target: cycle, with: { outcome: 'done' } } }],
82
+ },
83
+ ],
84
+ default: [go('unknown_screen', 'start')],
85
+ },
86
+ },
87
+ ],
88
+ },
89
+ },
90
+ ],
91
+ };
92
+ // Writes the router's instructions and allowed screens from the screens above.
93
+ return { config: refreshDerived(config), metadata: { kind: CONVERSATIONAL_FLOW_KIND } };
94
+ }
95
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe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EAAE,UAAU;gDACd,IAAI,EAAE,eAAe;gDACrB,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;6CACrF;4CACD,EAAE,CAAC,eAAe,EAAE,2CAA2C,CAAC;yCACjE;qCACF;oCACD;wCACE,KAAK,EAAE,QAAQ;wCACf,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;wCACjE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;qCAChG;iCACF;gCACD,OAAO,EAAE,CAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;6BACzC;yBACF;qBACF;iBACF;aACF;SACF;KAC2B,CAAC;IAE/B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Conversational-flow edits, as pure `config → config` functions.
3
+ *
4
+ * Each edit changes the real steps — a case label, a WAIT's options, a GO_TO's
5
+ * destination — and nothing else. There is no second model to keep in step:
6
+ * `readConversationalFlow` is re-run on the result.
7
+ *
8
+ * Where an edit has to create steps (a new screen), it copies the shape of one
9
+ * that already exists in the flow — its field names, the keys its GO_TOs
10
+ * carry — rather than assuming `choice`, `message`, `screen` or `text`.
11
+ *
12
+ * Two things are derived and refreshed after every structural edit, so the
13
+ * author never maintains them by hand:
14
+ * - prompt headers that were the generated breadcrumb ("Payments › Charges");
15
+ * - the AI router's instructions and the screens it may choose (`task`,
16
+ * `outputSchema.enum`), built from each screen's title, place and "about".
17
+ */
18
+ import type { WorkflowConfig } from '../types/workflow-config.js';
19
+ import type { ConversationalFlow, Screen } from './types.js';
20
+ export declare class ConversationalFlowEditError extends Error {
21
+ readonly name = "ConversationalFlowEditError";
22
+ }
23
+ /** Screen types an author can add. Routers are one per flow; hand-off needs a host step. */
24
+ export type NewScreenType = 'menu' | 'message' | 'questions' | 'ask-ai' | 'end';
25
+ /** Rename a screen. Breadcrumb headers and the router's list follow the new name. */
26
+ export declare function renameScreen(config: WorkflowConfig, screenId: string, title: string): WorkflowConfig;
27
+ /** "AI sends people here when…" — what the router reads about this screen. */
28
+ export declare function setAbout(config: WorkflowConfig, screenId: string, about: string): WorkflowConfig;
29
+ /**
30
+ * Add a screen of `type` under `parent` and link the parent to it. It sends
31
+ * typed text wherever the rest of the flow does and offers the way back.
32
+ */
33
+ export declare function addScreen(config: WorkflowConfig, args: {
34
+ title: string;
35
+ parent: string;
36
+ type?: NewScreenType;
37
+ id?: string;
38
+ }): {
39
+ config: WorkflowConfig;
40
+ screenId: string;
41
+ };
42
+ /**
43
+ * Change what a screen is. The title, "about" and wording carry over. A screen
44
+ * that other screens hang beneath can only become another screen with options.
45
+ */
46
+ export declare function setScreenType(config: WorkflowConfig, screenId: string, type: NewScreenType): WorkflowConfig;
47
+ /** Remove a screen, every option that led to it, and the router's permission to pick it. */
48
+ export declare function removeScreen(config: WorkflowConfig, screenId: string): WorkflowConfig;
49
+ /**
50
+ * Hang a screen beneath another. The old parent stops linking to it, the new one
51
+ * starts, and the way back from it — and from everything beneath it — follows.
52
+ */
53
+ export declare function moveScreen(config: WorkflowConfig, screenId: string, newParentId: string): WorkflowConfig;
54
+ /** Offer (or stop offering) the way back — ↑ each ancestor, then the first screen. */
55
+ export declare function setWayBack(config: WorkflowConfig, screenId: string, on: boolean): WorkflowConfig;
56
+ /** What a Finish screen returns as the run's outcome. */
57
+ export declare function setEndResult(config: WorkflowConfig, screenId: string, value: Record<string, unknown>): WorkflowConfig;
58
+ export declare function setRouterAgent(config: WorkflowConfig, agentSlug: string): WorkflowConfig;
59
+ /** The author's own instructions to the router, put before the generated screen list. */
60
+ export declare function setRouterGuidance(config: WorkflowConfig, guidance: string): WorkflowConfig;
61
+ export declare function setAskAi(config: WorkflowConfig, screenId: string, patch: {
62
+ agent?: string;
63
+ task?: string;
64
+ intro?: string;
65
+ }): WorkflowConfig;
66
+ export declare function setPromptText(config: WorkflowConfig, promptId: string, text: string): WorkflowConfig;
67
+ /**
68
+ * Add an answer to a question that opens a follow-up question, asked in the
69
+ * same round. The prompt must already branch on its answers (a Questions screen).
70
+ */
71
+ export declare function addFollowUp(config: WorkflowConfig, promptId: string, args: {
72
+ label: string;
73
+ question: string;
74
+ }): {
75
+ config: WorkflowConfig;
76
+ promptId: string;
77
+ };
78
+ /** Add an option that goes to a screen. */
79
+ export declare function addOption(config: WorkflowConfig, promptId: string, option: {
80
+ label: string;
81
+ screen: string;
82
+ }, at?: number): WorkflowConfig;
83
+ export declare function relabelOption(config: WorkflowConfig, promptId: string, index: number, label: string): WorkflowConfig;
84
+ /**
85
+ * Point an option at another screen. For a plain screen the option's value *is*
86
+ * its destination, so this rewrites the value. An option that opens a
87
+ * follow-up question can't be repointed — that would drop the question.
88
+ */
89
+ export declare function retargetOption(config: WorkflowConfig, promptId: string, index: number, screen: string): WorkflowConfig;
90
+ export declare function removeOption(config: WorkflowConfig, promptId: string, index: number): WorkflowConfig;
91
+ export declare function moveOption(config: WorkflowConfig, promptId: string, from: number, to: number): WorkflowConfig;
92
+ /** Recompute what is derived from the screens (headers, the router) without any other change. */
93
+ export declare function refreshDerived(config: WorkflowConfig): WorkflowConfig;
94
+ /** "Payments › Charges › Charged twice" — ancestors below the root, then the screen. */
95
+ export declare function breadcrumb(flow: ConversationalFlow, screen: Screen): string;
96
+ /** Screens the router may send people to: everything they can be shown. */
97
+ export declare function routableScreens(flow: ConversationalFlow): Screen[];
98
+ //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