@xyne/workflow-sdk 3.2.47 → 3.2.49
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.
- package/dist/agents/host-agent-step.d.ts +2 -2
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +46 -34
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/workflow-client.d.ts +1 -1
- package/dist/client/workflow-client.d.ts.map +1 -1
- package/dist/client/workflow-client.js +34 -30
- package/dist/client/workflow-client.js.map +1 -1
- package/dist/connectors/builtin/steps/classifier-agent.step.d.ts +2 -2
- package/dist/connectors/builtin/steps/parallel.step.d.ts +4 -4
- package/dist/connectors/builtin/steps/wait.step.d.ts +28 -0
- package/dist/connectors/builtin/steps/wait.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/wait.step.js +26 -1
- package/dist/connectors/builtin/steps/wait.step.js.map +1 -1
- package/dist/conversational-flow/calls.d.ts +20 -0
- package/dist/conversational-flow/calls.d.ts.map +1 -0
- package/dist/conversational-flow/calls.js +59 -0
- package/dist/conversational-flow/calls.js.map +1 -0
- package/dist/conversational-flow/conditions.d.ts +24 -0
- package/dist/conversational-flow/conditions.d.ts.map +1 -0
- package/dist/conversational-flow/conditions.js +69 -0
- package/dist/conversational-flow/conditions.js.map +1 -0
- package/dist/conversational-flow/create.d.ts +23 -18
- package/dist/conversational-flow/create.d.ts.map +1 -1
- package/dist/conversational-flow/create.js +73 -96
- package/dist/conversational-flow/create.js.map +1 -1
- package/dist/conversational-flow/edit/build.d.ts +112 -0
- package/dist/conversational-flow/edit/build.d.ts.map +1 -0
- package/dist/conversational-flow/edit/build.js +249 -0
- package/dist/conversational-flow/edit/build.js.map +1 -0
- package/dist/conversational-flow/edit/calls.d.ts +61 -0
- package/dist/conversational-flow/edit/calls.d.ts.map +1 -0
- package/dist/conversational-flow/edit/calls.js +296 -0
- package/dist/conversational-flow/edit/calls.js.map +1 -0
- package/dist/conversational-flow/edit/cases.d.ts +29 -0
- package/dist/conversational-flow/edit/cases.d.ts.map +1 -0
- package/dist/conversational-flow/edit/cases.js +83 -0
- package/dist/conversational-flow/edit/cases.js.map +1 -0
- package/dist/conversational-flow/edit/endings.d.ts +16 -0
- package/dist/conversational-flow/edit/endings.d.ts.map +1 -0
- package/dist/conversational-flow/edit/endings.js +53 -0
- package/dist/conversational-flow/edit/endings.js.map +1 -0
- package/dist/conversational-flow/edit/followups.d.ts +28 -0
- package/dist/conversational-flow/edit/followups.d.ts.map +1 -0
- package/dist/conversational-flow/edit/followups.js +103 -0
- package/dist/conversational-flow/edit/followups.js.map +1 -0
- package/dist/conversational-flow/edit/inputs.d.ts +24 -0
- package/dist/conversational-flow/edit/inputs.d.ts.map +1 -0
- package/dist/conversational-flow/edit/inputs.js +53 -0
- package/dist/conversational-flow/edit/inputs.js.map +1 -0
- package/dist/conversational-flow/edit/kinds.d.ts +29 -0
- package/dist/conversational-flow/edit/kinds.d.ts.map +1 -0
- package/dist/conversational-flow/edit/kinds.js +142 -0
- package/dist/conversational-flow/edit/kinds.js.map +1 -0
- package/dist/conversational-flow/edit/options.d.ts +68 -0
- package/dist/conversational-flow/edit/options.d.ts.map +1 -0
- package/dist/conversational-flow/edit/options.js +209 -0
- package/dist/conversational-flow/edit/options.js.map +1 -0
- package/dist/conversational-flow/edit/picklist.d.ts +28 -0
- package/dist/conversational-flow/edit/picklist.d.ts.map +1 -0
- package/dist/conversational-flow/edit/picklist.js +58 -0
- package/dist/conversational-flow/edit/picklist.js.map +1 -0
- package/dist/conversational-flow/edit/prompts.d.ts +24 -0
- package/dist/conversational-flow/edit/prompts.d.ts.map +1 -0
- package/dist/conversational-flow/edit/prompts.js +180 -0
- package/dist/conversational-flow/edit/prompts.js.map +1 -0
- package/dist/conversational-flow/edit/routers.d.ts +65 -0
- package/dist/conversational-flow/edit/routers.d.ts.map +1 -0
- package/dist/conversational-flow/edit/routers.js +208 -0
- package/dist/conversational-flow/edit/routers.js.map +1 -0
- package/dist/conversational-flow/edit/screens.d.ts +44 -0
- package/dist/conversational-flow/edit/screens.d.ts.map +1 -0
- package/dist/conversational-flow/edit/screens.js +137 -0
- package/dist/conversational-flow/edit/screens.js.map +1 -0
- package/dist/conversational-flow/edit/versions.d.ts +43 -0
- package/dist/conversational-flow/edit/versions.d.ts.map +1 -0
- package/dist/conversational-flow/edit/versions.js +189 -0
- package/dist/conversational-flow/edit/versions.js.map +1 -0
- package/dist/conversational-flow/index.d.ts +33 -16
- package/dist/conversational-flow/index.d.ts.map +1 -1
- package/dist/conversational-flow/index.js +42 -9
- package/dist/conversational-flow/index.js.map +1 -1
- package/dist/conversational-flow/json.d.ts +15 -0
- package/dist/conversational-flow/json.d.ts.map +1 -0
- package/dist/conversational-flow/json.js +14 -0
- package/dist/conversational-flow/json.js.map +1 -0
- package/dist/conversational-flow/jumps.d.ts +22 -0
- package/dist/conversational-flow/jumps.d.ts.map +1 -0
- package/dist/conversational-flow/jumps.js +160 -0
- package/dist/conversational-flow/jumps.js.map +1 -0
- package/dist/conversational-flow/locate.d.ts +30 -0
- package/dist/conversational-flow/locate.d.ts.map +1 -0
- package/dist/conversational-flow/locate.js +73 -0
- package/dist/conversational-flow/locate.js.map +1 -0
- package/dist/conversational-flow/paths.d.ts +31 -0
- package/dist/conversational-flow/paths.d.ts.map +1 -0
- package/dist/conversational-flow/paths.js +50 -0
- package/dist/conversational-flow/paths.js.map +1 -0
- package/dist/conversational-flow/prompt.d.ts +48 -0
- package/dist/conversational-flow/prompt.d.ts.map +1 -0
- package/dist/conversational-flow/prompt.js +161 -0
- package/dist/conversational-flow/prompt.js.map +1 -0
- package/dist/conversational-flow/read.d.ts +9 -17
- package/dist/conversational-flow/read.d.ts.map +1 -1
- package/dist/conversational-flow/read.js +217 -384
- package/dist/conversational-flow/read.js.map +1 -1
- package/dist/conversational-flow/rounds.d.ts +29 -0
- package/dist/conversational-flow/rounds.d.ts.map +1 -0
- package/dist/conversational-flow/rounds.js +41 -0
- package/dist/conversational-flow/rounds.js.map +1 -0
- package/dist/conversational-flow/routers.d.ts +24 -80
- package/dist/conversational-flow/routers.d.ts.map +1 -1
- package/dist/conversational-flow/routers.js +76 -262
- package/dist/conversational-flow/routers.js.map +1 -1
- package/dist/conversational-flow/server/conversation-service.d.ts +46 -18
- package/dist/conversational-flow/server/conversation-service.d.ts.map +1 -1
- package/dist/conversational-flow/server/conversation-service.js +56 -18
- package/dist/conversational-flow/server/conversation-service.js.map +1 -1
- package/dist/conversational-flow/server/routes.d.ts +15 -6
- package/dist/conversational-flow/server/routes.d.ts.map +1 -1
- package/dist/conversational-flow/server/routes.js +71 -74
- package/dist/conversational-flow/server/routes.js.map +1 -1
- package/dist/conversational-flow/settle.d.ts +21 -15
- package/dist/conversational-flow/settle.d.ts.map +1 -1
- package/dist/conversational-flow/settle.js +240 -38
- package/dist/conversational-flow/settle.js.map +1 -1
- package/dist/conversational-flow/shape.d.ts +114 -0
- package/dist/conversational-flow/shape.d.ts.map +1 -0
- package/dist/conversational-flow/shape.js +209 -0
- package/dist/conversational-flow/shape.js.map +1 -0
- package/dist/conversational-flow/testing.d.ts +54 -0
- package/dist/conversational-flow/testing.d.ts.map +1 -0
- package/dist/conversational-flow/testing.js +119 -0
- package/dist/conversational-flow/testing.js.map +1 -0
- package/dist/conversational-flow/tree.d.ts +28 -17
- package/dist/conversational-flow/tree.d.ts.map +1 -1
- package/dist/conversational-flow/tree.js +60 -47
- package/dist/conversational-flow/tree.js.map +1 -1
- package/dist/conversational-flow/turn.d.ts +30 -22
- package/dist/conversational-flow/turn.d.ts.map +1 -1
- package/dist/conversational-flow/turn.js +69 -48
- package/dist/conversational-flow/turn.js.map +1 -1
- package/dist/conversational-flow/types.d.ts +154 -118
- package/dist/conversational-flow/types.d.ts.map +1 -1
- package/dist/conversational-flow/types.js +27 -51
- package/dist/conversational-flow/types.js.map +1 -1
- package/dist/conversational-flow/typing.d.ts +31 -0
- package/dist/conversational-flow/typing.d.ts.map +1 -0
- package/dist/conversational-flow/typing.js +53 -0
- package/dist/conversational-flow/typing.js.map +1 -0
- package/dist/engine/variable-resolver.d.ts +16 -0
- package/dist/engine/variable-resolver.d.ts.map +1 -1
- package/dist/engine/variable-resolver.js +45 -1
- package/dist/engine/variable-resolver.js.map +1 -1
- package/dist/types/pause-state.d.ts +9 -0
- package/dist/types/pause-state.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/conversational-flow/edit.d.ts +0 -101
- package/dist/conversational-flow/edit.d.ts.map +0 -1
- package/dist/conversational-flow/edit.js +0 -785
- package/dist/conversational-flow/edit.js.map +0 -1
- package/dist/conversational-flow/internals.d.ts +0 -51
- package/dist/conversational-flow/internals.d.ts.map +0 -1
- package/dist/conversational-flow/internals.js +0 -163
- package/dist/conversational-flow/internals.js.map +0 -1
- package/dist/conversational-flow/lookup-edit.d.ts +0 -96
- package/dist/conversational-flow/lookup-edit.d.ts.map +0 -1
- package/dist/conversational-flow/lookup-edit.js +0 -266
- package/dist/conversational-flow/lookup-edit.js.map +0 -1
- package/dist/conversational-flow/lookups.d.ts +0 -46
- package/dist/conversational-flow/lookups.d.ts.map +0 -1
- package/dist/conversational-flow/lookups.js +0 -145
- package/dist/conversational-flow/lookups.js.map +0 -1
- package/dist/conversational-flow/router-edit.d.ts +0 -53
- package/dist/conversational-flow/router-edit.d.ts.map +0 -1
- package/dist/conversational-flow/router-edit.js +0 -191
- package/dist/conversational-flow/router-edit.js.map +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { asArray, asRec, str } from '../json.js';
|
|
2
|
+
import { caseFor } from '../locate.js';
|
|
3
|
+
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
4
|
+
import { partsOf, stepIn } from '../shape.js';
|
|
5
|
+
import { ancestorsOf, mainMenuLabel } from '../tree.js';
|
|
6
|
+
import { leavesOf } from '../conditions.js';
|
|
7
|
+
/** Offer a screen. New options go above the ways back, where they read first. */
|
|
8
|
+
export function addOption(config, promptId, option, at) {
|
|
9
|
+
const flow = requireFlow(config);
|
|
10
|
+
const { screen, prompt } = promptIn(flow, promptId);
|
|
11
|
+
const label = option.label.trim();
|
|
12
|
+
if (!label)
|
|
13
|
+
throw new ConversationalFlowEditError('An option needs a label.');
|
|
14
|
+
requireScreen(flow, option.screen);
|
|
15
|
+
const firstBack = prompt.options.findIndex((o) => o.back);
|
|
16
|
+
const where = at ?? (firstBack === -1 ? prompt.options.length : firstBack);
|
|
17
|
+
return settle(config, (draft) => {
|
|
18
|
+
const live = requireFlow(draft);
|
|
19
|
+
optionList(draft, live, requireScreen(live, screen.id), promptId).splice(where, 0, { label, value: option.screen });
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function relabelOption(config, promptId, index, label) {
|
|
23
|
+
const trimmed = label.trim();
|
|
24
|
+
if (!trimmed)
|
|
25
|
+
throw new ConversationalFlowEditError('An option needs a label.');
|
|
26
|
+
return onOption(config, promptId, index, (option) => {
|
|
27
|
+
option['label'] = trimmed;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Point an option at another screen. */
|
|
31
|
+
export function retargetOption(config, promptId, index, to) {
|
|
32
|
+
const flow = requireFlow(config);
|
|
33
|
+
requireScreen(flow, to);
|
|
34
|
+
return onOption(config, promptId, index, (option) => {
|
|
35
|
+
option['value'] = to;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Offer an option only when a condition holds — or, given `undefined`, always.
|
|
40
|
+
*
|
|
41
|
+
* It stays one option in one list, because that is what it is: the question is
|
|
42
|
+
* the same one, and a line of it appears or it doesn't. The engine filters the
|
|
43
|
+
* list as it asks, so nothing downstream has to know a choice existed — the gate
|
|
44
|
+
* that reads the answer is untouched, and so is where the option leads.
|
|
45
|
+
*/
|
|
46
|
+
export function setOptionCondition(config, promptId, index, when) {
|
|
47
|
+
if (when)
|
|
48
|
+
requireCondition(when);
|
|
49
|
+
return onOption(config, promptId, index, (option) => {
|
|
50
|
+
if (when)
|
|
51
|
+
option['when'] = when;
|
|
52
|
+
else
|
|
53
|
+
delete option['when'];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Every leaf of a condition must say what it reads and how. */
|
|
57
|
+
function requireCondition(when) {
|
|
58
|
+
const leaves = leavesOf(when);
|
|
59
|
+
if (leaves.length === 0)
|
|
60
|
+
throw new ConversationalFlowEditError('A condition needs something to test.');
|
|
61
|
+
for (const leaf of leaves) {
|
|
62
|
+
if (!leaf.variable.trim())
|
|
63
|
+
throw new ConversationalFlowEditError('Say which value decides.');
|
|
64
|
+
if (!leaf.operator.trim())
|
|
65
|
+
throw new ConversationalFlowEditError('Say how to compare it.');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function moveOption(config, promptId, from, to) {
|
|
69
|
+
const flow = requireFlow(config);
|
|
70
|
+
const { screen, prompt } = promptIn(flow, promptId);
|
|
71
|
+
if (from < 0 || from >= prompt.options.length)
|
|
72
|
+
throw new ConversationalFlowEditError('No such option.');
|
|
73
|
+
const at = Math.max(0, Math.min(to, prompt.options.length - 1));
|
|
74
|
+
return settle(config, (draft) => {
|
|
75
|
+
const live = requireFlow(draft);
|
|
76
|
+
const options = optionList(draft, live, requireScreen(live, screen.id), promptId);
|
|
77
|
+
const [moved] = options.splice(from, 1);
|
|
78
|
+
if (moved)
|
|
79
|
+
options.splice(at, 0, moved);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function removeOption(config, promptId, index) {
|
|
83
|
+
return onOption(config, promptId, index, undefined, (options, at) => {
|
|
84
|
+
options.splice(at, 1);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether the question offers the way back: one option per screen above it, and
|
|
89
|
+
* the first screen last. Generated, so turning it on after a move gives the ways
|
|
90
|
+
* back from where the screen now sits.
|
|
91
|
+
*/
|
|
92
|
+
export function setWayBack(config, promptId, on) {
|
|
93
|
+
const flow = requireFlow(config);
|
|
94
|
+
const { screen } = promptIn(flow, promptId);
|
|
95
|
+
if (screen.id === flow.rootScreen)
|
|
96
|
+
throw new ConversationalFlowEditError('The first screen has nowhere to go back to.');
|
|
97
|
+
return settle(config, (draft) => {
|
|
98
|
+
const live = requireFlow(draft);
|
|
99
|
+
const options = optionList(draft, live, requireScreen(live, screen.id), promptId);
|
|
100
|
+
const kept = options.filter((option) => !isWayBack(live, screen.id, str(asRec(option)['value'])));
|
|
101
|
+
options.splice(0, options.length, ...kept, ...(on ? waysBack(live, requireScreen(live, screen.id)) : []));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** The ways back a screen would offer: each screen above it, the first one last. */
|
|
105
|
+
export function waysBack(flow, screen) {
|
|
106
|
+
return wayBackOptions(flow, ancestorsOf(flow, screen.id));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The ways back a screen put inside `parentId` would offer — the parent, then
|
|
110
|
+
* whatever the parent goes back to. For building a screen that does not exist
|
|
111
|
+
* yet, and so has no ancestors to ask for.
|
|
112
|
+
*/
|
|
113
|
+
export function waysBackTo(flow, parentId) {
|
|
114
|
+
return wayBackOptions(flow, [parentId, ...ancestorsOf(flow, parentId)]);
|
|
115
|
+
}
|
|
116
|
+
/** How a way back is worded: the first screen by name, everything else with an arrow. */
|
|
117
|
+
function wayBackOptions(flow, ids) {
|
|
118
|
+
const byId = new Map(flow.screens.map((s) => [s.id, s]));
|
|
119
|
+
return ids.map((id) => ({
|
|
120
|
+
label: id === flow.rootScreen ? (mainMenuLabel(flow) ?? byId.get(id)?.title ?? 'Main menu') : `↑ ${byId.get(id)?.title ?? id}`,
|
|
121
|
+
value: id,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
function isWayBack(flow, screenId, value) {
|
|
125
|
+
return value !== undefined && ancestorsOf(flow, screenId).includes(value);
|
|
126
|
+
}
|
|
127
|
+
// ─── Shared with the edits that move screens around ───
|
|
128
|
+
/**
|
|
129
|
+
* The live list of options a question offers. Anything that changes options —
|
|
130
|
+
* here, or a screen being added, renamed or removed — goes through this, so the
|
|
131
|
+
* shape of a question is known in one place.
|
|
132
|
+
*/
|
|
133
|
+
export function optionList(config, flow, screen, promptId) {
|
|
134
|
+
const entry = caseFor(config, flow, screen);
|
|
135
|
+
const wait = entry ? stepIn(partsOf(entry, flow.routeKey).rest, promptId) : undefined;
|
|
136
|
+
const select = asArray(asRec(wait?.config['form'])['fields']).map(asRec).find((f) => f['type'] === 'select');
|
|
137
|
+
if (!select)
|
|
138
|
+
throw new ConversationalFlowEditError(`“${screen.title}” doesn’t offer options.`);
|
|
139
|
+
if (!Array.isArray(select['options']))
|
|
140
|
+
select['options'] = [];
|
|
141
|
+
return select['options'];
|
|
142
|
+
}
|
|
143
|
+
/** Take away every option that opened `screenId`, wherever it is offered. */
|
|
144
|
+
export function dropOptionsTo(config, flow, screenId) {
|
|
145
|
+
for (const screen of flow.screens) {
|
|
146
|
+
for (const prompt of screen.prompts) {
|
|
147
|
+
const options = optionListIfAny(config, flow, screen, prompt.id);
|
|
148
|
+
if (!options)
|
|
149
|
+
continue;
|
|
150
|
+
for (let at = options.length - 1; at >= 0; at -= 1) {
|
|
151
|
+
if (asRec(options[at])['value'] === screenId)
|
|
152
|
+
options.splice(at, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** Rename a screen wherever an option names it, keeping a way back's arrow. */
|
|
158
|
+
export function relabelOptionsTo(config, flow, screenId, title) {
|
|
159
|
+
for (const screen of flow.screens) {
|
|
160
|
+
for (const prompt of screen.prompts) {
|
|
161
|
+
const options = optionListIfAny(config, flow, screen, prompt.id);
|
|
162
|
+
for (const raw of options ?? []) {
|
|
163
|
+
const option = asRec(raw);
|
|
164
|
+
if (option['value'] !== screenId)
|
|
165
|
+
continue;
|
|
166
|
+
option['label'] = String(option['label'] ?? '').startsWith('↑ ') ? `↑ ${title}` : title;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function optionListIfAny(config, flow, screen, promptId) {
|
|
172
|
+
try {
|
|
173
|
+
return optionList(config, flow, screen, promptId);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// ─── Plumbing ───
|
|
180
|
+
function onOption(config, promptId, index, change, onList) {
|
|
181
|
+
const flow = requireFlow(config);
|
|
182
|
+
const { screen, prompt } = promptIn(flow, promptId);
|
|
183
|
+
if (index < 0 || index >= prompt.options.length)
|
|
184
|
+
throw new ConversationalFlowEditError('No such option.');
|
|
185
|
+
return settle(config, (draft) => {
|
|
186
|
+
const live = requireFlow(draft);
|
|
187
|
+
const options = optionList(draft, live, requireScreen(live, screen.id), promptId);
|
|
188
|
+
if (onList)
|
|
189
|
+
onList(options, index);
|
|
190
|
+
else if (change)
|
|
191
|
+
change(asRec(options[index]));
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/** The question an edit names, and the screen that asks it. */
|
|
195
|
+
export function promptIn(flow, promptId) {
|
|
196
|
+
for (const screen of flow.screens) {
|
|
197
|
+
const prompt = screen.prompts.find((p) => p.id === promptId);
|
|
198
|
+
if (prompt)
|
|
199
|
+
return { screen, prompt };
|
|
200
|
+
}
|
|
201
|
+
throw new ConversationalFlowEditError(`There is no question “${promptId}”.`);
|
|
202
|
+
}
|
|
203
|
+
function requireScreen(flow, id) {
|
|
204
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
205
|
+
if (!screen)
|
|
206
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
207
|
+
return screen;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/options.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,E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,QAAgB;IACjE,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;QAC7D,IAAI,MAAM;YAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,IAAI,2BAA2B,CAAC,yBAAyB,QAAQ,IAAI,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,aAAa,CAAC,IAAwB,EAAE,EAAU;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,2BAA2B,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAClF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options that come from data rather than from a list an author wrote.
|
|
3
|
+
*
|
|
4
|
+
* A WAIT's select already accepts a reference in place of its array — the step's
|
|
5
|
+
* own schema says so, and the resolver hands it the value rather than a string —
|
|
6
|
+
* so this needs nothing new from the engine. What it needs is for the layer to
|
|
7
|
+
* be able to say it, since a reader that only understands arrays shows an empty
|
|
8
|
+
* screen and draws no lines.
|
|
9
|
+
*
|
|
10
|
+
* The trade is honest and worth stating: the destinations are no longer known
|
|
11
|
+
* until it runs, so the map cannot draw where those taps go, and the router
|
|
12
|
+
* cannot count them among the screens it may open.
|
|
13
|
+
*/
|
|
14
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
15
|
+
import type { Screen } from '../types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Take this question's options from what a lookup found — `field` naming the
|
|
18
|
+
* part of its answer that holds `[{ label, value }]`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setOptionsFromLookup(config: WorkflowConfig, promptId: string, callId: string, field: string): WorkflowConfig;
|
|
21
|
+
/** Go back to a list the author writes, starting from nothing. */
|
|
22
|
+
export declare function setOptionsWritten(config: WorkflowConfig, promptId: string): WorkflowConfig;
|
|
23
|
+
/** Where a question's options come from, when they come from a lookup. */
|
|
24
|
+
export declare function optionsFrom(screen: Screen, promptId: string): {
|
|
25
|
+
callId: string;
|
|
26
|
+
field: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
//# sourceMappingURL=picklist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picklist.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/picklist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKrE,OAAO,KAAK,EAAsB,MAAM,EAAE,MAAM,aAAa,CAAC;AAG9D;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,cAAc,CAWhB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAO1F;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAM3G"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { asArray, asRec, str } from '../json.js';
|
|
2
|
+
import { caseFor } from '../locate.js';
|
|
3
|
+
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
4
|
+
import { partsOf, stepIn } from '../shape.js';
|
|
5
|
+
import { promptIn } from './options.js';
|
|
6
|
+
/**
|
|
7
|
+
* Take this question's options from what a lookup found — `field` naming the
|
|
8
|
+
* part of its answer that holds `[{ label, value }]`.
|
|
9
|
+
*/
|
|
10
|
+
export function setOptionsFromLookup(config, promptId, callId, field) {
|
|
11
|
+
const flow = requireFlow(config);
|
|
12
|
+
const { screen } = promptIn(flow, promptId);
|
|
13
|
+
const call = inScopeCall(flow, screen, callId);
|
|
14
|
+
const path = field.trim();
|
|
15
|
+
return settle(config, (draft) => {
|
|
16
|
+
const live = requireFlow(draft);
|
|
17
|
+
const select = selectIn(draft, live, promptId);
|
|
18
|
+
if (select)
|
|
19
|
+
select['options'] = `{{steps.${call.id}.output.${path ? `body.${path}` : 'body'}}}`;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Go back to a list the author writes, starting from nothing. */
|
|
23
|
+
export function setOptionsWritten(config, promptId) {
|
|
24
|
+
requireFlow(config);
|
|
25
|
+
return settle(config, (draft) => {
|
|
26
|
+
const live = requireFlow(draft);
|
|
27
|
+
const select = selectIn(draft, live, promptId);
|
|
28
|
+
if (select && typeof select['options'] === 'string')
|
|
29
|
+
select['options'] = [];
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Where a question's options come from, when they come from a lookup. */
|
|
33
|
+
export function optionsFrom(screen, promptId) {
|
|
34
|
+
const prompt = screen.prompts.find((p) => p.id === promptId);
|
|
35
|
+
const ref = prompt?.optionsFrom;
|
|
36
|
+
if (!ref)
|
|
37
|
+
return undefined;
|
|
38
|
+
const match = /^\{\{\s*steps\.([^.\s}]+)\.output\.body(?:\.([^\s}]+))?\s*\}\}$/.exec(ref);
|
|
39
|
+
return match ? { callId: match[1], field: match[2] ?? '' } : undefined;
|
|
40
|
+
}
|
|
41
|
+
function selectIn(draft, flow, promptId) {
|
|
42
|
+
const { screen } = promptIn(flow, promptId);
|
|
43
|
+
const entry = caseFor(draft, flow, screen);
|
|
44
|
+
const wait = entry ? stepIn(partsOf(entry, flow.routeKey).rest, promptId) : undefined;
|
|
45
|
+
return asArray(asRec(wait?.config['form'])['fields']).map(asRec).find((f) => str(f['type']) === 'select');
|
|
46
|
+
}
|
|
47
|
+
/** A lookup whose answer this screen can actually read. */
|
|
48
|
+
function inScopeCall(flow, screen, callId) {
|
|
49
|
+
const frames = [screen.id, ...screen.frames];
|
|
50
|
+
for (const id of frames) {
|
|
51
|
+
const on = flow.screens.find((s) => s.id === id);
|
|
52
|
+
const call = on?.calls.find((c) => c.id === callId);
|
|
53
|
+
if (call && (on?.id === screen.id || call.scope !== 'screen'))
|
|
54
|
+
return call;
|
|
55
|
+
}
|
|
56
|
+
throw new ConversationalFlowEditError(`“${screen.title}” can’t read anything called “${callId}”.`);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=picklist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picklist.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/picklist.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAsB,EACtB,QAAgB,EAChB,MAAc,EACd,KAAa;IAEb,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,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,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QACpD,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;IAC7E,CAAC;IACD,MAAM,IAAI,2BAA2B,CAAC,IAAI,MAAM,CAAC,KAAK,iCAAiC,MAAM,IAAI,CAAC,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a screen says, and whether it takes typing.
|
|
3
|
+
*
|
|
4
|
+
* The wording is the WAIT's own prompt, and can quote anything the frames
|
|
5
|
+
* around it fetched. Typing is the CONDITIONAL after it: with one, a message
|
|
6
|
+
* goes to the router; without, the screen only takes what it offers.
|
|
7
|
+
*/
|
|
8
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
9
|
+
/** What the screen says. It may quote what any frame around it fetched. */
|
|
10
|
+
export declare function setPromptText(config: WorkflowConfig, promptId: string, text: string): WorkflowConfig;
|
|
11
|
+
/**
|
|
12
|
+
* "The router sends people here when…" — what the router is told about this
|
|
13
|
+
* screen. On a Finish it is also what allows typing to end a conversation here.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setAbout(config: WorkflowConfig, screenId: string, about: string): WorkflowConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Whether a typed message is taken here.
|
|
18
|
+
*
|
|
19
|
+
* With typing, the question carries a text field and the steps after it split:
|
|
20
|
+
* something typed goes to the router, a tap goes wherever the option says.
|
|
21
|
+
* Without, the text field goes and the tap is all that is left.
|
|
22
|
+
*/
|
|
23
|
+
export declare function setTypingAllowed(config: WorkflowConfig, screenId: string, allowed: boolean): WorkflowConfig;
|
|
24
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AASrE,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAMpG;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAahG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,cAAc,CAmE3G"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { asArray, asRec, asSteps } from '../json.js';
|
|
2
|
+
import { caseFor } from '../locate.js';
|
|
3
|
+
import { routersFor } from '../routers.js';
|
|
4
|
+
import { carriedTo, textKeyOf } from '../rounds.js';
|
|
5
|
+
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
6
|
+
import { jumpStep, partsOf, stepIn } from '../shape.js';
|
|
7
|
+
/** What the screen says. It may quote what any frame around it fetched. */
|
|
8
|
+
export function setPromptText(config, promptId, text) {
|
|
9
|
+
requireFlow(config);
|
|
10
|
+
return settle(config, (draft) => {
|
|
11
|
+
const flow = requireFlow(draft);
|
|
12
|
+
questionStep(draft, flow, promptId).config['prompt'] = text;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* "The router sends people here when…" — what the router is told about this
|
|
17
|
+
* screen. On a Finish it is also what allows typing to end a conversation here.
|
|
18
|
+
*/
|
|
19
|
+
export function setAbout(config, screenId, about) {
|
|
20
|
+
const flow = requireFlow(config);
|
|
21
|
+
requireScreen(flow, screenId);
|
|
22
|
+
const text = about.trim();
|
|
23
|
+
return settle(config, (draft) => {
|
|
24
|
+
const live = requireFlow(draft);
|
|
25
|
+
const screen = requireScreen(live, screenId);
|
|
26
|
+
const entry = caseFor(draft, live, screen);
|
|
27
|
+
const step = entry ? partsOf(entry, live.routeKey).rest[0] : undefined;
|
|
28
|
+
if (!step)
|
|
29
|
+
throw new ConversationalFlowEditError(`“${screen.title}” has nothing to describe.`);
|
|
30
|
+
if (text)
|
|
31
|
+
step.description = text;
|
|
32
|
+
else
|
|
33
|
+
delete step.description;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether a typed message is taken here.
|
|
38
|
+
*
|
|
39
|
+
* With typing, the question carries a text field and the steps after it split:
|
|
40
|
+
* something typed goes to the router, a tap goes wherever the option says.
|
|
41
|
+
* Without, the text field goes and the tap is all that is left.
|
|
42
|
+
*/
|
|
43
|
+
export function setTypingAllowed(config, screenId, allowed) {
|
|
44
|
+
const flow = requireFlow(config);
|
|
45
|
+
const screen = requireScreen(flow, screenId);
|
|
46
|
+
const prompt = screen.prompts[0];
|
|
47
|
+
if (!prompt)
|
|
48
|
+
throw new ConversationalFlowEditError(`“${screen.title}” doesn’t ask anything.`);
|
|
49
|
+
if ((prompt.textField !== undefined) === allowed)
|
|
50
|
+
return config;
|
|
51
|
+
// The nearest router that serves this screen: a section's own, when it has one.
|
|
52
|
+
const router = routersFor(flow, screenId)[0];
|
|
53
|
+
if (allowed && !router) {
|
|
54
|
+
throw new ConversationalFlowEditError('This flow has no router, so a typed message would have nowhere to go.');
|
|
55
|
+
}
|
|
56
|
+
return settle(config, (draft) => {
|
|
57
|
+
const live = requireFlow(draft);
|
|
58
|
+
const entry = caseFor(draft, live, requireScreen(live, screenId));
|
|
59
|
+
if (!entry)
|
|
60
|
+
return;
|
|
61
|
+
const steps = asSteps(entry['steps']);
|
|
62
|
+
const { rest } = partsOf(entry, live.routeKey);
|
|
63
|
+
// Whatever the screen fetches on the way in stays exactly where it is.
|
|
64
|
+
const leading = steps.slice(0, steps.length - rest.length);
|
|
65
|
+
// A screen that asks more than one way has one question per branch, and
|
|
66
|
+
// typing is about the screen — so every branch changes together.
|
|
67
|
+
if (rest.length === 1 && rest[0]?.type === 'SWITCH') {
|
|
68
|
+
const versions = asRec(rest[0].config);
|
|
69
|
+
for (const raw of asArray(versions['cases'])) {
|
|
70
|
+
const branch = asRec(raw);
|
|
71
|
+
branch['steps'] = retell(draft, live, asSteps(branch['steps']), allowed, router?.id);
|
|
72
|
+
}
|
|
73
|
+
versions['default'] = retell(draft, live, asSteps(versions['default']), allowed, router?.id);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const [wait, ...after] = rest;
|
|
77
|
+
if (!wait)
|
|
78
|
+
return;
|
|
79
|
+
const fields = fieldsIn(wait);
|
|
80
|
+
if (!allowed) {
|
|
81
|
+
const field = fields.findIndex((f) => f['type'] === 'text' || f['type'] === 'textarea');
|
|
82
|
+
if (field >= 0)
|
|
83
|
+
fields.splice(field, 1);
|
|
84
|
+
// What the tap did is all that is left of the branch that split them.
|
|
85
|
+
const gate = after[0];
|
|
86
|
+
const tapped = gate?.type === 'CONDITIONAL' ? asSteps(asRec(gate.config)['if_false']) : after;
|
|
87
|
+
entry['steps'] = [...leading, wait, ...tapped];
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const name = textFieldName(live);
|
|
91
|
+
fields.push({ type: 'text', name, label: 'Or type your question' });
|
|
92
|
+
const typed = `{{steps.${wait.id}.output.resumeData.data.${name}}}`;
|
|
93
|
+
const gate = {
|
|
94
|
+
id: `typed_${screenId}`,
|
|
95
|
+
type: 'CONDITIONAL',
|
|
96
|
+
config: {
|
|
97
|
+
condition: { all: [{ variable: typed, operator: 'exists' }, { variable: typed, operator: 'neq', value: '' }] },
|
|
98
|
+
if_true: [
|
|
99
|
+
jumpStep(`typed_go_${screenId}`, live.rootScreen, {
|
|
100
|
+
...carriedTo(draft, live, router.id),
|
|
101
|
+
[textKeyOf(draft, live)]: typed,
|
|
102
|
+
}),
|
|
103
|
+
],
|
|
104
|
+
if_false: after,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
entry['steps'] = [...leading, wait, gate];
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* One way of asking, with typing turned on or off. The question keeps whatever
|
|
112
|
+
* it says and offers; only what happens to a typed message changes.
|
|
113
|
+
*/
|
|
114
|
+
function retell(draft, flow, asked, allowed, routerId) {
|
|
115
|
+
const [wait, ...after] = asked;
|
|
116
|
+
if (!wait)
|
|
117
|
+
return asked;
|
|
118
|
+
const fields = fieldsIn(wait);
|
|
119
|
+
if (!allowed) {
|
|
120
|
+
const at = fields.findIndex((f) => f['type'] === 'text' || f['type'] === 'textarea');
|
|
121
|
+
if (at >= 0)
|
|
122
|
+
fields.splice(at, 1);
|
|
123
|
+
// What the tap did is all that is left of the branch that split them.
|
|
124
|
+
const gate = after[0];
|
|
125
|
+
const tapped = gate?.type === 'CONDITIONAL' ? asSteps(asRec(gate.config)['if_false']) : after;
|
|
126
|
+
return [wait, ...tapped];
|
|
127
|
+
}
|
|
128
|
+
if (!routerId)
|
|
129
|
+
return asked;
|
|
130
|
+
const name = textFieldName(flow);
|
|
131
|
+
fields.push({ type: 'text', name, label: 'Or type your question' });
|
|
132
|
+
const typed = `{{steps.${wait.id}.output.resumeData.data.${name}}}`;
|
|
133
|
+
return [
|
|
134
|
+
wait,
|
|
135
|
+
{
|
|
136
|
+
id: `typed_${wait.id}`,
|
|
137
|
+
type: 'CONDITIONAL',
|
|
138
|
+
config: {
|
|
139
|
+
condition: { all: [{ variable: typed, operator: 'exists' }, { variable: typed, operator: 'neq', value: '' }] },
|
|
140
|
+
if_true: [jumpStep(`typed_go_${wait.id}`, flow.rootScreen, { ...carriedTo(draft, flow, routerId), [textKeyOf(draft, flow)]: typed })],
|
|
141
|
+
if_false: after,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
// ─── Plumbing ───
|
|
147
|
+
function questionStep(config, flow, promptId) {
|
|
148
|
+
for (const screen of flow.screens) {
|
|
149
|
+
if (!screen.prompts.some((p) => p.id === promptId))
|
|
150
|
+
continue;
|
|
151
|
+
const entry = caseFor(config, flow, screen);
|
|
152
|
+
const wait = entry ? stepIn(partsOf(entry, flow.routeKey).rest, promptId) : undefined;
|
|
153
|
+
if (wait)
|
|
154
|
+
return wait;
|
|
155
|
+
}
|
|
156
|
+
throw new ConversationalFlowEditError(`There is no question “${promptId}”.`);
|
|
157
|
+
}
|
|
158
|
+
function fieldsIn(wait) {
|
|
159
|
+
const form = asRec(wait.config['form']);
|
|
160
|
+
if (!Array.isArray(form['fields']))
|
|
161
|
+
form['fields'] = [];
|
|
162
|
+
wait.config['form'] = form;
|
|
163
|
+
return form['fields'];
|
|
164
|
+
}
|
|
165
|
+
/** The name this flow already gives its text field, so a screen matches the rest. */
|
|
166
|
+
function textFieldName(flow) {
|
|
167
|
+
for (const screen of flow.screens) {
|
|
168
|
+
for (const prompt of screen.prompts)
|
|
169
|
+
if (prompt.textField)
|
|
170
|
+
return prompt.textField;
|
|
171
|
+
}
|
|
172
|
+
return 'message';
|
|
173
|
+
}
|
|
174
|
+
function requireScreen(flow, id) {
|
|
175
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
176
|
+
if (!screen)
|
|
177
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
178
|
+
return screen;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/prompts.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAC1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;IAClF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router: what reads a typed message and opens the screen that fits.
|
|
3
|
+
*
|
|
4
|
+
* Two things here are the author's, and nothing else is. Which service answers,
|
|
5
|
+
* and what they want it told — and, per screen or per section, which router the
|
|
6
|
+
* typing goes to.
|
|
7
|
+
*
|
|
8
|
+
* What a router may *choose* is never edited: it is the screens its own frame
|
|
9
|
+
* holds, which `settle` writes after every change. So a router in the
|
|
10
|
+
* conversation's frame reaches the whole flow and one inside a section reaches
|
|
11
|
+
* that section, without anything having to say so.
|
|
12
|
+
*/
|
|
13
|
+
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
14
|
+
import { type RouterMode } from './build.js';
|
|
15
|
+
export interface RouterService {
|
|
16
|
+
/** The model id the classifier asks for. */
|
|
17
|
+
model?: string;
|
|
18
|
+
/** The credential holding where that service lives and the key it takes. */
|
|
19
|
+
credentialName?: string | null;
|
|
20
|
+
/** Below this it opens the first screen instead of guessing; `null` to stop. */
|
|
21
|
+
minConfidence?: number | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Which service decides, for every router in the flow.
|
|
25
|
+
*
|
|
26
|
+
* One flow, one service: a router in a section asks the same model as the one
|
|
27
|
+
* at the top, because the choice is about the deployment and not about the
|
|
28
|
+
* screens being chosen between.
|
|
29
|
+
*/
|
|
30
|
+
export declare function setRouterService(config: WorkflowConfig, service: RouterService): WorkflowConfig;
|
|
31
|
+
/**
|
|
32
|
+
* What the author wants this router told, on top of the screens themselves.
|
|
33
|
+
* Kept on the step's description, and put first in what it is asked.
|
|
34
|
+
*/
|
|
35
|
+
export declare function setRouterGuidance(config: WorkflowConfig, screenId: string, guidance: string): WorkflowConfig;
|
|
36
|
+
export type { RouterMode } from './build.js';
|
|
37
|
+
/**
|
|
38
|
+
* Change what answers this router, keeping everything about it that is the
|
|
39
|
+
* author's: its guidance, and the screens it may open — which are its frame's,
|
|
40
|
+
* not its own.
|
|
41
|
+
*
|
|
42
|
+
* The step keeps its id, so the jump that carries its answer only has to name
|
|
43
|
+
* the answer differently: a class, or a field of what the agent replied.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setRouterMode(config: WorkflowConfig, screenId: string, wanted: RouterMode): WorkflowConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Send what is typed on one screen to a particular router.
|
|
48
|
+
*
|
|
49
|
+
* This is the exception, made screen by screen: a screen inside Payments may keep
|
|
50
|
+
* its typing in Payments while its neighbour asks the router at the top. Only a
|
|
51
|
+
* router whose frame encloses the screen can be reached from it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function setTypedRouter(config: WorkflowConfig, screenId: string, routerId: string): WorkflowConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Keep typed messages inside a section — or stop keeping them there.
|
|
56
|
+
*
|
|
57
|
+
* On: the section gets a router of its own, in its own frame, asking the same
|
|
58
|
+
* service as the flow's, and every screen inside it sends its typing there. Off:
|
|
59
|
+
* that router goes, and those screens fall back to the nearest one outside.
|
|
60
|
+
*
|
|
61
|
+
* It is a bulk action rather than a rule, which is what makes an exception
|
|
62
|
+
* possible at all: a total derivation would erase one on the next edit.
|
|
63
|
+
*/
|
|
64
|
+
export declare function scopeRouter(config: WorkflowConfig, sectionId: string, on: boolean): WorkflowConfig;
|
|
65
|
+
//# sourceMappingURL=routers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routers.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/routers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AASrE,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGtF,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,cAAc,CA2B/F;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAU5G;AAeD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,CAuB1G;AAID;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAgBzG;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,cAAc,CA6ClG"}
|