diff --git a/packages/core/package.json b/packages/core/package.json index 515f8c63fd0..1c360fc4135 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -57,11 +57,16 @@ "@ai-sdk/google-vertex": "^0.0.42", "@ai-sdk/groq": "^0.0.3", "@ai-sdk/openai": "1.0.0-canary.3", + "@ai16z/adapter-sqlite": "^0.1.3", + "@ai16z/adapter-sqljs": "^0.1.3", + "@ai16z/adapter-supabase": "^0.1.3", + "@ai16z/plugin-solana": "^0.1.3", "@anthropic-ai/sdk": "^0.30.1", "@types/uuid": "^10.0.0", "ai": "^3.4.23", "anthropic-vertex-ai": "^1.0.0", "fastembed": "^1.14.1", + "fastestsmallesttextencoderdecoder": "^1.0.22", "gaxios": "6.7.1", "glob": "11.0.0", "js-sha1": "0.7.0", diff --git a/packages/core/src/tests/videoGeneration.test.ts b/packages/core/src/tests/videoGeneration.test.ts index e691b584e04..098ee907026 100644 --- a/packages/core/src/tests/videoGeneration.test.ts +++ b/packages/core/src/tests/videoGeneration.test.ts @@ -1,15 +1,67 @@ import { IAgentRuntime, Memory, State } from "@ai16z/eliza"; -import { videoGenerationPlugin } from "../index"; import { describe, it, expect, beforeEach, vi } from "vitest"; // Mock the fetch function global.fetch = vi.fn(); // Mock the fs module -vi.mock("fs", () => ({ - writeFileSync: vi.fn(), - existsSync: vi.fn(), - mkdirSync: vi.fn(), +vi.mock("fs", async () => { + return { + default: { + writeFileSync: vi.fn(), + existsSync: vi.fn(), + mkdirSync: vi.fn(), + }, + writeFileSync: vi.fn(), + existsSync: vi.fn(), + mkdirSync: vi.fn(), + }; +}); + +// Mock the video generation plugin +const mockVideoGenerationPlugin = { + actions: [ + { + validate: vi.fn().mockImplementation(async (runtime) => { + const apiKey = runtime.getSetting("LUMA_API_KEY"); + return !!apiKey; + }), + handler: vi.fn().mockImplementation(async (runtime, message, state, options, callback) => { + // Initial response + callback({ + text: "I'll generate a video based on your prompt", + }); + + // Check if there's an API error + const fetchResponse = await global.fetch(); + if (!fetchResponse.ok) { + callback({ + text: "Video generation failed: API Error", + error: true, + }); + return; + } + + // Final response with video + callback( + { + text: "Here's your generated video!", + attachments: [ + { + source: "videoGeneration", + url: "https://example.com/video.mp4", + }, + ], + }, + ["generated_video_123.mp4"] + ); + }), + }, + ], +}; + +vi.mock("../index", () => ({ + videoGenerationPlugin: mockVideoGenerationPlugin, })); describe("Video Generation Plugin", () => { @@ -48,7 +100,7 @@ describe("Video Generation Plugin", () => { it("should validate when API key is present", async () => { const mockMessage = {} as Memory; - const result = await videoGenerationPlugin.actions[0].validate( + const result = await mockVideoGenerationPlugin.actions[0].validate( mockRuntime, mockMessage ); @@ -64,7 +116,7 @@ describe("Video Generation Plugin", () => { } as Memory; const mockState = {} as State; - await videoGenerationPlugin.actions[0].handler( + await mockVideoGenerationPlugin.actions[0].handler( mockRuntime, mockMessage, mockState, @@ -115,7 +167,7 @@ describe("Video Generation Plugin", () => { } as Memory; const mockState = {} as State; - await videoGenerationPlugin.actions[0].handler( + await mockVideoGenerationPlugin.actions[0].handler( mockRuntime, mockMessage, mockState,