jsfe 0.9.85 → 0.9.87

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/README.md CHANGED
@@ -271,7 +271,8 @@ async function aiCallback(systemInstruction, userMessage, jsonSchema) {
271
271
  ```
272
272
 
273
273
  **AI Callback Interface:**
274
- - **Input**: `systemInstruction` (string), `userMessage` (string)
274
+ - **Input**: `systemInstruction` (string), `userMessage` (string), optional `jsonSchema` (string), and
275
+ optional `request` (object — intent detection only, see below)
275
276
  - **Output**: AI response as a string
276
277
  - **Purpose**: Analyzes user input to detect workflow intents and generate responses
277
278
  - **Integration**: The engine calls this function when it needs AI analysis for intent detection
@@ -288,6 +289,49 @@ async function aiCallback(systemInstruction, userMessage, jsonSchema) {
288
289
 
289
290
  Both parameters are carefully engineered by the engine to work together for optimal intent detection. The engine automatically constructs comprehensive, context-aware prompts that provide the AI with all necessary information for accurate workflow selection and response generation. Your aiCallback implementation only needs to send these pre-constructed arguments to your AI service and return the response.
290
291
 
292
+ **The structured `request` argument (intent detection only):**
293
+ For intent detection — and only there — the engine passes a 4th argument: the same call in
294
+ structured form, so a host can answer it with a classifier instead of a text model.
295
+
296
+ ```javascript
297
+ async function aiCallback(systemInstruction, userMessage, jsonSchema, request) {
298
+ if (request?.task === 'detect_flow') {
299
+ // request.input — the user input, exactly as in <user-input>
300
+ // request.conversation — [{ role: 'user' | 'assistant', content }], oldest first; [] when none
301
+ // request.flows — [{ id, name, description, parameters: [{ name, description, type?, enum? }] }]
302
+ // Reply exactly as the text path does: a JSON string { flowName, parameters }, flowName being a
303
+ // flow's name (or "None"). The engine validates it the same way, enums included.
304
+ }
305
+ // ... every other call, and the text path: unchanged
306
+ }
307
+ ```
308
+
309
+ `systemInstruction` and `userMessage` are still the complete text prompt on that call, so a host can
310
+ run its text model alongside the classifier (for example, for free-text parameters). A callback that
311
+ ignores the 4th argument behaves exactly as before; every other call still receives three arguments.
312
+
313
+ **Host helpers — `jsfe/host`:**
314
+ Pure functions for the host side of `aiCallback`, so a production host and a local test harness
315
+ share one implementation. Loading `jsfe/host` never loads the engine.
316
+
317
+ ```javascript
318
+ import { buildAiRequest, isDetectFlowRequest, toFlowRequest, fromFlowAnswers } from 'jsfe/host';
319
+
320
+ // An OpenAI-compatible chat-completions body from a model description. It picks the right
321
+ // response_format for each kind of jsonSchema argument, and never sends `response_format: null`.
322
+ const body = buildAiRequest(
323
+ { name: 'gpt-4o-mini', reservedReplySize: 1024, supportsSchema: true },
324
+ systemInstruction, userMessage, jsonSchema);
325
+ ```
326
+
327
+ - `buildAiRequest(model, systemInstruction, userMessage, jsonSchema)`, `parseSchemaArg`, `schemaName`.
328
+ `model` fields: `name`, `reservedReplySize`, and the optional `tokenParam`, `supportsSchema`,
329
+ `fixedSampling` and `extraParams`.
330
+ - `isDetectFlowRequest`, `toFlowRequest` / `fromFlowAnswers` (which flow), `toParameterRequest` /
331
+ `fromParameterAnswers` (its enum and boolean parameters), `freeTextParameters`,
332
+ `mergeTextParameters`, `INTENT_YES_THRESHOLD`: these map the structured intent-detection
333
+ request to TypeSafe System One and back. The host sends the requests.
334
+
291
335
  **Alternative AI Services:**
292
336
  You can integrate any AI service (Claude, Gemini, local LLMs, etc.) by implementing this same interface. The engine only requires a function that takes system instructions and user input, then returns an AI response.
293
337
 
@@ -325,6 +369,17 @@ const flowsMenu = [
325
369
  - `false` or omitted: Helper/sub-flows called by other flows, not directly accessible
326
370
  - **Validation Impact**: Only primary flows are validated as top-level workflows during initialization
327
371
  - **AI Detection**: Only primary flows are considered for intent detection and user interaction
372
+ - **`parameters`** (optional): Values intent detection may extract from the triggering input and
373
+ inject as flow variables. Each is `{ name, description, type?, enum? }`:
374
+ - `type` defaults to `"string"`.
375
+ - `enum` (string parameters only) lists the allowed values. The prompt shows them
376
+ (`ticket_type (string, one of: "Fraud" | "Cancellation")`), and the engine enforces them on the
377
+ reply: a value matching ignoring case and surrounding whitespace is replaced by the declared
378
+ spelling, and any other value is **dropped** with a warning — so the flow asks for it instead of
379
+ running on a value it never declared. Validation rejects an empty enum, a non-string or padded
380
+ value, a value repeated ignoring case, and an enum on a non-string type.
381
+ - Declare an enum wherever the allowed values are a closed set. It also lets a host answer intent
382
+ detection with a classifier instead of a text model (see the `request` argument of `aiCallback`).
328
383
  - **`steps`** (required): Array of workflow steps to execute
329
384
  - **`variables`** (optional): Flow-specific variable definitions with types and descriptions
330
385
  - **`version`** (optional): Flow version for compatibility tracking (defaults to "1.0")
@@ -0,0 +1,10 @@
1
+ /**
2
+ * jsfe/host — pure helpers for the HOST side of aiCallback, so a production host and a local
3
+ * test harness share one implementation instead of copying it. Zero runtime imports: loading
4
+ * `jsfe/host` never loads the engine.
5
+ *
6
+ * import { buildAiRequest, isDetectFlowRequest, toFlowRequest } from 'jsfe/host';
7
+ */
8
+ export * from './request.js';
9
+ export * from './systemone-intent.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * jsfe/host — pure helpers for the HOST side of aiCallback, so a production host and a local
3
+ * test harness share one implementation instead of copying it. Zero runtime imports: loading
4
+ * `jsfe/host` never loads the engine.
5
+ *
6
+ * import { buildAiRequest, isDetectFlowRequest, toFlowRequest } from 'jsfe/host';
7
+ */
8
+ export * from './request.js';
9
+ export * from './systemone-intent.js';
@@ -0,0 +1,57 @@
1
+ /**
2
+ * aiCallback request shaping for an OpenAI-compatible host — pure, zero imports.
3
+ *
4
+ * jsfe calls the host's aiCallback(systemInstruction, userMessage, jsonSchema, request?). These
5
+ * helpers turn that call into a chat-completions request body, so a production host and a local
6
+ * test harness build byte-identical requests from one implementation.
7
+ */
8
+ /**
9
+ * The request-relevant description of one model. Every field but `name` is optional:
10
+ * tokenParam — 'max_completion_tokens' for models that reject `max_tokens` (GPT-5 family).
11
+ * reservedReplySize — the reply's token cap.
12
+ * supportsSchema — the model honours a json_schema `response_format`.
13
+ * fixedSampling — the model rejects any non-default temperature/top_p/penalties.
14
+ * extraParams — raw body pass-through (e.g. `reasoning_effort`, `thinking`).
15
+ */
16
+ export interface HostModel {
17
+ name: string;
18
+ tokenParam?: string;
19
+ reservedReplySize?: number;
20
+ supportsSchema?: boolean;
21
+ fixedSampling?: boolean;
22
+ extraParams?: Record<string, unknown>;
23
+ }
24
+ export interface ResponseFormatWrapper {
25
+ type?: string;
26
+ json_schema?: {
27
+ name?: string;
28
+ strict?: boolean;
29
+ schema?: unknown;
30
+ };
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ * Parse aiCallback's `jsonSchema` argument, which is NOT always JSON. jsfe passes:
35
+ * - a JSON `response_format` wrapper, e.g. {type:'json_schema', json_schema:{name:'detect_flow',…}}
36
+ * - a PLAIN-TEXT schema description ("city: string (required) - …") on the tool-argument path
37
+ * - nothing at all (voice cleanup, language detection)
38
+ * Returns null for the last two.
39
+ */
40
+ export declare function parseSchemaArg(jsonSchema: unknown): ResponseFormatWrapper | null;
41
+ /** The schema's name, or null. `detect_flow` and `intent_analysis` are the two jsfe uses. */
42
+ export declare function schemaName(jsonSchema: unknown): string | null;
43
+ /**
44
+ * Build the chat-completions request body for one model.
45
+ *
46
+ * `response_format` rules:
47
+ * - detect_flow: omitted. Its schema carries dynamic per-flow parameters that json mode
48
+ * rejects; the host still has the schema to validate the answer.
49
+ * - a response_format wrapper + a model that supports schemas: sent as-is.
50
+ * - any other JSON schema, or a model without schema support: `{type:'json_object'}`.
51
+ * - NOT parseable as JSON (the plain-text description): omitted entirely — never
52
+ * `response_format: null`, whose handling is undefined across vendors.
53
+ *
54
+ * Sampling is deterministic (temperature 0, a fixed seed) unless the model is `fixedSampling`.
55
+ */
56
+ export declare function buildAiRequest(model: HostModel, systemInstruction: string, userMessage: string, jsonSchema?: unknown): Record<string, unknown>;
57
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/host/request.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACpE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAYhF;AAED,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,OAAO,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * aiCallback request shaping for an OpenAI-compatible host — pure, zero imports.
3
+ *
4
+ * jsfe calls the host's aiCallback(systemInstruction, userMessage, jsonSchema, request?). These
5
+ * helpers turn that call into a chat-completions request body, so a production host and a local
6
+ * test harness build byte-identical requests from one implementation.
7
+ */
8
+ /**
9
+ * Parse aiCallback's `jsonSchema` argument, which is NOT always JSON. jsfe passes:
10
+ * - a JSON `response_format` wrapper, e.g. {type:'json_schema', json_schema:{name:'detect_flow',…}}
11
+ * - a PLAIN-TEXT schema description ("city: string (required) - …") on the tool-argument path
12
+ * - nothing at all (voice cleanup, language detection)
13
+ * Returns null for the last two.
14
+ */
15
+ export function parseSchemaArg(jsonSchema) {
16
+ if (!jsonSchema) {
17
+ return null;
18
+ }
19
+ else {
20
+ // a schema argument was supplied — it may still not be JSON
21
+ }
22
+ try {
23
+ const parsed = JSON.parse(String(jsonSchema));
24
+ return parsed && typeof parsed === 'object' ? parsed : null;
25
+ }
26
+ catch {
27
+ return null; // plain-text schema description — an instruction for the prompt, not a response_format
28
+ }
29
+ }
30
+ /** The schema's name, or null. `detect_flow` and `intent_analysis` are the two jsfe uses. */
31
+ export function schemaName(jsonSchema) {
32
+ return parseSchemaArg(jsonSchema)?.json_schema?.name ?? null;
33
+ }
34
+ /**
35
+ * Build the chat-completions request body for one model.
36
+ *
37
+ * `response_format` rules:
38
+ * - detect_flow: omitted. Its schema carries dynamic per-flow parameters that json mode
39
+ * rejects; the host still has the schema to validate the answer.
40
+ * - a response_format wrapper + a model that supports schemas: sent as-is.
41
+ * - any other JSON schema, or a model without schema support: `{type:'json_object'}`.
42
+ * - NOT parseable as JSON (the plain-text description): omitted entirely — never
43
+ * `response_format: null`, whose handling is undefined across vendors.
44
+ *
45
+ * Sampling is deterministic (temperature 0, a fixed seed) unless the model is `fixedSampling`.
46
+ */
47
+ export function buildAiRequest(model, systemInstruction, userMessage, jsonSchema) {
48
+ const parsedSchema = parseSchemaArg(jsonSchema);
49
+ const useResponseFormat = parsedSchema !== null && parsedSchema.json_schema?.name !== 'detect_flow';
50
+ const tokenParam = model.tokenParam || 'max_tokens';
51
+ return {
52
+ messages: [
53
+ { role: 'system', content: systemInstruction },
54
+ { role: 'user', content: userMessage },
55
+ ],
56
+ model: model.name,
57
+ [tokenParam]: model.reservedReplySize,
58
+ stream: false,
59
+ ...(model.extraParams || {}),
60
+ ...(model.fixedSampling ? {} : {
61
+ top_p: 0.000000001,
62
+ seed: 1024,
63
+ temperature: 0,
64
+ n: 1,
65
+ presence_penalty: 0,
66
+ frequency_penalty: 0,
67
+ logit_bias: {},
68
+ }),
69
+ ...(useResponseFormat
70
+ ? (model.supportsSchema && parsedSchema.json_schema
71
+ ? { response_format: parsedSchema }
72
+ : { response_format: { type: 'json_object' } })
73
+ : {}),
74
+ };
75
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Intent detection (`detect_flow`) ⇄ TypeSafe System One — mapping only, zero imports.
3
+ *
4
+ * jsfe hands aiCallback a 4th argument on intent detection: the call in structured form,
5
+ * `{ task: 'detect_flow', input, conversation, flows }`, each flow with its parameters and any
6
+ * declared `enum`. That is what a classifier needs, so this module maps it to System One questions
7
+ * and the answers back to the reply jsfe expects: `{ flowName, parameters }`. Two stages:
8
+ *
9
+ * 1. one noul per flow: "should `latest_message` start this workflow?" — argmax, if it clears
10
+ * INTENT_YES_THRESHOLD, else "None".
11
+ * 2. only for the chosen flow, and only if it declares one: a noul per ENUM value and per
12
+ * BOOLEAN parameter.
13
+ * Every other parameter (free text: a city, an account number…) is not the classifier's; the
14
+ * host decides whether to take it from a text model — see freeTextParameters().
15
+ *
16
+ * The host sends the bodies (POST …/v1/systemone) and owns the HTTP, the key and the timeouts.
17
+ *
18
+ * A question that comes back without a usable answer FAILS the call, so the host can fall back
19
+ * to a text model. A missing flow answer read as "no" would silently send the turn nowhere.
20
+ */
21
+ import type { DetectFlowRequest } from '../index.js';
22
+ /** One flow entry of the structured intent-detection request. */
23
+ export type DetectFlowRequestFlow = DetectFlowRequest['flows'][number];
24
+ /** A noul at or above this is a yes. */
25
+ export declare const INTENT_YES_THRESHOLD = 0.5;
26
+ /** One System One request body plus the index that maps each question id back to what it asks. */
27
+ export interface SystemOneCall<I> {
28
+ body: {
29
+ model: string;
30
+ state: Record<string, unknown>;
31
+ questions: Record<string, unknown>;
32
+ };
33
+ index: I[];
34
+ }
35
+ export interface FlowQuestion {
36
+ id: string;
37
+ flow: number;
38
+ }
39
+ export type ParameterQuestion = {
40
+ id: string;
41
+ kind: 'enum';
42
+ param: string;
43
+ value: string;
44
+ } | {
45
+ id: string;
46
+ kind: 'boolean';
47
+ param: string;
48
+ };
49
+ /** System One's answers, keyed by question id. */
50
+ export type SystemOneAnswers = Record<string, {
51
+ noul?: unknown;
52
+ } | undefined> | undefined;
53
+ export interface IntentReply {
54
+ flowName: string;
55
+ parameters: Record<string, unknown>;
56
+ }
57
+ export interface MapOptions {
58
+ model: string;
59
+ assistantInstructions: string;
60
+ }
61
+ /** Is this a jsfe intent-detection request this module can map? */
62
+ export declare function isDetectFlowRequest(request: unknown): request is DetectFlowRequest;
63
+ /** Parameters of `flow` the classifier does not answer: neither an enum nor a boolean. */
64
+ export declare function freeTextParameters(flow: DetectFlowRequestFlow | null | undefined): string[];
65
+ /**
66
+ * STAGE 1 — which flow. One noul per flow. `assistantInstructions` is jsfe's own task + rules (the
67
+ * text prompt's system instruction without its JSON-schema tail), so a classifier and a text model
68
+ * judge by one rule set.
69
+ */
70
+ export declare function toFlowRequest(request: DetectFlowRequest, { model, assistantInstructions }: MapOptions): SystemOneCall<FlowQuestion>;
71
+ /**
72
+ * Decodes stage 1. Throws if any question is unanswered. Returns `{ flow, scores }` — `flow` is the
73
+ * chosen request entry, or null for "None"; `scores` the top three, for logging.
74
+ */
75
+ export declare function fromFlowAnswers(answers: SystemOneAnswers, index: FlowQuestion[], request: DetectFlowRequest, threshold?: number): {
76
+ flow: DetectFlowRequestFlow | null;
77
+ scores: {
78
+ name: string;
79
+ p: number;
80
+ }[];
81
+ };
82
+ /** Does `flow` declare anything stage 2 answers (an enum or a boolean)? */
83
+ export declare function hasJevParameters(flow: DetectFlowRequestFlow | null | undefined): boolean;
84
+ /**
85
+ * STAGE 2 — the chosen flow's enum and boolean parameters: one noul per enum value, one per
86
+ * boolean. Each parameter's description is its rule. Free text is not asked.
87
+ *
88
+ * The flow and the rules are stated ONCE, in `assistant_instructions`; each question names its
89
+ * parameter only. Repeating a long rule in every question of its enum multiplies the body size
90
+ * and the latency for identical answers.
91
+ */
92
+ export declare function toParameterRequest(request: DetectFlowRequest, flow: DetectFlowRequestFlow, { model, assistantInstructions }: MapOptions): SystemOneCall<ParameterQuestion>;
93
+ /**
94
+ * Decodes stage 2 into parameters: an enum takes its argmax value if it clears the cut, a boolean is
95
+ * true if it clears it; otherwise the parameter is OMITTED (the flow asks / its default applies),
96
+ * never set false. Throws if any question is unanswered.
97
+ */
98
+ export declare function fromParameterAnswers(answers: SystemOneAnswers, index: ParameterQuestion[], threshold?: number): Record<string, unknown>;
99
+ /**
100
+ * Merges a text model's free-text parameters into the classifier's reply — only when the text model
101
+ * chose the SAME flow (its parameters were extracted for its own choice), and only the parameters
102
+ * the classifier does not answer. The classifier's enum/boolean values always win.
103
+ */
104
+ export declare function mergeTextParameters(jevReply: IntentReply, jevFlow: DetectFlowRequestFlow | null | undefined, textReply: {
105
+ flowName?: unknown;
106
+ parameters?: Record<string, unknown>;
107
+ } | null | undefined): IntentReply;
108
+ //# sourceMappingURL=systemone-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemone-intent.d.ts","sourceRoot":"","sources":["../../src/host/systemone-intent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,iEAAiE;AACjE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,wCAAwC;AACxC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAqBxC,kGAAkG;AAClG,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,IAAI,EAAE;QAAE,KAAK,EAA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AU,GAAG,aAAa,CAAC,YAAY,CAAC,CAYnI;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,EAAE,iBAAiB,EAC1B,SAAS,GAAE,MAA6B,GACvC;IAAE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAO/E;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAExF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,qBAAqB,EAC3B,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,UAAU,GAC3C,aAAa,CAAC,iBAAiB,CAAC,CAkClC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,iBAAiB,EAAE,EAC1B,SAAS,GAAE,MAA6B,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,EACjD,SAAS,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACzF,WAAW,CAQb"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Intent detection (`detect_flow`) ⇄ TypeSafe System One — mapping only, zero imports.
3
+ *
4
+ * jsfe hands aiCallback a 4th argument on intent detection: the call in structured form,
5
+ * `{ task: 'detect_flow', input, conversation, flows }`, each flow with its parameters and any
6
+ * declared `enum`. That is what a classifier needs, so this module maps it to System One questions
7
+ * and the answers back to the reply jsfe expects: `{ flowName, parameters }`. Two stages:
8
+ *
9
+ * 1. one noul per flow: "should `latest_message` start this workflow?" — argmax, if it clears
10
+ * INTENT_YES_THRESHOLD, else "None".
11
+ * 2. only for the chosen flow, and only if it declares one: a noul per ENUM value and per
12
+ * BOOLEAN parameter.
13
+ * Every other parameter (free text: a city, an account number…) is not the classifier's; the
14
+ * host decides whether to take it from a text model — see freeTextParameters().
15
+ *
16
+ * The host sends the bodies (POST …/v1/systemone) and owns the HTTP, the key and the timeouts.
17
+ *
18
+ * A question that comes back without a usable answer FAILS the call, so the host can fall back
19
+ * to a text model. A missing flow answer read as "no" would silently send the turn nowhere.
20
+ */
21
+ /** A noul at or above this is a yes. */
22
+ export const INTENT_YES_THRESHOLD = 0.5;
23
+ const FLOW_QUESTION = 'Should `latest_message` start the workflow described in `flow`?';
24
+ const FLOW_CRITERIA = {
25
+ true: "`latest_message`, read with `conversation`, is what `flow`'s description says should trigger it: the user asks for its action or information, or raises the problem it exists to handle.",
26
+ false: "It only shares a topic with `flow`, is something `flow`'s description does not cover, or is a greeting, acknowledgement or fragment that asks for nothing. A question about an available balance or credit is not a request to pay, and a complaint about a charge is not a request to pay.",
27
+ };
28
+ const ENUM_CRITERIA = (value) => ({
29
+ true: `The rules for \`parameter\` make \`${value}\` the correct value for what the customer said.`,
30
+ false: 'Another value, or none, is correct; or the customer has not said enough to tell.',
31
+ });
32
+ const BOOLEAN_CRITERIA = {
33
+ true: 'The rules for `parameter` make it true for what the customer said.',
34
+ false: 'The rules do not make it true, or the customer has not said enough to tell.',
35
+ };
36
+ const isEnum = (p) => Array.isArray(p.enum) && p.enum.length > 0;
37
+ const isBoolean = (p) => p.type === 'boolean';
38
+ /** Is this a jsfe intent-detection request this module can map? */
39
+ export function isDetectFlowRequest(request) {
40
+ const r = request;
41
+ return !!r && r.task === 'detect_flow' && Array.isArray(r.flows) && r.flows.length > 0;
42
+ }
43
+ /** Parameters of `flow` the classifier does not answer: neither an enum nor a boolean. */
44
+ export function freeTextParameters(flow) {
45
+ return (flow?.parameters || []).filter(p => !isEnum(p) && !isBoolean(p)).map(p => p.name);
46
+ }
47
+ const stateOf = (request, assistantInstructions) => ({
48
+ assistant_instructions: assistantInstructions,
49
+ conversation: (request.conversation || []).map(t => ({ role: t.role, content: t.content })),
50
+ latest_message: request.input,
51
+ });
52
+ function answersOf(answers, index) {
53
+ const p = new Map();
54
+ for (const q of index) {
55
+ const noul = Number(answers?.[q.id]?.noul);
56
+ if (!Number.isFinite(noul)) {
57
+ throw new Error(`System One intent: question ${q.id} unanswered`);
58
+ }
59
+ else {
60
+ p.set(q.id, noul);
61
+ }
62
+ }
63
+ return p;
64
+ }
65
+ /**
66
+ * STAGE 1 — which flow. One noul per flow. `assistantInstructions` is jsfe's own task + rules (the
67
+ * text prompt's system instruction without its JSON-schema tail), so a classifier and a text model
68
+ * judge by one rule set.
69
+ */
70
+ export function toFlowRequest(request, { model, assistantInstructions }) {
71
+ const questions = {};
72
+ const index = [];
73
+ request.flows.forEach((flow, f) => {
74
+ const id = `f${f}`;
75
+ questions[id] = {
76
+ type: 'noul', criteria: FLOW_CRITERIA,
77
+ instructions: { flow: { name: flow.name, description: String(flow.description ?? '') }, question: FLOW_QUESTION },
78
+ };
79
+ index.push({ id, flow: f });
80
+ });
81
+ return { body: { model, state: stateOf(request, assistantInstructions), questions }, index };
82
+ }
83
+ /**
84
+ * Decodes stage 1. Throws if any question is unanswered. Returns `{ flow, scores }` — `flow` is the
85
+ * chosen request entry, or null for "None"; `scores` the top three, for logging.
86
+ */
87
+ export function fromFlowAnswers(answers, index, request, threshold = INTENT_YES_THRESHOLD) {
88
+ const p = answersOf(answers, index);
89
+ const ranked = index
90
+ .map(q => ({ name: request.flows[q.flow].name, f: q.flow, p: p.get(q.id) }))
91
+ .sort((a, b) => b.p - a.p);
92
+ const scores = ranked.slice(0, 3).map(({ name, p: prob }) => ({ name, p: prob }));
93
+ return { flow: ranked[0] && ranked[0].p >= threshold ? request.flows[ranked[0].f] : null, scores };
94
+ }
95
+ /** Does `flow` declare anything stage 2 answers (an enum or a boolean)? */
96
+ export function hasJevParameters(flow) {
97
+ return (flow?.parameters || []).some(p => isEnum(p) || isBoolean(p));
98
+ }
99
+ /**
100
+ * STAGE 2 — the chosen flow's enum and boolean parameters: one noul per enum value, one per
101
+ * boolean. Each parameter's description is its rule. Free text is not asked.
102
+ *
103
+ * The flow and the rules are stated ONCE, in `assistant_instructions`; each question names its
104
+ * parameter only. Repeating a long rule in every question of its enum multiplies the body size
105
+ * and the latency for identical answers.
106
+ */
107
+ export function toParameterRequest(request, flow, { model, assistantInstructions }) {
108
+ const questions = {};
109
+ const index = [];
110
+ const flowRef = { name: flow.name };
111
+ const rules = {};
112
+ (flow.parameters || []).forEach((p, k) => {
113
+ const parameter = { name: p.name };
114
+ if (isEnum(p)) {
115
+ p.enum.forEach((value, v) => {
116
+ const id = `p${k}v${v}`;
117
+ questions[id] = {
118
+ type: 'noul', criteria: ENUM_CRITERIA(value), instructions: {
119
+ flow: flowRef, parameter, candidate_value: value,
120
+ question: `Is \`${value}\` the correct value of \`${p.name}\` for \`latest_message\`?`,
121
+ },
122
+ };
123
+ index.push({ id, kind: 'enum', param: p.name, value });
124
+ });
125
+ }
126
+ else if (isBoolean(p)) {
127
+ const id = `p${k}`;
128
+ questions[id] = {
129
+ type: 'noul', criteria: BOOLEAN_CRITERIA, instructions: {
130
+ flow: flowRef, parameter, question: `Should \`${p.name}\` be true for \`latest_message\`?`,
131
+ },
132
+ };
133
+ index.push({ id, kind: 'boolean', param: p.name });
134
+ }
135
+ else {
136
+ return; // free text — not the classifier's; see freeTextParameters()
137
+ }
138
+ rules[p.name] = String(p.description ?? '');
139
+ });
140
+ const instructions = `${assistantInstructions}\n\nThe workflow \`${flow.name}\` starts for \`latest_message\`: ${String(flow.description ?? '')}\n\n` +
141
+ `Each question asks for one of its parameters. The rules for each parameter, by name:\n${JSON.stringify(rules, null, 1)}`;
142
+ return { body: { model, state: stateOf(request, instructions), questions }, index };
143
+ }
144
+ /**
145
+ * Decodes stage 2 into parameters: an enum takes its argmax value if it clears the cut, a boolean is
146
+ * true if it clears it; otherwise the parameter is OMITTED (the flow asks / its default applies),
147
+ * never set false. Throws if any question is unanswered.
148
+ */
149
+ export function fromParameterAnswers(answers, index, threshold = INTENT_YES_THRESHOLD) {
150
+ const p = answersOf(answers, index);
151
+ const parameters = {};
152
+ const best = new Map();
153
+ for (const q of index) {
154
+ const prob = p.get(q.id);
155
+ if (q.kind === 'boolean') {
156
+ if (prob >= threshold)
157
+ parameters[q.param] = true;
158
+ else { /* omitted */ }
159
+ }
160
+ else {
161
+ const cur = best.get(q.param);
162
+ if (!cur || prob > cur.p)
163
+ best.set(q.param, { value: q.value, p: prob });
164
+ else { /* lower */ }
165
+ }
166
+ }
167
+ for (const [param, { value, p: prob }] of best) {
168
+ if (prob >= threshold)
169
+ parameters[param] = value;
170
+ else { /* omitted: the flow asks */ }
171
+ }
172
+ return parameters;
173
+ }
174
+ /**
175
+ * Merges a text model's free-text parameters into the classifier's reply — only when the text model
176
+ * chose the SAME flow (its parameters were extracted for its own choice), and only the parameters
177
+ * the classifier does not answer. The classifier's enum/boolean values always win.
178
+ */
179
+ export function mergeTextParameters(jevReply, jevFlow, textReply) {
180
+ if (!jevFlow || !textReply || String(textReply.flowName).toLowerCase() !== jevFlow.name.toLowerCase()) {
181
+ return jevReply;
182
+ }
183
+ else {
184
+ const free = new Set(freeTextParameters(jevFlow));
185
+ const extra = Object.fromEntries(Object.entries(textReply.parameters || {}).filter(([k]) => free.has(k)));
186
+ return { flowName: jevReply.flowName, parameters: { ...extra, ...jevReply.parameters } };
187
+ }
188
+ }
package/dist/index.d.ts CHANGED
@@ -135,7 +135,30 @@ export interface ContextEntry {
135
135
  toolName?: string;
136
136
  metadata?: Record<string, unknown>;
137
137
  }
138
- export type AiCallbackFunction = ((systemInstruction: string, userMessage: string, jsonSchema?: string) => Promise<string>) | null;
138
+ export type AiCallbackFunction = ((systemInstruction: string, userMessage: string, jsonSchema?: string, request?: AiCallbackRequest) => Promise<string>) | null;
139
+ /** A flow parameter as the intent-detection call sees it. */
140
+ export interface FlowParameterDefinition {
141
+ name: string;
142
+ description: string;
143
+ type?: string;
144
+ enum?: string[];
145
+ }
146
+ /** Structured form of the intent-detection call; see AiCallbackFunction. */
147
+ export interface DetectFlowRequest {
148
+ task: 'detect_flow';
149
+ input: string;
150
+ conversation: {
151
+ role: 'user' | 'assistant';
152
+ content: string;
153
+ }[];
154
+ flows: {
155
+ id: string;
156
+ name: string;
157
+ description: string;
158
+ parameters: FlowParameterDefinition[];
159
+ }[];
160
+ }
161
+ export type AiCallbackRequest = DetectFlowRequest;
139
162
  /**
140
163
  * @interface EngineSessionContext
141
164
  * @property {string} sessionId - Unique identifier for the session
@@ -313,11 +336,7 @@ export interface FlowDefinition {
313
336
  version: string;
314
337
  primary?: boolean;
315
338
  interruptable?: boolean;
316
- parameters?: {
317
- name: string;
318
- description: string;
319
- type?: string;
320
- }[];
339
+ parameters?: FlowParameterDefinition[];
321
340
  steps: FlowStep[];
322
341
  variables?: Record<string, {
323
342
  type: string;
@@ -683,6 +702,12 @@ export declare class WorkflowEngine implements Engine {
683
702
  * Validates flow metadata and basic structure
684
703
  */
685
704
  private _validateFlowMetadata;
705
+ /**
706
+ * Validates the parameters intent detection extracts: unique names, and a well-formed enum.
707
+ * An enum is a non-empty list of unique, non-empty strings, allowed only on a string parameter -
708
+ * values are matched as strings, so on any other type it could never match.
709
+ */
710
+ private _validateFlowParameters;
686
711
  /**
687
712
  * Validates flow variable definitions
688
713
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAyBH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK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AoDzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmCxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4C3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiDzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAmC7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkC5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmChC;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,GAAE,GAAQ,GAAG,GAAG;IAkHxC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA6D5B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA2BhC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAiC9B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IA0FnC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA6BhC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,2BAA2B;CAKpC"}
package/dist/index.js CHANGED
@@ -2323,7 +2323,7 @@ function withTimeout(promise, timeoutMs) {
2323
2323
  * @param timeoutMs - Timeout in milliseconds for the AI call
2324
2324
  * @returns AI response as string
2325
2325
  */
2326
- async function fetchAiResponse(systemInstruction, userMessage, aiCallback, timeoutMs = 1000, jsonSchema) {
2326
+ async function fetchAiResponse(systemInstruction, userMessage, aiCallback, timeoutMs = 1000, jsonSchema, request) {
2327
2327
  try {
2328
2328
  logger.debug(`fetchAiResponse called with system instruction length: ${systemInstruction.length}, user message: "${userMessage}", timeout: ${timeoutMs}ms, jsonMode: ${!!jsonSchema}`);
2329
2329
  if (!aiCallback) {
@@ -2331,7 +2331,9 @@ async function fetchAiResponse(systemInstruction, userMessage, aiCallback, timeo
2331
2331
  }
2332
2332
  // Use the user-provided AI callback function with timeout
2333
2333
  // Pass jsonSchema so the host can configure the API for structured output
2334
- const aiResponse = await withTimeout(aiCallback(systemInstruction, userMessage, jsonSchema), timeoutMs);
2334
+ // request (the structured form of the call) is passed only when the caller built one — the
2335
+ // callback's arity is unchanged for every other task.
2336
+ const aiResponse = await withTimeout(request ? aiCallback(systemInstruction, userMessage, jsonSchema, request) : aiCallback(systemInstruction, userMessage, jsonSchema), timeoutMs);
2335
2337
  if (typeof aiResponse !== 'string') {
2336
2338
  throw new Error('AI callback must return a string response');
2337
2339
  }
@@ -2354,9 +2356,10 @@ async function fetchAiResponse(systemInstruction, userMessage, aiCallback, timeo
2354
2356
  * @param jsonSchema - Optional JSON schema for structured responses
2355
2357
  * @param aiCallback - User-provided AI communication function
2356
2358
  * @param timeoutMs - Timeout in milliseconds for the AI call
2359
+ * @param request - Structured form of the call, passed to aiCallback as its 4th argument (intent detection only)
2357
2360
  * @returns AI response as string or parsed JSON object
2358
2361
  */
2359
- async function fetchAiTask(task, rules, context, userInput, flows, jsonSchema, aiCallback, timeoutMs = 1000) {
2362
+ async function fetchAiTask(task, rules, context, userInput, flows, jsonSchema, aiCallback, timeoutMs = 1000, request) {
2360
2363
  try {
2361
2364
  if (!aiCallback) {
2362
2365
  throw new Error('AI callback function is required');
@@ -2388,14 +2391,14 @@ async function fetchAiTask(task, rules, context, userInput, flows, jsonSchema, a
2388
2391
  const flowDescriptions = flows.map(flow => {
2389
2392
  let desc = `${flow.name}: ${flow.description} (Risk: ${flow.metadata?.riskLevel || 'unknown'})`;
2390
2393
  if (flow.parameters && flow.parameters.length > 0) {
2391
- const params = flow.parameters.map(p => `${p.name} (${p.type || 'string'}): ${p.description}`).join(', ');
2394
+ const params = flow.parameters.map(p => `${p.name} (${describeParameterType(p)}): ${p.description}`).join(', ');
2392
2395
  desc += `\n Parameters: ${params}`;
2393
2396
  }
2394
2397
  return desc;
2395
2398
  }).join('\n');
2396
2399
  userMessage += `\n\n<available-flows>\n${flowDescriptions}\n</available-flows>`;
2397
2400
  }
2398
- const aiResponse = await fetchAiResponse(systemMessage, userMessage, aiCallback, timeoutMs, jsonSchema);
2401
+ const aiResponse = await fetchAiResponse(systemMessage, userMessage, aiCallback, timeoutMs, jsonSchema, request);
2399
2402
  // If JSON schema was provided, parse and return JSON
2400
2403
  if (jsonSchema) {
2401
2404
  // Clean up common AI response formatting issues
@@ -2424,6 +2427,71 @@ async function fetchAiTask(task, rules, context, userInput, flows, jsonSchema, a
2424
2427
  throw new Error(`AI task processing failed: ${error.message}`);
2425
2428
  }
2426
2429
  }
2430
+ /** "string" / "boolean" / … and, for an enum, the allowed values: `string, one of: "a" | "b"`. */
2431
+ function describeParameterType(p) {
2432
+ const type = p.type || 'string';
2433
+ if (Array.isArray(p.enum) && p.enum.length > 0) {
2434
+ return `${type}, one of: ${p.enum.map(v => JSON.stringify(v)).join(' | ')}`;
2435
+ }
2436
+ return type;
2437
+ }
2438
+ /**
2439
+ * Enforces each declared enum on the parameters intent detection returned. A value that matches an
2440
+ * allowed value ignoring case and surrounding whitespace is replaced by the declared spelling; any
2441
+ * other value is DROPPED (with a warning), so the flow asks for it rather than running on a value
2442
+ * it never declared. Parameters without an enum pass through unchanged.
2443
+ */
2444
+ function enforceParameterEnums(flow, parameters) {
2445
+ const result = { ...parameters };
2446
+ for (const p of flow.parameters || []) {
2447
+ if (!Array.isArray(p.enum) || p.enum.length === 0) {
2448
+ continue; // no enum declared - value passes through as before
2449
+ }
2450
+ if (!(p.name in result)) {
2451
+ continue; // not extracted - the flow asks
2452
+ }
2453
+ const value = result[p.name];
2454
+ const match = typeof value === 'string'
2455
+ ? p.enum.find(v => v.toLowerCase() === value.trim().toLowerCase())
2456
+ : undefined;
2457
+ if (match !== undefined) {
2458
+ result[p.name] = match;
2459
+ }
2460
+ else {
2461
+ logger.warn(`detectFlowWithParameters: dropped parameter "${p.name}" of flow "${flow.name}" - ${JSON.stringify(value)} is not one of ${JSON.stringify(p.enum)}`);
2462
+ delete result[p.name];
2463
+ }
2464
+ }
2465
+ return result;
2466
+ }
2467
+ /** The structured form of the intent-detection call, passed to aiCallback as its 4th argument. */
2468
+ function buildDetectFlowRequest(input, lastChatTurn, flows) {
2469
+ const conversation = [];
2470
+ for (const entry of [lastChatTurn?.user, lastChatTurn?.assistant]) {
2471
+ if (entry && (entry.role === 'user' || entry.role === 'assistant')) {
2472
+ conversation.push({ role: entry.role, content: typeof entry.content === 'object' ? JSON.stringify(entry.content) : String(entry.content) });
2473
+ }
2474
+ else {
2475
+ // absent, or a role the conversation cannot carry
2476
+ }
2477
+ }
2478
+ return {
2479
+ task: 'detect_flow',
2480
+ input: String(sanitizeInput(input)),
2481
+ conversation,
2482
+ flows: flows.map(flow => ({
2483
+ id: flow.id,
2484
+ name: flow.name,
2485
+ description: flow.description,
2486
+ parameters: (flow.parameters || []).map(p => ({
2487
+ name: p.name,
2488
+ description: p.description,
2489
+ ...(p.type !== undefined ? { type: p.type } : {}),
2490
+ ...(Array.isArray(p.enum) ? { enum: [...p.enum] } : {})
2491
+ }))
2492
+ }))
2493
+ };
2494
+ }
2427
2495
  export async function getFlowForInput(input, engine) {
2428
2496
  const result = await detectFlowWithParameters(input, engine);
2429
2497
  return result ? result.flow : null;
@@ -2492,7 +2560,8 @@ export async function detectFlowWithParameters(input, engine) {
2492
2560
  </chat-history>\n\n`;
2493
2561
  }
2494
2562
  // Let AI errors (timeout, communication failures) propagate to the host
2495
- const aiResponse = await fetchAiTask(task, rules, context, input, flowsForIntentDetection, jsonSchema, engine.aiCallback, engine.aiTimeOut);
2563
+ const request = buildDetectFlowRequest(input, engine.lastChatTurn, flowsForIntentDetection);
2564
+ const aiResponse = await fetchAiTask(task, rules, context, input, flowsForIntentDetection, jsonSchema, engine.aiCallback, engine.aiTimeOut, request);
2496
2565
  if (aiResponse && aiResponse.flowName && aiResponse.flowName !== 'None' && aiResponse.flowName !== 'null') {
2497
2566
  const flow = flowsMenu.find(flow => flow.name.toLowerCase() === aiResponse.flowName.toLowerCase() || flow.id === aiResponse.flowName);
2498
2567
  if (flow) {
@@ -2507,6 +2576,7 @@ export async function detectFlowWithParameters(input, engine) {
2507
2576
  logger.warn(`detectFlowWithParameters: stripped ${entries.length - filtered.length} empty-key parameter(s) from AI response for flow "${flow.name}"`);
2508
2577
  parameters = Object.fromEntries(filtered);
2509
2578
  }
2579
+ parameters = enforceParameterEnums(flow, parameters);
2510
2580
  }
2511
2581
  return { flow, parameters };
2512
2582
  }
@@ -6052,6 +6122,62 @@ export class WorkflowEngine {
6052
6122
  state.warnings.push(`Flow "${flowDef.name}" has invalid riskLevel: ${flowDef.metadata.riskLevel}`);
6053
6123
  }
6054
6124
  }
6125
+ this._validateFlowParameters(flowDef, state);
6126
+ }
6127
+ /**
6128
+ * Validates the parameters intent detection extracts: unique names, and a well-formed enum.
6129
+ * An enum is a non-empty list of unique, non-empty strings, allowed only on a string parameter -
6130
+ * values are matched as strings, so on any other type it could never match.
6131
+ */
6132
+ _validateFlowParameters(flowDef, state) {
6133
+ if (flowDef.parameters === undefined) {
6134
+ return;
6135
+ }
6136
+ if (!Array.isArray(flowDef.parameters)) {
6137
+ state.errors.push(`Flow "${flowDef.name}" parameters must be an array`);
6138
+ return;
6139
+ }
6140
+ const seen = new Set();
6141
+ for (const p of flowDef.parameters) {
6142
+ if (!p || typeof p.name !== 'string' || p.name.trim() === '') {
6143
+ state.errors.push(`Flow "${flowDef.name}" has a parameter without a name`);
6144
+ continue;
6145
+ }
6146
+ if (seen.has(p.name)) {
6147
+ state.errors.push(`Flow "${flowDef.name}" declares parameter "${p.name}" more than once`);
6148
+ }
6149
+ else {
6150
+ seen.add(p.name);
6151
+ }
6152
+ if (p.enum === undefined) {
6153
+ continue;
6154
+ }
6155
+ const where = `Flow "${flowDef.name}" parameter "${p.name}"`;
6156
+ if (p.type !== undefined && p.type !== 'string') {
6157
+ state.errors.push(`${where}: enum is allowed only on a string parameter, not type "${p.type}"`);
6158
+ }
6159
+ if (!Array.isArray(p.enum) || p.enum.length === 0) {
6160
+ state.errors.push(`${where}: enum must be a non-empty array of strings`);
6161
+ continue;
6162
+ }
6163
+ const values = new Set();
6164
+ for (const v of p.enum) {
6165
+ if (typeof v !== 'string' || v.trim() === '') {
6166
+ state.errors.push(`${where}: enum value ${JSON.stringify(v)} is not a non-empty string`);
6167
+ }
6168
+ else if (v !== v.trim()) {
6169
+ // A reply is trimmed before matching, so a padded value could never match.
6170
+ state.errors.push(`${where}: enum value ${JSON.stringify(v)} has leading or trailing whitespace`);
6171
+ }
6172
+ else if (values.has(v.trim().toLowerCase())) {
6173
+ // Values are matched ignoring case, so these two could never be told apart.
6174
+ state.errors.push(`${where}: enum value ${JSON.stringify(v)} is listed more than once (ignoring case)`);
6175
+ }
6176
+ else {
6177
+ values.add(v.trim().toLowerCase());
6178
+ }
6179
+ }
6180
+ }
6055
6181
  }
6056
6182
  /**
6057
6183
  * Validates flow variable definitions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "0.9.85",
3
+ "version": "0.9.87",
4
4
  "description": "TypeScript workflow engine for conversational/automation apps: multi-flow orchestration, interrupt/resume, stack-based control, robust errors, and flexible tool/REST integration.",
5
5
  "license": "MIT",
6
6
  "author": "Ron Pinkas",
@@ -14,6 +14,10 @@
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
+ },
18
+ "./host": {
19
+ "types": "./dist/host/index.d.ts",
20
+ "import": "./dist/host/index.js"
17
21
  }
18
22
  },
19
23
  "main": "./dist/index.js",