@scout9/app 1.0.0-alpha.0.8.7 → 1.0.0-alpha.0.8.8
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-5557cad7.cjs → dev-b085bde6.cjs} +2 -2
- package/dist/{index-a444f2c0.cjs → index-02973b72.cjs} +6 -6
- package/dist/index.cjs +3 -3
- package/dist/{multipart-parser-92961749.cjs → multipart-parser-efb778dc.cjs} +3 -3
- package/dist/{spirits-011bdf25.cjs → spirits-2d7d7919.cjs} +46 -28
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +2 -2
- package/package.json +1 -1
- package/src/testing-tools/spirits.js +63 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
3
|
+
var spirits = require("./spirits-2d7d7919.cjs");
|
|
4
4
|
var require$$0$4 = require('util');
|
|
5
5
|
var require$$0$3 = require('stream');
|
|
6
6
|
var require$$1 = require('path');
|
|
@@ -35337,7 +35337,7 @@ function _loadUserPackageJson() {
|
|
|
35337
35337
|
targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
|
|
35338
35338
|
_context2.t0 = JSON;
|
|
35339
35339
|
_context2.next = 10;
|
|
35340
|
-
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-
|
|
35340
|
+
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-b085bde6.js', document.baseURI).href))), 'utf-8');
|
|
35341
35341
|
case 10:
|
|
35342
35342
|
_context2.t1 = _context2.sent;
|
|
35343
35343
|
pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var spirits = require("./spirits-
|
|
4
|
-
var dev = require("./dev-
|
|
3
|
+
var spirits = require("./spirits-2d7d7919.cjs");
|
|
4
|
+
var dev = require("./dev-b085bde6.cjs");
|
|
5
5
|
var macros = require("./macros-f62cceac.cjs");
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$2$1 = require('events');
|
|
@@ -29483,7 +29483,7 @@ class Body {
|
|
|
29483
29483
|
}
|
|
29484
29484
|
const {
|
|
29485
29485
|
toFormData
|
|
29486
|
-
} = await Promise.resolve().then(function () { return require("./multipart-parser-
|
|
29486
|
+
} = await Promise.resolve().then(function () { return require("./multipart-parser-efb778dc.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-
|
|
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-02973b72.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-
|
|
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-02973b72.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-
|
|
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-02973b72.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,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
var dev = require("./dev-
|
|
7
|
-
require("./spirits-
|
|
5
|
+
var index = require("./index-02973b72.cjs");
|
|
6
|
+
var dev = require("./dev-b085bde6.cjs");
|
|
7
|
+
require("./spirits-2d7d7919.cjs");
|
|
8
8
|
require("./macros-f62cceac.cjs");
|
|
9
9
|
require('fs');
|
|
10
10
|
require('events');
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var index = require("./index-
|
|
6
|
-
require("./spirits-
|
|
7
|
-
require("./dev-
|
|
5
|
+
var index = require("./index-02973b72.cjs");
|
|
6
|
+
require("./spirits-2d7d7919.cjs");
|
|
7
|
+
require("./dev-b085bde6.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
|
@@ -833,6 +833,7 @@ var Spirits = {
|
|
|
833
833
|
_generatorPayload$err,
|
|
834
834
|
_generatorPayload$err2,
|
|
835
835
|
_generatorPayload$err3,
|
|
836
|
+
_generatorPayload$mes,
|
|
836
837
|
agentMessages,
|
|
837
838
|
lastAgentMessage,
|
|
838
839
|
addedMessages,
|
|
@@ -1518,37 +1519,54 @@ var Spirits = {
|
|
|
1518
1519
|
agentMessages = messages.filter(function (m) {
|
|
1519
1520
|
return m.role === 'agent';
|
|
1520
1521
|
});
|
|
1521
|
-
lastAgentMessage = agentMessages[agentMessages.length - 1];
|
|
1522
|
-
addedMessages =
|
|
1523
|
-
|
|
1524
|
-
var
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1522
|
+
lastAgentMessage = agentMessages[agentMessages.length - 1]; // Build addedMessages from generatorPayload.messages
|
|
1523
|
+
addedMessages = ((_generatorPayload$mes = generatorPayload === null || generatorPayload === void 0 ? void 0 : generatorPayload.messages) !== null && _generatorPayload$mes !== void 0 ? _generatorPayload$mes : []).map(function (message) {
|
|
1524
|
+
// Normalize time → ISO string
|
|
1525
|
+
var t = message.time;
|
|
1526
|
+
var isoTime;
|
|
1527
|
+
if (typeof t === "string") {
|
|
1528
|
+
isoTime = t;
|
|
1529
|
+
} else if (t instanceof Date) {
|
|
1530
|
+
isoTime = t.toISOString();
|
|
1531
|
+
} else if (t && typeof t.toDate === "function") {
|
|
1532
|
+
// Firestore Timestamp
|
|
1533
|
+
isoTime = t.toDate().toISOString();
|
|
1534
|
+
} else {
|
|
1535
|
+
progress("Message \"".concat(message.content, "\" wasn't given a usable timestamp (").concat(JSON.stringify(t), "), defaulting to now"));
|
|
1536
|
+
isoTime = new Date().toISOString();
|
|
1536
1537
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1538
|
+
|
|
1539
|
+
// Base fields we guarantee
|
|
1540
|
+
var base = {
|
|
1540
1541
|
role: message.role,
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
mediaUrls: message.mediaUrls
|
|
1542
|
+
content: message.content,
|
|
1543
|
+
id: idGenerator(message.role),
|
|
1544
|
+
time: isoTime
|
|
1545
1545
|
};
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1546
|
+
|
|
1547
|
+
// Copy any other non-nullish fields without overwriting base
|
|
1548
|
+
return Object.entries(message).reduce(function (acc, _ref) {
|
|
1549
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1550
|
+
key = _ref2[0],
|
|
1551
|
+
value = _ref2[1];
|
|
1552
|
+
if (!Object.prototype.hasOwnProperty.call(acc, key) && value != null) {
|
|
1553
|
+
acc[key] = value;
|
|
1554
|
+
}
|
|
1555
|
+
return acc;
|
|
1556
|
+
}, base);
|
|
1557
|
+
})
|
|
1558
|
+
// De-dupe by content (change the key if you want stricter uniqueness)
|
|
1559
|
+
.reduce(function (acc, msg) {
|
|
1560
|
+
var key = String(msg.content); // e.g. `${msg.role}::${msg.content}` for stronger uniqueness
|
|
1561
|
+
if (!acc.seen.has(key)) {
|
|
1562
|
+
acc.seen.add(key);
|
|
1563
|
+
acc.items.push(msg);
|
|
1564
|
+
}
|
|
1565
|
+
return acc;
|
|
1566
|
+
}, {
|
|
1567
|
+
seen: new Set(),
|
|
1568
|
+
items: []
|
|
1569
|
+
}).items;
|
|
1552
1570
|
if (lastAgentMessage && lastAgentMessage.content && addedMessages.some(function (message) {
|
|
1553
1571
|
return message.content === lastAgentMessage.content;
|
|
1554
1572
|
})) {
|
package/dist/spirits.cjs
CHANGED
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dev = require("./dev-
|
|
6
|
-
require("./spirits-
|
|
5
|
+
var dev = require("./dev-b085bde6.cjs");
|
|
6
|
+
require("./spirits-2d7d7919.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('path');
|
package/package.json
CHANGED
|
@@ -142,7 +142,7 @@ export const Spirits = {
|
|
|
142
142
|
messages: messagesBefore,
|
|
143
143
|
conversation: conversationBefore
|
|
144
144
|
} = input;
|
|
145
|
-
let {conversation, messages, context, message} = input;
|
|
145
|
+
let { conversation, messages, context, message } = input;
|
|
146
146
|
|
|
147
147
|
// Storing post process events here
|
|
148
148
|
const followup = [];
|
|
@@ -177,7 +177,7 @@ export const Spirits = {
|
|
|
177
177
|
const lockConversation = (_conversation, reason) => {
|
|
178
178
|
return updateConversation(
|
|
179
179
|
_conversation,
|
|
180
|
-
{locked: true, lockedReason: conversation.lockedReason || reason || 'Unknown'}
|
|
180
|
+
{ locked: true, lockedReason: conversation.lockedReason || reason || 'Unknown' }
|
|
181
181
|
);
|
|
182
182
|
};
|
|
183
183
|
|
|
@@ -333,7 +333,7 @@ export const Spirits = {
|
|
|
333
333
|
'Updated conversation intent',
|
|
334
334
|
'info',
|
|
335
335
|
'UPDATE_CONVERSATION',
|
|
336
|
-
{intent: parsePayload.intent, intentScore: parsePayload?.intentScore || 0}
|
|
336
|
+
{ intent: parsePayload.intent, intentScore: parsePayload?.intentScore || 0 }
|
|
337
337
|
);
|
|
338
338
|
}
|
|
339
339
|
const oldKeyCount = Object.keys(context).length;
|
|
@@ -345,7 +345,7 @@ export const Spirits = {
|
|
|
345
345
|
conversation.locked = false;
|
|
346
346
|
conversation.lockAttempts = 0;
|
|
347
347
|
conversation.lockedReason = '';
|
|
348
|
-
progress('Reset lock', 'info', 'UPDATE_CONVERSATION', {locked: false, lockAttempts: 0, lockedReason: ''});
|
|
348
|
+
progress('Reset lock', 'info', 'UPDATE_CONVERSATION', { locked: false, lockAttempts: 0, lockedReason: '' });
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
const noNewContext = Object.keys(parsePayload.context).length === 0;
|
|
@@ -370,7 +370,7 @@ export const Spirits = {
|
|
|
370
370
|
|
|
371
371
|
// 3. Run the contextualizer
|
|
372
372
|
progress('Running contextualizer', 'info', 'SET_PROCESSING', 'system');
|
|
373
|
-
const newContextMessages = await contextualizer({conversation, messages});
|
|
373
|
+
const newContextMessages = await contextualizer({ conversation, messages });
|
|
374
374
|
for (const contextMessage of newContextMessages) {
|
|
375
375
|
if (!messages.find(mes => mes.content === contextMessage.content)) {
|
|
376
376
|
messages.push(contextMessage);
|
|
@@ -418,7 +418,7 @@ export const Spirits = {
|
|
|
418
418
|
conversation.lockAttempts = 0;
|
|
419
419
|
conversation.locked = false;
|
|
420
420
|
conversation.lockedReason = '';
|
|
421
|
-
progress('Reset lock', 'info', 'UPDATE_CONVERSATION', {lockAttempts: 0, locked: false, lockedReason: ''});
|
|
421
|
+
progress('Reset lock', 'info', 'UPDATE_CONVERSATION', { lockAttempts: 0, locked: false, lockedReason: '' });
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
let resettedIntent = false;
|
|
@@ -451,7 +451,7 @@ export const Spirits = {
|
|
|
451
451
|
const slots = {};
|
|
452
452
|
const map = [];
|
|
453
453
|
for (let i = 0; i < anticipate.length; i++) {
|
|
454
|
-
const {keywords, ..._slot} = anticipate[i];
|
|
454
|
+
const { keywords, ..._slot } = anticipate[i];
|
|
455
455
|
const slotId = `${i}`;
|
|
456
456
|
slots[slotId] = _slot;
|
|
457
457
|
map.push({
|
|
@@ -499,7 +499,7 @@ export const Spirits = {
|
|
|
499
499
|
_forward = forward;
|
|
500
500
|
_forwardNote = forwardNote;
|
|
501
501
|
if (typeof forward === 'string') {
|
|
502
|
-
updateConversation(conversation, {forwarded: forward});
|
|
502
|
+
updateConversation(conversation, { forwarded: forward });
|
|
503
503
|
messages.push({
|
|
504
504
|
id: idGenerator('sys'),
|
|
505
505
|
role: 'system',
|
|
@@ -508,7 +508,7 @@ export const Spirits = {
|
|
|
508
508
|
});
|
|
509
509
|
progress(`Forwarded to "${forward}"`, 'info', 'ADD_MESSAGE', messages[messages.length - 1]);
|
|
510
510
|
} else if (typeof forward === 'boolean') {
|
|
511
|
-
updateConversation(conversation, {forwarded: conversation.$agent});
|
|
511
|
+
updateConversation(conversation, { forwarded: conversation.$agent });
|
|
512
512
|
messages.push({
|
|
513
513
|
id: idGenerator('sys'),
|
|
514
514
|
role: 'system',
|
|
@@ -530,7 +530,7 @@ export const Spirits = {
|
|
|
530
530
|
'ADD_MESSAGE',
|
|
531
531
|
messages[messages.length - 1]
|
|
532
532
|
);
|
|
533
|
-
updateConversation(conversation, {forwarded: forward.to});
|
|
533
|
+
updateConversation(conversation, { forwarded: forward.to });
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
|
|
@@ -622,7 +622,7 @@ export const Spirits = {
|
|
|
622
622
|
'Reset conversation intent',
|
|
623
623
|
'info',
|
|
624
624
|
'UPDATE_CONVERSATION',
|
|
625
|
-
{intent: null, intentScore: null, locked: false, lockAttempts: 0, lockedReason: ''}
|
|
625
|
+
{ intent: null, intentScore: null, locked: false, lockAttempts: 0, lockedReason: '' }
|
|
626
626
|
);
|
|
627
627
|
}
|
|
628
628
|
|
|
@@ -652,7 +652,7 @@ export const Spirits = {
|
|
|
652
652
|
'Generated response',
|
|
653
653
|
'failed',
|
|
654
654
|
undefined,
|
|
655
|
-
{error: generatorPayload.errors?.join('\n\n') || 'Unknown Reason'}
|
|
655
|
+
{ error: generatorPayload.errors?.join('\n\n') || 'Unknown Reason' }
|
|
656
656
|
);
|
|
657
657
|
console.error(
|
|
658
658
|
`Locking conversation, api returned send false: ${generatorPayload.messages}`,
|
|
@@ -667,40 +667,59 @@ export const Spirits = {
|
|
|
667
667
|
// Check if already had message
|
|
668
668
|
const agentMessages = messages.filter(m => m.role === 'agent');
|
|
669
669
|
const lastAgentMessage = agentMessages[agentMessages.length - 1];
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
670
|
+
|
|
671
|
+
// Build addedMessages from generatorPayload.messages
|
|
672
|
+
const addedMessages = (generatorPayload?.messages ?? [])
|
|
673
|
+
.map((message) => {
|
|
674
|
+
// Normalize time → ISO string
|
|
675
|
+
const t = message.time;
|
|
676
|
+
let isoTime;
|
|
677
|
+
|
|
678
|
+
if (typeof t === "string") {
|
|
679
|
+
isoTime = t;
|
|
680
|
+
} else if (t instanceof Date) {
|
|
681
|
+
isoTime = t.toISOString();
|
|
682
|
+
} else if (t && typeof t.toDate === "function") {
|
|
683
|
+
// Firestore Timestamp
|
|
684
|
+
isoTime = t.toDate().toISOString();
|
|
685
|
+
} else {
|
|
686
|
+
progress(
|
|
687
|
+
`Message "${message.content}" wasn't given a usable timestamp (${JSON.stringify(
|
|
688
|
+
t
|
|
689
|
+
)}), defaulting to now`
|
|
690
|
+
);
|
|
691
|
+
isoTime = new Date().toISOString();
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Base fields we guarantee
|
|
695
|
+
const base = {
|
|
696
|
+
role: message.role,
|
|
697
|
+
content: message.content,
|
|
698
|
+
id: idGenerator(message.role),
|
|
699
|
+
time: isoTime,
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// Copy any other non-nullish fields without overwriting base
|
|
703
|
+
return Object.entries(message).reduce((acc, [key, value]) => {
|
|
704
|
+
if (!Object.prototype.hasOwnProperty.call(acc, key) && value != null) {
|
|
705
|
+
acc[key] = value;
|
|
706
|
+
}
|
|
707
|
+
return acc;
|
|
708
|
+
}, base);
|
|
709
|
+
})
|
|
710
|
+
// De-dupe by content (change the key if you want stricter uniqueness)
|
|
711
|
+
.reduce(
|
|
712
|
+
(acc, msg) => {
|
|
713
|
+
const key = String(msg.content); // e.g. `${msg.role}::${msg.content}` for stronger uniqueness
|
|
714
|
+
if (!acc.seen.has(key)) {
|
|
715
|
+
acc.seen.add(key);
|
|
716
|
+
acc.items.push(msg);
|
|
687
717
|
}
|
|
718
|
+
return acc;
|
|
719
|
+
},
|
|
720
|
+
{ seen: new Set(), items: [] }
|
|
721
|
+
).items;
|
|
688
722
|
|
|
689
|
-
return ({
|
|
690
|
-
id: idGenerator(message.role),
|
|
691
|
-
content: message.content,
|
|
692
|
-
role: message.role,
|
|
693
|
-
time,
|
|
694
|
-
entities: message.entities ?? {},
|
|
695
|
-
context: message.context ?? {},
|
|
696
|
-
mediaUrls: message.mediaUrls
|
|
697
|
-
});
|
|
698
|
-
})
|
|
699
|
-
]
|
|
700
|
-
.reduce((accumulator, message) => {
|
|
701
|
-
if (!accumulator.find(m => m.content === message.content)) accumulator.push(message);
|
|
702
|
-
return accumulator;
|
|
703
|
-
}, []);
|
|
704
723
|
|
|
705
724
|
if (lastAgentMessage && lastAgentMessage.content && addedMessages.some((message) => message.content === lastAgentMessage.content)) {
|
|
706
725
|
// Error should not have happened
|