@xyne/workflow-sdk 3.2.47 → 3.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/host-agent-step.d.ts +2 -2
- 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/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 +20 -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
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { allStepIds, asArray, asRec, asSteps, caseOf, clone, ConversationalFlowEditError, findStep, mutate, prepLength, requireFlow, list, requireScreen, slug, uniqueName, walk, } from './internals.js';
|
|
2
|
-
import { addDerivedLookup, guardFor, lookupRef } from './lookups.js';
|
|
3
|
-
import { derivedLookupId } from './read.js';
|
|
4
|
-
import { settle } from './settle.js';
|
|
5
|
-
import { HTTP_STEP_TYPE } from './types.js';
|
|
6
|
-
/** What this layer will write into a case. Anything else is somebody's typo. */
|
|
7
|
-
const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD']);
|
|
8
|
-
/** How a remembered answer is quoted: `{{steps.__loop.output.input.refund.status}}`. */
|
|
9
|
-
export function memoryRef(key, path = '') {
|
|
10
|
-
return `{{steps.__loop.output.input.${key}${path ? `.${path}` : ''}}}`;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Add a call the screen makes before it speaks. Later ones can quote earlier
|
|
14
|
-
* ones. Returns the id it was given, so the caller can open it.
|
|
15
|
-
*/
|
|
16
|
-
export function addLookup(config, screenId, draft) {
|
|
17
|
-
const flow = requireFlow(config);
|
|
18
|
-
const screen = requireScreen(flow, screenId);
|
|
19
|
-
if (screen.kind === 'router') {
|
|
20
|
-
throw new ConversationalFlowEditError('A router only decides where a typed message goes; it has nothing to look up.');
|
|
21
|
-
}
|
|
22
|
-
const request = checked(draft.request);
|
|
23
|
-
const title = draft.title.trim();
|
|
24
|
-
let lookupId = '';
|
|
25
|
-
const next = mutate(config, (d) => {
|
|
26
|
-
const entry = caseOf(d, screenId);
|
|
27
|
-
const steps = asArray(entry['steps']);
|
|
28
|
-
lookupId = uniqueName(slug(title || 'lookup'), allStepIds(d));
|
|
29
|
-
steps.splice(prepLength(screen), 0, {
|
|
30
|
-
id: lookupId,
|
|
31
|
-
type: HTTP_STEP_TYPE,
|
|
32
|
-
...(title ? { title } : {}),
|
|
33
|
-
config: request,
|
|
34
|
-
});
|
|
35
|
-
entry['steps'] = steps;
|
|
36
|
-
});
|
|
37
|
-
return { config: next, lookupId };
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Rewrite a lookup. The request replaces what was there — the editor holds the
|
|
41
|
-
* whole request, so merging halves of two would be guesswork — while where a
|
|
42
|
-
* failed call goes is `setLookupFallback`'s and is left alone.
|
|
43
|
-
*
|
|
44
|
-
* Every copy of it on a screen that shows its answer is rewritten with it.
|
|
45
|
-
*/
|
|
46
|
-
export function setLookup(config, lookupId, draft) {
|
|
47
|
-
const flow = requireFlow(config);
|
|
48
|
-
authoredOf(flow, lookupId);
|
|
49
|
-
const request = checked(draft.request);
|
|
50
|
-
const title = draft.title.trim();
|
|
51
|
-
// `settle`, so every screen showing this answer gets the edited request too.
|
|
52
|
-
return settle(config, (d) => {
|
|
53
|
-
const step = findStep(d, lookupId, HTTP_STEP_TYPE);
|
|
54
|
-
step.config = request;
|
|
55
|
-
if (title)
|
|
56
|
-
step.title = title;
|
|
57
|
-
else
|
|
58
|
-
delete step.title;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/** Remove a lookup, the guard that said where a failed one goes, and its name. */
|
|
62
|
-
export function removeLookup(config, lookupId) {
|
|
63
|
-
const flow = requireFlow(config);
|
|
64
|
-
const { screen, lookup } = authoredOf(flow, lookupId);
|
|
65
|
-
const shown = shownOn(flow, lookupId);
|
|
66
|
-
if (shown.length > 0) {
|
|
67
|
-
throw new ConversationalFlowEditError(`${list(shown.map((s) => s.title))} show what “${lookup.title}” finds. Take it out of their wording first.`);
|
|
68
|
-
}
|
|
69
|
-
// Its name is part of it: dropping the call drops what it filled.
|
|
70
|
-
const base = lookup.remembers === undefined ? config : setLookupMemory(config, lookupId, false);
|
|
71
|
-
return mutate(base, (d) => {
|
|
72
|
-
const entry = caseOf(d, screen.id);
|
|
73
|
-
const steps = asArray(entry['steps']);
|
|
74
|
-
steps.splice(indexOf(steps, lookupId), lookup.onFail === undefined ? 1 : 2);
|
|
75
|
-
entry['steps'] = steps;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Where to send them when the call does not come back — or `null` to drop the
|
|
80
|
-
* fallback, after which an unanswered call fails the conversation.
|
|
81
|
-
*/
|
|
82
|
-
export function setLookupFallback(config, lookupId, screenId) {
|
|
83
|
-
const flow = requireFlow(config);
|
|
84
|
-
const { screen, lookup } = authoredOf(flow, lookupId);
|
|
85
|
-
if (screenId !== null) {
|
|
86
|
-
const target = requireScreen(flow, screenId);
|
|
87
|
-
if (target.id === screen.id) {
|
|
88
|
-
throw new ConversationalFlowEditError(`“${screen.title}” can’t fall back to itself — it would look the same thing up again.`);
|
|
89
|
-
}
|
|
90
|
-
if (target.kind === 'router') {
|
|
91
|
-
throw new ConversationalFlowEditError('A router reads typed messages. Send a failed lookup to a screen that says something.');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return settle(config, (d) => {
|
|
95
|
-
const entry = caseOf(d, screen.id);
|
|
96
|
-
const steps = asArray(entry['steps']);
|
|
97
|
-
const at = indexOf(steps, lookupId);
|
|
98
|
-
const step = asRec(steps[at]);
|
|
99
|
-
const had = lookup.onFail !== undefined;
|
|
100
|
-
if (screenId === null) {
|
|
101
|
-
if (had)
|
|
102
|
-
steps.splice(at + 1, 1);
|
|
103
|
-
const settings = asRec(step['settings']);
|
|
104
|
-
delete settings['onError'];
|
|
105
|
-
if (Object.keys(settings).length > 0)
|
|
106
|
-
step['settings'] = settings;
|
|
107
|
-
else
|
|
108
|
-
delete step['settings'];
|
|
109
|
-
entry['steps'] = steps;
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
// Without this the run stops where the call failed and the conversation is
|
|
113
|
-
// simply gone; with it, the guard below decides what the person sees.
|
|
114
|
-
step['settings'] = { ...asRec(step['settings']), onError: 'continue' };
|
|
115
|
-
// Rewriting an existing guard keeps its ids, so nothing that named them breaks.
|
|
116
|
-
const guard = guardFor(d, flow, lookupId, screenId, had ? asRec(steps[at + 1]) : {});
|
|
117
|
-
steps.splice(at + 1, had ? 1 : 0, guard);
|
|
118
|
-
entry['steps'] = steps;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Whether the screens after this one can read the answer without calling again.
|
|
123
|
-
*
|
|
124
|
-
* Turning it on gives the answer a name in the round state — the one thing that
|
|
125
|
-
* crosses from one screen to the next — and `settle` then makes every jump in
|
|
126
|
-
* the flow carry it. Turning it off takes the name away, and is refused while
|
|
127
|
-
* anything still quotes it.
|
|
128
|
-
*/
|
|
129
|
-
export function setLookupMemory(config, lookupId, remember) {
|
|
130
|
-
const flow = requireFlow(config);
|
|
131
|
-
const { screen, lookup } = authoredOf(flow, lookupId);
|
|
132
|
-
if (remember === (lookup.remembers !== undefined))
|
|
133
|
-
return config;
|
|
134
|
-
if (!remember) {
|
|
135
|
-
const key = lookup.remembers;
|
|
136
|
-
const used = memoryUses(flow, key);
|
|
137
|
-
if (used.length > 0) {
|
|
138
|
-
throw new ConversationalFlowEditError(`“${lookup.title}” is still quoted in ${used.join(', ')}. Take those out first.`);
|
|
139
|
-
}
|
|
140
|
-
return settle(config, (d) => {
|
|
141
|
-
delete asRec(findStep(d, flow.cycleId, 'CYCLE').config['input'])[key];
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return settle(config, (d) => {
|
|
145
|
-
const input = asRec(findStep(d, flow.cycleId, 'CYCLE').config['input']);
|
|
146
|
-
const key = uniqueName(slug(lookup.title), new Set(Object.keys(input)));
|
|
147
|
-
// `null` until a conversation reaches the screen that fills it.
|
|
148
|
-
input[key] = null;
|
|
149
|
-
// One jump has to say who fills it; `settle` writes the rest of the flow.
|
|
150
|
-
// A screen's jumps sit inside the branch that splits typing from tapping,
|
|
151
|
-
// so this looks through the whole case rather than at its top level.
|
|
152
|
-
const own = walk(asSteps(caseOf(d, screen.id)['steps']).slice(prepLength(screen)));
|
|
153
|
-
for (const step of own) {
|
|
154
|
-
if (step.type === 'GO_TO' && step.config['target'] === flow.cycleId) {
|
|
155
|
-
asRec(step.config['with'])[key] = lookupRef(lookupId, 'body');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
/** Where a remembered answer is quoted — the same places a lookup can be. */
|
|
161
|
-
export function memoryUses(flow, key) {
|
|
162
|
-
return quotedIn(flow, `output.input.${key}`);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Where a lookup's answer is quoted, in the author's terms — so removing one can
|
|
166
|
-
* say what it would leave blank. Covers everything the editor writes: wording,
|
|
167
|
-
* farewells, outcomes, and the requests of other lookups.
|
|
168
|
-
*/
|
|
169
|
-
export function lookupUses(flow, lookupId) {
|
|
170
|
-
return quotedIn(flow, `steps.${lookupId}.`);
|
|
171
|
-
}
|
|
172
|
-
/** Everything the editor writes that could quote something: wording, farewells, outcomes, requests. */
|
|
173
|
-
function quotedIn(flow, needle) {
|
|
174
|
-
const out = [];
|
|
175
|
-
for (const screen of flow.screens) {
|
|
176
|
-
for (const prompt of screen.prompts) {
|
|
177
|
-
if (prompt.text.includes(needle))
|
|
178
|
-
out.push(`what “${screen.title}” says`);
|
|
179
|
-
for (const option of prompt.options)
|
|
180
|
-
if (option.label.includes(needle))
|
|
181
|
-
out.push(`an option on “${screen.title}”`);
|
|
182
|
-
}
|
|
183
|
-
if (screen.endMessage?.includes(needle))
|
|
184
|
-
out.push(`the farewell on “${screen.title}”`);
|
|
185
|
-
for (const [key, value] of Object.entries(screen.endValue ?? {})) {
|
|
186
|
-
if (typeof value === 'string' && value.includes(needle))
|
|
187
|
-
out.push(`“${screen.title}” → ${key}`);
|
|
188
|
-
}
|
|
189
|
-
for (const other of screen.lookups) {
|
|
190
|
-
if (JSON.stringify(other.request).includes(needle))
|
|
191
|
-
out.push(`the request of “${other.title}”`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return out;
|
|
195
|
-
}
|
|
196
|
-
// ─── Plumbing ───
|
|
197
|
-
/**
|
|
198
|
-
* The call the author wrote. A copy on a screen that shows its answer is
|
|
199
|
-
* derived — `settle` rewrites it from the original — so it is never edited here.
|
|
200
|
-
*/
|
|
201
|
-
function authoredOf(flow, lookupId) {
|
|
202
|
-
const found = ownerOf(flow, lookupId);
|
|
203
|
-
if (found.lookup.derivedFrom !== undefined) {
|
|
204
|
-
throw new ConversationalFlowEditError(`“${found.lookup.title}” is here because this screen shows what it finds. Change it where it is set up, or take it out of the wording.`);
|
|
205
|
-
}
|
|
206
|
-
return found;
|
|
207
|
-
}
|
|
208
|
-
function ownerOf(flow, lookupId) {
|
|
209
|
-
for (const screen of flow.screens) {
|
|
210
|
-
const lookup = screen.lookups.find((l) => l.id === lookupId);
|
|
211
|
-
if (lookup)
|
|
212
|
-
return { screen, lookup };
|
|
213
|
-
}
|
|
214
|
-
throw new ConversationalFlowEditError(`There is nothing called “${lookupId}” to look up.`);
|
|
215
|
-
}
|
|
216
|
-
function indexOf(steps, id) {
|
|
217
|
-
const at = steps.findIndex((s) => asRec(s)['id'] === id);
|
|
218
|
-
if (at === -1)
|
|
219
|
-
throw new ConversationalFlowEditError(`Step “${id}” is missing.`);
|
|
220
|
-
return at;
|
|
221
|
-
}
|
|
222
|
-
/** A request this layer is willing to write, with what it insists on settled. */
|
|
223
|
-
function checked(request) {
|
|
224
|
-
const url = typeof request['url'] === 'string' ? request['url'].trim() : '';
|
|
225
|
-
if (!url)
|
|
226
|
-
throw new ConversationalFlowEditError('A lookup needs an address to call.');
|
|
227
|
-
const method = typeof request['method'] === 'string' ? request['method'].toUpperCase() : 'GET';
|
|
228
|
-
if (!METHODS.has(method))
|
|
229
|
-
throw new ConversationalFlowEditError(`“${method}” isn’t a method this can call.`);
|
|
230
|
-
return { ...clone(request), url, method };
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Quote a lookup's answer on a screen — the only way a value gets used, and the
|
|
234
|
-
* only place that decides whether the screen needs its own copy of the call.
|
|
235
|
-
*
|
|
236
|
-
* Returns the reference to write, so the caller puts it wherever it belongs:
|
|
237
|
-
* wording, an option's label, a farewell, an outcome, another request. Write it
|
|
238
|
-
* in the same edit — a copy nothing quotes is removed by the next `settle`,
|
|
239
|
-
* which is what keeps the derived ones honest.
|
|
240
|
-
*/
|
|
241
|
-
export function quoteValue(config, screenId, lookupId, path = 'body') {
|
|
242
|
-
const flow = requireFlow(config);
|
|
243
|
-
const screen = requireScreen(flow, screenId);
|
|
244
|
-
const { screen: home, lookup: source } = ownerOf(flow, lookupId);
|
|
245
|
-
if (source.derivedFrom !== undefined) {
|
|
246
|
-
throw new ConversationalFlowEditError('Quote the call the author wrote, not a copy of it.');
|
|
247
|
-
}
|
|
248
|
-
// Its own call: there is nothing to derive.
|
|
249
|
-
if (home.id === screenId)
|
|
250
|
-
return { config, ref: lookupRef(lookupId, path) };
|
|
251
|
-
const copyId = derivedLookupId(lookupId, screenId);
|
|
252
|
-
if (screen.lookups.some((l) => l.id === copyId))
|
|
253
|
-
return { config, ref: lookupRef(copyId, path) };
|
|
254
|
-
if (screen.kind === 'router') {
|
|
255
|
-
throw new ConversationalFlowEditError('A router says nothing, so it has nothing to show.');
|
|
256
|
-
}
|
|
257
|
-
// `mutate`, not `settle`: the copy is here for the reference the caller is
|
|
258
|
-
// about to write, and `settle` drops copies nothing quotes.
|
|
259
|
-
const next = mutate(config, (d) => addDerivedLookup(d, flow, screen, source));
|
|
260
|
-
return { config: next, ref: lookupRef(copyId, path) };
|
|
261
|
-
}
|
|
262
|
-
/** Screens that show this call's answer, and so make it themselves. */
|
|
263
|
-
export function shownOn(flow, lookupId) {
|
|
264
|
-
return flow.screens.filter((s) => s.lookups.some((l) => l.derivedFrom === lookupId));
|
|
265
|
-
}
|
|
266
|
-
//# sourceMappingURL=lookup-edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lookup-edit.js","sourceRoot":"","sources":["../../src/conversational-flow/lookup-edit.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,2BAA2B,EAC3B,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,GAEL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqD,MAAM,YAAY,CAAC;AAE/F,gFAAgF;AAChF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAU3E,wFAAwF;AACxF,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,IAAI,GAAG,EAAE;IAC9C,OAAO,+BAA+B,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AACzE,CAAC;AAED;;;GA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AAC;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;IACjG,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC,mDAAmD,CAAC,CAAC;IAC7F,CAAC;IAED,2EAA2E;IAC3E,4DAA4D;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9E,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,OAAO,CAAC,IAAwB,EAAE,QAAgB;IAChE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shapes a lookup is written as, shared by the edits that create them and
|
|
3
|
-
* by `settle`, which keeps derived ones true.
|
|
4
|
-
*
|
|
5
|
-
* ## Why a screen ever has a copy of another screen's call
|
|
6
|
-
*
|
|
7
|
-
* A value is only in scope for the round that fetched it, and the round is one
|
|
8
|
-
* screen. So a screen that *shows* a value has to make the call itself — and
|
|
9
|
-
* then it does not matter how the person arrived: by tapping down the menu, by
|
|
10
|
-
* typing and being routed straight in, by a way-back link, or from a failed
|
|
11
|
-
* lookup's fallback. Whatever opens the screen also makes its calls.
|
|
12
|
-
*
|
|
13
|
-
* The author writes the request once. Every screen that quotes it gets a copy,
|
|
14
|
-
* named after where the request came from (`refund_at_charged_twice`), kept in
|
|
15
|
-
* step with it here, and removed when nothing on that screen quotes it.
|
|
16
|
-
*/
|
|
17
|
-
import type { WorkflowConfig } from '../types/workflow-config.js';
|
|
18
|
-
import { type Rec } from './internals.js';
|
|
19
|
-
import { type ConversationalFlow, type Lookup, type Screen } from './types.js';
|
|
20
|
-
/** How a lookup's answer is quoted: `{{steps.<id>.output.body.status}}`. */
|
|
21
|
-
export declare function lookupRef(lookupId: string, path?: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* The guard after a call: when it did not come back, open `to` instead. An
|
|
24
|
-
* answer that never arrived has no `ok` at all, which is not `true` either.
|
|
25
|
-
*
|
|
26
|
-
* `old` is the guard being replaced, if any — its ids are kept so nothing that
|
|
27
|
-
* named them breaks.
|
|
28
|
-
*/
|
|
29
|
-
export declare function guardFor(draft: WorkflowConfig, flow: ConversationalFlow, lookupId: string, to: string, old?: Rec): Rec;
|
|
30
|
-
/**
|
|
31
|
-
* What a GO_TO must carry: every key the CYCLE starts a round with. The screen
|
|
32
|
-
* replaces the one the flow routes on; the rest start as the flow starts, and
|
|
33
|
-
* `settle` then writes whatever the conversation is carrying over the top.
|
|
34
|
-
*/
|
|
35
|
-
export declare function carried(draft: WorkflowConfig, flow: ConversationalFlow, screenId: string): Rec;
|
|
36
|
-
/** Whether anything this screen says or reports quotes `needle`. */
|
|
37
|
-
export declare function screenQuotes(screen: Screen, needle: string): boolean;
|
|
38
|
-
/** Add a copy of `source` to a screen, so that screen makes the call itself. */
|
|
39
|
-
export declare function addDerivedLookup(draft: WorkflowConfig, flow: ConversationalFlow, screen: Screen, source: Lookup): void;
|
|
40
|
-
/**
|
|
41
|
-
* Keep every derived copy true: the same request as the call it came from, the
|
|
42
|
-
* same way out when it fails — and gone once nothing on its screen quotes it,
|
|
43
|
-
* or the call it came from is gone.
|
|
44
|
-
*/
|
|
45
|
-
export declare function syncDerivedLookups(draft: WorkflowConfig, flow: ConversationalFlow): void;
|
|
46
|
-
//# sourceMappingURL=lookups.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lookups.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/lookups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EASL,KAAK,GAAG,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAkB,KAAK,kBAAkB,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAE/F,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,SAAS,GAAG,MAAM,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,GAAE,GAAQ,GACZ,GAAG,CAkBL;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAM9F;AAYD,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpE;AAYD,gFAAgF;AAChF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,IAAI,CAgBN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CA6CxF"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { allStepIds, asArray, asRec, clone, findStep, prepLength, routerCases, uniqueName, } from './internals.js';
|
|
2
|
-
import { derivedLookupId } from './read.js';
|
|
3
|
-
import { HTTP_STEP_TYPE } from './types.js';
|
|
4
|
-
/** How a lookup's answer is quoted: `{{steps.<id>.output.body.status}}`. */
|
|
5
|
-
export function lookupRef(lookupId, path = 'body') {
|
|
6
|
-
return `{{steps.${lookupId}.output.${path}}}`;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The guard after a call: when it did not come back, open `to` instead. An
|
|
10
|
-
* answer that never arrived has no `ok` at all, which is not `true` either.
|
|
11
|
-
*
|
|
12
|
-
* `old` is the guard being replaced, if any — its ids are kept so nothing that
|
|
13
|
-
* named them breaks.
|
|
14
|
-
*/
|
|
15
|
-
export function guardFor(draft, flow, lookupId, to, old = {}) {
|
|
16
|
-
const taken = allStepIds(draft);
|
|
17
|
-
const oldJump = asRec(asArray(asRec(old['config'])['if_true'])[0]);
|
|
18
|
-
return {
|
|
19
|
-
id: str(old['id']) ?? uniqueName(`${lookupId}_failed`, taken),
|
|
20
|
-
type: 'CONDITIONAL',
|
|
21
|
-
config: {
|
|
22
|
-
condition: { variable: lookupRef(lookupId, 'ok'), operator: 'neq', value: true },
|
|
23
|
-
if_true: [
|
|
24
|
-
{
|
|
25
|
-
id: str(oldJump['id']) ?? uniqueName(`${lookupId}_failed_go`, taken),
|
|
26
|
-
type: 'GO_TO',
|
|
27
|
-
config: { target: flow.cycleId, with: carried(draft, flow, to) },
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
if_false: [],
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* What a GO_TO must carry: every key the CYCLE starts a round with. The screen
|
|
36
|
-
* replaces the one the flow routes on; the rest start as the flow starts, and
|
|
37
|
-
* `settle` then writes whatever the conversation is carrying over the top.
|
|
38
|
-
*/
|
|
39
|
-
export function carried(draft, flow, screenId) {
|
|
40
|
-
const input = asRec(findStep(draft, flow.cycleId, 'CYCLE').config['input']);
|
|
41
|
-
const out = {};
|
|
42
|
-
for (const key of Object.keys(input))
|
|
43
|
-
out[key] = clone(input[key]);
|
|
44
|
-
out[flow.routeKey] = screenId;
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
|
-
/** Everything a screen says or reports, where a value can be quoted. */
|
|
48
|
-
function quotable(screen) {
|
|
49
|
-
return JSON.stringify([
|
|
50
|
-
screen.prompts.map((p) => [p.text, ...p.options.map((o) => o.label)]),
|
|
51
|
-
screen.endMessage ?? '',
|
|
52
|
-
screen.endValue ?? {},
|
|
53
|
-
screen.lookups.map((l) => l.request),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
/** Whether anything this screen says or reports quotes `needle`. */
|
|
57
|
-
export function screenQuotes(screen, needle) {
|
|
58
|
-
return quotable(screen).includes(needle);
|
|
59
|
-
}
|
|
60
|
-
/** Copies this screen's wording names, whether or not they exist yet. */
|
|
61
|
-
function quotedCopies(screen) {
|
|
62
|
-
const pattern = new RegExp(`steps\\.([A-Za-z0-9_]+)_at_${escapeId(screen.id)}\\.`, 'g');
|
|
63
|
-
return [...new Set([...quotable(screen).matchAll(pattern)].map((m) => m[1]))];
|
|
64
|
-
}
|
|
65
|
-
function escapeId(id) {
|
|
66
|
-
return id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
67
|
-
}
|
|
68
|
-
/** Add a copy of `source` to a screen, so that screen makes the call itself. */
|
|
69
|
-
export function addDerivedLookup(draft, flow, screen, source) {
|
|
70
|
-
const entry = routerCases(draft, flow)[screen.caseIndex];
|
|
71
|
-
const steps = asArray(entry['steps']);
|
|
72
|
-
const copy = {
|
|
73
|
-
id: derivedLookupId(source.id, screen.id),
|
|
74
|
-
type: HTTP_STEP_TYPE,
|
|
75
|
-
...(source.title ? { title: source.title } : {}),
|
|
76
|
-
config: clone(source.request),
|
|
77
|
-
};
|
|
78
|
-
const at = prepLength(screen);
|
|
79
|
-
steps.splice(at, 0, copy);
|
|
80
|
-
if (source.onFail !== undefined) {
|
|
81
|
-
copy['settings'] = { onError: 'continue' };
|
|
82
|
-
steps.splice(at + 1, 0, guardFor(draft, flow, String(copy['id']), source.onFail));
|
|
83
|
-
}
|
|
84
|
-
entry['steps'] = steps;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Keep every derived copy true: the same request as the call it came from, the
|
|
88
|
-
* same way out when it fails — and gone once nothing on its screen quotes it,
|
|
89
|
-
* or the call it came from is gone.
|
|
90
|
-
*/
|
|
91
|
-
export function syncDerivedLookups(draft, flow) {
|
|
92
|
-
const authored = new Map();
|
|
93
|
-
for (const screen of flow.screens) {
|
|
94
|
-
for (const lookup of screen.lookups)
|
|
95
|
-
if (lookup.derivedFrom === undefined)
|
|
96
|
-
authored.set(lookup.id, lookup);
|
|
97
|
-
}
|
|
98
|
-
// Wording that names a copy is what asks for it — so a sentence pasted from
|
|
99
|
-
// another screen, or a reference typed by hand, brings the call with it.
|
|
100
|
-
for (const screen of flow.screens) {
|
|
101
|
-
for (const sourceId of quotedCopies(screen)) {
|
|
102
|
-
const source = authored.get(sourceId);
|
|
103
|
-
if (!source || screen.kind === 'router')
|
|
104
|
-
continue;
|
|
105
|
-
if (screen.lookups.some((l) => l.id === derivedLookupId(sourceId, screen.id)))
|
|
106
|
-
continue;
|
|
107
|
-
addDerivedLookup(draft, flow, screen, source);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
for (const screen of flow.screens) {
|
|
111
|
-
for (const copy of screen.lookups) {
|
|
112
|
-
if (copy.derivedFrom === undefined)
|
|
113
|
-
continue;
|
|
114
|
-
const steps = asArray(routerCases(draft, flow)[screen.caseIndex]?.['steps']);
|
|
115
|
-
const at = steps.findIndex((s) => asRec(s)['id'] === copy.id);
|
|
116
|
-
if (at === -1)
|
|
117
|
-
continue;
|
|
118
|
-
const source = authored.get(copy.derivedFrom);
|
|
119
|
-
if (!source || !screenQuotes(screen, `steps.${copy.id}.`)) {
|
|
120
|
-
steps.splice(at, copy.onFail === undefined ? 1 : 2);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const step = asRec(steps[at]);
|
|
124
|
-
step['config'] = clone(source.request);
|
|
125
|
-
if (source.title)
|
|
126
|
-
step['title'] = source.title;
|
|
127
|
-
else
|
|
128
|
-
delete step['title'];
|
|
129
|
-
const had = copy.onFail !== undefined;
|
|
130
|
-
if (source.onFail === undefined) {
|
|
131
|
-
if (had)
|
|
132
|
-
steps.splice(at + 1, 1);
|
|
133
|
-
delete step['settings'];
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
step['settings'] = { ...asRec(step['settings']), onError: 'continue' };
|
|
137
|
-
steps.splice(at + 1, had ? 1 : 0, guardFor(draft, flow, copy.id, source.onFail, had ? asRec(steps[at + 1]) : {}));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function str(value) {
|
|
143
|
-
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=lookups.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lookups.js","sourceRoot":"","sources":["../../src/conversational-flow/lookups.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,GAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAqD,MAAM,YAAY,CAAC;AAE/F,4EAA4E;AAC5E,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAI,GAAG,MAAM;IACvD,OAAO,WAAW,QAAQ,WAAW,IAAI,IAAI,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAqB,EACrB,IAAwB,EACxB,QAAgB,EAChB,EAAU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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACpH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The author's own choices about routing: which service decides, how, what it
|
|
3
|
-
* is told, and which part of the flow a router serves.
|
|
4
|
-
*
|
|
5
|
-
* Everything else about a router — the screens it may choose, the question it
|
|
6
|
-
* is asked, where an unsure message goes — is derived from the flow and written
|
|
7
|
-
* by `settle`; see `routers.ts`.
|
|
8
|
-
*/
|
|
9
|
-
import type { WorkflowConfig } from '../types/workflow-config.js';
|
|
10
|
-
export declare function setRouterAgent(config: WorkflowConfig, agentSlug: string): WorkflowConfig;
|
|
11
|
-
/**
|
|
12
|
-
* The classifier router's own settings: which service answers, as which model,
|
|
13
|
-
* with which key, and how sure it must be. What it is asked — the question and
|
|
14
|
-
* the classes — is generated from the screens and is not settable here.
|
|
15
|
-
*
|
|
16
|
-
* `minConfidence: null` clears the threshold.
|
|
17
|
-
*/
|
|
18
|
-
export declare function setRouterModel(config: WorkflowConfig, patch: {
|
|
19
|
-
model?: string;
|
|
20
|
-
credentialName?: string;
|
|
21
|
-
minConfidence?: number | null;
|
|
22
|
-
}): WorkflowConfig;
|
|
23
|
-
/**
|
|
24
|
-
* Change how typed text is routed: a classifier model, or an agent asked for
|
|
25
|
-
* JSON. The screens, the guidance and everything around the router stay as they
|
|
26
|
-
* are — only the deciding step is replaced, and what it is told is regenerated.
|
|
27
|
-
*/
|
|
28
|
-
export declare function setRouterMode(config: WorkflowConfig, mode: 'classifier' | 'agent', options?: {
|
|
29
|
-
model?: string;
|
|
30
|
-
credentialName?: string;
|
|
31
|
-
minConfidence?: number;
|
|
32
|
-
agentSlug?: string;
|
|
33
|
-
}): WorkflowConfig;
|
|
34
|
-
/** The author's own guidance, put before the generated screen list. Either router. */
|
|
35
|
-
export declare function setRouterGuidance(config: WorkflowConfig, guidance: string, routerId?: string): WorkflowConfig;
|
|
36
|
-
/**
|
|
37
|
-
* Keep typed messages inside a section, or stop.
|
|
38
|
-
*
|
|
39
|
-
* On, a router of its own is created for that section — a copy of the flow's,
|
|
40
|
-
* so nothing has to be configured — and every screen beneath it is pointed at
|
|
41
|
-
* it. Off, the router goes and those screens fall back to the nearest one
|
|
42
|
-
* outside. Both are bulk actions on purpose: an exception afterwards is a
|
|
43
|
-
* per-screen choice (`setTypedRouter`), and a rule that rewrote every screen on
|
|
44
|
-
* every edit would erase it.
|
|
45
|
-
*/
|
|
46
|
-
export declare function setScopedRouter(config: WorkflowConfig, sectionId: string, on: boolean): WorkflowConfig;
|
|
47
|
-
/**
|
|
48
|
-
* Where one screen's typed text goes: any router the flow has, as long as it can
|
|
49
|
-
* serve this screen. This is how an author says "from here, typing may open
|
|
50
|
-
* anything" inside a scoped section.
|
|
51
|
-
*/
|
|
52
|
-
export declare function setTypedRouter(config: WorkflowConfig, screenId: string, routerId: string): WorkflowConfig;
|
|
53
|
-
//# sourceMappingURL=router-edit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router-edit.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/router-edit.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AA6BlE,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAOxF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAChF,cAAc,CAqBhB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,GAAG,OAAO,EAC5B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACpG,cAAc,CAqChB;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,CAY7G;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,cAAc,CAwCtG;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAkBzG"}
|