Skip to content

Commit 5088074

Browse files
committed
Merge branch 'staging' into fix/verbiage
2 parents a5073aa + 5e2468c commit 5088074

File tree

8 files changed

+186
-13
lines changed

8 files changed

+186
-13
lines changed

apps/sim/executor/variables/resolvers/block.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
type Resolver,
1111
} from '@/executor/variables/resolvers/reference'
1212
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
13+
import { getTool } from '@/tools/utils'
1314

1415
function isPathInOutputSchema(
1516
outputs: Record<string, any> | undefined,
@@ -168,8 +169,11 @@ export class BlockResolver implements Resolver {
168169
}
169170
}
170171

171-
const schemaFields = getSchemaFieldNames(block?.outputs)
172-
if (schemaFields.length > 0 && !isPathInOutputSchema(block?.outputs, pathParts)) {
172+
const toolId = block?.config?.tool
173+
const toolConfig = toolId ? getTool(toolId) : undefined
174+
const outputSchema = toolConfig?.outputs ?? block?.outputs
175+
const schemaFields = getSchemaFieldNames(outputSchema)
176+
if (schemaFields.length > 0 && !isPathInOutputSchema(outputSchema, pathParts)) {
173177
throw new Error(
174178
`"${pathParts.join('.')}" doesn't exist on block "${blockName}". ` +
175179
`Available fields: ${schemaFields.join(', ')}`

apps/sim/tools/google_slides/add_image.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,24 @@ export const addImageTool: ToolConfig<AddImageParams, AddImageResponse> = {
200200
metadata: {
201201
type: 'json',
202202
description: 'Operation metadata including presentation ID and image URL',
203+
properties: {
204+
presentationId: {
205+
type: 'string',
206+
description: 'The presentation ID',
207+
},
208+
pageObjectId: {
209+
type: 'string',
210+
description: 'The page object ID where the image was inserted',
211+
},
212+
imageUrl: {
213+
type: 'string',
214+
description: 'The source image URL',
215+
},
216+
url: {
217+
type: 'string',
218+
description: 'URL to open the presentation',
219+
},
220+
},
203221
},
204222
},
205223
}

apps/sim/tools/google_slides/add_slide.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,25 @@ export const addSlideTool: ToolConfig<AddSlideParams, AddSlideResponse> = {
186186
metadata: {
187187
type: 'json',
188188
description: 'Operation metadata including presentation ID, layout, and URL',
189+
properties: {
190+
presentationId: {
191+
type: 'string',
192+
description: 'The presentation ID',
193+
},
194+
layout: {
195+
type: 'string',
196+
description: 'The layout used for the new slide',
197+
},
198+
insertionIndex: {
199+
type: 'number',
200+
description: 'The zero-based index where the slide was inserted',
201+
optional: true,
202+
},
203+
url: {
204+
type: 'string',
205+
description: 'URL to open the presentation',
206+
},
207+
},
189208
},
190209
},
191210
}

apps/sim/tools/google_slides/create.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ export const createTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesCreateRe
153153
metadata: {
154154
type: 'json',
155155
description: 'Created presentation metadata including ID, title, and URL',
156+
properties: {
157+
presentationId: {
158+
type: 'string',
159+
description: 'The presentation ID',
160+
},
161+
title: {
162+
type: 'string',
163+
description: 'The presentation title',
164+
},
165+
mimeType: {
166+
type: 'string',
167+
description: 'The mime type of the presentation',
168+
},
169+
url: {
170+
type: 'string',
171+
description: 'URL to open the presentation',
172+
},
173+
},
156174
},
157175
},
158176
}

apps/sim/tools/google_slides/get_thumbnail.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,24 @@ export const getThumbnailTool: ToolConfig<GetThumbnailParams, GetThumbnailRespon
167167
metadata: {
168168
type: 'json',
169169
description: 'Operation metadata including presentation ID and page object ID',
170+
properties: {
171+
presentationId: {
172+
type: 'string',
173+
description: 'The presentation ID',
174+
},
175+
pageObjectId: {
176+
type: 'string',
177+
description: 'The page object ID for the thumbnail',
178+
},
179+
thumbnailSize: {
180+
type: 'string',
181+
description: 'The requested thumbnail size',
182+
},
183+
mimeType: {
184+
type: 'string',
185+
description: 'The thumbnail MIME type',
186+
},
187+
},
170188
},
171189
},
172190
}

apps/sim/tools/google_slides/read.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,39 @@ export const readTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesReadRespon
7979
metadata: {
8080
type: 'json',
8181
description: 'Presentation metadata including ID, title, and URL',
82+
properties: {
83+
presentationId: {
84+
type: 'string',
85+
description: 'The presentation ID',
86+
},
87+
title: {
88+
type: 'string',
89+
description: 'The presentation title',
90+
},
91+
pageSize: {
92+
type: 'object',
93+
description: 'Presentation page size',
94+
optional: true,
95+
properties: {
96+
width: {
97+
type: 'json',
98+
description: 'Page width as a Dimension object',
99+
},
100+
height: {
101+
type: 'json',
102+
description: 'Page height as a Dimension object',
103+
},
104+
},
105+
},
106+
mimeType: {
107+
type: 'string',
108+
description: 'The mime type of the presentation',
109+
},
110+
url: {
111+
type: 'string',
112+
description: 'URL to open the presentation',
113+
},
114+
},
82115
},
83116
},
84117
}

apps/sim/tools/google_slides/replace_all_text.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@ export const replaceAllTextTool: ToolConfig<ReplaceAllTextParams, ReplaceAllText
164164
metadata: {
165165
type: 'json',
166166
description: 'Operation metadata including presentation ID and URL',
167+
properties: {
168+
presentationId: {
169+
type: 'string',
170+
description: 'The presentation ID',
171+
},
172+
findText: {
173+
type: 'string',
174+
description: 'The text that was searched for',
175+
},
176+
replaceText: {
177+
type: 'string',
178+
description: 'The text that replaced the matches',
179+
},
180+
url: {
181+
type: 'string',
182+
description: 'URL to open the presentation',
183+
},
184+
},
167185
},
168186
},
169187
}

apps/sim/tools/google_slides/write.ts

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,39 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
9292
}
9393
).then((res) => res.json())
9494

95-
const slideIndex = params.slideIndex || 0
95+
const metadata = {
96+
presentationId,
97+
title: presentationData.title || 'Updated Presentation',
98+
mimeType: 'application/vnd.google-apps.presentation',
99+
url: `https://docs.google.com/presentation/d/${presentationId}/edit`,
100+
}
101+
102+
const slideIndex =
103+
typeof params.slideIndex === 'string'
104+
? Number.parseInt(params.slideIndex, 10)
105+
: (params.slideIndex ?? 0)
96106
const slide = presentationData.slides?.[slideIndex]
97107

108+
if (Number.isNaN(slideIndex) || slideIndex < 0) {
109+
return {
110+
success: false,
111+
error: 'Slide index must be a non-negative number',
112+
output: {
113+
updatedContent: false,
114+
metadata,
115+
},
116+
}
117+
}
118+
98119
if (!slide) {
99-
throw new Error(`Slide at index ${slideIndex} not found`)
120+
return {
121+
success: false,
122+
error: `Slide at index ${slideIndex} not found`,
123+
output: {
124+
updatedContent: false,
125+
metadata,
126+
},
127+
}
100128
}
101129

102130
// Create requests to add content to the slide
@@ -153,15 +181,14 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
153181
if (!updateResponse.ok) {
154182
const errorText = await updateResponse.text()
155183
logger.error('Failed to update presentation:', { errorText })
156-
throw new Error('Failed to update presentation')
157-
}
158-
159-
// Create presentation metadata
160-
const metadata = {
161-
presentationId,
162-
title: presentationData.title || 'Updated Presentation',
163-
mimeType: 'application/vnd.google-apps.presentation',
164-
url: `https://docs.google.com/presentation/d/${presentationId}/edit`,
184+
return {
185+
success: false,
186+
error: 'Failed to update presentation',
187+
output: {
188+
updatedContent: false,
189+
metadata,
190+
},
191+
}
165192
}
166193

167194
return {
@@ -185,6 +212,24 @@ export const writeTool: ToolConfig<GoogleSlidesToolParams, GoogleSlidesWriteResp
185212
metadata: {
186213
type: 'json',
187214
description: 'Updated presentation metadata including ID, title, and URL',
215+
properties: {
216+
presentationId: {
217+
type: 'string',
218+
description: 'The presentation ID',
219+
},
220+
title: {
221+
type: 'string',
222+
description: 'The presentation title',
223+
},
224+
mimeType: {
225+
type: 'string',
226+
description: 'The mime type of the presentation',
227+
},
228+
url: {
229+
type: 'string',
230+
description: 'URL to open the presentation',
231+
},
232+
},
188233
},
189234
},
190235

0 commit comments

Comments
 (0)