@xyne/workflow-sdk 3.2.45 → 3.2.46
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/agent-step.d.ts +5 -5
- package/dist/agents/contract.d.ts +5 -5
- package/dist/agents/host-agent-step.d.ts +7 -7
- package/dist/agents/pi-session-runtime.d.ts +4 -4
- package/dist/common/credentials.d.ts +43 -0
- package/dist/common/credentials.d.ts.map +1 -1
- package/dist/common/credentials.js +34 -0
- package/dist/common/credentials.js.map +1 -1
- package/dist/connectors/builtin/builtin-connector.d.ts +1 -1
- package/dist/connectors/builtin/builtin-connector.d.ts.map +1 -1
- package/dist/connectors/builtin/builtin-connector.js +6 -4
- package/dist/connectors/builtin/builtin-connector.js.map +1 -1
- package/dist/connectors/builtin/credentials.d.ts +8 -0
- package/dist/connectors/builtin/credentials.d.ts.map +1 -1
- package/dist/connectors/builtin/credentials.js +14 -0
- package/dist/connectors/builtin/credentials.js.map +1 -1
- package/dist/connectors/builtin/steps/classifier-agent.step.d.ts +176 -0
- package/dist/connectors/builtin/steps/classifier-agent.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/classifier-agent.step.js +248 -0
- package/dist/connectors/builtin/steps/classifier-agent.step.js.map +1 -0
- package/dist/connectors/builtin/steps/cycle.step.d.ts +4 -4
- package/dist/connectors/builtin/steps/http-request.step.d.ts +4 -4
- package/dist/connectors/builtin/steps/parallel.step.d.ts +4 -4
- package/dist/conversational-flow/create.d.ts +15 -2
- package/dist/conversational-flow/create.d.ts.map +1 -1
- package/dist/conversational-flow/create.js +29 -10
- package/dist/conversational-flow/create.js.map +1 -1
- package/dist/conversational-flow/edit.d.ts +21 -20
- package/dist/conversational-flow/edit.d.ts.map +1 -1
- package/dist/conversational-flow/edit.js +204 -286
- package/dist/conversational-flow/edit.js.map +1 -1
- package/dist/conversational-flow/index.d.ts +8 -3
- package/dist/conversational-flow/index.d.ts.map +1 -1
- package/dist/conversational-flow/index.js +7 -2
- package/dist/conversational-flow/index.js.map +1 -1
- package/dist/conversational-flow/internals.d.ts +51 -0
- package/dist/conversational-flow/internals.d.ts.map +1 -0
- package/dist/conversational-flow/internals.js +163 -0
- package/dist/conversational-flow/internals.js.map +1 -0
- package/dist/conversational-flow/lookup-edit.d.ts +96 -0
- package/dist/conversational-flow/lookup-edit.d.ts.map +1 -0
- package/dist/conversational-flow/lookup-edit.js +266 -0
- package/dist/conversational-flow/lookup-edit.js.map +1 -0
- package/dist/conversational-flow/lookups.d.ts +46 -0
- package/dist/conversational-flow/lookups.d.ts.map +1 -0
- package/dist/conversational-flow/lookups.js +145 -0
- package/dist/conversational-flow/lookups.js.map +1 -0
- package/dist/conversational-flow/read.d.ts.map +1 -1
- package/dist/conversational-flow/read.js +48 -7
- package/dist/conversational-flow/read.js.map +1 -1
- package/dist/conversational-flow/router-edit.d.ts +53 -0
- package/dist/conversational-flow/router-edit.d.ts.map +1 -0
- package/dist/conversational-flow/router-edit.js +191 -0
- package/dist/conversational-flow/router-edit.js.map +1 -0
- package/dist/conversational-flow/routers.d.ts +92 -0
- package/dist/conversational-flow/routers.d.ts.map +1 -0
- package/dist/conversational-flow/routers.js +286 -0
- package/dist/conversational-flow/routers.js.map +1 -0
- package/dist/conversational-flow/settle.d.ts +26 -0
- package/dist/conversational-flow/settle.d.ts.map +1 -0
- package/dist/conversational-flow/settle.js +59 -0
- package/dist/conversational-flow/settle.js.map +1 -0
- package/dist/conversational-flow/tree.d.ts +15 -1
- package/dist/conversational-flow/tree.d.ts.map +1 -1
- package/dist/conversational-flow/tree.js +28 -0
- package/dist/conversational-flow/tree.js.map +1 -1
- package/dist/conversational-flow/turn.d.ts +2 -0
- package/dist/conversational-flow/turn.d.ts.map +1 -1
- package/dist/conversational-flow/turn.js +26 -7
- package/dist/conversational-flow/turn.js.map +1 -1
- package/dist/conversational-flow/types.d.ts +50 -3
- package/dist/conversational-flow/types.d.ts.map +1 -1
- package/dist/conversational-flow/types.js +35 -0
- package/dist/conversational-flow/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/known-types.d.ts +1 -0
- package/dist/types/known-types.d.ts.map +1 -1
- package/dist/types/known-types.js +1 -0
- package/dist/types/known-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { breadcrumb, treeOrder } from './tree.js';
|
|
2
|
+
import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE, optionsOf } from './types.js';
|
|
3
|
+
import { asRec, asSteps, containerOf, findStep, walk } from './internals.js';
|
|
4
|
+
/** Screens a router may send people to: everything they can be shown. */
|
|
5
|
+
export function routableScreens(flow) {
|
|
6
|
+
return flow.screens.filter((s) => s.kind !== 'router' && s.kind !== 'end');
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Finish screens a router may choose — the ones whose author said when to send
|
|
10
|
+
* people there.
|
|
11
|
+
*
|
|
12
|
+
* Every other screen can be described to the model by where it sits in the
|
|
13
|
+
* menu; a Finish sits nowhere, so without that line there is nothing to
|
|
14
|
+
* describe it by, and nothing to stop the model ending a conversation it merely
|
|
15
|
+
* found hard to place. Writing the line is the author saying "typing may end it
|
|
16
|
+
* here".
|
|
17
|
+
*/
|
|
18
|
+
export function endsByTyping(flow) {
|
|
19
|
+
return flow.screens.filter((s) => s.kind === 'end' && s.about !== undefined);
|
|
20
|
+
}
|
|
21
|
+
/** Every router in the flow, the one serving everything first. */
|
|
22
|
+
export function routersOf(flow) {
|
|
23
|
+
return flow.screens.filter((s) => s.router !== undefined).sort((a, b) => Number(a.router.scope !== undefined) - Number(b.router.scope !== undefined));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where a screen's typed text should go: the nearest scoped router at or above
|
|
27
|
+
* it, else the one serving the flow.
|
|
28
|
+
*
|
|
29
|
+
* "At or above" is why a section's own screen uses its own router, and why a
|
|
30
|
+
* screen beneath two scoped sections uses the nearer one.
|
|
31
|
+
*/
|
|
32
|
+
export function routerFor(flow, screenId) {
|
|
33
|
+
const byId = new Map(flow.screens.map((s) => [s.id, s]));
|
|
34
|
+
const scoped = new Map(routersOf(flow).filter((r) => r.router.scope).map((r) => [r.router.scope, r]));
|
|
35
|
+
for (let at = byId.get(screenId); at; at = at.parent ? byId.get(at.parent) : undefined) {
|
|
36
|
+
const router = scoped.get(at.id);
|
|
37
|
+
if (router)
|
|
38
|
+
return router;
|
|
39
|
+
}
|
|
40
|
+
return flowRouter(flow);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What a router may choose. Scoped: its section and everything beneath it, plus
|
|
44
|
+
* the first screen — "when the message isn't about this section" — every hand
|
|
45
|
+
* off, so asking for a person works wherever they are, and the endings its own
|
|
46
|
+
* screens lead to. Unscoped: every screen they can be shown, and every ending.
|
|
47
|
+
*
|
|
48
|
+
* An ending is not automatically global: a Finish that says something ("Your
|
|
49
|
+
* driver is 3 minutes away") belongs to the part of the flow that links to it,
|
|
50
|
+
* and a router serving Payments has no business closing the conversation on a
|
|
51
|
+
* Rides screen. A shared "End of chat", linked from inside the section, stays
|
|
52
|
+
* available because the link is what puts it in reach.
|
|
53
|
+
*
|
|
54
|
+
* Not the same set as the screens that route *to* it: the flow's router must
|
|
55
|
+
* still reach a leaf inside a scoped section, or typing at the main menu could
|
|
56
|
+
* only ever reach the section itself.
|
|
57
|
+
*/
|
|
58
|
+
export function candidatesOf(flow, router) {
|
|
59
|
+
const scope = router.router?.scope;
|
|
60
|
+
// Ending is not part of a section: a conversation ends wherever it ends.
|
|
61
|
+
const ends = endsByTyping(flow);
|
|
62
|
+
if (!scope)
|
|
63
|
+
return [...routableScreens(flow), ...ends];
|
|
64
|
+
const section = flow.screens.find((s) => s.id === scope);
|
|
65
|
+
if (!section)
|
|
66
|
+
return [...routableScreens(flow), ...ends];
|
|
67
|
+
const inside = new Set([section.id]);
|
|
68
|
+
for (const s of treeOrder(flow))
|
|
69
|
+
if (s.parent !== undefined && inside.has(s.parent))
|
|
70
|
+
inside.add(s.id);
|
|
71
|
+
const linkedFromInside = (end) => flow.screens.some((s) => inside.has(s.id) && optionsOf(s).some((o) => o.to.kind === 'screen' && o.to.screen === end.id));
|
|
72
|
+
return [
|
|
73
|
+
...routableScreens(flow).filter((s) => inside.has(s.id) || s.id === flow.rootScreen || s.kind === 'handoff'),
|
|
74
|
+
...ends.filter(linkedFromInside),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Whether a screen's typed text may keep going where it goes. Anything else is
|
|
79
|
+
* repaired by `settle` — a router that was removed, or a scoped one whose
|
|
80
|
+
* section is no longer above this screen.
|
|
81
|
+
*
|
|
82
|
+
* A screen pointed at the flow's router is always valid: that is how an author
|
|
83
|
+
* says "from here, typing may open anything", and it survives every move.
|
|
84
|
+
*/
|
|
85
|
+
export function routingIsValid(flow, screenId, targetId) {
|
|
86
|
+
const target = flow.screens.find((s) => s.id === targetId);
|
|
87
|
+
if (!target?.router)
|
|
88
|
+
return false;
|
|
89
|
+
const scope = target.router.scope;
|
|
90
|
+
if (!scope)
|
|
91
|
+
return true;
|
|
92
|
+
const byId = new Map(flow.screens.map((s) => [s.id, s]));
|
|
93
|
+
for (let at = byId.get(screenId); at; at = at.parent ? byId.get(at.parent) : undefined) {
|
|
94
|
+
if (at.id === scope)
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Point every screen's typed text at a router that can serve it. Only links
|
|
101
|
+
* that have become invalid are touched, so an author's own choice — "from this
|
|
102
|
+
* screen, typing may open anything" — is left standing.
|
|
103
|
+
*/
|
|
104
|
+
export function repairTypedRouting(draft, flow) {
|
|
105
|
+
for (const screen of flow.screens) {
|
|
106
|
+
for (const prompt of screen.prompts) {
|
|
107
|
+
if (prompt.freeText?.kind !== 'screen')
|
|
108
|
+
continue;
|
|
109
|
+
if (routingIsValid(flow, screen.id, prompt.freeText.screen))
|
|
110
|
+
continue;
|
|
111
|
+
const target = routerFor(flow, screen.id);
|
|
112
|
+
if (!target)
|
|
113
|
+
continue;
|
|
114
|
+
const jump = typedJumpOf(draft, prompt.id);
|
|
115
|
+
if (jump)
|
|
116
|
+
asRec(jump.config['with'])[flow.routeKey] = target.id;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** The GO_TO a prompt's typed branch carries — the one naming a router. */
|
|
121
|
+
export function typedJumpOf(draft, promptId) {
|
|
122
|
+
const around = asSteps(containerOf(draft, promptId));
|
|
123
|
+
const at = around.findIndex((s) => s.id === promptId);
|
|
124
|
+
const gate = around[at + 1];
|
|
125
|
+
if (gate?.type !== 'CONDITIONAL')
|
|
126
|
+
return undefined;
|
|
127
|
+
return asSteps(asRec(gate.config)['if_true']).find((s) => s.type === 'GO_TO');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The AI router's instructions and output contract, generated from the screens.
|
|
131
|
+
* The author's own guidance (the router step's description) goes first; the
|
|
132
|
+
* `enum` is what stops the agent naming a screen that doesn't exist.
|
|
133
|
+
*/
|
|
134
|
+
export function writeRouters(draft, flow) {
|
|
135
|
+
const textKey = typedTextKey(draft, flow);
|
|
136
|
+
const service = serviceOf(flow);
|
|
137
|
+
for (const screen of routersOf(flow)) {
|
|
138
|
+
const router = screen.router;
|
|
139
|
+
if (router.mode === 'keywords')
|
|
140
|
+
continue;
|
|
141
|
+
if (router.mode === 'classifier')
|
|
142
|
+
writeClassifier(draft, flow, screen, candidatesOf(flow, screen), textKey, service);
|
|
143
|
+
else
|
|
144
|
+
writeAgentRouter(draft, flow, router, candidatesOf(flow, screen), textKey);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The service every router uses: the flow router's model, credential and how
|
|
149
|
+
* sure it must be. Configured once, so scoping a section asks the author for
|
|
150
|
+
* nothing.
|
|
151
|
+
*/
|
|
152
|
+
function serviceOf(flow) {
|
|
153
|
+
const main = flowRouter(flow)?.router;
|
|
154
|
+
if (main?.mode !== 'classifier')
|
|
155
|
+
return {};
|
|
156
|
+
return {
|
|
157
|
+
...(main.model !== undefined ? { model: main.model } : {}),
|
|
158
|
+
...(main.credentialName !== undefined ? { credentialName: main.credentialName } : {}),
|
|
159
|
+
...(main.minConfidence !== undefined ? { minConfidence: main.minConfidence } : {}),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/** An agent asked for JSON: its instructions and the screens it may name. */
|
|
163
|
+
function writeAgentRouter(draft, flow, router, screens, textKey) {
|
|
164
|
+
const step = findStep(draft, router.stepId, AGENT_STEP_TYPE);
|
|
165
|
+
const lines = screens.map((s) => describeScreen(flow, s));
|
|
166
|
+
step.config['task'] = [
|
|
167
|
+
...(router.guidance ? [router.guidance, ''] : []),
|
|
168
|
+
textKey
|
|
169
|
+
? `Someone in this conversation typed: "{{steps.__loop.output.input.${textKey}}}"`
|
|
170
|
+
: 'Someone in this conversation typed a message.',
|
|
171
|
+
'',
|
|
172
|
+
'Send them to the screen that best answers it. The screens, with where each sits:',
|
|
173
|
+
...lines,
|
|
174
|
+
'',
|
|
175
|
+
'Prefer the most specific screen. Only choose a [section] when the message is too vague for any of its screens.',
|
|
176
|
+
`If nothing fits, choose "${flow.rootScreen}".`,
|
|
177
|
+
`Answer with JSON only: {"${flow.routeKey}": "<id from the list>", "reason": "<one short sentence>"}.`,
|
|
178
|
+
].join('\n');
|
|
179
|
+
step.config['outputType'] = 'json';
|
|
180
|
+
step.config['outputSchema'] = {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
[flow.routeKey]: { type: 'string', enum: screens.map((s) => s.id) },
|
|
184
|
+
reason: { type: 'string' },
|
|
185
|
+
},
|
|
186
|
+
required: [flow.routeKey, 'reason'],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* A classifier router: the screens become its classes, each described the way
|
|
191
|
+
* the agent router's list describes them, and the question it is asked carries
|
|
192
|
+
* the author's guidance. Its endpoint, model and credential are the author's
|
|
193
|
+
* and are never touched here.
|
|
194
|
+
*/
|
|
195
|
+
function writeClassifier(draft, flow, screen, screens, textKey, service) {
|
|
196
|
+
const router = screen.router;
|
|
197
|
+
const step = findStep(draft, router.stepId, CLASSIFIER_STEP_TYPE);
|
|
198
|
+
const section = router.scope ? flow.screens.find((s) => s.id === router.scope) : undefined;
|
|
199
|
+
step.config['input'] = textKey ? `{{steps.__loop.output.input.${textKey}}}` : '';
|
|
200
|
+
step.config['instructions'] = [
|
|
201
|
+
...(router.guidance ? [router.guidance, ''] : []),
|
|
202
|
+
section
|
|
203
|
+
? `Which screen best answers what they typed? They are in ${breadcrumb(flow, section)}; prefer the most specific screen there, a [section] only when the message is too vague for any screen beneath it, and the first screen only when the message isn't about ${section.title} at all.`
|
|
204
|
+
: 'Which screen best answers what they typed? Prefer the most specific one; a [section] only when the message is too vague for any screen beneath it.',
|
|
205
|
+
].join('\n');
|
|
206
|
+
step.config['classes'] = Object.fromEntries(screens.map((s) => [s.id, describeClass(flow, s)]));
|
|
207
|
+
// Every router asks the same service; only the flow's router is configured.
|
|
208
|
+
for (const key of ['model', 'credentialName', 'minConfidence']) {
|
|
209
|
+
if (service[key] !== undefined)
|
|
210
|
+
step.config[key] = service[key];
|
|
211
|
+
else
|
|
212
|
+
delete step.config[key];
|
|
213
|
+
}
|
|
214
|
+
// Somewhere to send a message it can't place: a scoped router keeps them in
|
|
215
|
+
// its own section, the flow's sends them back to the start.
|
|
216
|
+
if (typeof step.config['minConfidence'] === 'number')
|
|
217
|
+
step.config['fallbackClass'] = section?.id ?? flow.rootScreen;
|
|
218
|
+
else
|
|
219
|
+
delete step.config['fallbackClass'];
|
|
220
|
+
}
|
|
221
|
+
/** "payments_double_charge (Payments › Charges › Charged twice) [section] — the same trip was charged twice" */
|
|
222
|
+
function describeScreen(flow, s) {
|
|
223
|
+
if (s.kind === 'end')
|
|
224
|
+
return `${s.id} — ends the conversation: ${s.about ?? 'they are done'}`;
|
|
225
|
+
const section = flow.screens.some((c) => c.parent === s.id) ? ' [section]' : '';
|
|
226
|
+
const about = s.about ?? `the ${breadcrumb(flow, s)} screen`;
|
|
227
|
+
return `${s.id} (${breadcrumb(flow, s)})${section} — ${about}`;
|
|
228
|
+
}
|
|
229
|
+
/** The same description, without repeating the id the class key already carries. */
|
|
230
|
+
function describeClass(flow, s) {
|
|
231
|
+
if (s.kind === 'end')
|
|
232
|
+
return `Ends the conversation — ${s.about ?? 'they are done'}`;
|
|
233
|
+
const section = flow.screens.some((c) => c.parent === s.id) ? ' [section]' : '';
|
|
234
|
+
const about = s.about ?? `the ${breadcrumb(flow, s)} screen`;
|
|
235
|
+
return `${breadcrumb(flow, s)}${section} — ${about}`;
|
|
236
|
+
}
|
|
237
|
+
/** The cycle input that carries what they typed — read from a typed-text GO_TO. */
|
|
238
|
+
function typedTextKey(draft, flow) {
|
|
239
|
+
for (const s of flow.screens) {
|
|
240
|
+
for (const p of s.prompts) {
|
|
241
|
+
if (p.freeText?.kind !== 'screen' || !p.textField)
|
|
242
|
+
continue;
|
|
243
|
+
const jump = walk(asSteps(draft.steps)).find((x) => x.type === 'GO_TO' && Object.values(asRec(x.config['with'])).some((v) => typeof v === 'string' && v.includes(`steps.${p.id}.output.resumeData.data.${p.textField}`)));
|
|
244
|
+
const carried = asRec(jump?.config['with']);
|
|
245
|
+
const key = Object.keys(carried).find((k) => k !== flow.routeKey && typeof carried[k] === 'string' && carried[k].includes('{{'));
|
|
246
|
+
if (key)
|
|
247
|
+
return key;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
export function agentRouter(flow) {
|
|
253
|
+
return flow.screens.find((s) => s.router?.mode === 'agent');
|
|
254
|
+
}
|
|
255
|
+
/** The router that reads typed text, however it decides — classifier or agent. */
|
|
256
|
+
export function aiRouter(flow) {
|
|
257
|
+
return flow.screens.find((s) => s.router?.mode === 'classifier' || s.router?.mode === 'agent');
|
|
258
|
+
}
|
|
259
|
+
/** The router that serves the flow as a whole — the one with no scope. */
|
|
260
|
+
export function flowRouter(flow) {
|
|
261
|
+
return flow.screens.find((s) => s.router !== undefined && s.router.scope === undefined);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Point a section and everything beneath it at one router. A bulk action —
|
|
265
|
+
* scoping a section, un-scoping it, moving a branch into another section —
|
|
266
|
+
* rather than something `settle` does, so a per-screen choice survives edits
|
|
267
|
+
* elsewhere.
|
|
268
|
+
*/
|
|
269
|
+
export function pointSubtreeAt(draft, flow, sectionId, routerId) {
|
|
270
|
+
const inside = new Set([sectionId]);
|
|
271
|
+
for (const s of treeOrder(flow))
|
|
272
|
+
if (s.parent !== undefined && inside.has(s.parent))
|
|
273
|
+
inside.add(s.id);
|
|
274
|
+
for (const screen of flow.screens) {
|
|
275
|
+
if (!inside.has(screen.id))
|
|
276
|
+
continue;
|
|
277
|
+
for (const prompt of screen.prompts) {
|
|
278
|
+
if (prompt.freeText?.kind !== 'screen')
|
|
279
|
+
continue;
|
|
280
|
+
const jump = typedJumpOf(draft, prompt.id);
|
|
281
|
+
if (jump)
|
|
282
|
+
asRec(jump.config['with'])[flow.routeKey] = routerId;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=routers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routers.js","sourceRoot":"","sources":["../../src/conversational-flow/routers.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAuB,MAAM,gBAAgB,C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QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is refreshed after every structural edit, so the author never maintains
|
|
3
|
+
* it by hand:
|
|
4
|
+
*
|
|
5
|
+
* - prompt headers that were the generated breadcrumb ("Payments › Charges");
|
|
6
|
+
* - typed text pointed at a router that can still serve the screen it comes
|
|
7
|
+
* from — repaired only where it has become invalid, so an author's own choice
|
|
8
|
+
* of router stands;
|
|
9
|
+
* - each router's instructions and the screens it may choose;
|
|
10
|
+
* - where each hand off can be sent once the person is done.
|
|
11
|
+
*
|
|
12
|
+
* An edit calls `settle` instead of `mutate` when its change can move any of
|
|
13
|
+
* those — a screen added, moved, renamed, retyped or removed.
|
|
14
|
+
*/
|
|
15
|
+
import type { WorkflowConfig } from '../types/workflow-config.js';
|
|
16
|
+
/** Recompute what is derived from the screens (headers, the router) without any other change. */
|
|
17
|
+
export declare function refreshDerived(config: WorkflowConfig): WorkflowConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Apply `edit`, then refresh what is derived from the screens: breadcrumb
|
|
20
|
+
* headers (only those that were the generated breadcrumb — a header the author
|
|
21
|
+
* wrote is left alone) and the AI router's list of screens.
|
|
22
|
+
*/
|
|
23
|
+
export declare function settle(config: WorkflowConfig, edit: (draft: WorkflowConfig) => void,
|
|
24
|
+
/** The config as the author last saw it, when `config` is already part-way through a multi-step edit. */
|
|
25
|
+
baseline?: WorkflowConfig): WorkflowConfig;
|
|
26
|
+
//# sourceMappingURL=settle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settle.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/settle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMlE,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAErE;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI;AACrC,yGAAyG;AACzG,QAAQ,GAAE,cAAuB,GAChC,cAAc,CAqBhB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { breadcrumb, mainMenuLabel, treeOrder } from './tree.js';
|
|
2
|
+
import { findStep, mutate, requireFlow, selectOptions } from './internals.js';
|
|
3
|
+
import { repairTypedRouting, writeRouters } from './routers.js';
|
|
4
|
+
/** Recompute what is derived from the screens (headers, the router) without any other change. */
|
|
5
|
+
export function refreshDerived(config) {
|
|
6
|
+
return settle(config, () => { });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Apply `edit`, then refresh what is derived from the screens: breadcrumb
|
|
10
|
+
* headers (only those that were the generated breadcrumb — a header the author
|
|
11
|
+
* wrote is left alone) and the AI router's list of screens.
|
|
12
|
+
*/
|
|
13
|
+
export function settle(config, edit,
|
|
14
|
+
/** The config as the author last saw it, when `config` is already part-way through a multi-step edit. */
|
|
15
|
+
baseline = config) {
|
|
16
|
+
const before = requireFlow(baseline);
|
|
17
|
+
const wasGenerated = new Set();
|
|
18
|
+
for (const s of before.screens) {
|
|
19
|
+
const crumb = breadcrumb(before, s);
|
|
20
|
+
for (const p of s.prompts)
|
|
21
|
+
if (p.header === crumb)
|
|
22
|
+
wasGenerated.add(p.id);
|
|
23
|
+
}
|
|
24
|
+
const edited = mutate(config, edit);
|
|
25
|
+
const after = requireFlow(edited);
|
|
26
|
+
return mutate(edited, (draft) => {
|
|
27
|
+
for (const s of after.screens) {
|
|
28
|
+
const crumb = breadcrumb(after, s);
|
|
29
|
+
for (const p of s.prompts) {
|
|
30
|
+
if (wasGenerated.has(p.id) || p.header === undefined)
|
|
31
|
+
findStep(draft, p.id, 'WAIT').config['reason'] = crumb;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
repairTypedRouting(draft, after);
|
|
35
|
+
writeRouters(draft, after);
|
|
36
|
+
writeHandoffs(draft, after);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Where a hand off can go once the person is done: a Finish closes the
|
|
41
|
+
* conversation; any other screen hands it back. Finishes first, then the
|
|
42
|
+
* screens as the menu reads — never another hand off.
|
|
43
|
+
*/
|
|
44
|
+
function writeHandoffs(draft, flow) {
|
|
45
|
+
const handoffs = flow.screens.filter((s) => s.kind === 'handoff' && s.prompts[0]);
|
|
46
|
+
if (handoffs.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
const ends = flow.screens.filter((s) => s.kind === 'end');
|
|
49
|
+
const canBeShown = (s) => s.kind === 'menu' || s.kind === 'message' || s.kind === 'questions' || s.kind === 'ask-ai';
|
|
50
|
+
// Endings are listed first, above; the menu follows, each screen once.
|
|
51
|
+
const screens = [...treeOrder(flow).filter(canBeShown), ...flow.screens.filter((s) => s.depth === -1 && canBeShown(s))];
|
|
52
|
+
const options = [
|
|
53
|
+
...ends.map((s) => ({ label: s.title, value: s.id })),
|
|
54
|
+
...screens.map((s) => ({ label: s.id === flow.rootScreen ? (mainMenuLabel(flow) ?? s.title) : breadcrumb(flow, s), value: s.id })),
|
|
55
|
+
];
|
|
56
|
+
for (const h of handoffs)
|
|
57
|
+
selectOptions(findStep(draft, h.prompts[0].id, 'WAIT')).splice(0, Infinity, ...options);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=settle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settle.js","sourceRoot":"","sources":["../../src/conversational-flow/settle.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,YAAY,E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KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrD,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;KACnI,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC;AACrH,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Tree helpers over a read conversational flow: ordering for lists and pickers,
|
|
3
|
+
* and how the flow itself words a screen — its breadcrumb, and its way back.
|
|
4
|
+
*/
|
|
2
5
|
import type { ConversationalFlow, Screen } from './types.js';
|
|
3
6
|
/** Children of each screen, in the order the router lists them. */
|
|
4
7
|
export declare function childrenOf(flow: ConversationalFlow): Map<string, Screen[]>;
|
|
@@ -8,4 +11,15 @@ export declare function treeOrder(flow: ConversationalFlow): Screen[];
|
|
|
8
11
|
export declare function outsideTree(flow: ConversationalFlow): Screen[];
|
|
9
12
|
/** Ids of a screen's ancestors, nearest first. */
|
|
10
13
|
export declare function ancestorsOf(flow: ConversationalFlow, id: string): string[];
|
|
14
|
+
/** "Payments › Charges › Charged twice" — ancestors below the root, then the screen. */
|
|
15
|
+
export declare function breadcrumb(flow: ConversationalFlow, screen: Screen): string;
|
|
16
|
+
/** How this flow words the way back to its first screen ("Main menu"), if it has one. */
|
|
17
|
+
export declare function mainMenuLabel(flow: ConversationalFlow): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The screen that leads to this one, for screens the tree leaves out — a Finish
|
|
20
|
+
* or a hand off, which every screen may link to and so has no parent of its
|
|
21
|
+
* own. The first to link it, as the menu reads: the same rule `placeInTree`
|
|
22
|
+
* uses for screens that are in the tree.
|
|
23
|
+
*/
|
|
24
|
+
export declare function linkerOf(flow: ConversationalFlow, id: string): Screen | undefined;
|
|
11
25
|
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/tree.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAG7D,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAS1E;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAU5D;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAE9D;AAED,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAK1E;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM3E;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { optionsOf } from './types.js';
|
|
1
2
|
/** Children of each screen, in the order the router lists them. */
|
|
2
3
|
export function childrenOf(flow) {
|
|
3
4
|
const out = new Map();
|
|
@@ -36,4 +37,31 @@ export function ancestorsOf(flow, id) {
|
|
|
36
37
|
out.push(at);
|
|
37
38
|
return out;
|
|
38
39
|
}
|
|
40
|
+
/** "Payments › Charges › Charged twice" — ancestors below the root, then the screen. */
|
|
41
|
+
export function breadcrumb(flow, screen) {
|
|
42
|
+
const byId = new Map(flow.screens.map((s) => [s.id, s]));
|
|
43
|
+
const chain = [];
|
|
44
|
+
for (let at = screen; at; at = at.parent ? byId.get(at.parent) : undefined)
|
|
45
|
+
chain.unshift(at);
|
|
46
|
+
const titles = chain.filter((s) => s.id !== flow.rootScreen).map((s) => s.title);
|
|
47
|
+
return titles.length > 0 ? titles.join(' › ') : screen.title;
|
|
48
|
+
}
|
|
49
|
+
/** How this flow words the way back to its first screen ("Main menu"), if it has one. */
|
|
50
|
+
export function mainMenuLabel(flow) {
|
|
51
|
+
for (const s of flow.screens) {
|
|
52
|
+
const o = optionsOf(s).find((x) => x.back && x.to.kind === 'screen' && x.to.screen === flow.rootScreen);
|
|
53
|
+
if (o)
|
|
54
|
+
return o.label;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The screen that leads to this one, for screens the tree leaves out — a Finish
|
|
60
|
+
* or a hand off, which every screen may link to and so has no parent of its
|
|
61
|
+
* own. The first to link it, as the menu reads: the same rule `placeInTree`
|
|
62
|
+
* uses for screens that are in the tree.
|
|
63
|
+
*/
|
|
64
|
+
export function linkerOf(flow, id) {
|
|
65
|
+
return treeOrder(flow).find((s) => optionsOf(s).some((o) => o.to.kind === 'screen' && o.to.screen === id));
|
|
66
|
+
}
|
|
39
67
|
//# sourceMappingURL=tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/conversational-flow/tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/conversational-flow/tree.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,IAAwB;IACjD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS;YAAE,SAAS;QACrC,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACb,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAQ,EAAE;QAChC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC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AAQ,IAAI,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC;AAC7G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD,OAAO,KAAK,EAAE,kBAAkB,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAC;AAIjF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvG,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,2EAA2E;IAC3E,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;CAClC;AAED,6FAA6F;AAC7F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IA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;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CA+B9G;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAyBlG"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readConversationalFlow } from './read.js';
|
|
2
|
+
import { END_MESSAGE_KEY } from './types.js';
|
|
2
3
|
import { ancestorsOf } from './tree.js';
|
|
4
|
+
import { routerName } from './types.js';
|
|
3
5
|
/** The answer doesn't fit what the turn asks for. */
|
|
4
6
|
export class TurnAnswerError extends Error {
|
|
5
7
|
name = 'TurnAnswerError';
|
|
@@ -23,6 +25,10 @@ export function readTurn(run) {
|
|
|
23
25
|
const outcome = terminal === 'finished' && flow ? outcomeOf(rows, flow) : undefined;
|
|
24
26
|
if (outcome)
|
|
25
27
|
turn.outcome = outcome;
|
|
28
|
+
// What the Finish said as it closed, when its author gave it something to say.
|
|
29
|
+
const farewell = str(outcome?.[END_MESSAGE_KEY]);
|
|
30
|
+
if (farewell)
|
|
31
|
+
turn.messages.push({ role: 'assistant', source: 'flow', text: farewell });
|
|
26
32
|
if (terminal === 'failed')
|
|
27
33
|
turn.error = errorOf(rows);
|
|
28
34
|
return turn;
|
|
@@ -101,19 +107,20 @@ const QUIET_STEPS = new Set(['CYCLE', 'SWITCH', 'CONDITIONAL', 'GO_TO', 'FINISH'
|
|
|
101
107
|
* which step is working, and what an agent is writing, thinking or using.
|
|
102
108
|
*/
|
|
103
109
|
export function streamEventOf(event, flow) {
|
|
104
|
-
const
|
|
110
|
+
const routers = new Map((flow?.screens ?? []).filter((s) => s.router).map((s) => [s.router.stepId, s]));
|
|
105
111
|
const askAi = (stepId) => flow?.screens.find((s) => s.askAi?.stepId === stepId);
|
|
106
112
|
if (event.event === 'step_started') {
|
|
107
113
|
const { stepName, stepType } = event.data;
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
const routing = routers.get(stepName);
|
|
115
|
+
if (routing)
|
|
116
|
+
return { type: 'working', kind: 'router', step: stepName, title: routerName(routing.router) };
|
|
110
117
|
const screen = askAi(stepName);
|
|
111
118
|
if (screen)
|
|
112
119
|
return { type: 'working', kind: 'agent', step: stepName, title: screen.title };
|
|
113
120
|
return QUIET_STEPS.has(stepType) ? null : { type: 'working', kind: 'step', step: stepName };
|
|
114
121
|
}
|
|
115
122
|
if (event.event === 'step_progress') {
|
|
116
|
-
if (event.data.stepName
|
|
123
|
+
if (routers.has(event.data.stepName))
|
|
117
124
|
return null;
|
|
118
125
|
const payload = rec(event.data['payload']);
|
|
119
126
|
switch (event.data['type']) {
|
|
@@ -313,11 +320,23 @@ function rowEvents(row, flow) {
|
|
|
313
320
|
}
|
|
314
321
|
}
|
|
315
322
|
if (row.screen.router?.stepId === row.stepId && row.step.status === 'COMPLETED') {
|
|
316
|
-
|
|
317
|
-
const
|
|
323
|
+
// An agent answers `{ screen, reason }`; a classifier answers a class and how sure it was.
|
|
324
|
+
const output = rec(row.data['output']);
|
|
325
|
+
const response = rec(output['response']);
|
|
326
|
+
const to = str(response[flow.routeKey]) ?? str(output['class']);
|
|
318
327
|
const reason = str(response['reason']);
|
|
328
|
+
const confidence = typeof output['confidence'] === 'number' ? output['confidence'] : undefined;
|
|
319
329
|
const title = to ? flow.screens.find((s) => s.id === to)?.title : undefined;
|
|
320
|
-
|
|
330
|
+
// Which router chose, since a flow may have one per section.
|
|
331
|
+
const by = row.screen.title;
|
|
332
|
+
out.push({
|
|
333
|
+
type: 'routed',
|
|
334
|
+
...(to ? { to } : {}),
|
|
335
|
+
...(title ? { title } : {}),
|
|
336
|
+
...(reason ? { reason } : {}),
|
|
337
|
+
...(confidence !== undefined ? { confidence } : {}),
|
|
338
|
+
...(by ? { by } : {}),
|
|
339
|
+
});
|
|
321
340
|
}
|
|
322
341
|
return out;
|
|
323
342
|
}
|