@scout9/app 1.0.0-alpha.0.6.5 → 1.0.0-alpha.0.6.7

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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var spirits = require("./spirits-985e6711.cjs");
3
+ var spirits = require("./spirits-9719ae4f.cjs");
4
4
  var require$$0$4 = require('util');
5
5
  var require$$0$3 = require('stream');
6
6
  var require$$1 = require('path');
@@ -21,7 +21,7 @@ var node_url = require('node:url');
21
21
  var node_events = require('node:events');
22
22
  var Stream = require('node:stream');
23
23
  var node_string_decoder = require('node:string_decoder');
24
- var macros = require("./macros-1a4fd407.cjs");
24
+ var macros = require("./macros-85a033b9.cjs");
25
25
  var readline = require('node:readline');
26
26
  var process$2 = require('node:process');
27
27
  var node_os = require('node:os');
@@ -35241,7 +35241,7 @@ function _loadUserPackageJson() {
35241
35241
  targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
35242
35242
  _context2.t0 = JSON;
35243
35243
  _context2.next = 10;
35244
- 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-6e60a643.js', document.baseURI).href))), 'utf-8');
35244
+ 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-197a7adb.js', document.baseURI).href))), 'utf-8');
35245
35245
  case 10:
35246
35246
  _context2.t1 = _context2.sent;
35247
35247
  pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var spirits = require("./spirits-985e6711.cjs");
4
- var dev = require("./dev-6e60a643.cjs");
5
- var macros = require("./macros-1a4fd407.cjs");
3
+ var spirits = require("./spirits-9719ae4f.cjs");
4
+ var dev = require("./dev-197a7adb.cjs");
5
+ var macros = require("./macros-85a033b9.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-13478cb7.cjs"); });
29486
+ } = await Promise.resolve().then(function () { return require("./multipart-parser-0d83aaf8.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-bf3ce1b6.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-1010a60c.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);
@@ -43176,7 +43176,7 @@ var ProjectFiles = /*#__PURE__*/function () {
43176
43176
  return ProjectFiles;
43177
43177
  }();
43178
43178
 
43179
- 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-bf3ce1b6.js', document.baseURI).href)));
43179
+ 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-1010a60c.js', document.baseURI).href)));
43180
43180
  var __dirname$1 = path__default["default"].dirname(__filename$1);
43181
43181
  function zipDirectory(source, out) {
43182
43182
  var archive = archiver$1('tar', {
@@ -43391,7 +43391,7 @@ function _buildApp() {
43391
43391
  case 11:
43392
43392
  _context4.t0 = JSON;
43393
43393
  _context4.next = 14;
43394
- 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-bf3ce1b6.js', document.baseURI).href))), 'utf-8');
43394
+ 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-1010a60c.js', document.baseURI).href))), 'utf-8');
43395
43395
  case 14:
43396
43396
  _context4.t1 = _context4.sent;
43397
43397
  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-bf3ce1b6.cjs");
6
- var dev = require("./dev-6e60a643.cjs");
7
- require("./spirits-985e6711.cjs");
8
- require("./macros-1a4fd407.cjs");
5
+ var index = require("./index-1010a60c.cjs");
6
+ var dev = require("./dev-197a7adb.cjs");
7
+ require("./spirits-9719ae4f.cjs");
8
+ require("./macros-85a033b9.cjs");
9
9
  require('fs');
10
10
  require('events');
11
11
  require('path');
@@ -4336,6 +4336,12 @@ var WorkflowEventSchema = z.object({
4336
4336
  description: 'Any developer notes to provide'
4337
4337
  }).optional()
4338
4338
  });
4339
+ var DirectMessageSchema = MessageSchema.partial().omit({
4340
+ id: true,
4341
+ entities: true,
4342
+ time: true,
4343
+ role: true
4344
+ });
4339
4345
 
4340
4346
  /**
4341
4347
  * The workflow response object slot
@@ -4347,16 +4353,27 @@ var WorkflowResponseSlotBaseSchema = z.object({
4347
4353
  }).optional(),
4348
4354
  instructions: InstructionSchema.optional(),
4349
4355
  removeInstructions: z.array(z.string()).optional(),
4350
- message: z.union([z.string(), z.object({
4351
- content: z.string(),
4352
- transform: z["boolean"]().optional()
4353
- })]).optional(),
4356
+ message: z.union([z.string(), DirectMessageSchema]).optional(),
4354
4357
  secondsDelay: z.number().optional(),
4355
4358
  scheduled: z.number().optional(),
4356
4359
  contextUpsert: ConversationContext.optional(),
4357
4360
  resetIntent: z["boolean"]().optional(),
4358
4361
  followup: FollowupSchema.optional()
4359
4362
  });
4363
+ var deleteSchema = z.object({
4364
+ entityType: z.string(),
4365
+ entityRecordId: z.string(),
4366
+ method: z.literal('delete')
4367
+ });
4368
+ var mutateSchema = z.object({
4369
+ entityType: z.string(),
4370
+ entityRecordId: z.string(),
4371
+ method: z.literal('mutate'),
4372
+ fields: z.record(z.union([z.string(), z.number(), z["boolean"](), z["null"](), z.literal('#remove'), z.literal('#delete')]))
4373
+ });
4374
+ var EntityContextUpsertSchema = z.discriminatedUnion('method', [deleteSchema, mutateSchema], {
4375
+ description: 'Metadata to provide a atomic transaction on a entity context record\n * @ingress auto/manual only'
4376
+ });
4360
4377
 
4361
4378
  /**
4362
4379
  * The workflow response object slot
@@ -4364,13 +4381,14 @@ var WorkflowResponseSlotBaseSchema = z.object({
4364
4381
  var WorkflowResponseSlotSchema = WorkflowResponseSlotBaseSchema.extend({
4365
4382
  anticipate: z.union([z.object({
4366
4383
  did: z.string({
4367
- definition: 'The prompt to check if true or false'
4384
+ description: 'The prompt to check if true or false'
4368
4385
  }),
4369
4386
  yes: WorkflowResponseSlotBaseSchema,
4370
4387
  no: WorkflowResponseSlotBaseSchema
4371
4388
  }), z.array(WorkflowResponseSlotBaseSchema.extend({
4372
4389
  keywords: z.array(z.string()).min(1).max(20)
4373
- }))]).optional()
4390
+ }))]).optional(),
4391
+ entityContextUpsert: z.array(EntityContextUpsertSchema).optional()
4374
4392
  });
4375
4393
 
4376
4394
  /**
@@ -4594,10 +4612,12 @@ exports.ConversationContext = ConversationContext;
4594
4612
  exports.ConversationSchema = ConversationSchema;
4595
4613
  exports.CustomerSchema = CustomerSchema;
4596
4614
  exports.CustomerValueSchema = CustomerValueSchema;
4615
+ exports.DirectMessageSchema = DirectMessageSchema;
4597
4616
  exports.EntitiesRootConfigurationSchema = EntitiesRootConfigurationSchema;
4598
4617
  exports.EntitiesRootProjectConfigurationSchema = EntitiesRootProjectConfigurationSchema;
4599
4618
  exports.EntityApiConfigurationSchema = EntityApiConfigurationSchema;
4600
4619
  exports.EntityConfigurationSchema = EntityConfigurationSchema;
4620
+ exports.EntityContextUpsertSchema = EntityContextUpsertSchema;
4601
4621
  exports.EntityRootProjectConfigurationSchema = EntityRootProjectConfigurationSchema;
4602
4622
  exports.FollowupBaseSchema = FollowupBaseSchema;
4603
4623
  exports.FollowupSchema = FollowupSchema;
@@ -2,9 +2,9 @@
2
2
 
3
3
  require('node:fs');
4
4
  require('node:path');
5
- var index = require("./index-bf3ce1b6.cjs");
6
- require("./spirits-985e6711.cjs");
7
- require("./dev-6e60a643.cjs");
5
+ var index = require("./index-1010a60c.cjs");
6
+ require("./spirits-9719ae4f.cjs");
7
+ require("./dev-197a7adb.cjs");
8
8
  require('util');
9
9
  require('stream');
10
10
  require('path');
@@ -23,7 +23,7 @@ require('node:url');
23
23
  require('node:events');
24
24
  require('node:stream');
25
25
  require('node:string_decoder');
26
- require("./macros-1a4fd407.cjs");
26
+ require("./macros-85a033b9.cjs");
27
27
  require('node:readline');
28
28
  require('node:process');
29
29
  require('node:os');
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-1a4fd407.cjs");
5
+ var macros = require("./macros-85a033b9.cjs");
6
6
 
7
7
 
8
8
 
@@ -19,10 +19,12 @@ exports.ConversationContext = macros.ConversationContext;
19
19
  exports.ConversationSchema = macros.ConversationSchema;
20
20
  exports.CustomerSchema = macros.CustomerSchema;
21
21
  exports.CustomerValueSchema = macros.CustomerValueSchema;
22
+ exports.DirectMessageSchema = macros.DirectMessageSchema;
22
23
  exports.EntitiesRootConfigurationSchema = macros.EntitiesRootConfigurationSchema;
23
24
  exports.EntitiesRootProjectConfigurationSchema = macros.EntitiesRootProjectConfigurationSchema;
24
25
  exports.EntityApiConfigurationSchema = macros.EntityApiConfigurationSchema;
25
26
  exports.EntityConfigurationSchema = macros.EntityConfigurationSchema;
27
+ exports.EntityContextUpsertSchema = macros.EntityContextUpsertSchema;
26
28
  exports.EntityRootProjectConfigurationSchema = macros.EntityRootProjectConfigurationSchema;
27
29
  exports.FollowupBaseSchema = macros.FollowupBaseSchema;
28
30
  exports.FollowupSchema = macros.FollowupSchema;
@@ -746,7 +746,7 @@ var Spirits = {
746
746
  while (1) switch (_context2.prev = _context2.next) {
747
747
  case 0:
748
748
  customer = input.customer, config = input.config, parser = input.parser, workflow = input.workflow, generator = input.generator, transformer = input.transformer, idGenerator = input.idGenerator, _input$progress = input.progress, progress = _input$progress === void 0 ? function (message, level, type, payload) {} : _input$progress, messageBefore = input.message, contextBefore = input.context, messagesBefore = input.messages, conversationBefore = input.conversation;
749
- conversation = input.conversation, messages = input.messages, context = input.context, message = input.message;
749
+ conversation = input.conversation, messages = input.messages, context = input.context, message = input.message; // Storing post process events here
750
750
  followup = [];
751
751
  entityContextUpsert = []; // 0. Setup Helpers
752
752
  updateConversation = function updateConversation(previousConversation, conversationUpdates) {
@@ -1021,7 +1021,7 @@ var Spirits = {
1021
1021
  _iterator.s();
1022
1022
  case 55:
1023
1023
  if ((_step = _iterator.n()).done) {
1024
- _context2.next = 116;
1024
+ _context2.next = 125;
1025
1025
  break;
1026
1026
  }
1027
1027
  _step$value = _step.value, forward = _step$value.forward, forwardNote = _step$value.forwardNote, instructions = _step$value.instructions, removeInstructions = _step$value.removeInstructions, manualMessage = _step$value.message, scheduled = _step$value.scheduled, resetIntent = _step$value.resetIntent, secondsDelay = _step$value.secondsDelay, contextUpsert = _step$value.contextUpsert, anticipate = _step$value.anticipate, slotFollowup = _step$value.followup, slotEntityContextUpsert = _step$value.entityContextUpsert;
@@ -1216,21 +1216,37 @@ var Spirits = {
1216
1216
  return _context2.finish(102);
1217
1217
  case 105:
1218
1218
  if (!manualMessage) {
1219
- _context2.next = 112;
1219
+ _context2.next = 121;
1220
1220
  break;
1221
1221
  }
1222
+ /** @type {import('@scout9/app').Message} */
1222
1223
  manualMessageObj = {
1223
- id: idGenerator('agent'),
1224
+ id: idGenerator('persona'),
1224
1225
  role: 'agent',
1225
- content: manualMessage,
1226
+ // @TODO switch role to persona
1227
+ content: '',
1226
1228
  time: new Date().toISOString()
1227
1229
  };
1228
- if (!(typeof manualMessage !== 'string')) {
1229
- _context2.next = 109;
1230
+ if (!(_typeof(manualMessage) === 'object')) {
1231
+ _context2.next = 113;
1230
1232
  break;
1231
1233
  }
1232
- throw new Error('Manual message must be of type "string"');
1233
- case 109:
1234
+ Object.assign(manualMessageObj, manualMessage);
1235
+ manualMessageObj.role = 'agent';
1236
+ manualMessageObj.time = new Date().toISOString();
1237
+ _context2.next = 118;
1238
+ break;
1239
+ case 113:
1240
+ if (!(typeof manualMessage === 'string')) {
1241
+ _context2.next = 117;
1242
+ break;
1243
+ }
1244
+ manualMessageObj.content = manualMessage;
1245
+ _context2.next = 118;
1246
+ break;
1247
+ case 117:
1248
+ throw new Error('Manual message must be of type "string" or "DirectMessage"');
1249
+ case 118:
1234
1250
  if (scheduled) {
1235
1251
  manualMessageObj.time = new Date(scheduled * 1000).toISOString();
1236
1252
  manualMessageObj.scheduled = manualMessageObj.time;
@@ -1242,7 +1258,7 @@ var Spirits = {
1242
1258
  }
1243
1259
  messages.push(manualMessageObj);
1244
1260
  progress('Added manual message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
1245
- case 112:
1261
+ case 121:
1246
1262
  if (contextUpsert) {
1247
1263
  context = updateContext(context, contextUpsert);
1248
1264
  progress('Upserted context', 'info', 'UPDATE_CONTEXT', contextUpsert);
@@ -1250,21 +1266,21 @@ var Spirits = {
1250
1266
  if (resetIntent) {
1251
1267
  resettedIntent = true;
1252
1268
  }
1253
- case 114:
1269
+ case 123:
1254
1270
  _context2.next = 55;
1255
1271
  break;
1256
- case 116:
1257
- _context2.next = 121;
1272
+ case 125:
1273
+ _context2.next = 130;
1258
1274
  break;
1259
- case 118:
1260
- _context2.prev = 118;
1275
+ case 127:
1276
+ _context2.prev = 127;
1261
1277
  _context2.t2 = _context2["catch"](53);
1262
1278
  _iterator.e(_context2.t2);
1263
- case 121:
1264
- _context2.prev = 121;
1279
+ case 130:
1280
+ _context2.prev = 130;
1265
1281
  _iterator.f();
1266
- return _context2.finish(121);
1267
- case 124:
1282
+ return _context2.finish(130);
1283
+ case 133:
1268
1284
  if (resettedIntent && !_forward) {
1269
1285
  conversation.intent = null;
1270
1286
  conversation.intentScore = null;
@@ -1283,16 +1299,16 @@ var Spirits = {
1283
1299
  // 4. Generate response
1284
1300
  // If conversation previously locked, don't generate
1285
1301
  if (input.conversation.locked) {
1286
- _context2.next = 172;
1302
+ _context2.next = 181;
1287
1303
  break;
1288
1304
  }
1289
1305
  if (!((!conversation.locked || !hasNoInstructions) && !!hasNoCustomMessage)) {
1290
- _context2.next = 139;
1306
+ _context2.next = 148;
1291
1307
  break;
1292
1308
  }
1293
- _context2.prev = 127;
1309
+ _context2.prev = 136;
1294
1310
  progress('Generating message', 'info', 'SET_PROCESSING', 'system');
1295
- _context2.next = 131;
1311
+ _context2.next = 140;
1296
1312
  return generator({
1297
1313
  messages: messages,
1298
1314
  persona: persona,
@@ -1300,7 +1316,7 @@ var Spirits = {
1300
1316
  llm: config.llm,
1301
1317
  pmt: config.pmt
1302
1318
  });
1303
- case 131:
1319
+ case 140:
1304
1320
  generatorPayload = _context2.sent;
1305
1321
  if (!generatorPayload.send) {
1306
1322
  progress('Generated response', 'failed', undefined, {
@@ -1339,29 +1355,29 @@ var Spirits = {
1339
1355
  }
1340
1356
  }
1341
1357
  }
1342
- _context2.next = 139;
1358
+ _context2.next = 148;
1343
1359
  break;
1344
- case 135:
1345
- _context2.prev = 135;
1346
- _context2.t3 = _context2["catch"](127);
1360
+ case 144:
1361
+ _context2.prev = 144;
1362
+ _context2.t3 = _context2["catch"](136);
1347
1363
  console.error("Locking conversation, error generating response: ".concat(_context2.t3.message));
1348
1364
  conversation = lockConversation(conversation, 'API: ' + _context2.t3.message);
1349
- case 139:
1365
+ case 148:
1350
1366
  if (!(messagesToTransform.length && transformer)) {
1351
- _context2.next = 171;
1367
+ _context2.next = 180;
1352
1368
  break;
1353
1369
  }
1354
- _context2.prev = 140;
1370
+ _context2.prev = 149;
1355
1371
  _iterator2 = _createForOfIteratorHelper(messagesToTransform);
1356
- _context2.prev = 142;
1372
+ _context2.prev = 151;
1357
1373
  _iterator2.s();
1358
- case 144:
1374
+ case 153:
1359
1375
  if ((_step2 = _iterator2.n()).done) {
1360
- _context2.next = 155;
1376
+ _context2.next = 164;
1361
1377
  break;
1362
1378
  }
1363
1379
  _step2.value;
1364
- _context2.next = 148;
1380
+ _context2.next = 157;
1365
1381
  return transformer({
1366
1382
  message: messagesToTransform,
1367
1383
  persona: persona,
@@ -1369,7 +1385,7 @@ var Spirits = {
1369
1385
  messages: messages,
1370
1386
  context: context
1371
1387
  });
1372
- case 148:
1388
+ case 157:
1373
1389
  transformResponse = _context2.sent;
1374
1390
  progress('Generated response', 'success', undefined, undefined);
1375
1391
  // Check if already had message
@@ -1389,36 +1405,36 @@ var Spirits = {
1389
1405
  });
1390
1406
  progress('Added agent message', 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
1391
1407
  }
1392
- case 153:
1393
- _context2.next = 144;
1408
+ case 162:
1409
+ _context2.next = 153;
1394
1410
  break;
1395
- case 155:
1396
- _context2.next = 160;
1411
+ case 164:
1412
+ _context2.next = 169;
1397
1413
  break;
1398
- case 157:
1399
- _context2.prev = 157;
1400
- _context2.t4 = _context2["catch"](142);
1414
+ case 166:
1415
+ _context2.prev = 166;
1416
+ _context2.t4 = _context2["catch"](151);
1401
1417
  _iterator2.e(_context2.t4);
1402
- case 160:
1403
- _context2.prev = 160;
1418
+ case 169:
1419
+ _context2.prev = 169;
1404
1420
  _iterator2.f();
1405
- return _context2.finish(160);
1406
- case 163:
1407
- _context2.next = 169;
1421
+ return _context2.finish(169);
1422
+ case 172:
1423
+ _context2.next = 178;
1408
1424
  break;
1409
- case 165:
1410
- _context2.prev = 165;
1411
- _context2.t5 = _context2["catch"](140);
1425
+ case 174:
1426
+ _context2.prev = 174;
1427
+ _context2.t5 = _context2["catch"](149);
1412
1428
  console.error("Locking conversation, error transforming response: ".concat(_context2.t5.message));
1413
1429
  conversation = lockConversation(conversation, 'API: ' + _context2.t5.message);
1414
- case 169:
1415
- _context2.next = 172;
1430
+ case 178:
1431
+ _context2.next = 181;
1416
1432
  break;
1417
- case 171:
1433
+ case 180:
1418
1434
  if (messagesToTransform.length) {
1419
1435
  console.warn("No transformer provided");
1420
1436
  }
1421
- case 172:
1437
+ case 181:
1422
1438
  progress('Parsing message', 'info', 'SET_PROCESSING', null);
1423
1439
  return _context2.abrupt("return", {
1424
1440
  conversation: {
@@ -1442,11 +1458,11 @@ var Spirits = {
1442
1458
  followup: followup,
1443
1459
  entityContextUpsert: entityContextUpsert
1444
1460
  });
1445
- case 174:
1461
+ case 183:
1446
1462
  case "end":
1447
1463
  return _context2.stop();
1448
1464
  }
1449
- }, _callee, null, [[53, 118, 121, 124], [90, 99, 102, 105], [127, 135], [140, 165], [142, 157, 160, 163]]);
1465
+ }, _callee, null, [[53, 127, 130, 133], [90, 99, 102, 105], [136, 144], [149, 174], [151, 166, 169, 172]]);
1450
1466
  }));
1451
1467
  function customer(_x) {
1452
1468
  return _customer.apply(this, arguments);
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-985e6711.cjs");
5
+ var spirits = require("./spirits-9719ae4f.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-6e60a643.cjs");
6
- require("./spirits-985e6711.cjs");
5
+ var dev = require("./dev-197a7adb.cjs");
6
+ require("./spirits-9719ae4f.cjs");
7
7
  require('util');
8
8
  require('stream');
9
9
  require('path');
@@ -24,7 +24,7 @@ require('node:url');
24
24
  require('node:events');
25
25
  require('node:stream');
26
26
  require('node:string_decoder');
27
- require("./macros-1a4fd407.cjs");
27
+ require("./macros-85a033b9.cjs");
28
28
  require('node:readline');
29
29
  require('node:process');
30
30
  require('node:os');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scout9/app",
3
- "version": "1.0.0-alpha.0.6.5",
3
+ "version": "1.0.0-alpha.0.6.7",
4
4
  "description": "Build and deploy your Scout9 app for SMS auto replies",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/public.d.ts CHANGED
@@ -589,7 +589,7 @@ export type Message = {
589
589
  intentScore?: (number | null) | undefined;
590
590
  /** How long to delay the message manually in seconds */
591
591
  delayInSeconds?: (number | null) | undefined;
592
- /** Entities related to the message */
592
+ /** Entities related to the message (gets set after the PMT transform) */
593
593
  entities?: EntityToken[] | null;
594
594
  /** If set to true, the PMT will not transform, message will be sent as is */
595
595
  ignoreTransform?: boolean;
@@ -690,19 +690,7 @@ export type AnticipateKeywords = WorkflowResponseSlotBase & {
690
690
 
691
691
  export type Anticipate = AnticipateDid | AnticipateKeywords[];
692
692
 
693
- export type DirectMessagePayload = {
694
- /**
695
- * The content
696
- */
697
- content: string;
698
-
699
- /**
700
- * If true, the PMT will transform the message into the owners own words. By default will send the message as is
701
- */
702
- transform?: boolean;
703
-
704
- mediaUrls?: string[];
705
- };
693
+ export type DirectMessage = Partial<Omit<Message, 'id' | 'entities' | 'time' | 'role'>>;
706
694
 
707
695
  /**
708
696
  * Workflow Response Slot, can use for both PMT workflow event and event macro runtimes
@@ -710,6 +698,7 @@ export type DirectMessagePayload = {
710
698
  export type WorkflowResponseSlotBase = {
711
699
  /** Forward input information of a conversation */
712
700
  forward?: Forward | undefined;
701
+
713
702
  /** Note to provide to the agent, recommend using forward object api instead */
714
703
  forwardNote?: string | undefined;
715
704
 
@@ -720,7 +709,7 @@ export type WorkflowResponseSlotBase = {
720
709
  removeInstructions?: string[] | undefined;
721
710
 
722
711
  /** If provided, sends a direct message to the user */
723
- message?: string | DirectMessagePayload | undefined;
712
+ message?: string | DirectMessage | undefined;
724
713
 
725
714
  /** Delays in seconds of instructions (if provided) to PMT and direct message (if provided) to user */
726
715
  secondsDelay?: number | undefined;
@@ -751,7 +740,6 @@ export type WorkflowResponseSlot = WorkflowResponseSlotBase & {
751
740
  */
752
741
  anticipate?: Anticipate | undefined;
753
742
 
754
-
755
743
  /**
756
744
  * If provided, it will propagate entity context to your Scout9 entity context store
757
745
  * @ingress auto/manual only
@@ -143,6 +143,8 @@ export const WorkflowEventSchema = z.object({
143
143
  note: z.string({description: 'Any developer notes to provide'}).optional()
144
144
  });
145
145
 
146
+ export const DirectMessageSchema = MessageSchema.partial().omit({id: true, entities: true, time: true, role: true})
147
+
146
148
  /**
147
149
  * The workflow response object slot
148
150
  */
@@ -152,10 +154,7 @@ export const WorkflowResponseSlotBaseSchema = z.object({
152
154
  .optional(),
153
155
  instructions: InstructionSchema.optional(),
154
156
  removeInstructions: z.array(z.string()).optional(),
155
- message: z.union([z.string(), z.object({
156
- content: z.string(),
157
- transform: z.boolean().optional()
158
- })]).optional(),
157
+ message: z.union([z.string(), DirectMessageSchema]).optional(),
159
158
  secondsDelay: z.number().optional(),
160
159
  scheduled: z.number().optional(),
161
160
  contextUpsert: ConversationContext.optional(),
@@ -163,20 +162,50 @@ export const WorkflowResponseSlotBaseSchema = z.object({
163
162
  followup: FollowupSchema.optional()
164
163
  });
165
164
 
165
+
166
+ const deleteSchema = z.object({
167
+ entityType: z.string(),
168
+ entityRecordId: z.string(),
169
+ method: z.literal('delete')
170
+ });
171
+
172
+ const mutateSchema = z.object({
173
+ entityType: z.string(),
174
+ entityRecordId: z.string(),
175
+ method: z.literal('mutate'),
176
+ fields: z.record(
177
+ z.union([
178
+ z.string(),
179
+ z.number(),
180
+ z.boolean(),
181
+ z.null(),
182
+ z.literal('#remove'),
183
+ z.literal('#delete')
184
+ ])
185
+ )
186
+ });
187
+
188
+ export const EntityContextUpsertSchema = z.discriminatedUnion('method', [
189
+ deleteSchema,
190
+ mutateSchema
191
+ ], {description: 'Metadata to provide a atomic transaction on a entity context record\n * @ingress auto/manual only'});
192
+
166
193
  /**
167
194
  * The workflow response object slot
168
195
  */
169
196
  export const WorkflowResponseSlotSchema = WorkflowResponseSlotBaseSchema.extend({
170
197
  anticipate: z.union([
171
198
  z.object({
172
- did: z.string({definition: 'The prompt to check if true or false'}),
199
+ did: z.string({description: 'The prompt to check if true or false'}),
173
200
  yes: WorkflowResponseSlotBaseSchema,
174
201
  no: WorkflowResponseSlotBaseSchema
175
202
  }),
176
203
  z.array(WorkflowResponseSlotBaseSchema.extend({
177
204
  keywords: z.array(z.string()).min(1).max(20)
178
205
  }))
179
- ]).optional()
206
+ ]).optional(),
207
+
208
+ entityContextUpsert: z.array(EntityContextUpsertSchema).optional()
180
209
  });
181
210
 
182
211
  /**