@wabot-dev/framework 0.9.26 → 0.9.80

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.
@@ -0,0 +1,53 @@
1
+ import { testImageBase64 } from './testImageBase64.js';
2
+
3
+ /**
4
+ * A real JPEG photo of a store receipt (total: 11.570), handy for testing
5
+ * vision flows against real models without shipping binary assets.
6
+ */
7
+ const testImageBase64Url = `data:image/jpeg;base64,${testImageBase64}`;
8
+ /** A minimal one-page PDF whose content is the text "Hello World". */
9
+ const testPdfBase64Url = 'data:application/pdf;base64,JVBERi0xLjEKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9NZWRpYUJveFswIDAgMjAwIDIwMF0vUmVzb3VyY2VzPDwvRm9udDw8L0YxPDwvVHlwZS9Gb250L1N1YnR5cGUvVHlwZTEvQmFzZUZvbnQvSGVsdmV0aWNhPj4+Pj4+L0NvbnRlbnRzIDQgMCBSPj5lbmRvYmoKNCAwIG9iajw8L0xlbmd0aCA0ND4+c3RyZWFtCkJUIC9GMSAxMiBUZiA1MCAxMDAgVGQgKEhlbGxvIFdvcmxkKSBUaiBFVAplbmRzdHJlYW0gZW5kb2JqCnhyZWYKMCA1CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDUzIDAwMDAwIG4gCjAwMDAwMDAwOTggMDAwMDAgbiAKMDAwMDAwMDIyOCAwMDAwMCBuIAp0cmFpbGVyPDwvU2l6ZSA1L1Jvb3QgMSAwIFI+PgpzdGFydHhyZWYKMzIwCiUlRU9GCg==';
10
+ function humanMessage(message) {
11
+ return typeof message === 'string' ? { text: message } : message;
12
+ }
13
+ /** Human message carrying an image; defaults to the embedded receipt photo. */
14
+ function imageMessage(options = {}) {
15
+ const image = options.publicUrl
16
+ ? {
17
+ id: options.id ?? 'test-image',
18
+ mimeType: options.mimeType ?? 'image/jpeg',
19
+ publicUrl: options.publicUrl,
20
+ }
21
+ : {
22
+ id: options.id ?? 'test-image',
23
+ mimeType: options.mimeType ?? 'image/jpeg',
24
+ base64Url: options.base64Url ?? testImageBase64Url,
25
+ };
26
+ return { text: options.text, images: [image] };
27
+ }
28
+ /** Human message carrying a document; defaults to the embedded sample PDF. */
29
+ function documentMessage(options = {}) {
30
+ const document = options.publicUrl
31
+ ? {
32
+ id: options.id ?? 'test-document',
33
+ mimeType: options.mimeType ?? 'application/pdf',
34
+ publicUrl: options.publicUrl,
35
+ }
36
+ : {
37
+ id: options.id ?? 'test-document',
38
+ mimeType: options.mimeType ?? 'application/pdf',
39
+ base64Url: options.base64Url ?? testPdfBase64Url,
40
+ };
41
+ return { text: options.text, documents: [document] };
42
+ }
43
+ function humanItem(message) {
44
+ return { type: 'humanMessage', humanMessage: humanMessage(message) };
45
+ }
46
+ function botItem(message) {
47
+ return {
48
+ type: 'botMessage',
49
+ botMessage: typeof message === 'string' ? { text: message } : message,
50
+ };
51
+ }
52
+
53
+ export { botItem, documentMessage, humanItem, humanMessage, imageMessage, testImageBase64Url, testPdfBase64Url };
@@ -0,0 +1,42 @@
1
+ import { d as distExports } from '../_virtual/index.js';
2
+
3
+ /** Poll a condition until it holds or the timeout elapses. */
4
+ async function waitUntil(condition, timeoutMs = 5000, intervalMs = 50) {
5
+ const start = Date.now();
6
+ while (Date.now() - start < timeoutMs) {
7
+ if (await condition())
8
+ return;
9
+ await new Promise((r) => setTimeout(r, intervalMs));
10
+ }
11
+ throw new Error('Condition not met within timeout');
12
+ }
13
+ async function wait(timeoutMs = 5000) {
14
+ await new Promise((r) => setTimeout(r, timeoutMs));
15
+ }
16
+ /** Check that a sequence of dates matches consecutive firings of a cron expression. */
17
+ function isValidCronSequence(cronExpression, dates, options = {}) {
18
+ if (dates.length < 2)
19
+ return false;
20
+ const { timezone = 'UTC', toleranceMs = 1000, // default 1 second tolerance
21
+ } = options;
22
+ try {
23
+ const interval = distExports.CronExpressionParser.parse(cronExpression, {
24
+ currentDate: dates[0],
25
+ tz: timezone,
26
+ });
27
+ for (let i = 1; i < dates.length; i++) {
28
+ const expected = interval.next().toDate();
29
+ const actual = dates[i];
30
+ const diff = Math.abs(expected.getTime() - actual.getTime());
31
+ if (diff > toleranceMs) {
32
+ return false;
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ export { isValidCronSequence, wait, waitUntil };