@scout9/app 1.0.0-alpha.0.1.85 → 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-dc75cb8b.cjs → exports-85e8c05c.cjs} +420 -239
- package/dist/index.cjs +37 -1
- package/dist/{multipart-parser-f133fa41.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 +12 -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 +4 -4
- package/src/runtime/client/workflow.js +73 -5
- package/types/index.d.ts +4068 -505
- package/types/index.d.ts.map +87 -18
package/src/platform.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import colors from 'kleur';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
10
|
} from './core/index.js';
|
|
11
11
|
import { loadConfig, loadEnvConfig } from './core/config/index.js';
|
|
12
12
|
import { coalesceToError, ProgressLogger } from './utils/index.js';
|
|
@@ -17,221 +17,223 @@ import { logUserValidationError, report } from './report.js';
|
|
|
17
17
|
* Collection of Scout9 Platform commands
|
|
18
18
|
*/
|
|
19
19
|
export const Scout9Platform = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
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<Scout9ProjectBuildConfig>}
|
|
58
|
-
*/
|
|
59
|
-
deploy: async function ({
|
|
60
|
-
cwd = process.cwd(),
|
|
61
|
-
src = './src',
|
|
62
|
-
dest = '/tmp/project',
|
|
63
|
-
mode = 'production',
|
|
64
|
-
sync = true
|
|
65
|
-
} = {}) {
|
|
66
|
-
const logger = new ProgressLogger();
|
|
67
|
-
const messages = [];
|
|
68
|
-
try {
|
|
69
|
-
// @TODO replace loadConfig with ProjectFiles class
|
|
70
|
-
logger.log(`Loading config...`);
|
|
71
|
-
let config = await loadConfig({cwd, src, deploying: true, dest, logger, cb: (m) => messages.push(m)});
|
|
72
|
-
logger.success('Config Loaded');
|
|
73
|
-
// await _build({cwd, src, dest, mode, logger}, config);
|
|
74
|
-
logger.log(`Deploying project...`);
|
|
75
|
-
const {contacts} = await _deploy({cwd, src, dest, logger}, config);
|
|
76
|
-
report(config, logger);
|
|
77
|
-
logger.success(`Deploy Complete\n\n`);
|
|
78
|
-
if (sync) {
|
|
79
|
-
logger.log(`Syncing project...`);
|
|
80
|
-
const projectFiles = new ProjectFiles({cwd, src, autoSave: true, logger});
|
|
81
|
-
config = await projectFiles.load();
|
|
82
|
-
const result = await _sync({cwd, src, logger, projectFiles}, config);
|
|
83
|
-
if (result.success) {
|
|
84
|
-
logger.success('Sync Complete');
|
|
85
|
-
config = result.config;
|
|
86
|
-
} else {
|
|
87
|
-
logger.error('Sync Failed');
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
logger.warn(`Syncing project... skipped`);
|
|
91
|
-
}
|
|
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 = [];
|
|
31
|
+
try {
|
|
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;
|
|
43
|
+
} catch (e) {
|
|
44
|
+
logger.done();
|
|
45
|
+
this.handleError(e);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
92
48
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
49
|
+
/**
|
|
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>}
|
|
58
|
+
*/
|
|
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 = [];
|
|
70
|
+
try {
|
|
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');
|
|
128
90
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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));
|
|
98
|
+
return config;
|
|
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();
|
|
129
|
+
this.handleError(e);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
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>}
|
|
140
|
+
*/
|
|
141
|
+
build: async function ({cwd = process.cwd(), src = './src', dest = '/tmp/project', mode = 'production'} = {}) {
|
|
142
|
+
const logger = new ProgressLogger();
|
|
143
|
+
const messages = [];
|
|
144
|
+
try {
|
|
145
|
+
logger.log(`Loading config...`);
|
|
146
|
+
const config = await loadConfig({
|
|
147
|
+
cwd, src, mode, logger, cb: (m) => {
|
|
148
|
+
logger.info(m);
|
|
160
149
|
}
|
|
161
|
-
|
|
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();
|
|
158
|
+
return config;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
logger.done();
|
|
161
|
+
this.handleError(e);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
162
164
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
}
|
|
180
182
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
} catch (e) {
|
|
184
|
+
this.handleError(e);
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
186
188
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
189
|
+
/**
|
|
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>}
|
|
198
|
+
*/
|
|
199
|
+
run: async function (
|
|
200
|
+
event,
|
|
201
|
+
{cwd = process.cwd(), mode = 'production', src = './src', eventSource}
|
|
202
|
+
) {
|
|
203
|
+
try {
|
|
204
|
+
loadEnvConfig({cwd});
|
|
205
|
+
return _run(event, {cwd, src, mode, eventSource})
|
|
206
|
+
.catch(e => {
|
|
207
|
+
throw e;
|
|
208
|
+
});
|
|
209
|
+
} catch (e) {
|
|
210
|
+
this.handleError(e);
|
|
211
|
+
throw e;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
212
214
|
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
+
handleError: function (e) {
|
|
217
|
+
const error = coalesceToError(e);
|
|
216
218
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
+
}
|
|
230
232
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
233
|
+
if (error.stack) {
|
|
234
|
+
console.error(colors.gray(error.stack.split('\n').slice(0).join('\n')));
|
|
234
235
|
}
|
|
235
|
-
process.exit(1);
|
|
236
236
|
}
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
237
239
|
};
|
package/src/public.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
* Represents the configuration provided in src/index.{js | ts} in a project
|
|
4
|
+
* @deprecated use IScout9ProjectConfig
|
|
4
5
|
*/
|
|
5
6
|
export interface Scout9ProjectConfig {
|
|
6
7
|
|
|
@@ -64,6 +65,7 @@ export interface Scout9ProjectConfig {
|
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Entity config the user provides
|
|
68
|
+
* @deprecated use IEntityConfiguration
|
|
67
69
|
*/
|
|
68
70
|
export interface EntityBuildConfig {
|
|
69
71
|
definitions?: {
|
|
@@ -85,6 +87,7 @@ export interface EntityBuildConfig {
|
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
89
|
* What gets exported to the scout9 backend, properties are constructed by @scout/app build
|
|
90
|
+
* @deprecated use IEntityRootProjectConfiguration instead
|
|
88
91
|
*/
|
|
89
92
|
export interface ExportedEntityBuildConfig extends EntityBuildConfig {
|
|
90
93
|
entities: string[];
|
|
@@ -100,15 +103,27 @@ export interface ExportedEntityBuildConfig extends EntityBuildConfig {
|
|
|
100
103
|
} | null;
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated use IEntitiesRootProjectConfiguration instead
|
|
108
|
+
*/
|
|
103
109
|
export type EntitiesBuildConfig = ExportedEntityBuildConfig[];
|
|
104
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated use IWorkflowConfiguration instead
|
|
113
|
+
*/
|
|
105
114
|
export type WorkflowBuildConfig = {
|
|
106
115
|
entities: string[];
|
|
107
116
|
entity: string;
|
|
108
117
|
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated use IWorkflowsConfiguration instead
|
|
121
|
+
*/
|
|
109
122
|
export type WorkflowsBuildConfig = WorkflowBuildConfig[];
|
|
123
|
+
|
|
110
124
|
/**
|
|
111
125
|
* Including the provided project config, this is the manifest for all entities and workflows to be managed in build
|
|
126
|
+
* @deprecated IScout9ProjectBuildConfig
|
|
112
127
|
*/
|
|
113
128
|
export interface Scout9ProjectBuildConfig extends Scout9ProjectConfig {
|
|
114
129
|
agents: Agent[];
|
|
@@ -131,6 +146,9 @@ export interface RunOptions {
|
|
|
131
146
|
mode?: 'remote' | 'local';
|
|
132
147
|
}
|
|
133
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated use IConversation
|
|
151
|
+
*/
|
|
134
152
|
export interface Conversation {
|
|
135
153
|
$agent: string;
|
|
136
154
|
$customer: string;
|
|
@@ -158,6 +176,9 @@ export interface Conversation {
|
|
|
158
176
|
intentScore?: number | null;
|
|
159
177
|
}
|
|
160
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated use IMessage
|
|
181
|
+
*/
|
|
161
182
|
export interface Message {
|
|
162
183
|
id: string;
|
|
163
184
|
|
|
@@ -185,6 +206,9 @@ export interface Message {
|
|
|
185
206
|
intentScore?: number | null;
|
|
186
207
|
}
|
|
187
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @deprecated use ICustomer
|
|
211
|
+
*/
|
|
188
212
|
export interface Customer {
|
|
189
213
|
id: string;
|
|
190
214
|
name: string;
|
|
@@ -205,6 +229,9 @@ export interface Customer {
|
|
|
205
229
|
[key: string]: any;
|
|
206
230
|
}
|
|
207
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated use IAgent
|
|
234
|
+
*/
|
|
208
235
|
export interface Agent {
|
|
209
236
|
// Generated Info
|
|
210
237
|
id: string;
|
|
@@ -236,10 +263,14 @@ export interface Agent {
|
|
|
236
263
|
audios?: any[];
|
|
237
264
|
}
|
|
238
265
|
|
|
266
|
+
/**
|
|
267
|
+
* @deprecated use IPersona
|
|
268
|
+
*/
|
|
239
269
|
export type Persona = Agent;
|
|
240
270
|
|
|
241
271
|
/**
|
|
242
272
|
* The input event provided to the application
|
|
273
|
+
* @deprecated use IWorkflowEvent
|
|
243
274
|
*/
|
|
244
275
|
export interface WorkflowEvent<Type = any> {
|
|
245
276
|
messages: Message[];
|
|
@@ -256,11 +287,17 @@ export interface WorkflowEvent<Type = any> {
|
|
|
256
287
|
stagnationCount: number;
|
|
257
288
|
}
|
|
258
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @deprecated use IInstruction
|
|
292
|
+
*/
|
|
259
293
|
export interface Instruction {
|
|
260
294
|
id: string;
|
|
261
295
|
content: string;
|
|
262
296
|
}
|
|
263
297
|
|
|
298
|
+
/**
|
|
299
|
+
* @deprecated use IWorkflowResponseSlot
|
|
300
|
+
*/
|
|
264
301
|
export interface WorkflowResponseSlot<Type = any> {
|
|
265
302
|
forward?: string | boolean | {
|
|
266
303
|
to?: string;
|
|
@@ -281,86 +318,12 @@ export interface WorkflowResponseSlot<Type = any> {
|
|
|
281
318
|
resetIntent?: boolean;
|
|
282
319
|
}
|
|
283
320
|
|
|
321
|
+
/**
|
|
322
|
+
* @deprecated use IWorkflowResponse
|
|
323
|
+
*/
|
|
284
324
|
export type WorkflowResponse<Type = any> = WorkflowResponseSlot<Type> | WorkflowResponseSlot<Type>[];
|
|
285
325
|
|
|
326
|
+
/**
|
|
327
|
+
* @deprecated use IWorkflowFunction
|
|
328
|
+
*/
|
|
286
329
|
export type WorkflowFunction<Type = any> = (event: WorkflowEvent) => Promise<WorkflowResponse<Type>> | WorkflowResponse<Type>;
|
|
287
|
-
|
|
288
|
-
export declare function json<Type = any>(data: Type, init?: ResponseInit): Promise<EventResponse<Type>>;
|
|
289
|
-
|
|
290
|
-
export declare function run<Type = any>(event: WorkflowEvent, options?: RunOptions): Promise<WorkflowResponse<Type>>;
|
|
291
|
-
|
|
292
|
-
export declare function sendEvent<Type = any>(event: WorkflowEvent, options?: RunOptions): Promise<WorkflowResponse<Type>>;
|
|
293
|
-
|
|
294
|
-
export declare function build(options?: BuildOptions): Promise<Scout9ProjectBuildConfig>;
|
|
295
|
-
|
|
296
|
-
export declare function deploy(options?: DeployOptions): Promise<Scout9ProjectBuildConfig>;
|
|
297
|
-
|
|
298
|
-
export class EventResponse<Type = any> {
|
|
299
|
-
/**
|
|
300
|
-
* Static method to create an EventResponse object.
|
|
301
|
-
* @param body The body of the response, expected to be an object.
|
|
302
|
-
* @param options Additional options for the response.
|
|
303
|
-
*/
|
|
304
|
-
static json<Type = any>(body: object, options?: ResponseInit): EventResponse<Type>;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* The body of the response.
|
|
308
|
-
*/
|
|
309
|
-
body: object;
|
|
310
|
-
|
|
311
|
-
// Alias to body
|
|
312
|
-
readonly data: object;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Initialization options for the response.
|
|
316
|
-
*/
|
|
317
|
-
init?: ResponseInit;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Creates an instance of EventResponse.
|
|
321
|
-
* @param body The body of the response, expected to be an object.
|
|
322
|
-
* @param init Initialization options for the response.
|
|
323
|
-
*/
|
|
324
|
-
constructor(body: Type, init?: ResponseInit);
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Returns a Response object with JSON body.
|
|
328
|
-
*/
|
|
329
|
-
readonly response: Response;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export type ApiFunctionParams<Params = Record<string, string>> = {
|
|
333
|
-
searchParams: {[key: string]: string | string[] };
|
|
334
|
-
params: Params;
|
|
335
|
-
}
|
|
336
|
-
// export type ApiEntityFunctionParams<Params = Record<string, string>> = ApiFunctionParams<Params> & {id: string};
|
|
337
|
-
export type ApiFunction<Params = Record<string, string>, Response = any> = (params: ApiFunctionParams<Params>) => Promise<EventResponse<Response>>;
|
|
338
|
-
export type QueryApiFunction<Params = Record<string, string>, Response = any> = (params: ApiFunctionParams<Params>) => Promise<EventResponse<Response>>;
|
|
339
|
-
export type GetApiFunction<Params = Record<string, string>, Response = any> = (params: ApiFunctionParams<Params>) => Promise<EventResponse<Response>>;
|
|
340
|
-
export type PostApiFunction<Params = Record<string, string>, RequestBody = any, Response = any> = (params: ApiFunctionParams<Params> & {body: Partial<RequestBody>}) => Promise<EventResponse<Response>>;
|
|
341
|
-
export type PutApiFunction<Params = Record<string, string>, RequestBody = any, Response = any> = (params: ApiFunctionParams<Params> & {body: Partial<RequestBody>}) => Promise<EventResponse<Response>>;
|
|
342
|
-
export type PatchApiFunction<Params = Record<string, string>, RequestBody = any, Response = any> = (params: ApiFunctionParams<Params> & {body: Partial<RequestBody>}) => Promise<EventResponse<Response>>;
|
|
343
|
-
export type DeleteApiFunction<Params = Record<string, string>, Response = any> = (params: ApiFunctionParams<Params>) => Promise<EventResponse<Response>>;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
export type mimicCustomerMessage = (input: {
|
|
347
|
-
message: string;
|
|
348
|
-
messages?: Message[];
|
|
349
|
-
workflowFn: WorkflowFunction;
|
|
350
|
-
customer?: Customer;
|
|
351
|
-
context?: any;
|
|
352
|
-
/**
|
|
353
|
-
* Agent or persona id
|
|
354
|
-
*/
|
|
355
|
-
persona?: string;
|
|
356
|
-
|
|
357
|
-
conversation?: Conversation;
|
|
358
|
-
|
|
359
|
-
cwd?: string;
|
|
360
|
-
src?: string;
|
|
361
|
-
mode?: 'development' | 'production';
|
|
362
|
-
}) => Promise<{
|
|
363
|
-
messages: Message[];
|
|
364
|
-
conversation: Conversation;
|
|
365
|
-
context: any;
|
|
366
|
-
}>
|