From c38265e749898b130ba0c5f87c7f5f2e0057f162 Mon Sep 17 00:00:00 2001 From: flick Date: Fri, 22 Nov 2024 21:25:00 -0700 Subject: [PATCH 1/2] fix: pass runtime to video downloader --- packages/client-discord/src/attachments.ts | 5 ++++- packages/client-discord/src/messages.ts | 7 +++++-- packages/plugin-node/src/services/video.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/client-discord/src/attachments.ts b/packages/client-discord/src/attachments.ts index fe675e29bf7..129d9d072d0 100644 --- a/packages/client-discord/src/attachments.ts +++ b/packages/client-discord/src/attachments.ts @@ -335,7 +335,10 @@ export class AttachmentManager { } if (videoService.isVideoUrl(attachment.url)) { - const videoInfo = await videoService.processVideo(attachment.url); + const videoInfo = await videoService.processVideo( + attachment.url, + this.runtime + ); return { id: attachment.id, url: attachment.url, diff --git a/packages/client-discord/src/messages.ts b/packages/client-discord/src/messages.ts index 6c4069c0d6b..f96f0fc2936 100644 --- a/packages/client-discord/src/messages.ts +++ b/packages/client-discord/src/messages.ts @@ -693,7 +693,7 @@ export class MessageManager { if ( this.runtime .getService(ServiceType.VIDEO) - .isVideoUrl(url) + ?.isVideoUrl(url) ) { const videoService = this.runtime.getService( ServiceType.VIDEO @@ -701,7 +701,10 @@ export class MessageManager { if (!videoService) { throw new Error("Video service not found"); } - const videoInfo = await videoService.processVideo(url); + const videoInfo = await videoService.processVideo( + url, + this.runtime + ); attachments.push({ id: `youtube-${Date.now()}`, diff --git a/packages/plugin-node/src/services/video.ts b/packages/plugin-node/src/services/video.ts index 81554cc7a7b..9fc757ea660 100644 --- a/packages/plugin-node/src/services/video.ts +++ b/packages/plugin-node/src/services/video.ts @@ -93,7 +93,7 @@ export class VideoService extends Service implements IVideoService { public async processVideo( url: string, - runtime?: IAgentRuntime + runtime: IAgentRuntime ): Promise { this.queue.push(url); this.processQueue(runtime); From c64074a0268fc27730508897650299f5796ae945 Mon Sep 17 00:00:00 2001 From: flick Date: Fri, 22 Nov 2024 22:07:45 -0700 Subject: [PATCH 2/2] fix: this typescript should work but it causes a build error in plugin-node --- packages/core/src/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index f6ceb828679..40f9cf4492d 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1033,7 +1033,6 @@ export interface ITranscriptionService extends Service { export interface IVideoService extends Service { isVideoUrl(url: string): boolean; - processVideo(url: string): Promise; fetchVideoInfo(url: string): Promise; downloadVideo(videoInfo: Media): Promise; processVideo(url: string, runtime: IAgentRuntime): Promise;