@xyne/workflow-sdk 3.2.45 → 3.2.47
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/map.step.d.ts +15 -4
- package/dist/connectors/builtin/steps/map.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/map.step.js +51 -18
- package/dist/connectors/builtin/steps/map.step.js.map +1 -1
- 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/engine/config-validator.js +2 -2
- package/dist/engine/config-validator.js.map +1 -1
- package/dist/engine/variable-resolver.js +1 -1
- package/dist/engine/variable-resolver.js.map +1 -1
- package/dist/engine/workflow-executor.d.ts.map +1 -1
- package/dist/engine/workflow-executor.js +10 -0
- package/dist/engine/workflow-executor.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/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +3 -0
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/steps/base-step.d.ts.map +1 -1
- package/dist/steps/base-step.js +1 -0
- package/dist/steps/base-step.js.map +1 -1
- package/dist/testing/mock-context.d.ts.map +1 -1
- package/dist/testing/mock-context.js +1 -0
- package/dist/testing/mock-context.js.map +1 -1
- package/dist/types/context.d.ts +15 -0
- package/dist/types/context.d.ts.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/dist/util/variable-ref.d.ts +1 -1
- package/dist/util/variable-ref.d.ts.map +1 -1
- package/dist/util/variable-ref.js +1 -1
- package/dist/util/variable-ref.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,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,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
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C;AAClE,OAAO,KAAK,EAGV,kBAAkB,EAKlB,UAAU,EACX,MAAM,YAAY,CAAC;AA0BpB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,IAAI,CAmCxF;
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAGV,kBAAkB,EAKlB,UAAU,EACX,MAAM,YAAY,CAAC;AA0BpB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,IAAI,CAmCxF;AA+SD,2DAA2D;AAC3D,eAAO,MAAM,eAAe,YAAY,CAAC;AAkBzC,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAiJzD,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AGENT_STEP_TYPE, optionsOf } from './types.js';
|
|
1
|
+
import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE, END_MESSAGE_KEY, optionsOf } from './types.js';
|
|
2
2
|
const LOOP_INPUT = /^\{\{\s*steps\.__loop\.output\.input\.([A-Za-z0-9_]+)\s*\}\}$/;
|
|
3
3
|
const WAIT_FIELD = /^\{\{\s*steps\.([^.\s}]+)\.output\.resumeData\.data\.([A-Za-z0-9_]+)\s*\}\}$/;
|
|
4
4
|
const STEP_OUTPUT = /^\{\{\s*steps\.([^.\s}]+)\.output\b/;
|
|
@@ -67,6 +67,7 @@ function readScreen(entry, caseIndex, ctx) {
|
|
|
67
67
|
router: undefined,
|
|
68
68
|
askAi: undefined,
|
|
69
69
|
endValue: undefined,
|
|
70
|
+
endMessage: undefined,
|
|
70
71
|
parent: undefined,
|
|
71
72
|
depth: -1,
|
|
72
73
|
};
|
|
@@ -92,7 +93,13 @@ function readScreen(entry, caseIndex, ctx) {
|
|
|
92
93
|
}
|
|
93
94
|
if (steps.length === 1 && first.type === 'FINISH' && isAimedAtCycle(first, ctx)) {
|
|
94
95
|
screen.kind = 'end';
|
|
95
|
-
|
|
96
|
+
// A Finish has no question to carry its "about", so its own step does — and
|
|
97
|
+
// writing one is what lets a router end the conversation here.
|
|
98
|
+
screen.about = typeof first.description === 'string' && first.description.trim() ? first.description : undefined;
|
|
99
|
+
const { [END_MESSAGE_KEY]: message, ...result } = asRec(asRec(first.config)['with']);
|
|
100
|
+
screen.endValue = result;
|
|
101
|
+
if (typeof message === 'string' && message)
|
|
102
|
+
screen.endMessage = message;
|
|
96
103
|
return screen;
|
|
97
104
|
}
|
|
98
105
|
const router = readRouter(steps, ctx);
|
|
@@ -213,19 +220,43 @@ function finalise(resolved) {
|
|
|
213
220
|
}
|
|
214
221
|
// ─── Routers ───
|
|
215
222
|
function readRouter(steps, ctx) {
|
|
223
|
+
/** The step's answer is carried on by a GO_TO in the same case. */
|
|
224
|
+
const forwards = (id) => steps.some((s) => {
|
|
225
|
+
const d = jumpDestination(s, ctx);
|
|
226
|
+
return d.kind === 'dynamic' && d.from === id;
|
|
227
|
+
});
|
|
228
|
+
// A classifier picks the screen: CLASSIFIER_AGENT, then a GO_TO carrying
|
|
229
|
+
// `{{steps.<it>.output.class}}`. Its classes are the screens it may choose.
|
|
230
|
+
const classifier = steps.find((s) => s.type === CLASSIFIER_STEP_TYPE);
|
|
231
|
+
if (classifier && forwards(classifier.id)) {
|
|
232
|
+
const config = asRec(classifier.config);
|
|
233
|
+
return {
|
|
234
|
+
mode: 'classifier',
|
|
235
|
+
stepId: classifier.id,
|
|
236
|
+
scope: typeof config['scope'] === 'string' ? config['scope'] : undefined,
|
|
237
|
+
agent: undefined,
|
|
238
|
+
model: typeof config['model'] === 'string' ? config['model'] : undefined,
|
|
239
|
+
credentialName: typeof config['credentialName'] === 'string' ? config['credentialName'] : undefined,
|
|
240
|
+
minConfidence: typeof config['minConfidence'] === 'number' ? config['minConfidence'] : undefined,
|
|
241
|
+
task: typeof config['instructions'] === 'string' ? config['instructions'] : undefined,
|
|
242
|
+
guidance: typeof classifier.description === 'string' && classifier.description.trim() ? classifier.description : undefined,
|
|
243
|
+
candidates: Object.keys(asRec(config['classes'])),
|
|
244
|
+
rules: [],
|
|
245
|
+
};
|
|
246
|
+
}
|
|
216
247
|
// An agent picks the screen: RUN_AGENT, then a GO_TO carrying its answer.
|
|
217
248
|
const agent = steps.find((s) => s.type === AGENT_STEP_TYPE);
|
|
218
249
|
if (agent) {
|
|
219
|
-
|
|
220
|
-
const d = jumpDestination(s, ctx);
|
|
221
|
-
return d.kind === 'dynamic' && d.from === agent.id;
|
|
222
|
-
});
|
|
223
|
-
if (forwards) {
|
|
250
|
+
if (forwards(agent.id)) {
|
|
224
251
|
const config = asRec(agent.config);
|
|
225
252
|
return {
|
|
226
253
|
mode: 'agent',
|
|
227
254
|
stepId: agent.id,
|
|
255
|
+
scope: typeof config['scope'] === 'string' ? config['scope'] : undefined,
|
|
228
256
|
agent: typeof config['agentSlug'] === 'string' ? config['agentSlug'] : undefined,
|
|
257
|
+
model: undefined,
|
|
258
|
+
credentialName: undefined,
|
|
259
|
+
minConfidence: undefined,
|
|
229
260
|
task: typeof config['task'] === 'string' ? config['task'] : undefined,
|
|
230
261
|
guidance: typeof agent.description === 'string' && agent.description.trim() ? agent.description : undefined,
|
|
231
262
|
candidates: enumOf(asRec(config['outputSchema']), ctx.routeKey),
|
|
@@ -249,7 +280,11 @@ function readRouter(steps, ctx) {
|
|
|
249
280
|
return {
|
|
250
281
|
mode: 'keywords',
|
|
251
282
|
stepId: only.id,
|
|
283
|
+
scope: undefined,
|
|
252
284
|
agent: undefined,
|
|
285
|
+
model: undefined,
|
|
286
|
+
credentialName: undefined,
|
|
287
|
+
minConfidence: undefined,
|
|
253
288
|
task: undefined,
|
|
254
289
|
guidance: undefined,
|
|
255
290
|
candidates: [...new Set(rules.map((r) => r.screen))],
|
|
@@ -321,6 +356,12 @@ function enumOf(schema, key) {
|
|
|
321
356
|
* Parent = the screen that first links to this one, walking options outward
|
|
322
357
|
* from the root. Routers, ends and hand offs sit outside the menu tree: every
|
|
323
358
|
* screen can reach them, so "first to link" would be meaningless.
|
|
359
|
+
*
|
|
360
|
+
* That is a statement about the menu, not about the picture: the map draws an
|
|
361
|
+
* ending that exactly one screen leads to beside that screen (see the layout's
|
|
362
|
+
* `leadsTo`), because that is where the author put it. Keeping it out of the
|
|
363
|
+
* tree keeps the meaning stable — an ending does not change what it is when a
|
|
364
|
+
* second screen starts offering it.
|
|
324
365
|
*/
|
|
325
366
|
function placeInTree(screens, rootScreen) {
|
|
326
367
|
const byId = new Map(screens.map((s) => [s.id, s]));
|