@scout9/app 1.0.0-alpha.0.1.9 → 1.0.0-alpha.0.1.90
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 +32 -0
- package/dist/{index-92deaa5f.cjs → exports-e7d51b70.cjs} +46618 -4591
- package/dist/index.cjs +58 -15
- package/dist/{multipart-parser-090f08a9.cjs → multipart-parser-e09a67c9.cjs} +13 -7
- package/dist/spirits-3b603262.cjs +1218 -0
- package/dist/spirits.cjs +9 -0
- package/dist/testing-tools.cjs +48 -0
- package/package.json +30 -8
- package/src/cli.js +162 -69
- package/src/core/config/agents.js +300 -7
- package/src/core/config/entities.js +58 -28
- package/src/core/config/index.js +37 -15
- package/src/core/config/project.js +160 -6
- package/src/core/config/workflow.js +13 -12
- package/src/core/data.js +27 -0
- package/src/core/index.js +386 -137
- package/src/core/sync.js +71 -0
- package/src/core/templates/Dockerfile +22 -0
- package/src/core/templates/app.js +453 -0
- package/src/core/templates/project-files.js +36 -0
- package/src/core/templates/template-package.json +13 -0
- package/src/exports.js +21 -17
- package/src/platform.js +189 -33
- package/src/public.d.ts.text +330 -0
- package/src/report.js +117 -0
- package/src/runtime/client/api.js +56 -159
- package/src/runtime/client/config.js +60 -11
- package/src/runtime/client/entity.js +19 -6
- package/src/runtime/client/index.js +5 -3
- package/src/runtime/client/message.js +13 -3
- package/src/runtime/client/platform.js +86 -0
- package/src/runtime/client/{agent.js → users.js} +35 -3
- package/src/runtime/client/utils.js +10 -9
- package/src/runtime/client/workflow.js +131 -9
- package/src/runtime/entry.js +2 -2
- package/src/testing-tools/dev.js +373 -0
- package/src/testing-tools/index.js +1 -0
- package/src/testing-tools/mocks.js +37 -5
- package/src/testing-tools/spirits.js +530 -0
- package/src/utils/audio-buffer.js +16 -0
- package/src/utils/audio-type.js +27 -0
- package/src/utils/configs/agents.js +68 -0
- package/src/utils/configs/entities.js +145 -0
- package/src/utils/configs/project.js +23 -0
- package/src/utils/configs/workflow.js +47 -0
- package/src/utils/file-type.js +569 -0
- package/src/utils/file.js +158 -0
- package/src/utils/glob.js +30 -0
- package/src/utils/image-buffer.js +23 -0
- package/src/utils/image-type.js +39 -0
- package/src/utils/index.js +1 -0
- package/src/utils/is-svg.js +37 -0
- package/src/utils/logger.js +111 -0
- package/src/utils/module.js +14 -25
- package/src/utils/project-templates.js +191 -0
- package/src/utils/project.js +387 -0
- package/src/utils/video-type.js +29 -0
- package/types/index.d.ts +7588 -206
- package/types/index.d.ts.map +97 -22
- package/dist/index-1b8d7dd2.cjs +0 -49555
- package/dist/index-2ccb115e.cjs +0 -49514
- package/dist/index-66b06a30.cjs +0 -49549
- package/dist/index-bc029a1d.cjs +0 -49528
- package/dist/index-d9a93523.cjs +0 -49527
- package/dist/multipart-parser-1508046a.cjs +0 -413
- package/dist/multipart-parser-7007403a.cjs +0 -413
- package/dist/multipart-parser-70c32c1d.cjs +0 -413
- package/dist/multipart-parser-71dec101.cjs +0 -413
- package/dist/multipart-parser-f15bf2e0.cjs +0 -414
- package/src/public.d.ts +0 -209
package/src/platform.js
CHANGED
|
@@ -1,83 +1,239 @@
|
|
|
1
1
|
import colors from 'kleur';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
build as _build,
|
|
5
|
+
deploy as _deploy,
|
|
6
|
+
run as _run,
|
|
7
|
+
runConfig as _runConfig,
|
|
8
|
+
sync as _sync,
|
|
9
|
+
test as _test
|
|
10
|
+
} from './core/index.js';
|
|
4
11
|
import { loadConfig, loadEnvConfig } from './core/config/index.js';
|
|
5
|
-
import { coalesceToError } from './utils/index.js';
|
|
12
|
+
import { coalesceToError, ProgressLogger } from './utils/index.js';
|
|
13
|
+
import ProjectFiles from './utils/project.js';
|
|
14
|
+
import { logUserValidationError, report } from './report.js';
|
|
6
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Collection of Scout9 Platform commands
|
|
18
|
+
*/
|
|
7
19
|
export const Scout9Platform = {
|
|
8
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Syncs the project with the Scout9 account
|
|
22
|
+
* @param {Object} params
|
|
23
|
+
* @param {string} [params.cwd=process.cwd()] - the working directory
|
|
24
|
+
* @param {string} [params.src='src'] - the source directory
|
|
25
|
+
* @param {string} [params.mode='production'] - the build mode
|
|
26
|
+
* @returns {Promise<import('./runtime/client/config.js').IScout9ProjectBuildConfig>}
|
|
27
|
+
*/
|
|
28
|
+
sync: async function ({cwd = process.cwd(), src = 'src', mode = 'production'} = {}) {
|
|
29
|
+
const logger = new ProgressLogger();
|
|
30
|
+
const messages = [];
|
|
9
31
|
try {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
32
|
+
logger.log(`Loading Local Config...`);
|
|
33
|
+
const projectFiles = new ProjectFiles({cwd, src, autoSave: true, logger});
|
|
34
|
+
const config = await projectFiles.load();
|
|
35
|
+
logger.success('Local Config Loaded');
|
|
36
|
+
logger.log(`Syncing project...`);
|
|
37
|
+
const result = await _sync({cwd, src, logger, projectFiles}, config);
|
|
38
|
+
logger.success('Sync Complete');
|
|
39
|
+
report(config, logger);
|
|
40
|
+
messages.forEach((m) => logger.info(m));
|
|
41
|
+
logger.done();
|
|
42
|
+
return result;
|
|
16
43
|
} catch (e) {
|
|
44
|
+
logger.done();
|
|
17
45
|
this.handleError(e);
|
|
18
46
|
}
|
|
19
47
|
},
|
|
20
48
|
|
|
21
49
|
/**
|
|
22
50
|
* Builds & Deploys the project
|
|
51
|
+
* @param {Object} params
|
|
52
|
+
* @param {string} [params.cwd=process.cwd()] - the working directory
|
|
53
|
+
* @param {string} [params.src='./src'] - the source directory
|
|
54
|
+
* @param {string} [params.dest='/tmp/project'] - the destination directory
|
|
55
|
+
* @param {'development' | 'production'} [params.mode='production'] - the build mode
|
|
56
|
+
* @param {boolean} [params.sync=true] - whether to sync the project after deploying
|
|
57
|
+
* @returns {Promise<import('./runtime/client/config.js').IScout9ProjectBuildConfig>}
|
|
23
58
|
*/
|
|
24
|
-
deploy:
|
|
59
|
+
deploy: async function (
|
|
60
|
+
{
|
|
61
|
+
cwd = process.cwd(),
|
|
62
|
+
src = './src',
|
|
63
|
+
dest = '/tmp/project',
|
|
64
|
+
mode = 'production',
|
|
65
|
+
sync = true
|
|
66
|
+
} = {}
|
|
67
|
+
) {
|
|
68
|
+
const logger = new ProgressLogger();
|
|
69
|
+
const messages = [];
|
|
25
70
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
await
|
|
71
|
+
// @TODO replace loadConfig with ProjectFiles class
|
|
72
|
+
logger.log(`Loading config...`);
|
|
73
|
+
let config = await loadConfig({cwd, src, deploying: true, dest, logger, cb: (m) => messages.push(m)});
|
|
74
|
+
logger.success('Config Loaded');
|
|
75
|
+
// await _build({cwd, src, dest, mode, logger}, config);
|
|
76
|
+
logger.log(`Deploying project...`);
|
|
77
|
+
const {contacts} = await _deploy({cwd, src, dest, logger}, config);
|
|
78
|
+
report(config, logger);
|
|
79
|
+
logger.success(`Deploy Complete\n\n`);
|
|
80
|
+
if (sync) {
|
|
81
|
+
logger.log(`Syncing project...`);
|
|
82
|
+
const projectFiles = new ProjectFiles({cwd, src, autoSave: true, logger});
|
|
83
|
+
config = await projectFiles.load();
|
|
84
|
+
const result = await _sync({cwd, src, logger, projectFiles}, config);
|
|
85
|
+
if (result.success) {
|
|
86
|
+
logger.success('Sync Complete');
|
|
87
|
+
config = result.config;
|
|
88
|
+
} else {
|
|
89
|
+
logger.error('Sync Failed');
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
logger.warn(`Syncing project... skipped`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
logger.write(`\tApplication will be live for the following channels in a few moments:\n${contacts}`);
|
|
96
|
+
logger.done();
|
|
97
|
+
messages.forEach((m) => logger.info(m));
|
|
29
98
|
return config;
|
|
30
99
|
} catch (e) {
|
|
100
|
+
logger.done();
|
|
101
|
+
this.handleError(e);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Tests the project
|
|
106
|
+
* @param {Object} params
|
|
107
|
+
* @param {string} [params.cwd=process.cwd()] - the working directory
|
|
108
|
+
* @param {string} [params.src='./src'] - the source directory
|
|
109
|
+
* @param {string} [params.dest='/tmp/project'] - the destination directory
|
|
110
|
+
* @param {'development' | 'production'} [params.mode='production'] - the build mode
|
|
111
|
+
* @returns {Promise<import('./runtime/client/config.js').IScout9ProjectBuildConfig>}
|
|
112
|
+
*/
|
|
113
|
+
test: async function ({cwd = process.cwd(), src = './src', dest = '/tmp/project', mode = 'production'} = {}) {
|
|
114
|
+
const logger = new ProgressLogger();
|
|
115
|
+
const messages = [];
|
|
116
|
+
try {
|
|
117
|
+
logger.log(`Loading test data...`);
|
|
118
|
+
const config = await loadConfig({cwd, src, logger, cb: (m) => messages.push(m)});
|
|
119
|
+
logger.success('Test data loaded');
|
|
120
|
+
logger.log(`Testing project...`);
|
|
121
|
+
await _test({cwd, src, dest, logger}, config);
|
|
122
|
+
report(config, logger);
|
|
123
|
+
messages.forEach((m) => logger.info(m));
|
|
124
|
+
logger.success(`Test complete`);
|
|
125
|
+
logger.done();
|
|
126
|
+
return config;
|
|
127
|
+
} catch (e) {
|
|
128
|
+
logger.done();
|
|
31
129
|
this.handleError(e);
|
|
32
130
|
}
|
|
33
131
|
},
|
|
34
|
-
|
|
35
132
|
/**
|
|
36
133
|
* Builds the project
|
|
134
|
+
* @param {Object} params
|
|
135
|
+
* @param {string} [params.cwd=process.cwd()] - the working directory
|
|
136
|
+
* @param {string} [params.src='./src'] - the source directory
|
|
137
|
+
* @param {string} [params.dest='/tmp/project'] - the destination directory
|
|
138
|
+
* @param {'development' | 'production'} [params.mode='production'] - the build mode
|
|
139
|
+
* @returns {Promise<import('./runtime/client/config.js').IScout9ProjectBuildConfig>}
|
|
37
140
|
*/
|
|
38
|
-
build: async function({cwd = process.cwd(), mode = 'production'} = {}) {
|
|
141
|
+
build: async function ({cwd = process.cwd(), src = './src', dest = '/tmp/project', mode = 'production'} = {}) {
|
|
142
|
+
const logger = new ProgressLogger();
|
|
143
|
+
const messages = [];
|
|
39
144
|
try {
|
|
40
|
-
|
|
41
|
-
await
|
|
145
|
+
logger.log(`Loading config...`);
|
|
146
|
+
const config = await loadConfig({
|
|
147
|
+
cwd, src, mode, logger, cb: (m) => {
|
|
148
|
+
logger.info(m);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
logger.success('Config Loaded');
|
|
152
|
+
logger.log(`Building project...`);
|
|
153
|
+
await _build({cwd, src, dest, mode, logger}, config);
|
|
154
|
+
report(config, logger);
|
|
155
|
+
messages.forEach((m) => logger.info(m));
|
|
156
|
+
logger.success('Build Complete');
|
|
157
|
+
logger.done();
|
|
42
158
|
return config;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
logger.done();
|
|
161
|
+
this.handleError(e);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Loads the project config
|
|
167
|
+
* @param {Object} params
|
|
168
|
+
* @param {string} [params.cwd=process.cwd()] - the working directory
|
|
169
|
+
* @param {boolean} [params.local=false] - whether to only load the local config (ignores what's saved on server)
|
|
170
|
+
* @param {string} [params.src='./src'] - the source directory
|
|
171
|
+
* @returns {Promise<import('./runtime/client/config.js').IScout9ProjectBuildConfig>}
|
|
172
|
+
*/
|
|
173
|
+
config: async function ({cwd = process.cwd(), local = false, src = './src'} = {}) {
|
|
174
|
+
try {
|
|
175
|
+
loadEnvConfig({cwd});
|
|
176
|
+
if (local) {
|
|
177
|
+
const projectFiles = new ProjectFiles({cwd, src, autoSave: false});
|
|
178
|
+
return projectFiles.load();
|
|
179
|
+
} else {
|
|
180
|
+
return _runConfig();
|
|
181
|
+
}
|
|
182
|
+
|
|
43
183
|
} catch (e) {
|
|
44
184
|
this.handleError(e);
|
|
185
|
+
throw e;
|
|
45
186
|
}
|
|
46
187
|
},
|
|
47
188
|
|
|
48
189
|
/**
|
|
49
190
|
* Runs the project in a container
|
|
191
|
+
* @param {import('./runtime/client/workflow.js').IWorkflowEvent} event - every workflow receives an event object
|
|
192
|
+
* @param {Object} options
|
|
193
|
+
* @param {string} [options.cwd=process.cwd()] - the working directory
|
|
194
|
+
* @param {string} [options.mode='production'] - the build mode
|
|
195
|
+
* @param {string} [options.src='./src'] - the source directory
|
|
196
|
+
* @param {string} options.eventSource - the source of the workflow event
|
|
197
|
+
* @returns {Promise<import('./runtime/client/workflow.js').IWorkflowResponse>}
|
|
50
198
|
*/
|
|
51
199
|
run: async function (
|
|
52
200
|
event,
|
|
53
|
-
{cwd = process.cwd(), mode = '
|
|
201
|
+
{cwd = process.cwd(), mode = 'production', src = './src', eventSource}
|
|
54
202
|
) {
|
|
55
|
-
if (mode !== 'remote') {
|
|
56
|
-
throw new Error(`Unimplemented mode "${mode}"`);
|
|
57
|
-
}
|
|
58
203
|
try {
|
|
59
204
|
loadEnvConfig({cwd});
|
|
60
|
-
return _run(event, {cwd,
|
|
205
|
+
return _run(event, {cwd, src, mode, eventSource})
|
|
206
|
+
.catch(e => {
|
|
207
|
+
throw e;
|
|
208
|
+
});
|
|
61
209
|
} catch (e) {
|
|
62
210
|
this.handleError(e);
|
|
63
211
|
throw e;
|
|
64
212
|
}
|
|
65
213
|
},
|
|
214
|
+
|
|
215
|
+
|
|
66
216
|
handleError: function (e) {
|
|
67
217
|
const error = coalesceToError(e);
|
|
68
218
|
|
|
69
|
-
|
|
219
|
+
switch (error.name) {
|
|
220
|
+
case 'SyntaxError':
|
|
221
|
+
throw error;
|
|
222
|
+
case 'ZodError':
|
|
223
|
+
logUserValidationError(error, error.source || 'src/index.js|ts');
|
|
224
|
+
break;
|
|
225
|
+
default:
|
|
226
|
+
console.error(colors.bold().red(`> ${error.message}`));
|
|
227
|
+
if (error instanceof z.ZodError) {
|
|
228
|
+
console.error(error.issues.map(i => colors.red(`${colors.bold(`\tZod Error (${i.code}): `)}"${i.message}" ${JSON.stringify(
|
|
229
|
+
i.path)}`)).join('\n'));
|
|
230
|
+
console.error(colors.gray(JSON.stringify(error.format(), null, 2)));
|
|
231
|
+
}
|
|
70
232
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.error(colors.gray(JSON.stringify(error.format(), null, 2)));
|
|
233
|
+
if (error.stack) {
|
|
234
|
+
console.error(colors.gray(error.stack.split('\n').slice(0).join('\n')));
|
|
235
|
+
}
|
|
75
236
|
}
|
|
76
|
-
|
|
77
|
-
if (error.stack) {
|
|
78
|
-
console.error(colors.gray(error.stack.split('\n').slice(0).join('\n')));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
237
|
process.exit(1);
|
|
82
238
|
}
|
|
83
|
-
}
|
|
239
|
+
};
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Represents the configuration provided in src/index.{js | ts} in a project
|
|
4
|
+
* @deprecated use IScout9ProjectConfig
|
|
5
|
+
*/
|
|
6
|
+
export interface Scout9ProjectConfig {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tag to reference this application
|
|
10
|
+
* @defaut your local package.json name + version, or scout9-app-v1.0.0
|
|
11
|
+
*/
|
|
12
|
+
tag?: string;
|
|
13
|
+
|
|
14
|
+
llm: {
|
|
15
|
+
engine: 'openai',
|
|
16
|
+
model: (string & {})
|
|
17
|
+
| 'gpt-4-1106-preview'
|
|
18
|
+
| 'gpt-4-vision-preview'
|
|
19
|
+
| 'gpt-4'
|
|
20
|
+
| 'gpt-4-0314'
|
|
21
|
+
| 'gpt-4-0613'
|
|
22
|
+
| 'gpt-4-32k'
|
|
23
|
+
| 'gpt-4-32k-0314'
|
|
24
|
+
| 'gpt-4-32k-0613'
|
|
25
|
+
| 'gpt-3.5-turbo'
|
|
26
|
+
| 'gpt-3.5-turbo-16k'
|
|
27
|
+
| 'gpt-3.5-turbo-0301'
|
|
28
|
+
| 'gpt-3.5-turbo-0613'
|
|
29
|
+
| 'gpt-3.5-turbo-16k-0613';
|
|
30
|
+
} | {
|
|
31
|
+
engine: 'bard' | 'gemini' | 'llama',
|
|
32
|
+
model: string;
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Configure personal model transformer (PMT) settings to align auto replies the agent's tone
|
|
36
|
+
*/
|
|
37
|
+
pmt: {
|
|
38
|
+
engine: 'scout9',
|
|
39
|
+
model: 'orin-1.0' | 'orin-2.0-preview'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Determines the max auto replies without further conversation progression (defined by new context data gathered)
|
|
44
|
+
* before the conversation is locked and requires manual intervention
|
|
45
|
+
* @default 3
|
|
46
|
+
*/
|
|
47
|
+
maxLockAttempts?: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Configure the initial contexts for every conversation
|
|
51
|
+
*/
|
|
52
|
+
initialContext: string[];
|
|
53
|
+
organization: {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
dashboard?: string;
|
|
57
|
+
logo?: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
logos?: string;
|
|
60
|
+
website?: string;
|
|
61
|
+
email?: string;
|
|
62
|
+
phone?: string;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Entity config the user provides
|
|
68
|
+
* @deprecated use IEntityConfiguration
|
|
69
|
+
*/
|
|
70
|
+
export interface EntityBuildConfig {
|
|
71
|
+
definitions?: {
|
|
72
|
+
utterance?: string;
|
|
73
|
+
value: string;
|
|
74
|
+
text: string[];
|
|
75
|
+
}[],
|
|
76
|
+
training?: {
|
|
77
|
+
text: string, intent: string;
|
|
78
|
+
}[];
|
|
79
|
+
tests?: {
|
|
80
|
+
text: string;
|
|
81
|
+
expected: {
|
|
82
|
+
intent: string;
|
|
83
|
+
context: any;
|
|
84
|
+
}
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* What gets exported to the scout9 backend, properties are constructed by @scout/app build
|
|
90
|
+
* @deprecated use IEntityRootProjectConfiguration instead
|
|
91
|
+
*/
|
|
92
|
+
export interface ExportedEntityBuildConfig extends EntityBuildConfig {
|
|
93
|
+
entities: string[];
|
|
94
|
+
entity: string;
|
|
95
|
+
// id: string;
|
|
96
|
+
api: {
|
|
97
|
+
QUERY?: boolean;
|
|
98
|
+
GET?: boolean;
|
|
99
|
+
POST?: boolean;
|
|
100
|
+
PUT?: boolean;
|
|
101
|
+
PATCH?: boolean;
|
|
102
|
+
DELETE?: boolean;
|
|
103
|
+
} | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated use IEntitiesRootProjectConfiguration instead
|
|
108
|
+
*/
|
|
109
|
+
export type EntitiesBuildConfig = ExportedEntityBuildConfig[];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated use IWorkflowConfiguration instead
|
|
113
|
+
*/
|
|
114
|
+
export type WorkflowBuildConfig = {
|
|
115
|
+
entities: string[];
|
|
116
|
+
entity: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated use IWorkflowsConfiguration instead
|
|
121
|
+
*/
|
|
122
|
+
export type WorkflowsBuildConfig = WorkflowBuildConfig[];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Including the provided project config, this is the manifest for all entities and workflows to be managed in build
|
|
126
|
+
* @deprecated IScout9ProjectBuildConfig
|
|
127
|
+
*/
|
|
128
|
+
export interface Scout9ProjectBuildConfig extends Scout9ProjectConfig {
|
|
129
|
+
agents: Agent[];
|
|
130
|
+
entities: EntitiesBuildConfig;
|
|
131
|
+
workflows: WorkflowsBuildConfig;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
export interface DeployOptions {
|
|
136
|
+
cwd?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface BuildOptions {
|
|
140
|
+
cwd?: string;
|
|
141
|
+
mode?: 'development' | 'production';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface RunOptions {
|
|
145
|
+
cwd?: string;
|
|
146
|
+
mode?: 'remote' | 'local';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated use IConversation
|
|
151
|
+
*/
|
|
152
|
+
export interface Conversation {
|
|
153
|
+
$agent: string;
|
|
154
|
+
$customer: string;
|
|
155
|
+
initialContexts?: string[];
|
|
156
|
+
environment: 'phone' | 'email' | 'web';
|
|
157
|
+
environmentProps?: {
|
|
158
|
+
subject?: string;
|
|
159
|
+
platformEmailThreadId?: string;
|
|
160
|
+
};
|
|
161
|
+
locked?: boolean;
|
|
162
|
+
lockedReason?: string;
|
|
163
|
+
lockAttempts?: number;
|
|
164
|
+
forwardedTo?: string; // personaId/phone/email
|
|
165
|
+
forwarded?: string; // ISO 8601
|
|
166
|
+
forwardNote?: string;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Detected intent
|
|
170
|
+
*/
|
|
171
|
+
intent?: string | null;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Confidence score of the assigned intent
|
|
175
|
+
*/
|
|
176
|
+
intentScore?: number | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @typedef {import('./runtime/client/message.js').IMessage} IMessage
|
|
181
|
+
* @deprecated use IMessage
|
|
182
|
+
*/
|
|
183
|
+
export interface Message {
|
|
184
|
+
id: string;
|
|
185
|
+
|
|
186
|
+
role: 'customer' | 'agent' | 'system';
|
|
187
|
+
content: string;
|
|
188
|
+
name?: string;
|
|
189
|
+
time: string;
|
|
190
|
+
|
|
191
|
+
scheduled?: string;
|
|
192
|
+
delayInSeconds?: number;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The context generated from the message
|
|
196
|
+
*/
|
|
197
|
+
context?: any;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Detected intent
|
|
201
|
+
*/
|
|
202
|
+
intent?: string | null;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Confidence score of the assigned intent
|
|
206
|
+
*/
|
|
207
|
+
intentScore?: number | null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @deprecated use ICustomer
|
|
212
|
+
*/
|
|
213
|
+
export interface Customer {
|
|
214
|
+
id: string;
|
|
215
|
+
name: string;
|
|
216
|
+
firstName?: string;
|
|
217
|
+
lastName?: string;
|
|
218
|
+
email?: string;
|
|
219
|
+
phone?: string;
|
|
220
|
+
img?: string;
|
|
221
|
+
neighborhood?: string;
|
|
222
|
+
city?: string;
|
|
223
|
+
country?: string;
|
|
224
|
+
line1?: string;
|
|
225
|
+
line2?: string;
|
|
226
|
+
postal_code?: string;
|
|
227
|
+
state?: string;
|
|
228
|
+
town?: string;
|
|
229
|
+
|
|
230
|
+
[key: string]: any;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @deprecated use IAgent
|
|
235
|
+
*/
|
|
236
|
+
export interface Agent {
|
|
237
|
+
// Generated Info
|
|
238
|
+
id: string;
|
|
239
|
+
deployed?: {
|
|
240
|
+
web?: string;
|
|
241
|
+
phone?: string;
|
|
242
|
+
email?: string;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Profile image path
|
|
247
|
+
*/
|
|
248
|
+
img?: string | Buffer;
|
|
249
|
+
|
|
250
|
+
firstName?: string;
|
|
251
|
+
lastName?: string;
|
|
252
|
+
inactive?: boolean;
|
|
253
|
+
programmablePhoneNumber?: string;
|
|
254
|
+
programmablePhoneNumberSid?: string;
|
|
255
|
+
programmableEmail?: string;
|
|
256
|
+
forwardEmail?: string;
|
|
257
|
+
forwardPhone?: string;
|
|
258
|
+
title?: string;
|
|
259
|
+
context?: string;
|
|
260
|
+
includedLocations?: string[];
|
|
261
|
+
excludedLocations?: string[];
|
|
262
|
+
model?: 'Scout9' | 'bard' | 'openai';
|
|
263
|
+
transcripts?: Message[][];
|
|
264
|
+
audios?: any[];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated use IPersona
|
|
269
|
+
*/
|
|
270
|
+
export type Persona = Agent;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The input event provided to the application
|
|
274
|
+
* @deprecated use IWorkflowEvent
|
|
275
|
+
*/
|
|
276
|
+
export interface WorkflowEvent<Type = any> {
|
|
277
|
+
messages: Message[];
|
|
278
|
+
conversation: Conversation;
|
|
279
|
+
context: Partial<Type>;
|
|
280
|
+
message: Message;
|
|
281
|
+
agent: Omit<Agent, 'transcripts' | 'audios' | 'includedLocations' | 'excludedLocations' | 'model' | 'context'>;
|
|
282
|
+
customer: Customer;
|
|
283
|
+
intent: {
|
|
284
|
+
current: string | null;
|
|
285
|
+
flow: string[];
|
|
286
|
+
initial: string | null;
|
|
287
|
+
};
|
|
288
|
+
stagnationCount: number;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @deprecated use IInstruction
|
|
293
|
+
*/
|
|
294
|
+
export interface Instruction {
|
|
295
|
+
id: string;
|
|
296
|
+
content: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @deprecated use IWorkflowResponseSlot
|
|
301
|
+
*/
|
|
302
|
+
export interface WorkflowResponseSlot<Type = any> {
|
|
303
|
+
forward?: string | boolean | {
|
|
304
|
+
to?: string;
|
|
305
|
+
mode?: 'after-reply' | 'immediately';
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Note to provide to the agent
|
|
309
|
+
*/
|
|
310
|
+
note?: string;
|
|
311
|
+
};
|
|
312
|
+
forwardNote?: string;
|
|
313
|
+
instructions?: string | string[] | Instruction | Instruction[];
|
|
314
|
+
removeInstructions?: string[];
|
|
315
|
+
message?: string;
|
|
316
|
+
secondsDelay?: number;
|
|
317
|
+
scheduled?: number;
|
|
318
|
+
contextUpsert?: Partial<Type>;
|
|
319
|
+
resetIntent?: boolean;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @deprecated use IWorkflowResponse
|
|
324
|
+
*/
|
|
325
|
+
export type WorkflowResponse<Type = any> = WorkflowResponseSlot<Type> | WorkflowResponseSlot<Type>[];
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @deprecated use IWorkflowFunction
|
|
329
|
+
*/
|
|
330
|
+
export type WorkflowFunction<Type = any> = (event: WorkflowEvent) => Promise<WorkflowResponse<Type>> | WorkflowResponse<Type>;
|