@xyne/workflow-sdk 3.2.57 → 3.2.59
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/connectors/builtin/steps/wait-for-human.step.d.ts +6 -0
- package/dist/connectors/builtin/steps/wait-for-human.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/wait-for-human.step.js +2 -0
- package/dist/connectors/builtin/steps/wait-for-human.step.js.map +1 -1
- package/dist/conversational-flow/edit/build.js +10 -1
- package/dist/conversational-flow/edit/build.js.map +1 -1
- package/dist/conversational-flow/edit/kinds.d.ts.map +1 -1
- package/dist/conversational-flow/edit/kinds.js +7 -0
- package/dist/conversational-flow/edit/kinds.js.map +1 -1
- package/dist/conversational-flow/edit/options.d.ts +8 -2
- package/dist/conversational-flow/edit/options.d.ts.map +1 -1
- package/dist/conversational-flow/edit/options.js +61 -18
- package/dist/conversational-flow/edit/options.js.map +1 -1
- package/dist/conversational-flow/edit/questions.d.ts +55 -23
- package/dist/conversational-flow/edit/questions.d.ts.map +1 -1
- package/dist/conversational-flow/edit/questions.js +219 -144
- package/dist/conversational-flow/edit/questions.js.map +1 -1
- package/dist/conversational-flow/edit/screens.d.ts +17 -1
- package/dist/conversational-flow/edit/screens.d.ts.map +1 -1
- package/dist/conversational-flow/edit/screens.js +24 -10
- package/dist/conversational-flow/edit/screens.js.map +1 -1
- package/dist/conversational-flow/edit/versions.js +7 -0
- package/dist/conversational-flow/edit/versions.js.map +1 -1
- package/dist/conversational-flow/index.d.ts +4 -2
- package/dist/conversational-flow/index.d.ts.map +1 -1
- package/dist/conversational-flow/index.js +4 -1
- package/dist/conversational-flow/index.js.map +1 -1
- package/dist/conversational-flow/prompt.d.ts +11 -1
- package/dist/conversational-flow/prompt.d.ts.map +1 -1
- package/dist/conversational-flow/prompt.js +79 -13
- package/dist/conversational-flow/prompt.js.map +1 -1
- package/dist/conversational-flow/questions.d.ts +15 -20
- package/dist/conversational-flow/questions.d.ts.map +1 -1
- package/dist/conversational-flow/questions.js +75 -49
- package/dist/conversational-flow/questions.js.map +1 -1
- package/dist/conversational-flow/read.d.ts.map +1 -1
- package/dist/conversational-flow/read.js +19 -5
- package/dist/conversational-flow/read.js.map +1 -1
- package/dist/conversational-flow/server/conversation-service.d.ts.map +1 -1
- package/dist/conversational-flow/server/conversation-service.js +19 -3
- package/dist/conversational-flow/server/conversation-service.js.map +1 -1
- package/dist/conversational-flow/settle.js +8 -3
- package/dist/conversational-flow/settle.js.map +1 -1
- package/dist/conversational-flow/shape.d.ts +6 -0
- package/dist/conversational-flow/shape.d.ts.map +1 -1
- package/dist/conversational-flow/shape.js +26 -1
- package/dist/conversational-flow/shape.js.map +1 -1
- package/dist/conversational-flow/turn.d.ts +39 -0
- package/dist/conversational-flow/turn.d.ts.map +1 -1
- package/dist/conversational-flow/turn.js +118 -11
- package/dist/conversational-flow/turn.js.map +1 -1
- package/dist/conversational-flow/types.d.ts +87 -1
- package/dist/conversational-flow/types.d.ts.map +1 -1
- package/dist/conversational-flow/types.js +21 -1
- package/dist/conversational-flow/types.js.map +1 -1
- package/dist/persistence/types.d.ts +17 -0
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts +26 -3
- package/dist/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +60 -28
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,188 +1,263 @@
|
|
|
1
|
-
import { asArray, asRec,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { asArray, asRec, str } from '../json.js';
|
|
2
|
+
import { sectionCaseFor } from '../locate.js';
|
|
3
|
+
import { ANSWER_KEY, formFor } from '../questions.js';
|
|
4
|
+
import { frameFor } from './cases.js';
|
|
5
|
+
import { newScreenSteps, offerOn, refuseAsAParent } from './screens.js';
|
|
6
|
+
import { carriedTo, inheritedInput } from '../rounds.js';
|
|
4
7
|
import { ConversationalFlowEditError, requireFlow, settle } from '../settle.js';
|
|
5
|
-
import { partsOf,
|
|
6
|
-
import {
|
|
8
|
+
import { cycleStep, jumpStep, partsOf, screenCase, sectionCase, switchStep } from '../shape.js';
|
|
9
|
+
import { setWayBack, waysBack } from './options.js';
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* Add a screen whose whole purpose is to ask for something.
|
|
12
|
+
*
|
|
13
|
+
* It is a frame with one screen inside it and nothing of its own to ask twice:
|
|
14
|
+
* the question sits before the frame, so whatever they answer is in scope for
|
|
15
|
+
* the screen inside and everything below it, and its own case only moves on.
|
|
16
|
+
* That is why it is passed through once rather than returned to.
|
|
11
17
|
*/
|
|
12
|
-
export function
|
|
18
|
+
export function addInputScreen(config, args) {
|
|
13
19
|
const flow = requireFlow(config);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const parent = requireScreen(flow, args.parent);
|
|
21
|
+
refuseAsAParent(parent);
|
|
22
|
+
const title = args.title.trim();
|
|
23
|
+
if (!title)
|
|
24
|
+
throw new ConversationalFlowEditError('A screen needs a name.');
|
|
25
|
+
const taken = new Set(flow.screens.map((s) => s.id));
|
|
26
|
+
const screenId = unique(slug(title), taken);
|
|
27
|
+
taken.add(screenId);
|
|
28
|
+
const nextTitle = args.next?.title?.trim() || 'What happens next';
|
|
29
|
+
const nextId = unique(slug(nextTitle), taken);
|
|
30
|
+
// The frame and the screen inside it are written together, because neither is
|
|
31
|
+
// a screen on its own: the question needs somewhere to let them in to, and
|
|
32
|
+
// what is inside needs the question in front of it.
|
|
33
|
+
let next = settle(config, (draft) => {
|
|
28
34
|
const live = requireFlow(draft);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const inside = screenCase(nextId, nextTitle, newScreenSteps(draft, live, nextId, nextTitle, requireScreen(live, args.parent), {
|
|
36
|
+
title: nextTitle,
|
|
37
|
+
parent: args.parent,
|
|
38
|
+
...(args.next?.type ? { type: args.next.type } : {}),
|
|
39
|
+
}), live.routeKey);
|
|
40
|
+
frameFor(draft, live, args.parent).push(sectionCase([screenId, nextId], title, [
|
|
41
|
+
cycleStep(screenId, inheritedInput(draft, live), [
|
|
42
|
+
switchStep(`${screenId}_route`, [
|
|
43
|
+
// Answering is the way on, so its own case has only to move on.
|
|
44
|
+
screenCase(screenId, title, [jumpStep(`into_${screenId}`, screenId, carriedTo(draft, live, nextId))], live.routeKey),
|
|
45
|
+
inside,
|
|
46
|
+
], [jumpStep(`${screenId}_unknown`, screenId, carriedTo(draft, live, nextId))]),
|
|
47
|
+
]),
|
|
48
|
+
], live.routeKey));
|
|
49
|
+
offerOn(draft, requireFlow(draft), args.parent, { label: title, value: screenId });
|
|
34
50
|
});
|
|
51
|
+
next = setWayBack(next, nextId, true);
|
|
52
|
+
next = setQuestion(next, screenId, args.asks ?? []);
|
|
53
|
+
if (args.purpose)
|
|
54
|
+
next = setQuestionPurpose(next, screenId, args.purpose);
|
|
55
|
+
return { config: next, screenId, nextId };
|
|
35
56
|
}
|
|
36
57
|
/**
|
|
37
|
-
*
|
|
38
|
-
* several. It may quote whatever the frames around it fetched or asked for.
|
|
58
|
+
* Ask for these, in this order, on the way into `screenId`.
|
|
39
59
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
60
|
+
* An empty list is a question with nothing to fill in yet, not the absence of
|
|
61
|
+
* one: an input screen always asks, because that is what it is for — at the
|
|
62
|
+
* least, which way on they are taking.
|
|
42
63
|
*/
|
|
43
|
-
export function
|
|
64
|
+
export function setQuestion(config, screenId, asks) {
|
|
44
65
|
const flow = requireFlow(config);
|
|
45
|
-
const asked = flow
|
|
46
|
-
if (asked?.when === 'here') {
|
|
47
|
-
throw new ConversationalFlowEditError('This is asked on the screen itself, so what the screen says is what asks.');
|
|
48
|
-
}
|
|
66
|
+
const asked = checked(flow, requireAskable(flow, screenId), asks);
|
|
49
67
|
return settle(config, (draft) => {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
const live = requireFlow(draft);
|
|
69
|
+
const screen = requireAskable(live, screenId);
|
|
70
|
+
const section = sectionCaseFor(draft, live, screen);
|
|
71
|
+
if (!section)
|
|
72
|
+
throw new ConversationalFlowEditError(`“${screen.title}” has no frame to ask on the way into.`);
|
|
73
|
+
// The array has to be the one the config holds, since it is spliced below.
|
|
74
|
+
const steps = asArray(section['steps']);
|
|
75
|
+
section['steps'] = steps;
|
|
76
|
+
// Out with whatever it asked before: this list is the whole question.
|
|
77
|
+
const before = partsOf(section, live.routeKey).asking;
|
|
78
|
+
const said = before ? asArray(asRec(before.step.config)['prompt']) : [];
|
|
79
|
+
const purpose = before ? str(asRec(before.step.config)['purpose']) : undefined;
|
|
80
|
+
const waitId = before?.step.id ?? unique(`ask_${screenId}_entry`, takenIds(draft));
|
|
81
|
+
const choice = choiceFieldName(live);
|
|
82
|
+
const form = formFor(asked);
|
|
83
|
+
// Answering is how they go on — the screen inside opens by itself — so the
|
|
84
|
+
// only thing to offer is not answering. An author may take even that away.
|
|
85
|
+
const ways = waysBack(live, screen);
|
|
86
|
+
if (ways.length > 0)
|
|
87
|
+
form['fields'].push({ type: 'select', name: choice, label: 'Or', options: ways });
|
|
88
|
+
const at = before ? steps.findIndex((step) => asRec(step)['id'] === before.step.id) : steps.findIndex(isCycleStep);
|
|
89
|
+
steps.splice(at < 0 ? steps.length : at, before ? (before.guard ? 2 : 1) : 0, { id: waitId, type: 'WAIT', config: { mode: 'approval', prompt: said, form, ...(purpose ? { purpose } : {}) } }, ...(ways.length > 0 ? [leaving(draft, live, waitId, choice)] : []));
|
|
54
90
|
});
|
|
55
91
|
}
|
|
56
|
-
// ─── Writing it where it belongs ───
|
|
57
92
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
93
|
+
* What its answers are for, in a word the people reading the runs will know —
|
|
94
|
+
* `feedback`, or whatever this flow calls its own kind of question. Empty takes
|
|
95
|
+
* the label off again.
|
|
60
96
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
97
|
+
* It is never read by the flow: it is for whoever receives the answers, which
|
|
98
|
+
* is why it is a word rather than a list this layer polices.
|
|
63
99
|
*/
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
100
|
+
export function setQuestionPurpose(config, screenId, purpose) {
|
|
101
|
+
const flow = requireFlow(config);
|
|
102
|
+
requireAskable(flow, screenId);
|
|
103
|
+
const word = purpose.trim();
|
|
104
|
+
return settle(config, (draft) => {
|
|
105
|
+
const live = requireFlow(draft);
|
|
106
|
+
const way = askingOn(draft, live, requireAskable(live, screenId));
|
|
107
|
+
if (!way)
|
|
108
|
+
throw new ConversationalFlowEditError('This screen doesn’t ask for anything.');
|
|
109
|
+
if (word)
|
|
110
|
+
way.step.config['purpose'] = word;
|
|
111
|
+
else
|
|
112
|
+
delete way.step.config['purpose'];
|
|
113
|
+
});
|
|
74
114
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
config: { mode: 'approval', prompt: [], form: formFor(asks) },
|
|
115
|
+
/**
|
|
116
|
+
* What it says while asking — one message, or several. It may quote whatever the
|
|
117
|
+
* frames around it fetched, since those ran before it.
|
|
118
|
+
*/
|
|
119
|
+
export function setQuestionSays(config, screenId, says) {
|
|
120
|
+
const flow = requireFlow(config);
|
|
121
|
+
requireAskable(flow, screenId);
|
|
122
|
+
// Written as given, as a screen's own wording is: the list is the whole of
|
|
123
|
+
// what it says, and an empty line is a box waiting to be typed in rather
|
|
124
|
+
// than a line to throw away.
|
|
125
|
+
const lines = [...says];
|
|
126
|
+
return settle(config, (draft) => {
|
|
127
|
+
const live = requireFlow(draft);
|
|
128
|
+
const way = askingOn(draft, live, requireAskable(live, screenId));
|
|
129
|
+
if (!way)
|
|
130
|
+
throw new ConversationalFlowEditError('This screen doesn’t ask for anything on the way in.');
|
|
131
|
+
way.step.config['prompt'] = lines;
|
|
93
132
|
});
|
|
94
133
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
if (first?.type === 'WAIT')
|
|
101
|
-
return [first];
|
|
102
|
-
if (rest.length !== 1 || first?.type !== 'SWITCH')
|
|
103
|
-
return [];
|
|
104
|
-
const config = asRec(first.config);
|
|
105
|
-
return [...asArray(config['cases']).map((c) => asSteps(asRec(c)['steps'])), asSteps(config['default'])]
|
|
106
|
-
.map((steps) => steps[0])
|
|
107
|
-
.filter((step) => step?.type === 'WAIT');
|
|
134
|
+
// ─── Plumbing ───
|
|
135
|
+
/** The question a screen asks on the way in, live, so a caller can change it. */
|
|
136
|
+
function askingOn(draft, flow, screen) {
|
|
137
|
+
const section = sectionCaseFor(draft, flow, screen);
|
|
138
|
+
return section ? partsOf(section, flow.routeKey).asking : undefined;
|
|
108
139
|
}
|
|
109
|
-
/**
|
|
110
|
-
function
|
|
111
|
-
return
|
|
140
|
+
/** Whether a step is the frame a question is asked in front of. */
|
|
141
|
+
function isCycleStep(step) {
|
|
142
|
+
return asRec(step)['type'] === 'CYCLE';
|
|
112
143
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
144
|
+
/**
|
|
145
|
+
* The branch that lets them leave instead of answering.
|
|
146
|
+
*
|
|
147
|
+
* Nothing picked falls through to the frame, which is how answering opens the
|
|
148
|
+
* screen inside: that is what the question is for, so it needs no button.
|
|
149
|
+
*/
|
|
150
|
+
function leaving(draft, flow, waitId, choice) {
|
|
151
|
+
const ref = `{{steps.${waitId}.output.resumeData.data.${choice}}}`;
|
|
152
|
+
return {
|
|
153
|
+
id: `leave_${waitId}`,
|
|
154
|
+
type: 'CONDITIONAL',
|
|
155
|
+
config: {
|
|
156
|
+
condition: {
|
|
157
|
+
all: [
|
|
158
|
+
{ variable: ref, operator: 'exists' },
|
|
159
|
+
{ variable: ref, operator: 'neq', value: '' },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
if_true: [
|
|
163
|
+
jumpStep(`left_${waitId}`, flow.rootScreen, { ...carriedTo(draft, flow, flow.rootScreen), [flow.routeKey]: ref }),
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/** How a refusal says which kind is already asked for. */
|
|
169
|
+
const VERB = { text: 'type', choice: 'pick', attachment: 'attach' };
|
|
170
|
+
/** What this flow calls the field a question is navigated by, so a new one matches. */
|
|
171
|
+
function choiceFieldName(flow) {
|
|
172
|
+
for (const screen of flow.screens) {
|
|
173
|
+
for (const prompt of screen.prompts)
|
|
174
|
+
if (prompt.choiceField)
|
|
175
|
+
return prompt.choiceField;
|
|
125
176
|
}
|
|
177
|
+
return 'choice';
|
|
126
178
|
}
|
|
127
|
-
/**
|
|
128
|
-
|
|
179
|
+
/**
|
|
180
|
+
* The fields as they will be written: labelled, one of each kind, and named by
|
|
181
|
+
* the kind rather than by the author — so the same answer is called the same
|
|
182
|
+
* thing in every flow. A row with no label is one nobody has filled in.
|
|
183
|
+
*/
|
|
184
|
+
function checked(flow, screen, asks) {
|
|
185
|
+
const seen = new Set();
|
|
129
186
|
const out = [];
|
|
130
187
|
for (const ask of asks) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
if (ask.kind
|
|
137
|
-
throw new ConversationalFlowEditError(
|
|
138
|
-
}
|
|
139
|
-
const name = slug(ask.name);
|
|
140
|
-
if (!name) {
|
|
141
|
-
throw new ConversationalFlowEditError('Everything asked for needs a name — it is what the answer is called afterwards.');
|
|
188
|
+
const label = ask.label.trim();
|
|
189
|
+
if (label === '')
|
|
190
|
+
continue;
|
|
191
|
+
// One of each kind, because the key is the kind: two things to pick would
|
|
192
|
+
// both be `selectedOptions`, and the second would overwrite the first.
|
|
193
|
+
if (seen.has(ask.kind)) {
|
|
194
|
+
throw new ConversationalFlowEditError(`It already asks for something to ${VERB[ask.kind]}; a question asks for one of each.`);
|
|
142
195
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const choices = ask.kind === 'choice' ? ask.choices.map((c) => c.trim()).filter(Boolean) : [];
|
|
147
|
-
if (ask.kind === 'choice' && choices.length === 0) {
|
|
148
|
-
throw new ConversationalFlowEditError('A choice needs something to pick from.');
|
|
196
|
+
seen.add(ask.kind);
|
|
197
|
+
if (ask.required && waysBack(flow, screen).length === 0) {
|
|
198
|
+
throw new ConversationalFlowEditError(`“${label}” can’t be required here: there would be no way past it.`);
|
|
149
199
|
}
|
|
150
200
|
out.push({
|
|
151
|
-
|
|
152
|
-
name,
|
|
153
|
-
label
|
|
201
|
+
...ask,
|
|
202
|
+
name: ANSWER_KEY[ask.kind],
|
|
203
|
+
label,
|
|
154
204
|
required: ask.required === true,
|
|
155
|
-
choices,
|
|
156
|
-
multiple: ask.
|
|
205
|
+
choices: ask.choices ?? [],
|
|
206
|
+
multiple: ask.multiple === true,
|
|
157
207
|
});
|
|
158
208
|
}
|
|
159
209
|
return out;
|
|
160
210
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Only an input screen asks on the way in.
|
|
213
|
+
*
|
|
214
|
+
* A screen that also has a question of its own would ask twice — once on the way
|
|
215
|
+
* in and again every time someone came back to it — so asking belongs to the
|
|
216
|
+
* kind whose whole purpose is to ask, and {@link addInputScreen} is how one is made.
|
|
217
|
+
*/
|
|
218
|
+
function requireAskable(flow, id) {
|
|
219
|
+
const screen = flow.screens.find((s) => s.id === id);
|
|
220
|
+
if (!screen)
|
|
221
|
+
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
222
|
+
if (screen.kind !== 'input') {
|
|
223
|
+
throw new ConversationalFlowEditError(`“${screen.title}” isn’t a screen that asks for something — add one inside it instead.`);
|
|
224
|
+
}
|
|
225
|
+
return screen;
|
|
169
226
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
227
|
+
function takenIds(config) {
|
|
228
|
+
const out = new Set();
|
|
229
|
+
const walk = (steps) => {
|
|
230
|
+
for (const raw of steps) {
|
|
231
|
+
const step = asRec(raw);
|
|
232
|
+
if (typeof step['id'] === 'string')
|
|
233
|
+
out.add(step['id']);
|
|
234
|
+
for (const value of Object.values(asRec(step['config']))) {
|
|
235
|
+
if (!Array.isArray(value))
|
|
236
|
+
continue;
|
|
237
|
+
walk(value);
|
|
238
|
+
for (const entry of value)
|
|
239
|
+
walk(asArray(asRec(entry)['steps']));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
walk(asArray(config.steps));
|
|
244
|
+
return out;
|
|
173
245
|
}
|
|
174
|
-
/**
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
const id = n === 1 ? base : `${base}_${String(n)}`;
|
|
178
|
-
if (!stepIn(asArray(draft.steps), id))
|
|
179
|
-
return id;
|
|
180
|
-
}
|
|
246
|
+
/** An id from a title, as every other screen gets one. */
|
|
247
|
+
function slug(title) {
|
|
248
|
+
return title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'screen';
|
|
181
249
|
}
|
|
250
|
+
/** A screen by id, or a refusal naming it. */
|
|
182
251
|
function requireScreen(flow, id) {
|
|
183
252
|
const screen = flow.screens.find((s) => s.id === id);
|
|
184
253
|
if (!screen)
|
|
185
254
|
throw new ConversationalFlowEditError(`There is no screen “${id}”.`);
|
|
186
255
|
return screen;
|
|
187
256
|
}
|
|
257
|
+
function unique(base, taken) {
|
|
258
|
+
let name = base;
|
|
259
|
+
for (let n = 2; taken.has(name); n += 1)
|
|
260
|
+
name = `${base}_${n}`;
|
|
261
|
+
return name;
|
|
262
|
+
}
|
|
188
263
|
//# sourceMappingURL=questions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.js","sourceRoot":"","sources":["../../../src/conversational-flow/edit/questions.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAAsB,EACtB,QAAgB,EAChB,IAA8B,EAC9B,IAAgB;IAEhB,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,MA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M;QAAE,MAAM,IAAI,2BAA2B,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAClF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,KAAkB;IAC9C,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;QAAE,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* aimed, the headings — is `settle`'s, and runs after every one of these.
|
|
11
11
|
*/
|
|
12
12
|
import type { WorkflowConfig } from '../../types/workflow-config.js';
|
|
13
|
+
import { type Rec } from '../json.js';
|
|
13
14
|
import type { NewScreenType } from './kinds.js';
|
|
14
|
-
import type { ConversationalFlow } from '../types.js';
|
|
15
|
+
import type { ConversationalFlow, Screen } from '../types.js';
|
|
15
16
|
export interface NewScreen {
|
|
16
17
|
title: string;
|
|
17
18
|
/** The screen it goes inside. */
|
|
@@ -103,4 +104,19 @@ export declare function emptyScreen(config: WorkflowConfig, screenId: string, wh
|
|
|
103
104
|
* it is refused: they would go with it, and that is a different decision.
|
|
104
105
|
*/
|
|
105
106
|
export declare function removeScreen(config: WorkflowConfig, screenId: string): WorkflowConfig;
|
|
107
|
+
/**
|
|
108
|
+
* What a new screen is made of. A screen that asks is the common case; every
|
|
109
|
+
* other kind is built the same way `setScreenType` builds it, so a screen
|
|
110
|
+
* created as a Finish and a screen turned into one are the same screen.
|
|
111
|
+
*/
|
|
112
|
+
export declare function newScreenSteps(draft: WorkflowConfig, flow: ConversationalFlow, screenId: string, title: string, parent: Screen, args: NewScreen): unknown[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether a screen can hold another, and why not when it cannot.
|
|
115
|
+
*
|
|
116
|
+
* One rule, asked by everything that puts a screen inside another, so the map,
|
|
117
|
+
* the inspector and every edit agree about where something may go.
|
|
118
|
+
*/
|
|
119
|
+
export declare function refuseAsAParent(parent: Screen): void;
|
|
120
|
+
/** Give the parent an option that opens the new screen, above its ways back. */
|
|
121
|
+
export declare function offerOn(draft: WorkflowConfig, flow: ConversationalFlow, screenId: string, option: Rec): void;
|
|
106
122
|
//# sourceMappingURL=screens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screens.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/screens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"screens.d.ts","sourceRoot":"","sources":["../../../src/conversational-flow/edit/screens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAkB,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAOtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAahD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,kFAAkF;IAClF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,GAAG;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA0B/G;AAED;;;;;;;;;;;GAW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AAM,GAAG,cAAc,CAcrF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,EAAE,CAWX;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAUpD;AAeD,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAO5G"}
|
|
@@ -17,10 +17,7 @@ import { dropOptionsTo, optionList, optionListIfAny, relabelOptionsTo, removeOpt
|
|
|
17
17
|
export function addScreen(config, args) {
|
|
18
18
|
const flow = requireFlow(config);
|
|
19
19
|
const parent = requireScreen(flow, args.parent);
|
|
20
|
-
|
|
21
|
-
throw new ConversationalFlowEditError('A router decides where typed messages go; nothing sits inside it.');
|
|
22
|
-
if (parent.kind === 'end')
|
|
23
|
-
throw new ConversationalFlowEditError(`“${parent.title}” ends the conversation, so nothing follows it.`);
|
|
20
|
+
refuseAsAParent(parent);
|
|
24
21
|
const title = args.title.trim();
|
|
25
22
|
if (!title)
|
|
26
23
|
throw new ConversationalFlowEditError('A screen needs a name.');
|
|
@@ -293,7 +290,7 @@ export function removeScreen(config, screenId) {
|
|
|
293
290
|
* other kind is built the same way `setScreenType` builds it, so a screen
|
|
294
291
|
* created as a Finish and a screen turned into one are the same screen.
|
|
295
292
|
*/
|
|
296
|
-
function newScreenSteps(draft, flow, screenId, title, parent, args) {
|
|
293
|
+
export function newScreenSteps(draft, flow, screenId, title, parent, args) {
|
|
297
294
|
const nearest = routersFor(flow, parent.id)[0];
|
|
298
295
|
return stepsForKind(draft, flow, args.type, {
|
|
299
296
|
screenId,
|
|
@@ -305,6 +302,23 @@ function newScreenSteps(draft, flow, screenId, title, parent, args) {
|
|
|
305
302
|
...(args.agentSlug ? { agentSlug: args.agentSlug } : {}),
|
|
306
303
|
});
|
|
307
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Whether a screen can hold another, and why not when it cannot.
|
|
307
|
+
*
|
|
308
|
+
* One rule, asked by everything that puts a screen inside another, so the map,
|
|
309
|
+
* the inspector and every edit agree about where something may go.
|
|
310
|
+
*/
|
|
311
|
+
export function refuseAsAParent(parent) {
|
|
312
|
+
if (parent.kind === 'router') {
|
|
313
|
+
throw new ConversationalFlowEditError('A router decides where typed messages go; nothing sits inside it.');
|
|
314
|
+
}
|
|
315
|
+
if (parent.kind === 'end') {
|
|
316
|
+
throw new ConversationalFlowEditError(`“${parent.title}” ends the conversation, so nothing follows it.`);
|
|
317
|
+
}
|
|
318
|
+
if (parent.kind === 'input') {
|
|
319
|
+
throw new ConversationalFlowEditError(`Answering “${parent.title}” opens the one screen inside it; branch from there instead.`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
308
322
|
/** Take the option that opens `screenId` off `holderId`, and hand it back. */
|
|
309
323
|
function takeOptionOff(draft, flow, holderId, screenId) {
|
|
310
324
|
const holder = flow.screens.find((s) => s.id === holderId);
|
|
@@ -321,13 +335,13 @@ function takeOptionOff(draft, flow, holderId, screenId) {
|
|
|
321
335
|
return undefined;
|
|
322
336
|
}
|
|
323
337
|
/** Give the parent an option that opens the new screen, above its ways back. */
|
|
324
|
-
function offerOn(draft, flow, screenId, option) {
|
|
338
|
+
export function offerOn(draft, flow, screenId, option) {
|
|
325
339
|
const screen = requireScreen(flow, screenId);
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
340
|
+
const asking = screen.prompts[0];
|
|
341
|
+
if (!asking)
|
|
328
342
|
return;
|
|
329
|
-
const options = optionList(draft, flow, screen,
|
|
330
|
-
const firstBack =
|
|
343
|
+
const options = optionList(draft, flow, screen, asking.id);
|
|
344
|
+
const firstBack = asking.options.findIndex((o) => o.back);
|
|
331
345
|
options.splice(firstBack === -1 ? options.length : firstBack, 0, option);
|
|
332
346
|
}
|
|
333
347
|
// ─── Plumbing ───
|