rasa-pro 3.13.0.dev5__py3-none-any.whl → 3.13.0.dev7__py3-none-any.whl

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.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

Files changed (154) hide show
  1. rasa/api.py +4 -0
  2. rasa/cli/arguments/default_arguments.py +13 -1
  3. rasa/cli/arguments/train.py +2 -0
  4. rasa/cli/evaluate.py +1 -1
  5. rasa/cli/export.py +2 -2
  6. rasa/cli/train.py +1 -0
  7. rasa/constants.py +2 -0
  8. rasa/core/agent.py +2 -2
  9. rasa/core/brokers/kafka.py +4 -0
  10. rasa/core/brokers/pika.py +4 -0
  11. rasa/core/brokers/sql.py +1 -1
  12. rasa/core/channels/inspector/.eslintrc.cjs +12 -6
  13. rasa/core/channels/inspector/.prettierrc +5 -0
  14. rasa/core/channels/inspector/README.md +10 -4
  15. rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-c4b064fc.js} +1 -1
  16. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
  17. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
  18. rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
  19. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
  20. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
  21. rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
  22. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-83c206ba.js} +1 -1
  23. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
  24. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-17586500.js} +1 -1
  25. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-be2a1776.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
  27. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
  28. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-0f155405.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-d5f1d1b7.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-47737d3a.js} +123 -123
  34. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-1936d429.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-dde8d0f3.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-0c2c7ee0.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-35dd89a4.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-128ea07c.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-4984898a.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-1bf266ba.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-60521c63.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-44ee592e.js} +1 -1
  53. rasa/core/channels/inspector/dist/index.html +1 -1
  54. rasa/core/channels/inspector/package.json +3 -1
  55. rasa/core/channels/inspector/src/App.tsx +91 -90
  56. rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
  57. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
  58. rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
  59. rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
  60. rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
  61. rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
  62. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
  63. rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
  64. rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
  65. rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
  66. rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
  67. rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
  68. rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
  69. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
  70. rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
  71. rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
  72. rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
  73. rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
  74. rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
  75. rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
  76. rasa/core/channels/inspector/src/main.tsx +8 -8
  77. rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
  78. rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
  79. rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
  80. rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
  81. rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
  82. rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
  83. rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
  84. rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
  85. rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
  86. rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
  87. rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
  88. rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
  89. rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
  90. rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
  91. rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
  92. rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
  93. rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
  94. rasa/core/channels/inspector/src/theme/index.ts +38 -38
  95. rasa/core/channels/inspector/src/types.ts +56 -50
  96. rasa/core/channels/inspector/yarn.lock +5 -0
  97. rasa/core/channels/voice_ready/audiocodes.py +34 -17
  98. rasa/core/evaluation/marker_tracker_loader.py +1 -1
  99. rasa/core/exporter.py +1 -1
  100. rasa/core/nlg/contextual_response_rephraser.py +4 -2
  101. rasa/core/nlg/summarize.py +1 -1
  102. rasa/core/persistor.py +55 -20
  103. rasa/core/policies/enterprise_search_policy.py +7 -4
  104. rasa/core/policies/intentless_policy.py +15 -9
  105. rasa/core/processor.py +2 -2
  106. rasa/core/run.py +7 -2
  107. rasa/core/tracker_stores/__init__.py +0 -0
  108. rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
  109. rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
  110. rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
  111. rasa/core/tracker_stores/redis_tracker_store.py +219 -0
  112. rasa/core/tracker_stores/sql_tracker_store.py +555 -0
  113. rasa/core/tracker_stores/tracker_store.py +805 -0
  114. rasa/core/utils.py +6 -0
  115. rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
  116. rasa/dialogue_understanding/commands/clarify_command.py +2 -2
  117. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -2
  118. rasa/dialogue_understanding/generator/constants.py +2 -2
  119. rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -1
  120. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +33 -12
  121. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +2 -2
  122. rasa/hooks.py +2 -2
  123. rasa/keys +1 -0
  124. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
  125. rasa/model_manager/config.py +3 -1
  126. rasa/model_manager/model_api.py +1 -2
  127. rasa/model_manager/runner_service.py +8 -4
  128. rasa/model_manager/trainer_service.py +1 -0
  129. rasa/model_training.py +12 -3
  130. rasa/nlu/extractors/crf_entity_extractor.py +66 -16
  131. rasa/plugin.py +1 -1
  132. rasa/server.py +6 -2
  133. rasa/shared/constants.py +3 -0
  134. rasa/shared/core/events.py +68 -2
  135. rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
  136. rasa/shared/providers/_configs/openai_client_config.py +4 -0
  137. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
  138. rasa/shared/providers/llm/_base_litellm_client.py +5 -2
  139. rasa/telemetry.py +2 -2
  140. rasa/tracing/config.py +1 -1
  141. rasa/tracing/instrumentation/attribute_extractors.py +1 -1
  142. rasa/tracing/instrumentation/instrumentation.py +1 -1
  143. rasa/utils/licensing.py +1 -2
  144. rasa/version.py +1 -1
  145. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/METADATA +4 -4
  146. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/RECORD +149 -140
  147. rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
  148. rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
  149. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
  150. rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
  151. rasa/core/tracker_store.py +0 -1792
  152. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/NOTICE +0 -0
  153. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/WHEEL +0 -0
  154. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/entry_points.txt +0 -0
@@ -1,84 +1,84 @@
1
- import { rasaColors } from "../theme/base/colors";
2
- import type { Event, Flow, Slot, Stack } from "../types";
1
+ import { rasaColors } from '../theme/base/colors'
2
+ import type { Event, Flow, Slot, Stack } from '../types'
3
3
 
4
4
  export function formatSlots(slots: { [key: string]: unknown }) {
5
5
  if (!slots) {
6
- return [];
6
+ return []
7
7
  }
8
8
 
9
9
  return Object.entries(slots)
10
10
  .filter(
11
11
  (slotDuple) =>
12
- slotDuple[0] !== "dialogue_stack" &&
13
- slotDuple[0] !== "flow_hashes" &&
14
- slotDuple[1] != null
12
+ slotDuple[0] !== 'dialogue_stack' &&
13
+ slotDuple[0] !== 'flow_hashes' &&
14
+ slotDuple[1] != null,
15
15
  )
16
- .map((slotDuple) => ({ name: slotDuple[0], value: slotDuple[1] }));
16
+ .map((slotDuple) => ({ name: slotDuple[0], value: slotDuple[1] }))
17
17
  }
18
18
 
19
19
  export const formatTestCases = (events: Event[], sessionId: string) => {
20
20
  let testCases = `test_cases:
21
21
  - test_case: ${sessionId}
22
- steps:`;
22
+ steps:`
23
23
 
24
24
  const steps = events
25
25
  .map((event) => {
26
- const escapedText = JSON.stringify(event.text);
27
- if (event.event === "user") {
28
- return ` - user: ${escapedText}`;
29
- } else if (event.event === "bot") {
26
+ const escapedText = JSON.stringify(event.text)
27
+ if (event.event === 'user') {
28
+ return ` - user: ${escapedText}`
29
+ } else if (event.event === 'bot') {
30
30
  return `${
31
31
  event.metadata?.utter_action
32
32
  ? ` - utter: ${event.metadata.utter_action}`
33
33
  : ` - bot: ${escapedText}`
34
- }`;
34
+ }`
35
35
  }
36
36
  })
37
- .filter(Boolean);
37
+ .filter(Boolean)
38
38
 
39
39
  if (steps.length === 0) {
40
- testCases = `${testCases} []`;
40
+ testCases = `${testCases} []`
41
41
  } else {
42
42
  testCases = `${testCases}
43
- ${steps.join("\n")}`;
43
+ ${steps.join('\n')}`
44
44
  }
45
45
 
46
- return testCases;
47
- };
46
+ return testCases
47
+ }
48
48
 
49
49
  function hashCode(str: string) {
50
50
  var hash = 0,
51
51
  i,
52
- chr;
53
- if (str.length === 0) return hash;
52
+ chr
53
+ if (str.length === 0) return hash
54
54
  for (i = 0; i < str.length; i++) {
55
- chr = str.charCodeAt(i);
56
- hash = (hash << 5) - hash + chr;
57
- hash |= 0; // Convert to 32bit integer
55
+ chr = str.charCodeAt(i)
56
+ hash = (hash << 5) - hash + chr
57
+ hash |= 0 // Convert to 32bit integer
58
58
  }
59
- return hash;
59
+ return hash
60
60
  }
61
61
 
62
62
  function mermaidIdForTitle(title: string) {
63
- return `id${hashCode(title)}`;
63
+ return `id${hashCode(title)}`
64
64
  }
65
65
 
66
66
  const encodeDoubleQuotes = (str: string) =>
67
67
  /**
68
68
  * Transforms all " characters of a string into html codes.
69
69
  */
70
- str.replace(/"/g, `#34;`);
70
+ str.replace(/"/g, `#34;`)
71
71
 
72
72
  export const formatFlow = (
73
73
  slots: Slot[],
74
74
  currentStack?: Stack,
75
75
  flow?: Flow,
76
- stepTrail?: string[]
76
+ stepTrail?: string[],
77
77
  ) => {
78
- const activeStep = currentStack?.step_id;
78
+ const activeStep = currentStack?.step_id
79
79
 
80
80
  if (!flow) {
81
- return "";
81
+ return ''
82
82
  }
83
83
 
84
84
  const mermaidText = [
@@ -91,189 +91,189 @@ classDef endstep fill:#ccc,stroke:#444
91
91
  classDef previous stroke:${rasaColors.rasaOrange[400]},stroke-width:1px
92
92
  classDef active stroke:${rasaColors.rasaOrange[400]},stroke-width:3px,fill:${rasaColors.warning[50]}
93
93
  `,
94
- ];
94
+ ]
95
95
  try {
96
96
  const text = renderStepSequence(
97
97
  flow.steps,
98
98
  slots,
99
99
  currentStack,
100
100
  activeStep,
101
- stepTrail
102
- );
103
- mermaidText.push(text);
104
- mermaidText.push(colorDoubleEdges(mermaidText.join("")));
105
- return mermaidText.join("");
101
+ stepTrail,
102
+ )
103
+ mermaidText.push(text)
104
+ mermaidText.push(colorDoubleEdges(mermaidText.join('')))
105
+ return mermaidText.join('')
106
106
  } catch (e) {
107
- return `${mermaidText}\nA["Something went wrong!"]\nB["${e}"]`;
107
+ return `${mermaidText}\nA["Something went wrong!"]\nB["${e}"]`
108
108
  }
109
- };
109
+ }
110
110
 
111
111
  function truncate(str: string, limit = 35) {
112
112
  // if a string is too long, use an ellipsis
113
113
  if (str.length > limit) {
114
- return str.substring(0, limit) + "...";
114
+ return str.substring(0, limit) + '...'
115
115
  }
116
- return str;
116
+ return str
117
117
  }
118
118
 
119
119
  function colorDoubleEdges(mermaidText: string) {
120
120
  // go through the lines of mermaid text. keep a counter counting edges
121
121
  // ("-->"" or "==>"). if "==>" is found in a line, add the line number to
122
122
  // a list.
123
- const lines = mermaidText.split("\n");
124
- const coloredEdges = [];
125
- let edgeCounter = 0;
123
+ const lines = mermaidText.split('\n')
124
+ const coloredEdges = []
125
+ let edgeCounter = 0
126
126
  for (let i = 0; i < lines.length; i++) {
127
- if (lines[i].includes("-->")) {
128
- edgeCounter++;
129
- } else if (lines[i].includes("==>")) {
130
- coloredEdges.push(edgeCounter);
131
- edgeCounter++;
127
+ if (lines[i].includes('-->')) {
128
+ edgeCounter++
129
+ } else if (lines[i].includes('==>')) {
130
+ coloredEdges.push(edgeCounter)
131
+ edgeCounter++
132
132
  }
133
133
  }
134
- if(coloredEdges.length > 0) {
135
- return `linkStyle ${coloredEdges.join(",")} stroke:${
134
+ if (coloredEdges.length > 0) {
135
+ return `linkStyle ${coloredEdges.join(',')} stroke:${
136
136
  rasaColors.rasaOrange[400]
137
- }, ;\n`;
137
+ }, ;\n`
138
138
  } else {
139
- return "";
139
+ return ''
140
140
  }
141
141
  }
142
142
 
143
143
  export function parseFieldUsingStack(name: string, stack?: Stack): string {
144
144
  // name might be in the `{{context.field_in_stack}}` format so we're stripping everything except the field in the stack name
145
- const parsedField = name.split(/{{context\.|}}/);
145
+ const parsedField = name.split(/{{context\.|}}/)
146
146
  if (parsedField.length === 1) {
147
- return parsedField[0];
147
+ return parsedField[0]
148
148
  }
149
149
 
150
- const stackField = parsedField[1];
150
+ const stackField = parsedField[1]
151
151
 
152
152
  // @ts-expect-error `stack[stackField]` doesn't necessary exists this might return `undefined`
153
- const stackValue = stack ? stack[stackField] : undefined;
153
+ const stackValue = stack ? stack[stackField] : undefined
154
154
 
155
155
  // name might also be in the `condition {{context.field_in_stack}} condition` format
156
156
  // so we want to keep that if there is any
157
- if (parsedField[2] && parsedField[2] !== "") {
158
- return `${parsedField[0]}${stackValue}${parsedField[2]}`;
157
+ if (parsedField[2] && parsedField[2] !== '') {
158
+ return `${parsedField[0]}${stackValue}${parsedField[2]}`
159
159
  }
160
160
 
161
- return `${parsedField[0]}${stackValue}`;
161
+ return `${parsedField[0]}${stackValue}`
162
162
  }
163
163
 
164
164
  function arrowTypeFor(stepId: string, nextId: string, stepTrail?: string[]) {
165
165
  return stepTrail?.includes(stepId) && stepTrail?.includes(nextId)
166
- ? "==>"
167
- : "-->";
166
+ ? '==>'
167
+ : '-->'
168
168
  }
169
169
 
170
170
  function renderStepSequence(
171
- steps: Flow["steps"],
171
+ steps: Flow['steps'],
172
172
  slots: Slot[],
173
173
  currentStack?: Stack,
174
174
  activeStep?: string,
175
- stepTrail?: string[]
175
+ stepTrail?: string[],
176
176
  ) {
177
- let hasUsedEndStep = false;
178
- let mermaidTextFragment = "";
177
+ let hasUsedEndStep = false
178
+ let mermaidTextFragment = ''
179
179
  steps.forEach((step) => {
180
- const stepId = parseFieldUsingStack(step.id, currentStack);
181
- const mermaidId = mermaidIdForTitle(stepId);
180
+ const stepId = parseFieldUsingStack(step.id, currentStack)
181
+ const mermaidId = mermaidIdForTitle(stepId)
182
182
 
183
183
  if (step.collect) {
184
- const slot = slots.find((slot) => slot.name === step.collect);
184
+ const slot = slots.find((slot) => slot.name === step.collect)
185
185
  const slotValue =
186
- slot && typeof slot.value === "string"
186
+ slot && typeof slot.value === 'string'
187
187
  ? `"${encodeDoubleQuotes(truncate(slot.value))}"`
188
- : "💬";
188
+ : '💬'
189
189
  mermaidTextFragment += `${mermaidId}["${encodeDoubleQuotes(
190
- truncate(parseFieldUsingStack(step.collect, currentStack))
191
- )}\n${slotValue}"]:::collect\n`;
190
+ truncate(parseFieldUsingStack(step.collect, currentStack)),
191
+ )}\n${slotValue}"]:::collect\n`
192
192
  }
193
193
 
194
194
  if (step.action) {
195
195
  mermaidTextFragment += `${mermaidId}["${encodeDoubleQuotes(
196
- truncate(parseFieldUsingStack(step.action, currentStack))
197
- )}"]:::action\n`;
196
+ truncate(parseFieldUsingStack(step.action, currentStack)),
197
+ )}"]:::action\n`
198
198
  }
199
199
 
200
200
  if (step.link) {
201
201
  mermaidTextFragment += `${mermaidId}["\uD83D\uDD17 ${parseFieldUsingStack(
202
202
  step.link,
203
- currentStack
204
- )}"]:::link\n`;
203
+ currentStack,
204
+ )}"]:::link\n`
205
205
  }
206
206
 
207
207
  if (step.set_slots) {
208
208
  mermaidTextFragment += `${mermaidId}["✍️ ${encodeDoubleQuotes(
209
- stepId
210
- )}"]:::slot\n`;
209
+ stepId,
210
+ )}"]:::slot\n`
211
211
  }
212
212
 
213
213
  if (activeStep && stepId === activeStep) {
214
- mermaidTextFragment += `class ${mermaidId} active\n`;
214
+ mermaidTextFragment += `class ${mermaidId} active\n`
215
215
  } else if (stepTrail?.includes(stepId)) {
216
- mermaidTextFragment += `class ${mermaidId} previous\n`;
216
+ mermaidTextFragment += `class ${mermaidId} previous\n`
217
217
  }
218
218
 
219
219
  // if next is an id, then it is a link
220
- if (step.next && typeof step.next === "string") {
221
- const nextId = parseFieldUsingStack(step.next, currentStack);
220
+ if (step.next && typeof step.next === 'string') {
221
+ const nextId = parseFieldUsingStack(step.next, currentStack)
222
222
 
223
223
  mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
224
224
  stepId,
225
225
  nextId,
226
- stepTrail
227
- )} ${mermaidIdForTitle(nextId)}\n`;
228
- if (step.next == "END") {
229
- hasUsedEndStep = true;
226
+ stepTrail,
227
+ )} ${mermaidIdForTitle(nextId)}\n`
228
+ if (step.next == 'END') {
229
+ hasUsedEndStep = true
230
230
  }
231
231
  }
232
232
 
233
233
  // if next is an array, then it is a list of conditions
234
234
  if (step.next && Array.isArray(step.next)) {
235
235
  step.next.forEach((condition) => {
236
- if (condition.then && typeof condition.then === "string") {
236
+ if (condition.then && typeof condition.then === 'string') {
237
237
  mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
238
238
  stepId,
239
239
  condition.then,
240
- stepTrail
240
+ stepTrail,
241
241
  )}|"${encodeDoubleQuotes(
242
- parseFieldUsingStack(condition.if, currentStack)
243
- )}"| ${mermaidIdForTitle(condition.then)}\n`;
244
- if (condition.then == "END") {
245
- hasUsedEndStep = true;
242
+ parseFieldUsingStack(condition.if, currentStack),
243
+ )}"| ${mermaidIdForTitle(condition.then)}\n`
244
+ if (condition.then == 'END') {
245
+ hasUsedEndStep = true
246
246
  }
247
247
  } else if (condition.then) {
248
248
  mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
249
249
  stepId,
250
250
  condition.then[0].id,
251
- stepTrail
251
+ stepTrail,
252
252
  )}|"${encodeDoubleQuotes(
253
- parseFieldUsingStack(condition.if, currentStack)
254
- )}"| ${mermaidIdForTitle(condition.then[0].id)}\n`;
253
+ parseFieldUsingStack(condition.if, currentStack),
254
+ )}"| ${mermaidIdForTitle(condition.then[0].id)}\n`
255
255
  mermaidTextFragment += renderStepSequence(
256
256
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
257
257
  condition.then,
258
258
  slots,
259
259
  currentStack,
260
260
  activeStep,
261
- stepTrail
262
- );
261
+ stepTrail,
262
+ )
263
263
  }
264
264
 
265
265
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
266
- if (condition.else && typeof condition.else === "string") {
266
+ if (condition.else && typeof condition.else === 'string') {
267
267
  mermaidTextFragment += `${mermaidId} ${arrowTypeFor(
268
268
  stepId,
269
269
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
270
270
  condition.else,
271
- stepTrail
271
+ stepTrail,
272
272
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
273
- )}|else| ${mermaidIdForTitle(condition.else)}\n`;
273
+ )}|else| ${mermaidIdForTitle(condition.else)}\n`
274
274
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
275
- if (condition.else == "END") {
276
- hasUsedEndStep = true;
275
+ if (condition.else == 'END') {
276
+ hasUsedEndStep = true
277
277
  }
278
278
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
279
279
  } else if (condition.else) {
@@ -281,26 +281,26 @@ function renderStepSequence(
281
281
  stepId,
282
282
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
283
283
  condition.else[0].id,
284
- stepTrail
284
+ stepTrail,
285
285
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
286
- )}|else| ${mermaidIdForTitle(condition.else[0].id)}\n`;
286
+ )}|else| ${mermaidIdForTitle(condition.else[0].id)}\n`
287
287
  mermaidTextFragment += renderStepSequence(
288
288
  // @ts-expect-error Currently the param for renderStepSequence only accepts a Step, for further improvements we need to change the type to know that it can also be a then step
289
289
  condition.else,
290
290
  slots,
291
291
  currentStack,
292
292
  activeStep,
293
- stepTrail
294
- );
293
+ stepTrail,
294
+ )
295
295
  }
296
- });
296
+ })
297
297
  }
298
- });
298
+ })
299
299
  if (hasUsedEndStep) {
300
- mermaidTextFragment += `${mermaidIdForTitle("END")}["🏁 END"]:::endstep\n`;
301
- if (activeStep && "END" === activeStep) {
302
- mermaidTextFragment += `class ${mermaidIdForTitle("END")} active\n`;
300
+ mermaidTextFragment += `${mermaidIdForTitle('END')}["🏁 END"]:::endstep\n`
301
+ if (activeStep && 'END' === activeStep) {
302
+ mermaidTextFragment += `class ${mermaidIdForTitle('END')} active\n`
303
303
  }
304
304
  }
305
- return mermaidTextFragment;
305
+ return mermaidTextFragment
306
306
  }
@@ -1,131 +1,148 @@
1
- import { SelectedStack, Stack, Event } from "../types";
2
- import { immutableJSONPatch} from 'immutable-json-patch'
1
+ import { SelectedStack, Stack, Event } from '../types'
2
+ import { immutableJSONPatch } from 'immutable-json-patch'
3
3
 
4
4
  export const shouldShowTooltip = (text: string) => {
5
5
  if (!text) {
6
- return false;
6
+ return false
7
7
  }
8
8
 
9
- const textLength = text.length;
9
+ const textLength = text.length
10
10
 
11
11
  if (textLength > 10 && textLength < 89) {
12
- return true;
12
+ return true
13
13
  }
14
14
 
15
- return false;
16
- };
15
+ return false
16
+ }
17
17
 
18
- export const createHistoricalStack = (activeStack: Stack [], events: Event[]): Stack[] => {
18
+ export const createHistoricalStack = (
19
+ activeStack: Stack[],
20
+ events: Event[],
21
+ ): Stack[] => {
19
22
  let stackFrames = activeStack.map((frame) => ({
20
23
  ...frame,
21
24
  ended: false,
22
- }));
25
+ }))
23
26
  // go through the events looking for flow_completed and append them to the stack
24
- let historicalStack: Stack[] = [];
25
- let pastStackFrames: Stack[] = [];
27
+ let historicalStack: Stack[] = []
28
+ let pastStackFrames: Stack[] = []
26
29
  for (const event of events) {
27
- if (event.event === "restart") {
28
- historicalStack = [];
29
- stackFrames = [];
30
- } else if (event.event === "stack") {
31
- let stackUpdate = JSON.parse(event.update || "");
30
+ if (event.event === 'restart') {
31
+ historicalStack = []
32
+ stackFrames = []
33
+ } else if (event.event === 'stack') {
34
+ let stackUpdate = JSON.parse(event.update || '')
32
35
  historicalStack = immutableJSONPatch(historicalStack, stackUpdate)
33
36
  for (const frame of historicalStack) {
34
- if(!frame.flow_id){
37
+ if (!frame.flow_id) {
35
38
  // this is not a stack frame from the flow handler
36
- continue;
39
+ continue
37
40
  }
38
41
  // if the frame is already in stackFrames, skip it
39
- if(stackFrames.find((f) => f.frame_id === frame.frame_id)) {
40
- continue;
42
+ if (stackFrames.find((f) => f.frame_id === frame.frame_id)) {
43
+ continue
41
44
  }
42
45
  // if the frame is in pastStackFrames, update the step_id otherwise add it
43
- const pastFrame = pastStackFrames.find((f) => f.frame_id === frame.frame_id)
44
- if(pastFrame) {
45
- pastFrame.step_id = frame.step_id;
46
- continue;
46
+ const pastFrame = pastStackFrames.find(
47
+ (f) => f.frame_id === frame.frame_id,
48
+ )
49
+ if (pastFrame) {
50
+ pastFrame.step_id = frame.step_id
51
+ continue
47
52
  }
48
- pastStackFrames.push({...frame, ended: true});
53
+ pastStackFrames.push({ ...frame, ended: true })
49
54
  }
50
55
  }
51
56
  }
52
57
  // filter out pattern_collect_information frames
53
- pastStackFrames = pastStackFrames.filter((frame) => frame.flow_id !== "pattern_collect_information");
54
- return [...pastStackFrames, ...stackFrames];
58
+ pastStackFrames = pastStackFrames.filter(
59
+ (frame) => frame.flow_id !== 'pattern_collect_information',
60
+ )
61
+ return [...pastStackFrames, ...stackFrames]
55
62
  }
56
63
 
57
64
  export const flowStepTrail = (events: Event[]): Record<string, string[]> => {
58
- let stack: Stack[] = [];
65
+ let stack: Stack[] = []
59
66
  // mapping from flow id to the steps that were active in that flow
60
- let activeSteps: { [key: string]: string[] } = {};
67
+ let activeSteps: { [key: string]: string[] } = {}
61
68
  for (const event of events) {
62
- if (event.event === "restart") {
63
- stack = [];
64
- activeSteps = {};
65
- } else if (event.event === "stack") {
66
- let stackUpdate = JSON.parse(event.update || "");
69
+ if (event.event === 'restart') {
70
+ stack = []
71
+ activeSteps = {}
72
+ } else if (event.event === 'stack') {
73
+ let stackUpdate = JSON.parse(event.update || '')
67
74
  stack = immutableJSONPatch(stack, stackUpdate)
68
75
  if (stack.length > 0) {
69
- let topFrame = stack[stack.length - 1];
76
+ let topFrame = stack[stack.length - 1]
70
77
  if (!topFrame.flow_id) {
71
78
  // this is not a stack frame from the flow handler
72
- continue;
79
+ continue
73
80
  }
74
- if (!activeSteps[topFrame.flow_id] || topFrame.step_id === "START") {
75
- activeSteps[topFrame.flow_id] = [];
81
+ if (!activeSteps[topFrame.flow_id] || topFrame.step_id === 'START') {
82
+ activeSteps[topFrame.flow_id] = []
76
83
  }
77
84
  if (!activeSteps[topFrame.flow_id].includes(topFrame.step_id)) {
78
85
  activeSteps[topFrame.flow_id].push(topFrame.step_id)
79
86
  }
80
87
  }
81
-
82
88
  }
83
89
  }
84
- return activeSteps;
85
- };
90
+ return activeSteps
91
+ }
86
92
 
87
- export const updatedActiveFrame = (previous: SelectedStack | undefined, updatedStack: Stack[], events: Event[]) => {
93
+ export const updatedActiveFrame = (
94
+ previous: SelectedStack | undefined,
95
+ updatedStack: Stack[],
96
+ events: Event[],
97
+ ) => {
88
98
  // try to find the currently active frame in the updated stack
89
99
  // if it isn't there anymore, we will show the first non-pattern frame
90
100
  // instead
91
101
 
92
102
  // reset previously active stack frame, if it was not user selected
93
- if(!previous?.isUserSelected){
103
+ if (!previous?.isUserSelected) {
94
104
  previous = undefined
95
105
  }
96
106
 
97
107
  const activeFrame = updatedStack.find(
98
- (stackFrame) => stackFrame.frame_id === previous?.stack.frame_id
99
- );
108
+ (stackFrame) => stackFrame.frame_id === previous?.stack.frame_id,
109
+ )
100
110
  if (!activeFrame || activeFrame.ended) {
101
- if (!updatedStack){
102
- return undefined;
111
+ if (!updatedStack) {
112
+ return undefined
103
113
  }
104
114
  // iterate over the stack. select the first frame where the name does not
105
115
  // contain "pattern" and that has not
106
116
  // ended yet. If there is no such frame, select the topmost frame that has
107
117
  // not ended yet. If there is no such frame, select the topmost frame.
108
- const updatedFrame = updatedStack.slice().reverse().find(
109
- (frame) =>
110
- !frame.flow_id?.startsWith("pattern_") && !frame.ended
111
- ) || updatedStack.slice().reverse().find(
112
- (frame) => !frame.ended
113
- ) || updatedStack[updatedStack.length - 1];
118
+ const updatedFrame =
119
+ updatedStack
120
+ .slice()
121
+ .reverse()
122
+ .find(
123
+ (frame) => !frame.flow_id?.startsWith('pattern_') && !frame.ended,
124
+ ) ||
125
+ updatedStack
126
+ .slice()
127
+ .reverse()
128
+ .find((frame) => !frame.ended) ||
129
+ updatedStack[updatedStack.length - 1]
114
130
 
115
- if(updatedFrame !== undefined) {
131
+ if (updatedFrame !== undefined) {
116
132
  return {
117
133
  stack: updatedFrame,
118
134
  isUserSelected: false,
119
135
  activatedSteps: flowStepTrail(events)[updatedFrame.flow_id] || [],
120
- };
136
+ }
121
137
  } else {
122
- return undefined;
138
+ return undefined
123
139
  }
124
140
  } else {
125
- if(previous){
126
- previous.activatedSteps = flowStepTrail(events)[previous.stack.flow_id] || [];
127
- previous.stack = activeFrame;
141
+ if (previous) {
142
+ previous.activatedSteps =
143
+ flowStepTrail(events)[previous.stack.flow_id] || []
144
+ previous.stack = activeFrame
128
145
  }
129
- return previous;
146
+ return previous
130
147
  }
131
- };
148
+ }
@@ -1,13 +1,13 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom/client";
3
- import { App } from "./App.tsx";
4
- import { ChakraProvider } from "@chakra-ui/react";
5
- import { theme } from "./theme";
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import { App } from './App.tsx'
4
+ import { ChakraProvider } from '@chakra-ui/react'
5
+ import { theme } from './theme'
6
6
 
7
- ReactDOM.createRoot(document.getElementById("root")!).render(
7
+ ReactDOM.createRoot(document.getElementById('root')!).render(
8
8
  <React.StrictMode>
9
9
  <ChakraProvider theme={theme}>
10
10
  <App />
11
11
  </ChakraProvider>
12
- </React.StrictMode>
13
- );
12
+ </React.StrictMode>,
13
+ )