@scout9/app 1.0.0-alpha.0.4.8 → 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-332ccb5a.cjs → dev-5c6f5d76.cjs} +323 -153
- package/dist/{index-2d62ac36.cjs → index-45f6ee5e.cjs} +16 -10
- package/dist/index.cjs +5 -4
- package/dist/{macros-e4105c56.cjs → macros-2f21c706.cjs} +8 -1
- package/dist/{multipart-parser-948d98ce.cjs → multipart-parser-bac8efc8.cjs} +4 -4
- package/dist/schemas.cjs +3 -1
- package/dist/{spirits-5c9243a1.cjs → spirits-2ab4d673.cjs} +14 -2
- 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/macros/builder.js +6 -3
- package/src/runtime/schemas/conversation.js +1 -0
- package/src/runtime/schemas/workflow.js +7 -0
- package/src/testing-tools/dev.js +371 -360
- package/src/testing-tools/spirits.js +2 -2
- package/types/index.d.ts +625 -618
- 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
|
|
|
@@ -29939,7 +29939,7 @@ common.createRequestFunction = createRequestFunction;
|
|
|
29939
29939
|
var configuration = {};
|
|
29940
29940
|
|
|
29941
29941
|
var name$1 = "@scout9/admin";
|
|
29942
|
-
var version$2 = "1.0.0-alpha.0.0.
|
|
29942
|
+
var version$2 = "1.0.0-alpha.0.0.52";
|
|
29943
29943
|
var description$1 = "";
|
|
29944
29944
|
var main$2 = "./build/index.js";
|
|
29945
29945
|
var types$1 = "./build/index.d.ts";
|
|
@@ -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,62 +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
|
|
42654
|
-
this.context = context || {}
|
|
42737
|
+
spirits._classPrivateFieldSet(this, _cwd, cwd);
|
|
42738
|
+
spirits._classPrivateFieldSet(this, _src, src);
|
|
42739
|
+
spirits._classPrivateFieldSet(this, _mode, mode);
|
|
42740
|
+
this.context = spirits._objectSpread2(spirits._objectSpread2({}, context || {}), {}, {
|
|
42741
|
+
__no_cache: true
|
|
42742
|
+
});
|
|
42655
42743
|
this.conversation = conversation;
|
|
42656
42744
|
if (api) {
|
|
42657
|
-
this
|
|
42745
|
+
spirits._classPrivateFieldSet(this, _api, api);
|
|
42658
42746
|
}
|
|
42659
42747
|
if (app) {
|
|
42660
|
-
this
|
|
42748
|
+
spirits._classPrivateFieldSet(this, _app, app);
|
|
42661
42749
|
}
|
|
42662
42750
|
if (project) {
|
|
42663
|
-
this
|
|
42751
|
+
spirits._classPrivateFieldSet(this, _project, project);
|
|
42752
|
+
}
|
|
42753
|
+
if (_command2) {
|
|
42754
|
+
spirits._classPrivateFieldSet(this, _commandId, _command2);
|
|
42664
42755
|
}
|
|
42665
42756
|
if (!customer) {
|
|
42666
42757
|
customer = {
|
|
@@ -42675,7 +42766,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42675
42766
|
}
|
|
42676
42767
|
this.customer = customer;
|
|
42677
42768
|
this.context.customer = customer;
|
|
42678
|
-
this
|
|
42769
|
+
spirits._classPrivateFieldSet(this, _personaId, persona);
|
|
42679
42770
|
spirits._classPrivateFieldSet(this, _defaultLog, !!log);
|
|
42680
42771
|
}
|
|
42681
42772
|
|
|
@@ -42696,57 +42787,82 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42696
42787
|
while (1) switch (_context.prev = _context.next) {
|
|
42697
42788
|
case 0:
|
|
42698
42789
|
override = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
42699
|
-
if (!(override || !this
|
|
42700
|
-
_context.next =
|
|
42790
|
+
if (!(override || !spirits._classPrivateFieldGet(this, _app))) {
|
|
42791
|
+
_context.next = 9;
|
|
42701
42792
|
break;
|
|
42702
42793
|
}
|
|
42703
|
-
_context.
|
|
42704
|
-
|
|
42705
|
-
|
|
42706
|
-
|
|
42707
|
-
|
|
42708
|
-
|
|
42709
|
-
|
|
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;
|
|
42710
42805
|
break;
|
|
42711
42806
|
}
|
|
42712
|
-
_context.
|
|
42807
|
+
_context.t4 = spirits._classPrivateFieldSet;
|
|
42808
|
+
_context.t5 = this;
|
|
42809
|
+
_context.t6 = _project;
|
|
42810
|
+
_context.next = 15;
|
|
42713
42811
|
return loadConfig({
|
|
42714
|
-
cwd: this
|
|
42715
|
-
src: this
|
|
42716
|
-
mode: this
|
|
42812
|
+
cwd: spirits._classPrivateFieldGet(this, _cwd),
|
|
42813
|
+
src: spirits._classPrivateFieldGet(this, _src),
|
|
42814
|
+
mode: spirits._classPrivateFieldGet(this, _mode)
|
|
42717
42815
|
});
|
|
42718
|
-
case
|
|
42719
|
-
|
|
42720
|
-
|
|
42721
|
-
|
|
42722
|
-
|
|
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({
|
|
42723
42839
|
apiKey: process.env.SCOUT9_API_KEY
|
|
42724
|
-
}));
|
|
42840
|
+
})));
|
|
42725
42841
|
}
|
|
42726
|
-
if (this
|
|
42727
|
-
_context.next =
|
|
42842
|
+
if (spirits._classPrivateFieldGet(this, _personaId)) {
|
|
42843
|
+
_context.next = 31;
|
|
42728
42844
|
break;
|
|
42729
42845
|
}
|
|
42730
|
-
this
|
|
42731
|
-
if (this
|
|
42732
|
-
_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;
|
|
42733
42849
|
break;
|
|
42734
42850
|
}
|
|
42735
42851
|
throw new Error("No persona found in config, please specify a persona id");
|
|
42736
|
-
case
|
|
42737
|
-
this.conversation.$agent = this
|
|
42738
|
-
this.persona = (this
|
|
42739
|
-
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);
|
|
42740
42856
|
});
|
|
42741
42857
|
if (this.persona) {
|
|
42742
|
-
_context.next =
|
|
42858
|
+
_context.next = 35;
|
|
42743
42859
|
break;
|
|
42744
42860
|
}
|
|
42745
|
-
throw new Error("Could not find persona with id: ".concat(this
|
|
42746
|
-
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:
|
|
42747
42863
|
this.context.agent = this.persona;
|
|
42748
|
-
this
|
|
42749
|
-
case
|
|
42864
|
+
spirits._classPrivateFieldSet(this, _loaded, true);
|
|
42865
|
+
case 37:
|
|
42750
42866
|
case "end":
|
|
42751
42867
|
return _context.stop();
|
|
42752
42868
|
}
|
|
@@ -42764,10 +42880,10 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42764
42880
|
}, {
|
|
42765
42881
|
key: "teardown",
|
|
42766
42882
|
value: function teardown() {
|
|
42767
|
-
this
|
|
42768
|
-
this
|
|
42769
|
-
this
|
|
42770
|
-
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);
|
|
42771
42887
|
}
|
|
42772
42888
|
|
|
42773
42889
|
/**
|
|
@@ -42793,7 +42909,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42793
42909
|
while (1) switch (_context4.prev = _context4.next) {
|
|
42794
42910
|
case 0:
|
|
42795
42911
|
progress = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : spirits._classPrivateFieldGet(this, _defaultLog);
|
|
42796
|
-
if (this
|
|
42912
|
+
if (spirits._classPrivateFieldGet(this, _loaded)) {
|
|
42797
42913
|
_context4.next = 4;
|
|
42798
42914
|
break;
|
|
42799
42915
|
}
|
|
@@ -42829,7 +42945,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42829
42945
|
_context4.next = 11;
|
|
42830
42946
|
return spirits.Spirits.customer({
|
|
42831
42947
|
customer: this.customer,
|
|
42832
|
-
config: this
|
|
42948
|
+
config: spirits._classPrivateFieldGet(this, _project),
|
|
42833
42949
|
parser: function () {
|
|
42834
42950
|
var _parser = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee2(_msg, _lng) {
|
|
42835
42951
|
var detectableEntities;
|
|
@@ -42837,11 +42953,11 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42837
42953
|
while (1) switch (_context2.prev = _context2.next) {
|
|
42838
42954
|
case 0:
|
|
42839
42955
|
// @TODO can't do this for HUGE data sets
|
|
42840
|
-
detectableEntities = _this2
|
|
42956
|
+
detectableEntities = spirits._classPrivateFieldGet(_this2, _project).entities.filter(function (e) {
|
|
42841
42957
|
var _e$training, _e$definitions;
|
|
42842
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;
|
|
42843
42959
|
});
|
|
42844
|
-
return _context2.abrupt("return", _this2
|
|
42960
|
+
return _context2.abrupt("return", spirits._classPrivateFieldGet(_this2, _api).parse({
|
|
42845
42961
|
message: _msg,
|
|
42846
42962
|
language: _lng,
|
|
42847
42963
|
entities: detectableEntities
|
|
@@ -42861,13 +42977,20 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42861
42977
|
}(),
|
|
42862
42978
|
workflow: function () {
|
|
42863
42979
|
var _workflow = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee3(event) {
|
|
42980
|
+
var _this2$conversation$$;
|
|
42864
42981
|
return spirits._regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
42865
42982
|
while (1) switch (_context3.prev = _context3.next) {
|
|
42866
42983
|
case 0:
|
|
42867
42984
|
globalThis.SCOUT9 = spirits._objectSpread2(spirits._objectSpread2({}, event), {}, {
|
|
42868
|
-
$convo: _this2.conversation.$id
|
|
42985
|
+
$convo: (_this2$conversation$$ = _this2.conversation.$id) !== null && _this2$conversation$$ !== void 0 ? _this2$conversation$$ : 'test_convo'
|
|
42869
42986
|
});
|
|
42870
|
-
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));
|
|
42871
42994
|
case 2:
|
|
42872
42995
|
case "end":
|
|
42873
42996
|
return _context3.stop();
|
|
@@ -42880,7 +43003,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42880
43003
|
return workflow;
|
|
42881
43004
|
}(),
|
|
42882
43005
|
generator: function generator(request) {
|
|
42883
|
-
return _this2
|
|
43006
|
+
return spirits._classPrivateFieldGet(_this2, _api).generate(request).then(function (_res) {
|
|
42884
43007
|
return _res.data;
|
|
42885
43008
|
});
|
|
42886
43009
|
},
|
|
@@ -42949,16 +43072,16 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42949
43072
|
while (1) switch (_context5.prev = _context5.next) {
|
|
42950
43073
|
case 0:
|
|
42951
43074
|
language = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 'en';
|
|
42952
|
-
if (this
|
|
43075
|
+
if (spirits._classPrivateFieldGet(this, _project)) {
|
|
42953
43076
|
_context5.next = 3;
|
|
42954
43077
|
break;
|
|
42955
43078
|
}
|
|
42956
43079
|
throw new Error("Config is not defined");
|
|
42957
43080
|
case 3:
|
|
42958
|
-
return _context5.abrupt("return", this
|
|
43081
|
+
return _context5.abrupt("return", spirits._classPrivateFieldGet(this, _api).parse({
|
|
42959
43082
|
message: message,
|
|
42960
43083
|
language: language,
|
|
42961
|
-
entities: this
|
|
43084
|
+
entities: spirits._classPrivateFieldGet(this, _project).entities
|
|
42962
43085
|
}).then(function (_res) {
|
|
42963
43086
|
return _res.data;
|
|
42964
43087
|
}));
|
|
@@ -42990,7 +43113,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42990
43113
|
while (1) switch (_context6.prev = _context6.next) {
|
|
42991
43114
|
case 0:
|
|
42992
43115
|
event = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
42993
|
-
if (this
|
|
43116
|
+
if (spirits._classPrivateFieldGet(this, _app)) {
|
|
42994
43117
|
_context6.next = 3;
|
|
42995
43118
|
break;
|
|
42996
43119
|
}
|
|
@@ -42999,7 +43122,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
42999
43122
|
if (event.hasOwnProperty('message')) {
|
|
43000
43123
|
console.warn("WARNING: inserting a \"event.message\" will overwrite your \"message\" argument");
|
|
43001
43124
|
}
|
|
43002
|
-
return _context6.abrupt("return", this.
|
|
43125
|
+
return _context6.abrupt("return", spirits._classPrivateFieldGet(this, _app).call(this, spirits._objectSpread2(spirits._objectSpread2({}, createMockWorkflowEvent(message)), event)));
|
|
43003
43126
|
case 5:
|
|
43004
43127
|
case "end":
|
|
43005
43128
|
return _context6.stop();
|
|
@@ -43029,20 +43152,20 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43029
43152
|
return spirits._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
43030
43153
|
while (1) switch (_context7.prev = _context7.next) {
|
|
43031
43154
|
case 0:
|
|
43032
|
-
_ref3$personaId = _ref3.personaId, personaId = _ref3$personaId === void 0 ? this
|
|
43033
|
-
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)) {
|
|
43034
43157
|
_context7.next = 3;
|
|
43035
43158
|
break;
|
|
43036
43159
|
}
|
|
43037
43160
|
throw new Error("Scout9 API is not loaded or found - make sure to run \".load()\" before calling \".generate()\"");
|
|
43038
43161
|
case 3:
|
|
43039
|
-
if (this
|
|
43162
|
+
if (spirits._classPrivateFieldGet(this, _project)) {
|
|
43040
43163
|
_context7.next = 5;
|
|
43041
43164
|
break;
|
|
43042
43165
|
}
|
|
43043
43166
|
throw new Error("Config is not defined - make sure to run \".load()\" before calling \".generate()\"");
|
|
43044
43167
|
case 5:
|
|
43045
|
-
persona = (this
|
|
43168
|
+
persona = (spirits._classPrivateFieldGet(this, _project).persona || spirits._classPrivateFieldGet(this, _project).agents).find(function (p) {
|
|
43046
43169
|
return p.id === personaId;
|
|
43047
43170
|
});
|
|
43048
43171
|
if (persona) {
|
|
@@ -43051,7 +43174,7 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43051
43174
|
}
|
|
43052
43175
|
throw new Error("Could not find persona with id: ".concat(personaId, ", ensure your project is sync'd by running \"scout9 sync\""));
|
|
43053
43176
|
case 8:
|
|
43054
|
-
return _context7.abrupt("return", this
|
|
43177
|
+
return _context7.abrupt("return", spirits._classPrivateFieldGet(this, _api).generate({
|
|
43055
43178
|
convo: spirits._objectSpread2(spirits._objectSpread2({
|
|
43056
43179
|
$customer: this.customer.id,
|
|
43057
43180
|
environment: this.conversation.environment,
|
|
@@ -43062,8 +43185,8 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43062
43185
|
messages: messages,
|
|
43063
43186
|
context: context,
|
|
43064
43187
|
persona: persona,
|
|
43065
|
-
llm: this
|
|
43066
|
-
pmt: this
|
|
43188
|
+
llm: spirits._classPrivateFieldGet(this, _project).llm,
|
|
43189
|
+
pmt: spirits._classPrivateFieldGet(this, _project).pmt
|
|
43067
43190
|
}).then(function (_res) {
|
|
43068
43191
|
return _res.data;
|
|
43069
43192
|
}));
|
|
@@ -43087,52 +43210,99 @@ var Scout9Test = /*#__PURE__*/function () {
|
|
|
43087
43210
|
set: function set(ctx) {
|
|
43088
43211
|
this.context = spirits._objectSpread2(spirits._objectSpread2({}, this.context), ctx);
|
|
43089
43212
|
}
|
|
43090
|
-
|
|
43091
|
-
/**
|
|
43092
|
-
* @private
|
|
43093
|
-
*/
|
|
43094
|
-
}, {
|
|
43095
|
-
key: "_loadApp",
|
|
43096
|
-
value: (function () {
|
|
43097
|
-
var _loadApp2 = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee8() {
|
|
43098
|
-
var paths, _paths, appFilePath;
|
|
43099
|
-
return spirits._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
43100
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
43101
|
-
case 0:
|
|
43102
|
-
paths = globSync("".concat(this._src, "/app.{ts,cjs,mjs,js}"), {
|
|
43103
|
-
cwd: this._cwd,
|
|
43104
|
-
absolute: true
|
|
43105
|
-
});
|
|
43106
|
-
if (!(paths.length === 0)) {
|
|
43107
|
-
_context8.next = 5;
|
|
43108
|
-
break;
|
|
43109
|
-
}
|
|
43110
|
-
throw new Error("Missing main project entry file ".concat(this._src, "/app.{js|ts|cjs|mjs}"));
|
|
43111
|
-
case 5:
|
|
43112
|
-
if (!(paths.length > 1)) {
|
|
43113
|
-
_context8.next = 7;
|
|
43114
|
-
break;
|
|
43115
|
-
}
|
|
43116
|
-
throw new Error("Multiple main project entry files found ".concat(this._src, "/app.{js|ts|cjs|mjs}"));
|
|
43117
|
-
case 7:
|
|
43118
|
-
_paths = spirits._slicedToArray(paths, 1), appFilePath = _paths[0];
|
|
43119
|
-
return _context8.abrupt("return", requireProjectFile(appFilePath).then(function (mod) {
|
|
43120
|
-
return mod["default"];
|
|
43121
|
-
}));
|
|
43122
|
-
case 9:
|
|
43123
|
-
case "end":
|
|
43124
|
-
return _context8.stop();
|
|
43125
|
-
}
|
|
43126
|
-
}, _callee8, this);
|
|
43127
|
-
}));
|
|
43128
|
-
function _loadApp() {
|
|
43129
|
-
return _loadApp2.apply(this, arguments);
|
|
43130
|
-
}
|
|
43131
|
-
return _loadApp;
|
|
43132
|
-
}())
|
|
43133
43213
|
}]);
|
|
43134
43214
|
return Scout9Test;
|
|
43135
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
|
+
}
|
|
43136
43306
|
|
|
43137
43307
|
exports.$ = $$1;
|
|
43138
43308
|
exports.MacroGlobals = MacroGlobals;
|