Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/sim/tools/google_slides/add_image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,24 @@ export const addImageTool: ToolConfig<AddImageParams, AddImageResponse> = {
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and image URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
pageObjectId: {
type: 'string',
description: 'The page object ID where the image was inserted',
},
imageUrl: {
type: 'string',
description: 'The source image URL',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
19 changes: 19 additions & 0 deletions apps/sim/tools/google_slides/add_slide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,25 @@ export const addSlideTool: ToolConfig<AddSlideParams, AddSlideResponse> = {
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID, layout, and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
layout: {
type: 'string',
description: 'The layout used for the new slide',
},
insertionIndex: {
type: 'number',
description: 'The zero-based index where the slide was inserted',
optional: true,
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
18 changes: 18 additions & 0 deletions apps/sim/tools/google_slides/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ export const createTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesCreateRe
metadata: {
type: 'json',
description: 'Created presentation metadata including ID, title, and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
title: {
type: 'string',
description: 'The presentation title',
},
mimeType: {
type: 'string',
description: 'The mime type of the presentation',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
14 changes: 14 additions & 0 deletions apps/sim/tools/google_slides/create_shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,20 @@ export const createShapeTool: ToolConfig<CreateShapeParams, CreateShapeResponse>
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and page object ID',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
pageObjectId: {
type: 'string',
description: 'The page object ID where the shape was created',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
14 changes: 14 additions & 0 deletions apps/sim/tools/google_slides/create_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ export const createTableTool: ToolConfig<CreateTableParams, CreateTableResponse>
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and page object ID',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
pageObjectId: {
type: 'string',
description: 'The page object ID where the table was created',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
10 changes: 10 additions & 0 deletions apps/sim/tools/google_slides/delete_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ export const deleteObjectTool: ToolConfig<DeleteObjectParams, DeleteObjectRespon
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
14 changes: 14 additions & 0 deletions apps/sim/tools/google_slides/duplicate_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ export const duplicateObjectTool: ToolConfig<DuplicateObjectParams, DuplicateObj
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and source object ID',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
sourceObjectId: {
type: 'string',
description: 'The object ID that was duplicated',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
10 changes: 10 additions & 0 deletions apps/sim/tools/google_slides/get_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ export const getPageTool: ToolConfig<GetPageParams, GetPageResponse> = {
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
18 changes: 18 additions & 0 deletions apps/sim/tools/google_slides/get_thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ export const getThumbnailTool: ToolConfig<GetThumbnailParams, GetThumbnailRespon
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and page object ID',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
pageObjectId: {
type: 'string',
description: 'The page object ID for the thumbnail',
},
thumbnailSize: {
type: 'string',
description: 'The requested thumbnail size',
},
mimeType: {
type: 'string',
description: 'The thumbnail MIME type',
},
},
},
},
}
10 changes: 10 additions & 0 deletions apps/sim/tools/google_slides/insert_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ export const insertTextTool: ToolConfig<InsertTextParams, InsertTextResponse> =
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
33 changes: 33 additions & 0 deletions apps/sim/tools/google_slides/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,39 @@ export const readTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesReadRespon
metadata: {
type: 'json',
description: 'Presentation metadata including ID, title, and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
title: {
type: 'string',
description: 'The presentation title',
},
pageSize: {
type: 'object',
description: 'Presentation page size',
optional: true,
properties: {
width: {
type: 'json',
description: 'Page width as a Dimension object',
},
height: {
type: 'json',
description: 'Page height as a Dimension object',
},
},
},
mimeType: {
type: 'string',
description: 'The mime type of the presentation',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
18 changes: 18 additions & 0 deletions apps/sim/tools/google_slides/replace_all_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ export const replaceAllTextTool: ToolConfig<ReplaceAllTextParams, ReplaceAllText
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
findText: {
type: 'string',
description: 'The text that was searched for',
},
replaceText: {
type: 'string',
description: 'The text that replaced the matches',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
10 changes: 10 additions & 0 deletions apps/sim/tools/google_slides/update_slides_position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ export const updateSlidesPositionTool: ToolConfig<
metadata: {
type: 'json',
description: 'Operation metadata including presentation ID and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},
}
67 changes: 56 additions & 11 deletions apps/sim/tools/google_slides/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,39 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
}
).then((res) => res.json())

const slideIndex = params.slideIndex || 0
const metadata = {
presentationId,
title: presentationData.title || 'Updated Presentation',
mimeType: 'application/vnd.google-apps.presentation',
url: `https://docs.google.com/presentation/d/${presentationId}/edit`,
}

const slideIndex =
typeof params.slideIndex === 'string'
? Number.parseInt(params.slideIndex, 10)
: (params.slideIndex ?? 0)
const slide = presentationData.slides?.[slideIndex]

if (Number.isNaN(slideIndex) || slideIndex < 0) {
return {
success: false,
error: 'Slide index must be a non-negative number',
output: {
updatedContent: false,
metadata,
},
}
}

if (!slide) {
throw new Error(`Slide at index ${slideIndex} not found`)
return {
success: false,
error: `Slide at index ${slideIndex} not found`,
output: {
updatedContent: false,
metadata,
},
}
}

// Create requests to add content to the slide
Expand Down Expand Up @@ -153,15 +181,14 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
if (!updateResponse.ok) {
const errorText = await updateResponse.text()
logger.error('Failed to update presentation:', { errorText })
throw new Error('Failed to update presentation')
}

// Create presentation metadata
const metadata = {
presentationId,
title: presentationData.title || 'Updated Presentation',
mimeType: 'application/vnd.google-apps.presentation',
url: `https://docs.google.com/presentation/d/${presentationId}/edit`,
return {
success: false,
error: 'Failed to update presentation',
output: {
updatedContent: false,
metadata,
},
}
}

return {
Expand All @@ -185,6 +212,24 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
metadata: {
type: 'json',
description: 'Updated presentation metadata including ID, title, and URL',
properties: {
presentationId: {
type: 'string',
description: 'The presentation ID',
},
title: {
type: 'string',
description: 'The presentation title',
},
mimeType: {
type: 'string',
description: 'The mime type of the presentation',
},
url: {
type: 'string',
description: 'URL to open the presentation',
},
},
},
},

Expand Down