@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.
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var spirits = require("./spirits-5c9243a1.cjs");
4
- var dev = require("./dev-332ccb5a.cjs");
5
- var macros = require("./macros-e4105c56.cjs");
3
+ var spirits = require("./spirits-2ab4d673.cjs");
4
+ var dev = require("./dev-5c6f5d76.cjs");
5
+ var macros = require("./macros-2f21c706.cjs");
6
6
  var require$$0 = require('fs');
7
7
  var require$$2$1 = require('events');
8
8
  var require$$1 = require('path');
@@ -29483,7 +29483,7 @@ class Body {
29483
29483
  }
29484
29484
  const {
29485
29485
  toFormData
29486
- } = await Promise.resolve().then(function () { return require("./multipart-parser-948d98ce.cjs"); });
29486
+ } = await Promise.resolve().then(function () { return require("./multipart-parser-bac8efc8.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-2d62ac36.js', document.baseURI).href))), 'utf-8');
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-45f6ee5e.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);
@@ -42011,6 +42011,7 @@ function did(_x) {
42011
42011
  */
42012
42012
  function _did() {
42013
42013
  _did = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee(prompt) {
42014
+ var _event$context;
42014
42015
  var convoId, event, _yield$Scout9Api$did$, value;
42015
42016
  return spirits._regeneratorRuntime().wrap(function _callee$(_context2) {
42016
42017
  while (1) switch (_context2.prev = _context2.next) {
@@ -42031,7 +42032,8 @@ function _did() {
42031
42032
  })).did(processPayload({
42032
42033
  prompt: prompt,
42033
42034
  convoId: convoId,
42034
- event: event
42035
+ event: event,
42036
+ cache: !((_event$context = event.context) !== null && _event$context !== void 0 && _event$context.__no_cache)
42035
42037
  })).then(handleAxiosResponse)["catch"](function (err) {
42036
42038
  console.error('Error in did macro', err);
42037
42039
  throw err;
@@ -42076,6 +42078,7 @@ function does(_x2) {
42076
42078
  */
42077
42079
  function _does() {
42078
42080
  _does = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee2(prompt) {
42081
+ var _event$context2;
42079
42082
  var relation,
42080
42083
  convoId,
42081
42084
  event,
@@ -42103,7 +42106,8 @@ function _does() {
42103
42106
  prompt: prompt,
42104
42107
  convoId: convoId,
42105
42108
  role: relation,
42106
- event: event
42109
+ event: event,
42110
+ cache: !((_event$context2 = event.context) !== null && _event$context2 !== void 0 && _event$context2.__no_cache)
42107
42111
  })).then(handleAxiosResponse)["catch"](function (err) {
42108
42112
  console.error('Error in did macro', err);
42109
42113
  throw err;
@@ -42125,6 +42129,7 @@ function context(_x3, _x4) {
42125
42129
  }
42126
42130
  function _context() {
42127
42131
  _context = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee3(prompt, examples) {
42132
+ var _event$context3;
42128
42133
  var convoId, event, _yield$Scout9Api$capt, value;
42129
42134
  return spirits._regeneratorRuntime().wrap(function _callee3$(_context4) {
42130
42135
  while (1) switch (_context4.prev = _context4.next) {
@@ -42146,7 +42151,8 @@ function _context() {
42146
42151
  prompt: prompt,
42147
42152
  examples: examples,
42148
42153
  convoId: convoId,
42149
- event: event
42154
+ event: event,
42155
+ cache: !((_event$context3 = event.context) !== null && _event$context3 !== void 0 && _event$context3.__no_cache)
42150
42156
  })).then(handleAxiosResponse)["catch"](function (err) {
42151
42157
  console.error('Error in context macro', err);
42152
42158
  throw err;
@@ -43158,7 +43164,7 @@ var ProjectFiles = /*#__PURE__*/function () {
43158
43164
  return ProjectFiles;
43159
43165
  }();
43160
43166
 
43161
- 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-2d62ac36.js', document.baseURI).href)));
43167
+ 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-45f6ee5e.js', document.baseURI).href)));
43162
43168
  var __dirname$1 = path__default["default"].dirname(__filename$1);
43163
43169
  function zipDirectory(source, out) {
43164
43170
  var archive = archiver$1('tar', {
@@ -43373,7 +43379,7 @@ function _buildApp() {
43373
43379
  case 11:
43374
43380
  _context4.t0 = JSON;
43375
43381
  _context4.next = 14;
43376
- 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-2d62ac36.js', document.baseURI).href))), 'utf-8');
43382
+ 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-45f6ee5e.js', document.baseURI).href))), 'utf-8');
43377
43383
  case 14:
43378
43384
  _context4.t1 = _context4.sent;
43379
43385
  packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
package/dist/index.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require("./index-2d62ac36.cjs");
6
- var dev = require("./dev-332ccb5a.cjs");
7
- require("./spirits-5c9243a1.cjs");
8
- require("./macros-e4105c56.cjs");
5
+ var index = require("./index-45f6ee5e.cjs");
6
+ var dev = require("./dev-5c6f5d76.cjs");
7
+ require("./spirits-2ab4d673.cjs");
8
+ require("./macros-2f21c706.cjs");
9
9
  require('fs');
10
10
  require('events');
11
11
  require('path');
@@ -49,6 +49,7 @@ exports.does = index.does;
49
49
  exports.json = index.json;
50
50
  exports.run = index.run;
51
51
  exports.sendEvent = index.sendEvent;
52
+ exports.ProgressLogger = dev.ProgressLogger;
52
53
  exports.Scout9Test = dev.Scout9Test;
53
54
  exports.createMockAgent = dev.createMockAgent;
54
55
  exports.createMockConversation = dev.createMockConversation;
@@ -4131,7 +4131,7 @@ var PersonasConfigurationSchema = z.array(PersonaConfigurationSchema);
4131
4131
  var AgentsSchema = z.array(AgentSchema);
4132
4132
  var PersonasSchema = z.array(PersonaSchema);
4133
4133
 
4134
- var ConversationContext = z.record(z.union([z.string(), z.number(), z["boolean"](), z["null"](), z.array(z.union([z.string(), z.number(), z["boolean"](), z["null"]()]))]));
4134
+ var ConversationContext = z.record(z.union([z.any(), z.string(), z.number(), z["boolean"](), z["null"](), z.array(z.union([z.string(), z.number(), z["boolean"](), z["null"]()]))]));
4135
4135
  var ConversationAnticipateSchema = z.object({
4136
4136
  type: z["enum"](['did', 'literal', 'context'], {
4137
4137
  description: "Determines the runtime to address the next response"
@@ -4275,6 +4275,11 @@ var WorkflowConfigurationSchema = z.object({
4275
4275
  entity: zId('Workflow Folder', z.string())
4276
4276
  });
4277
4277
  var WorkflowsConfigurationSchema = z.array(WorkflowConfigurationSchema);
4278
+ var CommandSchema = z.object({
4279
+ path: z.string(),
4280
+ entity: zId('Command ID', z.string())
4281
+ });
4282
+ var CommandsSchema = z.array(CommandSchema);
4278
4283
  var IntentWorkflowEventSchema = z.object({
4279
4284
  current: z.string().nullable(),
4280
4285
  flow: z.array(z.string()),
@@ -4545,6 +4550,8 @@ exports.AgentConfigurationSchema = AgentConfigurationSchema;
4545
4550
  exports.AgentSchema = AgentSchema;
4546
4551
  exports.AgentsConfigurationSchema = AgentsConfigurationSchema;
4547
4552
  exports.AgentsSchema = AgentsSchema;
4553
+ exports.CommandSchema = CommandSchema;
4554
+ exports.CommandsSchema = CommandsSchema;
4548
4555
  exports.ContextExampleSchema = ContextExampleSchema;
4549
4556
  exports.ContextExampleWithTrainingDataSchema = ContextExampleWithTrainingDataSchema;
4550
4557
  exports.ConversationAnticipateSchema = ConversationAnticipateSchema;
@@ -2,9 +2,9 @@
2
2
 
3
3
  require('node:fs');
4
4
  require('node:path');
5
- var index = require("./index-2d62ac36.cjs");
6
- require("./spirits-5c9243a1.cjs");
7
- require("./dev-332ccb5a.cjs");
5
+ var index = require("./index-45f6ee5e.cjs");
6
+ require("./spirits-2ab4d673.cjs");
7
+ require("./dev-5c6f5d76.cjs");
8
8
  require('util');
9
9
  require('stream');
10
10
  require('path');
@@ -25,7 +25,7 @@ require('node:stream');
25
25
  require('node:string_decoder');
26
26
  require('node:readline');
27
27
  require('node:process');
28
- require("./macros-e4105c56.cjs");
28
+ require("./macros-2f21c706.cjs");
29
29
  require('node:os');
30
30
  require('fs/promises');
31
31
  require('constants');
package/dist/schemas.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var macros = require("./macros-e4105c56.cjs");
5
+ var macros = require("./macros-2f21c706.cjs");
6
6
 
7
7
 
8
8
 
@@ -10,6 +10,8 @@ exports.AgentConfigurationSchema = macros.AgentConfigurationSchema;
10
10
  exports.AgentSchema = macros.AgentSchema;
11
11
  exports.AgentsConfigurationSchema = macros.AgentsConfigurationSchema;
12
12
  exports.AgentsSchema = macros.AgentsSchema;
13
+ exports.CommandSchema = macros.CommandSchema;
14
+ exports.CommandsSchema = macros.CommandsSchema;
13
15
  exports.ContextExampleSchema = macros.ContextExampleSchema;
14
16
  exports.ContextExampleWithTrainingDataSchema = macros.ContextExampleWithTrainingDataSchema;
15
17
  exports.ConversationAnticipateSchema = macros.ConversationAnticipateSchema;
@@ -596,6 +596,12 @@ function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
596
596
  throw new TypeError("attempted to " + action + " private static field before its declaration");
597
597
  }
598
598
  }
599
+ function _classPrivateMethodGet(receiver, privateSet, fn) {
600
+ if (!privateSet.has(receiver)) {
601
+ throw new TypeError("attempted to get private field on non-instance");
602
+ }
603
+ return fn;
604
+ }
599
605
  function _checkPrivateRedeclaration(obj, privateCollection) {
600
606
  if (privateCollection.has(obj)) {
601
607
  throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -605,6 +611,10 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) {
605
611
  _checkPrivateRedeclaration(obj, privateMap);
606
612
  privateMap.set(obj, value);
607
613
  }
614
+ function _classPrivateMethodInitSpec(obj, privateSet) {
615
+ _checkPrivateRedeclaration(obj, privateSet);
616
+ privateSet.add(obj);
617
+ }
608
618
 
609
619
  var _excluded = ["keywords"];
610
620
  /**
@@ -1116,7 +1126,7 @@ var Spirits = {
1116
1126
  _context2.next = 84;
1117
1127
  break;
1118
1128
  case 79:
1119
- if (!(_typeof(instructions) === 'object' && 'content' in instructions && 'id' in instructions)) {
1129
+ if (!(_typeof(instructions) === 'object' && 'content' in instructions)) {
1120
1130
  _context2.next = 83;
1121
1131
  break;
1122
1132
  }
@@ -1124,7 +1134,7 @@ var Spirits = {
1124
1134
  _context2.next = 84;
1125
1135
  break;
1126
1136
  case 83:
1127
- throw new Error('SpiritsError: instructions must be a string or array or {content: "", id: ""}');
1137
+ throw new Error("SpiritsError: instructions must be a string or array or {content: \"<instruction>\"}, got: ".concat(JSON.stringify(instructions)));
1128
1138
  case 84:
1129
1139
  if (!removeInstructions) {
1130
1140
  _context2.next = 101;
@@ -1348,6 +1358,8 @@ exports._classCallCheck = _classCallCheck;
1348
1358
  exports._classPrivateFieldGet = _classPrivateFieldGet;
1349
1359
  exports._classPrivateFieldInitSpec = _classPrivateFieldInitSpec;
1350
1360
  exports._classPrivateFieldSet = _classPrivateFieldSet;
1361
+ exports._classPrivateMethodGet = _classPrivateMethodGet;
1362
+ exports._classPrivateMethodInitSpec = _classPrivateMethodInitSpec;
1351
1363
  exports._classStaticPrivateFieldSpecGet = _classStaticPrivateFieldSpecGet;
1352
1364
  exports._createClass = _createClass;
1353
1365
  exports._createForOfIteratorHelper = _createForOfIteratorHelper;
package/dist/spirits.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var spirits = require("./spirits-5c9243a1.cjs");
5
+ var spirits = require("./spirits-2ab4d673.cjs");
6
6
 
7
7
 
8
8
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dev = require("./dev-332ccb5a.cjs");
6
- require("./spirits-5c9243a1.cjs");
5
+ var dev = require("./dev-5c6f5d76.cjs");
6
+ require("./spirits-2ab4d673.cjs");
7
7
  require('util');
8
8
  require('stream');
9
9
  require('path');
@@ -26,7 +26,7 @@ require('node:stream');
26
26
  require('node:string_decoder');
27
27
  require('node:readline');
28
28
  require('node:process');
29
- require("./macros-e4105c56.cjs");
29
+ require("./macros-2f21c706.cjs");
30
30
  require('node:os');
31
31
  require('fs/promises');
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scout9/app",
3
- "version": "1.0.0-alpha.0.4.8",
3
+ "version": "1.0.0-alpha.0.5.0",
4
4
  "description": "Build and deploy your Scout9 app for SMS auto replies",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -85,8 +85,8 @@
85
85
  "zod-to-ts": "^1.2.0"
86
86
  },
87
87
  "dependencies": {
88
- "@scout9/admin": "^1.0.0-alpha.0.0.51",
89
- "@scout9/crm": "^1.0.0-alpha.0.0.4",
88
+ "@scout9/admin": "latest",
89
+ "@scout9/crm": "latest",
90
90
  "archiver": "^6.0.1",
91
91
  "body-parser": "^1.20.2",
92
92
  "compression": "^1.7.4",
@@ -0,0 +1,41 @@
1
+ import { globSync } from 'glob';
2
+ import { CommandsSchema } from '../../runtime/index.js';
3
+ import { basename, dirname } from 'node:path';
4
+
5
+
6
+ /**
7
+ * @returns {Promise<CommandConfiguration[]>}
8
+ */
9
+ export default async function loadCommandsConfig(
10
+ {
11
+ cwd = process.cwd(),
12
+ src = 'src',
13
+ cb = (message) => {}
14
+ } = {}
15
+ ) {
16
+ // const config = globSync(path.resolve(cwd, `${src}/workflows/**/workflow.{ts,js}`), {cwd, absolute: true})
17
+ const config = globSync(`${src}/commands/**/{index,command,*.command}.{ts,js}`, {cwd, absolute: false})
18
+ .map((path) => {
19
+
20
+ const dir = dirname(path);
21
+ let entity = basename(path).replace(/\..*$/, ''); // Removes any "."'s
22
+ if (!entity) {
23
+ throw new Error(`Invalid command path "${path}"`)
24
+ }
25
+ switch (entity) {
26
+ case "index":
27
+ case "command":
28
+ entity = basename(dir);
29
+ break;
30
+ }
31
+ return {
32
+ entity,
33
+ path: path.split(src + '/commands/')[1]
34
+ }
35
+ });
36
+
37
+ // Validate the config
38
+ CommandsSchema.parse(config);
39
+
40
+ return config;
41
+ }
@@ -7,6 +7,7 @@ import loadProjectConfig from './project.js';
7
7
  import loadWorkflowsConfig from './workflow.js';
8
8
  import { Scout9ProjectBuildConfigSchema } from '../../runtime/index.js';
9
9
  import { ProgressLogger } from '../../utils/index.js';
10
+ import loadCommandsConfig from './commands.js';
10
11
 
11
12
 
12
13
  export function loadEnvConfig({
@@ -47,6 +48,7 @@ export async function loadConfig({
47
48
  const entitiesConfig = await loadEntitiesConfig({cwd, src, logger, cb, deploying});
48
49
  const agentsConfig = await loadAgentConfig({cwd, src, logger, cb, deploying, dest});
49
50
  const workflowsConfig = await loadWorkflowsConfig({cwd, src, logger, deploying, cb});
51
+ const commandsConfig = await loadCommandsConfig({cwd, src, logger, deploying, cb});
50
52
 
51
53
  /**
52
54
  * @type {Scout9ProjectBuildConfig}
@@ -55,7 +57,8 @@ export async function loadConfig({
55
57
  ...baseProjectConfig,
56
58
  entities: entitiesConfig,
57
59
  agents: agentsConfig,
58
- workflows: workflowsConfig
60
+ workflows: workflowsConfig,
61
+ commands: commandsConfig
59
62
  };
60
63
 
61
64
  // Validate the config