@scout9/app 1.0.0-alpha.0.3.1 → 1.0.0-alpha.0.3.2
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/{dev-73437873.cjs → dev-b57781e5.cjs} +114 -1031
- package/dist/{index-78f40e9a.cjs → index-6b64a6ac.cjs} +26 -10
- package/dist/index.cjs +4 -4
- package/dist/{macros-44f1f872.cjs → macros-5be965e9.cjs} +1 -1
- package/dist/{multipart-parser-12c1b026.cjs → multipart-parser-77660bcb.cjs} +4 -4
- package/dist/schemas.cjs +1 -1
- package/dist/{spirits-76855e30.cjs → spirits-d3dafe71.cjs} +2 -2
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +3 -3
- package/package.json +1 -1
- package/src/core/templates/app.js +9 -2
- package/src/platform.js +18 -3
- package/src/public.d.ts +16 -4
- package/src/runtime/macros/event.js +2 -1
- package/src/runtime/schemas/conversation.js +11 -1
- package/src/testing-tools/dev.js +1 -1
- package/src/testing-tools/spirits.js +2 -2
- package/types/index.d.ts +625 -601
- package/types/index.d.ts.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
4
|
-
var dev = require("./dev-
|
|
5
|
-
var macros = require("./macros-
|
|
3
|
+
var spirits = require("./spirits-d3dafe71.cjs");
|
|
4
|
+
var dev = require("./dev-b57781e5.cjs");
|
|
5
|
+
var macros = require("./macros-5be965e9.cjs");
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$2$1 = require('events');
|
|
8
8
|
var require$$1 = require('path');
|
|
@@ -29483,7 +29483,7 @@ class Body {
|
|
|
29483
29483
|
}
|
|
29484
29484
|
const {
|
|
29485
29485
|
toFormData
|
|
29486
|
-
} = await Promise.resolve().then(function () { return require("./multipart-parser-
|
|
29486
|
+
} = await Promise.resolve().then(function () { return require("./multipart-parser-77660bcb.cjs"); });
|
|
29487
29487
|
return toFormData(this.body, ct);
|
|
29488
29488
|
}
|
|
29489
29489
|
|
|
@@ -41892,7 +41892,7 @@ function _loadUserPackageJson() {
|
|
|
41892
41892
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
41893
41893
|
_context.t0 = JSON;
|
|
41894
41894
|
_context.next = 10;
|
|
41895
|
-
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
41895
|
+
return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-6b64a6ac.js', document.baseURI).href))), 'utf-8');
|
|
41896
41896
|
case 10:
|
|
41897
41897
|
_context.t1 = _context.sent;
|
|
41898
41898
|
pkg = _context.t0.parse.call(_context.t0, _context.t1);
|
|
@@ -43098,7 +43098,7 @@ var ProjectFiles = /*#__PURE__*/function () {
|
|
|
43098
43098
|
return ProjectFiles;
|
|
43099
43099
|
}();
|
|
43100
43100
|
|
|
43101
|
-
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
43101
|
+
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-6b64a6ac.js', document.baseURI).href)));
|
|
43102
43102
|
var __dirname$1 = path__default["default"].dirname(__filename$1);
|
|
43103
43103
|
function zipDirectory(source, out) {
|
|
43104
43104
|
var archive = archiver$1('tar', {
|
|
@@ -43313,7 +43313,7 @@ function _buildApp() {
|
|
|
43313
43313
|
case 11:
|
|
43314
43314
|
_context4.t0 = JSON;
|
|
43315
43315
|
_context4.next = 14;
|
|
43316
|
-
return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-
|
|
43316
|
+
return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-6b64a6ac.js', document.baseURI).href))), 'utf-8');
|
|
43317
43317
|
case 14:
|
|
43318
43318
|
_context4.t1 = _context4.sent;
|
|
43319
43319
|
packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
|
|
@@ -44428,10 +44428,26 @@ var Scout9Platform = {
|
|
|
44428
44428
|
method = request.method;
|
|
44429
44429
|
var status = response.status,
|
|
44430
44430
|
data = response.data;
|
|
44431
|
-
|
|
44432
|
-
|
|
44431
|
+
switch (path) {
|
|
44432
|
+
case '/v1-parse':
|
|
44433
|
+
console.error(dev.$.red(JSON.stringify(data)));
|
|
44434
|
+
break;
|
|
44435
|
+
default:
|
|
44436
|
+
console.error(dev.$.red(dev.$.bold("".concat(method, " ").concat(path, " Scout9 ApiError (").concat(status, ")")) + ': ' + JSON.stringify(data)));
|
|
44437
|
+
}
|
|
44438
|
+
break;
|
|
44433
44439
|
case 'SyntaxError':
|
|
44434
|
-
|
|
44440
|
+
var message = error.message,
|
|
44441
|
+
cause = error.cause;
|
|
44442
|
+
if (cause) {
|
|
44443
|
+
try {
|
|
44444
|
+
message += "\nCause: ".concat(JSON.stringify(cause));
|
|
44445
|
+
} catch (e) {
|
|
44446
|
+
//
|
|
44447
|
+
}
|
|
44448
|
+
}
|
|
44449
|
+
console.error(dev.$.red(dev.$.bold('SyntaxError') + ": ".concat(message)));
|
|
44450
|
+
break;
|
|
44435
44451
|
case 'ZodError':
|
|
44436
44452
|
dev.logUserValidationError(error, error.source || 'src/index.js|ts');
|
|
44437
44453
|
break;
|
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
var dev = require("./dev-
|
|
7
|
-
require("./spirits-
|
|
8
|
-
require("./macros-
|
|
5
|
+
var index = require("./index-6b64a6ac.cjs");
|
|
6
|
+
var dev = require("./dev-b57781e5.cjs");
|
|
7
|
+
require("./spirits-d3dafe71.cjs");
|
|
8
|
+
require("./macros-5be965e9.cjs");
|
|
9
9
|
require('fs');
|
|
10
10
|
require('events');
|
|
11
11
|
require('path');
|
|
@@ -4131,7 +4131,7 @@ var PersonasConfigurationSchema = z.array(PersonaConfigurationSchema);
|
|
|
4131
4131
|
var AgentsSchema = z.array(AgentSchema);
|
|
4132
4132
|
var PersonasSchema = z.array(PersonaSchema);
|
|
4133
4133
|
|
|
4134
|
-
var ConversationContext = z.record(z.string(), z.
|
|
4134
|
+
var ConversationContext = z.record(z.union([z.string(), z.number(), z["boolean"](), z["null"](), z.array(z.union([z.string(), z.number(), z["boolean"](), z["null"]()]))]));
|
|
4135
4135
|
var ConversationAnticipateSchema = z.object({
|
|
4136
4136
|
type: z["enum"](['did', 'literal', 'context'], {
|
|
4137
4137
|
description: "Determines the runtime to address the next response"
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
require("./spirits-
|
|
7
|
-
require("./dev-
|
|
5
|
+
var index = require("./index-6b64a6ac.cjs");
|
|
6
|
+
require("./spirits-d3dafe71.cjs");
|
|
7
|
+
require("./dev-b57781e5.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
|
@@ -25,7 +25,7 @@ require('node:stream');
|
|
|
25
25
|
require('node:string_decoder');
|
|
26
26
|
require('node:readline');
|
|
27
27
|
require('node:process');
|
|
28
|
-
require("./macros-
|
|
28
|
+
require("./macros-5be965e9.cjs");
|
|
29
29
|
require('node:os');
|
|
30
30
|
require('fs/promises');
|
|
31
31
|
require('constants');
|
package/dist/schemas.cjs
CHANGED
|
@@ -779,14 +779,14 @@ var Spirits = {
|
|
|
779
779
|
}
|
|
780
780
|
throw new Error("SpiritsError: No agent found in conversation, must define \".$agent\" in the conversation");
|
|
781
781
|
case 13:
|
|
782
|
-
persona = (config.persona || config.agents).find(function (p) {
|
|
782
|
+
persona = (config.persona || config.personas || config.agents).find(function (p) {
|
|
783
783
|
return p.id === conversation.$agent;
|
|
784
784
|
});
|
|
785
785
|
if (persona) {
|
|
786
786
|
_context2.next = 18;
|
|
787
787
|
break;
|
|
788
788
|
}
|
|
789
|
-
if (!(config.persona || config.agents).some(function (a) {
|
|
789
|
+
if (!(config.persona || config.personas || config.agents).some(function (a) {
|
|
790
790
|
return !a.id;
|
|
791
791
|
})) {
|
|
792
792
|
_context2.next = 17;
|
package/dist/spirits.cjs
CHANGED
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dev = require("./dev-
|
|
6
|
-
require("./spirits-
|
|
5
|
+
var dev = require("./dev-b57781e5.cjs");
|
|
6
|
+
require("./spirits-d3dafe71.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('path');
|
|
@@ -26,7 +26,7 @@ require('node:stream');
|
|
|
26
26
|
require('node:string_decoder');
|
|
27
27
|
require('node:readline');
|
|
28
28
|
require('node:process');
|
|
29
|
-
require("./macros-
|
|
29
|
+
require("./macros-5be965e9.cjs");
|
|
30
30
|
require('node:os');
|
|
31
31
|
require('fs/promises');
|
|
32
32
|
|
package/package.json
CHANGED
|
@@ -112,7 +112,7 @@ const handleError = (e, res = undefined) => {
|
|
|
112
112
|
const handleZodError = ({error, res = undefined, code = 500, status, name, bodyLabel = 'Provided Input', body = undefined, action = ''}) => {
|
|
113
113
|
res?.writeHead?.(code, {'Content-Type': 'application/json'});
|
|
114
114
|
if (error instanceof ZodError) {
|
|
115
|
-
const formattedErrors = JSON.stringify(error.
|
|
115
|
+
const formattedErrors = JSON.stringify(error.format(), null, 2);
|
|
116
116
|
res?.end?.(JSON.stringify({
|
|
117
117
|
status,
|
|
118
118
|
errors: formattedErrors
|
|
@@ -224,7 +224,14 @@ app.post(dev ? '/dev/workflow' : '/', async (req, res) => {
|
|
|
224
224
|
}
|
|
225
225
|
let response;
|
|
226
226
|
try {
|
|
227
|
-
response = await projectApp(workflowEvent)
|
|
227
|
+
response = await projectApp(workflowEvent)
|
|
228
|
+
.then((response) => {
|
|
229
|
+
if ('toJSON' in response) {
|
|
230
|
+
return response.toJSON();
|
|
231
|
+
} else {
|
|
232
|
+
return response;
|
|
233
|
+
}
|
|
234
|
+
})
|
|
228
235
|
} catch (error) {
|
|
229
236
|
error.message = `Workflow Template Runtime Error: ` + error.message;
|
|
230
237
|
handleError(error, res);
|
package/src/platform.js
CHANGED
|
@@ -219,10 +219,25 @@ export const Scout9Platform = {
|
|
|
219
219
|
const {request, response} = error;
|
|
220
220
|
const { path, method } = request;
|
|
221
221
|
const {status, data} = response;
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
switch (path) {
|
|
223
|
+
case '/v1-parse':
|
|
224
|
+
console.error(colors.red(JSON.stringify(data)));
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
console.error(colors.red(colors.bold(`${method} ${path} Scout9 ApiError (${status})`) + ': ' + JSON.stringify(data)));
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
224
230
|
case 'SyntaxError':
|
|
225
|
-
|
|
231
|
+
let {message, cause} = error;
|
|
232
|
+
if (cause) {
|
|
233
|
+
try {
|
|
234
|
+
message += `\nCause: ${JSON.stringify(cause)}`;
|
|
235
|
+
} catch (e) {
|
|
236
|
+
//
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
console.error(colors.red(colors.bold('SyntaxError') + `: ${message}`));
|
|
240
|
+
break;
|
|
226
241
|
case 'ZodError':
|
|
227
242
|
logUserValidationError(error, error.source || 'src/index.js|ts');
|
|
228
243
|
break;
|
package/src/public.d.ts
CHANGED
|
@@ -106,6 +106,9 @@ export const instruct: (message: string, options?: OptionsInstruct) => EventMacr
|
|
|
106
106
|
*
|
|
107
107
|
* Calling this method will lock the conversation and prevent auto replies from being sent to the user.
|
|
108
108
|
*
|
|
109
|
+
* @example - basic forward
|
|
110
|
+
* forward()
|
|
111
|
+
*
|
|
109
112
|
* @example - end of workflow
|
|
110
113
|
* forward("User wants 1 cheese pizza ready for pick");
|
|
111
114
|
*
|
|
@@ -117,7 +120,7 @@ export const instruct: (message: string, options?: OptionsInstruct) => EventMacr
|
|
|
117
120
|
*
|
|
118
121
|
* @type {(message: string, options?: OptionsForward) => EventMacros}
|
|
119
122
|
*/
|
|
120
|
-
export const forward: (message
|
|
123
|
+
export const forward: (message?: string, options?: OptionsForward) => EventMacros;
|
|
121
124
|
/**
|
|
122
125
|
* Manual message to send to the customer from the workflow.
|
|
123
126
|
*
|
|
@@ -177,6 +180,8 @@ export type OptionsForward = {
|
|
|
177
180
|
* - another phone or email to forward to instead of owner
|
|
178
181
|
*/
|
|
179
182
|
to?: string;
|
|
183
|
+
|
|
184
|
+
resetIntent?: boolean;
|
|
180
185
|
};
|
|
181
186
|
/**
|
|
182
187
|
* - Extends `WorkflowResponseSlotBase` to include keywords.
|
|
@@ -214,8 +219,7 @@ export type ContextExampleWithTrainingData = {
|
|
|
214
219
|
output: Record<string, any>[];
|
|
215
220
|
}
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
export type ConversationContext = Record<string, any>;
|
|
222
|
+
export type ConversationContext = Record<string, string | number | boolean | null | Array<string | number | boolean | null>>;
|
|
219
223
|
|
|
220
224
|
export type ContextExamples = (ContextExampleWithTrainingData | ConversationContext)[];
|
|
221
225
|
export type ContextOutput = Record<string, any>;
|
|
@@ -525,7 +529,15 @@ export type Scout9ProjectConfig = {
|
|
|
525
529
|
};
|
|
526
530
|
|
|
527
531
|
export type Scout9ProjectBuildConfig = Scout9ProjectConfig & {
|
|
528
|
-
agents:
|
|
532
|
+
agents: AgentsConfiguration;
|
|
533
|
+
/**
|
|
534
|
+
* @deprecated use agents
|
|
535
|
+
*/
|
|
536
|
+
personas?: AgentsConfiguration;
|
|
537
|
+
/**
|
|
538
|
+
* @deprecated use agents
|
|
539
|
+
*/
|
|
540
|
+
persona?: AgentsConfiguration;
|
|
529
541
|
entities: EntityRootProjectConfiguration[];
|
|
530
542
|
workflows: WorkflowConfiguration[];
|
|
531
543
|
};
|
|
@@ -268,12 +268,13 @@ function EventMacrosFactory() {
|
|
|
268
268
|
},
|
|
269
269
|
/**
|
|
270
270
|
* Returns event payload
|
|
271
|
+
* @param {boolean} flush - if true, will reset the data payload
|
|
271
272
|
* @return {Array<WorkflowResponseSlot>}
|
|
272
273
|
*/
|
|
273
274
|
toJSON(flush = true) {
|
|
274
275
|
if (flush) {
|
|
275
276
|
const copy = [...slots];
|
|
276
|
-
slots =[];
|
|
277
|
+
slots = [];
|
|
277
278
|
return copy;
|
|
278
279
|
} else {
|
|
279
280
|
return slots;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { zId } from './utils.js';
|
|
3
3
|
|
|
4
|
-
export const ConversationContext = z.record(
|
|
4
|
+
export const ConversationContext = z.record(
|
|
5
|
+
z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number(),
|
|
8
|
+
z.boolean(),
|
|
9
|
+
z.null(),
|
|
10
|
+
z.array(
|
|
11
|
+
z.union([z.string(), z.number(), z.boolean(), z.null()])
|
|
12
|
+
)
|
|
13
|
+
])
|
|
14
|
+
);
|
|
5
15
|
|
|
6
16
|
export const ConversationAnticipateSchema = z.object({
|
|
7
17
|
type: z.enum(['did', 'literal', 'context'], {description: "Determines the runtime to address the next response"}),
|
package/src/testing-tools/dev.js
CHANGED
|
@@ -268,7 +268,7 @@ export class Scout9Test {
|
|
|
268
268
|
console.error(`Invalid forward result`, result.conversation.forward);
|
|
269
269
|
this.conversation.forwardedTo = 'Invalid Forward';
|
|
270
270
|
}
|
|
271
|
-
this.conversation.forwarded = new Date().
|
|
271
|
+
this.conversation.forwarded = new Date().toISOString();
|
|
272
272
|
this.conversation.forwardNote = result.conversation.forwardNote || '';
|
|
273
273
|
this.conversation.locked = true;
|
|
274
274
|
this.conversation.lockedReason = result.conversation.forwardNote ?? ('Forwarded to ' + this.conversation.forwardedTo);
|
|
@@ -235,9 +235,9 @@ export const Spirits = {
|
|
|
235
235
|
if (!conversation.$agent) {
|
|
236
236
|
throw new Error(`SpiritsError: No agent found in conversation, must define ".$agent" in the conversation`);
|
|
237
237
|
}
|
|
238
|
-
const persona = (config.persona || config.agents).find(p => p.id === conversation.$agent);
|
|
238
|
+
const persona = (config.persona || config.personas || config.agents).find(p => p.id === conversation.$agent);
|
|
239
239
|
if (!persona) {
|
|
240
|
-
if ((config.persona || config.agents).some(a => !a.id)) {
|
|
240
|
+
if ((config.persona || config.personas || config.agents).some(a => !a.id)) {
|
|
241
241
|
throw new Error(`SpiritsError: No persona found ("${conversation.$agent}") in provided config, some persona's did not contain an "id" (Internal Mapping Error)`);
|
|
242
242
|
}
|
|
243
243
|
throw new Error(`SpiritsError: No persona found ("${conversation.$agent}") in provided config`);
|