@scout9/app 1.0.0-alpha.0.4.2 → 1.0.0-alpha.0.4.3
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-89d0d9da.cjs → dev-195686a8.cjs} +67 -2
- package/dist/{index-d60f8919.cjs → index-ec0cd08d.cjs} +11 -42
- package/dist/index.cjs +3 -2
- package/dist/{multipart-parser-6df56089.cjs → multipart-parser-a2f207ea.cjs} +2 -2
- package/dist/testing-tools.cjs +1 -1
- package/package.json +1 -1
- package/src/runtime/macros/event.js +31 -1
|
@@ -35049,7 +35049,7 @@ function _loadUserPackageJson() {
|
|
|
35049
35049
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
35050
35050
|
_context2.t0 = JSON;
|
|
35051
35051
|
_context2.next = 10;
|
|
35052
|
-
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-
|
|
35052
|
+
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-195686a8.js', document.baseURI).href))), 'utf-8');
|
|
35053
35053
|
case 10:
|
|
35054
35054
|
_context2.t1 = _context2.sent;
|
|
35055
35055
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -35781,6 +35781,37 @@ function MacroUtilsFactory() {
|
|
|
35781
35781
|
}
|
|
35782
35782
|
var MacroUtils = MacroUtilsFactory();
|
|
35783
35783
|
|
|
35784
|
+
var MacroGlobals = /*#__PURE__*/function () {
|
|
35785
|
+
function MacroGlobals() {
|
|
35786
|
+
spirits._classCallCheck(this, MacroGlobals);
|
|
35787
|
+
}
|
|
35788
|
+
spirits._createClass(MacroGlobals, null, [{
|
|
35789
|
+
key: "$convo",
|
|
35790
|
+
value: function $convo() {
|
|
35791
|
+
var _globalThis$SCOUT;
|
|
35792
|
+
var $convo = globalThis === null || globalThis === void 0 || (_globalThis$SCOUT = globalThis.SCOUT9) === null || _globalThis$SCOUT === void 0 ? void 0 : _globalThis$SCOUT.$convo;
|
|
35793
|
+
if (!$convo) {
|
|
35794
|
+
throw new Error("$convo not found in runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
35795
|
+
}
|
|
35796
|
+
return $convo;
|
|
35797
|
+
}
|
|
35798
|
+
}, {
|
|
35799
|
+
key: "event",
|
|
35800
|
+
value: function event() {
|
|
35801
|
+
var event = globalThis === null || globalThis === void 0 ? void 0 : globalThis.SCOUT9;
|
|
35802
|
+
if (!event) {
|
|
35803
|
+
throw new Error("No runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
35804
|
+
}
|
|
35805
|
+
return event;
|
|
35806
|
+
}
|
|
35807
|
+
}]);
|
|
35808
|
+
return MacroGlobals;
|
|
35809
|
+
}();
|
|
35810
|
+
var _hint = {
|
|
35811
|
+
writable: true,
|
|
35812
|
+
value: "make sure the context is properly instantiated before running workflow."
|
|
35813
|
+
};
|
|
35814
|
+
|
|
35784
35815
|
var _excluded$1 = ["success"];
|
|
35785
35816
|
|
|
35786
35817
|
/**
|
|
@@ -35994,6 +36025,25 @@ function EventMacrosFactory() {
|
|
|
35994
36025
|
}
|
|
35995
36026
|
return this;
|
|
35996
36027
|
},
|
|
36028
|
+
/**
|
|
36029
|
+
* If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
|
|
36030
|
+
* @param {string} instruction
|
|
36031
|
+
* @param {OptionsInstruct & OptionsForward & {stagnationLimit?: number}} [options] - stagnationCountLimit, defaults to 2
|
|
36032
|
+
* @return {EventMacros}
|
|
36033
|
+
*/
|
|
36034
|
+
instructSafe: function instructSafe(instruction) {
|
|
36035
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
36036
|
+
stagnationLimit: 2
|
|
36037
|
+
};
|
|
36038
|
+
var _options$stagnationLi = options.stagnationLimit,
|
|
36039
|
+
stagnationLimit = _options$stagnationLi === void 0 ? 2 : _options$stagnationLi;
|
|
36040
|
+
var event = MacroGlobals.event(); // Check the event to eval stagnation
|
|
36041
|
+
if (event.stagnationCount < stagnationLimit) {
|
|
36042
|
+
return this.instruct(instruction, options);
|
|
36043
|
+
} else {
|
|
36044
|
+
return this.forward("Instruct Exceeds event.stagnationCount >= ".concat(stagnationLimit, ": ").concat(instruction), options);
|
|
36045
|
+
}
|
|
36046
|
+
},
|
|
35997
36047
|
/**
|
|
35998
36048
|
* Return instructions to guide next auto reply response
|
|
35999
36049
|
* @param {string} instruction
|
|
@@ -36110,7 +36160,7 @@ function EventMacrosFactory() {
|
|
|
36110
36160
|
var eventMacros = EventMacrosFactory();
|
|
36111
36161
|
|
|
36112
36162
|
/**
|
|
36113
|
-
* Return instructions to guide next
|
|
36163
|
+
* Return instructions to guide next response
|
|
36114
36164
|
* @param {string} instruction - the instruction to send to the
|
|
36115
36165
|
* @param {OptionsInstruct} [options]
|
|
36116
36166
|
* @return {EventMacros}
|
|
@@ -36121,6 +36171,19 @@ var eventMacros = EventMacrosFactory();
|
|
|
36121
36171
|
*/
|
|
36122
36172
|
var instruct = eventMacros.instruct.bind(eventMacros);
|
|
36123
36173
|
|
|
36174
|
+
/**
|
|
36175
|
+
* If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
|
|
36176
|
+
* @param {string} instruction - the instruction to send to the
|
|
36177
|
+
* @param {OptionsInstruct} [options]
|
|
36178
|
+
* @return {EventMacros}
|
|
36179
|
+
*
|
|
36180
|
+
* @example instructSafe("Ask user if they are looking to order a pizza");
|
|
36181
|
+
* @example instructSafe("Ask user if they are looking to order a pizza", {stagnationLimit: 3}); // Allows for 3 stagnate messages before forwarding
|
|
36182
|
+
*
|
|
36183
|
+
* @type {(message: string, options?: OptionsInstruct) => EventMacros}
|
|
36184
|
+
*/
|
|
36185
|
+
var instructSafe = eventMacros.instructSafe.bind(eventMacros);
|
|
36186
|
+
|
|
36124
36187
|
/**
|
|
36125
36188
|
* Forwards conversation back to you or owner of workflow.
|
|
36126
36189
|
*
|
|
@@ -42828,6 +42891,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42828
42891
|
}();
|
|
42829
42892
|
|
|
42830
42893
|
exports.$ = $$1;
|
|
42894
|
+
exports.MacroGlobals = MacroGlobals;
|
|
42831
42895
|
exports.ProgressLogger = ProgressLogger;
|
|
42832
42896
|
exports.Scout9Test = Scout9Test;
|
|
42833
42897
|
exports.balancedMatch = balancedMatch;
|
|
@@ -42846,6 +42910,7 @@ exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
|
42846
42910
|
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
42847
42911
|
exports.globSync = globSync;
|
|
42848
42912
|
exports.instruct = instruct;
|
|
42913
|
+
exports.instructSafe = instructSafe;
|
|
42849
42914
|
exports.loadConfig = loadConfig;
|
|
42850
42915
|
exports.loadEnvConfig = loadEnvConfig;
|
|
42851
42916
|
exports.loadUserPackageJson = loadUserPackageJson;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var spirits = require("./spirits-5c9243a1.cjs");
|
|
4
|
-
var dev = require("./dev-
|
|
4
|
+
var dev = require("./dev-195686a8.cjs");
|
|
5
5
|
var macros = require("./macros-e4105c56.cjs");
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$2$1 = require('events');
|
|
@@ -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-a2f207ea.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-ec0cd08d.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);
|
|
@@ -41966,37 +41966,6 @@ var EventResponse = /*#__PURE__*/function () {
|
|
|
41966
41966
|
return EventResponse;
|
|
41967
41967
|
}();
|
|
41968
41968
|
|
|
41969
|
-
var MacroGlobals = /*#__PURE__*/function () {
|
|
41970
|
-
function MacroGlobals() {
|
|
41971
|
-
spirits._classCallCheck(this, MacroGlobals);
|
|
41972
|
-
}
|
|
41973
|
-
spirits._createClass(MacroGlobals, null, [{
|
|
41974
|
-
key: "$convo",
|
|
41975
|
-
value: function $convo() {
|
|
41976
|
-
var _globalThis$SCOUT;
|
|
41977
|
-
var $convo = globalThis === null || globalThis === void 0 || (_globalThis$SCOUT = globalThis.SCOUT9) === null || _globalThis$SCOUT === void 0 ? void 0 : _globalThis$SCOUT.$convo;
|
|
41978
|
-
if (!$convo) {
|
|
41979
|
-
throw new Error("$convo not found in runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
41980
|
-
}
|
|
41981
|
-
return $convo;
|
|
41982
|
-
}
|
|
41983
|
-
}, {
|
|
41984
|
-
key: "event",
|
|
41985
|
-
value: function event() {
|
|
41986
|
-
var event = globalThis === null || globalThis === void 0 ? void 0 : globalThis.SCOUT9;
|
|
41987
|
-
if (!event) {
|
|
41988
|
-
throw new Error("No runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
41989
|
-
}
|
|
41990
|
-
return event;
|
|
41991
|
-
}
|
|
41992
|
-
}]);
|
|
41993
|
-
return MacroGlobals;
|
|
41994
|
-
}();
|
|
41995
|
-
var _hint = {
|
|
41996
|
-
writable: true,
|
|
41997
|
-
value: "make sure the context is properly instantiated before running workflow."
|
|
41998
|
-
};
|
|
41999
|
-
|
|
42000
41969
|
var _excluded = ["event"];
|
|
42001
41970
|
function handleAxiosResponse(res) {
|
|
42002
41971
|
if (res.status === 200) {
|
|
@@ -42045,8 +42014,8 @@ function _did() {
|
|
|
42045
42014
|
return spirits._regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
42046
42015
|
while (1) switch (_context2.prev = _context2.next) {
|
|
42047
42016
|
case 0:
|
|
42048
|
-
convoId = MacroGlobals.$convo();
|
|
42049
|
-
event = MacroGlobals.event();
|
|
42017
|
+
convoId = dev.MacroGlobals.$convo();
|
|
42018
|
+
event = dev.MacroGlobals.event();
|
|
42050
42019
|
event.conversation.$id = convoId;
|
|
42051
42020
|
event.conversation.id = convoId;
|
|
42052
42021
|
if (convoId) {
|
|
@@ -42116,8 +42085,8 @@ function _does() {
|
|
|
42116
42085
|
while (1) switch (_context3.prev = _context3.next) {
|
|
42117
42086
|
case 0:
|
|
42118
42087
|
relation = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'customer';
|
|
42119
|
-
convoId = MacroGlobals.$convo();
|
|
42120
|
-
event = MacroGlobals.event();
|
|
42088
|
+
convoId = dev.MacroGlobals.$convo();
|
|
42089
|
+
event = dev.MacroGlobals.event();
|
|
42121
42090
|
event.conversation.$id = convoId;
|
|
42122
42091
|
event.conversation.id = convoId;
|
|
42123
42092
|
if (convoId) {
|
|
@@ -42159,8 +42128,8 @@ function _context() {
|
|
|
42159
42128
|
return spirits._regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
42160
42129
|
while (1) switch (_context4.prev = _context4.next) {
|
|
42161
42130
|
case 0:
|
|
42162
|
-
convoId = MacroGlobals.$convo();
|
|
42163
|
-
event = MacroGlobals.event();
|
|
42131
|
+
convoId = dev.MacroGlobals.$convo();
|
|
42132
|
+
event = dev.MacroGlobals.event();
|
|
42164
42133
|
event.conversation.$id = convoId;
|
|
42165
42134
|
event.conversation.id = convoId;
|
|
42166
42135
|
if (convoId) {
|
|
@@ -43188,7 +43157,7 @@ var ProjectFiles = /*#__PURE__*/function () {
|
|
|
43188
43157
|
return ProjectFiles;
|
|
43189
43158
|
}();
|
|
43190
43159
|
|
|
43191
|
-
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-
|
|
43160
|
+
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-ec0cd08d.js', document.baseURI).href)));
|
|
43192
43161
|
var __dirname$1 = path__default["default"].dirname(__filename$1);
|
|
43193
43162
|
function zipDirectory(source, out) {
|
|
43194
43163
|
var archive = archiver$1('tar', {
|
|
@@ -43403,7 +43372,7 @@ function _buildApp() {
|
|
|
43403
43372
|
case 11:
|
|
43404
43373
|
_context4.t0 = JSON;
|
|
43405
43374
|
_context4.next = 14;
|
|
43406
|
-
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-
|
|
43375
|
+
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-ec0cd08d.js', document.baseURI).href))), 'utf-8');
|
|
43407
43376
|
case 14:
|
|
43408
43377
|
_context4.t1 = _context4.sent;
|
|
43409
43378
|
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 index = require("./index-
|
|
6
|
-
var dev = require("./dev-
|
|
5
|
+
var index = require("./index-ec0cd08d.cjs");
|
|
6
|
+
var dev = require("./dev-195686a8.cjs");
|
|
7
7
|
require("./spirits-5c9243a1.cjs");
|
|
8
8
|
require("./macros-e4105c56.cjs");
|
|
9
9
|
require('fs');
|
|
@@ -57,4 +57,5 @@ exports.createMockMessage = dev.createMockMessage;
|
|
|
57
57
|
exports.createMockWorkflowEvent = dev.createMockWorkflowEvent;
|
|
58
58
|
exports.forward = dev.forward;
|
|
59
59
|
exports.instruct = dev.instruct;
|
|
60
|
+
exports.instructSafe = dev.instructSafe;
|
|
60
61
|
exports.reply = dev.reply;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var index = require("./index-
|
|
5
|
+
var index = require("./index-ec0cd08d.cjs");
|
|
6
6
|
require("./spirits-5c9243a1.cjs");
|
|
7
|
-
require("./dev-
|
|
7
|
+
require("./dev-195686a8.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
package/dist/testing-tools.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorkflowResponseSlotBaseSchema, WorkflowResponseSlotSchema } from '../schemas/workflow.js';
|
|
2
2
|
import { MacroUtils } from './utils.js';
|
|
3
3
|
import { simplifyError } from '../../utils/index.js';
|
|
4
|
+
import MacroGlobals from './globals.js';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -214,6 +215,22 @@ function EventMacrosFactory() {
|
|
|
214
215
|
return this;
|
|
215
216
|
},
|
|
216
217
|
|
|
218
|
+
/**
|
|
219
|
+
* If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
|
|
220
|
+
* @param {string} instruction
|
|
221
|
+
* @param {OptionsInstruct & OptionsForward & {stagnationLimit?: number}} [options] - stagnationCountLimit, defaults to 2
|
|
222
|
+
* @return {EventMacros}
|
|
223
|
+
*/
|
|
224
|
+
instructSafe(instruction, options = {stagnationLimit: 2}) {
|
|
225
|
+
const {stagnationLimit = 2} = options;
|
|
226
|
+
const event = MacroGlobals.event(); // Check the event to eval stagnation
|
|
227
|
+
if (event.stagnationCount < stagnationLimit) {
|
|
228
|
+
return this.instruct(instruction, options);
|
|
229
|
+
} else {
|
|
230
|
+
return this.forward(`Instruct Exceeds event.stagnationCount >= ${stagnationLimit}: ${instruction}`, options);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
|
|
217
234
|
/**
|
|
218
235
|
* Return instructions to guide next auto reply response
|
|
219
236
|
* @param {string} instruction
|
|
@@ -327,7 +344,7 @@ function EventMacrosFactory() {
|
|
|
327
344
|
const eventMacros = EventMacrosFactory();
|
|
328
345
|
|
|
329
346
|
/**
|
|
330
|
-
* Return instructions to guide next
|
|
347
|
+
* Return instructions to guide next response
|
|
331
348
|
* @param {string} instruction - the instruction to send to the
|
|
332
349
|
* @param {OptionsInstruct} [options]
|
|
333
350
|
* @return {EventMacros}
|
|
@@ -338,6 +355,19 @@ const eventMacros = EventMacrosFactory();
|
|
|
338
355
|
*/
|
|
339
356
|
export const instruct = eventMacros.instruct.bind(eventMacros);
|
|
340
357
|
|
|
358
|
+
/**
|
|
359
|
+
* If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
|
|
360
|
+
* @param {string} instruction - the instruction to send to the
|
|
361
|
+
* @param {OptionsInstruct} [options]
|
|
362
|
+
* @return {EventMacros}
|
|
363
|
+
*
|
|
364
|
+
* @example instructSafe("Ask user if they are looking to order a pizza");
|
|
365
|
+
* @example instructSafe("Ask user if they are looking to order a pizza", {stagnationLimit: 3}); // Allows for 3 stagnate messages before forwarding
|
|
366
|
+
*
|
|
367
|
+
* @type {(message: string, options?: OptionsInstruct) => EventMacros}
|
|
368
|
+
*/
|
|
369
|
+
export const instructSafe = eventMacros.instructSafe.bind(eventMacros);
|
|
370
|
+
|
|
341
371
|
/**
|
|
342
372
|
* Forwards conversation back to you or owner of workflow.
|
|
343
373
|
*
|