@xyne/workflow-sdk 3.2.47 → 3.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/host-agent-step.d.ts +2 -2
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +46 -34
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/workflow-client.d.ts +1 -1
- package/dist/client/workflow-client.d.ts.map +1 -1
- package/dist/client/workflow-client.js +34 -30
- package/dist/client/workflow-client.js.map +1 -1
- package/dist/connectors/builtin/steps/classifier-agent.step.d.ts +2 -2
- package/dist/connectors/builtin/steps/parallel.step.d.ts +4 -4
- package/dist/connectors/builtin/steps/wait.step.d.ts +28 -0
- package/dist/connectors/builtin/steps/wait.step.d.ts.map +1 -1
- package/dist/connectors/builtin/steps/wait.step.js +26 -1
- package/dist/connectors/builtin/steps/wait.step.js.map +1 -1
- package/dist/conversational-flow/calls.d.ts +20 -0
- package/dist/conversational-flow/calls.d.ts.map +1 -0
- package/dist/conversational-flow/calls.js +59 -0
- package/dist/conversational-flow/calls.js.map +1 -0
- package/dist/conversational-flow/conditions.d.ts +24 -0
- package/dist/conversational-flow/conditions.d.ts.map +1 -0
- package/dist/conversational-flow/conditions.js +69 -0
- package/dist/conversational-flow/conditions.js.map +1 -0
- package/dist/conversational-flow/create.d.ts +23 -18
- package/dist/conversational-flow/create.d.ts.map +1 -1
- package/dist/conversational-flow/create.js +73 -96
- package/dist/conversational-flow/create.js.map +1 -1
- package/dist/conversational-flow/edit/build.d.ts +112 -0
- package/dist/conversational-flow/edit/build.d.ts.map +1 -0
- package/dist/conversational-flow/edit/build.js +249 -0
- package/dist/conversational-flow/edit/build.js.map +1 -0
- package/dist/conversational-flow/edit/calls.d.ts +61 -0
- package/dist/conversational-flow/edit/calls.d.ts.map +1 -0
- package/dist/conversational-flow/edit/calls.js +296 -0
- package/dist/conversational-flow/edit/calls.js.map +1 -0
- package/dist/conversational-flow/edit/cases.d.ts +29 -0
- package/dist/conversational-flow/edit/cases.d.ts.map +1 -0
- package/dist/conversational-flow/edit/cases.js +83 -0
- package/dist/conversational-flow/edit/cases.js.map +1 -0
- package/dist/conversational-flow/edit/endings.d.ts +16 -0
- package/dist/conversational-flow/edit/endings.d.ts.map +1 -0
- package/dist/conversational-flow/edit/endings.js +53 -0
- package/dist/conversational-flow/edit/endings.js.map +1 -0
- package/dist/conversational-flow/edit/followups.d.ts +28 -0
- package/dist/conversational-flow/edit/followups.d.ts.map +1 -0
- package/dist/conversational-flow/edit/followups.js +103 -0
- package/dist/conversational-flow/edit/followups.js.map +1 -0
- package/dist/conversational-flow/edit/inputs.d.ts +24 -0
- package/dist/conversational-flow/edit/inputs.d.ts.map +1 -0
- package/dist/conversational-flow/edit/inputs.js +53 -0
- package/dist/conversational-flow/edit/inputs.js.map +1 -0
- package/dist/conversational-flow/edit/kinds.d.ts +29 -0
- package/dist/conversational-flow/edit/kinds.d.ts.map +1 -0
- package/dist/conversational-flow/edit/kinds.js +142 -0
- package/dist/conversational-flow/edit/kinds.js.map +1 -0
- package/dist/conversational-flow/edit/options.d.ts +68 -0
- package/dist/conversational-flow/edit/options.d.ts.map +1 -0
- package/dist/conversational-flow/edit/options.js +209 -0
- package/dist/conversational-flow/edit/options.js.map +1 -0
- package/dist/conversational-flow/edit/picklist.d.ts +28 -0
- package/dist/conversational-flow/edit/picklist.d.ts.map +1 -0
- package/dist/conversational-flow/edit/picklist.js +58 -0
- package/dist/conversational-flow/edit/picklist.js.map +1 -0
- package/dist/conversational-flow/edit/prompts.d.ts +24 -0
- package/dist/conversational-flow/edit/prompts.d.ts.map +1 -0
- package/dist/conversational-flow/edit/prompts.js +180 -0
- package/dist/conversational-flow/edit/prompts.js.map +1 -0
- package/dist/conversational-flow/edit/routers.d.ts +65 -0
- package/dist/conversational-flow/edit/routers.d.ts.map +1 -0
- package/dist/conversational-flow/edit/routers.js +208 -0
- package/dist/conversational-flow/edit/routers.js.map +1 -0
- package/dist/conversational-flow/edit/screens.d.ts +44 -0
- package/dist/conversational-flow/edit/screens.d.ts.map +1 -0
- package/dist/conversational-flow/edit/screens.js +137 -0
- package/dist/conversational-flow/edit/screens.js.map +1 -0
- package/dist/conversational-flow/edit/versions.d.ts +43 -0
- package/dist/conversational-flow/edit/versions.d.ts.map +1 -0
- package/dist/conversational-flow/edit/versions.js +189 -0
- package/dist/conversational-flow/edit/versions.js.map +1 -0
- package/dist/conversational-flow/index.d.ts +33 -16
- package/dist/conversational-flow/index.d.ts.map +1 -1
- package/dist/conversational-flow/index.js +42 -9
- package/dist/conversational-flow/index.js.map +1 -1
- package/dist/conversational-flow/json.d.ts +15 -0
- package/dist/conversational-flow/json.d.ts.map +1 -0
- package/dist/conversational-flow/json.js +14 -0
- package/dist/conversational-flow/json.js.map +1 -0
- package/dist/conversational-flow/jumps.d.ts +22 -0
- package/dist/conversational-flow/jumps.d.ts.map +1 -0
- package/dist/conversational-flow/jumps.js +160 -0
- package/dist/conversational-flow/jumps.js.map +1 -0
- package/dist/conversational-flow/locate.d.ts +30 -0
- package/dist/conversational-flow/locate.d.ts.map +1 -0
- package/dist/conversational-flow/locate.js +73 -0
- package/dist/conversational-flow/locate.js.map +1 -0
- package/dist/conversational-flow/paths.d.ts +31 -0
- package/dist/conversational-flow/paths.d.ts.map +1 -0
- package/dist/conversational-flow/paths.js +50 -0
- package/dist/conversational-flow/paths.js.map +1 -0
- package/dist/conversational-flow/prompt.d.ts +48 -0
- package/dist/conversational-flow/prompt.d.ts.map +1 -0
- package/dist/conversational-flow/prompt.js +161 -0
- package/dist/conversational-flow/prompt.js.map +1 -0
- package/dist/conversational-flow/read.d.ts +9 -17
- package/dist/conversational-flow/read.d.ts.map +1 -1
- package/dist/conversational-flow/read.js +217 -384
- package/dist/conversational-flow/read.js.map +1 -1
- package/dist/conversational-flow/rounds.d.ts +29 -0
- package/dist/conversational-flow/rounds.d.ts.map +1 -0
- package/dist/conversational-flow/rounds.js +41 -0
- package/dist/conversational-flow/rounds.js.map +1 -0
- package/dist/conversational-flow/routers.d.ts +24 -80
- package/dist/conversational-flow/routers.d.ts.map +1 -1
- package/dist/conversational-flow/routers.js +76 -262
- package/dist/conversational-flow/routers.js.map +1 -1
- package/dist/conversational-flow/server/conversation-service.d.ts +46 -18
- package/dist/conversational-flow/server/conversation-service.d.ts.map +1 -1
- package/dist/conversational-flow/server/conversation-service.js +56 -18
- package/dist/conversational-flow/server/conversation-service.js.map +1 -1
- package/dist/conversational-flow/server/routes.d.ts +15 -6
- package/dist/conversational-flow/server/routes.d.ts.map +1 -1
- package/dist/conversational-flow/server/routes.js +71 -74
- package/dist/conversational-flow/server/routes.js.map +1 -1
- package/dist/conversational-flow/settle.d.ts +21 -15
- package/dist/conversational-flow/settle.d.ts.map +1 -1
- package/dist/conversational-flow/settle.js +240 -38
- package/dist/conversational-flow/settle.js.map +1 -1
- package/dist/conversational-flow/shape.d.ts +114 -0
- package/dist/conversational-flow/shape.d.ts.map +1 -0
- package/dist/conversational-flow/shape.js +209 -0
- package/dist/conversational-flow/shape.js.map +1 -0
- package/dist/conversational-flow/testing.d.ts +54 -0
- package/dist/conversational-flow/testing.d.ts.map +1 -0
- package/dist/conversational-flow/testing.js +119 -0
- package/dist/conversational-flow/testing.js.map +1 -0
- package/dist/conversational-flow/tree.d.ts +28 -17
- package/dist/conversational-flow/tree.d.ts.map +1 -1
- package/dist/conversational-flow/tree.js +60 -47
- package/dist/conversational-flow/tree.js.map +1 -1
- package/dist/conversational-flow/turn.d.ts +30 -22
- package/dist/conversational-flow/turn.d.ts.map +1 -1
- package/dist/conversational-flow/turn.js +69 -48
- package/dist/conversational-flow/turn.js.map +1 -1
- package/dist/conversational-flow/types.d.ts +154 -118
- package/dist/conversational-flow/types.d.ts.map +1 -1
- package/dist/conversational-flow/types.js +27 -51
- package/dist/conversational-flow/types.js.map +1 -1
- package/dist/conversational-flow/typing.d.ts +31 -0
- package/dist/conversational-flow/typing.d.ts.map +1 -0
- package/dist/conversational-flow/typing.js +53 -0
- package/dist/conversational-flow/typing.js.map +1 -0
- package/dist/engine/variable-resolver.d.ts +16 -0
- package/dist/engine/variable-resolver.d.ts.map +1 -1
- package/dist/engine/variable-resolver.js +45 -1
- package/dist/engine/variable-resolver.js.map +1 -1
- package/dist/types/pause-state.d.ts +9 -0
- package/dist/types/pause-state.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/conversational-flow/edit.d.ts +0 -101
- package/dist/conversational-flow/edit.d.ts.map +0 -1
- package/dist/conversational-flow/edit.js +0 -785
- package/dist/conversational-flow/edit.js.map +0 -1
- package/dist/conversational-flow/internals.d.ts +0 -51
- package/dist/conversational-flow/internals.d.ts.map +0 -1
- package/dist/conversational-flow/internals.js +0 -163
- package/dist/conversational-flow/internals.js.map +0 -1
- package/dist/conversational-flow/lookup-edit.d.ts +0 -96
- package/dist/conversational-flow/lookup-edit.d.ts.map +0 -1
- package/dist/conversational-flow/lookup-edit.js +0 -266
- package/dist/conversational-flow/lookup-edit.js.map +0 -1
- package/dist/conversational-flow/lookups.d.ts +0 -46
- package/dist/conversational-flow/lookups.d.ts.map +0 -1
- package/dist/conversational-flow/lookups.js +0 -145
- package/dist/conversational-flow/lookups.js.map +0 -1
- package/dist/conversational-flow/router-edit.d.ts +0 -53
- package/dist/conversational-flow/router-edit.d.ts.map +0 -1
- package/dist/conversational-flow/router-edit.js +0 -191
- package/dist/conversational-flow/router-edit.js.map +0 -1
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
import { z } from 'zod';
|
|
24
24
|
import { BaseActionStep } from '../../../steps/base-step.js';
|
|
25
25
|
import { BuiltinStepType } from '../../../types/known-types.js';
|
|
26
|
+
import { ConditionSchema } from '../../../types/workflow-config.js';
|
|
27
|
+
import { ConditionEvaluator } from '../../../engine/condition-evaluator.js';
|
|
26
28
|
import { ATTACHMENT_ARRAY_JSON_SCHEMA } from '../../../common/attachment.js';
|
|
27
29
|
import { pauseFormToJsonSchema } from '../../../util/pause-form-schema.js';
|
|
28
30
|
// ─── Pause UI Schemas (shared with PauseState types) ───
|
|
@@ -37,6 +39,7 @@ const PauseDisplaySectionSchema = z.object({
|
|
|
37
39
|
const PauseFormFieldOptionSchema = z.object({
|
|
38
40
|
label: z.string(),
|
|
39
41
|
value: z.string(),
|
|
42
|
+
when: ConditionSchema.optional().describe('Offer this choice only when the condition holds. Omit to always offer it.'),
|
|
40
43
|
});
|
|
41
44
|
const PauseFormFieldSchema = z.discriminatedUnion('type', [
|
|
42
45
|
z.object({
|
|
@@ -239,7 +242,7 @@ export class WaitStep extends BaseActionStep {
|
|
|
239
242
|
if (config.display)
|
|
240
243
|
pauseState.display = config.display;
|
|
241
244
|
if (config.form)
|
|
242
|
-
pauseState.form = config.form;
|
|
245
|
+
pauseState.form = this.offered(config.form, ctx);
|
|
243
246
|
if (config.actions)
|
|
244
247
|
pauseState.actions = config.actions;
|
|
245
248
|
ctx.pause(config.reason, {
|
|
@@ -250,5 +253,27 @@ export class WaitStep extends BaseActionStep {
|
|
|
250
253
|
},
|
|
251
254
|
});
|
|
252
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* The form as this person sees it: a choice carrying a `when` is kept only
|
|
258
|
+
* when the condition holds against the run so far.
|
|
259
|
+
*
|
|
260
|
+
* What is filtered is the *offer*, not the answer — so nothing downstream has
|
|
261
|
+
* to know a choice existed. A field left with no choices still renders; that
|
|
262
|
+
* is the author's flow saying "under this data, there is nothing to pick here",
|
|
263
|
+
* and hiding the question instead would be this step inventing a rule.
|
|
264
|
+
*/
|
|
265
|
+
offered(form, ctx) {
|
|
266
|
+
const anyConditioned = form.fields.some((field) => field.type === 'select' && Array.isArray(field.options) && field.options.some((o) => o.when !== undefined));
|
|
267
|
+
if (!anyConditioned)
|
|
268
|
+
return form;
|
|
269
|
+
const evaluator = new ConditionEvaluator();
|
|
270
|
+
const fields = form.fields.map((field) => {
|
|
271
|
+
if (field.type !== 'select' || !Array.isArray(field.options))
|
|
272
|
+
return field;
|
|
273
|
+
const options = field.options.filter((option) => option.when === undefined || evaluator.evaluate(option.when, ctx.workflow));
|
|
274
|
+
return options.length === field.options.length ? field : { ...field, options };
|
|
275
|
+
});
|
|
276
|
+
return { ...form, fields };
|
|
277
|
+
}
|
|
253
278
|
}
|
|
254
279
|
//# sourceMappingURL=wait.step.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.step.js","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/wait.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,0DAA0D;AAE1D,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,8EAA8E;IAC9E,8EAA8E;IAC9E,gFAAgF;IAChF,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"wait.step.js","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/wait.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cA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OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CACtH,CAAC;QACF,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC;QAEjC,MAAM,SAAS,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAkB,EAAE;YACvD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC3E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7H,OAAO,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC;QACjF,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a call — the step a frame makes on the way in, whose answer everything
|
|
3
|
+
* inside that frame can quote.
|
|
4
|
+
*/
|
|
5
|
+
import { type Step } from './json.js';
|
|
6
|
+
import type { Call, CallScope } from './types.js';
|
|
7
|
+
export declare function readCall(step: Step, scope: CallScope, onFail: string | undefined): Call;
|
|
8
|
+
/**
|
|
9
|
+
* The answer's fields, from the JSON Schema its author declared — written the
|
|
10
|
+
* way they are quoted, relative to the body.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The leaves of a declared shape, as dotted paths — what a JSON Schema says you
|
|
14
|
+
* can quote. The same walk serves a lookup's answer and what the conversation is
|
|
15
|
+
* started with, because they are the same promise: these names will be there.
|
|
16
|
+
*/
|
|
17
|
+
export declare function declaredFields(schema: unknown): Call['fields'];
|
|
18
|
+
/** Whatever `steps` quote of a call's answer, so nothing is removed silently. */
|
|
19
|
+
export declare function quotedBy(steps: unknown, callId: string): boolean;
|
|
20
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/calls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAuB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMlD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAavF;AAED;;;GAGG;AACH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAc9D;AAQD,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a call — the step a frame makes on the way in, whose answer everything
|
|
3
|
+
* inside that frame can quote.
|
|
4
|
+
*/
|
|
5
|
+
import { asArray, asRec, str } from './json.js';
|
|
6
|
+
/** How deep and how wide a declared answer is described. */
|
|
7
|
+
const MAX_DEPTH = 3;
|
|
8
|
+
const MAX_FIELDS = 60;
|
|
9
|
+
export function readCall(step, scope, onFail) {
|
|
10
|
+
const config = asRec(step.config);
|
|
11
|
+
return {
|
|
12
|
+
id: step.id,
|
|
13
|
+
scope,
|
|
14
|
+
title: str(step.title) ?? humanise(step.id),
|
|
15
|
+
method: str(config['method']) ?? 'GET',
|
|
16
|
+
url: str(config['url']) ?? '',
|
|
17
|
+
request: config,
|
|
18
|
+
credentialName: str(config['credentialName']),
|
|
19
|
+
fields: declaredFields(asRec(config['response'])['bodySchema']),
|
|
20
|
+
onFail,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The answer's fields, from the JSON Schema its author declared — written the
|
|
25
|
+
* way they are quoted, relative to the body.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The leaves of a declared shape, as dotted paths — what a JSON Schema says you
|
|
29
|
+
* can quote. The same walk serves a lookup's answer and what the conversation is
|
|
30
|
+
* started with, because they are the same promise: these names will be there.
|
|
31
|
+
*/
|
|
32
|
+
export function declaredFields(schema) {
|
|
33
|
+
const out = [];
|
|
34
|
+
const descend = (node, path, depth) => {
|
|
35
|
+
if (out.length >= MAX_FIELDS)
|
|
36
|
+
return;
|
|
37
|
+
const properties = asRec(asRec(node)['properties']);
|
|
38
|
+
const keys = Object.keys(properties);
|
|
39
|
+
if (keys.length === 0 || depth >= MAX_DEPTH) {
|
|
40
|
+
if (path)
|
|
41
|
+
out.push({ path, type: str(asRec(node)['type']) });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
for (const key of keys)
|
|
45
|
+
descend(properties[key], path ? `${path}.${key}` : key, depth + 1);
|
|
46
|
+
};
|
|
47
|
+
descend(schema, '', 0);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
/** `fetch_refund` → `Fetch refund`, for a call whose author never named it. */
|
|
51
|
+
function humanise(id) {
|
|
52
|
+
const words = id.replace(/[_-]+/g, ' ').trim();
|
|
53
|
+
return words ? words.charAt(0).toUpperCase() + words.slice(1) : id;
|
|
54
|
+
}
|
|
55
|
+
/** Whatever `steps` quote of a call's answer, so nothing is removed silently. */
|
|
56
|
+
export function quotedBy(steps, callId) {
|
|
57
|
+
return JSON.stringify(asArray(steps)).includes(`steps.${callId}.`);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.js","sourceRoot":"","sources":["../../src/conversational-flow/calls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAa,MAAM,WAAW,CAAC;AAG3D,4DAA4D;AAC5D,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,MAAM,UAAU,QAAQ,CAAC,IAAU,EAAE,KAAgB,EAAE,MAA0B;IAC/E,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK;QACL,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK;QACtC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC7C,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;QAC/D,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,CAAC,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SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Condition, LeafCondition } from '../types/workflow-config.js';
|
|
2
|
+
/** A group's join, or `undefined` when it is a single test. */
|
|
3
|
+
export declare function joinOf(condition: Condition): 'all' | 'any' | undefined;
|
|
4
|
+
/** The conditions directly inside a group; a leaf is its own only part. */
|
|
5
|
+
export declare function partsIn(condition: Condition): Condition[];
|
|
6
|
+
/** Every test a condition makes, however it is grouped. */
|
|
7
|
+
export declare function leavesOf(condition: Condition): LeafCondition[];
|
|
8
|
+
/** Whether every part is a test — what the editor can lay out as rows. */
|
|
9
|
+
export declare function isFlat(condition: Condition): boolean;
|
|
10
|
+
/** A group of tests, or the test itself when there is one. */
|
|
11
|
+
export declare function group(join: 'all' | 'any', parts: readonly Condition[]): Condition;
|
|
12
|
+
/** Whether this operator reads a value at all — `is there` compares with nothing. */
|
|
13
|
+
export declare function takesValue(operator: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A short name for a condition, for a place that needs one word about it — a
|
|
16
|
+
* switch case's label in the config, a chip in a list.
|
|
17
|
+
*
|
|
18
|
+
* The field name, not the whole reference: `{{steps.account.output.body.plan}}`
|
|
19
|
+
* is `plan`, which is what the author called it and what they will recognise.
|
|
20
|
+
*/
|
|
21
|
+
export declare function labelFor(condition: Condition): string;
|
|
22
|
+
/** The last segment of a reference — what the author named the field. */
|
|
23
|
+
export declare function fieldName(variable: string): string;
|
|
24
|
+
//# sourceMappingURL=conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/conditions.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5E,+DAA+D;AAC/D,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAItE;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,CAGzD;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,EAAE,CAI9D;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAEpD;AAMD,8DAA8D;AAC9D,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAEjF;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAOrD;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a condition — the same shape wherever one appears.
|
|
3
|
+
*
|
|
4
|
+
* A condition is a leaf (`read this, compare it that way, against that`) or a
|
|
5
|
+
* group of conditions joined by `all` or `any`. Two places in a conversation
|
|
6
|
+
* carry one: a screen asked differently depending on the data, and an option
|
|
7
|
+
* offered only under it. Both mean the same thing and are edited by the same
|
|
8
|
+
* editor, so what a condition *is* is answered once, here.
|
|
9
|
+
*
|
|
10
|
+
* Nesting deeper than one group is legal in the engine and read faithfully by
|
|
11
|
+
* everything below — it just isn't something this layer writes.
|
|
12
|
+
*/
|
|
13
|
+
import { VALUE_LESS_OPERATORS } from '../types/operators.js';
|
|
14
|
+
/** A group's join, or `undefined` when it is a single test. */
|
|
15
|
+
export function joinOf(condition) {
|
|
16
|
+
if ('all' in condition)
|
|
17
|
+
return 'all';
|
|
18
|
+
if ('any' in condition)
|
|
19
|
+
return 'any';
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
/** The conditions directly inside a group; a leaf is its own only part. */
|
|
23
|
+
export function partsIn(condition) {
|
|
24
|
+
const join = joinOf(condition);
|
|
25
|
+
return join ? condition[join] : [condition];
|
|
26
|
+
}
|
|
27
|
+
/** Every test a condition makes, however it is grouped. */
|
|
28
|
+
export function leavesOf(condition) {
|
|
29
|
+
const join = joinOf(condition);
|
|
30
|
+
if (!join)
|
|
31
|
+
return isLeaf(condition) ? [condition] : [];
|
|
32
|
+
return condition[join].flatMap(leavesOf);
|
|
33
|
+
}
|
|
34
|
+
/** Whether every part is a test — what the editor can lay out as rows. */
|
|
35
|
+
export function isFlat(condition) {
|
|
36
|
+
return partsIn(condition).every(isLeaf);
|
|
37
|
+
}
|
|
38
|
+
function isLeaf(condition) {
|
|
39
|
+
return 'variable' in condition && 'operator' in condition;
|
|
40
|
+
}
|
|
41
|
+
/** A group of tests, or the test itself when there is one. */
|
|
42
|
+
export function group(join, parts) {
|
|
43
|
+
return parts.length === 1 ? parts[0] : { [join]: [...parts] };
|
|
44
|
+
}
|
|
45
|
+
/** Whether this operator reads a value at all — `is there` compares with nothing. */
|
|
46
|
+
export function takesValue(operator) {
|
|
47
|
+
return !VALUE_LESS_OPERATORS.has(operator);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A short name for a condition, for a place that needs one word about it — a
|
|
51
|
+
* switch case's label in the config, a chip in a list.
|
|
52
|
+
*
|
|
53
|
+
* The field name, not the whole reference: `{{steps.account.output.body.plan}}`
|
|
54
|
+
* is `plan`, which is what the author called it and what they will recognise.
|
|
55
|
+
*/
|
|
56
|
+
export function labelFor(condition) {
|
|
57
|
+
const leaves = leavesOf(condition);
|
|
58
|
+
const first = leaves[0];
|
|
59
|
+
if (!first)
|
|
60
|
+
return 'when';
|
|
61
|
+
const name = fieldName(first.variable);
|
|
62
|
+
const said = first.value === undefined ? `${name} ${first.operator}` : `${name} ${first.operator} ${String(first.value)}`;
|
|
63
|
+
return leaves.length === 1 ? said : `${said} +${String(leaves.length - 1)}`;
|
|
64
|
+
}
|
|
65
|
+
/** The last segment of a reference — what the author named the field. */
|
|
66
|
+
export function fieldName(variable) {
|
|
67
|
+
return /\.([^.\s}]+)\s*\}\}$/.exec(variable)?.[1] ?? /\{\{\s*([^.}\s]+)\s*\}\}/.exec(variable)?.[1] ?? 'data';
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/conversational-flow/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,oBAAoB,EAA0B,MAAM,uBAAuB,CAAC;AAGrF,+DAA+D;AAC/D,MAAM,UAAU,MAAM,CAAC,SAAoB;IACzC,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,OAAO,CAAC,SAAoB;IAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,CAAC,CAAE,SAAgD,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACtF,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,QAAQ,CAAC,SAAoB;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,OAAQ,SAAgD,CAAC,IAAI,CAAC,CA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I,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AAChH,CAAC"}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A new
|
|
2
|
+
* A new conversation: the smallest one that runs, and grows.
|
|
3
3
|
*
|
|
4
|
-
* CYCLE
|
|
5
|
-
* └ SWITCH
|
|
4
|
+
* CYCLE start input { screen: 'start', text: '' }
|
|
5
|
+
* └ SWITCH start_route
|
|
6
6
|
* ├ start — the first screen: a greeting, no options yet
|
|
7
|
-
* ├ ai_router — typed text → a classifier (or an agent)
|
|
7
|
+
* ├ ai_router — typed text → a classifier (or an agent) names the screen
|
|
8
8
|
* ├ done — Finish
|
|
9
9
|
* └ default → start
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The conversation's own cycle is named after its first screen, because a
|
|
12
|
+
* section and its screen are one thing; every section added later is a cycle
|
|
13
|
+
* inside this one. This is the one place that names the round's keys (`screen`,
|
|
14
|
+
* `text`) and the fields (`choice`, `message`) — every later edit copies
|
|
15
|
+
* whatever shape the flow already has.
|
|
16
|
+
*
|
|
17
|
+
* Everything derived — what the router may open and how it is asked, the
|
|
18
|
+
* headings, where each jump is aimed — is left to `settle`.
|
|
14
19
|
*/
|
|
15
20
|
import type { WorkflowConfig } from '../types/workflow-config.js';
|
|
16
21
|
export declare const CONVERSATIONAL_FLOW_KIND = "conversational_flow";
|
|
17
|
-
|
|
18
|
-
config: WorkflowConfig;
|
|
19
|
-
/** Stored on the workflow so it opens in the conversational-flow editor. */
|
|
20
|
-
metadata: {
|
|
21
|
-
kind: typeof CONVERSATIONAL_FLOW_KIND;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** How typed messages are routed. A classifier model, or an agent asked for JSON. */
|
|
22
|
+
/** How typed messages are routed: a classifier model, or an agent asked for JSON. */
|
|
25
23
|
export type NewRouter = {
|
|
26
24
|
kind: 'classifier';
|
|
27
25
|
model?: string;
|
|
@@ -32,13 +30,20 @@ export type NewRouter = {
|
|
|
32
30
|
kind: 'agent';
|
|
33
31
|
agentSlug?: string;
|
|
34
32
|
};
|
|
33
|
+
export interface NewConversationalFlow {
|
|
34
|
+
config: WorkflowConfig;
|
|
35
|
+
/** Stored on the workflow so it opens in the conversational-flow editor. */
|
|
36
|
+
metadata: {
|
|
37
|
+
kind: typeof CONVERSATIONAL_FLOW_KIND;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
35
40
|
export declare function createConversationalFlow(options?: {
|
|
36
|
-
/** How typed text is routed. A classifier
|
|
41
|
+
/** How typed text is routed. A classifier unless an agent is asked for. */
|
|
37
42
|
router?: NewRouter;
|
|
38
|
-
/**
|
|
43
|
+
/** Shorthand for `router: { kind: 'agent', agentSlug }`. */
|
|
39
44
|
agentSlug?: string;
|
|
40
45
|
greeting?: string;
|
|
41
|
-
/**
|
|
46
|
+
/** The first screen's name, and the heading on it. */
|
|
42
47
|
title?: string;
|
|
43
48
|
}): NewConversationalFlow;
|
|
44
49
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMlE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D,qFAAqF;AACrF,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,EAAE;QAAE,IAAI,EAAE,OAAO,wBAAwB,CAAA;KAAE,CAAC;CACrD;AAED,wBAAgB,wBAAwB,CACtC,OAAO,GAAE;IACP,2EAA2E;IAC3E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,GACL,qBAAqB,CA0DvB"}
|
|
@@ -1,114 +1,91 @@
|
|
|
1
|
-
import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE } from './types.js';
|
|
2
1
|
import { refreshDerived } from './settle.js';
|
|
2
|
+
import { carrying, cycleStep, DEFAULT_ROUTE_KEY, finishStep, jumpStep, screenCase, switchStep } from './shape.js';
|
|
3
|
+
import { AGENT_STEP_TYPE, CLASSIFIER_STEP_TYPE } from './types.js';
|
|
3
4
|
export const CONVERSATIONAL_FLOW_KIND = 'conversational_flow';
|
|
4
5
|
export function createConversationalFlow(options = {}) {
|
|
5
6
|
const title = options.title?.trim() || 'Start';
|
|
6
7
|
const greeting = options.greeting?.trim() || 'Hi! How can I help?';
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const go = (id, screen, text = '') => ({
|
|
12
|
-
id,
|
|
13
|
-
type: 'GO_TO',
|
|
14
|
-
config: { target: cycle, with: { screen, text } },
|
|
15
|
-
});
|
|
16
|
-
const router = options.router ?? (options.agentSlug ? { kind: 'agent', agentSlug: options.agentSlug } : { kind: 'classifier' });
|
|
17
|
-
// Its instructions, classes and allowed screens are written by `refreshDerived` below.
|
|
18
|
-
const deciding = router.kind === 'classifier'
|
|
19
|
-
? [
|
|
20
|
-
{
|
|
21
|
-
id: 'classify',
|
|
22
|
-
type: CLASSIFIER_STEP_TYPE,
|
|
23
|
-
config: {
|
|
24
|
-
input: '',
|
|
25
|
-
instructions: '',
|
|
26
|
-
classes: {},
|
|
27
|
-
...(router.model ? { model: router.model } : {}),
|
|
28
|
-
...(router.credentialName ? { credentialName: router.credentialName } : {}),
|
|
29
|
-
...(router.minConfidence !== undefined ? { minConfidence: router.minConfidence } : {}),
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
go('go_classified', '{{steps.classify.output.class}}'),
|
|
33
|
-
]
|
|
34
|
-
: [
|
|
35
|
-
{
|
|
36
|
-
id: 'classify',
|
|
37
|
-
type: AGENT_STEP_TYPE,
|
|
38
|
-
config: { agentSlug: router.agentSlug?.trim() ?? '', task: '', outputType: 'json' },
|
|
39
|
-
},
|
|
40
|
-
go('go_classified', '{{steps.classify.output.response.screen}}'),
|
|
41
|
-
];
|
|
8
|
+
const first = 'start';
|
|
9
|
+
const keys = [DEFAULT_ROUTE_KEY, TEXT_KEY];
|
|
10
|
+
const home = (screen) => carrying(keys, DEFAULT_ROUTE_KEY, screen);
|
|
11
|
+
const typed = `{{steps.ask_${first}.output.resumeData.data.message}}`;
|
|
42
12
|
const config = {
|
|
43
13
|
trigger: { type: 'MANUAL', config: {} },
|
|
44
14
|
steps: [
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
cycleStep(first, { [DEFAULT_ROUTE_KEY]: first, [TEXT_KEY]: '' }, [
|
|
16
|
+
switchStep(`${first}_route`, [
|
|
17
|
+
screenCase(first, title, [
|
|
18
|
+
{
|
|
19
|
+
id: `ask_${first}`,
|
|
20
|
+
type: 'WAIT',
|
|
21
|
+
config: {
|
|
22
|
+
mode: 'approval',
|
|
23
|
+
reason: title,
|
|
24
|
+
prompt: greeting,
|
|
25
|
+
form: {
|
|
26
|
+
fields: [
|
|
27
|
+
{ type: 'select', name: 'choice', label: 'Choose one', options: [] },
|
|
28
|
+
{ type: 'text', name: 'message', label: 'Or type your question' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
52
33
|
{
|
|
53
|
-
id:
|
|
54
|
-
type: '
|
|
34
|
+
id: `typed_${first}`,
|
|
35
|
+
type: 'CONDITIONAL',
|
|
55
36
|
config: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
mode: 'approval',
|
|
66
|
-
reason: title,
|
|
67
|
-
prompt: greeting,
|
|
68
|
-
form: {
|
|
69
|
-
fields: [
|
|
70
|
-
{ type: 'select', name: 'choice', label: 'Choose one', options: [] },
|
|
71
|
-
{ type: 'text', name: 'message', label: 'Or type your question' },
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: 'typed_start',
|
|
78
|
-
type: 'CONDITIONAL',
|
|
79
|
-
config: {
|
|
80
|
-
condition: {
|
|
81
|
-
all: [
|
|
82
|
-
{ variable: message('ask_start'), operator: 'exists' },
|
|
83
|
-
{ variable: message('ask_start'), operator: 'neq', value: '' },
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
if_true: [go('route_start', 'ai_router', message('ask_start'))],
|
|
87
|
-
if_false: [go('go_start', choice('ask_start'))],
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: 'AI router',
|
|
94
|
-
condition: { variable: screenRef, operator: 'eq', value: 'ai_router' },
|
|
95
|
-
steps: deciding,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: 'Finish',
|
|
99
|
-
condition: { variable: screenRef, operator: 'eq', value: 'done' },
|
|
100
|
-
steps: [{ id: 'finish', type: 'FINISH', config: { target: cycle, with: { outcome: 'done' } } }],
|
|
101
|
-
},
|
|
37
|
+
condition: {
|
|
38
|
+
all: [
|
|
39
|
+
{ variable: typed, operator: 'exists' },
|
|
40
|
+
{ variable: typed, operator: 'neq', value: '' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
if_true: [jumpStep(`route_${first}`, first, { ...home(ROUTER_ID), [TEXT_KEY]: typed })],
|
|
44
|
+
if_false: [
|
|
45
|
+
jumpStep(`go_${first}`, first, home(`{{steps.ask_${first}.output.resumeData.data.choice}}`)),
|
|
102
46
|
],
|
|
103
|
-
default: [go('unknown_screen', 'start')],
|
|
104
47
|
},
|
|
105
48
|
},
|
|
106
|
-
],
|
|
107
|
-
|
|
108
|
-
|
|
49
|
+
]),
|
|
50
|
+
screenCase(ROUTER_ID, 'AI router', decidingWith(options), DEFAULT_ROUTE_KEY),
|
|
51
|
+
screenCase('done', 'Finish', [finishStep('finish', first, { outcome: 'done' })]),
|
|
52
|
+
], [jumpStep('unknown_screen', first, home(first))]),
|
|
53
|
+
]),
|
|
109
54
|
],
|
|
110
55
|
};
|
|
111
|
-
// Writes the router's instructions and allowed screens from the screens above.
|
|
112
56
|
return { config: refreshDerived(config), metadata: { kind: CONVERSATIONAL_FLOW_KIND } };
|
|
113
57
|
}
|
|
58
|
+
/** The key holding what they typed, on the way to the router. */
|
|
59
|
+
const TEXT_KEY = 'text';
|
|
60
|
+
const ROUTER_ID = 'ai_router';
|
|
61
|
+
/**
|
|
62
|
+
* What reads a typed message, and the jump that carries its answer on. A
|
|
63
|
+
* classifier puts the message in one of the screens; an agent is asked for the
|
|
64
|
+
* same answer as JSON. What either is told is written by `settle`.
|
|
65
|
+
*/
|
|
66
|
+
function decidingWith(options) {
|
|
67
|
+
const router = options.router ?? (options.agentSlug ? { kind: 'agent', agentSlug: options.agentSlug } : { kind: 'classifier' });
|
|
68
|
+
const keys = [DEFAULT_ROUTE_KEY, TEXT_KEY];
|
|
69
|
+
if (router.kind === 'agent') {
|
|
70
|
+
const step = {
|
|
71
|
+
id: 'classify',
|
|
72
|
+
type: AGENT_STEP_TYPE,
|
|
73
|
+
config: { agentSlug: router.agentSlug?.trim() ?? '', task: '', outputType: 'json' },
|
|
74
|
+
};
|
|
75
|
+
return [step, jumpStep('go_classified', 'start', carrying(keys, DEFAULT_ROUTE_KEY, `{{steps.classify.output.response.${DEFAULT_ROUTE_KEY}}}`))];
|
|
76
|
+
}
|
|
77
|
+
const step = {
|
|
78
|
+
id: 'classify',
|
|
79
|
+
type: CLASSIFIER_STEP_TYPE,
|
|
80
|
+
config: {
|
|
81
|
+
input: '',
|
|
82
|
+
instructions: '',
|
|
83
|
+
classes: {},
|
|
84
|
+
...(router.model ? { model: router.model } : {}),
|
|
85
|
+
...(router.credentialName ? { credentialName: router.credentialName } : {}),
|
|
86
|
+
...(router.minConfidence !== undefined ? { minConfidence: router.minConfidence } : {}),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
return [step, jumpStep('go_classified', 'start', carrying(keys, DEFAULT_ROUTE_KEY, '{{steps.classify.output.class}}'))];
|
|
90
|
+
}
|
|
114
91
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/conversational-flow/create.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,cAAc,EAAE,MAAM,aA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