@scout9/app 1.0.0-alpha.0.1.86 → 1.0.0-alpha.0.1.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/dist/{exports-291eb22e.cjs → exports-85e8c05c.cjs} +389 -234
- package/dist/index.cjs +11 -2
- package/dist/{multipart-parser-caa634a9.cjs → multipart-parser-1f8d78d0.cjs} +1 -1
- package/dist/testing-tools.cjs +1 -1
- package/package.json +1 -1
- package/src/core/index.js +15 -35
- package/src/exports.js +11 -7
- package/src/platform.js +213 -211
- package/src/public.d.ts +43 -80
- package/src/runtime/client/api.js +51 -159
- package/src/runtime/client/config.js +43 -7
- package/src/runtime/client/entity.js +19 -5
- package/src/runtime/client/index.js +2 -1
- package/src/runtime/client/message.js +12 -3
- package/src/runtime/client/platform.js +86 -0
- package/src/runtime/client/{agent.js → users.js} +25 -4
- package/src/runtime/client/utils.js +3 -2
- package/src/runtime/client/workflow.js +73 -5
- package/types/index.d.ts +2923 -1261
- package/types/index.d.ts.map +53 -20
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { zId } from './utils.js';
|
|
5
|
-
import { agentConfigurationSchema, customerSchema } from './
|
|
5
|
+
import { agentConfigurationSchema, customerSchema } from './users.js';
|
|
6
6
|
import { MessageSchema } from './message.js';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('zod').infer<typeof WorkflowConfigurationSchema>} IWorkflowConfiguration
|
|
12
|
+
*/
|
|
10
13
|
export const WorkflowConfigurationSchema = z.object({
|
|
11
14
|
entities: z.array(zId('Workflow Folder', z.string()), {description: 'Workflow id association, used to handle route params'})
|
|
12
15
|
.min(1, 'Must have at least 1 entity')
|
|
@@ -14,8 +17,15 @@ export const WorkflowConfigurationSchema = z.object({
|
|
|
14
17
|
entity: zId('Workflow Folder', z.string()),
|
|
15
18
|
});
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {import('zod').infer<typeof WorkflowsConfigurationSchema>} IWorkflowsConfiguration
|
|
22
|
+
*/
|
|
17
23
|
export const WorkflowsConfigurationSchema = z.array(WorkflowConfigurationSchema);
|
|
18
24
|
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('zod').infer<typeof ConversationSchema>} IConversation
|
|
28
|
+
*/
|
|
19
29
|
export const ConversationSchema = z.object({
|
|
20
30
|
$agent: zId('Conversation Agent ID', z.string({description: 'Default agent assigned to the conversation(s)'})),
|
|
21
31
|
$customer: zId('Conversation Customer ID', z.string({description: 'Customer this conversation is with'})),
|
|
@@ -25,20 +35,41 @@ export const ConversationSchema = z.object({
|
|
|
25
35
|
subject: z.string({description: 'HTML Subject of the conversation'}).optional(),
|
|
26
36
|
platformEmailThreadId: z.string({description: 'Used to sync email messages with the conversation'}).optional(),
|
|
27
37
|
}).optional(),
|
|
38
|
+
locked: z.boolean({description: 'Whether the conversation is locked or not'}).optional().nullable(),
|
|
39
|
+
lockedReason: z.string({description: 'Why this conversation was locked'}).optional().nullable(),
|
|
40
|
+
lockAttempts: z.number({description: 'Number attempts made until conversation is locked'}).optional().nullable(),
|
|
41
|
+
forwardedTo: z.string({description: 'What personaId/phone/email was forwarded'}).optional().nullable(),
|
|
42
|
+
forwarded: z.string({description: 'Datetime ISO 8601 timestamp when persona was forwarded'}).optional().nullable(),
|
|
43
|
+
forwardNote: z.string().optional().nullable(),
|
|
44
|
+
intent: z.string({description: 'Detected intent of conversation'}).optional().nullable(),
|
|
45
|
+
intentScore: z.number({description: 'Confidence score of the assigned intent'}).optional().nullable(),
|
|
28
46
|
});
|
|
29
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {import('zod').infer<typeof IntentWorkflowEventSchema>} IIntentWorkflowEvent
|
|
50
|
+
*/
|
|
30
51
|
export const IntentWorkflowEventSchema = z.object({
|
|
31
52
|
current: z.string().nullable(),
|
|
32
53
|
flow: z.array(z.string()),
|
|
33
54
|
initial: z.string().nullable()
|
|
34
|
-
})
|
|
55
|
+
});
|
|
35
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {import('zod').infer<typeof WorkflowEventSchema>} IWorkflowEvent
|
|
59
|
+
*/
|
|
36
60
|
export const WorkflowEventSchema = z.object({
|
|
37
61
|
messages: z.array(MessageSchema),
|
|
38
62
|
conversation: ConversationSchema,
|
|
39
63
|
context: z.any(),
|
|
40
64
|
message: MessageSchema,
|
|
41
|
-
agent: agentConfigurationSchema
|
|
65
|
+
agent: agentConfigurationSchema.omit({
|
|
66
|
+
transcripts: true,
|
|
67
|
+
audios: true,
|
|
68
|
+
includedLocations: true,
|
|
69
|
+
excludedLocations: true,
|
|
70
|
+
model: true,
|
|
71
|
+
context: true
|
|
72
|
+
}),
|
|
42
73
|
customer: customerSchema,
|
|
43
74
|
intent: IntentWorkflowEventSchema,
|
|
44
75
|
stagnationCount: z.number(),
|
|
@@ -48,7 +79,10 @@ export const WorkflowEventSchema = z.object({
|
|
|
48
79
|
const Primitive = z.union([z.string(), z.number(), z.boolean()]);
|
|
49
80
|
// Assuming ConversationContext is already defined as a Zod schema
|
|
50
81
|
|
|
51
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Lazy is used to handle recursive types.
|
|
84
|
+
* @typedef {import('zod').infer<typeof ConversationContext>} IConversation
|
|
85
|
+
*/
|
|
52
86
|
export const ConversationContext = z.lazy(() =>
|
|
53
87
|
z.record(
|
|
54
88
|
Primitive.or(ConversationContext)
|
|
@@ -57,15 +91,25 @@ export const ConversationContext = z.lazy(() =>
|
|
|
57
91
|
|
|
58
92
|
const ContextSchema = z.record(Primitive.or(ConversationContext));
|
|
59
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Forward input information of a conversation
|
|
96
|
+
* @typedef {import('zod').infer<typeof ForwardSchema>} IForward
|
|
97
|
+
*/
|
|
60
98
|
export const ForwardSchema = z.union([
|
|
61
99
|
z.boolean(),
|
|
62
100
|
z.string(),
|
|
63
101
|
z.object({
|
|
64
102
|
to: z.string().optional(),
|
|
65
103
|
mode: z.enum(['after-reply', 'immediately']).optional(),
|
|
104
|
+
note: z.string({description: 'Note to provide to the agent'}).optional()
|
|
66
105
|
}),
|
|
67
|
-
]);
|
|
106
|
+
], {description: 'Forward input information of a conversation'});
|
|
107
|
+
|
|
68
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Instruction object schema used to send context to guide conversations
|
|
111
|
+
* @typedef {import('zod').infer<typeof InstructionSchema>} IInstruction
|
|
112
|
+
*/
|
|
69
113
|
export const InstructionSchema = z.object({
|
|
70
114
|
id: zId('Instruction ID').describe('Unique ID for the instruction, this is used to remove the instruction later'),
|
|
71
115
|
content: z.string(),
|
|
@@ -74,6 +118,7 @@ export const InstructionSchema = z.object({
|
|
|
74
118
|
/**
|
|
75
119
|
* If its a string, it will be sent as a static string.
|
|
76
120
|
* If it's a object or WorkflowResponseMessageAPI - it will use
|
|
121
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseMessage>} IWorkflowResponseMessage
|
|
77
122
|
*/
|
|
78
123
|
export const WorkflowResponseMessage = z.union(
|
|
79
124
|
z.string(),
|
|
@@ -84,6 +129,9 @@ export const WorkflowResponseMessage = z.union(
|
|
|
84
129
|
WorkflowResponseMessageApiRequest
|
|
85
130
|
);
|
|
86
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiRequest>} IWorkflowResponseMessageApiRequest
|
|
134
|
+
*/
|
|
87
135
|
export const WorkflowResponseMessageApiRequest = z.object({
|
|
88
136
|
uri: z.string(),
|
|
89
137
|
data: z.any().optional(),
|
|
@@ -95,6 +143,7 @@ export const WorkflowResponseMessageApiRequest = z.object({
|
|
|
95
143
|
|
|
96
144
|
/**
|
|
97
145
|
* The intended response provided by the WorkflowResponseMessageApiRequest
|
|
146
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiResponse>} IWorkflowResponseMessageApiResponse
|
|
98
147
|
*/
|
|
99
148
|
export const WorkflowResponseMessageApiResponse = z.union([
|
|
100
149
|
z.string(),
|
|
@@ -116,8 +165,13 @@ export const WorkflowResponseMessageApiResponse = z.union([
|
|
|
116
165
|
})
|
|
117
166
|
]);
|
|
118
167
|
|
|
168
|
+
/**
|
|
169
|
+
* The workflow response object slot
|
|
170
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseSlotSchema>} IWorkflowResponseSlot
|
|
171
|
+
*/
|
|
119
172
|
export const WorkflowResponseSlotSchema = z.object({
|
|
120
173
|
forward: ForwardSchema.optional(),
|
|
174
|
+
forwardNote: z.string({description: 'Note to provide to the agent, recommend using forward object api instead'}).optional(),
|
|
121
175
|
instructions: z.union([z.string(), InstructionSchema, z.array(z.string()), z.array(InstructionSchema)]).optional(),
|
|
122
176
|
removeInstructions: z.array(z.string()).optional(),
|
|
123
177
|
message: z.string().optional(),
|
|
@@ -128,7 +182,21 @@ export const WorkflowResponseSlotSchema = z.object({
|
|
|
128
182
|
resetIntent: z.boolean().optional(),
|
|
129
183
|
});
|
|
130
184
|
|
|
185
|
+
/**
|
|
186
|
+
* The workflow response to send in any given workflow
|
|
187
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseSchema>} IWorkflowResponse
|
|
188
|
+
*/
|
|
131
189
|
export const WorkflowResponseSchema = z.union([
|
|
132
190
|
WorkflowResponseSlotSchema,
|
|
133
191
|
z.array(WorkflowResponseSlotSchema)
|
|
134
192
|
]);
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @typedef {import('zod').infer<typeof WorkflowFunctionSchema>} IWorkflowFunction
|
|
196
|
+
*/
|
|
197
|
+
export const WorkflowFunctionSchema = z.function()
|
|
198
|
+
.args(WorkflowEventSchema)
|
|
199
|
+
.returns(z.union([
|
|
200
|
+
z.promise(WorkflowResponseSchema),
|
|
201
|
+
WorkflowResponseSchema,
|
|
202
|
+
]));
|