@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.
@@ -3,7 +3,6 @@
3
3
  * @property {string} id
4
4
  */
5
5
 
6
-
7
6
  /**
8
7
  * Represents a change with before and after states of a given type.
9
8
  * @template Type The type of the before and after properties.
@@ -138,6 +137,8 @@ export const Spirits = {
138
137
  conversation: conversationBefore
139
138
  } = input;
140
139
  let {conversation, messages, context, message} = input;
140
+
141
+ // Storing post process events here
141
142
  const followup = [];
142
143
  const entityContextUpsert = [];
143
144
 
@@ -521,15 +522,24 @@ export const Spirits = {
521
522
  }
522
523
 
523
524
  if (manualMessage) {
525
+
526
+ /** @type {import('@scout9/app').Message} */
524
527
  let manualMessageObj = {
525
- id: idGenerator('agent'),
526
- role: 'agent',
527
- content: manualMessage,
528
+ id: idGenerator('persona'),
529
+ role: 'agent', // @TODO switch role to persona
530
+ content: '',
528
531
  time: new Date().toISOString()
529
532
  };
530
- if (typeof manualMessage !== 'string') {
531
- throw new Error('Manual message must be of type "string"');
533
+ if (typeof manualMessage === 'object') {
534
+ Object.assign(manualMessageObj, manualMessage);
535
+ manualMessageObj.role = 'agent';
536
+ manualMessageObj.time = new Date().toISOString();
537
+ } else if (typeof manualMessage === 'string') {
538
+ manualMessageObj.content = manualMessage;
539
+ } else {
540
+ throw new Error('Manual message must be of type "string" or "DirectMessage"');
532
541
  }
542
+
533
543
  if (scheduled) {
534
544
  manualMessageObj.time = new Date(scheduled * 1000).toISOString();
535
545
  manualMessageObj.scheduled = manualMessageObj.time;