@scout9/app 1.0.0-alpha.0.4.9 → 1.0.0-alpha.0.5.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-51604173.cjs → dev-5c6f5d76.cjs} +319 -151
- package/dist/{index-2aa6f869.cjs → index-45f6ee5e.cjs} +7 -7
- package/dist/index.cjs +5 -4
- package/dist/{macros-c9b4654d.cjs → macros-2f21c706.cjs} +7 -0
- package/dist/{multipart-parser-24b2e9b9.cjs → multipart-parser-bac8efc8.cjs} +4 -4
- package/dist/schemas.cjs +3 -1
- package/dist/{spirits-8225c9fd.cjs → spirits-2ab4d673.cjs} +12 -0
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +3 -3
- package/package.json +3 -3
- package/src/core/config/commands.js +41 -0
- package/src/core/config/index.js +4 -1
- package/src/core/templates/app.js +466 -76
- package/src/exports.js +1 -0
- package/src/public.d.ts +5 -2
- package/src/runtime/schemas/workflow.js +7 -0
- package/src/testing-tools/dev.js +371 -360
- package/types/index.d.ts +28 -21
- package/types/index.d.ts.map +4 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
3
|
+
var spirits = require("./spirits-2ab4d673.cjs");
|
|
4
4
|
var require$$0$4 = require('util');
|
|
5
5
|
var require$$0$3 = require('stream');
|
|
6
6
|
var require$$1 = require('path');
|
|
@@ -23,7 +23,7 @@ var Stream = require('node:stream');
|
|
|
23
23
|
var node_string_decoder = require('node:string_decoder');
|
|
24
24
|
var readline = require('node:readline');
|
|
25
25
|
var process$2 = require('node:process');
|
|
26
|
-
var macros = require("./macros-
|
|
26
|
+
var macros = require("./macros-2f21c706.cjs");
|
|
27
27
|
var node_os = require('node:os');
|
|
28
28
|
var promises = require('fs/promises');
|
|
29
29
|
|
|
@@ -35164,7 +35164,7 @@ function _loadUserPackageJson() {
|
|
|
35164
35164
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
35165
35165
|
_context2.t0 = JSON;
|
|
35166
35166
|
_context2.next = 10;
|
|
35167
|
-
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-
|
|
35167
|
+
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-5c6f5d76.js', document.baseURI).href))), 'utf-8');
|
|
35168
35168
|
case 10:
|
|
35169
35169
|
_context2.t1 = _context2.sent;
|
|
35170
35170
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -37779,6 +37779,57 @@ function _loadWorkflowsConfig() {
|
|
|
37779
37779
|
return _loadWorkflowsConfig.apply(this, arguments);
|
|
37780
37780
|
}
|
|
37781
37781
|
|
|
37782
|
+
/**
|
|
37783
|
+
* @returns {Promise<CommandConfiguration[]>}
|
|
37784
|
+
*/
|
|
37785
|
+
function loadCommandsConfig() {
|
|
37786
|
+
return _loadCommandsConfig.apply(this, arguments);
|
|
37787
|
+
}
|
|
37788
|
+
function _loadCommandsConfig() {
|
|
37789
|
+
_loadCommandsConfig = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee() {
|
|
37790
|
+
var _ref,
|
|
37791
|
+
_ref$cwd,
|
|
37792
|
+
cwd,
|
|
37793
|
+
_ref$src,
|
|
37794
|
+
src,
|
|
37795
|
+
config,
|
|
37796
|
+
_args = arguments;
|
|
37797
|
+
return spirits._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
37798
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37799
|
+
case 0:
|
|
37800
|
+
_ref = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref$cwd = _ref.cwd, cwd = _ref$cwd === void 0 ? process.cwd() : _ref$cwd, _ref$src = _ref.src, src = _ref$src === void 0 ? 'src' : _ref$src, _ref.cb;
|
|
37801
|
+
// const config = globSync(path.resolve(cwd, `${src}/workflows/**/workflow.{ts,js}`), {cwd, absolute: true})
|
|
37802
|
+
config = globSync("".concat(src, "/commands/**/{index,command,*.command}.{ts,js}"), {
|
|
37803
|
+
cwd: cwd,
|
|
37804
|
+
absolute: false
|
|
37805
|
+
}).map(function (path) {
|
|
37806
|
+
var dir = path$2.dirname(path);
|
|
37807
|
+
var entity = path$2.basename(path).replace(/\..*$/, ''); // Removes any "."'s
|
|
37808
|
+
if (!entity) {
|
|
37809
|
+
throw new Error("Invalid command path \"".concat(path, "\""));
|
|
37810
|
+
}
|
|
37811
|
+
switch (entity) {
|
|
37812
|
+
case "index":
|
|
37813
|
+
case "command":
|
|
37814
|
+
entity = path$2.basename(dir);
|
|
37815
|
+
break;
|
|
37816
|
+
}
|
|
37817
|
+
return {
|
|
37818
|
+
entity: entity,
|
|
37819
|
+
path: path.split(src + '/commands/')[1]
|
|
37820
|
+
};
|
|
37821
|
+
}); // Validate the config
|
|
37822
|
+
macros.CommandsSchema.parse(config);
|
|
37823
|
+
return _context.abrupt("return", config);
|
|
37824
|
+
case 4:
|
|
37825
|
+
case "end":
|
|
37826
|
+
return _context.stop();
|
|
37827
|
+
}
|
|
37828
|
+
}, _callee);
|
|
37829
|
+
}));
|
|
37830
|
+
return _loadCommandsConfig.apply(this, arguments);
|
|
37831
|
+
}
|
|
37832
|
+
|
|
37782
37833
|
function loadEnvConfig() {
|
|
37783
37834
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
37784
37835
|
_ref$cwd = _ref.cwd,
|
|
@@ -37831,6 +37882,7 @@ function _loadConfig() {
|
|
|
37831
37882
|
entitiesConfig,
|
|
37832
37883
|
agentsConfig,
|
|
37833
37884
|
workflowsConfig,
|
|
37885
|
+
commandsConfig,
|
|
37834
37886
|
projectConfig,
|
|
37835
37887
|
result,
|
|
37836
37888
|
_args = arguments;
|
|
@@ -37886,24 +37938,35 @@ function _loadConfig() {
|
|
|
37886
37938
|
});
|
|
37887
37939
|
case 13:
|
|
37888
37940
|
workflowsConfig = _context.sent;
|
|
37941
|
+
_context.next = 16;
|
|
37942
|
+
return loadCommandsConfig({
|
|
37943
|
+
cwd: cwd,
|
|
37944
|
+
src: src,
|
|
37945
|
+
logger: logger,
|
|
37946
|
+
deploying: deploying,
|
|
37947
|
+
cb: cb
|
|
37948
|
+
});
|
|
37949
|
+
case 16:
|
|
37950
|
+
commandsConfig = _context.sent;
|
|
37889
37951
|
/**
|
|
37890
37952
|
* @type {Scout9ProjectBuildConfig}
|
|
37891
37953
|
*/
|
|
37892
37954
|
projectConfig = spirits._objectSpread2(spirits._objectSpread2({}, baseProjectConfig), {}, {
|
|
37893
37955
|
entities: entitiesConfig,
|
|
37894
37956
|
agents: agentsConfig,
|
|
37895
|
-
workflows: workflowsConfig
|
|
37957
|
+
workflows: workflowsConfig,
|
|
37958
|
+
commands: commandsConfig
|
|
37896
37959
|
}); // Validate the config
|
|
37897
37960
|
result = macros.Scout9ProjectBuildConfigSchema.safeParse(projectConfig);
|
|
37898
37961
|
if (result.success) {
|
|
37899
|
-
_context.next =
|
|
37962
|
+
_context.next = 22;
|
|
37900
37963
|
break;
|
|
37901
37964
|
}
|
|
37902
37965
|
result.error.source = "".concat(src, "/index.js");
|
|
37903
37966
|
throw result.error;
|
|
37904
|
-
case
|
|
37967
|
+
case 22:
|
|
37905
37968
|
return _context.abrupt("return", projectConfig);
|
|
37906
|
-
case
|
|
37969
|
+
case 23:
|
|
37907
37970
|
case "end":
|
|
37908
37971
|
return _context.stop();
|
|
37909
37972
|
}
|
|
@@ -42546,7 +42609,19 @@ var createMockWorkflowEvent = function createMockWorkflowEvent(message) {
|
|
|
42546
42609
|
/**
|
|
42547
42610
|
* Testing tool kit, used to handle Scout9 operations such as parsing, workflow, and generating responses
|
|
42548
42611
|
*/
|
|
42612
|
+
var _project = /*#__PURE__*/new WeakMap();
|
|
42613
|
+
var _app = /*#__PURE__*/new WeakMap();
|
|
42614
|
+
var _command = /*#__PURE__*/new WeakMap();
|
|
42615
|
+
var _api = /*#__PURE__*/new WeakMap();
|
|
42616
|
+
var _cwd = /*#__PURE__*/new WeakMap();
|
|
42617
|
+
var _src = /*#__PURE__*/new WeakMap();
|
|
42618
|
+
var _mode = /*#__PURE__*/new WeakMap();
|
|
42619
|
+
var _loaded = /*#__PURE__*/new WeakMap();
|
|
42620
|
+
var _personaId = /*#__PURE__*/new WeakMap();
|
|
42549
42621
|
var _defaultLog = /*#__PURE__*/new WeakMap();
|
|
42622
|
+
var _commandId = /*#__PURE__*/new WeakMap();
|
|
42623
|
+
var _loadApp = /*#__PURE__*/new WeakSet();
|
|
42624
|
+
var _loadCommand = /*#__PURE__*/new WeakSet();
|
|
42550
42625
|
var Scout9Test = /*#__PURE__*/function () {
|
|
42551
42626
|
/**
|
|
42552
42627
|
* Mimics a customer message to your app (useful for testing)
|
|
@@ -42558,6 +42633,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42558
42633
|
* @param {string | undefined} [props.cwd]
|
|
42559
42634
|
* @param {string | undefined} [props.src]
|
|
42560
42635
|
* @param {string | undefined} [props.mode]
|
|
42636
|
+
* @param {string | null | undefined} [props.command] - if provided it will use the command runtime instead of the app runtime
|
|
42561
42637
|
* @param {import('@scout9/admin').Scout9Api} [props.api]
|
|
42562
42638
|
* @param {import('@scout9/app').WorkflowFunction} [props.app]
|
|
42563
42639
|
* @param {import('@scout9/app').Scout9ProjectBuildConfig} [props.project]
|
|
@@ -42581,10 +42657,18 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42581
42657
|
mode = _ref$mode === void 0 ? 'production' : _ref$mode,
|
|
42582
42658
|
api = _ref.api,
|
|
42583
42659
|
app = _ref.app,
|
|
42660
|
+
_ref$command = _ref.command,
|
|
42661
|
+
_command2 = _ref$command === void 0 ? null : _ref$command,
|
|
42584
42662
|
project = _ref.project,
|
|
42585
42663
|
_ref$log = _ref.log,
|
|
42586
42664
|
log = _ref$log === void 0 ? false : _ref$log;
|
|
42587
42665
|
spirits._classCallCheck(this, Scout9Test);
|
|
42666
|
+
/**
|
|
42667
|
+
* @param {string} command
|
|
42668
|
+
* @returns {Promise<void>}
|
|
42669
|
+
*/
|
|
42670
|
+
spirits._classPrivateMethodInitSpec(this, _loadCommand);
|
|
42671
|
+
spirits._classPrivateMethodInitSpec(this, _loadApp);
|
|
42588
42672
|
/**
|
|
42589
42673
|
* @type {import('@scout9/app').Customer}
|
|
42590
42674
|
*/
|
|
@@ -42605,64 +42689,69 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42605
42689
|
* @type {import('@scout9/app').ConversationContext}
|
|
42606
42690
|
*/
|
|
42607
42691
|
spirits._defineProperty(this, "context", void 0);
|
|
42608
|
-
|
|
42609
|
-
|
|
42610
|
-
|
|
42611
|
-
|
|
42612
|
-
spirits.
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42616
|
-
|
|
42617
|
-
|
|
42618
|
-
|
|
42619
|
-
|
|
42620
|
-
|
|
42621
|
-
|
|
42622
|
-
|
|
42623
|
-
|
|
42624
|
-
|
|
42625
|
-
|
|
42626
|
-
|
|
42627
|
-
|
|
42628
|
-
|
|
42629
|
-
|
|
42630
|
-
|
|
42631
|
-
|
|
42632
|
-
|
|
42633
|
-
|
|
42634
|
-
|
|
42635
|
-
|
|
42636
|
-
|
|
42637
|
-
|
|
42638
|
-
|
|
42639
|
-
|
|
42640
|
-
|
|
42641
|
-
|
|
42642
|
-
|
|
42643
|
-
|
|
42644
|
-
* @private
|
|
42645
|
-
*/
|
|
42692
|
+
spirits._classPrivateFieldInitSpec(this, _project, {
|
|
42693
|
+
writable: true,
|
|
42694
|
+
value: null
|
|
42695
|
+
});
|
|
42696
|
+
spirits._classPrivateFieldInitSpec(this, _app, {
|
|
42697
|
+
writable: true,
|
|
42698
|
+
value: null
|
|
42699
|
+
});
|
|
42700
|
+
spirits._classPrivateFieldInitSpec(this, _command, {
|
|
42701
|
+
writable: true,
|
|
42702
|
+
value: null
|
|
42703
|
+
});
|
|
42704
|
+
spirits._classPrivateFieldInitSpec(this, _api, {
|
|
42705
|
+
writable: true,
|
|
42706
|
+
value: null
|
|
42707
|
+
});
|
|
42708
|
+
spirits._classPrivateFieldInitSpec(this, _cwd, {
|
|
42709
|
+
writable: true,
|
|
42710
|
+
value: void 0
|
|
42711
|
+
});
|
|
42712
|
+
spirits._classPrivateFieldInitSpec(this, _src, {
|
|
42713
|
+
writable: true,
|
|
42714
|
+
value: void 0
|
|
42715
|
+
});
|
|
42716
|
+
spirits._classPrivateFieldInitSpec(this, _mode, {
|
|
42717
|
+
writable: true,
|
|
42718
|
+
value: void 0
|
|
42719
|
+
});
|
|
42720
|
+
spirits._classPrivateFieldInitSpec(this, _loaded, {
|
|
42721
|
+
writable: true,
|
|
42722
|
+
value: void 0
|
|
42723
|
+
});
|
|
42724
|
+
spirits._classPrivateFieldInitSpec(this, _personaId, {
|
|
42725
|
+
writable: true,
|
|
42726
|
+
value: void 0
|
|
42727
|
+
});
|
|
42646
42728
|
spirits._classPrivateFieldInitSpec(this, _defaultLog, {
|
|
42647
42729
|
writable: true,
|
|
42648
42730
|
value: void 0
|
|
42649
42731
|
});
|
|
42732
|
+
spirits._classPrivateFieldInitSpec(this, _commandId, {
|
|
42733
|
+
writable: true,
|
|
42734
|
+
value: null
|
|
42735
|
+
});
|
|
42650
42736
|
this.messages = [];
|
|
42651
|
-
this
|
|
42652
|
-
this
|
|
42653
|
-
this
|
|
42737
|
+
spirits._classPrivateFieldSet(this, _cwd, cwd);
|
|
42738
|
+
spirits._classPrivateFieldSet(this, _src, src);
|
|
42739
|
+
spirits._classPrivateFieldSet(this, _mode, mode);
|
|
42654
42740
|
this.context = spirits._objectSpread2(spirits._objectSpread2({}, context || {}), {}, {
|
|
42655
42741
|
__no_cache: true
|
|
42656
42742
|
});
|
|
42657
42743
|
this.conversation = conversation;
|
|
42658
42744
|
if (api) {
|
|
42659
|
-
this
|
|
42745
|
+
spirits._classPrivateFieldSet(this, _api, api);
|
|
42660
42746
|
}
|
|
42661
42747
|
if (app) {
|
|
42662
|
-
this
|
|
42748
|
+
spirits._classPrivateFieldSet(this, _app, app);
|
|
42663
42749
|
}
|
|
42664
42750
|
if (project) {
|
|
42665
|
-
this
|
|
42751
|
+
spirits._classPrivateFieldSet(this, _project, project);
|
|
42752
|
+
}
|
|
42753
|
+
if (_command2) {
|
|
42754
|
+
spirits._classPrivateFieldSet(this, _commandId, _command2);
|
|
42666
42755
|
}
|
|
42667
42756
|
if (!customer) {
|
|
42668
42757
|
customer = {
|
|
@@ -42677,7 +42766,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42677
42766
|
}
|
|
42678
42767
|
this.customer = customer;
|
|
42679
42768
|
this.context.customer = customer;
|
|
42680
|
-
this
|
|
42769
|
+
spirits._classPrivateFieldSet(this, _personaId, persona);
|
|
42681
42770
|
spirits._classPrivateFieldSet(this, _defaultLog, !!log);
|
|
42682
42771
|
}
|
|
42683
42772
|
|
|
@@ -42698,57 +42787,82 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42698
42787
|
while (1) switch (_context.prev = _context.next) {
|
|
42699
42788
|
case 0:
|
|
42700
42789
|
override = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
42701
|
-
if (!(override || !this
|
|
42702
|
-
_context.next =
|
|
42790
|
+
if (!(override || !spirits._classPrivateFieldGet(this, _app))) {
|
|
42791
|
+
_context.next = 9;
|
|
42703
42792
|
break;
|
|
42704
42793
|
}
|
|
42705
|
-
_context.
|
|
42706
|
-
|
|
42707
|
-
|
|
42708
|
-
|
|
42709
|
-
|
|
42710
|
-
|
|
42711
|
-
|
|
42794
|
+
_context.t0 = spirits._classPrivateFieldSet;
|
|
42795
|
+
_context.t1 = this;
|
|
42796
|
+
_context.t2 = _app;
|
|
42797
|
+
_context.next = 7;
|
|
42798
|
+
return spirits._classPrivateMethodGet(this, _loadApp, _loadApp2).call(this);
|
|
42799
|
+
case 7:
|
|
42800
|
+
_context.t3 = _context.sent;
|
|
42801
|
+
(0, _context.t0)(_context.t1, _context.t2, _context.t3);
|
|
42802
|
+
case 9:
|
|
42803
|
+
if (!(override || !spirits._classPrivateFieldGet(this, _project))) {
|
|
42804
|
+
_context.next = 17;
|
|
42712
42805
|
break;
|
|
42713
42806
|
}
|
|
42714
|
-
_context.
|
|
42807
|
+
_context.t4 = spirits._classPrivateFieldSet;
|
|
42808
|
+
_context.t5 = this;
|
|
42809
|
+
_context.t6 = _project;
|
|
42810
|
+
_context.next = 15;
|
|
42715
42811
|
return loadConfig({
|
|
42716
|
-
cwd: this
|
|
42717
|
-
src: this
|
|
42718
|
-
mode: this
|
|
42812
|
+
cwd: spirits._classPrivateFieldGet(this, _cwd),
|
|
42813
|
+
src: spirits._classPrivateFieldGet(this, _src),
|
|
42814
|
+
mode: spirits._classPrivateFieldGet(this, _mode)
|
|
42719
42815
|
});
|
|
42720
|
-
case
|
|
42721
|
-
|
|
42722
|
-
|
|
42723
|
-
|
|
42724
|
-
|
|
42816
|
+
case 15:
|
|
42817
|
+
_context.t7 = _context.sent;
|
|
42818
|
+
(0, _context.t4)(_context.t5, _context.t6, _context.t7);
|
|
42819
|
+
case 17:
|
|
42820
|
+
if (!spirits._classPrivateFieldGet(this, _commandId)) {
|
|
42821
|
+
_context.next = 26;
|
|
42822
|
+
break;
|
|
42823
|
+
}
|
|
42824
|
+
if (!(override || !spirits._classPrivateFieldGet(this, _commandId))) {
|
|
42825
|
+
_context.next = 26;
|
|
42826
|
+
break;
|
|
42827
|
+
}
|
|
42828
|
+
_context.t8 = spirits._classPrivateFieldSet;
|
|
42829
|
+
_context.t9 = this;
|
|
42830
|
+
_context.t10 = _command;
|
|
42831
|
+
_context.next = 24;
|
|
42832
|
+
return spirits._classPrivateMethodGet(this, _loadCommand, _loadCommand2).call(this, spirits._classPrivateFieldGet(this, _commandId));
|
|
42833
|
+
case 24:
|
|
42834
|
+
_context.t11 = _context.sent;
|
|
42835
|
+
(0, _context.t8)(_context.t9, _context.t10, _context.t11);
|
|
42836
|
+
case 26:
|
|
42837
|
+
if (override || !spirits._classPrivateFieldGet(this, _api)) {
|
|
42838
|
+
spirits._classPrivateFieldSet(this, _api, new build.Scout9Api(new build.Configuration({
|
|
42725
42839
|
apiKey: process.env.SCOUT9_API_KEY
|
|
42726
|
-
}));
|
|
42840
|
+
})));
|
|
42727
42841
|
}
|
|
42728
|
-
if (this
|
|
42729
|
-
_context.next =
|
|
42842
|
+
if (spirits._classPrivateFieldGet(this, _personaId)) {
|
|
42843
|
+
_context.next = 31;
|
|
42730
42844
|
break;
|
|
42731
42845
|
}
|
|
42732
|
-
this
|
|
42733
|
-
if (this
|
|
42734
|
-
_context.next =
|
|
42846
|
+
spirits._classPrivateFieldSet(this, _personaId, (_ref2 = spirits._classPrivateFieldGet(this, _project).persona || spirits._classPrivateFieldGet(this, _project).agents) === null || _ref2 === void 0 || (_ref2 = _ref2[0]) === null || _ref2 === void 0 ? void 0 : _ref2.id);
|
|
42847
|
+
if (spirits._classPrivateFieldGet(this, _personaId)) {
|
|
42848
|
+
_context.next = 31;
|
|
42735
42849
|
break;
|
|
42736
42850
|
}
|
|
42737
42851
|
throw new Error("No persona found in config, please specify a persona id");
|
|
42738
|
-
case
|
|
42739
|
-
this.conversation.$agent = this
|
|
42740
|
-
this.persona = (this
|
|
42741
|
-
return p.id === _this
|
|
42852
|
+
case 31:
|
|
42853
|
+
this.conversation.$agent = spirits._classPrivateFieldGet(this, _personaId);
|
|
42854
|
+
this.persona = (spirits._classPrivateFieldGet(this, _project).persona || spirits._classPrivateFieldGet(this, _project).agents).find(function (p) {
|
|
42855
|
+
return p.id === spirits._classPrivateFieldGet(_this, _personaId);
|
|
42742
42856
|
});
|
|
42743
42857
|
if (this.persona) {
|
|
42744
|
-
_context.next =
|
|
42858
|
+
_context.next = 35;
|
|
42745
42859
|
break;
|
|
42746
42860
|
}
|
|
42747
|
-
throw new Error("Could not find persona with id: ".concat(this
|
|
42748
|
-
case
|
|
42861
|
+
throw new Error("Could not find persona with id: ".concat(spirits._classPrivateFieldGet(this, _personaId), ", ensure your project is sync'd by running \"scout9 sync\" or you are using the correct persona id"));
|
|
42862
|
+
case 35:
|
|
42749
42863
|
this.context.agent = this.persona;
|
|
42750
|
-
this
|
|
42751
|
-
case
|
|
42864
|
+
spirits._classPrivateFieldSet(this, _loaded, true);
|
|
42865
|
+
case 37:
|
|
42752
42866
|
case "end":
|
|
42753
42867
|
return _context.stop();
|
|
42754
42868
|
}
|
|
@@ -42766,10 +42880,10 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42766
42880
|
}, {
|
|
42767
42881
|
key: "teardown",
|
|
42768
42882
|
value: function teardown() {
|
|
42769
|
-
this
|
|
42770
|
-
this
|
|
42771
|
-
this
|
|
42772
|
-
this
|
|
42883
|
+
spirits._classPrivateFieldSet(this, _loaded, false);
|
|
42884
|
+
spirits._classPrivateFieldSet(this, _api, null);
|
|
42885
|
+
spirits._classPrivateFieldSet(this, _project, null);
|
|
42886
|
+
spirits._classPrivateFieldSet(this, _app, null);
|
|
42773
42887
|
}
|
|
42774
42888
|
|
|
42775
42889
|
/**
|
|
@@ -42795,7 +42909,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42795
42909
|
while (1) switch (_context4.prev = _context4.next) {
|
|
42796
42910
|
case 0:
|
|
42797
42911
|
progress = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : spirits._classPrivateFieldGet(this, _defaultLog);
|
|
42798
|
-
if (this
|
|
42912
|
+
if (spirits._classPrivateFieldGet(this, _loaded)) {
|
|
42799
42913
|
_context4.next = 4;
|
|
42800
42914
|
break;
|
|
42801
42915
|
}
|
|
@@ -42831,7 +42945,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42831
42945
|
_context4.next = 11;
|
|
42832
42946
|
return spirits.Spirits.customer({
|
|
42833
42947
|
customer: this.customer,
|
|
42834
|
-
config: this
|
|
42948
|
+
config: spirits._classPrivateFieldGet(this, _project),
|
|
42835
42949
|
parser: function () {
|
|
42836
42950
|
var _parser = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee2(_msg, _lng) {
|
|
42837
42951
|
var detectableEntities;
|
|
@@ -42839,11 +42953,11 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42839
42953
|
while (1) switch (_context2.prev = _context2.next) {
|
|
42840
42954
|
case 0:
|
|
42841
42955
|
// @TODO can't do this for HUGE data sets
|
|
42842
|
-
detectableEntities = _this2
|
|
42956
|
+
detectableEntities = spirits._classPrivateFieldGet(_this2, _project).entities.filter(function (e) {
|
|
42843
42957
|
var _e$training, _e$definitions;
|
|
42844
42958
|
return ((_e$training = e.training) === null || _e$training === void 0 ? void 0 : _e$training.length) > 0 && ((_e$definitions = e.definitions) === null || _e$definitions === void 0 ? void 0 : _e$definitions.length) > 0;
|
|
42845
42959
|
});
|
|
42846
|
-
return _context2.abrupt("return", _this2
|
|
42960
|
+
return _context2.abrupt("return", spirits._classPrivateFieldGet(_this2, _api).parse({
|
|
42847
42961
|
message: _msg,
|
|
42848
42962
|
language: _lng,
|
|
42849
42963
|
entities: detectableEntities
|
|
@@ -42863,13 +42977,20 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42863
42977
|
}(),
|
|
42864
42978
|
workflow: function () {
|
|
42865
42979
|
var _workflow = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee3(event) {
|
|
42980
|
+
var _this2$conversation$$;
|
|
42866
42981
|
return spirits._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
42867
42982
|
while (1) switch (_context3.prev = _context3.next) {
|
|
42868
42983
|
case 0:
|
|
42869
42984
|
globalThis.SCOUT9 = spirits._objectSpread2(spirits._objectSpread2({}, event), {}, {
|
|
42870
|
-
$convo: _this2.conversation.$id
|
|
42985
|
+
$convo: (_this2$conversation$$ = _this2.conversation.$id) !== null && _this2$conversation$$ !== void 0 ? _this2$conversation$$ : 'test_convo'
|
|
42871
42986
|
});
|
|
42872
|
-
return _context3.abrupt("return", _this2._app(event))
|
|
42987
|
+
return _context3.abrupt("return", (spirits._classPrivateFieldGet(_this2, _command) ? spirits._classPrivateFieldGet(_this2, _command) : spirits._classPrivateFieldGet(_this2, _app))(event).then(function (response) {
|
|
42988
|
+
if ('toJSON' in response) {
|
|
42989
|
+
return response.toJSON();
|
|
42990
|
+
} else {
|
|
42991
|
+
return response;
|
|
42992
|
+
}
|
|
42993
|
+
}).then(macros.WorkflowResponseSchema.parse));
|
|
42873
42994
|
case 2:
|
|
42874
42995
|
case "end":
|
|
42875
42996
|
return _context3.stop();
|
|
@@ -42882,7 +43003,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42882
43003
|
return workflow;
|
|
42883
43004
|
}(),
|
|
42884
43005
|
generator: function generator(request) {
|
|
42885
|
-
return _this2
|
|
43006
|
+
return spirits._classPrivateFieldGet(_this2, _api).generate(request).then(function (_res) {
|
|
42886
43007
|
return _res.data;
|
|
42887
43008
|
});
|
|
42888
43009
|
},
|
|
@@ -42951,16 +43072,16 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42951
43072
|
while (1) switch (_context5.prev = _context5.next) {
|
|
42952
43073
|
case 0:
|
|
42953
43074
|
language = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 'en';
|
|
42954
|
-
if (this
|
|
43075
|
+
if (spirits._classPrivateFieldGet(this, _project)) {
|
|
42955
43076
|
_context5.next = 3;
|
|
42956
43077
|
break;
|
|
42957
43078
|
}
|
|
42958
43079
|
throw new Error("Config is not defined");
|
|
42959
43080
|
case 3:
|
|
42960
|
-
return _context5.abrupt("return", this
|
|
43081
|
+
return _context5.abrupt("return", spirits._classPrivateFieldGet(this, _api).parse({
|
|
42961
43082
|
message: message,
|
|
42962
43083
|
language: language,
|
|
42963
|
-
entities: this
|
|
43084
|
+
entities: spirits._classPrivateFieldGet(this, _project).entities
|
|
42964
43085
|
}).then(function (_res) {
|
|
42965
43086
|
return _res.data;
|
|
42966
43087
|
}));
|
|
@@ -42992,7 +43113,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42992
43113
|
while (1) switch (_context6.prev = _context6.next) {
|
|
42993
43114
|
case 0:
|
|
42994
43115
|
event = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
42995
|
-
if (this
|
|
43116
|
+
if (spirits._classPrivateFieldGet(this, _app)) {
|
|
42996
43117
|
_context6.next = 3;
|
|
42997
43118
|
break;
|
|
42998
43119
|
}
|
|
@@ -43001,7 +43122,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43001
43122
|
if (event.hasOwnProperty('message')) {
|
|
43002
43123
|
console.warn("WARNING: inserting a \"event.message\" will overwrite your \"message\" argument");
|
|
43003
43124
|
}
|
|
43004
|
-
return _context6.abrupt("return", this.
|
|
43125
|
+
return _context6.abrupt("return", spirits._classPrivateFieldGet(this, _app).call(this, spirits._objectSpread2(spirits._objectSpread2({}, createMockWorkflowEvent(message)), event)));
|
|
43005
43126
|
case 5:
|
|
43006
43127
|
case "end":
|
|
43007
43128
|
return _context6.stop();
|
|
@@ -43031,20 +43152,20 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43031
43152
|
return spirits._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
43032
43153
|
while (1) switch (_context7.prev = _context7.next) {
|
|
43033
43154
|
case 0:
|
|
43034
|
-
_ref3$personaId = _ref3.personaId, personaId = _ref3$personaId === void 0 ? this
|
|
43035
|
-
if (this
|
|
43155
|
+
_ref3$personaId = _ref3.personaId, personaId = _ref3$personaId === void 0 ? spirits._classPrivateFieldGet(this, _personaId) : _ref3$personaId, _ref3$conversation = _ref3.conversation, conversation = _ref3$conversation === void 0 ? {} : _ref3$conversation, _ref3$messages = _ref3.messages, messages = _ref3$messages === void 0 ? this.messages : _ref3$messages, _ref3$context = _ref3.context, context = _ref3$context === void 0 ? this.context : _ref3$context;
|
|
43156
|
+
if (spirits._classPrivateFieldGet(this, _api)) {
|
|
43036
43157
|
_context7.next = 3;
|
|
43037
43158
|
break;
|
|
43038
43159
|
}
|
|
43039
43160
|
throw new Error("Scout9 API is not loaded or found - make sure to run \".load()\" before calling \".generate()\"");
|
|
43040
43161
|
case 3:
|
|
43041
|
-
if (this
|
|
43162
|
+
if (spirits._classPrivateFieldGet(this, _project)) {
|
|
43042
43163
|
_context7.next = 5;
|
|
43043
43164
|
break;
|
|
43044
43165
|
}
|
|
43045
43166
|
throw new Error("Config is not defined - make sure to run \".load()\" before calling \".generate()\"");
|
|
43046
43167
|
case 5:
|
|
43047
|
-
persona = (this
|
|
43168
|
+
persona = (spirits._classPrivateFieldGet(this, _project).persona || spirits._classPrivateFieldGet(this, _project).agents).find(function (p) {
|
|
43048
43169
|
return p.id === personaId;
|
|
43049
43170
|
});
|
|
43050
43171
|
if (persona) {
|
|
@@ -43053,7 +43174,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43053
43174
|
}
|
|
43054
43175
|
throw new Error("Could not find persona with id: ".concat(personaId, ", ensure your project is sync'd by running \"scout9 sync\""));
|
|
43055
43176
|
case 8:
|
|
43056
|
-
return _context7.abrupt("return", this
|
|
43177
|
+
return _context7.abrupt("return", spirits._classPrivateFieldGet(this, _api).generate({
|
|
43057
43178
|
convo: spirits._objectSpread2(spirits._objectSpread2({
|
|
43058
43179
|
$customer: this.customer.id,
|
|
43059
43180
|
environment: this.conversation.environment,
|
|
@@ -43064,8 +43185,8 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43064
43185
|
messages: messages,
|
|
43065
43186
|
context: context,
|
|
43066
43187
|
persona: persona,
|
|
43067
|
-
llm: this
|
|
43068
|
-
pmt: this
|
|
43188
|
+
llm: spirits._classPrivateFieldGet(this, _project).llm,
|
|
43189
|
+
pmt: spirits._classPrivateFieldGet(this, _project).pmt
|
|
43069
43190
|
}).then(function (_res) {
|
|
43070
43191
|
return _res.data;
|
|
43071
43192
|
}));
|
|
@@ -43089,52 +43210,99 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43089
43210
|
set: function set(ctx) {
|
|
43090
43211
|
this.context = spirits._objectSpread2(spirits._objectSpread2({}, this.context), ctx);
|
|
43091
43212
|
}
|
|
43092
|
-
|
|
43093
|
-
/**
|
|
43094
|
-
* @private
|
|
43095
|
-
*/
|
|
43096
|
-
}, {
|
|
43097
|
-
key: "_loadApp",
|
|
43098
|
-
value: (function () {
|
|
43099
|
-
var _loadApp2 = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee8() {
|
|
43100
|
-
var paths, _paths, appFilePath;
|
|
43101
|
-
return spirits._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
43102
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
43103
|
-
case 0:
|
|
43104
|
-
paths = globSync("".concat(this._src, "/app.{ts,cjs,mjs,js}"), {
|
|
43105
|
-
cwd: this._cwd,
|
|
43106
|
-
absolute: true
|
|
43107
|
-
});
|
|
43108
|
-
if (!(paths.length === 0)) {
|
|
43109
|
-
_context8.next = 5;
|
|
43110
|
-
break;
|
|
43111
|
-
}
|
|
43112
|
-
throw new Error("Missing main project entry file ".concat(this._src, "/app.{js|ts|cjs|mjs}"));
|
|
43113
|
-
case 5:
|
|
43114
|
-
if (!(paths.length > 1)) {
|
|
43115
|
-
_context8.next = 7;
|
|
43116
|
-
break;
|
|
43117
|
-
}
|
|
43118
|
-
throw new Error("Multiple main project entry files found ".concat(this._src, "/app.{js|ts|cjs|mjs}"));
|
|
43119
|
-
case 7:
|
|
43120
|
-
_paths = spirits._slicedToArray(paths, 1), appFilePath = _paths[0];
|
|
43121
|
-
return _context8.abrupt("return", requireProjectFile(appFilePath).then(function (mod) {
|
|
43122
|
-
return mod["default"];
|
|
43123
|
-
}));
|
|
43124
|
-
case 9:
|
|
43125
|
-
case "end":
|
|
43126
|
-
return _context8.stop();
|
|
43127
|
-
}
|
|
43128
|
-
}, _callee8, this);
|
|
43129
|
-
}));
|
|
43130
|
-
function _loadApp() {
|
|
43131
|
-
return _loadApp2.apply(this, arguments);
|
|
43132
|
-
}
|
|
43133
|
-
return _loadApp;
|
|
43134
|
-
}())
|
|
43135
43213
|
}]);
|
|
43136
43214
|
return Scout9Test;
|
|
43137
43215
|
}();
|
|
43216
|
+
function _loadApp2() {
|
|
43217
|
+
return _loadApp3.apply(this, arguments);
|
|
43218
|
+
}
|
|
43219
|
+
function _loadApp3() {
|
|
43220
|
+
_loadApp3 = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee8() {
|
|
43221
|
+
var paths, _paths, appFilePath;
|
|
43222
|
+
return spirits._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
43223
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
43224
|
+
case 0:
|
|
43225
|
+
paths = globSync("".concat(spirits._classPrivateFieldGet(this, _src), "/app.{ts,cjs,mjs,js}"), {
|
|
43226
|
+
cwd: spirits._classPrivateFieldGet(this, _cwd),
|
|
43227
|
+
absolute: true
|
|
43228
|
+
});
|
|
43229
|
+
if (!(paths.length === 0)) {
|
|
43230
|
+
_context8.next = 5;
|
|
43231
|
+
break;
|
|
43232
|
+
}
|
|
43233
|
+
throw new Error("Missing main project entry file ".concat(spirits._classPrivateFieldGet(this, _src), "/app.{js|ts|cjs|mjs}"));
|
|
43234
|
+
case 5:
|
|
43235
|
+
if (!(paths.length > 1)) {
|
|
43236
|
+
_context8.next = 7;
|
|
43237
|
+
break;
|
|
43238
|
+
}
|
|
43239
|
+
throw new Error("Multiple main project entry files found ".concat(spirits._classPrivateFieldGet(this, _src), "/app.{js|ts|cjs|mjs}"));
|
|
43240
|
+
case 7:
|
|
43241
|
+
_paths = spirits._slicedToArray(paths, 1), appFilePath = _paths[0];
|
|
43242
|
+
return _context8.abrupt("return", requireProjectFile(appFilePath).then(function (mod) {
|
|
43243
|
+
return mod["default"];
|
|
43244
|
+
}));
|
|
43245
|
+
case 9:
|
|
43246
|
+
case "end":
|
|
43247
|
+
return _context8.stop();
|
|
43248
|
+
}
|
|
43249
|
+
}, _callee8, this);
|
|
43250
|
+
}));
|
|
43251
|
+
return _loadApp3.apply(this, arguments);
|
|
43252
|
+
}
|
|
43253
|
+
function _loadCommand2(_x8) {
|
|
43254
|
+
return _loadCommand3.apply(this, arguments);
|
|
43255
|
+
}
|
|
43256
|
+
function _loadCommand3() {
|
|
43257
|
+
_loadCommand3 = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee9(command) {
|
|
43258
|
+
var commandsDir, commandConfig, commandFilePath, mod;
|
|
43259
|
+
return spirits._regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
43260
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
43261
|
+
case 0:
|
|
43262
|
+
if (spirits._classPrivateFieldGet(this, _project)) {
|
|
43263
|
+
_context9.next = 2;
|
|
43264
|
+
break;
|
|
43265
|
+
}
|
|
43266
|
+
throw new Error("Must load #project before running #loadCommand");
|
|
43267
|
+
case 2:
|
|
43268
|
+
commandsDir = path$2.resolve(spirits._classPrivateFieldGet(this, _src), "./commands");
|
|
43269
|
+
commandConfig = spirits._classPrivateFieldGet(this, _project).commands.find(function (command) {
|
|
43270
|
+
return command.entity === command || command.path === command;
|
|
43271
|
+
});
|
|
43272
|
+
if (commandConfig) {
|
|
43273
|
+
_context9.next = 6;
|
|
43274
|
+
break;
|
|
43275
|
+
}
|
|
43276
|
+
throw new Error("Unable to find command \"".concat(command, "\""));
|
|
43277
|
+
case 6:
|
|
43278
|
+
commandFilePath = path$2.resolve(commandsDir, commandConfig.path);
|
|
43279
|
+
_context9.prev = 7;
|
|
43280
|
+
_context9.next = 10;
|
|
43281
|
+
return (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(commandFilePath);
|
|
43282
|
+
case 10:
|
|
43283
|
+
mod = _context9.sent;
|
|
43284
|
+
_context9.next = 16;
|
|
43285
|
+
break;
|
|
43286
|
+
case 13:
|
|
43287
|
+
_context9.prev = 13;
|
|
43288
|
+
_context9.t0 = _context9["catch"](7);
|
|
43289
|
+
throw new Error("Unable to resolve command ".concat(command, " at ").concat(commandFilePath));
|
|
43290
|
+
case 16:
|
|
43291
|
+
if (!(!mod || !mod["default"])) {
|
|
43292
|
+
_context9.next = 18;
|
|
43293
|
+
break;
|
|
43294
|
+
}
|
|
43295
|
+
throw new Error("Unable to run command ".concat(command, " at ").concat(commandFilePath, " - must return a default function that returns a WorkflowEvent payload"));
|
|
43296
|
+
case 18:
|
|
43297
|
+
return _context9.abrupt("return", mod["default"]);
|
|
43298
|
+
case 19:
|
|
43299
|
+
case "end":
|
|
43300
|
+
return _context9.stop();
|
|
43301
|
+
}
|
|
43302
|
+
}, _callee9, this, [[7, 13]]);
|
|
43303
|
+
}));
|
|
43304
|
+
return _loadCommand3.apply(this, arguments);
|
|
43305
|
+
}
|
|
43138
43306
|
|
|
43139
43307
|
exports.$ = $$1;
|
|
43140
43308
|
exports.MacroGlobals = MacroGlobals;
|