@scout9/app 1.0.0-alpha.0.1.96 → 1.0.0-alpha.0.1.98

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.
Files changed (44) hide show
  1. package/dist/{dev-ecdbe765.cjs → dev-1afc1e7b.cjs} +3788 -3684
  2. package/dist/{index-ea1273a0.cjs → index-2aedbf12.cjs} +150 -55
  3. package/dist/index.cjs +6 -47
  4. package/dist/{multipart-parser-26f98006.cjs → multipart-parser-51d88fc4.cjs} +9 -7
  5. package/dist/{spirits-32395ac4.cjs → spirits-43ce19cf.cjs} +19 -19
  6. package/dist/spirits.cjs +1 -1
  7. package/dist/testing-tools.cjs +7 -6
  8. package/package.json +4 -3
  9. package/src/core/config/agents.js +2 -2
  10. package/src/core/config/entities.js +10 -10
  11. package/src/core/config/index.js +2 -2
  12. package/src/core/config/project.js +1 -1
  13. package/src/core/config/workflow.js +2 -2
  14. package/src/core/index.js +7 -7
  15. package/src/core/sync.js +2 -2
  16. package/src/core/templates/project-files.js +1 -1
  17. package/src/exports.js +8 -7
  18. package/src/platform.js +7 -7
  19. package/src/public.d.ts +3383 -0
  20. package/src/runtime/client/api.js +0 -22
  21. package/src/runtime/client/index.js +0 -6
  22. package/src/runtime/index.js +1 -0
  23. package/src/runtime/macros/builder.js +25 -4
  24. package/src/runtime/macros/event.js +139 -35
  25. package/src/runtime/macros/index.js +0 -1
  26. package/src/runtime/schemas/api.js +21 -0
  27. package/src/runtime/{client → schemas}/config.js +13 -17
  28. package/src/runtime/{client → schemas}/entity.js +16 -29
  29. package/src/runtime/schemas/index.js +9 -0
  30. package/src/runtime/{client → schemas}/message.js +0 -3
  31. package/src/runtime/{client → schemas}/platform.js +1 -1
  32. package/src/runtime/{client → schemas}/users.js +32 -26
  33. package/src/runtime/{client → schemas}/workflow.js +7 -59
  34. package/src/testing-tools/dev.js +15 -17
  35. package/src/testing-tools/mocks.js +6 -6
  36. package/src/testing-tools/spirits.js +19 -19
  37. package/src/utils/configs/agents.js +2 -2
  38. package/src/utils/configs/entities.js +8 -8
  39. package/src/utils/project-templates.js +3 -3
  40. package/types/index.d.ts +2899 -25181
  41. package/types/index.d.ts.map +67 -108
  42. package/src/public.d.ts.text +0 -330
  43. /package/src/runtime/{macros/schemas.js → schemas/macros.js} +0 -0
  44. /package/src/runtime/{client → schemas}/utils.js +0 -0
@@ -1,5 +1,3 @@
1
- import { z } from 'zod';
2
-
3
1
  /**
4
2
  * Utility runtime class used to guide event output
5
3
  * @template T
@@ -58,23 +56,3 @@ export class EventResponse {
58
56
 
59
57
  }
60
58
 
61
-
62
-
63
- const responseInitSchema = z.object({
64
- status: z.number().optional(),
65
- statusText: z.string().optional(),
66
- headers: z.any().optional() // Headers can be complex; adjust as needed
67
- });
68
-
69
- /**
70
- * @template T
71
- * @typedef {object} IEventResponse
72
- * @property {T} body - The body of the response.
73
- * @property {ResponseInit} [init] - Additional options for the response.
74
- * @property {Response} response - The response object.
75
- * @property {T} data - The body of the response.
76
- */
77
- export const eventResponseSchema = z.object({
78
- body: z.any(), // Adjust as per your actual body structure
79
- init: responseInitSchema.optional()
80
- });
@@ -1,8 +1,2 @@
1
- export * from './users.js';
2
1
  export * from './api.js';
3
- export * from './config.js';
4
- export * from './entity.js';
5
- export * from './message.js';
6
- export * from './workflow.js';
7
- export * from './platform.js';
8
2
 
@@ -1,2 +1,3 @@
1
1
  export * from './client/index.js';
2
2
  export * from './macros/index.js';
3
+ export * from './schemas/index.js'
@@ -2,7 +2,7 @@
2
2
  * Builder Macros
3
3
  * used to build and guide a application logic in relation to the Scout9 conversation state.
4
4
  */
5
- import { Configuration, MacroContextResult, Scout9Api } from '@scout9/admin';
5
+ import { Configuration, Scout9Api } from '@scout9/admin';
6
6
  import MacroGlobals from './globals.js';
7
7
 
8
8
  function handleAxiosResponse(res) {
@@ -20,20 +20,41 @@ function handleAxiosResponse(res) {
20
20
  */
21
21
  export async function did(prompt) {
22
22
  const convoId = MacroGlobals.$convo();
23
+ if (!convoId) {
24
+ throw new Error(`Internal: Unable to contextualize did response for "${prompt}"`);
25
+ }
23
26
  const {value} = (await (new Scout9Api(new Configuration({apiKey: process.env.SCOUT9_API_KEY}))).did({prompt, convoId})
24
27
  .then(handleAxiosResponse));
25
28
  return value;
26
29
  }
27
30
 
31
+ /**
32
+ * @typedef {import('@scout9/admin').MacroContextInputExamples} ContextExamples
33
+ * @typedef {import('@scout9/admin').MacroContextValue} ContextOutput
34
+ */
28
35
 
29
36
  /**
30
37
  * The `context` macro, similar to the `did` macro, takes a natural statement and checks the entire conversation state and extracts or infers a metadata composition result.
31
- * @param {string} prompt
32
- * @param {import('@scout9/admin').CaptureContextRequestExamples} [examples]
33
- * @return {Promise<import('@scout9/admin').MacroContextValue>}
38
+ *
39
+ * @example - inferring what a user requested
40
+ * const response = await context(`What pizzas did the user want to order?`);
41
+ * {
42
+ * "order": {
43
+ * "pizzas": [
44
+ * {"size": "small", "toppings": ["cheese"], quantity: 1}
45
+ * ]
46
+ * }
47
+ * }
48
+ *
49
+ * @param {string} prompt - Prompt to infer a context data set to use in your workflow code.
50
+ * @param {ContextExamples} [examples] - Examples to the macro to ensure a consistent data structure.
51
+ * @return {Promise<ContextOutput>}
34
52
  */
35
53
  export async function context(prompt, examples) {
36
54
  const convoId = MacroGlobals.$convo();
55
+ if (!convoId) {
56
+ throw new Error(`Internal: Unable to contextualize did response for "${prompt}"`);
57
+ }
37
58
  const {value} = (await (new Scout9Api(new Configuration({apiKey: process.env.SCOUT9_API_KEY}))).captureContext({
38
59
  prompt,
39
60
  examples,
@@ -1,9 +1,77 @@
1
- import { WorkflowResponseSlotBaseSchema, WorkflowResponseSlotSchema } from '../client/workflow.js';
1
+ import { WorkflowResponseSlotBaseSchema, WorkflowResponseSlotSchema } from '../schemas/workflow.js';
2
2
  import { MacroUtils } from './utils.js';
3
3
 
4
4
 
5
+ /**
6
+ * followup macro options
7
+ * @typedef {Object} OptionsFollowup
8
+ * @property {Date | string} scheduled
9
+ * @property {Record<string, any>} [cancelIf]
10
+ * @property {boolean} [literal]
11
+ * @property {boolean} [overrideLock]
12
+ */
5
13
 
6
- function EventMacros() {
14
+ /**
15
+ * instruct macro options
16
+ * @typedef {Object} OptionsInstruct
17
+ * @property {string} [id] - Unique ID for the instruction, this is used to remove the instruction later
18
+ * @property {boolean} [persist] - if true, the instruction persists the conversation, if false the instruction will only last for 1 auto reply
19
+ */
20
+
21
+ /**
22
+ * reply macro options
23
+ * @typedef {Object} OptionsReply
24
+ * @property {Date | string} [scheduled]
25
+ * @property {number} [delay]
26
+ */
27
+
28
+ /**
29
+ * forward macro options
30
+ * @typedef {Object} OptionsForward
31
+ * @property {'after-reply' | 'immediately'} [mode] - sets forward mode, defaults to "immediately". If "after-reply", the forward will be on hold until the customer responds. We recommend using "immediately" for most cases.
32
+ * @property {string} [to] - another phone or email to forward to instead of owner
33
+ */
34
+
35
+ /**
36
+ *
37
+ * @return {{followup(string, (Date|string|OptionsFollowup)): EventMacros, toJSON(boolean=): Array<WorkflowResponseSlot>, instruct(string, OptionsFollowup=): EventMacros, forward(string=, OptionsForward=): EventMacros, anticipate((string|Array<WorkflowResponseSlotBase&{keywords: string[]}>), WorkflowResponseSlotBaseSchema, WorkflowResponseSlotBaseSchema): EventMacros, upsert(Record<string, *>): EventMacros, reply(string, OptionsReply=): EventMacros}|*|*[]}
38
+ * @constructor
39
+ */
40
+
41
+ /**
42
+ * @typedef {WorkflowResponseSlotBase & {keywords: string[]}} WorkflowResponseSlotBaseWithKeywords
43
+ * - Extends `WorkflowResponseSlotBase` to include keywords.
44
+ * @property {string[]} keywords - Keywords associated with the slot.
45
+ */
46
+
47
+ /**
48
+ * @typedef {(
49
+ * (instruction: string, yes: WorkflowResponseSlotBase, no: WorkflowResponseSlotBase) => EventMacros |
50
+ * (instruction: WorkflowResponseSlotBaseWithKeywords[]) => EventMacros
51
+ * )} AnticipateFunction
52
+ * - Defines the overloads for the `anticipate` function.
53
+ * @property {function(string, WorkflowResponseSlotBase, WorkflowResponseSlotBase): EventMacros} withCondition
54
+ * - Overload for when the instruction is a string.
55
+ * @property {string} withCondition.instruction - The instruction as a string.
56
+ * @property {WorkflowResponseSlotBase} withCondition.yes - Object to process if the condition is met.
57
+ * @property {WorkflowResponseSlotBase} withCondition.no - Object to process if the condition is not met.
58
+ * @property {function(WorkflowResponseSlotBaseWithKeywords[]): EventMacros} withoutCondition
59
+ * - Overload for when the instruction is an array.
60
+ * @property {WorkflowResponseSlotBaseWithKeywords[]} withoutCondition.instruction - Array of slots with keywords.
61
+ */
62
+
63
+ /**
64
+ * Event macros to be used inside your scout9 auto reply workflows
65
+ * @typedef {Object} EventMacros
66
+ * @property {function(Record<string, any>): EventMacros} upsert
67
+ * @property {function(string, (Date | string | OptionsFollowup)): EventMacros} followup
68
+ * @property {AnticipateFunction} anticipate
69
+ * @property {function(string, OptionsInstruct?): EventMacros} instruct
70
+ * @property {function(string, OptionsReply?): EventMacros} reply
71
+ * @property {function(string?, OptionsForward?): EventMacros} forward
72
+ * @property {function(boolean?): Array<WorkflowResponseSlot>} toJSON
73
+ */
74
+ function EventMacrosFactory() {
7
75
 
8
76
  let slots = [];
9
77
 
@@ -12,7 +80,7 @@ function EventMacros() {
12
80
  /**
13
81
  * Sets context into the conversation context for later use
14
82
  * @param {Record<string, any>} updates
15
- * @return {this}
83
+ * @return {EventMacros}
16
84
  */
17
85
  upsert(updates) {
18
86
  const slot = {contextUpsert: updates}
@@ -24,18 +92,9 @@ function EventMacros() {
24
92
  * Similar to `instruction` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
25
93
  *
26
94
  * @param {string} instruction
95
+ * @param {Date | string | OptionsFollowup} options
27
96
  *
28
- * @overload
29
- * @param {Date | string} options
30
- *
31
- * @overload
32
- * @param {Object} options
33
- * @param {Date | string} options.scheduled
34
- * @param {Record<string, any>} [options.cancelIf]
35
- * @param {boolean} [options.literal]
36
- * @param {boolean} [options.overrideLock]
37
- *
38
- * @return {this}
97
+ * @return {EventMacros}
39
98
  */
40
99
  followup(instruction, options) {
41
100
  let slot;
@@ -88,11 +147,11 @@ function EventMacros() {
88
147
  * Similar to `instruct` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
89
148
  * @overload
90
149
  * @param {string} instruction - The instruction to be anticipated as a string. When this is a string, `yes` and `no` must be provided as objects.
91
- * @param {object} yes - The object to process if the instruction is a string and the condition is met.
92
- * @param {object} no - The object to process if the instruction is a string and the condition is not met.
150
+ * @param {WorkflowResponseSlotBaseSchema} yes - The object to process if the instruction is a string and the condition is met.
151
+ * @param {WorkflowResponseSlotBaseSchema} no - The object to process if the instruction is a string and the condition is not met.
93
152
  *
94
153
  * @overload
95
- * @param {(Array<IWorkflowResponseSlotBase & {keywords: string[]}>)} instruction
154
+ * @param {(Array<WorkflowResponseSlotBase & {keywords: string[]}>)} instruction
96
155
  *
97
156
  * @return {EventMacros}
98
157
  */
@@ -127,11 +186,9 @@ function EventMacros() {
127
186
  },
128
187
 
129
188
  /**
130
- *
189
+ * Return instructions to guide next auto reply response
131
190
  * @param {string} instruction
132
- * @param {Object} [options]
133
- * @param {string} [options.id] - Unique ID for the instruction, this is used to remove the instruction later
134
- * @param {string} [options.persist] - if true, the instruction persists the conversation, if false the instruction will only last for 1 auto reply
191
+ * @param {OptionsFollowup} [options]
135
192
  * @return {EventMacros}
136
193
  */
137
194
  instruct(instruction, options = {}) {
@@ -156,10 +213,8 @@ function EventMacros() {
156
213
  /**
157
214
  * If a manual message must be sent, you can use the `reply` macro
158
215
  * @param {string} message - the message to manually send to the user
159
- * @param {Object} [options]
160
- * @param {Date | string} [options.scheduled] - this will schedule the date to a specific provided date
161
- * @param {string} [options.delay] - delays the message return in seconds
162
- * @return {this}
216
+ * @param {OptionsReply} [options]
217
+ * @return {EventMacros}
163
218
  */
164
219
  reply(message, options = {}) {
165
220
  const slot = {
@@ -182,20 +237,19 @@ function EventMacros() {
182
237
  },
183
238
  /**
184
239
  * This macro ends the conversation and forwards it the owner of the persona to manually handle the flow. If your app returns undefined or no event, then a default forward is generated.
185
- * @param {string} message - the message to forward to owner of persona
186
- * @param {Object} [options]
187
- * @param {'after-reply' | 'immediately'} [options.mode] - sets forward mode, defaults to "immediately"
188
- * @param {string} [options.to] - another phone or email to forward to instead of owner
189
- * @return {this}
240
+ * @param {string} [message] - the message to forward to owner of persona
241
+ * @param {OptionsForward} [options]
242
+ * @return {EventMacros}
190
243
  */
191
244
  forward(message, options = {}) {
192
245
  let slot;
246
+ const defaultForward = 'Conversation forwarded for manual intervention';
193
247
  if (options && Object.keys(options).length) {
194
248
  slot = {
195
249
  forward: {
196
- note: message
250
+ note: message ?? defaultForward
197
251
  },
198
- forwardNote: message
252
+ forwardNote: message ?? defaultForward
199
253
  }
200
254
  if (options.to) {
201
255
  slot.forward.to = options.to;
@@ -206,7 +260,7 @@ function EventMacros() {
206
260
  } else {
207
261
  slot = {
208
262
  forward: true,
209
- forwardNote: message
263
+ forwardNote: message ?? defaultForward
210
264
  }
211
265
  }
212
266
  slots.push(WorkflowResponseSlotSchema.parse(slot));
@@ -214,7 +268,7 @@ function EventMacros() {
214
268
  },
215
269
  /**
216
270
  * Returns event payload
217
- * @return {Array<IWorkflowResponseSlot>}
271
+ * @return {Array<WorkflowResponseSlot>}
218
272
  */
219
273
  toJSON(flush = true) {
220
274
  if (flush) {
@@ -228,7 +282,57 @@ function EventMacros() {
228
282
  };
229
283
  }
230
284
 
231
- const eventMacros = EventMacros();
285
+ const eventMacros = EventMacrosFactory();
286
+
287
+ /**
288
+ * Return instructions to guide next auto reply response
289
+ * @param {string} instruction - the instruction to send to the
290
+ * @param {OptionsInstruct} [options]
291
+ * @return {EventMacros}
292
+ *
293
+ * @example instruct("Ask user if they are looking to order a pizza");
294
+ *
295
+ * @type {(message: string, options?: OptionsInstruct) => EventMacros}
296
+ */
232
297
  export const instruct = eventMacros.instruct.bind(eventMacros);
298
+
299
+ /**
300
+ * Forwards conversation back to you or owner of workflow.
301
+ *
302
+ * Typically used when the conversation is over or user is stuck in the workflow and needs manual intervention.
303
+ *
304
+ * The provided message input gets sent to you in a sms text with some information why conversation was forwarded.
305
+ *
306
+ * Calling this method will lock the conversation and prevent auto replies from being sent to the user.
307
+ *
308
+ * @example - end of workflow
309
+ * forward("User wants 1 cheese pizza ready for pick");
310
+ *
311
+ * @example - broken step in workflow
312
+ * forward("Cannot determine what the user wants");
313
+ *
314
+ * @example - forward if user sends a message
315
+ * reply("Let me know if you're looking for a gutter cleaning").forward("User responded to gutter cleaning request", {mode: 'after-reply'});
316
+ *
317
+ * @type {(message: string, options?: OptionsForward) => EventMacros}
318
+ */
233
319
  export const forward = eventMacros.forward.bind(eventMacros);
320
+
321
+ /**
322
+ * Manual message to send to the customer from the workflow.
323
+ *
324
+ * Typically used to return specific information to the user
325
+ *
326
+ * @example - confirming invoice
327
+ * reply(`So I got...\n${invoiceItems.map((item) => `${}`)}`)
328
+ * const msg = [
329
+ * 'So I got...',
330
+ * invoice.items.map((item) => `${item.quantity} ${item.name}`),
331
+ * `Total: ${invoice.totalStr}`,
332
+ * `\nThis look right?`
333
+ * ].join('\n');
334
+ * return reply(msg).instruct("If user confirms ask if they prefer to pay cash or credit");
335
+ *
336
+ * @type {(message: string, options?: OptionsReply) => EventMacros}
337
+ */
234
338
  export const reply = eventMacros.reply.bind(eventMacros);
@@ -1,3 +1,2 @@
1
1
  export * from './event.js';
2
2
  export * from './builder.js';
3
- export * from './schemas.js';
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+
3
+
4
+ const responseInitSchema = z.object({
5
+ status: z.number().optional(),
6
+ statusText: z.string().optional(),
7
+ headers: z.any().optional() // Headers can be complex; adjust as needed
8
+ });
9
+
10
+ /**
11
+ * @template T
12
+ * @typedef {object} IEventResponse
13
+ * @property {T} body - The body of the response.
14
+ * @property {ResponseInit} [init] - Additional options for the response.
15
+ * @property {Response} response - The response object.
16
+ * @property {T} data - The body of the response.
17
+ */
18
+ export const eventResponseSchema = z.object({
19
+ body: z.any(), // Adjust as per your actual body structure
20
+ init: responseInitSchema.optional()
21
+ });
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { agentsBaseConfigurationSchema } from './users.js';
3
- import { entitiesRootProjectConfigurationSchema } from './entity.js';
2
+ import { AgentsSchema } from './users.js';
3
+ import { EntitiesRootProjectConfigurationSchema } from './entity.js';
4
4
  import { WorkflowsConfigurationSchema } from './workflow.js';
5
5
 
6
- const llmModelOptions = z.union([
6
+ const LlmModelOptions = z.union([
7
7
  z.literal('gpt-4-1106-preview'),
8
8
  z.literal('gpt-4-vision-preview'),
9
9
  z.literal('gpt-4'),
@@ -20,22 +20,22 @@ const llmModelOptions = z.union([
20
20
  z.string() // for the (string & {}) part
21
21
  ]);
22
22
 
23
- const pmtModelOptions = z.union([
23
+ const PmtModelOptions = z.union([
24
24
  z.literal('orin-1.0'),
25
25
  z.literal('orin-2.0-preview')
26
26
  ]);
27
27
 
28
- const llmSchema = z.object({
28
+ const LlmSchema = z.object({
29
29
  engine: z.literal('openai'),
30
- model: llmModelOptions
30
+ model: LlmModelOptions
31
31
  });
32
32
 
33
- const llamaSchema = z.object({
33
+ const LlamaSchema = z.object({
34
34
  engine: z.literal('llama'),
35
35
  model: z.string()
36
36
  });
37
37
 
38
- const bardSchema = z.object({
38
+ const BardSchema = z.object({
39
39
  engine: z.literal('bard'),
40
40
  model: z.string()
41
41
  });
@@ -43,7 +43,7 @@ const bardSchema = z.object({
43
43
  /**
44
44
  * Configure personal model transformer (PMT) settings to align auto replies the agent's tone
45
45
  */
46
- const pmtSchema = z.object({
46
+ const PmtSchema = z.object({
47
47
  engine: z.literal('scout9'),
48
48
  // model: pmtModelOptions
49
49
  model: z.string()
@@ -53,7 +53,6 @@ const pmtSchema = z.object({
53
53
 
54
54
  /**
55
55
  * Represents the configuration provided in src/index.{js | ts} in a project
56
- * @typedef {import('zod').infer<typeof Scout9ProjectConfigSchema>} IScout9ProjectConfig
57
56
  */
58
57
  export const Scout9ProjectConfigSchema = z.object({
59
58
  /**
@@ -61,11 +60,11 @@ export const Scout9ProjectConfigSchema = z.object({
61
60
  * @defaut your local package.json name + version, or scout9-app-v1.0.0
62
61
  */
63
62
  tag: z.string().optional(), // Defaults to scout9-app-v1.0.0
64
- llm: z.union([llmSchema, llamaSchema, bardSchema]),
63
+ llm: z.union([LlmSchema, LlamaSchema, BardSchema]),
65
64
  /**
66
65
  * Configure personal model transformer (PMT) settings to align auto replies the agent's tone
67
66
  */
68
- pmt: pmtSchema,
67
+ pmt: PmtSchema,
69
68
 
70
69
  /**
71
70
  * Determines the max auto replies without further conversation progression (defined by new context data gathered)
@@ -93,12 +92,9 @@ export const Scout9ProjectConfigSchema = z.object({
93
92
  }).optional()
94
93
  })
95
94
 
96
- /**
97
- * @typedef {import('zod').infer<typeof Scout9ProjectBuildConfigSchema>} IScout9ProjectBuildConfig
98
- */
99
95
  export const Scout9ProjectBuildConfigSchema = Scout9ProjectConfigSchema.extend({
100
- agents: agentsBaseConfigurationSchema,
101
- entities: entitiesRootProjectConfigurationSchema,
96
+ agents: AgentsSchema,
97
+ entities: EntitiesRootProjectConfigurationSchema,
102
98
  workflows: WorkflowsConfigurationSchema
103
99
  });
104
100
 
@@ -2,10 +2,7 @@ import { z } from 'zod';
2
2
  import { zId } from './utils.js';
3
3
 
4
4
 
5
- /**
6
- * @typedef {import('zod').infer<typeof entityApiConfigurationSchema>} IEntityApiConfiguration
7
- */
8
- export const entityApiConfigurationSchema = z.object({
5
+ export const EntityApiConfigurationSchema = z.object({
9
6
  // path: z.string(),
10
7
  GET: z.boolean().optional(),
11
8
  UPDATE: z.boolean().optional(),
@@ -15,17 +12,17 @@ export const entityApiConfigurationSchema = z.object({
15
12
  DELETE: z.boolean().optional()
16
13
  }).nullable();
17
14
 
18
- const entityConfigurationDefinitionSchema = z.object({
15
+ const EntityConfigurationDefinitionSchema = z.object({
19
16
  utterance: zId('Utterance', z.string({description: 'What entity utterance this represents, if not provided, it will default to the entity id'}))
20
17
  .optional(),
21
18
  value: z.string({description: 'The value of this entity variance'}),
22
19
  text: z.array(z.string(), {description: 'Text representing the entity variance'})
23
20
  });
24
- const entityConfigurationTrainingSchema = z.object({
21
+ const EntityConfigurationTrainingSchema = z.object({
25
22
  intent: zId('Intent', z.string({description: 'The assigned intent id of the given text, e.g. "I love %pizza%" could have an intent id "feedback" and "Can I purchase a %pizza%?" could have an intent id "purchase"'})),
26
23
  text: z.string({description: 'Text to train the intent field and entities in or entity variances in example sentences or phrase. Ex: "I love %pizza%" and "Can I purchase a %pizza%?"'})
27
24
  });
28
- const entityConfigurationTestSchema = z.object({
25
+ const EntityConfigurationTestSchema = z.object({
29
26
  text: z.string({description: 'Text to test the entity detection'}),
30
27
  expected: z.object({
31
28
  intent: zId('Intent', z.string({description: 'The expected intent id'})),
@@ -33,17 +30,14 @@ const entityConfigurationTestSchema = z.object({
33
30
  context: z.any()
34
31
  })
35
32
  });
36
- const _entityConfigurationSchema = z.object({
33
+ const _EntityConfigurationSchema = z.object({
37
34
  id: zId('Id', z.string({description: 'If not provided, the id will default to the route (folder) name'})).optional(),
38
- definitions: z.array(entityConfigurationDefinitionSchema).optional(),
39
- training: z.array(entityConfigurationTrainingSchema).optional(),
40
- tests: z.array(entityConfigurationTestSchema).optional()
35
+ definitions: z.array(EntityConfigurationDefinitionSchema).optional(),
36
+ training: z.array(EntityConfigurationTrainingSchema).optional(),
37
+ tests: z.array(EntityConfigurationTestSchema).optional()
41
38
  }).strict();
42
39
 
43
- /**
44
- * @typedef {import('zod').infer<typeof entityConfigurationSchema>} IEntityConfiguration
45
- */
46
- export const entityConfigurationSchema = _entityConfigurationSchema.refine((data) => {
40
+ export const EntityConfigurationSchema = _EntityConfigurationSchema.refine((data) => {
47
41
  // If 'definitions' is provided, then 'training' must also be provided
48
42
  if (data.definitions !== undefined) {
49
43
  return data.training !== undefined;
@@ -55,28 +49,24 @@ export const entityConfigurationSchema = _entityConfigurationSchema.refine((data
55
49
  message: "If 'definitions' is provided, then 'training' must also be provided",
56
50
  });
57
51
 
58
- /**
59
- * @typedef {import('zod').infer<typeof entitiesRootConfigurationSchema>} IEntitiesRootConfiguration
60
- */
61
- export const entitiesRootConfigurationSchema = z.array(entityConfigurationSchema);
52
+ export const EntitiesRootConfigurationSchema = z.array(EntityConfigurationSchema);
62
53
 
63
54
 
64
- const entityExtendedProjectConfigurationSchema = z.object({
55
+ const EntityExtendedProjectConfigurationSchema = z.object({
65
56
  entities: z.array(zId('Entity Folder', z.string()), {description: 'Entity id association, used to handle route params'})
66
57
  .min(1, 'Must have at least 1 entity')
67
58
  .max(15, 'Cannot have more than 15 entity paths'),
68
59
  entity: zId('Entity Folder', z.string()),
69
- api: entityApiConfigurationSchema
60
+ api: EntityApiConfigurationSchema
70
61
  });
71
62
 
72
- const _entityRootProjectConfigurationSchema = _entityConfigurationSchema.extend(entityExtendedProjectConfigurationSchema.shape);
73
- const _entitiesRootProjectConfigurationSchema = z.array(_entityRootProjectConfigurationSchema);
63
+ const _EntityRootProjectConfigurationSchema = _EntityConfigurationSchema.extend(EntityExtendedProjectConfigurationSchema.shape);
64
+ const _EntitiesRootProjectConfigurationSchema = z.array(_EntityRootProjectConfigurationSchema);
74
65
 
75
66
  /**
76
67
  * @TODO why type extend not valid?
77
- * @typedef {import('zod').infer<typeof entityRootProjectConfigurationSchema>} IEntityRootProjectConfiguration
78
68
  */
79
- export const entityRootProjectConfigurationSchema = _entityConfigurationSchema.extend(entityExtendedProjectConfigurationSchema.shape).refine((data) => {
69
+ export const EntityRootProjectConfigurationSchema = _EntityConfigurationSchema.extend(EntityExtendedProjectConfigurationSchema.shape).refine((data) => {
80
70
  // If 'definitions' is provided, then 'training' must also be provided
81
71
  if (data.definitions !== undefined) {
82
72
  return data.training !== undefined;
@@ -88,7 +78,4 @@ export const entityRootProjectConfigurationSchema = _entityConfigurationSchema.e
88
78
  message: "If 'definitions' is provided, then 'training' must also be provided",
89
79
  });
90
80
 
91
- /**
92
- * @typedef {import('zod').infer<typeof entitiesRootProjectConfigurationSchema>} IEntitiesRootProjectConfiguration
93
- */
94
- export const entitiesRootProjectConfigurationSchema = z.array(entityRootProjectConfigurationSchema);
81
+ export const EntitiesRootProjectConfigurationSchema = z.array(EntityRootProjectConfigurationSchema);
@@ -0,0 +1,9 @@
1
+ export * from './users.js';
2
+ export * from './api.js';
3
+ export * from './config.js';
4
+ export * from './entity.js';
5
+ export * from './message.js';
6
+ export * from './workflow.js';
7
+ export * from './platform.js';
8
+ export * from './macros.js';
9
+
@@ -1,9 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { zId } from './utils.js';
3
3
 
4
- /**
5
- * @typedef {import('zod').infer<typeof MessageSchema>} IMessage
6
- */
7
4
  export const MessageSchema = z.object({
8
5
  id: zId('Message ID', {description: 'Unique ID for the message'}),
9
6
  role: z.enum(['agent', 'customer', 'system']),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { eventResponseSchema, EventResponse } from './api.js';
2
+ import { eventResponseSchema } from './api.js';
3
3
 
4
4
 
5
5
  /**