@scout9/app 1.0.0-alpha.0.5.9 → 1.0.0-alpha.0.6.0
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-8ed1e379.cjs → dev-32a9a0c8.cjs} +4 -4
- package/dist/{index-4f698e67.cjs → index-d94326d3.cjs} +7 -7
- package/dist/index.cjs +4 -4
- package/dist/{macros-4bff92c7.cjs → macros-621210f1.cjs} +14 -2
- package/dist/{multipart-parser-8f894f70.cjs → multipart-parser-6ba4e92d.cjs} +4 -4
- package/dist/schemas.cjs +2 -1
- package/dist/{spirits-82575cd5.cjs → spirits-8819b1c9.cjs} +106 -93
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +3 -3
- package/package.json +1 -1
- package/src/public.d.ts +10 -1
- package/src/runtime/schemas/message.js +10 -1
- package/src/runtime/schemas/users.js +3 -0
- package/src/testing-tools/spirits.js +13 -0
- package/types/index.d.ts +916 -2
- package/types/index.d.ts.map +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
3
|
+
var spirits = require("./spirits-8819b1c9.cjs");
|
|
4
4
|
var require$$0$4 = require('util');
|
|
5
5
|
var require$$0$3 = require('stream');
|
|
6
6
|
var require$$1 = require('path');
|
|
@@ -21,7 +21,7 @@ var node_url = require('node:url');
|
|
|
21
21
|
var node_events = require('node:events');
|
|
22
22
|
var Stream = require('node:stream');
|
|
23
23
|
var node_string_decoder = require('node:string_decoder');
|
|
24
|
-
var macros = require("./macros-
|
|
24
|
+
var macros = require("./macros-621210f1.cjs");
|
|
25
25
|
var readline = require('node:readline');
|
|
26
26
|
var process$2 = require('node:process');
|
|
27
27
|
var node_os = require('node:os');
|
|
@@ -30176,7 +30176,7 @@ common.createRequestFunction = createRequestFunction;
|
|
|
30176
30176
|
var configuration = {};
|
|
30177
30177
|
|
|
30178
30178
|
var name$1 = "@scout9/admin";
|
|
30179
|
-
var version$2 = "1.0.0-alpha.0.0.
|
|
30179
|
+
var version$2 = "1.0.0-alpha.0.0.55";
|
|
30180
30180
|
var description$1 = "";
|
|
30181
30181
|
var main$2 = "./build/index.js";
|
|
30182
30182
|
var types$1 = "./build/index.d.ts";
|
|
@@ -35241,7 +35241,7 @@ function _loadUserPackageJson() {
|
|
|
35241
35241
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
35242
35242
|
_context2.t0 = JSON;
|
|
35243
35243
|
_context2.next = 10;
|
|
35244
|
-
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('dev-
|
|
35244
|
+
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('dev-32a9a0c8.js', document.baseURI).href))), 'utf-8');
|
|
35245
35245
|
case 10:
|
|
35246
35246
|
_context2.t1 = _context2.sent;
|
|
35247
35247
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -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-8819b1c9.cjs");
|
|
4
|
+
var dev = require("./dev-32a9a0c8.cjs");
|
|
5
|
+
var macros = require("./macros-621210f1.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-6ba4e92d.cjs"); });
|
|
29487
29487
|
return toFormData(this.body, ct);
|
|
29488
29488
|
}
|
|
29489
29489
|
|
|
@@ -41884,7 +41884,7 @@ function _loadUserPackageJson() {
|
|
|
41884
41884
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
41885
41885
|
_context.t0 = JSON;
|
|
41886
41886
|
_context.next = 10;
|
|
41887
|
-
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-
|
|
41887
|
+
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-d94326d3.js', document.baseURI).href))), 'utf-8');
|
|
41888
41888
|
case 10:
|
|
41889
41889
|
_context.t1 = _context.sent;
|
|
41890
41890
|
pkg = _context.t0.parse.call(_context.t0, _context.t1);
|
|
@@ -43176,7 +43176,7 @@ var ProjectFiles = /*#__PURE__*/function () {
|
|
|
43176
43176
|
return ProjectFiles;
|
|
43177
43177
|
}();
|
|
43178
43178
|
|
|
43179
|
-
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-
|
|
43179
|
+
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-d94326d3.js', document.baseURI).href)));
|
|
43180
43180
|
var __dirname$1 = path__default["default"].dirname(__filename$1);
|
|
43181
43181
|
function zipDirectory(source, out) {
|
|
43182
43182
|
var archive = archiver$1('tar', {
|
|
@@ -43391,7 +43391,7 @@ function _buildApp() {
|
|
|
43391
43391
|
case 11:
|
|
43392
43392
|
_context4.t0 = JSON;
|
|
43393
43393
|
_context4.next = 14;
|
|
43394
|
-
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-
|
|
43394
|
+
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-d94326d3.js', document.baseURI).href))), 'utf-8');
|
|
43395
43395
|
case 14:
|
|
43396
43396
|
_context4.t1 = _context4.sent;
|
|
43397
43397
|
packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
|
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-d94326d3.cjs");
|
|
6
|
+
var dev = require("./dev-32a9a0c8.cjs");
|
|
7
|
+
require("./spirits-8819b1c9.cjs");
|
|
8
|
+
require("./macros-621210f1.cjs");
|
|
9
9
|
require('fs');
|
|
10
10
|
require('events');
|
|
11
11
|
require('path');
|
|
@@ -4015,6 +4015,13 @@ function zId(name) {
|
|
|
4015
4015
|
});
|
|
4016
4016
|
}
|
|
4017
4017
|
|
|
4018
|
+
var MessageEntitySchema = z.object({
|
|
4019
|
+
start: z.number(),
|
|
4020
|
+
end: z.number(),
|
|
4021
|
+
type: z.string(),
|
|
4022
|
+
option: z.string().optional().nullable(),
|
|
4023
|
+
text: z.string().optional().nullable()
|
|
4024
|
+
});
|
|
4018
4025
|
var MessageSchema = z.object({
|
|
4019
4026
|
id: zId('Message ID', {
|
|
4020
4027
|
description: 'Unique ID for the message'
|
|
@@ -4039,7 +4046,8 @@ var MessageSchema = z.object({
|
|
|
4039
4046
|
}).nullable().optional(),
|
|
4040
4047
|
delayInSeconds: z.number({
|
|
4041
4048
|
description: 'How long to delay the message manually in seconds'
|
|
4042
|
-
}).nullable().optional()
|
|
4049
|
+
}).nullable().optional(),
|
|
4050
|
+
entities: z.array(MessageEntitySchema).optional().nullable()
|
|
4043
4051
|
});
|
|
4044
4052
|
|
|
4045
4053
|
var CustomerValueSchema = z.union([z["boolean"](), z.number(), z.string()]);
|
|
@@ -4117,7 +4125,10 @@ var AgentSchema = z.object({
|
|
|
4117
4125
|
pmt: z.object({
|
|
4118
4126
|
tag: z.string().optional(),
|
|
4119
4127
|
ingress: z["enum"](["auto", "manual", "app", "workflow"]),
|
|
4120
|
-
llm: z.string().optional()
|
|
4128
|
+
llm: z.string().optional(),
|
|
4129
|
+
webhookUri: z.string().optional(),
|
|
4130
|
+
watermarkEnabled: z["boolean"]().optional(),
|
|
4131
|
+
watermark: z.string().optional()
|
|
4121
4132
|
}).optional()
|
|
4122
4133
|
});
|
|
4123
4134
|
var PersonaSchema = AgentSchema;
|
|
@@ -4585,6 +4596,7 @@ exports.ForwardSchema = ForwardSchema;
|
|
|
4585
4596
|
exports.InstructionObjectSchema = InstructionObjectSchema;
|
|
4586
4597
|
exports.InstructionSchema = InstructionSchema;
|
|
4587
4598
|
exports.IntentWorkflowEventSchema = IntentWorkflowEventSchema;
|
|
4599
|
+
exports.MessageEntitySchema = MessageEntitySchema;
|
|
4588
4600
|
exports.MessageSchema = MessageSchema;
|
|
4589
4601
|
exports.PersonaConfigurationSchema = PersonaConfigurationSchema;
|
|
4590
4602
|
exports.PersonaSchema = PersonaSchema;
|
|
@@ -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-d94326d3.cjs");
|
|
6
|
+
require("./spirits-8819b1c9.cjs");
|
|
7
|
+
require("./dev-32a9a0c8.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
|
@@ -23,7 +23,7 @@ require('node:url');
|
|
|
23
23
|
require('node:events');
|
|
24
24
|
require('node:stream');
|
|
25
25
|
require('node:string_decoder');
|
|
26
|
-
require("./macros-
|
|
26
|
+
require("./macros-621210f1.cjs");
|
|
27
27
|
require('node:readline');
|
|
28
28
|
require('node:process');
|
|
29
29
|
require('node:os');
|
package/dist/schemas.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var macros = require("./macros-
|
|
5
|
+
var macros = require("./macros-621210f1.cjs");
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -30,6 +30,7 @@ exports.ForwardSchema = macros.ForwardSchema;
|
|
|
30
30
|
exports.InstructionObjectSchema = macros.InstructionObjectSchema;
|
|
31
31
|
exports.InstructionSchema = macros.InstructionSchema;
|
|
32
32
|
exports.IntentWorkflowEventSchema = macros.IntentWorkflowEventSchema;
|
|
33
|
+
exports.MessageEntitySchema = macros.MessageEntitySchema;
|
|
33
34
|
exports.MessageSchema = macros.MessageSchema;
|
|
34
35
|
exports.PersonaConfigurationSchema = macros.PersonaConfigurationSchema;
|
|
35
36
|
exports.PersonaSchema = macros.PersonaSchema;
|
|
@@ -637,6 +637,7 @@ var _excluded = ["keywords"];
|
|
|
637
637
|
* @property {Array<import('@scout9/app').Message>} messages
|
|
638
638
|
* @property {import('@scout9/app').Message} message - the message sent by the customer (should exist in messages)
|
|
639
639
|
* @property {import('@scout9/app').Customer} customer
|
|
640
|
+
* @property {import('@scout9/app').ConversationProgress} progress - progress checklist for manual/auto ingress workflows (needed if conversation progress is not managed by external webhooks or @scout9 apps (ingress app/webhook)
|
|
640
641
|
* @property {any} context
|
|
641
642
|
*/
|
|
642
643
|
|
|
@@ -664,6 +665,14 @@ var _excluded = ["keywords"];
|
|
|
664
665
|
* @property {any} context
|
|
665
666
|
*/
|
|
666
667
|
|
|
668
|
+
/**
|
|
669
|
+
* @typedef {Object} GenerateOutput
|
|
670
|
+
* @property {import('@scout9/admin').GenerateResponse | undefined} generate
|
|
671
|
+
* @property {Array<import('@scout9/app').Message>} messages
|
|
672
|
+
* @property {import('@scout9/app').Conversation} conversation
|
|
673
|
+
* @property {any} context
|
|
674
|
+
*/
|
|
675
|
+
|
|
667
676
|
/**
|
|
668
677
|
* @callback ParseFun
|
|
669
678
|
* @param {string} message - message to send
|
|
@@ -694,6 +703,7 @@ var _excluded = ["keywords"];
|
|
|
694
703
|
* @param {import('@scout9/app').Message['role']} prefix
|
|
695
704
|
* @returns {string}
|
|
696
705
|
*/
|
|
706
|
+
|
|
697
707
|
/**
|
|
698
708
|
* @callback StatusCallback
|
|
699
709
|
* @param {string} message
|
|
@@ -888,6 +898,7 @@ var Spirits = {
|
|
|
888
898
|
message.intentScore = parsePayload.intentScore;
|
|
889
899
|
}
|
|
890
900
|
message.context = parsePayload.context;
|
|
901
|
+
message.entities = parsePayload.entities;
|
|
891
902
|
index = messages.findIndex(function (m) {
|
|
892
903
|
return m.content === message.content || m.id === message.id;
|
|
893
904
|
});
|
|
@@ -897,6 +908,7 @@ var Spirits = {
|
|
|
897
908
|
role: 'customer',
|
|
898
909
|
content: message,
|
|
899
910
|
context: parsePayload.context,
|
|
911
|
+
entities: parsePayload.entities,
|
|
900
912
|
time: new Date().toISOString()
|
|
901
913
|
};
|
|
902
914
|
if (parsePayload.intent) {
|
|
@@ -910,6 +922,7 @@ var Spirits = {
|
|
|
910
922
|
progress('Added message', 'info', 'ADD_MESSAGE', _message);
|
|
911
923
|
} else {
|
|
912
924
|
messages[index].context = parsePayload.context;
|
|
925
|
+
messages[index].entities = parsePayload.entities;
|
|
913
926
|
if (parsePayload.intent) {
|
|
914
927
|
messages[index].intent = parsePayload.intent;
|
|
915
928
|
}
|
|
@@ -947,7 +960,7 @@ var Spirits = {
|
|
|
947
960
|
}
|
|
948
961
|
noNewContext = Object.keys(parsePayload.context).length === 0; // 3. Run the workflow
|
|
949
962
|
progress('Running workflow', 'info', 'SET_PROCESSING', 'system');
|
|
950
|
-
_context2.next =
|
|
963
|
+
_context2.next = 44;
|
|
951
964
|
return workflow({
|
|
952
965
|
messages: messages,
|
|
953
966
|
conversation: conversation,
|
|
@@ -976,7 +989,7 @@ var Spirits = {
|
|
|
976
989
|
return accumulator;
|
|
977
990
|
}, []);
|
|
978
991
|
});
|
|
979
|
-
case
|
|
992
|
+
case 44:
|
|
980
993
|
slots = _context2.sent;
|
|
981
994
|
hasNoInstructions = slots.every(function (s) {
|
|
982
995
|
return !s.instructions || Array.isArray(s.instructions) && s.instructions.length === 0;
|
|
@@ -1002,20 +1015,20 @@ var Spirits = {
|
|
|
1002
1015
|
}
|
|
1003
1016
|
resettedIntent = false;
|
|
1004
1017
|
_iterator = _createForOfIteratorHelper(slots);
|
|
1005
|
-
_context2.prev =
|
|
1018
|
+
_context2.prev = 52;
|
|
1006
1019
|
_iterator.s();
|
|
1007
|
-
case
|
|
1020
|
+
case 54:
|
|
1008
1021
|
if ((_step = _iterator.n()).done) {
|
|
1009
|
-
_context2.next =
|
|
1022
|
+
_context2.next = 114;
|
|
1010
1023
|
break;
|
|
1011
1024
|
}
|
|
1012
1025
|
_step$value = _step.value, forward = _step$value.forward, forwardNote = _step$value.forwardNote, instructions = _step$value.instructions, removeInstructions = _step$value.removeInstructions, manualMessage = _step$value.message, scheduled = _step$value.scheduled, resetIntent = _step$value.resetIntent, secondsDelay = _step$value.secondsDelay, contextUpsert = _step$value.contextUpsert, anticipate = _step$value.anticipate, slotFollowup = _step$value.followup;
|
|
1013
1026
|
if (!anticipate) {
|
|
1014
|
-
_context2.next =
|
|
1027
|
+
_context2.next = 69;
|
|
1015
1028
|
break;
|
|
1016
1029
|
}
|
|
1017
1030
|
if (!Array.isArray(anticipate)) {
|
|
1018
|
-
_context2.next =
|
|
1031
|
+
_context2.next = 64;
|
|
1019
1032
|
break;
|
|
1020
1033
|
}
|
|
1021
1034
|
// 'literal' anticipation
|
|
@@ -1035,11 +1048,11 @@ var Spirits = {
|
|
|
1035
1048
|
slots: _slots,
|
|
1036
1049
|
map: map
|
|
1037
1050
|
});
|
|
1038
|
-
_context2.next =
|
|
1051
|
+
_context2.next = 69;
|
|
1039
1052
|
break;
|
|
1040
|
-
case
|
|
1053
|
+
case 64:
|
|
1041
1054
|
if (!('yes' in anticipate && 'no' in anticipate && 'did' in anticipate)) {
|
|
1042
|
-
_context2.next =
|
|
1055
|
+
_context2.next = 68;
|
|
1043
1056
|
break;
|
|
1044
1057
|
}
|
|
1045
1058
|
// "did" anticipation
|
|
@@ -1051,11 +1064,11 @@ var Spirits = {
|
|
|
1051
1064
|
},
|
|
1052
1065
|
did: anticipate.did
|
|
1053
1066
|
});
|
|
1054
|
-
_context2.next =
|
|
1067
|
+
_context2.next = 69;
|
|
1055
1068
|
break;
|
|
1056
|
-
case 67:
|
|
1057
|
-
throw new Error("Invalid anticipate payload \"".concat(JSON.stringify(anticipate), "\""));
|
|
1058
1069
|
case 68:
|
|
1070
|
+
throw new Error("Invalid anticipate payload \"".concat(JSON.stringify(anticipate), "\""));
|
|
1071
|
+
case 69:
|
|
1059
1072
|
if (slotFollowup) {
|
|
1060
1073
|
followup.push(slotFollowup);
|
|
1061
1074
|
}
|
|
@@ -1103,19 +1116,19 @@ var Spirits = {
|
|
|
1103
1116
|
|
|
1104
1117
|
// Insert instructions context
|
|
1105
1118
|
if (!instructions) {
|
|
1106
|
-
_context2.next =
|
|
1119
|
+
_context2.next = 86;
|
|
1107
1120
|
break;
|
|
1108
1121
|
}
|
|
1109
1122
|
if (!(typeof instructions === 'string')) {
|
|
1110
|
-
_context2.next =
|
|
1123
|
+
_context2.next = 76;
|
|
1111
1124
|
break;
|
|
1112
1125
|
}
|
|
1113
1126
|
addInstruction(instructions, previousLockAttempt);
|
|
1114
|
-
_context2.next =
|
|
1127
|
+
_context2.next = 86;
|
|
1115
1128
|
break;
|
|
1116
|
-
case
|
|
1129
|
+
case 76:
|
|
1117
1130
|
if (!Array.isArray(instructions)) {
|
|
1118
|
-
_context2.next =
|
|
1131
|
+
_context2.next = 81;
|
|
1119
1132
|
break;
|
|
1120
1133
|
}
|
|
1121
1134
|
_iterator3 = _createForOfIteratorHelper(instructions);
|
|
@@ -1133,25 +1146,25 @@ var Spirits = {
|
|
|
1133
1146
|
} finally {
|
|
1134
1147
|
_iterator3.f();
|
|
1135
1148
|
}
|
|
1136
|
-
_context2.next =
|
|
1149
|
+
_context2.next = 86;
|
|
1137
1150
|
break;
|
|
1138
|
-
case
|
|
1151
|
+
case 81:
|
|
1139
1152
|
if (!(_typeof(instructions) === 'object' && 'content' in instructions)) {
|
|
1140
|
-
_context2.next =
|
|
1153
|
+
_context2.next = 85;
|
|
1141
1154
|
break;
|
|
1142
1155
|
}
|
|
1143
1156
|
addInstruction(instructions.content, previousLockAttempt, instructions.id);
|
|
1144
|
-
_context2.next =
|
|
1157
|
+
_context2.next = 86;
|
|
1145
1158
|
break;
|
|
1146
|
-
case 84:
|
|
1147
|
-
throw new Error("SpiritsError: instructions must be a string or array or {content: \"<instruction>\"}, got: ".concat(JSON.stringify(instructions)));
|
|
1148
1159
|
case 85:
|
|
1160
|
+
throw new Error("SpiritsError: instructions must be a string or array or {content: \"<instruction>\"}, got: ".concat(JSON.stringify(instructions)));
|
|
1161
|
+
case 86:
|
|
1149
1162
|
if (!removeInstructions) {
|
|
1150
|
-
_context2.next =
|
|
1163
|
+
_context2.next = 103;
|
|
1151
1164
|
break;
|
|
1152
1165
|
}
|
|
1153
1166
|
_iterator4 = _createForOfIteratorHelper(removeInstructions);
|
|
1154
|
-
_context2.prev =
|
|
1167
|
+
_context2.prev = 88;
|
|
1155
1168
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1156
1169
|
var instructionId, index;
|
|
1157
1170
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
@@ -1176,29 +1189,29 @@ var Spirits = {
|
|
|
1176
1189
|
}, _loop);
|
|
1177
1190
|
});
|
|
1178
1191
|
_iterator4.s();
|
|
1179
|
-
case
|
|
1192
|
+
case 91:
|
|
1180
1193
|
if ((_step4 = _iterator4.n()).done) {
|
|
1181
|
-
_context2.next =
|
|
1194
|
+
_context2.next = 95;
|
|
1182
1195
|
break;
|
|
1183
1196
|
}
|
|
1184
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
1185
|
-
case
|
|
1186
|
-
_context2.next =
|
|
1197
|
+
return _context2.delegateYield(_loop(), "t0", 93);
|
|
1198
|
+
case 93:
|
|
1199
|
+
_context2.next = 91;
|
|
1187
1200
|
break;
|
|
1188
|
-
case
|
|
1189
|
-
_context2.next =
|
|
1201
|
+
case 95:
|
|
1202
|
+
_context2.next = 100;
|
|
1190
1203
|
break;
|
|
1191
|
-
case
|
|
1192
|
-
_context2.prev =
|
|
1193
|
-
_context2.t1 = _context2["catch"](
|
|
1204
|
+
case 97:
|
|
1205
|
+
_context2.prev = 97;
|
|
1206
|
+
_context2.t1 = _context2["catch"](88);
|
|
1194
1207
|
_iterator4.e(_context2.t1);
|
|
1195
|
-
case
|
|
1196
|
-
_context2.prev =
|
|
1208
|
+
case 100:
|
|
1209
|
+
_context2.prev = 100;
|
|
1197
1210
|
_iterator4.f();
|
|
1198
|
-
return _context2.finish(
|
|
1199
|
-
case
|
|
1211
|
+
return _context2.finish(100);
|
|
1212
|
+
case 103:
|
|
1200
1213
|
if (!manualMessage) {
|
|
1201
|
-
_context2.next =
|
|
1214
|
+
_context2.next = 110;
|
|
1202
1215
|
break;
|
|
1203
1216
|
}
|
|
1204
1217
|
manualMessageObj = {
|
|
@@ -1208,11 +1221,11 @@ var Spirits = {
|
|
|
1208
1221
|
time: new Date().toISOString()
|
|
1209
1222
|
};
|
|
1210
1223
|
if (!(typeof manualMessage !== 'string')) {
|
|
1211
|
-
_context2.next =
|
|
1224
|
+
_context2.next = 107;
|
|
1212
1225
|
break;
|
|
1213
1226
|
}
|
|
1214
1227
|
throw new Error('Manual message must be of type "string"');
|
|
1215
|
-
case
|
|
1228
|
+
case 107:
|
|
1216
1229
|
if (scheduled) {
|
|
1217
1230
|
manualMessageObj.time = new Date(scheduled * 1000).toISOString();
|
|
1218
1231
|
manualMessageObj.scheduled = manualMessageObj.time;
|
|
@@ -1224,7 +1237,7 @@ var Spirits = {
|
|
|
1224
1237
|
}
|
|
1225
1238
|
messages.push(manualMessageObj);
|
|
1226
1239
|
progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1227
|
-
case
|
|
1240
|
+
case 110:
|
|
1228
1241
|
if (contextUpsert) {
|
|
1229
1242
|
context = updateContext(context, contextUpsert);
|
|
1230
1243
|
progress('Upserted context', 'info', 'UPDATE_CONTEXT', contextUpsert);
|
|
@@ -1232,21 +1245,21 @@ var Spirits = {
|
|
|
1232
1245
|
if (resetIntent) {
|
|
1233
1246
|
resettedIntent = true;
|
|
1234
1247
|
}
|
|
1235
|
-
case
|
|
1236
|
-
_context2.next =
|
|
1248
|
+
case 112:
|
|
1249
|
+
_context2.next = 54;
|
|
1237
1250
|
break;
|
|
1238
|
-
case
|
|
1239
|
-
_context2.next =
|
|
1251
|
+
case 114:
|
|
1252
|
+
_context2.next = 119;
|
|
1240
1253
|
break;
|
|
1241
|
-
case
|
|
1242
|
-
_context2.prev =
|
|
1243
|
-
_context2.t2 = _context2["catch"](
|
|
1254
|
+
case 116:
|
|
1255
|
+
_context2.prev = 116;
|
|
1256
|
+
_context2.t2 = _context2["catch"](52);
|
|
1244
1257
|
_iterator.e(_context2.t2);
|
|
1245
|
-
case
|
|
1246
|
-
_context2.prev =
|
|
1258
|
+
case 119:
|
|
1259
|
+
_context2.prev = 119;
|
|
1247
1260
|
_iterator.f();
|
|
1248
|
-
return _context2.finish(
|
|
1249
|
-
case
|
|
1261
|
+
return _context2.finish(119);
|
|
1262
|
+
case 122:
|
|
1250
1263
|
if (resettedIntent && !_forward) {
|
|
1251
1264
|
conversation.intent = null;
|
|
1252
1265
|
conversation.intentScore = null;
|
|
@@ -1265,16 +1278,16 @@ var Spirits = {
|
|
|
1265
1278
|
// 4. Generate response
|
|
1266
1279
|
// If conversation previously locked, don't generate
|
|
1267
1280
|
if (input.conversation.locked) {
|
|
1268
|
-
_context2.next =
|
|
1281
|
+
_context2.next = 170;
|
|
1269
1282
|
break;
|
|
1270
1283
|
}
|
|
1271
1284
|
if (!((!conversation.locked || !hasNoInstructions) && !!hasNoCustomMessage)) {
|
|
1272
|
-
_context2.next =
|
|
1285
|
+
_context2.next = 137;
|
|
1273
1286
|
break;
|
|
1274
1287
|
}
|
|
1275
|
-
_context2.prev =
|
|
1288
|
+
_context2.prev = 125;
|
|
1276
1289
|
progress('Parsing message', 'info', 'SET_PROCESSING', 'system');
|
|
1277
|
-
_context2.next =
|
|
1290
|
+
_context2.next = 129;
|
|
1278
1291
|
return generator({
|
|
1279
1292
|
messages: messages,
|
|
1280
1293
|
persona: persona,
|
|
@@ -1282,7 +1295,7 @@ var Spirits = {
|
|
|
1282
1295
|
llm: config.llm,
|
|
1283
1296
|
pmt: config.pmt
|
|
1284
1297
|
});
|
|
1285
|
-
case
|
|
1298
|
+
case 129:
|
|
1286
1299
|
generatorPayload = _context2.sent;
|
|
1287
1300
|
if (!generatorPayload.send) {
|
|
1288
1301
|
progress('Generated response', 'failed', undefined, {
|
|
@@ -1319,29 +1332,29 @@ var Spirits = {
|
|
|
1319
1332
|
}
|
|
1320
1333
|
}
|
|
1321
1334
|
}
|
|
1322
|
-
_context2.next =
|
|
1335
|
+
_context2.next = 137;
|
|
1323
1336
|
break;
|
|
1324
|
-
case
|
|
1325
|
-
_context2.prev =
|
|
1326
|
-
_context2.t3 = _context2["catch"](
|
|
1337
|
+
case 133:
|
|
1338
|
+
_context2.prev = 133;
|
|
1339
|
+
_context2.t3 = _context2["catch"](125);
|
|
1327
1340
|
console.error("Locking conversation, error generating response: ".concat(_context2.t3.message));
|
|
1328
1341
|
conversation = lockConversation(conversation, 'API: ' + _context2.t3.message);
|
|
1329
|
-
case
|
|
1342
|
+
case 137:
|
|
1330
1343
|
if (!(messagesToTransform.length && transformer)) {
|
|
1331
|
-
_context2.next =
|
|
1344
|
+
_context2.next = 169;
|
|
1332
1345
|
break;
|
|
1333
1346
|
}
|
|
1334
|
-
_context2.prev =
|
|
1347
|
+
_context2.prev = 138;
|
|
1335
1348
|
_iterator2 = _createForOfIteratorHelper(messagesToTransform);
|
|
1336
|
-
_context2.prev =
|
|
1349
|
+
_context2.prev = 140;
|
|
1337
1350
|
_iterator2.s();
|
|
1338
|
-
case
|
|
1351
|
+
case 142:
|
|
1339
1352
|
if ((_step2 = _iterator2.n()).done) {
|
|
1340
|
-
_context2.next =
|
|
1353
|
+
_context2.next = 153;
|
|
1341
1354
|
break;
|
|
1342
1355
|
}
|
|
1343
1356
|
_step2.value;
|
|
1344
|
-
_context2.next =
|
|
1357
|
+
_context2.next = 146;
|
|
1345
1358
|
return transformer({
|
|
1346
1359
|
message: messagesToTransform,
|
|
1347
1360
|
persona: persona,
|
|
@@ -1349,7 +1362,7 @@ var Spirits = {
|
|
|
1349
1362
|
messages: messages,
|
|
1350
1363
|
context: context
|
|
1351
1364
|
});
|
|
1352
|
-
case
|
|
1365
|
+
case 146:
|
|
1353
1366
|
transformResponse = _context2.sent;
|
|
1354
1367
|
progress('Generated response', 'success', undefined, undefined);
|
|
1355
1368
|
// Check if already had message
|
|
@@ -1369,36 +1382,36 @@ var Spirits = {
|
|
|
1369
1382
|
});
|
|
1370
1383
|
progress('Added agent message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1371
1384
|
}
|
|
1372
|
-
case
|
|
1373
|
-
_context2.next =
|
|
1385
|
+
case 151:
|
|
1386
|
+
_context2.next = 142;
|
|
1374
1387
|
break;
|
|
1375
|
-
case
|
|
1376
|
-
_context2.next =
|
|
1388
|
+
case 153:
|
|
1389
|
+
_context2.next = 158;
|
|
1377
1390
|
break;
|
|
1378
|
-
case
|
|
1379
|
-
_context2.prev =
|
|
1380
|
-
_context2.t4 = _context2["catch"](
|
|
1391
|
+
case 155:
|
|
1392
|
+
_context2.prev = 155;
|
|
1393
|
+
_context2.t4 = _context2["catch"](140);
|
|
1381
1394
|
_iterator2.e(_context2.t4);
|
|
1382
|
-
case
|
|
1383
|
-
_context2.prev =
|
|
1395
|
+
case 158:
|
|
1396
|
+
_context2.prev = 158;
|
|
1384
1397
|
_iterator2.f();
|
|
1385
|
-
return _context2.finish(
|
|
1386
|
-
case
|
|
1387
|
-
_context2.next =
|
|
1398
|
+
return _context2.finish(158);
|
|
1399
|
+
case 161:
|
|
1400
|
+
_context2.next = 167;
|
|
1388
1401
|
break;
|
|
1389
|
-
case
|
|
1390
|
-
_context2.prev =
|
|
1391
|
-
_context2.t5 = _context2["catch"](
|
|
1402
|
+
case 163:
|
|
1403
|
+
_context2.prev = 163;
|
|
1404
|
+
_context2.t5 = _context2["catch"](138);
|
|
1392
1405
|
console.error("Locking conversation, error transforming response: ".concat(_context2.t5.message));
|
|
1393
1406
|
conversation = lockConversation(conversation, 'API: ' + _context2.t5.message);
|
|
1394
|
-
case
|
|
1395
|
-
_context2.next =
|
|
1407
|
+
case 167:
|
|
1408
|
+
_context2.next = 170;
|
|
1396
1409
|
break;
|
|
1397
|
-
case
|
|
1410
|
+
case 169:
|
|
1398
1411
|
if (messagesToTransform.length) {
|
|
1399
1412
|
console.warn("No transformer provided");
|
|
1400
1413
|
}
|
|
1401
|
-
case
|
|
1414
|
+
case 170:
|
|
1402
1415
|
progress('Parsing message', 'info', 'SET_PROCESSING', null);
|
|
1403
1416
|
return _context2.abrupt("return", {
|
|
1404
1417
|
conversation: {
|
|
@@ -1421,11 +1434,11 @@ var Spirits = {
|
|
|
1421
1434
|
},
|
|
1422
1435
|
followup: followup
|
|
1423
1436
|
});
|
|
1424
|
-
case
|
|
1437
|
+
case 172:
|
|
1425
1438
|
case "end":
|
|
1426
1439
|
return _context2.stop();
|
|
1427
1440
|
}
|
|
1428
|
-
}, _callee, null, [[
|
|
1441
|
+
}, _callee, null, [[52, 116, 119, 122], [88, 97, 100, 103], [125, 133], [138, 163], [140, 155, 158, 161]]);
|
|
1429
1442
|
}));
|
|
1430
1443
|
function customer(_x) {
|
|
1431
1444
|
return _customer.apply(this, arguments);
|
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-32a9a0c8.cjs");
|
|
6
|
+
require("./spirits-8819b1c9.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('path');
|
|
@@ -24,7 +24,7 @@ require('node:url');
|
|
|
24
24
|
require('node:events');
|
|
25
25
|
require('node:stream');
|
|
26
26
|
require('node:string_decoder');
|
|
27
|
-
require("./macros-
|
|
27
|
+
require("./macros-621210f1.cjs");
|
|
28
28
|
require('node:readline');
|
|
29
29
|
require('node:process');
|
|
30
30
|
require('node:os');
|