@scout9/app 1.0.0-alpha.0.1.90 → 1.0.0-alpha.0.1.92
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 +1 -0
- package/dist/{exports-e7d51b70.cjs → exports-dfabefaf.cjs} +37 -19
- package/dist/index.cjs +2 -2
- package/dist/{multipart-parser-e09a67c9.cjs → multipart-parser-52e1536f.cjs} +2 -2
- package/dist/{spirits-3b603262.cjs → spirits-6a709255.cjs} +102 -85
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +2 -2
- package/package.json +10 -3
- package/src/runtime/client/workflow.js +12 -11
- package/src/testing-tools/spirits.js +446 -406
- package/src/utils/file.js +7 -1
- package/types/index.d.ts +7 -7
- package/types/index.d.ts.map +3 -3
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Scout9's Persona Model Transforming (PMT) technology auto crafts messages in you
|
|
|
23
23
|
* `scout9 sync` (coming soon)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
#### Thanks to our early backers using Scout9 to improve their customer experience
|
|
27
28
|
* [REI](https://rei.com): Supply chain procurement SMS auto replies
|
|
28
29
|
* [Microsoft](https://microsoft.com): Azure customer account support SMS auto replies
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
3
|
+
var spirits = require("./spirits-6a709255.cjs");
|
|
4
4
|
var readline = require('node:readline');
|
|
5
5
|
var require$$0$2 = require('fs');
|
|
6
6
|
var require$$2$1 = require('events');
|
|
@@ -41174,7 +41174,7 @@ class Body {
|
|
|
41174
41174
|
}
|
|
41175
41175
|
const {
|
|
41176
41176
|
toFormData
|
|
41177
|
-
} = await Promise.resolve().then(function () { return require("./multipart-parser-
|
|
41177
|
+
} = await Promise.resolve().then(function () { return require("./multipart-parser-52e1536f.cjs"); });
|
|
41178
41178
|
return toFormData(this.body, ct);
|
|
41179
41179
|
}
|
|
41180
41180
|
|
|
@@ -78902,7 +78902,7 @@ function fetchFileToBuffer(_x) {
|
|
|
78902
78902
|
*/
|
|
78903
78903
|
function _fetchFileToBuffer() {
|
|
78904
78904
|
_fetchFileToBuffer = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee(url) {
|
|
78905
|
-
var response;
|
|
78905
|
+
var response, buffer;
|
|
78906
78906
|
return spirits._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
78907
78907
|
while (1) switch (_context.prev = _context.next) {
|
|
78908
78908
|
case 0:
|
|
@@ -78922,12 +78922,30 @@ function _fetchFileToBuffer() {
|
|
|
78922
78922
|
}
|
|
78923
78923
|
throw new Error("Failed to fetch file \"".concat(url, "\": ").concat(response.statusText));
|
|
78924
78924
|
case 7:
|
|
78925
|
+
if (!('buffer' in response)) {
|
|
78926
|
+
_context.next = 13;
|
|
78927
|
+
break;
|
|
78928
|
+
}
|
|
78929
|
+
_context.next = 10;
|
|
78930
|
+
return response.buffer();
|
|
78931
|
+
case 10:
|
|
78932
|
+
buffer = _context.sent;
|
|
78933
|
+
_context.next = 16;
|
|
78934
|
+
break;
|
|
78935
|
+
case 13:
|
|
78936
|
+
_context.next = 15;
|
|
78937
|
+
return response.arrayBuffer().then(function (a) {
|
|
78938
|
+
return Buffer.from(a);
|
|
78939
|
+
});
|
|
78940
|
+
case 15:
|
|
78941
|
+
buffer = _context.sent;
|
|
78942
|
+
case 16:
|
|
78925
78943
|
return _context.abrupt("return", {
|
|
78926
|
-
buffer:
|
|
78944
|
+
buffer: buffer,
|
|
78927
78945
|
ext: path$d.extname(url).slice(1),
|
|
78928
78946
|
mime: response.headers.get('content-type')
|
|
78929
78947
|
});
|
|
78930
|
-
case
|
|
78948
|
+
case 17:
|
|
78931
78949
|
case "end":
|
|
78932
78950
|
return _context.stop();
|
|
78933
78951
|
}
|
|
@@ -81232,7 +81250,7 @@ function _loadUserPackageJson$1() {
|
|
|
81232
81250
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
81233
81251
|
_context2.t0 = JSON;
|
|
81234
81252
|
_context2.next = 10;
|
|
81235
|
-
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('exports-
|
|
81253
|
+
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('exports-dfabefaf.js', document.baseURI).href))), 'utf-8');
|
|
81236
81254
|
case 10:
|
|
81237
81255
|
_context2.t1 = _context2.sent;
|
|
81238
81256
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -82077,7 +82095,7 @@ function _loadUserPackageJson() {
|
|
|
82077
82095
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
82078
82096
|
_context.t0 = JSON;
|
|
82079
82097
|
_context.next = 10;
|
|
82080
|
-
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('exports-
|
|
82098
|
+
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('exports-dfabefaf.js', document.baseURI).href))), 'utf-8');
|
|
82081
82099
|
case 10:
|
|
82082
82100
|
_context.t1 = _context.sent;
|
|
82083
82101
|
pkg = _context.t0.parse.call(_context.t0, _context.t1);
|
|
@@ -87096,6 +87114,16 @@ var InstructionSchema = z.object({
|
|
|
87096
87114
|
content: z.string()
|
|
87097
87115
|
});
|
|
87098
87116
|
|
|
87117
|
+
/**
|
|
87118
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiRequest>} IWorkflowResponseMessageApiRequest
|
|
87119
|
+
*/
|
|
87120
|
+
var WorkflowResponseMessageApiRequest = z.object({
|
|
87121
|
+
uri: z.string(),
|
|
87122
|
+
data: z.any().optional(),
|
|
87123
|
+
headers: z.object(spirits._defineProperty({}, z.string(), z.string())).optional(),
|
|
87124
|
+
method: z["enum"](["GET", "POST", "PUT"]).optional()
|
|
87125
|
+
});
|
|
87126
|
+
|
|
87099
87127
|
/**
|
|
87100
87128
|
* If its a string, it will be sent as a static string.
|
|
87101
87129
|
* If it's a object or WorkflowResponseMessageAPI - it will use
|
|
@@ -87107,16 +87135,6 @@ var WorkflowResponseMessage = z.union(z.string(),
|
|
|
87107
87135
|
*/
|
|
87108
87136
|
WorkflowResponseMessageApiRequest);
|
|
87109
87137
|
|
|
87110
|
-
/**
|
|
87111
|
-
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiRequest>} IWorkflowResponseMessageApiRequest
|
|
87112
|
-
*/
|
|
87113
|
-
var WorkflowResponseMessageApiRequest = z.object({
|
|
87114
|
-
uri: z.string(),
|
|
87115
|
-
data: z.any().optional(),
|
|
87116
|
-
headers: z.object(spirits._defineProperty({}, z.string(), z.string())).optional(),
|
|
87117
|
-
method: z["enum"](["GET", "POST", "PUT"]).optional()
|
|
87118
|
-
});
|
|
87119
|
-
|
|
87120
87138
|
/**
|
|
87121
87139
|
* The intended response provided by the WorkflowResponseMessageApiRequest
|
|
87122
87140
|
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiResponse>} IWorkflowResponseMessageApiResponse
|
|
@@ -88516,7 +88534,7 @@ function report(config, logger) {
|
|
|
88516
88534
|
logger.primary("Run ".concat(cyan('scout9 dev'), " to test your project locally"));
|
|
88517
88535
|
}
|
|
88518
88536
|
|
|
88519
|
-
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('exports-
|
|
88537
|
+
var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('exports-dfabefaf.js', document.baseURI).href)));
|
|
88520
88538
|
var __dirname$1 = path__default["default"].dirname(__filename$1);
|
|
88521
88539
|
function zipDirectory(source, out) {
|
|
88522
88540
|
var archive = archiver$1('tar', {
|
|
@@ -88731,7 +88749,7 @@ function _buildApp() {
|
|
|
88731
88749
|
case 11:
|
|
88732
88750
|
_context4.t0 = JSON;
|
|
88733
88751
|
_context4.next = 14;
|
|
88734
|
-
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('exports-
|
|
88752
|
+
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('exports-dfabefaf.js', document.baseURI).href))), 'utf-8');
|
|
88735
88753
|
case 14:
|
|
88736
88754
|
_context4.t1 = _context4.sent;
|
|
88737
88755
|
packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
|
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var exports$1 = require("./exports-
|
|
6
|
-
var spirits = require("./spirits-
|
|
5
|
+
var exports$1 = require("./exports-dfabefaf.cjs");
|
|
6
|
+
var spirits = require("./spirits-6a709255.cjs");
|
|
7
7
|
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var exports$1 = require("./exports-
|
|
6
|
-
require("./spirits-
|
|
5
|
+
var exports$1 = require("./exports-dfabefaf.cjs");
|
|
6
|
+
require("./spirits-6a709255.cjs");
|
|
7
7
|
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
|
@@ -753,38 +753,46 @@ var Spirits = {
|
|
|
753
753
|
_context2.next = 12;
|
|
754
754
|
break;
|
|
755
755
|
}
|
|
756
|
-
throw new Error("No agent found in conversation, must define \".$agent\" in the conversation");
|
|
756
|
+
throw new Error("SpiritsError: No agent found in conversation, must define \".$agent\" in the conversation");
|
|
757
757
|
case 12:
|
|
758
758
|
persona = (config.persona || config.agents).find(function (p) {
|
|
759
759
|
return p.id === conversation.$agent;
|
|
760
760
|
});
|
|
761
761
|
if (persona) {
|
|
762
|
-
_context2.next =
|
|
762
|
+
_context2.next = 17;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
if (!(config.persona || config.agents).some(function (a) {
|
|
766
|
+
return !a.id;
|
|
767
|
+
})) {
|
|
768
|
+
_context2.next = 16;
|
|
763
769
|
break;
|
|
764
770
|
}
|
|
765
|
-
throw new Error("No persona found (\"".concat(conversation.$agent, "\") in provided config"));
|
|
766
|
-
case
|
|
771
|
+
throw new Error("SpiritsError: No persona found (\"".concat(conversation.$agent, "\") in provided config, some persona's did not contain an \"id\" (Internal Mapping Error)"));
|
|
772
|
+
case 16:
|
|
773
|
+
throw new Error("SpiritsError: No persona found (\"".concat(conversation.$agent, "\") in provided config"));
|
|
774
|
+
case 17:
|
|
767
775
|
if (messages.every(function (m) {
|
|
768
776
|
return !!m.id;
|
|
769
777
|
})) {
|
|
770
|
-
_context2.next =
|
|
778
|
+
_context2.next = 19;
|
|
771
779
|
break;
|
|
772
780
|
}
|
|
773
|
-
throw new Error("Every message must have an \".id\", ensure all messages have an id assigned before running");
|
|
774
|
-
case
|
|
781
|
+
throw new Error("SpiritsError: Every message must have an \".id\", ensure all messages have an id assigned before running");
|
|
782
|
+
case 19:
|
|
775
783
|
if (messages.every(function (m) {
|
|
776
784
|
return m.role === 'customer' || m.role === 'agent' || m.role === 'system';
|
|
777
785
|
})) {
|
|
778
|
-
_context2.next =
|
|
786
|
+
_context2.next = 22;
|
|
779
787
|
break;
|
|
780
788
|
}
|
|
781
789
|
invalidRoles = messages.filter(function (m) {
|
|
782
790
|
return m.role !== 'customer' && m.role !== 'agent' && m.role !== 'system';
|
|
783
791
|
});
|
|
784
|
-
throw new Error("Every message must have a role of \"customer\", \"agent\", or \"system\". Got invalid roles: ".concat(invalidRoles.map(function (m) {
|
|
792
|
+
throw new Error("SpiritsError: Every message must have a role of \"customer\", \"agent\", or \"system\". Got invalid roles: ".concat(invalidRoles.map(function (m) {
|
|
785
793
|
return m.role;
|
|
786
794
|
}).join(', ')));
|
|
787
|
-
case
|
|
795
|
+
case 22:
|
|
788
796
|
// if message is not in messages, then add it
|
|
789
797
|
if (!messages.find(function (m) {
|
|
790
798
|
return m.id === input.message.id;
|
|
@@ -794,9 +802,9 @@ var Spirits = {
|
|
|
794
802
|
|
|
795
803
|
// 2. Parse the message
|
|
796
804
|
progress('Parsing message', 'info', 'SET_PROCESSING', 'user');
|
|
797
|
-
_context2.next =
|
|
805
|
+
_context2.next = 26;
|
|
798
806
|
return parser(message.content, 'en');
|
|
799
|
-
case
|
|
807
|
+
case 26:
|
|
800
808
|
parsePayload = _context2.sent;
|
|
801
809
|
if (parsePayload.intent) {
|
|
802
810
|
message.intent = parsePayload.intent;
|
|
@@ -864,7 +872,7 @@ var Spirits = {
|
|
|
864
872
|
}
|
|
865
873
|
noNewContext = Object.keys(parsePayload.context).length === 0; // 3. Run the workflow
|
|
866
874
|
progress('Running workflow', 'info', 'SET_PROCESSING', 'system');
|
|
867
|
-
_context2.next =
|
|
875
|
+
_context2.next = 42;
|
|
868
876
|
return workflow({
|
|
869
877
|
messages: messages,
|
|
870
878
|
conversation: conversation,
|
|
@@ -883,7 +891,7 @@ var Spirits = {
|
|
|
883
891
|
}).then(function (res) {
|
|
884
892
|
return Array.isArray(res) ? res : [res];
|
|
885
893
|
});
|
|
886
|
-
case
|
|
894
|
+
case 42:
|
|
887
895
|
slots = _context2.sent;
|
|
888
896
|
hasNoInstructions = slots.every(function (s) {
|
|
889
897
|
return !s.instructions || Array.isArray(s) && s.instructions.length === 0;
|
|
@@ -906,11 +914,11 @@ var Spirits = {
|
|
|
906
914
|
}
|
|
907
915
|
resettedIntent = false;
|
|
908
916
|
_iterator = _createForOfIteratorHelper(slots);
|
|
909
|
-
_context2.prev =
|
|
917
|
+
_context2.prev = 49;
|
|
910
918
|
_iterator.s();
|
|
911
|
-
case
|
|
919
|
+
case 51:
|
|
912
920
|
if ((_step = _iterator.n()).done) {
|
|
913
|
-
_context2.next =
|
|
921
|
+
_context2.next = 97;
|
|
914
922
|
break;
|
|
915
923
|
}
|
|
916
924
|
_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;
|
|
@@ -957,19 +965,19 @@ var Spirits = {
|
|
|
957
965
|
|
|
958
966
|
// Insert instructions context
|
|
959
967
|
if (!instructions) {
|
|
960
|
-
_context2.next =
|
|
968
|
+
_context2.next = 69;
|
|
961
969
|
break;
|
|
962
970
|
}
|
|
963
971
|
if (!(typeof instructions === 'string')) {
|
|
964
|
-
_context2.next =
|
|
972
|
+
_context2.next = 59;
|
|
965
973
|
break;
|
|
966
974
|
}
|
|
967
975
|
addInstruction(instructions, previousLockAttempt);
|
|
968
|
-
_context2.next =
|
|
976
|
+
_context2.next = 69;
|
|
969
977
|
break;
|
|
970
|
-
case
|
|
978
|
+
case 59:
|
|
971
979
|
if (!Array.isArray(instructions)) {
|
|
972
|
-
_context2.next =
|
|
980
|
+
_context2.next = 64;
|
|
973
981
|
break;
|
|
974
982
|
}
|
|
975
983
|
_iterator2 = _createForOfIteratorHelper(instructions);
|
|
@@ -987,25 +995,25 @@ var Spirits = {
|
|
|
987
995
|
} finally {
|
|
988
996
|
_iterator2.f();
|
|
989
997
|
}
|
|
990
|
-
_context2.next =
|
|
998
|
+
_context2.next = 69;
|
|
991
999
|
break;
|
|
992
|
-
case
|
|
1000
|
+
case 64:
|
|
993
1001
|
if (!(_typeof(instructions) === 'object' && 'content' in instructions && 'id' in instructions)) {
|
|
994
|
-
_context2.next =
|
|
1002
|
+
_context2.next = 68;
|
|
995
1003
|
break;
|
|
996
1004
|
}
|
|
997
1005
|
addInstruction(instructions.content, previousLockAttempt, instructions.id);
|
|
998
|
-
_context2.next =
|
|
1006
|
+
_context2.next = 69;
|
|
999
1007
|
break;
|
|
1000
|
-
case
|
|
1001
|
-
throw new Error('instructions must be a string or array or {content: "", id: ""}');
|
|
1002
|
-
case
|
|
1008
|
+
case 68:
|
|
1009
|
+
throw new Error('SpiritsError: instructions must be a string or array or {content: "", id: ""}');
|
|
1010
|
+
case 69:
|
|
1003
1011
|
if (!removeInstructions) {
|
|
1004
|
-
_context2.next =
|
|
1012
|
+
_context2.next = 86;
|
|
1005
1013
|
break;
|
|
1006
1014
|
}
|
|
1007
1015
|
_iterator3 = _createForOfIteratorHelper(removeInstructions);
|
|
1008
|
-
_context2.prev =
|
|
1016
|
+
_context2.prev = 71;
|
|
1009
1017
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1010
1018
|
var instructionId, index;
|
|
1011
1019
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
@@ -1028,46 +1036,55 @@ var Spirits = {
|
|
|
1028
1036
|
}, _loop);
|
|
1029
1037
|
});
|
|
1030
1038
|
_iterator3.s();
|
|
1031
|
-
case
|
|
1039
|
+
case 74:
|
|
1032
1040
|
if ((_step3 = _iterator3.n()).done) {
|
|
1033
|
-
_context2.next =
|
|
1041
|
+
_context2.next = 78;
|
|
1034
1042
|
break;
|
|
1035
1043
|
}
|
|
1036
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
1037
|
-
case 74:
|
|
1038
|
-
_context2.next = 72;
|
|
1039
|
-
break;
|
|
1044
|
+
return _context2.delegateYield(_loop(), "t0", 76);
|
|
1040
1045
|
case 76:
|
|
1041
|
-
_context2.next =
|
|
1046
|
+
_context2.next = 74;
|
|
1042
1047
|
break;
|
|
1043
1048
|
case 78:
|
|
1044
|
-
_context2.
|
|
1045
|
-
|
|
1049
|
+
_context2.next = 83;
|
|
1050
|
+
break;
|
|
1051
|
+
case 80:
|
|
1052
|
+
_context2.prev = 80;
|
|
1053
|
+
_context2.t1 = _context2["catch"](71);
|
|
1046
1054
|
_iterator3.e(_context2.t1);
|
|
1047
|
-
case
|
|
1048
|
-
_context2.prev =
|
|
1055
|
+
case 83:
|
|
1056
|
+
_context2.prev = 83;
|
|
1049
1057
|
_iterator3.f();
|
|
1050
|
-
return _context2.finish(
|
|
1051
|
-
case
|
|
1052
|
-
if (manualMessage) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
role: 'agent',
|
|
1056
|
-
content: message,
|
|
1057
|
-
time: new Date().toISOString()
|
|
1058
|
-
};
|
|
1059
|
-
if (scheduled) {
|
|
1060
|
-
manualMessageObj.time = new Date(scheduled * 1000).toISOString();
|
|
1061
|
-
manualMessageObj.scheduled = manualMessageObj.time;
|
|
1062
|
-
} else if (secondsDelay) {
|
|
1063
|
-
now = new Date();
|
|
1064
|
-
now.setSeconds(now.getSeconds() + secondsDelay);
|
|
1065
|
-
manualMessageObj.time = now.toISOString();
|
|
1066
|
-
manualMessageObj.delayInSeconds = secondsDelay;
|
|
1067
|
-
}
|
|
1068
|
-
messages.push(manualMessageObj);
|
|
1069
|
-
progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1058
|
+
return _context2.finish(83);
|
|
1059
|
+
case 86:
|
|
1060
|
+
if (!manualMessage) {
|
|
1061
|
+
_context2.next = 93;
|
|
1062
|
+
break;
|
|
1070
1063
|
}
|
|
1064
|
+
manualMessageObj = {
|
|
1065
|
+
id: idGenerator('agent'),
|
|
1066
|
+
role: 'agent',
|
|
1067
|
+
content: manualMessage,
|
|
1068
|
+
time: new Date().toISOString()
|
|
1069
|
+
};
|
|
1070
|
+
if (!(typeof manualMessage !== 'string')) {
|
|
1071
|
+
_context2.next = 90;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
throw new Error('Manual message must be of type "string"');
|
|
1075
|
+
case 90:
|
|
1076
|
+
if (scheduled) {
|
|
1077
|
+
manualMessageObj.time = new Date(scheduled * 1000).toISOString();
|
|
1078
|
+
manualMessageObj.scheduled = manualMessageObj.time;
|
|
1079
|
+
} else if (secondsDelay) {
|
|
1080
|
+
now = new Date();
|
|
1081
|
+
now.setSeconds(now.getSeconds() + secondsDelay);
|
|
1082
|
+
manualMessageObj.time = now.toISOString();
|
|
1083
|
+
manualMessageObj.delayInSeconds = secondsDelay;
|
|
1084
|
+
}
|
|
1085
|
+
messages.push(manualMessageObj);
|
|
1086
|
+
progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1087
|
+
case 93:
|
|
1071
1088
|
if (contextUpsert) {
|
|
1072
1089
|
context = updateContext(context, contextUpsert);
|
|
1073
1090
|
progress('Upserted context', 'info', 'UPDATE_CONTEXT', contextUpsert);
|
|
@@ -1075,21 +1092,21 @@ var Spirits = {
|
|
|
1075
1092
|
if (resetIntent) {
|
|
1076
1093
|
resettedIntent = true;
|
|
1077
1094
|
}
|
|
1078
|
-
case
|
|
1079
|
-
_context2.next =
|
|
1095
|
+
case 95:
|
|
1096
|
+
_context2.next = 51;
|
|
1080
1097
|
break;
|
|
1081
|
-
case
|
|
1082
|
-
_context2.next =
|
|
1098
|
+
case 97:
|
|
1099
|
+
_context2.next = 102;
|
|
1083
1100
|
break;
|
|
1084
|
-
case
|
|
1085
|
-
_context2.prev =
|
|
1086
|
-
_context2.t2 = _context2["catch"](
|
|
1101
|
+
case 99:
|
|
1102
|
+
_context2.prev = 99;
|
|
1103
|
+
_context2.t2 = _context2["catch"](49);
|
|
1087
1104
|
_iterator.e(_context2.t2);
|
|
1088
|
-
case
|
|
1089
|
-
_context2.prev =
|
|
1105
|
+
case 102:
|
|
1106
|
+
_context2.prev = 102;
|
|
1090
1107
|
_iterator.f();
|
|
1091
|
-
return _context2.finish(
|
|
1092
|
-
case
|
|
1108
|
+
return _context2.finish(102);
|
|
1109
|
+
case 105:
|
|
1093
1110
|
if (resettedIntent && !_forward) {
|
|
1094
1111
|
conversation.intent = null;
|
|
1095
1112
|
conversation.intentScore = null;
|
|
@@ -1108,16 +1125,16 @@ var Spirits = {
|
|
|
1108
1125
|
// 4. Generate response
|
|
1109
1126
|
// If conversation previously locked, don't generate
|
|
1110
1127
|
if (input.conversation.locked) {
|
|
1111
|
-
_context2.next =
|
|
1128
|
+
_context2.next = 120;
|
|
1112
1129
|
break;
|
|
1113
1130
|
}
|
|
1114
1131
|
if (!((!conversation.locked || !hasNoInstructions) && !!hasNoCustomMessage)) {
|
|
1115
|
-
_context2.next =
|
|
1132
|
+
_context2.next = 120;
|
|
1116
1133
|
break;
|
|
1117
1134
|
}
|
|
1118
|
-
_context2.prev =
|
|
1135
|
+
_context2.prev = 108;
|
|
1119
1136
|
progress('Parsing message', 'info', 'SET_PROCESSING', 'system');
|
|
1120
|
-
_context2.next =
|
|
1137
|
+
_context2.next = 112;
|
|
1121
1138
|
return generator({
|
|
1122
1139
|
messages: messages,
|
|
1123
1140
|
persona: persona,
|
|
@@ -1125,7 +1142,7 @@ var Spirits = {
|
|
|
1125
1142
|
llm: config.llm,
|
|
1126
1143
|
pmt: config.pmt
|
|
1127
1144
|
});
|
|
1128
|
-
case
|
|
1145
|
+
case 112:
|
|
1129
1146
|
generatorPayload = _context2.sent;
|
|
1130
1147
|
if (!generatorPayload.send) {
|
|
1131
1148
|
progress('Generated response', 'failed', undefined, {
|
|
@@ -1162,14 +1179,14 @@ var Spirits = {
|
|
|
1162
1179
|
}
|
|
1163
1180
|
}
|
|
1164
1181
|
}
|
|
1165
|
-
_context2.next =
|
|
1182
|
+
_context2.next = 120;
|
|
1166
1183
|
break;
|
|
1167
|
-
case
|
|
1168
|
-
_context2.prev =
|
|
1169
|
-
_context2.t3 = _context2["catch"](
|
|
1184
|
+
case 116:
|
|
1185
|
+
_context2.prev = 116;
|
|
1186
|
+
_context2.t3 = _context2["catch"](108);
|
|
1170
1187
|
console.error("Locking conversation, error generating response: ".concat(_context2.t3.message));
|
|
1171
1188
|
conversation = lockConversation(conversation, 'API: ' + _context2.t3.message);
|
|
1172
|
-
case
|
|
1189
|
+
case 120:
|
|
1173
1190
|
progress('Parsing message', 'info', 'SET_PROCESSING', null);
|
|
1174
1191
|
return _context2.abrupt("return", {
|
|
1175
1192
|
conversation: {
|
|
@@ -1191,11 +1208,11 @@ var Spirits = {
|
|
|
1191
1208
|
after: context
|
|
1192
1209
|
}
|
|
1193
1210
|
});
|
|
1194
|
-
case
|
|
1211
|
+
case 122:
|
|
1195
1212
|
case "end":
|
|
1196
1213
|
return _context2.stop();
|
|
1197
1214
|
}
|
|
1198
|
-
}, _callee, null, [[
|
|
1215
|
+
}, _callee, null, [[49, 99, 102, 105], [71, 80, 83, 86], [108, 116]]);
|
|
1199
1216
|
}));
|
|
1200
1217
|
function customer(_x) {
|
|
1201
1218
|
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 exports$1 = require("./exports-
|
|
6
|
-
var spirits = require("./spirits-
|
|
5
|
+
var exports$1 = require("./exports-dfabefaf.cjs");
|
|
6
|
+
var spirits = require("./spirits-6a709255.cjs");
|
|
7
7
|
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scout9/app",
|
|
3
|
-
"version": "1.0.0-alpha.0.1.
|
|
3
|
+
"version": "1.0.0-alpha.0.1.92",
|
|
4
4
|
"description": "Build and deploy your Scout9 app for SMS auto replies",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,13 +10,19 @@
|
|
|
10
10
|
"url": "git://github.com/Scout9Official/scout9-nodejs.git"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
13
|
+
"pretest:generate": "npm run build-no-test",
|
|
14
|
+
"test:generate": "npx rimraf src-test && echo \"Generate a new test project\" && npm create scout9@latest src-test",
|
|
15
|
+
"posttest:generate": "node scripts/test-project-build.js && node scripts/test-project-sync.js",
|
|
16
|
+
"pretest": "node scripts/test-project-build.js",
|
|
17
|
+
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest --detectOpenHandles --forceExit",
|
|
18
|
+
"test:deploy": "node ./src/cli.js deploy",
|
|
14
19
|
"postinstall": "node postinstall.js",
|
|
15
20
|
"prepublishOnly": "npm run build",
|
|
16
21
|
"generate:types": "node scripts/generate-dts.js",
|
|
17
22
|
"prebuild": "rimraf dist/",
|
|
18
23
|
"build": "rollup -c",
|
|
19
|
-
"postbuild": "npm run generate:types && node scripts/post-build.js && npx tsc --noEmit"
|
|
24
|
+
"postbuild": "npm run generate:types && node scripts/post-build.js && npx tsc --noEmit",
|
|
25
|
+
"build-no-test": "npm run prebuild && rollup -c"
|
|
20
26
|
},
|
|
21
27
|
"type": "module",
|
|
22
28
|
"bin": {
|
|
@@ -67,6 +73,7 @@
|
|
|
67
73
|
"babel-jest": "^29.7.0",
|
|
68
74
|
"babel-preset-minify": "^0.5.2",
|
|
69
75
|
"dts-buddy": "^0.4.3",
|
|
76
|
+
"jest": "^29.7.0",
|
|
70
77
|
"rollup": "^2.79.1",
|
|
71
78
|
"rollup-plugin-babel": "^4.4.0",
|
|
72
79
|
"typescript": "^5.3.3"
|
|
@@ -115,6 +115,18 @@ export const InstructionSchema = z.object({
|
|
|
115
115
|
content: z.string(),
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiRequest>} IWorkflowResponseMessageApiRequest
|
|
120
|
+
*/
|
|
121
|
+
export const WorkflowResponseMessageApiRequest = z.object({
|
|
122
|
+
uri: z.string(),
|
|
123
|
+
data: z.any().optional(),
|
|
124
|
+
headers: z.object({
|
|
125
|
+
[z.string()]: z.string(),
|
|
126
|
+
}).optional(),
|
|
127
|
+
method: z.enum(["GET", "POST", "PUT"]).optional()
|
|
128
|
+
});
|
|
129
|
+
|
|
118
130
|
/**
|
|
119
131
|
* If its a string, it will be sent as a static string.
|
|
120
132
|
* If it's a object or WorkflowResponseMessageAPI - it will use
|
|
@@ -129,17 +141,6 @@ export const WorkflowResponseMessage = z.union(
|
|
|
129
141
|
WorkflowResponseMessageApiRequest
|
|
130
142
|
);
|
|
131
143
|
|
|
132
|
-
/**
|
|
133
|
-
* @typedef {import('zod').infer<typeof WorkflowResponseMessageApiRequest>} IWorkflowResponseMessageApiRequest
|
|
134
|
-
*/
|
|
135
|
-
export const WorkflowResponseMessageApiRequest = z.object({
|
|
136
|
-
uri: z.string(),
|
|
137
|
-
data: z.any().optional(),
|
|
138
|
-
headers: z.object({
|
|
139
|
-
[z.string()]: z.string(),
|
|
140
|
-
}).optional(),
|
|
141
|
-
method: z.enum(["GET", "POST", "PUT"]).optional()
|
|
142
|
-
});
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
146
|
* The intended response provided by the WorkflowResponseMessageApiRequest
|