@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,24 @@
1
+ import type { Condition, LeafCondition } from '../types/workflow-config.js';
2
+ /** A group's join, or `undefined` when it is a single test. */
3
+ export declare function joinOf(condition: Condition): 'all' | 'any' | undefined;
4
+ /** The conditions directly inside a group; a leaf is its own only part. */
5
+ export declare function partsIn(condition: Condition): Condition[];
6
+ /** Every test a condition makes, however it is grouped. */
7
+ export declare function leavesOf(condition: Condition): LeafCondition[];
8
+ /** Whether every part is a test — what the editor can lay out as rows. */
9
+ export declare function isFlat(condition: Condition): boolean;
10
+ /** A group of tests, or the test itself when there is one. */
11
+ export declare function group(join: 'all' | 'any', parts: readonly Condition[]): Condition;
12
+ /** Whether this operator reads a value at all — `is there` compares with nothing. */
13
+ export declare function takesValue(operator: string): boolean;
14
+ /**
15
+ * A short name for a condition, for a place that needs one word about it — a
16
+ * switch case's label in the config, a chip in a list.
17
+ *
18
+ * The field name, not the whole reference: `{{steps.account.output.body.plan}}`
19
+ * is `plan`, which is what the author called it and what they will recognise.
20
+ */
21
+ export declare function labelFor(condition: Condition): string;
22
+ /** The last segment of a reference — what the author named the field. */
23
+ export declare function fieldName(variable: string): string;
24
+ //# sourceMappingURL=conditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/conditions.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5E,+DAA+D;AAC/D,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAItE;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,CAGzD;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,EAAE,CAI9D;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAEpD;AAMD,8DAA8D;AAC9D,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAEjF;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAOrD;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Reading a condition — the same shape wherever one appears.
3
+ *
4
+ * A condition is a leaf (`read this, compare it that way, against that`) or a
5
+ * group of conditions joined by `all` or `any`. Two places in a conversation
6
+ * carry one: a screen asked differently depending on the data, and an option
7
+ * offered only under it. Both mean the same thing and are edited by the same
8
+ * editor, so what a condition *is* is answered once, here.
9
+ *
10
+ * Nesting deeper than one group is legal in the engine and read faithfully by
11
+ * everything below — it just isn't something this layer writes.
12
+ */
13
+ import { VALUE_LESS_OPERATORS } from '../types/operators.js';
14
+ /** A group's join, or `undefined` when it is a single test. */
15
+ export function joinOf(condition) {
16
+ if ('all' in condition)
17
+ return 'all';
18
+ if ('any' in condition)
19
+ return 'any';
20
+ return undefined;
21
+ }
22
+ /** The conditions directly inside a group; a leaf is its own only part. */
23
+ export function partsIn(condition) {
24
+ const join = joinOf(condition);
25
+ return join ? condition[join] : [condition];
26
+ }
27
+ /** Every test a condition makes, however it is grouped. */
28
+ export function leavesOf(condition) {
29
+ const join = joinOf(condition);
30
+ if (!join)
31
+ return isLeaf(condition) ? [condition] : [];
32
+ return condition[join].flatMap(leavesOf);
33
+ }
34
+ /** Whether every part is a test — what the editor can lay out as rows. */
35
+ export function isFlat(condition) {
36
+ return partsIn(condition).every(isLeaf);
37
+ }
38
+ function isLeaf(condition) {
39
+ return 'variable' in condition && 'operator' in condition;
40
+ }
41
+ /** A group of tests, or the test itself when there is one. */
42
+ export function group(join, parts) {
43
+ return parts.length === 1 ? parts[0] : { [join]: [...parts] };
44
+ }
45
+ /** Whether this operator reads a value at all — `is there` compares with nothing. */
46
+ export function takesValue(operator) {
47
+ return !VALUE_LESS_OPERATORS.has(operator);
48
+ }
49
+ /**
50
+ * A short name for a condition, for a place that needs one word about it — a
51
+ * switch case's label in the config, a chip in a list.
52
+ *
53
+ * The field name, not the whole reference: `{{steps.account.output.body.plan}}`
54
+ * is `plan`, which is what the author called it and what they will recognise.
55
+ */
56
+ export function labelFor(condition) {
57
+ const leaves = leavesOf(condition);
58
+ const first = leaves[0];
59
+ if (!first)
60
+ return 'when';
61
+ const name = fieldName(first.variable);
62
+ const said = first.value === undefined ? `${name} ${first.operator}` : `${name} ${first.operator} ${String(first.value)}`;
63
+ return leaves.length === 1 ? said : `${said} +${String(leaves.length - 1)}`;
64
+ }
65
+ /** The last segment of a reference — what the author named the field. */
66
+ export function fieldName(variable) {
67
+ return /\.([^.\s}]+)\s*\}\}$/.exec(variable)?.[1] ?? /\{\{\s*([^.}\s]+)\s*\}\}/.exec(variable)?.[1] ?? 'data';
68
+ }
69
+ //# sourceMappingURL=conditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/conversational-flow/conditions.ts"],"names":[],"mappings":"AAAA;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AAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,EAAgB,CAAC;AAChF,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAA6B,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAoB;IAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;IAC1H,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AAChH,CAAC"}
@@ -1,27 +1,25 @@
1
1
  /**
2
- * A new conversational flow: the smallest conversation that runs.
2
+ * A new conversation: the smallest one that runs, and grows.
3
3
  *
4
- * CYCLE conversation input { screen: 'start', text: '' }
5
- * └ SWITCH route on screen
4
+ * CYCLE start input { screen: 'start', text: '' }
5
+ * └ SWITCH start_route
6
6
  * ├ start — the first screen: a greeting, no options yet
7
- * ├ ai_router — typed text → a classifier (or an agent) picks the screen
7
+ * ├ ai_router — typed text → a classifier (or an agent) names the screen
8
8
  * ├ done — Finish
9
9
  * └ default → start
10
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.
11
+ * The conversation's own cycle is named after its first screen, because a
12
+ * section and its screen are one thing; every section added later is a cycle
13
+ * inside this one. This is the one place that names the round's keys (`screen`,
14
+ * `text`) and the fields (`choice`, `message`) — every later edit copies
15
+ * whatever shape the flow already has.
16
+ *
17
+ * Everything derived — what the router may open and how it is asked, the
18
+ * headings, where each jump is aimed — is left to `settle`.
14
19
  */
15
20
  import type { WorkflowConfig } from '../types/workflow-config.js';
16
21
  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
- /** How typed messages are routed. A classifier model, or an agent asked for JSON. */
22
+ /** How typed messages are routed: a classifier model, or an agent asked for JSON. */
25
23
  export type NewRouter = {
26
24
  kind: 'classifier';
27
25
  model?: string;
@@ -32,13 +30,20 @@ export type NewRouter = {
32
30
  kind: 'agent';
33
31
  agentSlug?: string;
34
32
  };
33
+ export interface NewConversationalFlow {
34
+ config: WorkflowConfig;
35
+ /** Stored on the workflow so it opens in the conversational-flow editor. */
36
+ metadata: {
37
+ kind: typeof CONVERSATIONAL_FLOW_KIND;
38
+ };
39
+ }
35
40
  export declare function createConversationalFlow(options?: {
36
- /** How typed text is routed. A classifier model unless an agent is asked for. */
41
+ /** How typed text is routed. A classifier unless an agent is asked for. */
37
42
  router?: NewRouter;
38
- /** The agent that routes typed messages; can be set later. Same as `router: { kind: 'agent', agentSlug }`. */
43
+ /** Shorthand for `router: { kind: 'agent', agentSlug }`. */
39
44
  agentSlug?: string;
40
45
  greeting?: string;
41
- /** Title of the first screen, and the conversation header on it. */
46
+ /** The first screen's name, and the heading on it. */
42
47
  title?: string;
43
48
  }): NewConversationalFlow;
44
49
  //# sourceMappingURL=create.d.ts.map
@@ -1 +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,qFAAqF;AACrF,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAChD,iFAAiF;IACjF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,8GAA8G;IAC9G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,GAAG,qBAAqB,CAkH7B"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMlE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D,qFAAqF;AACrF,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,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,CACtC,OAAO,GAAE;IACP,2EAA2E;IAC3E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,GACL,qBAAqB,CA0DvB"}
@@ -1,114 +1,91 @@
1
- import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE } from './types.js';
2
1
  import { refreshDerived } from './settle.js';
2
+ import { carrying, cycleStep, DEFAULT_ROUTE_KEY, finishStep, jumpStep, screenCase, switchStep } from './shape.js';
3
+ import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE } from './types.js';
3
4
  export const CONVERSATIONAL_FLOW_KIND = 'conversational_flow';
4
5
  export function createConversationalFlow(options = {}) {
5
6
  const title = options.title?.trim() || 'Start';
6
7
  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 router = options.router ?? (options.agentSlug ? { kind: 'agent', agentSlug: options.agentSlug } : { kind: 'classifier' });
17
- // Its instructions, classes and allowed screens are written by `refreshDerived` below.
18
- const deciding = router.kind === 'classifier'
19
- ? [
20
- {
21
- id: 'classify',
22
- type: CLASSIFIER_STEP_TYPE,
23
- config: {
24
- input: '',
25
- instructions: '',
26
- classes: {},
27
- ...(router.model ? { model: router.model } : {}),
28
- ...(router.credentialName ? { credentialName: router.credentialName } : {}),
29
- ...(router.minConfidence !== undefined ? { minConfidence: router.minConfidence } : {}),
30
- },
31
- },
32
- go('go_classified', '{{steps.classify.output.class}}'),
33
- ]
34
- : [
35
- {
36
- id: 'classify',
37
- type: AGENT_STEP_TYPE,
38
- config: { agentSlug: router.agentSlug?.trim() ?? '', task: '', outputType: 'json' },
39
- },
40
- go('go_classified', '{{steps.classify.output.response.screen}}'),
41
- ];
8
+ const first = 'start';
9
+ const keys = [DEFAULT_ROUTE_KEY, TEXT_KEY];
10
+ const home = (screen) => carrying(keys, DEFAULT_ROUTE_KEY, screen);
11
+ const typed = `{{steps.ask_${first}.output.resumeData.data.message}}`;
42
12
  const config = {
43
13
  trigger: { type: 'MANUAL', config: {} },
44
14
  steps: [
45
- {
46
- id: cycle,
47
- type: 'CYCLE',
48
- config: {
49
- input: { screen: 'start', text: '' },
50
- maxIterations: 200,
51
- body: [
15
+ cycleStep(first, { [DEFAULT_ROUTE_KEY]: first, [TEXT_KEY]: '' }, [
16
+ switchStep(`${first}_route`, [
17
+ screenCase(first, title, [
18
+ {
19
+ id: `ask_${first}`,
20
+ type: 'WAIT',
21
+ config: {
22
+ mode: 'approval',
23
+ reason: title,
24
+ prompt: greeting,
25
+ form: {
26
+ fields: [
27
+ { type: 'select', name: 'choice', label: 'Choose one', options: [] },
28
+ { type: 'text', name: 'message', label: 'Or type your question' },
29
+ ],
30
+ },
31
+ },
32
+ },
52
33
  {
53
- id: 'route',
54
- type: 'SWITCH',
34
+ id: `typed_${first}`,
35
+ type: 'CONDITIONAL',
55
36
  config: {
56
- cases: [
57
- {
58
- label: title,
59
- condition: { variable: screenRef, operator: 'eq', value: 'start' },
60
- steps: [
61
- {
62
- id: 'ask_start',
63
- type: 'WAIT',
64
- config: {
65
- mode: 'approval',
66
- reason: title,
67
- prompt: greeting,
68
- form: {
69
- fields: [
70
- { type: 'select', name: 'choice', label: 'Choose one', options: [] },
71
- { type: 'text', name: 'message', label: 'Or type your question' },
72
- ],
73
- },
74
- },
75
- },
76
- {
77
- id: 'typed_start',
78
- type: 'CONDITIONAL',
79
- config: {
80
- condition: {
81
- all: [
82
- { variable: message('ask_start'), operator: 'exists' },
83
- { variable: message('ask_start'), operator: 'neq', value: '' },
84
- ],
85
- },
86
- if_true: [go('route_start', 'ai_router', message('ask_start'))],
87
- if_false: [go('go_start', choice('ask_start'))],
88
- },
89
- },
90
- ],
91
- },
92
- {
93
- label: 'AI router',
94
- condition: { variable: screenRef, operator: 'eq', value: 'ai_router' },
95
- steps: deciding,
96
- },
97
- {
98
- label: 'Finish',
99
- condition: { variable: screenRef, operator: 'eq', value: 'done' },
100
- steps: [{ id: 'finish', type: 'FINISH', config: { target: cycle, with: { outcome: 'done' } } }],
101
- },
37
+ condition: {
38
+ all: [
39
+ { variable: typed, operator: 'exists' },
40
+ { variable: typed, operator: 'neq', value: '' },
41
+ ],
42
+ },
43
+ if_true: [jumpStep(`route_${first}`, first, { ...home(ROUTER_ID), [TEXT_KEY]: typed })],
44
+ if_false: [
45
+ jumpStep(`go_${first}`, first, home(`{{steps.ask_${first}.output.resumeData.data.choice}}`)),
102
46
  ],
103
- default: [go('unknown_screen', 'start')],
104
47
  },
105
48
  },
106
- ],
107
- },
108
- },
49
+ ]),
50
+ screenCase(ROUTER_ID, 'AI router', decidingWith(options), DEFAULT_ROUTE_KEY),
51
+ screenCase('done', 'Finish', [finishStep('finish', first, { outcome: 'done' })]),
52
+ ], [jumpStep('unknown_screen', first, home(first))]),
53
+ ]),
109
54
  ],
110
55
  };
111
- // Writes the router's instructions and allowed screens from the screens above.
112
56
  return { config: refreshDerived(config), metadata: { kind: CONVERSATIONAL_FLOW_KIND } };
113
57
  }
58
+ /** The key holding what they typed, on the way to the router. */
59
+ const TEXT_KEY = 'text';
60
+ const ROUTER_ID = 'ai_router';
61
+ /**
62
+ * What reads a typed message, and the jump that carries its answer on. A
63
+ * classifier puts the message in one of the screens; an agent is asked for the
64
+ * same answer as JSON. What either is told is written by `settle`.
65
+ */
66
+ function decidingWith(options) {
67
+ const router = options.router ?? (options.agentSlug ? { kind: 'agent', agentSlug: options.agentSlug } : { kind: 'classifier' });
68
+ const keys = [DEFAULT_ROUTE_KEY, TEXT_KEY];
69
+ if (router.kind === 'agent') {
70
+ const step = {
71
+ id: 'classify',
72
+ type: AGENT_STEP_TYPE,
73
+ config: { agentSlug: router.agentSlug?.trim() ?? '', task: '', outputType: 'json' },
74
+ };
75
+ return [step, jumpStep('go_classified', 'start', carrying(keys, DEFAULT_ROUTE_KEY, `{{steps.classify.output.response.${DEFAULT_ROUTE_KEY}}}`))];
76
+ }
77
+ const step = {
78
+ id: 'classify',
79
+ type: CLASSIFIER_STEP_TYPE,
80
+ config: {
81
+ input: '',
82
+ instructions: '',
83
+ classes: {},
84
+ ...(router.model ? { model: router.model } : {}),
85
+ ...(router.credentialName ? { credentialName: router.credentialName } : {}),
86
+ ...(router.minConfidence !== undefined ? { minConfidence: router.minConfidence } : {}),
87
+ },
88
+ };
89
+ return [step, jumpStep('go_classified', 'start', carrying(keys, DEFAULT_ROUTE_KEY, '{{steps.classify.output.class}}'))];
90
+ }
114
91
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources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because two edits need it: adding a screen, and changing what kind
5
+ * an existing one is. Every builder models itself on a question the flow already
6
+ * has — the same field names, the same way of telling typing from tapping — so a
7
+ * screen added to a flow looks like the rest of it rather than like this file.
8
+ *
9
+ * Nothing here is derived: the headings, the subtrees, where the jumps are
10
+ * aimed and what a hand off offers are all written by `settle` afterwards.
11
+ */
12
+ import type { WorkflowConfig } from '../../types/workflow-config.js';
13
+ import { type Rec } from '../json.js';
14
+ import { type ConversationalFlow, type Screen } from '../types.js';
15
+ /** Everything the builders share: who is being built, and what it says. */
16
+ export interface Building {
17
+ screenId: string;
18
+ title: string;
19
+ /** What the screen says. */
20
+ prompt: string;
21
+ /** The options it offers — its ways back, and whatever its kind adds. */
22
+ options: Rec[];
23
+ /** The router its typed text goes to. Without one, the flow's own. */
24
+ router?: string;
25
+ /**
26
+ * The heading above it. Left out for a screen, whose heading is where it sits
27
+ * and so is written by `settle`; given for a follow-up, which is asked inside
28
+ * another question rather than anywhere of its own.
29
+ */
30
+ header?: string;
31
+ }
32
+ /**
33
+ * What a screen of this kind is made of — the one place that decides, so a screen
34
+ * created as a Finish and a screen turned into one are the same screen.
35
+ */
36
+ export declare function stepsForKind(draft: WorkflowConfig, flow: ConversationalFlow, kind: 'menu' | 'message' | 'questions' | 'ask-ai' | 'end' | 'handoff' | undefined, args: Building & {
37
+ agentSlug?: string;
38
+ }): unknown[];
39
+ /**
40
+ * A screen that asks: the question, and where each answer goes.
41
+ *
42
+ * `branches` makes it a screen with follow-ups — the jump moves into a SWITCH
43
+ * whose cases are the answers that ask something more before moving on.
44
+ */
45
+ export declare function questionSteps(draft: WorkflowConfig, flow: ConversationalFlow, args: Building & {
46
+ branches?: boolean;
47
+ }): unknown[];
48
+ /**
49
+ * The end of the conversation. Whatever the screen said becomes its last word,
50
+ * so turning a Message into a Finish keeps its wording instead of dropping it.
51
+ */
52
+ export declare function endingSteps(flow: ConversationalFlow, args: Pick<Building, 'screenId' | 'prompt'>): unknown[];
53
+ /**
54
+ * A person has it from here.
55
+ *
56
+ * The run pauses on a WAIT only they answer — no text box, since the customer is
57
+ * talking to them now — and a jump carries their answer on: an ending closes the
58
+ * conversation, a screen sends it back into the flow. What they may choose is
59
+ * written by `settle`.
60
+ */
61
+ export declare function handoffSteps(draft: WorkflowConfig, flow: ConversationalFlow, args: Pick<Building, 'screenId'>): unknown[];
62
+ /**
63
+ * An agent that answers until they leave.
64
+ *
65
+ * It opens like any screen — the intro, the ways out, a text box — and a typed
66
+ * question goes to an agent that answers and then waits for a reply: another
67
+ * question is answered in place, and tapping one of the ways out carries them
68
+ * there. So the whole exchange is one round of the conversation.
69
+ */
70
+ export declare function askAiSteps(draft: WorkflowConfig, flow: ConversationalFlow, args: Building & {
71
+ agentSlug?: string;
72
+ }): unknown[];
73
+ export declare class AskAiUnsupported extends Error {
74
+ readonly name = "AskAiUnsupported";
75
+ }
76
+ /** What decides where typed text goes: a classifier model, or one of the agents. */
77
+ export type RouterMode = {
78
+ mode: 'classifier';
79
+ model?: string;
80
+ credentialName?: string;
81
+ minConfidence?: number;
82
+ } | {
83
+ mode: 'agent';
84
+ agentSlug: string;
85
+ };
86
+ /**
87
+ * A router: the step that reads a typed message and names a screen, and the jump
88
+ * that carries its answer on.
89
+ *
90
+ * What it is told, the screens it may choose and where an unsure message goes are
91
+ * all written by `settle`, from the frame the router ends up in.
92
+ */
93
+ export declare function routerSteps(draft: WorkflowConfig, flow: ConversationalFlow, args: {
94
+ screenId: string;
95
+ wanted: RouterMode;
96
+ stepId?: string;
97
+ }): unknown[];
98
+ /** The deciding step itself, keeping anything the author wrote on the old one. */
99
+ export declare function decidingStep(stepId: string, wanted: RouterMode, description?: string): Rec;
100
+ /** How the jump after a router names what it chose. */
101
+ export declare function routerAnswer(stepId: string, wanted: RouterMode, routeKey: string): string;
102
+ /**
103
+ * The ending a new Message screen offers as "That's all": a way out of the
104
+ * conversation that belongs to no branch in particular.
105
+ *
106
+ * A Finish that says something ("Your driver is 3 minutes away") is that
107
+ * branch's own ending, and offering it from an unrelated screen would put words
108
+ * in its mouth. So: a silent Finish first, then whichever ending the most
109
+ * screens already lead to, and none at all when every ending belongs somewhere.
110
+ */
111
+ export declare function sharedExit(flow: ConversationalFlow, exclude: string): Screen | undefined;
112
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAuB,KAAK,GAAG,EAAa,MAAM,YAAY,CAAC;AAItE,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AAErB,2EAA2E;AAC3E,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,EACjF,IAAI,EAAE,QAAQ,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,EAAE,CAaX;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,QAAQ,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GACtC,OAAO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