@scout9/app 1.0.0-alpha.0.1.91 → 1.0.0-alpha.0.1.93
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-212ef6be.cjs → exports-83755281.cjs} +511 -23
- package/dist/index.cjs +111 -2
- package/dist/{multipart-parser-54a3ab5f.cjs → multipart-parser-af15f044.cjs} +2 -2
- package/dist/{spirits-3b603262.cjs → spirits-32395ac4.cjs} +125 -86
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +2 -2
- package/package.json +2 -2
- package/src/core/config/agents.js +1 -1
- package/src/exports.js +1 -0
- package/src/runtime/client/utils.js +1 -0
- package/src/runtime/client/workflow.js +82 -24
- package/src/runtime/index.js +1 -0
- package/src/runtime/macros/builder.js +43 -0
- package/src/runtime/macros/event.js +234 -0
- package/src/runtime/macros/globals.js +14 -0
- package/src/runtime/macros/index.js +3 -0
- package/src/runtime/macros/schemas.js +12 -0
- package/src/runtime/macros/utils.js +31 -0
- package/src/testing-tools/spirits.js +447 -407
- package/src/utils/configs/agents.js +1 -1
- package/types/index.d.ts +18426 -332
- package/types/index.d.ts.map +9 -2
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-83755281.cjs");
|
|
6
|
+
var spirits = require("./spirits-32395ac4.cjs");
|
|
7
7
|
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
|
@@ -37,12 +37,115 @@ require('node:util');
|
|
|
37
37
|
require('node:net');
|
|
38
38
|
require('node:vm');
|
|
39
39
|
|
|
40
|
+
var MacroGlobals = /*#__PURE__*/function () {
|
|
41
|
+
function MacroGlobals() {
|
|
42
|
+
spirits._classCallCheck(this, MacroGlobals);
|
|
43
|
+
}
|
|
44
|
+
spirits._createClass(MacroGlobals, null, [{
|
|
45
|
+
key: "$convo",
|
|
46
|
+
value: function $convo() {
|
|
47
|
+
var _globalThis$SCOUT;
|
|
48
|
+
var $convo = globalThis === null || globalThis === void 0 || (_globalThis$SCOUT = globalThis.SCOUT9) === null || _globalThis$SCOUT === void 0 ? void 0 : _globalThis$SCOUT.$convo;
|
|
49
|
+
if (!$convo) {
|
|
50
|
+
throw new Error("$convo not found in runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
51
|
+
}
|
|
52
|
+
return $convo;
|
|
53
|
+
}
|
|
54
|
+
}]);
|
|
55
|
+
return MacroGlobals;
|
|
56
|
+
}();
|
|
57
|
+
var _hint = {
|
|
58
|
+
writable: true,
|
|
59
|
+
value: "make sure the context is properly instantiated before running workflow."
|
|
60
|
+
};
|
|
40
61
|
|
|
62
|
+
function handleAxiosResponse(res) {
|
|
63
|
+
if (res.status === 200) {
|
|
64
|
+
return res.data;
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error("".concat(res.status, " ").concat(res.statusText));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
41
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The `did` macro takes a given prompt and infers a binary `true` or `false` result in relation to the prompt's subject actor and the prompt's inquiry.
|
|
72
|
+
* @param {string} prompt
|
|
73
|
+
* @return {Promise<boolean>}
|
|
74
|
+
*/
|
|
75
|
+
function did(_x) {
|
|
76
|
+
return _did.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The `context` macro, similar to the `did` macro, takes a natural statement and checks the entire conversation state and extracts or infers a metadata composition result.
|
|
81
|
+
* @param {string} prompt
|
|
82
|
+
* @param {import('@scout9/admin').CaptureContextRequestExamples} [examples]
|
|
83
|
+
* @return {Promise<import('@scout9/admin').CaptureContext200Response>}
|
|
84
|
+
*/
|
|
85
|
+
function _did() {
|
|
86
|
+
_did = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee(prompt) {
|
|
87
|
+
var convoId, _yield$Scout9Api$did$, value;
|
|
88
|
+
return spirits._regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
89
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
90
|
+
case 0:
|
|
91
|
+
convoId = MacroGlobals.$convo();
|
|
92
|
+
_context2.next = 3;
|
|
93
|
+
return new exports$1.build.Scout9Api(new exports$1.build.Configuration({
|
|
94
|
+
apiKey: process.env.SCOUT9_API_KEY
|
|
95
|
+
})).did({
|
|
96
|
+
prompt: prompt,
|
|
97
|
+
convoId: convoId
|
|
98
|
+
}).then(handleAxiosResponse);
|
|
99
|
+
case 3:
|
|
100
|
+
_yield$Scout9Api$did$ = _context2.sent;
|
|
101
|
+
value = _yield$Scout9Api$did$.value;
|
|
102
|
+
return _context2.abrupt("return", value);
|
|
103
|
+
case 6:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context2.stop();
|
|
106
|
+
}
|
|
107
|
+
}, _callee);
|
|
108
|
+
}));
|
|
109
|
+
return _did.apply(this, arguments);
|
|
110
|
+
}
|
|
111
|
+
function context(_x2, _x3) {
|
|
112
|
+
return _context.apply(this, arguments);
|
|
113
|
+
}
|
|
114
|
+
function _context() {
|
|
115
|
+
_context = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee2(prompt, examples) {
|
|
116
|
+
var convoId;
|
|
117
|
+
return spirits._regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
118
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
119
|
+
case 0:
|
|
120
|
+
convoId = MacroGlobals.$convo();
|
|
121
|
+
_context3.next = 3;
|
|
122
|
+
return new exports$1.build.Scout9Api(new exports$1.build.Configuration({
|
|
123
|
+
apiKey: process.env.SCOUT9_API_KEY
|
|
124
|
+
})).captureContext({
|
|
125
|
+
prompt: prompt,
|
|
126
|
+
examples: examples,
|
|
127
|
+
convoId: convoId
|
|
128
|
+
}).then(handleAxiosResponse);
|
|
129
|
+
case 3:
|
|
130
|
+
return _context3.abrupt("return", _context3.sent);
|
|
131
|
+
case 4:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context3.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee2);
|
|
136
|
+
}));
|
|
137
|
+
return _context.apply(this, arguments);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.ContextExampleSchema = exports$1.ContextExampleSchema;
|
|
141
|
+
exports.ContextExampleWithTrainingDataSchema = exports$1.ContextExampleWithTrainingDataSchema;
|
|
42
142
|
exports.ConversationContext = exports$1.ConversationContext;
|
|
43
143
|
exports.ConversationSchema = exports$1.ConversationSchema;
|
|
44
144
|
exports.EventResponse = exports$1.EventResponse;
|
|
145
|
+
exports.FollowupBaseSchema = exports$1.FollowupBaseSchema;
|
|
146
|
+
exports.FollowupSchema = exports$1.FollowupSchema;
|
|
45
147
|
exports.ForwardSchema = exports$1.ForwardSchema;
|
|
148
|
+
exports.InstructionObjectSchema = exports$1.InstructionObjectSchema;
|
|
46
149
|
exports.InstructionSchema = exports$1.InstructionSchema;
|
|
47
150
|
exports.IntentWorkflowEventSchema = exports$1.IntentWorkflowEventSchema;
|
|
48
151
|
exports.MessageSchema = exports$1.MessageSchema;
|
|
@@ -56,6 +159,7 @@ exports.WorkflowResponseMessage = exports$1.WorkflowResponseMessage;
|
|
|
56
159
|
exports.WorkflowResponseMessageApiRequest = exports$1.WorkflowResponseMessageApiRequest;
|
|
57
160
|
exports.WorkflowResponseMessageApiResponse = exports$1.WorkflowResponseMessageApiResponse;
|
|
58
161
|
exports.WorkflowResponseSchema = exports$1.WorkflowResponseSchema;
|
|
162
|
+
exports.WorkflowResponseSlotBaseSchema = exports$1.WorkflowResponseSlotBaseSchema;
|
|
59
163
|
exports.WorkflowResponseSlotSchema = exports$1.WorkflowResponseSlotSchema;
|
|
60
164
|
exports.WorkflowsConfigurationSchema = exports$1.WorkflowsConfigurationSchema;
|
|
61
165
|
exports.agentBaseConfigurationSchema = exports$1.agentBaseConfigurationSchema;
|
|
@@ -77,12 +181,17 @@ exports.entityApiConfigurationSchema = exports$1.entityApiConfigurationSchema;
|
|
|
77
181
|
exports.entityConfigurationSchema = exports$1.entityConfigurationSchema;
|
|
78
182
|
exports.entityRootProjectConfigurationSchema = exports$1.entityRootProjectConfigurationSchema;
|
|
79
183
|
exports.eventResponseSchema = exports$1.eventResponseSchema;
|
|
184
|
+
exports.forward = exports$1.forward;
|
|
80
185
|
exports.getApiFunctionSchema = exports$1.getApiFunctionSchema;
|
|
186
|
+
exports.instruct = exports$1.instruct;
|
|
81
187
|
exports.json = exports$1.json;
|
|
82
188
|
exports.patchApiFunctionSchema = exports$1.patchApiFunctionSchema;
|
|
83
189
|
exports.postApiFunctionSchema = exports$1.postApiFunctionSchema;
|
|
84
190
|
exports.putApiFunctionSchema = exports$1.putApiFunctionSchema;
|
|
85
191
|
exports.queryApiFunctionSchema = exports$1.queryApiFunctionSchema;
|
|
192
|
+
exports.reply = exports$1.reply;
|
|
86
193
|
exports.run = exports$1.run;
|
|
87
194
|
exports.sendEvent = exports$1.sendEvent;
|
|
88
195
|
exports.Spirits = spirits.Spirits;
|
|
196
|
+
exports.context = context;
|
|
197
|
+
exports.did = did;
|
|
@@ -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-83755281.cjs");
|
|
6
|
+
require("./spirits-32395ac4.cjs");
|
|
7
7
|
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
|
@@ -550,6 +550,27 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
550
550
|
}
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
|
+
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
|
|
554
|
+
_classCheckPrivateStaticAccess(receiver, classConstructor);
|
|
555
|
+
_classCheckPrivateStaticFieldDescriptor(descriptor, "get");
|
|
556
|
+
return _classApplyDescriptorGet(receiver, descriptor);
|
|
557
|
+
}
|
|
558
|
+
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
559
|
+
if (descriptor.get) {
|
|
560
|
+
return descriptor.get.call(receiver);
|
|
561
|
+
}
|
|
562
|
+
return descriptor.value;
|
|
563
|
+
}
|
|
564
|
+
function _classCheckPrivateStaticAccess(receiver, classConstructor) {
|
|
565
|
+
if (receiver !== classConstructor) {
|
|
566
|
+
throw new TypeError("Private static access of wrong provenance");
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
|
|
570
|
+
if (descriptor === undefined) {
|
|
571
|
+
throw new TypeError("attempted to " + action + " private static field before its declaration");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
553
574
|
|
|
554
575
|
/**
|
|
555
576
|
* @typedef {Object} Document
|
|
@@ -644,7 +665,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
644
665
|
* @typedef {Object} ConversationEvent
|
|
645
666
|
* @property {Change<import('../runtime/client/workflow.js').IConversation> & {forwardNote?: string; forward?: import('../runtime/client/message.js').IWorkflowResponseSlot['forward']}} conversation
|
|
646
667
|
* @property {Change<Array<import('../runtime/client/message.js').IMessage>>} messages
|
|
647
|
-
* @property {Change<
|
|
668
|
+
* @property {Change<any>} context
|
|
648
669
|
* @property {Change<import('../runtime/client/message.js').IMessage>} message
|
|
649
670
|
*/
|
|
650
671
|
var Spirits = {
|
|
@@ -753,38 +774,46 @@ var Spirits = {
|
|
|
753
774
|
_context2.next = 12;
|
|
754
775
|
break;
|
|
755
776
|
}
|
|
756
|
-
throw new Error("No agent found in conversation, must define \".$agent\" in the conversation");
|
|
777
|
+
throw new Error("SpiritsError: No agent found in conversation, must define \".$agent\" in the conversation");
|
|
757
778
|
case 12:
|
|
758
779
|
persona = (config.persona || config.agents).find(function (p) {
|
|
759
780
|
return p.id === conversation.$agent;
|
|
760
781
|
});
|
|
761
782
|
if (persona) {
|
|
762
|
-
_context2.next =
|
|
783
|
+
_context2.next = 17;
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
if (!(config.persona || config.agents).some(function (a) {
|
|
787
|
+
return !a.id;
|
|
788
|
+
})) {
|
|
789
|
+
_context2.next = 16;
|
|
763
790
|
break;
|
|
764
791
|
}
|
|
765
|
-
throw new Error("No persona found (\"".concat(conversation.$agent, "\") in provided config"));
|
|
766
|
-
case
|
|
792
|
+
throw new Error("SpiritsError: No persona found (\"".concat(conversation.$agent, "\") in provided config, some persona's did not contain an \"id\" (Internal Mapping Error)"));
|
|
793
|
+
case 16:
|
|
794
|
+
throw new Error("SpiritsError: No persona found (\"".concat(conversation.$agent, "\") in provided config"));
|
|
795
|
+
case 17:
|
|
767
796
|
if (messages.every(function (m) {
|
|
768
797
|
return !!m.id;
|
|
769
798
|
})) {
|
|
770
|
-
_context2.next =
|
|
799
|
+
_context2.next = 19;
|
|
771
800
|
break;
|
|
772
801
|
}
|
|
773
|
-
throw new Error("Every message must have an \".id\", ensure all messages have an id assigned before running");
|
|
774
|
-
case
|
|
802
|
+
throw new Error("SpiritsError: Every message must have an \".id\", ensure all messages have an id assigned before running");
|
|
803
|
+
case 19:
|
|
775
804
|
if (messages.every(function (m) {
|
|
776
805
|
return m.role === 'customer' || m.role === 'agent' || m.role === 'system';
|
|
777
806
|
})) {
|
|
778
|
-
_context2.next =
|
|
807
|
+
_context2.next = 22;
|
|
779
808
|
break;
|
|
780
809
|
}
|
|
781
810
|
invalidRoles = messages.filter(function (m) {
|
|
782
811
|
return m.role !== 'customer' && m.role !== 'agent' && m.role !== 'system';
|
|
783
812
|
});
|
|
784
|
-
throw new Error("Every message must have a role of \"customer\", \"agent\", or \"system\". Got invalid roles: ".concat(invalidRoles.map(function (m) {
|
|
813
|
+
throw new Error("SpiritsError: Every message must have a role of \"customer\", \"agent\", or \"system\". Got invalid roles: ".concat(invalidRoles.map(function (m) {
|
|
785
814
|
return m.role;
|
|
786
815
|
}).join(', ')));
|
|
787
|
-
case
|
|
816
|
+
case 22:
|
|
788
817
|
// if message is not in messages, then add it
|
|
789
818
|
if (!messages.find(function (m) {
|
|
790
819
|
return m.id === input.message.id;
|
|
@@ -794,9 +823,9 @@ var Spirits = {
|
|
|
794
823
|
|
|
795
824
|
// 2. Parse the message
|
|
796
825
|
progress('Parsing message', 'info', 'SET_PROCESSING', 'user');
|
|
797
|
-
_context2.next =
|
|
826
|
+
_context2.next = 26;
|
|
798
827
|
return parser(message.content, 'en');
|
|
799
|
-
case
|
|
828
|
+
case 26:
|
|
800
829
|
parsePayload = _context2.sent;
|
|
801
830
|
if (parsePayload.intent) {
|
|
802
831
|
message.intent = parsePayload.intent;
|
|
@@ -864,7 +893,7 @@ var Spirits = {
|
|
|
864
893
|
}
|
|
865
894
|
noNewContext = Object.keys(parsePayload.context).length === 0; // 3. Run the workflow
|
|
866
895
|
progress('Running workflow', 'info', 'SET_PROCESSING', 'system');
|
|
867
|
-
_context2.next =
|
|
896
|
+
_context2.next = 42;
|
|
868
897
|
return workflow({
|
|
869
898
|
messages: messages,
|
|
870
899
|
conversation: conversation,
|
|
@@ -883,7 +912,7 @@ var Spirits = {
|
|
|
883
912
|
}).then(function (res) {
|
|
884
913
|
return Array.isArray(res) ? res : [res];
|
|
885
914
|
});
|
|
886
|
-
case
|
|
915
|
+
case 42:
|
|
887
916
|
slots = _context2.sent;
|
|
888
917
|
hasNoInstructions = slots.every(function (s) {
|
|
889
918
|
return !s.instructions || Array.isArray(s) && s.instructions.length === 0;
|
|
@@ -906,11 +935,11 @@ var Spirits = {
|
|
|
906
935
|
}
|
|
907
936
|
resettedIntent = false;
|
|
908
937
|
_iterator = _createForOfIteratorHelper(slots);
|
|
909
|
-
_context2.prev =
|
|
938
|
+
_context2.prev = 49;
|
|
910
939
|
_iterator.s();
|
|
911
|
-
case
|
|
940
|
+
case 51:
|
|
912
941
|
if ((_step = _iterator.n()).done) {
|
|
913
|
-
_context2.next =
|
|
942
|
+
_context2.next = 97;
|
|
914
943
|
break;
|
|
915
944
|
}
|
|
916
945
|
_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 +986,19 @@ var Spirits = {
|
|
|
957
986
|
|
|
958
987
|
// Insert instructions context
|
|
959
988
|
if (!instructions) {
|
|
960
|
-
_context2.next =
|
|
989
|
+
_context2.next = 69;
|
|
961
990
|
break;
|
|
962
991
|
}
|
|
963
992
|
if (!(typeof instructions === 'string')) {
|
|
964
|
-
_context2.next =
|
|
993
|
+
_context2.next = 59;
|
|
965
994
|
break;
|
|
966
995
|
}
|
|
967
996
|
addInstruction(instructions, previousLockAttempt);
|
|
968
|
-
_context2.next =
|
|
997
|
+
_context2.next = 69;
|
|
969
998
|
break;
|
|
970
|
-
case
|
|
999
|
+
case 59:
|
|
971
1000
|
if (!Array.isArray(instructions)) {
|
|
972
|
-
_context2.next =
|
|
1001
|
+
_context2.next = 64;
|
|
973
1002
|
break;
|
|
974
1003
|
}
|
|
975
1004
|
_iterator2 = _createForOfIteratorHelper(instructions);
|
|
@@ -987,25 +1016,25 @@ var Spirits = {
|
|
|
987
1016
|
} finally {
|
|
988
1017
|
_iterator2.f();
|
|
989
1018
|
}
|
|
990
|
-
_context2.next =
|
|
1019
|
+
_context2.next = 69;
|
|
991
1020
|
break;
|
|
992
|
-
case
|
|
1021
|
+
case 64:
|
|
993
1022
|
if (!(_typeof(instructions) === 'object' && 'content' in instructions && 'id' in instructions)) {
|
|
994
|
-
_context2.next =
|
|
1023
|
+
_context2.next = 68;
|
|
995
1024
|
break;
|
|
996
1025
|
}
|
|
997
1026
|
addInstruction(instructions.content, previousLockAttempt, instructions.id);
|
|
998
|
-
_context2.next =
|
|
1027
|
+
_context2.next = 69;
|
|
999
1028
|
break;
|
|
1000
|
-
case
|
|
1001
|
-
throw new Error('instructions must be a string or array or {content: "", id: ""}');
|
|
1002
|
-
case
|
|
1029
|
+
case 68:
|
|
1030
|
+
throw new Error('SpiritsError: instructions must be a string or array or {content: "", id: ""}');
|
|
1031
|
+
case 69:
|
|
1003
1032
|
if (!removeInstructions) {
|
|
1004
|
-
_context2.next =
|
|
1033
|
+
_context2.next = 86;
|
|
1005
1034
|
break;
|
|
1006
1035
|
}
|
|
1007
1036
|
_iterator3 = _createForOfIteratorHelper(removeInstructions);
|
|
1008
|
-
_context2.prev =
|
|
1037
|
+
_context2.prev = 71;
|
|
1009
1038
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1010
1039
|
var instructionId, index;
|
|
1011
1040
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
@@ -1028,46 +1057,55 @@ var Spirits = {
|
|
|
1028
1057
|
}, _loop);
|
|
1029
1058
|
});
|
|
1030
1059
|
_iterator3.s();
|
|
1031
|
-
case
|
|
1060
|
+
case 74:
|
|
1032
1061
|
if ((_step3 = _iterator3.n()).done) {
|
|
1033
|
-
_context2.next =
|
|
1062
|
+
_context2.next = 78;
|
|
1034
1063
|
break;
|
|
1035
1064
|
}
|
|
1036
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
1037
|
-
case 74:
|
|
1038
|
-
_context2.next = 72;
|
|
1039
|
-
break;
|
|
1065
|
+
return _context2.delegateYield(_loop(), "t0", 76);
|
|
1040
1066
|
case 76:
|
|
1041
|
-
_context2.next =
|
|
1067
|
+
_context2.next = 74;
|
|
1042
1068
|
break;
|
|
1043
1069
|
case 78:
|
|
1044
|
-
_context2.
|
|
1045
|
-
|
|
1070
|
+
_context2.next = 83;
|
|
1071
|
+
break;
|
|
1072
|
+
case 80:
|
|
1073
|
+
_context2.prev = 80;
|
|
1074
|
+
_context2.t1 = _context2["catch"](71);
|
|
1046
1075
|
_iterator3.e(_context2.t1);
|
|
1047
|
-
case
|
|
1048
|
-
_context2.prev =
|
|
1076
|
+
case 83:
|
|
1077
|
+
_context2.prev = 83;
|
|
1049
1078
|
_iterator3.f();
|
|
1050
|
-
return _context2.finish(
|
|
1051
|
-
case
|
|
1052
|
-
if (manualMessage) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1079
|
+
return _context2.finish(83);
|
|
1080
|
+
case 86:
|
|
1081
|
+
if (!manualMessage) {
|
|
1082
|
+
_context2.next = 93;
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
manualMessageObj = {
|
|
1086
|
+
id: idGenerator('agent'),
|
|
1087
|
+
role: 'agent',
|
|
1088
|
+
content: manualMessage,
|
|
1089
|
+
time: new Date().toISOString()
|
|
1090
|
+
};
|
|
1091
|
+
if (!(typeof manualMessage !== 'string')) {
|
|
1092
|
+
_context2.next = 90;
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
throw new Error('Manual message must be of type "string"');
|
|
1096
|
+
case 90:
|
|
1097
|
+
if (scheduled) {
|
|
1098
|
+
manualMessageObj.time = new Date(scheduled * 1000).toISOString();
|
|
1099
|
+
manualMessageObj.scheduled = manualMessageObj.time;
|
|
1100
|
+
} else if (secondsDelay) {
|
|
1101
|
+
now = new Date();
|
|
1102
|
+
now.setSeconds(now.getSeconds() + secondsDelay);
|
|
1103
|
+
manualMessageObj.time = now.toISOString();
|
|
1104
|
+
manualMessageObj.delayInSeconds = secondsDelay;
|
|
1070
1105
|
}
|
|
1106
|
+
messages.push(manualMessageObj);
|
|
1107
|
+
progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
1108
|
+
case 93:
|
|
1071
1109
|
if (contextUpsert) {
|
|
1072
1110
|
context = updateContext(context, contextUpsert);
|
|
1073
1111
|
progress('Upserted context', 'info', 'UPDATE_CONTEXT', contextUpsert);
|
|
@@ -1075,21 +1113,21 @@ var Spirits = {
|
|
|
1075
1113
|
if (resetIntent) {
|
|
1076
1114
|
resettedIntent = true;
|
|
1077
1115
|
}
|
|
1078
|
-
case
|
|
1079
|
-
_context2.next =
|
|
1116
|
+
case 95:
|
|
1117
|
+
_context2.next = 51;
|
|
1080
1118
|
break;
|
|
1081
|
-
case
|
|
1082
|
-
_context2.next =
|
|
1119
|
+
case 97:
|
|
1120
|
+
_context2.next = 102;
|
|
1083
1121
|
break;
|
|
1084
|
-
case
|
|
1085
|
-
_context2.prev =
|
|
1086
|
-
_context2.t2 = _context2["catch"](
|
|
1122
|
+
case 99:
|
|
1123
|
+
_context2.prev = 99;
|
|
1124
|
+
_context2.t2 = _context2["catch"](49);
|
|
1087
1125
|
_iterator.e(_context2.t2);
|
|
1088
|
-
case
|
|
1089
|
-
_context2.prev =
|
|
1126
|
+
case 102:
|
|
1127
|
+
_context2.prev = 102;
|
|
1090
1128
|
_iterator.f();
|
|
1091
|
-
return _context2.finish(
|
|
1092
|
-
case
|
|
1129
|
+
return _context2.finish(102);
|
|
1130
|
+
case 105:
|
|
1093
1131
|
if (resettedIntent && !_forward) {
|
|
1094
1132
|
conversation.intent = null;
|
|
1095
1133
|
conversation.intentScore = null;
|
|
@@ -1108,16 +1146,16 @@ var Spirits = {
|
|
|
1108
1146
|
// 4. Generate response
|
|
1109
1147
|
// If conversation previously locked, don't generate
|
|
1110
1148
|
if (input.conversation.locked) {
|
|
1111
|
-
_context2.next =
|
|
1149
|
+
_context2.next = 120;
|
|
1112
1150
|
break;
|
|
1113
1151
|
}
|
|
1114
1152
|
if (!((!conversation.locked || !hasNoInstructions) && !!hasNoCustomMessage)) {
|
|
1115
|
-
_context2.next =
|
|
1153
|
+
_context2.next = 120;
|
|
1116
1154
|
break;
|
|
1117
1155
|
}
|
|
1118
|
-
_context2.prev =
|
|
1156
|
+
_context2.prev = 108;
|
|
1119
1157
|
progress('Parsing message', 'info', 'SET_PROCESSING', 'system');
|
|
1120
|
-
_context2.next =
|
|
1158
|
+
_context2.next = 112;
|
|
1121
1159
|
return generator({
|
|
1122
1160
|
messages: messages,
|
|
1123
1161
|
persona: persona,
|
|
@@ -1125,7 +1163,7 @@ var Spirits = {
|
|
|
1125
1163
|
llm: config.llm,
|
|
1126
1164
|
pmt: config.pmt
|
|
1127
1165
|
});
|
|
1128
|
-
case
|
|
1166
|
+
case 112:
|
|
1129
1167
|
generatorPayload = _context2.sent;
|
|
1130
1168
|
if (!generatorPayload.send) {
|
|
1131
1169
|
progress('Generated response', 'failed', undefined, {
|
|
@@ -1162,14 +1200,14 @@ var Spirits = {
|
|
|
1162
1200
|
}
|
|
1163
1201
|
}
|
|
1164
1202
|
}
|
|
1165
|
-
_context2.next =
|
|
1203
|
+
_context2.next = 120;
|
|
1166
1204
|
break;
|
|
1167
|
-
case
|
|
1168
|
-
_context2.prev =
|
|
1169
|
-
_context2.t3 = _context2["catch"](
|
|
1205
|
+
case 116:
|
|
1206
|
+
_context2.prev = 116;
|
|
1207
|
+
_context2.t3 = _context2["catch"](108);
|
|
1170
1208
|
console.error("Locking conversation, error generating response: ".concat(_context2.t3.message));
|
|
1171
1209
|
conversation = lockConversation(conversation, 'API: ' + _context2.t3.message);
|
|
1172
|
-
case
|
|
1210
|
+
case 120:
|
|
1173
1211
|
progress('Parsing message', 'info', 'SET_PROCESSING', null);
|
|
1174
1212
|
return _context2.abrupt("return", {
|
|
1175
1213
|
conversation: {
|
|
@@ -1191,11 +1229,11 @@ var Spirits = {
|
|
|
1191
1229
|
after: context
|
|
1192
1230
|
}
|
|
1193
1231
|
});
|
|
1194
|
-
case
|
|
1232
|
+
case 122:
|
|
1195
1233
|
case "end":
|
|
1196
1234
|
return _context2.stop();
|
|
1197
1235
|
}
|
|
1198
|
-
}, _callee, null, [[
|
|
1236
|
+
}, _callee, null, [[49, 99, 102, 105], [71, 80, 83, 86], [108, 116]]);
|
|
1199
1237
|
}));
|
|
1200
1238
|
function customer(_x) {
|
|
1201
1239
|
return _customer.apply(this, arguments);
|
|
@@ -1207,6 +1245,7 @@ var Spirits = {
|
|
|
1207
1245
|
exports.Spirits = Spirits;
|
|
1208
1246
|
exports._asyncToGenerator = _asyncToGenerator;
|
|
1209
1247
|
exports._classCallCheck = _classCallCheck;
|
|
1248
|
+
exports._classStaticPrivateFieldSpecGet = _classStaticPrivateFieldSpecGet;
|
|
1210
1249
|
exports._createClass = _createClass;
|
|
1211
1250
|
exports._createForOfIteratorHelper = _createForOfIteratorHelper;
|
|
1212
1251
|
exports._defineProperty = _defineProperty;
|
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-83755281.cjs");
|
|
6
|
+
var spirits = require("./spirits-32395ac4.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.93",
|
|
4
4
|
"description": "Build and deploy your Scout9 app for SMS auto replies",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"generate:types": "node scripts/generate-dts.js",
|
|
22
22
|
"prebuild": "rimraf dist/",
|
|
23
23
|
"build": "rollup -c",
|
|
24
|
-
"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
25
|
"build-no-test": "npm run prebuild && rollup -c"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
|
@@ -135,7 +135,7 @@ export default async function loadAgentConfig({
|
|
|
135
135
|
}
|
|
136
136
|
if (!agent.programmablePhoneNumber) {
|
|
137
137
|
const userName = agent.firstName ? `${agent.firstName}${agent.lastName ? ' ' + agent.lastName : ''}` : agent.forwardPhone;
|
|
138
|
-
cb(`⚠️${colors.yellow('Warning')}: ${userName} does not have a masked phone number to do auto replies
|
|
138
|
+
cb(`⚠️${colors.yellow('Warning')}: ${userName} does not have a masked phone number to do auto replies.\nYou can register one at ${colors.cyan(
|
|
139
139
|
'https://scout9.com/b')} under ${colors.green('users')} > ${colors.green(userName)}. Then run ${colors.cyan(
|
|
140
140
|
'scout9 sync')} to update.`);
|
|
141
141
|
}
|
package/src/exports.js
CHANGED
|
@@ -5,6 +5,7 @@ export { EventResponse } from './runtime/index.js';
|
|
|
5
5
|
|
|
6
6
|
export * from './testing-tools/index.js';
|
|
7
7
|
export * from './runtime/client/index.js';
|
|
8
|
+
export * from './runtime/macros/index.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @param {import('./runtime/client/workflow.js').IWorkflowEvent} event - every workflow receives an event object
|