|
1 | 1 | import { createTool } from "@mastra/core/tools"; |
2 | | -import { executeGenerateOrEditMedia } from "../../tools/media/execute"; |
3 | 2 | import { |
4 | | - GenerateOrEditMediaInputSchema, |
5 | | - GenerateOrEditMediaOutputSchema, |
| 3 | + executeGenerateOrEditImage, |
| 4 | + executeGenerateOrExtendVideo, |
| 5 | +} from "../../tools/media/execute"; |
| 6 | +import { |
| 7 | + GenerateImageOutputSchema, |
| 8 | + GenerateOrEditImageInputSchema, |
| 9 | + GenerateOrExtendVideoInputSchema, |
| 10 | + GenerateVideoOutputSchema, |
6 | 11 | } from "../../tools/media/schemas"; |
7 | 12 | import { resolveGoogleToolApiKey } from "./request-context"; |
8 | 13 | import { requestContextFromToolContext, workspaceRuntimeFromContext } from "./tool-runtime-context"; |
9 | 14 |
|
10 | | -/** Generates or edits media after lazily resolving the user's Google AI tool key. */ |
11 | | -export const mastraGenerateOrEditMedia = createTool({ |
12 | | - id: "generate_or_edit_media", |
| 15 | +/** Generates or edits one image through a contract that cannot accept video-only fields. */ |
| 16 | +export const mastraGenerateOrEditImage = createTool({ |
| 17 | + id: "generate_or_edit_image", |
| 18 | + description: |
| 19 | + "Generate a new image or edit/reference provided images with Google AI. Publishes the result to the project and Deliverables in one bounded call.", |
| 20 | + inputSchema: GenerateOrEditImageInputSchema, |
| 21 | + outputSchema: GenerateImageOutputSchema, |
| 22 | + execute: async (input, context) => { |
| 23 | + const requestContext = requestContextFromToolContext(context); |
| 24 | + const googleApiKey = await resolveGoogleToolApiKey(requestContext); |
| 25 | + return executeGenerateOrEditImage( |
| 26 | + GenerateOrEditImageInputSchema.parse(input), |
| 27 | + await workspaceRuntimeFromContext(context), |
| 28 | + googleApiKey ?? "", |
| 29 | + ); |
| 30 | + }, |
| 31 | +}); |
| 32 | + |
| 33 | +/** Generates or extends one video through a contract that cannot accept image-edit fields. */ |
| 34 | +export const mastraGenerateOrExtendVideo = createTool({ |
| 35 | + id: "generate_or_extend_video", |
13 | 36 | description: |
14 | | - "Generate or edit an image, or generate/extend a video, using Google media models. Stores the result in the project and Deliverables.", |
15 | | - inputSchema: GenerateOrEditMediaInputSchema, |
16 | | - outputSchema: GenerateOrEditMediaOutputSchema, |
| 37 | + "Generate a new video or extend a provided video with Google AI. Publishes the result to the project and Deliverables in one bounded call.", |
| 38 | + inputSchema: GenerateOrExtendVideoInputSchema, |
| 39 | + outputSchema: GenerateVideoOutputSchema, |
17 | 40 | execute: async (input, context) => { |
18 | 41 | const requestContext = requestContextFromToolContext(context); |
19 | 42 | const googleApiKey = await resolveGoogleToolApiKey(requestContext); |
20 | | - return executeGenerateOrEditMedia( |
21 | | - GenerateOrEditMediaInputSchema.parse(input), |
| 43 | + return executeGenerateOrExtendVideo( |
| 44 | + GenerateOrExtendVideoInputSchema.parse(input), |
22 | 45 | await workspaceRuntimeFromContext(context), |
23 | 46 | googleApiKey ?? "", |
24 | 47 | ); |
|
0 commit comments