@xyne/workflow-sdk 3.2.46 → 3.2.48

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 (186) hide show
  1. package/dist/agents/host-agent-step.d.ts +2 -2
  2. package/dist/connectors/builtin/steps/classifier-agent.step.d.ts +2 -2
  3. package/dist/connectors/builtin/steps/map.step.d.ts +15 -4
  4. package/dist/connectors/builtin/steps/map.step.d.ts.map +1 -1
  5. package/dist/connectors/builtin/steps/map.step.js +51 -18
  6. package/dist/connectors/builtin/steps/map.step.js.map +1 -1
  7. package/dist/connectors/builtin/steps/parallel.step.d.ts +4 -4
  8. package/dist/connectors/builtin/steps/wait.step.d.ts +28 -0
  9. package/dist/connectors/builtin/steps/wait.step.d.ts.map +1 -1
  10. package/dist/connectors/builtin/steps/wait.step.js +26 -1
  11. package/dist/connectors/builtin/steps/wait.step.js.map +1 -1
  12. package/dist/conversational-flow/calls.d.ts +20 -0
  13. package/dist/conversational-flow/calls.d.ts.map +1 -0
  14. package/dist/conversational-flow/calls.js +59 -0
  15. package/dist/conversational-flow/calls.js.map +1 -0
  16. package/dist/conversational-flow/conditions.d.ts +24 -0
  17. package/dist/conversational-flow/conditions.d.ts.map +1 -0
  18. package/dist/conversational-flow/conditions.js +69 -0
  19. package/dist/conversational-flow/conditions.js.map +1 -0
  20. package/dist/conversational-flow/create.d.ts +23 -18
  21. package/dist/conversational-flow/create.d.ts.map +1 -1
  22. package/dist/conversational-flow/create.js +73 -96
  23. package/dist/conversational-flow/create.js.map +1 -1
  24. package/dist/conversational-flow/edit/build.d.ts +112 -0
  25. package/dist/conversational-flow/edit/build.d.ts.map +1 -0
  26. package/dist/conversational-flow/edit/build.js +249 -0
  27. package/dist/conversational-flow/edit/build.js.map +1 -0
  28. package/dist/conversational-flow/edit/calls.d.ts +61 -0
  29. package/dist/conversational-flow/edit/calls.d.ts.map +1 -0
  30. package/dist/conversational-flow/edit/calls.js +296 -0
  31. package/dist/conversational-flow/edit/calls.js.map +1 -0
  32. package/dist/conversational-flow/edit/cases.d.ts +29 -0
  33. package/dist/conversational-flow/edit/cases.d.ts.map +1 -0
  34. package/dist/conversational-flow/edit/cases.js +83 -0
  35. package/dist/conversational-flow/edit/cases.js.map +1 -0
  36. package/dist/conversational-flow/edit/endings.d.ts +16 -0
  37. package/dist/conversational-flow/edit/endings.d.ts.map +1 -0
  38. package/dist/conversational-flow/edit/endings.js +53 -0
  39. package/dist/conversational-flow/edit/endings.js.map +1 -0
  40. package/dist/conversational-flow/edit/followups.d.ts +28 -0
  41. package/dist/conversational-flow/edit/followups.d.ts.map +1 -0
  42. package/dist/conversational-flow/edit/followups.js +103 -0
  43. package/dist/conversational-flow/edit/followups.js.map +1 -0
  44. package/dist/conversational-flow/edit/inputs.d.ts +24 -0
  45. package/dist/conversational-flow/edit/inputs.d.ts.map +1 -0
  46. package/dist/conversational-flow/edit/inputs.js +53 -0
  47. package/dist/conversational-flow/edit/inputs.js.map +1 -0
  48. package/dist/conversational-flow/edit/kinds.d.ts +29 -0
  49. package/dist/conversational-flow/edit/kinds.d.ts.map +1 -0
  50. package/dist/conversational-flow/edit/kinds.js +142 -0
  51. package/dist/conversational-flow/edit/kinds.js.map +1 -0
  52. package/dist/conversational-flow/edit/options.d.ts +68 -0
  53. package/dist/conversational-flow/edit/options.d.ts.map +1 -0
  54. package/dist/conversational-flow/edit/options.js +209 -0
  55. package/dist/conversational-flow/edit/options.js.map +1 -0
  56. package/dist/conversational-flow/edit/picklist.d.ts +28 -0
  57. package/dist/conversational-flow/edit/picklist.d.ts.map +1 -0
  58. package/dist/conversational-flow/edit/picklist.js +58 -0
  59. package/dist/conversational-flow/edit/picklist.js.map +1 -0
  60. package/dist/conversational-flow/edit/prompts.d.ts +24 -0
  61. package/dist/conversational-flow/edit/prompts.d.ts.map +1 -0
  62. package/dist/conversational-flow/edit/prompts.js +180 -0
  63. package/dist/conversational-flow/edit/prompts.js.map +1 -0
  64. package/dist/conversational-flow/edit/routers.d.ts +65 -0
  65. package/dist/conversational-flow/edit/routers.d.ts.map +1 -0
  66. package/dist/conversational-flow/edit/routers.js +208 -0
  67. package/dist/conversational-flow/edit/routers.js.map +1 -0
  68. package/dist/conversational-flow/edit/screens.d.ts +44 -0
  69. package/dist/conversational-flow/edit/screens.d.ts.map +1 -0
  70. package/dist/conversational-flow/edit/screens.js +137 -0
  71. package/dist/conversational-flow/edit/screens.js.map +1 -0
  72. package/dist/conversational-flow/edit/versions.d.ts +43 -0
  73. package/dist/conversational-flow/edit/versions.d.ts.map +1 -0
  74. package/dist/conversational-flow/edit/versions.js +189 -0
  75. package/dist/conversational-flow/edit/versions.js.map +1 -0
  76. package/dist/conversational-flow/index.d.ts +33 -16
  77. package/dist/conversational-flow/index.d.ts.map +1 -1
  78. package/dist/conversational-flow/index.js +42 -9
  79. package/dist/conversational-flow/index.js.map +1 -1
  80. package/dist/conversational-flow/json.d.ts +15 -0
  81. package/dist/conversational-flow/json.d.ts.map +1 -0
  82. package/dist/conversational-flow/json.js +14 -0
  83. package/dist/conversational-flow/json.js.map +1 -0
  84. package/dist/conversational-flow/jumps.d.ts +22 -0
  85. package/dist/conversational-flow/jumps.d.ts.map +1 -0
  86. package/dist/conversational-flow/jumps.js +160 -0
  87. package/dist/conversational-flow/jumps.js.map +1 -0
  88. package/dist/conversational-flow/locate.d.ts +30 -0
  89. package/dist/conversational-flow/locate.d.ts.map +1 -0
  90. package/dist/conversational-flow/locate.js +73 -0
  91. package/dist/conversational-flow/locate.js.map +1 -0
  92. package/dist/conversational-flow/paths.d.ts +31 -0
  93. package/dist/conversational-flow/paths.d.ts.map +1 -0
  94. package/dist/conversational-flow/paths.js +50 -0
  95. package/dist/conversational-flow/paths.js.map +1 -0
  96. package/dist/conversational-flow/prompt.d.ts +48 -0
  97. package/dist/conversational-flow/prompt.d.ts.map +1 -0
  98. package/dist/conversational-flow/prompt.js +161 -0
  99. package/dist/conversational-flow/prompt.js.map +1 -0
  100. package/dist/conversational-flow/read.d.ts +9 -17
  101. package/dist/conversational-flow/read.d.ts.map +1 -1
  102. package/dist/conversational-flow/read.js +217 -384
  103. package/dist/conversational-flow/read.js.map +1 -1
  104. package/dist/conversational-flow/rounds.d.ts +29 -0
  105. package/dist/conversational-flow/rounds.d.ts.map +1 -0
  106. package/dist/conversational-flow/rounds.js +41 -0
  107. package/dist/conversational-flow/rounds.js.map +1 -0
  108. package/dist/conversational-flow/routers.d.ts +24 -80
  109. package/dist/conversational-flow/routers.d.ts.map +1 -1
  110. package/dist/conversational-flow/routers.js +76 -262
  111. package/dist/conversational-flow/routers.js.map +1 -1
  112. package/dist/conversational-flow/settle.d.ts +21 -15
  113. package/dist/conversational-flow/settle.d.ts.map +1 -1
  114. package/dist/conversational-flow/settle.js +240 -38
  115. package/dist/conversational-flow/settle.js.map +1 -1
  116. package/dist/conversational-flow/shape.d.ts +114 -0
  117. package/dist/conversational-flow/shape.d.ts.map +1 -0
  118. package/dist/conversational-flow/shape.js +209 -0
  119. package/dist/conversational-flow/shape.js.map +1 -0
  120. package/dist/conversational-flow/testing.d.ts +54 -0
  121. package/dist/conversational-flow/testing.d.ts.map +1 -0
  122. package/dist/conversational-flow/testing.js +119 -0
  123. package/dist/conversational-flow/testing.js.map +1 -0
  124. package/dist/conversational-flow/tree.d.ts +28 -17
  125. package/dist/conversational-flow/tree.d.ts.map +1 -1
  126. package/dist/conversational-flow/tree.js +60 -47
  127. package/dist/conversational-flow/tree.js.map +1 -1
  128. package/dist/conversational-flow/turn.d.ts +20 -22
  129. package/dist/conversational-flow/turn.d.ts.map +1 -1
  130. package/dist/conversational-flow/turn.js +69 -48
  131. package/dist/conversational-flow/turn.js.map +1 -1
  132. package/dist/conversational-flow/types.d.ts +154 -118
  133. package/dist/conversational-flow/types.d.ts.map +1 -1
  134. package/dist/conversational-flow/types.js +27 -51
  135. package/dist/conversational-flow/types.js.map +1 -1
  136. package/dist/conversational-flow/typing.d.ts +31 -0
  137. package/dist/conversational-flow/typing.d.ts.map +1 -0
  138. package/dist/conversational-flow/typing.js +53 -0
  139. package/dist/conversational-flow/typing.js.map +1 -0
  140. package/dist/engine/config-validator.js +2 -2
  141. package/dist/engine/config-validator.js.map +1 -1
  142. package/dist/engine/variable-resolver.d.ts +16 -0
  143. package/dist/engine/variable-resolver.d.ts.map +1 -1
  144. package/dist/engine/variable-resolver.js +46 -2
  145. package/dist/engine/variable-resolver.js.map +1 -1
  146. package/dist/engine/workflow-executor.d.ts.map +1 -1
  147. package/dist/engine/workflow-executor.js +10 -0
  148. package/dist/engine/workflow-executor.js.map +1 -1
  149. package/dist/runtime/workflow-runtime.d.ts.map +1 -1
  150. package/dist/runtime/workflow-runtime.js +3 -0
  151. package/dist/runtime/workflow-runtime.js.map +1 -1
  152. package/dist/steps/base-step.d.ts.map +1 -1
  153. package/dist/steps/base-step.js +1 -0
  154. package/dist/steps/base-step.js.map +1 -1
  155. package/dist/testing/mock-context.d.ts.map +1 -1
  156. package/dist/testing/mock-context.js +1 -0
  157. package/dist/testing/mock-context.js.map +1 -1
  158. package/dist/types/context.d.ts +15 -0
  159. package/dist/types/context.d.ts.map +1 -1
  160. package/dist/types/pause-state.d.ts +9 -0
  161. package/dist/types/pause-state.d.ts.map +1 -1
  162. package/dist/util/variable-ref.d.ts +1 -1
  163. package/dist/util/variable-ref.d.ts.map +1 -1
  164. package/dist/util/variable-ref.js +1 -1
  165. package/dist/util/variable-ref.js.map +1 -1
  166. package/package.json +1 -1
  167. package/dist/conversational-flow/edit.d.ts +0 -101
  168. package/dist/conversational-flow/edit.d.ts.map +0 -1
  169. package/dist/conversational-flow/edit.js +0 -785
  170. package/dist/conversational-flow/edit.js.map +0 -1
  171. package/dist/conversational-flow/internals.d.ts +0 -51
  172. package/dist/conversational-flow/internals.d.ts.map +0 -1
  173. package/dist/conversational-flow/internals.js +0 -163
  174. package/dist/conversational-flow/internals.js.map +0 -1
  175. package/dist/conversational-flow/lookup-edit.d.ts +0 -96
  176. package/dist/conversational-flow/lookup-edit.d.ts.map +0 -1
  177. package/dist/conversational-flow/lookup-edit.js +0 -266
  178. package/dist/conversational-flow/lookup-edit.js.map +0 -1
  179. package/dist/conversational-flow/lookups.d.ts +0 -46
  180. package/dist/conversational-flow/lookups.d.ts.map +0 -1
  181. package/dist/conversational-flow/lookups.js +0 -145
  182. package/dist/conversational-flow/lookups.js.map +0 -1
  183. package/dist/conversational-flow/router-edit.d.ts +0 -53
  184. package/dist/conversational-flow/router-edit.d.ts.map +0 -1
  185. package/dist/conversational-flow/router-edit.js +0 -191
  186. package/dist/conversational-flow/router-edit.js.map +0 -1
@@ -0,0 +1,73 @@
1
+ import { asSteps } from './json.js';
2
+ import { caseKind, casesOf, isCycle, partsOf, switchIn } from './shape.js';
3
+ /** The cycle the conversation itself is. */
4
+ export function rootCycle(config) {
5
+ return asSteps(config.steps).find(isCycle);
6
+ }
7
+ /** The cycle named by the last of `frames`, walking down from the conversation. */
8
+ export function cycleAt(config, frames, routeKey) {
9
+ let cycle = rootCycle(config);
10
+ if (!cycle || cycle.id !== frames[0])
11
+ return undefined;
12
+ for (const frame of frames.slice(1)) {
13
+ const routing = switchIn(cycle);
14
+ if (!routing)
15
+ return undefined;
16
+ const next = casesOf(routing)
17
+ .filter((entry) => caseKind(entry, routeKey)?.kind === 'section')
18
+ .map((entry) => partsOf(entry, routeKey).rest.find(isCycle))
19
+ .find((inner) => inner?.id === frame);
20
+ if (!next)
21
+ return undefined;
22
+ cycle = next;
23
+ }
24
+ return cycle;
25
+ }
26
+ /** The case that holds one screen: its steps are what that screen is. */
27
+ export function caseFor(config, flow, screen) {
28
+ const cycle = cycleAt(config, screen.frames, flow.routeKey);
29
+ if (!cycle)
30
+ return undefined;
31
+ const routing = switchIn(cycle);
32
+ if (!routing)
33
+ return undefined;
34
+ return casesOf(routing).find((entry) => {
35
+ const kind = caseKind(entry, flow.routeKey);
36
+ return kind?.kind === 'screen' && kind.screen === screen.id;
37
+ });
38
+ }
39
+ /**
40
+ * The case that holds a section: its condition is the section's subtree, and
41
+ * its steps are the section's calls and its cycle. It sits in the switch of the
42
+ * frame above, which is where a section is reached from.
43
+ */
44
+ export function sectionCaseFor(config, flow, screen) {
45
+ const above = screen.frames.slice(0, -1);
46
+ if (above.length === 0)
47
+ return undefined;
48
+ const cycle = cycleAt(config, above, flow.routeKey);
49
+ const routing = cycle ? switchIn(cycle) : undefined;
50
+ if (!routing)
51
+ return undefined;
52
+ return casesOf(routing).find((entry) => {
53
+ const kind = caseKind(entry, flow.routeKey);
54
+ return kind?.kind === 'section' && partsOf(entry, flow.routeKey).rest.find(isCycle)?.id === screen.id;
55
+ });
56
+ }
57
+ /**
58
+ * The innermost frame that holds both ends — where a jump between them
59
+ * belongs, so that leaving one does not unwind more than it has to.
60
+ *
61
+ * Takes frame paths rather than screens, because a call on a section sits
62
+ * outside that section's own cycle and so is enclosed by one frame fewer.
63
+ */
64
+ export function commonFrame(from, to) {
65
+ let shared = from[0] ?? '';
66
+ for (let at = 0; at < Math.min(from.length, to.length); at += 1) {
67
+ if (from[at] !== to[at])
68
+ break;
69
+ shared = from[at];
70
+ }
71
+ return shared;
72
+ }
73
+ //# sourceMappingURL=locate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate.js","sourceRoot":"","sources":["../../src/conversational-flow/locate.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAuB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3E,4CAA4C;AAC5C,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,OAAO,CAAC,MAAsB,EAAE,MAAyB,EAAE,QAAgB;IACzF,IAAI,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC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C,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAChE,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;YAAE,MAAM;QAC/B,MAAM,GAAG,IAAI,CAAC,EAAE,CAAE,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Which screen a step of a run belongs to.
3
+ *
4
+ * The engine addresses every step by the frames it ran inside — the cycles it
5
+ * is in and the case each switch opened:
6
+ *
7
+ * root:body#3/root_route:case_1#0/payments:body#0/payments_route:case_0#0/ask_payments
8
+ * └ round 3 of the conversation │ the Payments case │ round 0 of Payments │ its own case │ the question
9
+ *
10
+ * So reading a run is walking the same tree the config is, one frame at a time.
11
+ * Nothing is matched by id or by name: the path says which case, and the case
12
+ * says which screen.
13
+ */
14
+ import type { WorkflowConfig } from '../types/workflow-config.js';
15
+ import type { ConversationalFlow, Screen } from './types.js';
16
+ /**
17
+ * The screen a step ran for, or undefined when it ran somewhere that is not a
18
+ * screen — a switch's fallback, or a step outside the conversation entirely.
19
+ *
20
+ * A step in a section's case but outside its cycle — what that section fetches
21
+ * on the way in — belongs to the section itself, which is why the walk keeps
22
+ * the last screen it saw rather than insisting on the deepest.
23
+ */
24
+ export declare function screenAtPath(config: WorkflowConfig, flow: ConversationalFlow, nodePath: string): Screen | undefined;
25
+ /**
26
+ * The rounds a step ran in, outermost first — round 2 of the conversation, then
27
+ * round 0 of the section inside it, and so on. Comparing these in order is what
28
+ * puts a run back in the order it happened.
29
+ */
30
+ export declare function roundsIn(nodePath: string): number[];
31
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAoB7D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiBnH;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD"}
@@ -0,0 +1,50 @@
1
+ import { rootCycle } from './locate.js';
2
+ import { caseKind, casesOf, isCycle, partsOf, switchIn } from './shape.js';
3
+ /** `<switch>:case_<n>#<round>` — a switch, and the case it opened. */
4
+ const CASE_FRAME = /^(.+):case_(\d+)#\d+$/;
5
+ /** The cases a node path opened, outermost first. */
6
+ function framesIn(nodePath) {
7
+ const out = [];
8
+ for (const segment of nodePath.split('/')) {
9
+ const match = CASE_FRAME.exec(segment);
10
+ if (match)
11
+ out.push({ switchId: match[1], caseIndex: Number(match[2]) });
12
+ }
13
+ return out;
14
+ }
15
+ /**
16
+ * The screen a step ran for, or undefined when it ran somewhere that is not a
17
+ * screen — a switch's fallback, or a step outside the conversation entirely.
18
+ *
19
+ * A step in a section's case but outside its cycle — what that section fetches
20
+ * on the way in — belongs to the section itself, which is why the walk keeps
21
+ * the last screen it saw rather than insisting on the deepest.
22
+ */
23
+ export function screenAtPath(config, flow, nodePath) {
24
+ const byId = new Map(flow.screens.map((s) => [s.id, s]));
25
+ let cycle = rootCycle(config);
26
+ let screen;
27
+ for (const frame of framesIn(nodePath)) {
28
+ const routing = cycle ? switchIn(cycle) : undefined;
29
+ if (!routing || routing.id !== frame.switchId)
30
+ return screen;
31
+ const entry = casesOf(routing)[frame.caseIndex];
32
+ const kind = entry ? caseKind(entry, flow.routeKey) : null;
33
+ if (!entry || !kind)
34
+ return screen;
35
+ if (kind.kind === 'screen')
36
+ return byId.get(kind.screen);
37
+ cycle = partsOf(entry, flow.routeKey).rest.find(isCycle);
38
+ screen = byId.get(cycle?.id ?? '') ?? screen;
39
+ }
40
+ return screen;
41
+ }
42
+ /**
43
+ * The rounds a step ran in, outermost first — round 2 of the conversation, then
44
+ * round 0 of the section inside it, and so on. Comparing these in order is what
45
+ * puts a run back in the order it happened.
46
+ */
47
+ export function roundsIn(nodePath) {
48
+ return [...nodePath.matchAll(/#(\d+)/g)].map((match) => Number(match[1]));
49
+ }
50
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/conversational-flow/paths.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3E,sEAAsE;AACtE,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAO3C,qDAAqD;AACrD,SAAS,QAAQ,CAAC,QAAgB;IAChC,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,KAAK;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB,EAAE,IAAwB,EAAE,QAAgB;IAC7F,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,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SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Reading what a screen asks.
3
+ *
4
+ * A question is a WAIT with a select field (the options) and, when typing is
5
+ * allowed, a text field. What follows it says where each answer goes:
6
+ *
7
+ * WAIT ask_x
8
+ * CONDITIONAL they typed something → GO_TO the router carrying the text
9
+ * otherwise → GO_TO carrying their pick, or a SWITCH
10
+ * that opens a follow-up question
11
+ *
12
+ * Everything here is recognised by the WAIT's own output contract — never by an
13
+ * id or a naming convention.
14
+ */
15
+ import { type Step } from './json.js';
16
+ import type { Destination, Prompt } from './types.js';
17
+ export interface PromptContext {
18
+ routeKey: string;
19
+ /** Step id → its type, for saying what decides a dynamic destination. */
20
+ typeOf: Map<string, string>;
21
+ }
22
+ /** A pick forwarded as the next screen, before it is expanded per option. */
23
+ type Resolved = Destination | {
24
+ kind: 'choice';
25
+ wait: string;
26
+ field: string;
27
+ };
28
+ /**
29
+ * Read a WAIT-led run of steps into `out`, following any follow-up questions.
30
+ * Returns the id of the question read, so a parent option can point at it.
31
+ */
32
+ export declare function readPrompt(steps: Step[], ctx: PromptContext, out: Prompt[]): string;
33
+ /**
34
+ * One destination written as several jumps: the same answer carried on, tested
35
+ * by which frame it lands in. They all say the same thing, so reading one is
36
+ * reading the destination.
37
+ */
38
+ export declare function splitDestination(steps: Step[], ctx: PromptContext): Resolved | undefined;
39
+ /**
40
+ * A GO_TO carries the screen it opens; a FINISH carries what the conversation
41
+ * reports. Which cycle catches the jump is not the view's business — that is
42
+ * settled from where the two screens sit.
43
+ */
44
+ export declare function jumpDestination(step: Step, ctx: PromptContext): Resolved;
45
+ /** A pick forwarded outside an option list has no single screen to name. */
46
+ export declare function finalise(resolved: Resolved): Destination;
47
+ export {};
48
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAgC,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AAMpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED,6EAA6E;AAC7E,KAAK,QAAQ,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CA+CnF;AA0DD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,aAAa,GAAG,QAAQ,GAAG,SAAS,CAMxF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,GAAG,QAAQ,CAexE;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAExD"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Reading what a screen asks.
3
+ *
4
+ * A question is a WAIT with a select field (the options) and, when typing is
5
+ * allowed, a text field. What follows it says where each answer goes:
6
+ *
7
+ * WAIT ask_x
8
+ * CONDITIONAL they typed something → GO_TO the router carrying the text
9
+ * otherwise → GO_TO carrying their pick, or a SWITCH
10
+ * that opens a follow-up question
11
+ *
12
+ * Everything here is recognised by the WAIT's own output contract — never by an
13
+ * id or a naming convention.
14
+ */
15
+ import { asArray, asRec, asSteps, str } from './json.js';
16
+ import { jumpsIn } from './shape.js';
17
+ /** `{{steps.<wait>.output.resumeData.data.<field>}}` — a WAIT's own answer. */
18
+ const WAIT_FIELD = /^\{\{\s*steps\.([^.\s}]+)\.output\.resumeData\.data\.([A-Za-z0-9_]+)\s*\}\}$/;
19
+ const STEP_OUTPUT = /^\{\{\s*steps\.([^.\s}]+)\.output\b/;
20
+ /**
21
+ * Read a WAIT-led run of steps into `out`, following any follow-up questions.
22
+ * Returns the id of the question read, so a parent option can point at it.
23
+ */
24
+ export function readPrompt(steps, ctx, out) {
25
+ const wait = steps[0];
26
+ const config = asRec(wait.config);
27
+ const fields = asArray(asRec(config['form'])['fields']).map(asRec);
28
+ const select = fields.find((f) => f['type'] === 'select');
29
+ const text = fields.find((f) => f['type'] === 'text' || f['type'] === 'textarea');
30
+ const prompt = {
31
+ id: wait.id,
32
+ text: str(config['prompt']) ?? '',
33
+ header: str(config['reason']),
34
+ choiceField: str(select?.['name']),
35
+ textField: str(text?.['name']),
36
+ options: [],
37
+ freeText: undefined,
38
+ pickSwitchId: undefined,
39
+ ...(typeof select?.['options'] === 'string' ? { optionsFrom: String(select['options']) } : {}),
40
+ };
41
+ out.push(prompt);
42
+ // Typed text is split off by a CONDITIONAL testing this WAIT's own text field;
43
+ // its other branch is what happens when an option was picked.
44
+ let picked = steps.slice(1);
45
+ const [gate] = picked;
46
+ if (gate?.type === 'CONDITIONAL' && prompt.textField && tests(asRec(gate.config)['condition'], wait.id, prompt.textField)) {
47
+ const config = asRec(gate.config);
48
+ prompt.freeText = finalise(destinationOf(asSteps(config['if_true']), ctx, out));
49
+ picked = asSteps(config['if_false']);
50
+ }
51
+ const { byValue, switchId } = pickedDestinations(picked, wait.id, prompt.choiceField, ctx, out);
52
+ prompt.pickSwitchId = switchId;
53
+ prompt.options = asArray(select?.['options']).map(asRec).map((option) => {
54
+ const value = String(option['value'] ?? '');
55
+ const to = byValue(value);
56
+ const when = option['when'];
57
+ return {
58
+ label: str(option['label']) ?? value,
59
+ value,
60
+ // A pick forwarded whole opens the screen the option names.
61
+ to: to.kind === 'choice' ? { kind: 'screen', screen: value } : to,
62
+ back: false,
63
+ // Kept as written: the engine reads it, and the editor edits it in place.
64
+ ...(when !== undefined && when !== null ? { when: when } : {}),
65
+ };
66
+ });
67
+ return wait.id;
68
+ }
69
+ /**
70
+ * Where each answer leads. A pick may be forwarded whole — every option opens
71
+ * the screen it names — or branched by a SWITCH on this question's own answer,
72
+ * one case per option, with the rest falling to its default.
73
+ */
74
+ function pickedDestinations(picked, waitId, choiceField, ctx, out) {
75
+ const [only] = picked;
76
+ if (only?.type === 'SWITCH' && picked.length === 1) {
77
+ const config = asRec(only.config);
78
+ const cases = asArray(config['cases']).map(asRec);
79
+ const onThisAnswer = cases.every((entry) => {
80
+ const condition = asRec(entry['condition']);
81
+ return condition['operator'] === 'eq' && refersTo(condition['variable'], waitId, choiceField);
82
+ });
83
+ if (onThisAnswer) {
84
+ const branches = new Map();
85
+ for (const entry of cases) {
86
+ branches.set(String(asRec(entry['condition'])['value']), destinationOf(asSteps(entry['steps']), ctx, out));
87
+ }
88
+ const fallback = destinationOf(asSteps(config['default']), ctx, out);
89
+ return { byValue: (value) => branches.get(value) ?? fallback, switchId: only.id };
90
+ }
91
+ }
92
+ const whole = destinationOf(picked, ctx, out);
93
+ return { byValue: () => whole, switchId: undefined };
94
+ }
95
+ /** Does this reference read `field` off `waitId`'s answer? */
96
+ function refersTo(variable, waitId, field) {
97
+ if (typeof variable !== 'string' || !field)
98
+ return false;
99
+ const match = WAIT_FIELD.exec(variable);
100
+ return match?.[1] === waitId && match[2] === field;
101
+ }
102
+ /** A condition that tests whether this question's text field was filled in. */
103
+ function tests(condition, waitId, field) {
104
+ const rec = asRec(condition);
105
+ const parts = [rec, ...asArray(rec['all']).map(asRec), ...asArray(rec['any']).map(asRec)];
106
+ return parts.some((part) => refersTo(part['variable'], waitId, field));
107
+ }
108
+ /** What a run of steps leads to: another question, a jump, or an end. */
109
+ function destinationOf(steps, ctx, out) {
110
+ const [first] = steps;
111
+ if (!first)
112
+ return { kind: 'none' };
113
+ if (first.type === 'WAIT')
114
+ return { kind: 'prompt', prompt: readPrompt(steps, ctx, out) };
115
+ if (steps.length === 1 && (first.type === 'GO_TO' || first.type === 'FINISH'))
116
+ return jumpDestination(first, ctx);
117
+ return splitDestination(steps, ctx) ?? { kind: 'none' };
118
+ }
119
+ /**
120
+ * One destination written as several jumps: the same answer carried on, tested
121
+ * by which frame it lands in. They all say the same thing, so reading one is
122
+ * reading the destination.
123
+ */
124
+ export function splitDestination(steps, ctx) {
125
+ const jumps = jumpsIn(steps);
126
+ if (jumps.length === 0)
127
+ return undefined;
128
+ const carried = new Set(jumps.map((jump) => String(asRec(asRec(jump.config)['with'])[ctx.routeKey])));
129
+ if (carried.size !== 1)
130
+ return undefined;
131
+ return jumpDestination(jumps[0], ctx);
132
+ }
133
+ /**
134
+ * A GO_TO carries the screen it opens; a FINISH carries what the conversation
135
+ * reports. Which cycle catches the jump is not the view's business — that is
136
+ * settled from where the two screens sit.
137
+ */
138
+ export function jumpDestination(step, ctx) {
139
+ const carried = asRec(asRec(step.config)['with']);
140
+ if (step.type === 'FINISH')
141
+ return { kind: 'end', value: carried };
142
+ if (step.type !== 'GO_TO')
143
+ return { kind: 'none' };
144
+ const next = carried[ctx.routeKey];
145
+ if (typeof next !== 'string' || next === '')
146
+ return { kind: 'none' };
147
+ if (!next.includes('{{'))
148
+ return { kind: 'screen', screen: next };
149
+ const pick = WAIT_FIELD.exec(next);
150
+ if (pick && ctx.typeOf.get(pick[1]) === 'WAIT')
151
+ return { kind: 'choice', wait: pick[1], field: pick[2] };
152
+ const source = STEP_OUTPUT.exec(next);
153
+ if (source)
154
+ return { kind: 'dynamic', from: source[1], fromType: ctx.typeOf.get(source[1]) };
155
+ return { kind: 'none' };
156
+ }
157
+ /** A pick forwarded outside an option list has no single screen to name. */
158
+ export function finalise(resolved) {
159
+ return resolved.kind === 'choice' ? { kind: 'none' } : resolved;
160
+ }
161
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/conversational-flow/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAa,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,+EAA+E;AAC/E,MAAM,UAAU,GAAG,8EAA8E,CAAC;AAClG,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAW1D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,GAAkB,EAAE,GAAa;IACzE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IACvB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;IAElF,MAAM,MAAM,GAAW;QACrB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE;QACjC,MAAM,E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AM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAElE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,KAAK,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAE,EAAE,CAAC;IAE5G,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC;IAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,QAAkB;IACzC,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC"}
@@ -1,24 +1,16 @@
1
1
  /**
2
- * config → conversational-flow view. Pure; no DOM, no network.
2
+ * config → the conversational-flow view.
3
3
  *
4
- * Everything is recognised by node type and by the step output contracts the
5
- * SDK defines — never by id or naming convention:
4
+ * The walk is the tree: each CYCLE is a section, each case inside it is a screen
5
+ * or a section of its own, and a screen's place is where its case sits. Nothing
6
+ * is inferred from where options point, so nothing the reader says can disagree
7
+ * with what the engine will do.
6
8
  *
7
- * - the router is a SWITCH whose cases all test `{{steps.__loop.output.input.<key>}}`
8
- * for equality, directly inside a CYCLE — `<key>` is whatever the author chose;
9
- * - an option's choice is `{{steps.<wait>.output.resumeData.data.<field>}}`, the
10
- * WAIT step's own output shape;
11
- * - a destination is a GO_TO / FINISH aimed at that CYCLE.
12
- *
13
- * Returns `null` when the config does not have that shape, which is how the
14
- * caller knows to fall back to the general builder.
9
+ * Returns `null` when the config is not this shape, which is how a caller knows
10
+ * to fall back to the general builder.
15
11
  */
16
12
  import type { WorkflowConfig } from '../types/workflow-config.js';
17
- import type { ConversationalFlow, ScreenKind } from './types.js';
13
+ import { type ConversationalFlow, type Prompt } from './types.js';
18
14
  export declare function readConversationalFlow(config: WorkflowConfig): ConversationalFlow | null;
19
- /** The display section that marks a WAIT as a hand off. */
20
- export declare const HANDOFF_SECTION = "handoff";
21
- /** An Ask AI task is the author's instructions, then the question the person typed. */
22
- export declare const QUESTION_SEPARATOR = "\n\nTheir question: ";
23
- export type { ScreenKind };
15
+ export type { Prompt };
24
16
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAGV,kBAAkB,EAKlB,UAAU,EACX,MAAM,YAAY,CAAC;AA0BpB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,IAAI,CAmCxF;AA+SD,2DAA2D;AAC3D,eAAO,MAAM,eAAe,YAAY,CAAC;AAkBzC,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAiJzD,YAAY,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAKlE,OAAO,EASL,KAAK,kBAAkB,EAEvB,KAAK,MAAM,EAIZ,MAAM,YAAY,CAAC;AAgBpB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,IAAI,CAkBxF;AAiRD,YAAY,EAAE,MAAM,EAAE,CAAC"}