@elizaos/plugin-dummy-services 1.2.5 → 1.2.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/index.d.ts +144 -6
- package/dist/index.js +1018 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// src/tokenData/service.ts
|
|
2
|
-
import {
|
|
3
|
-
Service,
|
|
4
|
-
ServiceType,
|
|
5
|
-
logger
|
|
6
|
-
} from "@elizaos/core";
|
|
2
|
+
import { ITokenDataService, ServiceType, logger } from "@elizaos/core";
|
|
7
3
|
import { v4 as uuidv4 } from "uuid";
|
|
8
|
-
var DummyTokenDataService = class _DummyTokenDataService extends
|
|
4
|
+
var DummyTokenDataService = class _DummyTokenDataService extends ITokenDataService {
|
|
9
5
|
serviceName = "dummy-token-data";
|
|
10
6
|
static serviceType = ServiceType.TOKEN_DATA;
|
|
11
|
-
capabilityDescription = "Provides dummy token data for testing and development purposes.";
|
|
12
7
|
constructor(runtime) {
|
|
13
8
|
super(runtime);
|
|
14
9
|
logger.info("DummyTokenDataService initialized");
|
|
@@ -232,11 +227,10 @@ var DummyLpService = class _DummyLpService extends ILpService {
|
|
|
232
227
|
};
|
|
233
228
|
|
|
234
229
|
// src/wallet/service.ts
|
|
235
|
-
import {
|
|
230
|
+
import { IWalletService, ServiceType as ServiceType2 } from "@elizaos/core";
|
|
236
231
|
var DEFAULT_QUOTE_ASSET = "USDC";
|
|
237
|
-
var DummyWalletService = class _DummyWalletService extends
|
|
232
|
+
var DummyWalletService = class _DummyWalletService extends IWalletService {
|
|
238
233
|
static serviceType = ServiceType2.WALLET;
|
|
239
|
-
capabilityDescription = "Provides standardized access to wallet balances and portfolios.";
|
|
240
234
|
balances;
|
|
241
235
|
// assetSymbolOrAddress -> quantity
|
|
242
236
|
positions;
|
|
@@ -344,6 +338,1003 @@ var DummyWalletService = class _DummyWalletService extends Service3 {
|
|
|
344
338
|
}
|
|
345
339
|
};
|
|
346
340
|
|
|
341
|
+
// src/pdf/service.ts
|
|
342
|
+
import {
|
|
343
|
+
IPdfService
|
|
344
|
+
} from "@elizaos/core";
|
|
345
|
+
var DummyPdfService = class _DummyPdfService extends IPdfService {
|
|
346
|
+
static serviceType = IPdfService.serviceType;
|
|
347
|
+
constructor(runtime) {
|
|
348
|
+
super(runtime);
|
|
349
|
+
}
|
|
350
|
+
static async start(runtime) {
|
|
351
|
+
const service = new _DummyPdfService(runtime);
|
|
352
|
+
await service.initialize();
|
|
353
|
+
return service;
|
|
354
|
+
}
|
|
355
|
+
async initialize() {
|
|
356
|
+
this.runtime.logger.info("DummyPdfService initialized");
|
|
357
|
+
}
|
|
358
|
+
async stop() {
|
|
359
|
+
this.runtime.logger.info("DummyPdfService stopped");
|
|
360
|
+
}
|
|
361
|
+
async extractText(pdfPath) {
|
|
362
|
+
const isBuffer = Buffer.isBuffer(pdfPath);
|
|
363
|
+
const filename = isBuffer ? "buffer.pdf" : pdfPath;
|
|
364
|
+
this.runtime.logger.debug(`Extracting text from ${filename}`);
|
|
365
|
+
return {
|
|
366
|
+
text: `Mock extracted text from ${filename}.
|
|
367
|
+
|
|
368
|
+
This is a dummy PDF service that simulates text extraction.
|
|
369
|
+
|
|
370
|
+
Page 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
371
|
+
Page 2: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
372
|
+
Page 3: Ut enim ad minim veniam, quis nostrud exercitation ullamco.`,
|
|
373
|
+
pageCount: 3,
|
|
374
|
+
metadata: {
|
|
375
|
+
title: "Mock PDF Document",
|
|
376
|
+
author: "Dummy Service",
|
|
377
|
+
createdAt: /* @__PURE__ */ new Date("2024-01-01"),
|
|
378
|
+
modifiedAt: /* @__PURE__ */ new Date()
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
async generatePdf(htmlContent, options) {
|
|
383
|
+
this.runtime.logger.debug("Generating PDF from HTML content");
|
|
384
|
+
const pdfContent = `Mock PDF generated from HTML content with ${htmlContent.length} characters`;
|
|
385
|
+
const mockPdfBuffer = Buffer.from(pdfContent, "utf8");
|
|
386
|
+
if (options) {
|
|
387
|
+
this.runtime.logger.debug("PDF generation options:", options);
|
|
388
|
+
}
|
|
389
|
+
return mockPdfBuffer;
|
|
390
|
+
}
|
|
391
|
+
async convertToPdf(filePath, options) {
|
|
392
|
+
this.runtime.logger.debug(`Converting ${filePath} to PDF`);
|
|
393
|
+
const pdfContent = `Mock PDF converted from ${filePath}`;
|
|
394
|
+
const mockPdfBuffer = Buffer.from(pdfContent, "utf8");
|
|
395
|
+
if (options) {
|
|
396
|
+
this.runtime.logger.debug("PDF conversion options:", options);
|
|
397
|
+
}
|
|
398
|
+
return mockPdfBuffer;
|
|
399
|
+
}
|
|
400
|
+
async mergePdfs(pdfPaths) {
|
|
401
|
+
this.runtime.logger.debug(`Merging ${pdfPaths.length} PDF files`);
|
|
402
|
+
const mergedContent = pdfPaths.map((path, index) => {
|
|
403
|
+
const name = Buffer.isBuffer(path) ? `buffer-${index}` : path;
|
|
404
|
+
return `Content from ${name}`;
|
|
405
|
+
}).join("\n\n");
|
|
406
|
+
const mockMergedBuffer = Buffer.from(`Mock merged PDF:
|
|
407
|
+
${mergedContent}`, "utf8");
|
|
408
|
+
return mockMergedBuffer;
|
|
409
|
+
}
|
|
410
|
+
async splitPdf(pdfPath) {
|
|
411
|
+
this.runtime.logger.debug("Splitting PDF into pages");
|
|
412
|
+
const filename = Buffer.isBuffer(pdfPath) ? "buffer.pdf" : pdfPath;
|
|
413
|
+
const pages = [
|
|
414
|
+
Buffer.from(`Mock Page 1 from ${filename}`, "utf8"),
|
|
415
|
+
Buffer.from(`Mock Page 2 from ${filename}`, "utf8"),
|
|
416
|
+
Buffer.from(`Mock Page 3 from ${filename}`, "utf8")
|
|
417
|
+
];
|
|
418
|
+
return pages;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// src/video/service.ts
|
|
423
|
+
import {
|
|
424
|
+
IVideoService
|
|
425
|
+
} from "@elizaos/core";
|
|
426
|
+
var DummyVideoService = class _DummyVideoService extends IVideoService {
|
|
427
|
+
static serviceType = IVideoService.serviceType;
|
|
428
|
+
constructor(runtime) {
|
|
429
|
+
super(runtime);
|
|
430
|
+
}
|
|
431
|
+
static async start(runtime) {
|
|
432
|
+
const service = new _DummyVideoService(runtime);
|
|
433
|
+
await service.initialize();
|
|
434
|
+
return service;
|
|
435
|
+
}
|
|
436
|
+
async initialize() {
|
|
437
|
+
this.runtime.logger.info("DummyVideoService initialized");
|
|
438
|
+
}
|
|
439
|
+
async stop() {
|
|
440
|
+
this.runtime.logger.info("DummyVideoService stopped");
|
|
441
|
+
}
|
|
442
|
+
async getVideoInfo(url) {
|
|
443
|
+
this.runtime.logger.debug(`Getting video info for ${url}`);
|
|
444
|
+
return {
|
|
445
|
+
title: "Mock Video Title",
|
|
446
|
+
duration: 300,
|
|
447
|
+
// 5 minutes in seconds
|
|
448
|
+
url,
|
|
449
|
+
thumbnail: "https://example.com/thumbnail.jpg",
|
|
450
|
+
description: "This is a mock video description for testing purposes.",
|
|
451
|
+
uploader: "DummyUploader",
|
|
452
|
+
viewCount: 12345,
|
|
453
|
+
uploadDate: /* @__PURE__ */ new Date("2024-01-01"),
|
|
454
|
+
formats: [
|
|
455
|
+
{
|
|
456
|
+
formatId: "mp4-720p",
|
|
457
|
+
url: "https://example.com/video-720p.mp4",
|
|
458
|
+
extension: "mp4",
|
|
459
|
+
quality: "720p",
|
|
460
|
+
fileSize: 5e7,
|
|
461
|
+
// 50MB
|
|
462
|
+
videoCodec: "h264",
|
|
463
|
+
audioCodec: "aac",
|
|
464
|
+
resolution: "1280x720",
|
|
465
|
+
fps: 30,
|
|
466
|
+
bitrate: 1e6
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
formatId: "mp4-1080p",
|
|
470
|
+
url: "https://example.com/video-1080p.mp4",
|
|
471
|
+
extension: "mp4",
|
|
472
|
+
quality: "1080p",
|
|
473
|
+
fileSize: 1e8,
|
|
474
|
+
// 100MB
|
|
475
|
+
videoCodec: "h264",
|
|
476
|
+
audioCodec: "aac",
|
|
477
|
+
resolution: "1920x1080",
|
|
478
|
+
fps: 30,
|
|
479
|
+
bitrate: 2e6
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
async downloadVideo(url, options) {
|
|
485
|
+
this.runtime.logger.debug(`Downloading video from ${url}`);
|
|
486
|
+
if (options) {
|
|
487
|
+
this.runtime.logger.debug("Download options:", options);
|
|
488
|
+
}
|
|
489
|
+
const filename = `mock-video-${Date.now()}.mp4`;
|
|
490
|
+
const outputPath = options?.outputPath || `/tmp/${filename}`;
|
|
491
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
492
|
+
return outputPath;
|
|
493
|
+
}
|
|
494
|
+
async extractAudio(videoPath, outputPath) {
|
|
495
|
+
this.runtime.logger.debug(`Extracting audio from ${videoPath}`);
|
|
496
|
+
const audioPath = outputPath || videoPath.replace(/\.[^/.]+$/, "") + ".mp3";
|
|
497
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
498
|
+
return audioPath;
|
|
499
|
+
}
|
|
500
|
+
async getThumbnail(videoPath, timestamp) {
|
|
501
|
+
this.runtime.logger.debug(`Generating thumbnail for ${videoPath} at ${timestamp || 0}s`);
|
|
502
|
+
const thumbnailPath = videoPath.replace(/\.[^/.]+$/, "") + `_${timestamp || 0}s.jpg`;
|
|
503
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
504
|
+
return thumbnailPath;
|
|
505
|
+
}
|
|
506
|
+
async convertVideo(videoPath, outputPath, options) {
|
|
507
|
+
this.runtime.logger.debug(`Converting video from ${videoPath} to ${outputPath}`);
|
|
508
|
+
if (options) {
|
|
509
|
+
this.runtime.logger.debug("Conversion options:", options);
|
|
510
|
+
}
|
|
511
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
512
|
+
return outputPath;
|
|
513
|
+
}
|
|
514
|
+
async getAvailableFormats(url) {
|
|
515
|
+
this.runtime.logger.debug(`Getting available formats for ${url}`);
|
|
516
|
+
return [
|
|
517
|
+
{
|
|
518
|
+
formatId: "mp4-360p",
|
|
519
|
+
url: "https://example.com/video-360p.mp4",
|
|
520
|
+
extension: "mp4",
|
|
521
|
+
quality: "360p",
|
|
522
|
+
fileSize: 15e6,
|
|
523
|
+
// 15MB
|
|
524
|
+
videoCodec: "h264",
|
|
525
|
+
audioCodec: "aac",
|
|
526
|
+
resolution: "640x360",
|
|
527
|
+
fps: 30,
|
|
528
|
+
bitrate: 5e5
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
formatId: "mp4-720p",
|
|
532
|
+
url: "https://example.com/video-720p.mp4",
|
|
533
|
+
extension: "mp4",
|
|
534
|
+
quality: "720p",
|
|
535
|
+
fileSize: 5e7,
|
|
536
|
+
// 50MB
|
|
537
|
+
videoCodec: "h264",
|
|
538
|
+
audioCodec: "aac",
|
|
539
|
+
resolution: "1280x720",
|
|
540
|
+
fps: 30,
|
|
541
|
+
bitrate: 1e6
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
formatId: "mp4-1080p",
|
|
545
|
+
url: "https://example.com/video-1080p.mp4",
|
|
546
|
+
extension: "mp4",
|
|
547
|
+
quality: "1080p",
|
|
548
|
+
fileSize: 1e8,
|
|
549
|
+
// 100MB
|
|
550
|
+
videoCodec: "h264",
|
|
551
|
+
audioCodec: "aac",
|
|
552
|
+
resolution: "1920x1080",
|
|
553
|
+
fps: 30,
|
|
554
|
+
bitrate: 2e6
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
formatId: "audio-only",
|
|
558
|
+
url: "https://example.com/audio.mp3",
|
|
559
|
+
extension: "mp3",
|
|
560
|
+
quality: "audio",
|
|
561
|
+
fileSize: 5e6,
|
|
562
|
+
// 5MB
|
|
563
|
+
audioCodec: "mp3",
|
|
564
|
+
bitrate: 128e3
|
|
565
|
+
}
|
|
566
|
+
];
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// src/browser/service.ts
|
|
571
|
+
import {
|
|
572
|
+
IBrowserService
|
|
573
|
+
} from "@elizaos/core";
|
|
574
|
+
var DummyBrowserService = class _DummyBrowserService extends IBrowserService {
|
|
575
|
+
static serviceType = IBrowserService.serviceType;
|
|
576
|
+
currentUrl = "about:blank";
|
|
577
|
+
history = [];
|
|
578
|
+
historyIndex = -1;
|
|
579
|
+
constructor(runtime) {
|
|
580
|
+
super(runtime);
|
|
581
|
+
}
|
|
582
|
+
static async start(runtime) {
|
|
583
|
+
const service = new _DummyBrowserService(runtime);
|
|
584
|
+
await service.initialize();
|
|
585
|
+
return service;
|
|
586
|
+
}
|
|
587
|
+
async initialize() {
|
|
588
|
+
this.runtime.logger.info("DummyBrowserService initialized");
|
|
589
|
+
}
|
|
590
|
+
async stop() {
|
|
591
|
+
this.runtime.logger.info("DummyBrowserService stopped");
|
|
592
|
+
}
|
|
593
|
+
async navigate(url, options) {
|
|
594
|
+
this.runtime.logger.debug(`Navigating to ${url}`);
|
|
595
|
+
if (options) {
|
|
596
|
+
this.runtime.logger.debug("Navigation options:", options);
|
|
597
|
+
}
|
|
598
|
+
this.history.push(url);
|
|
599
|
+
this.historyIndex = this.history.length - 1;
|
|
600
|
+
this.currentUrl = url;
|
|
601
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
602
|
+
}
|
|
603
|
+
async screenshot(options) {
|
|
604
|
+
this.runtime.logger.debug("Taking screenshot");
|
|
605
|
+
if (options) {
|
|
606
|
+
this.runtime.logger.debug("Screenshot options:", options);
|
|
607
|
+
}
|
|
608
|
+
const mockImage = `Mock screenshot of ${this.currentUrl}`;
|
|
609
|
+
const imageBuffer = Buffer.from(mockImage, "utf8");
|
|
610
|
+
return imageBuffer;
|
|
611
|
+
}
|
|
612
|
+
async extractContent(selector) {
|
|
613
|
+
this.runtime.logger.debug(`Extracting content${selector ? ` from ${selector}` : ""}`);
|
|
614
|
+
let isGitHub = false;
|
|
615
|
+
let isGoogle = false;
|
|
616
|
+
try {
|
|
617
|
+
const url = new URL(this.currentUrl);
|
|
618
|
+
isGitHub = url.hostname === "github.com" || url.hostname.endsWith(".github.com");
|
|
619
|
+
isGoogle = url.hostname === "google.com" || url.hostname.endsWith(".google.com");
|
|
620
|
+
} catch (error) {
|
|
621
|
+
this.runtime.logger.debug("Invalid URL format, defaulting to generic content");
|
|
622
|
+
}
|
|
623
|
+
let mockContent;
|
|
624
|
+
if (isGitHub) {
|
|
625
|
+
mockContent = {
|
|
626
|
+
text: "Mock GitHub repository content\n\nThis is a dummy browser service extracting content from GitHub.\n\nFeatures:\n- Mock code repository\n- Sample README content\n- Dummy issue tracking",
|
|
627
|
+
html: '<div class="repository-content"><h1>Mock Repository</h1><p>This is a dummy GitHub repository.</p></div>',
|
|
628
|
+
links: [
|
|
629
|
+
{ url: "https://github.com/mock/repo/issues", text: "Issues" },
|
|
630
|
+
{ url: "https://github.com/mock/repo/pulls", text: "Pull Requests" },
|
|
631
|
+
{ url: "https://github.com/mock/repo/wiki", text: "Wiki" }
|
|
632
|
+
],
|
|
633
|
+
images: [{ src: "https://github.com/mock/repo/avatar.png", alt: "Repository Avatar" }],
|
|
634
|
+
title: "Mock Repository - GitHub",
|
|
635
|
+
metadata: {
|
|
636
|
+
"og:title": "Mock Repository",
|
|
637
|
+
"og:description": "A dummy repository for testing",
|
|
638
|
+
"og:type": "website"
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
} else if (isGoogle) {
|
|
642
|
+
mockContent = {
|
|
643
|
+
text: "Mock Google search results\n\nSearch results for your query:\n\n1. Mock Result 1\n2. Mock Result 2\n3. Mock Result 3",
|
|
644
|
+
html: '<div class="search-results"><div class="result"><h3>Mock Result 1</h3><p>Mock description</p></div></div>',
|
|
645
|
+
links: [
|
|
646
|
+
{ url: "https://example.com/result1", text: "Mock Result 1" },
|
|
647
|
+
{ url: "https://example.com/result2", text: "Mock Result 2" },
|
|
648
|
+
{ url: "https://example.com/result3", text: "Mock Result 3" }
|
|
649
|
+
],
|
|
650
|
+
images: [{ src: "https://google.com/logo.png", alt: "Google Logo" }],
|
|
651
|
+
title: "Mock Search - Google",
|
|
652
|
+
metadata: {
|
|
653
|
+
description: "Mock search results page"
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
} else {
|
|
657
|
+
mockContent = {
|
|
658
|
+
text: `Mock content from ${this.currentUrl}
|
|
659
|
+
|
|
660
|
+
This is dummy content extracted by the browser service.
|
|
661
|
+
|
|
662
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.`,
|
|
663
|
+
html: '<div class="content"><h1>Mock Page</h1><p>This is mock content from the dummy browser service.</p></div>',
|
|
664
|
+
links: [
|
|
665
|
+
{ url: `${this.currentUrl}/page1`, text: "Page 1" },
|
|
666
|
+
{ url: `${this.currentUrl}/page2`, text: "Page 2" }
|
|
667
|
+
],
|
|
668
|
+
images: [{ src: `${this.currentUrl}/image.jpg`, alt: "Mock Image" }],
|
|
669
|
+
title: "Mock Page Title",
|
|
670
|
+
metadata: {
|
|
671
|
+
description: "Mock page description"
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return mockContent;
|
|
676
|
+
}
|
|
677
|
+
async click(selector, options) {
|
|
678
|
+
const selectorStr = typeof selector === "string" ? selector : selector.selector;
|
|
679
|
+
this.runtime.logger.debug(`Clicking on ${selectorStr}`);
|
|
680
|
+
if (options) {
|
|
681
|
+
this.runtime.logger.debug("Click options:", options);
|
|
682
|
+
}
|
|
683
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
684
|
+
}
|
|
685
|
+
async type(selector, text, options) {
|
|
686
|
+
this.runtime.logger.debug(`Typing "${text}" into ${selector}`);
|
|
687
|
+
if (options) {
|
|
688
|
+
this.runtime.logger.debug("Type options:", options);
|
|
689
|
+
}
|
|
690
|
+
const delay = options?.delay || 10;
|
|
691
|
+
await new Promise((resolve) => setTimeout(resolve, delay * text.length));
|
|
692
|
+
}
|
|
693
|
+
async waitForElement(selector) {
|
|
694
|
+
const selectorStr = typeof selector === "string" ? selector : selector.selector;
|
|
695
|
+
this.runtime.logger.debug(`Waiting for element ${selectorStr}`);
|
|
696
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
697
|
+
}
|
|
698
|
+
async evaluate(script, ...args) {
|
|
699
|
+
this.runtime.logger.debug(`Evaluating script: ${script}`);
|
|
700
|
+
if (script.includes("document.title")) {
|
|
701
|
+
return "Mock Page Title";
|
|
702
|
+
}
|
|
703
|
+
if (script.includes("window.location.href")) {
|
|
704
|
+
return this.currentUrl;
|
|
705
|
+
}
|
|
706
|
+
if (script.includes("document.body.innerHTML")) {
|
|
707
|
+
return "<div>Mock page content</div>";
|
|
708
|
+
}
|
|
709
|
+
return { result: "mock evaluation result", args };
|
|
710
|
+
}
|
|
711
|
+
async getCurrentUrl() {
|
|
712
|
+
return this.currentUrl;
|
|
713
|
+
}
|
|
714
|
+
async goBack() {
|
|
715
|
+
this.runtime.logger.debug("Going back in history");
|
|
716
|
+
if (this.historyIndex > 0) {
|
|
717
|
+
this.historyIndex--;
|
|
718
|
+
this.currentUrl = this.history[this.historyIndex];
|
|
719
|
+
}
|
|
720
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
721
|
+
}
|
|
722
|
+
async goForward() {
|
|
723
|
+
this.runtime.logger.debug("Going forward in history");
|
|
724
|
+
if (this.historyIndex < this.history.length - 1) {
|
|
725
|
+
this.historyIndex++;
|
|
726
|
+
this.currentUrl = this.history[this.historyIndex];
|
|
727
|
+
}
|
|
728
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
729
|
+
}
|
|
730
|
+
async refresh() {
|
|
731
|
+
this.runtime.logger.debug("Refreshing page");
|
|
732
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
// src/transcription/service.ts
|
|
737
|
+
import {
|
|
738
|
+
ITranscriptionService
|
|
739
|
+
} from "@elizaos/core";
|
|
740
|
+
var DummyTranscriptionService = class _DummyTranscriptionService extends ITranscriptionService {
|
|
741
|
+
static serviceType = ITranscriptionService.serviceType;
|
|
742
|
+
supportedLanguages = ["en", "es", "fr", "de", "it", "pt", "ru", "zh", "ja", "ko"];
|
|
743
|
+
availableVoices = [
|
|
744
|
+
{ id: "en-US-male", name: "John", language: "en-US", gender: "male" },
|
|
745
|
+
{ id: "en-US-female", name: "Jane", language: "en-US", gender: "female" },
|
|
746
|
+
{ id: "es-ES-male", name: "Carlos", language: "es-ES", gender: "male" },
|
|
747
|
+
{ id: "fr-FR-female", name: "Marie", language: "fr-FR", gender: "female" }
|
|
748
|
+
];
|
|
749
|
+
constructor(runtime) {
|
|
750
|
+
super(runtime);
|
|
751
|
+
}
|
|
752
|
+
static async start(runtime) {
|
|
753
|
+
const service = new _DummyTranscriptionService(runtime);
|
|
754
|
+
await service.initialize();
|
|
755
|
+
return service;
|
|
756
|
+
}
|
|
757
|
+
async initialize() {
|
|
758
|
+
this.runtime.logger.info("DummyTranscriptionService initialized");
|
|
759
|
+
}
|
|
760
|
+
async stop() {
|
|
761
|
+
this.runtime.logger.info("DummyTranscriptionService stopped");
|
|
762
|
+
}
|
|
763
|
+
async transcribeAudio(audioPath, options) {
|
|
764
|
+
const filename = Buffer.isBuffer(audioPath) ? "audio-buffer" : audioPath;
|
|
765
|
+
this.runtime.logger.debug(`Transcribing audio from ${filename}`);
|
|
766
|
+
if (options) {
|
|
767
|
+
this.runtime.logger.debug("Transcription options:", options);
|
|
768
|
+
}
|
|
769
|
+
const mockText = "Hello, this is a mock transcription from the dummy service. The audio has been processed and converted to text. This demonstrates the transcription capabilities of the system.";
|
|
770
|
+
const words = mockText.split(" ").map((word, index) => ({
|
|
771
|
+
word: word.replace(/[.,!?]/, ""),
|
|
772
|
+
start: index * 0.5,
|
|
773
|
+
end: (index + 1) * 0.5,
|
|
774
|
+
confidence: 0.9 + Math.random() * 0.1
|
|
775
|
+
}));
|
|
776
|
+
const segments = [
|
|
777
|
+
{
|
|
778
|
+
id: 0,
|
|
779
|
+
text: "Hello, this is a mock transcription from the dummy service.",
|
|
780
|
+
start: 0,
|
|
781
|
+
end: 5,
|
|
782
|
+
confidence: 0.95,
|
|
783
|
+
temperature: 0,
|
|
784
|
+
avg_logprob: -0.1,
|
|
785
|
+
compression_ratio: 1.2,
|
|
786
|
+
no_speech_prob: 0.01
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
id: 1,
|
|
790
|
+
text: "The audio has been processed and converted to text.",
|
|
791
|
+
start: 5,
|
|
792
|
+
end: 10,
|
|
793
|
+
confidence: 0.92,
|
|
794
|
+
temperature: 0,
|
|
795
|
+
avg_logprob: -0.12,
|
|
796
|
+
compression_ratio: 1.1,
|
|
797
|
+
no_speech_prob: 0.02
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
id: 2,
|
|
801
|
+
text: "This demonstrates the transcription capabilities of the system.",
|
|
802
|
+
start: 10,
|
|
803
|
+
end: 15,
|
|
804
|
+
confidence: 0.89,
|
|
805
|
+
temperature: 0,
|
|
806
|
+
avg_logprob: -0.15,
|
|
807
|
+
compression_ratio: 1.3,
|
|
808
|
+
no_speech_prob: 0.03
|
|
809
|
+
}
|
|
810
|
+
];
|
|
811
|
+
return {
|
|
812
|
+
text: mockText,
|
|
813
|
+
language: options?.language || "en",
|
|
814
|
+
duration: 15,
|
|
815
|
+
segments: options?.response_format === "verbose_json" ? segments : void 0,
|
|
816
|
+
words: options?.word_timestamps ? words : void 0,
|
|
817
|
+
confidence: 0.92
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
async transcribeVideo(videoPath, options) {
|
|
821
|
+
const filename = Buffer.isBuffer(videoPath) ? "video-buffer" : videoPath;
|
|
822
|
+
this.runtime.logger.debug(`Transcribing video from ${filename}`);
|
|
823
|
+
const mockText = "This is a mock transcription from a video file. The video's audio track has been extracted and processed. The speaker discusses various topics including technology, AI, and automation systems.";
|
|
824
|
+
const words = mockText.split(" ").map((word, index) => ({
|
|
825
|
+
word: word.replace(/[.,!?]/, ""),
|
|
826
|
+
start: index * 0.6,
|
|
827
|
+
end: (index + 1) * 0.6,
|
|
828
|
+
confidence: 0.85 + Math.random() * 0.15
|
|
829
|
+
}));
|
|
830
|
+
return {
|
|
831
|
+
text: mockText,
|
|
832
|
+
language: options?.language || "en",
|
|
833
|
+
duration: 20,
|
|
834
|
+
words: options?.word_timestamps ? words : void 0,
|
|
835
|
+
confidence: 0.88
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
async speechToText(audioStream, options) {
|
|
839
|
+
this.runtime.logger.debug("Processing real-time speech to text");
|
|
840
|
+
if (options) {
|
|
841
|
+
this.runtime.logger.debug("Speech to text options:", options);
|
|
842
|
+
}
|
|
843
|
+
const mockText = "Real-time speech recognition is working. This is a continuous transcription from the audio stream.";
|
|
844
|
+
return {
|
|
845
|
+
text: mockText,
|
|
846
|
+
language: options?.language || "en",
|
|
847
|
+
duration: 5,
|
|
848
|
+
confidence: 0.85
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
async textToSpeech(text, options) {
|
|
852
|
+
this.runtime.logger.debug(`Converting text to speech: "${text.substring(0, 50)}..."`);
|
|
853
|
+
if (options) {
|
|
854
|
+
this.runtime.logger.debug("Text to speech options:", options);
|
|
855
|
+
}
|
|
856
|
+
const mockAudioData = `Mock audio data for: ${text}`;
|
|
857
|
+
const audioBuffer = Buffer.from(mockAudioData, "utf8");
|
|
858
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(text.length * 10, 1e3)));
|
|
859
|
+
return audioBuffer;
|
|
860
|
+
}
|
|
861
|
+
async getSupportedLanguages() {
|
|
862
|
+
return [...this.supportedLanguages];
|
|
863
|
+
}
|
|
864
|
+
async getAvailableVoices() {
|
|
865
|
+
return [...this.availableVoices];
|
|
866
|
+
}
|
|
867
|
+
async detectLanguage(audioPath) {
|
|
868
|
+
const filename = Buffer.isBuffer(audioPath) ? "audio-buffer" : audioPath;
|
|
869
|
+
this.runtime.logger.debug(`Detecting language from ${filename}`);
|
|
870
|
+
const randomLanguage = this.supportedLanguages[Math.floor(Math.random() * this.supportedLanguages.length)];
|
|
871
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
872
|
+
return randomLanguage;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
// src/web-search/service.ts
|
|
877
|
+
import {
|
|
878
|
+
IWebSearchService
|
|
879
|
+
} from "@elizaos/core";
|
|
880
|
+
var DummyWebSearchService = class _DummyWebSearchService extends IWebSearchService {
|
|
881
|
+
static serviceType = IWebSearchService.serviceType;
|
|
882
|
+
trendingSearches = [
|
|
883
|
+
"artificial intelligence",
|
|
884
|
+
"machine learning",
|
|
885
|
+
"blockchain technology",
|
|
886
|
+
"climate change",
|
|
887
|
+
"space exploration",
|
|
888
|
+
"quantum computing",
|
|
889
|
+
"renewable energy",
|
|
890
|
+
"cybersecurity",
|
|
891
|
+
"biotechnology",
|
|
892
|
+
"autonomous vehicles"
|
|
893
|
+
];
|
|
894
|
+
constructor(runtime) {
|
|
895
|
+
super(runtime);
|
|
896
|
+
}
|
|
897
|
+
static async start(runtime) {
|
|
898
|
+
const service = new _DummyWebSearchService(runtime);
|
|
899
|
+
await service.initialize();
|
|
900
|
+
return service;
|
|
901
|
+
}
|
|
902
|
+
async initialize() {
|
|
903
|
+
this.runtime.logger.info("DummyWebSearchService initialized");
|
|
904
|
+
}
|
|
905
|
+
async stop() {
|
|
906
|
+
this.runtime.logger.info("DummyWebSearchService stopped");
|
|
907
|
+
}
|
|
908
|
+
async search(query, options) {
|
|
909
|
+
this.runtime.logger.debug(`Searching for: "${query}"`);
|
|
910
|
+
if (options) {
|
|
911
|
+
this.runtime.logger.debug("Search options:", options);
|
|
912
|
+
}
|
|
913
|
+
const results = [
|
|
914
|
+
{
|
|
915
|
+
title: `${query} - Comprehensive Guide`,
|
|
916
|
+
url: `https://example.com/guide/${query.replace(/\s+/g, "-")}`,
|
|
917
|
+
description: `A comprehensive guide about ${query}. This mock result provides detailed information and explanations about the topic.`,
|
|
918
|
+
displayUrl: "example.com",
|
|
919
|
+
thumbnail: "https://example.com/thumbnail1.jpg",
|
|
920
|
+
publishedDate: /* @__PURE__ */ new Date("2024-01-15"),
|
|
921
|
+
source: "Example Guide",
|
|
922
|
+
relevanceScore: 0.95,
|
|
923
|
+
snippet: `Learn everything about ${query} with this detailed guide...`
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
title: `${query} - Latest News and Updates`,
|
|
927
|
+
url: `https://news.example.com/latest/${query.replace(/\s+/g, "-")}`,
|
|
928
|
+
description: `Stay updated with the latest news about ${query}. Recent developments, trends, and insights.`,
|
|
929
|
+
displayUrl: "news.example.com",
|
|
930
|
+
thumbnail: "https://news.example.com/thumbnail2.jpg",
|
|
931
|
+
publishedDate: /* @__PURE__ */ new Date("2024-01-10"),
|
|
932
|
+
source: "Example News",
|
|
933
|
+
relevanceScore: 0.88,
|
|
934
|
+
snippet: `Breaking news about ${query}: Recent developments show...`
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
title: `${query} - Wikipedia`,
|
|
938
|
+
url: `https://en.wikipedia.org/wiki/${query.replace(/\s+/g, "_")}`,
|
|
939
|
+
description: `Wikipedia article about ${query}. Comprehensive information from the free encyclopedia.`,
|
|
940
|
+
displayUrl: "en.wikipedia.org",
|
|
941
|
+
publishedDate: /* @__PURE__ */ new Date("2023-12-01"),
|
|
942
|
+
source: "Wikipedia",
|
|
943
|
+
relevanceScore: 0.82,
|
|
944
|
+
snippet: `${query} is a topic that encompasses various aspects...`
|
|
945
|
+
}
|
|
946
|
+
];
|
|
947
|
+
return {
|
|
948
|
+
query,
|
|
949
|
+
results,
|
|
950
|
+
totalResults: 156789,
|
|
951
|
+
searchTime: 0.42,
|
|
952
|
+
suggestions: [
|
|
953
|
+
`${query} tutorial`,
|
|
954
|
+
`${query} examples`,
|
|
955
|
+
`${query} best practices`,
|
|
956
|
+
`${query} 2024`
|
|
957
|
+
],
|
|
958
|
+
relatedSearches: [
|
|
959
|
+
`what is ${query}`,
|
|
960
|
+
`how to ${query}`,
|
|
961
|
+
`${query} vs alternatives`,
|
|
962
|
+
`${query} benefits`
|
|
963
|
+
]
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
async searchNews(query, options) {
|
|
967
|
+
this.runtime.logger.debug(`Searching news for: "${query}"`);
|
|
968
|
+
if (options) {
|
|
969
|
+
this.runtime.logger.debug("News search options:", options);
|
|
970
|
+
}
|
|
971
|
+
const results = [
|
|
972
|
+
{
|
|
973
|
+
title: `Breaking: ${query} Makes Headlines`,
|
|
974
|
+
url: `https://news.example.com/breaking/${query.replace(/\s+/g, "-")}`,
|
|
975
|
+
description: `Latest breaking news about ${query}. Important developments that are making headlines today.`,
|
|
976
|
+
displayUrl: "news.example.com",
|
|
977
|
+
thumbnail: "https://news.example.com/breaking.jpg",
|
|
978
|
+
publishedDate: new Date(Date.now() - 36e5),
|
|
979
|
+
// 1 hour ago
|
|
980
|
+
source: "Example News",
|
|
981
|
+
relevanceScore: 0.93
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
title: `${query}: Analysis and Commentary`,
|
|
985
|
+
url: `https://analysis.example.com/commentary/${query.replace(/\s+/g, "-")}`,
|
|
986
|
+
description: `Expert analysis and commentary on ${query}. In-depth perspectives from industry leaders.`,
|
|
987
|
+
displayUrl: "analysis.example.com",
|
|
988
|
+
thumbnail: "https://analysis.example.com/analysis.jpg",
|
|
989
|
+
publishedDate: new Date(Date.now() - 72e5),
|
|
990
|
+
// 2 hours ago
|
|
991
|
+
source: "Example Analysis",
|
|
992
|
+
relevanceScore: 0.87
|
|
993
|
+
}
|
|
994
|
+
];
|
|
995
|
+
return {
|
|
996
|
+
query,
|
|
997
|
+
results,
|
|
998
|
+
totalResults: 12345,
|
|
999
|
+
searchTime: 0.28,
|
|
1000
|
+
suggestions: [`${query} news`, `${query} headlines`, `${query} updates`]
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
async searchImages(query, options) {
|
|
1004
|
+
this.runtime.logger.debug(`Searching images for: "${query}"`);
|
|
1005
|
+
if (options) {
|
|
1006
|
+
this.runtime.logger.debug("Image search options:", options);
|
|
1007
|
+
}
|
|
1008
|
+
const results = Array.from({ length: 12 }, (_, i) => ({
|
|
1009
|
+
title: `${query} Image ${i + 1}`,
|
|
1010
|
+
url: `https://images.example.com/${query.replace(/\s+/g, "-")}-${i + 1}.jpg`,
|
|
1011
|
+
description: `High-quality image of ${query}. Perfect for various uses and applications.`,
|
|
1012
|
+
displayUrl: "images.example.com",
|
|
1013
|
+
thumbnail: `https://images.example.com/thumb/${query.replace(/\s+/g, "-")}-${i + 1}.jpg`,
|
|
1014
|
+
source: "Example Images",
|
|
1015
|
+
relevanceScore: 0.9 - i * 0.05
|
|
1016
|
+
}));
|
|
1017
|
+
return {
|
|
1018
|
+
query,
|
|
1019
|
+
results,
|
|
1020
|
+
totalResults: 45678,
|
|
1021
|
+
searchTime: 0.35
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
async searchVideos(query, options) {
|
|
1025
|
+
this.runtime.logger.debug(`Searching videos for: "${query}"`);
|
|
1026
|
+
if (options) {
|
|
1027
|
+
this.runtime.logger.debug("Video search options:", options);
|
|
1028
|
+
}
|
|
1029
|
+
const results = [
|
|
1030
|
+
{
|
|
1031
|
+
title: `${query} - Complete Tutorial`,
|
|
1032
|
+
url: `https://video.example.com/tutorial/${query.replace(/\s+/g, "-")}`,
|
|
1033
|
+
description: `Complete tutorial about ${query}. Step-by-step guide with examples and demonstrations.`,
|
|
1034
|
+
displayUrl: "video.example.com",
|
|
1035
|
+
thumbnail: `https://video.example.com/thumb/tutorial-${query.replace(/\s+/g, "-")}.jpg`,
|
|
1036
|
+
publishedDate: /* @__PURE__ */ new Date("2024-01-05"),
|
|
1037
|
+
source: "Example Video",
|
|
1038
|
+
relevanceScore: 0.91
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
title: `${query} Explained in 5 Minutes`,
|
|
1042
|
+
url: `https://video.example.com/quick/${query.replace(/\s+/g, "-")}`,
|
|
1043
|
+
description: `Quick explanation of ${query} in just 5 minutes. Perfect for beginners and quick reference.`,
|
|
1044
|
+
displayUrl: "video.example.com",
|
|
1045
|
+
thumbnail: `https://video.example.com/thumb/quick-${query.replace(/\s+/g, "-")}.jpg`,
|
|
1046
|
+
publishedDate: /* @__PURE__ */ new Date("2024-01-03"),
|
|
1047
|
+
source: "Example Video",
|
|
1048
|
+
relevanceScore: 0.86
|
|
1049
|
+
}
|
|
1050
|
+
];
|
|
1051
|
+
return {
|
|
1052
|
+
query,
|
|
1053
|
+
results,
|
|
1054
|
+
totalResults: 8765,
|
|
1055
|
+
searchTime: 0.31
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
async getSuggestions(query) {
|
|
1059
|
+
this.runtime.logger.debug(`Getting suggestions for: "${query}"`);
|
|
1060
|
+
const suggestions = [
|
|
1061
|
+
`${query} tutorial`,
|
|
1062
|
+
`${query} guide`,
|
|
1063
|
+
`${query} examples`,
|
|
1064
|
+
`${query} best practices`,
|
|
1065
|
+
`${query} vs alternatives`,
|
|
1066
|
+
`how to ${query}`,
|
|
1067
|
+
`what is ${query}`,
|
|
1068
|
+
`${query} 2024`
|
|
1069
|
+
];
|
|
1070
|
+
return suggestions;
|
|
1071
|
+
}
|
|
1072
|
+
async getTrendingSearches(region) {
|
|
1073
|
+
this.runtime.logger.debug(`Getting trending searches for region: ${region || "global"}`);
|
|
1074
|
+
return [...this.trendingSearches].sort(() => Math.random() - 0.5);
|
|
1075
|
+
}
|
|
1076
|
+
async getPageInfo(url) {
|
|
1077
|
+
this.runtime.logger.debug(`Getting page info for: ${url}`);
|
|
1078
|
+
const domain = new URL(url).hostname;
|
|
1079
|
+
return {
|
|
1080
|
+
title: `Mock Page Title - ${domain}`,
|
|
1081
|
+
description: `This is a mock page description for ${url}. It provides detailed information about the page content.`,
|
|
1082
|
+
content: `Mock page content from ${url}.
|
|
1083
|
+
|
|
1084
|
+
This is a comprehensive analysis of the page including:
|
|
1085
|
+
- Main content sections
|
|
1086
|
+
- Important information
|
|
1087
|
+
- Key topics covered
|
|
1088
|
+
- Related resources
|
|
1089
|
+
|
|
1090
|
+
The page provides valuable insights and information for users interested in the topic.`,
|
|
1091
|
+
metadata: {
|
|
1092
|
+
"og:title": `Mock Page Title - ${domain}`,
|
|
1093
|
+
"og:description": `Mock page description for ${url}`,
|
|
1094
|
+
"og:type": "website",
|
|
1095
|
+
"og:url": url,
|
|
1096
|
+
"og:image": `${url}/og-image.jpg`,
|
|
1097
|
+
"twitter:card": "summary_large_image",
|
|
1098
|
+
"twitter:title": `Mock Page Title - ${domain}`,
|
|
1099
|
+
"twitter:description": `Mock page description for ${url}`,
|
|
1100
|
+
author: "Mock Author",
|
|
1101
|
+
keywords: "mock, page, content, analysis"
|
|
1102
|
+
},
|
|
1103
|
+
images: [`${url}/image1.jpg`, `${url}/image2.jpg`, `${url}/banner.jpg`],
|
|
1104
|
+
links: [
|
|
1105
|
+
`${url}/page1`,
|
|
1106
|
+
`${url}/page2`,
|
|
1107
|
+
`${url}/contact`,
|
|
1108
|
+
`${url}/about`,
|
|
1109
|
+
"https://external-link.com"
|
|
1110
|
+
]
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
// src/email/service.ts
|
|
1116
|
+
import {
|
|
1117
|
+
IEmailService
|
|
1118
|
+
} from "@elizaos/core";
|
|
1119
|
+
var DummyEmailService = class _DummyEmailService extends IEmailService {
|
|
1120
|
+
static serviceType = IEmailService.serviceType;
|
|
1121
|
+
mockEmails = [];
|
|
1122
|
+
mockFolders = [
|
|
1123
|
+
{
|
|
1124
|
+
name: "Inbox",
|
|
1125
|
+
path: "INBOX",
|
|
1126
|
+
type: "inbox",
|
|
1127
|
+
messageCount: 15,
|
|
1128
|
+
unreadCount: 3
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "Sent",
|
|
1132
|
+
path: "SENT",
|
|
1133
|
+
type: "sent",
|
|
1134
|
+
messageCount: 8,
|
|
1135
|
+
unreadCount: 0
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
name: "Drafts",
|
|
1139
|
+
path: "DRAFTS",
|
|
1140
|
+
type: "drafts",
|
|
1141
|
+
messageCount: 2,
|
|
1142
|
+
unreadCount: 0
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
name: "Trash",
|
|
1146
|
+
path: "TRASH",
|
|
1147
|
+
type: "trash",
|
|
1148
|
+
messageCount: 5,
|
|
1149
|
+
unreadCount: 0
|
|
1150
|
+
}
|
|
1151
|
+
];
|
|
1152
|
+
constructor(runtime) {
|
|
1153
|
+
super(runtime);
|
|
1154
|
+
this.initializeMockEmails();
|
|
1155
|
+
}
|
|
1156
|
+
static async start(runtime) {
|
|
1157
|
+
const service = new _DummyEmailService(runtime);
|
|
1158
|
+
await service.initialize();
|
|
1159
|
+
return service;
|
|
1160
|
+
}
|
|
1161
|
+
async initialize() {
|
|
1162
|
+
this.runtime.logger.info("DummyEmailService initialized");
|
|
1163
|
+
}
|
|
1164
|
+
async stop() {
|
|
1165
|
+
this.runtime.logger.info("DummyEmailService stopped");
|
|
1166
|
+
}
|
|
1167
|
+
initializeMockEmails() {
|
|
1168
|
+
this.mockEmails = [
|
|
1169
|
+
{
|
|
1170
|
+
from: { email: "alice@example.com", name: "Alice Smith" },
|
|
1171
|
+
to: [{ email: "user@example.com", name: "User" }],
|
|
1172
|
+
subject: "Project Update",
|
|
1173
|
+
text: "Hi! Just wanted to update you on the project progress. We've completed the first phase and are moving to the next milestone.",
|
|
1174
|
+
date: /* @__PURE__ */ new Date("2024-01-15T10:30:00Z"),
|
|
1175
|
+
messageId: "msg-001"
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
from: { email: "bob@company.com", name: "Bob Johnson" },
|
|
1179
|
+
to: [{ email: "user@example.com", name: "User" }],
|
|
1180
|
+
cc: [{ email: "team@company.com", name: "Team" }],
|
|
1181
|
+
subject: "Meeting Tomorrow",
|
|
1182
|
+
text: "Don't forget about our meeting tomorrow at 2 PM. We'll be discussing the quarterly results.",
|
|
1183
|
+
date: /* @__PURE__ */ new Date("2024-01-14T14:15:00Z"),
|
|
1184
|
+
messageId: "msg-002"
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
from: { email: "newsletter@tech.com", name: "Tech Newsletter" },
|
|
1188
|
+
to: [{ email: "user@example.com", name: "User" }],
|
|
1189
|
+
subject: "Weekly Tech Update",
|
|
1190
|
+
html: "<h1>This Week in Tech</h1><p>Latest technology news and updates.</p>",
|
|
1191
|
+
text: "This Week in Tech\n\nLatest technology news and updates.",
|
|
1192
|
+
date: /* @__PURE__ */ new Date("2024-01-13T09:00:00Z"),
|
|
1193
|
+
messageId: "msg-003"
|
|
1194
|
+
}
|
|
1195
|
+
];
|
|
1196
|
+
}
|
|
1197
|
+
async sendEmail(message, options) {
|
|
1198
|
+
this.runtime.logger.debug(`Sending email to ${message.to.map((t) => t.email).join(", ")}`);
|
|
1199
|
+
this.runtime.logger.debug(`Subject: ${message.subject}`);
|
|
1200
|
+
if (options) {
|
|
1201
|
+
this.runtime.logger.debug("Send options:", options);
|
|
1202
|
+
}
|
|
1203
|
+
const messageId = `mock-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1204
|
+
this.mockEmails.push({
|
|
1205
|
+
...message,
|
|
1206
|
+
messageId,
|
|
1207
|
+
date: /* @__PURE__ */ new Date()
|
|
1208
|
+
});
|
|
1209
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1210
|
+
return messageId;
|
|
1211
|
+
}
|
|
1212
|
+
async getEmails(options) {
|
|
1213
|
+
this.runtime.logger.debug("Getting emails");
|
|
1214
|
+
if (options) {
|
|
1215
|
+
this.runtime.logger.debug("Search options:", options);
|
|
1216
|
+
}
|
|
1217
|
+
let filteredEmails = [...this.mockEmails];
|
|
1218
|
+
if (options?.from) {
|
|
1219
|
+
filteredEmails = filteredEmails.filter(
|
|
1220
|
+
(email) => email.from.email.includes(options.from) || email.from.name?.includes(options.from)
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
if (options?.subject) {
|
|
1224
|
+
filteredEmails = filteredEmails.filter(
|
|
1225
|
+
(email) => email.subject.toLowerCase().includes(options.subject.toLowerCase())
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
if (options?.since) {
|
|
1229
|
+
filteredEmails = filteredEmails.filter((email) => email.date && email.date >= options.since);
|
|
1230
|
+
}
|
|
1231
|
+
if (options?.before) {
|
|
1232
|
+
filteredEmails = filteredEmails.filter(
|
|
1233
|
+
(email) => email.date && email.date <= options.before
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
const offset = options?.offset || 0;
|
|
1237
|
+
const limit = options?.limit || 50;
|
|
1238
|
+
return filteredEmails.slice(offset, offset + limit);
|
|
1239
|
+
}
|
|
1240
|
+
async getEmail(messageId) {
|
|
1241
|
+
this.runtime.logger.debug(`Getting email with ID: ${messageId}`);
|
|
1242
|
+
const email = this.mockEmails.find((e) => e.messageId === messageId);
|
|
1243
|
+
if (!email) {
|
|
1244
|
+
throw new Error(`Email with ID ${messageId} not found`);
|
|
1245
|
+
}
|
|
1246
|
+
return email;
|
|
1247
|
+
}
|
|
1248
|
+
async deleteEmail(messageId) {
|
|
1249
|
+
this.runtime.logger.debug(`Deleting email with ID: ${messageId}`);
|
|
1250
|
+
const index = this.mockEmails.findIndex((e) => e.messageId === messageId);
|
|
1251
|
+
if (index === -1) {
|
|
1252
|
+
throw new Error(`Email with ID ${messageId} not found`);
|
|
1253
|
+
}
|
|
1254
|
+
this.mockEmails.splice(index, 1);
|
|
1255
|
+
}
|
|
1256
|
+
async markEmailAsRead(messageId, read) {
|
|
1257
|
+
this.runtime.logger.debug(`Marking email ${messageId} as ${read ? "read" : "unread"}`);
|
|
1258
|
+
const email = this.mockEmails.find((e) => e.messageId === messageId);
|
|
1259
|
+
if (!email) {
|
|
1260
|
+
throw new Error(`Email with ID ${messageId} not found`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
async flagEmail(messageId, flagged) {
|
|
1264
|
+
this.runtime.logger.debug(`${flagged ? "Flagging" : "Unflagging"} email ${messageId}`);
|
|
1265
|
+
const email = this.mockEmails.find((e) => e.messageId === messageId);
|
|
1266
|
+
if (!email) {
|
|
1267
|
+
throw new Error(`Email with ID ${messageId} not found`);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
async moveEmail(messageId, folderPath) {
|
|
1271
|
+
this.runtime.logger.debug(`Moving email ${messageId} to folder ${folderPath}`);
|
|
1272
|
+
const email = this.mockEmails.find((e) => e.messageId === messageId);
|
|
1273
|
+
if (!email) {
|
|
1274
|
+
throw new Error(`Email with ID ${messageId} not found`);
|
|
1275
|
+
}
|
|
1276
|
+
const folder = this.mockFolders.find((f) => f.path === folderPath);
|
|
1277
|
+
if (!folder) {
|
|
1278
|
+
throw new Error(`Folder ${folderPath} not found`);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
async getFolders() {
|
|
1282
|
+
this.runtime.logger.debug("Getting email folders");
|
|
1283
|
+
return [...this.mockFolders];
|
|
1284
|
+
}
|
|
1285
|
+
async createFolder(folderName, parentPath) {
|
|
1286
|
+
this.runtime.logger.debug(
|
|
1287
|
+
`Creating folder ${folderName}${parentPath ? ` under ${parentPath}` : ""}`
|
|
1288
|
+
);
|
|
1289
|
+
const newFolder = {
|
|
1290
|
+
name: folderName,
|
|
1291
|
+
path: parentPath ? `${parentPath}/${folderName}` : folderName,
|
|
1292
|
+
type: "custom",
|
|
1293
|
+
messageCount: 0,
|
|
1294
|
+
unreadCount: 0
|
|
1295
|
+
};
|
|
1296
|
+
this.mockFolders.push(newFolder);
|
|
1297
|
+
}
|
|
1298
|
+
async getAccountInfo() {
|
|
1299
|
+
this.runtime.logger.debug("Getting account info");
|
|
1300
|
+
return {
|
|
1301
|
+
email: "user@example.com",
|
|
1302
|
+
name: "Mock User",
|
|
1303
|
+
provider: "MockProvider",
|
|
1304
|
+
folders: [...this.mockFolders],
|
|
1305
|
+
quotaUsed: 512e6,
|
|
1306
|
+
// 512 MB
|
|
1307
|
+
quotaLimit: 1073741824
|
|
1308
|
+
// 1 GB
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
async searchEmails(query, options) {
|
|
1312
|
+
this.runtime.logger.debug(`Searching emails with query: "${query}"`);
|
|
1313
|
+
if (options) {
|
|
1314
|
+
this.runtime.logger.debug("Search options:", options);
|
|
1315
|
+
}
|
|
1316
|
+
const filteredEmails = this.mockEmails.filter((email) => {
|
|
1317
|
+
const searchText = `${email.subject} ${email.text || ""} ${email.html || ""} ${email.from.name || ""} ${email.from.email}`;
|
|
1318
|
+
return searchText.toLowerCase().includes(query.toLowerCase());
|
|
1319
|
+
});
|
|
1320
|
+
let results = filteredEmails;
|
|
1321
|
+
if (options?.from) {
|
|
1322
|
+
results = results.filter(
|
|
1323
|
+
(email) => email.from.email.includes(options.from) || email.from.name?.includes(options.from)
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
if (options?.since) {
|
|
1327
|
+
results = results.filter((email) => email.date && email.date >= options.since);
|
|
1328
|
+
}
|
|
1329
|
+
if (options?.before) {
|
|
1330
|
+
results = results.filter((email) => email.date && email.date <= options.before);
|
|
1331
|
+
}
|
|
1332
|
+
const offset = options?.offset || 0;
|
|
1333
|
+
const limit = options?.limit || 50;
|
|
1334
|
+
return results.slice(offset, offset + limit);
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
|
|
347
1338
|
// src/e2e/scenarios.ts
|
|
348
1339
|
import { ILpService as ILpService2, ServiceType as ServiceType3 } from "@elizaos/core";
|
|
349
1340
|
import { strict as assert } from "assert";
|
|
@@ -650,7 +1641,17 @@ var dummyServicesScenariosSuite = {
|
|
|
650
1641
|
var dummyServicesPlugin = {
|
|
651
1642
|
name: "dummy-services",
|
|
652
1643
|
description: "Load standard dummy services for testing purposes.",
|
|
653
|
-
services: [
|
|
1644
|
+
services: [
|
|
1645
|
+
DummyTokenDataService,
|
|
1646
|
+
DummyLpService,
|
|
1647
|
+
DummyWalletService,
|
|
1648
|
+
DummyPdfService,
|
|
1649
|
+
DummyVideoService,
|
|
1650
|
+
DummyBrowserService,
|
|
1651
|
+
DummyTranscriptionService,
|
|
1652
|
+
DummyWebSearchService,
|
|
1653
|
+
DummyEmailService
|
|
1654
|
+
],
|
|
654
1655
|
tests: [dummyServicesScenariosSuite],
|
|
655
1656
|
init: async (runtime) => {
|
|
656
1657
|
console.log("Dummy Services Plugin Initialized");
|
|
@@ -658,9 +1659,15 @@ var dummyServicesPlugin = {
|
|
|
658
1659
|
};
|
|
659
1660
|
var index_default = dummyServicesPlugin;
|
|
660
1661
|
export {
|
|
1662
|
+
DummyBrowserService,
|
|
1663
|
+
DummyEmailService,
|
|
661
1664
|
DummyLpService,
|
|
1665
|
+
DummyPdfService,
|
|
662
1666
|
DummyTokenDataService,
|
|
1667
|
+
DummyTranscriptionService,
|
|
1668
|
+
DummyVideoService,
|
|
663
1669
|
DummyWalletService,
|
|
1670
|
+
DummyWebSearchService,
|
|
664
1671
|
index_default as default,
|
|
665
1672
|
dummyServicesPlugin
|
|
666
1673
|
};
|