From 6e682f5f4738e25581f297e9f12bbd8365c323cb Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 28 May 2025 10:11:35 -0700 Subject: [PATCH] fix(doc-generator): added in missing microsoft docs, fixed doc generator --- .../content/docs/tools/microsoft_teams.mdx | 73 +++++++++++++++++++ apps/sim/tools/airtable/create_records.ts | 3 - apps/sim/tools/google_docs/index.ts | 6 +- apps/sim/tools/google_drive/index.ts | 8 +- apps/sim/tools/google_sheets/index.ts | 8 +- apps/sim/tools/registry.ts | 40 +++++----- apps/sim/tools/stagehand/agent.ts | 3 - apps/sim/tools/stagehand/extract.ts | 3 - scripts/generate-block-docs.ts | 38 ++++++---- 9 files changed, 129 insertions(+), 53 deletions(-) diff --git a/apps/docs/content/docs/tools/microsoft_teams.mdx b/apps/docs/content/docs/tools/microsoft_teams.mdx index d3b868f26f..3e15fd5a51 100644 --- a/apps/docs/content/docs/tools/microsoft_teams.mdx +++ b/apps/docs/content/docs/tools/microsoft_teams.mdx @@ -103,15 +103,88 @@ Integrate Microsoft Teams functionality to manage messages. Read content from ex ### `microsoft_teams_read_chat` +Read content from a Microsoft Teams chat + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `accessToken` | string | Yes | The access token for the Microsoft Teams API | +| `chatId` | string | Yes | The ID of the chat to read from | + +#### Output + +| Parameter | Type | +| --------- | ---- | +| `content` | string | +| `metadata` | string | +| `messageCount` | string | +| `messages` | string | +| `totalAttachments` | string | +| `attachmentTypes` | string | ### `microsoft_teams_write_chat` +Write or update content in a Microsoft Teams chat + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `accessToken` | string | Yes | The access token for the Microsoft Teams API | +| `chatId` | string | Yes | The ID of the chat to write to | +| `content` | string | Yes | The content to write to the message | + +#### Output + +| Parameter | Type | +| --------- | ---- | +| `updatedContent` | string | +| `metadata` | string | ### `microsoft_teams_read_channel` +Read content from a Microsoft Teams channel + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `accessToken` | string | Yes | The access token for the Microsoft Teams API | +| `teamId` | string | Yes | The ID of the team to read from | +| `channelId` | string | Yes | The ID of the channel to read from | + +#### Output + +| Parameter | Type | +| --------- | ---- | +| `content` | string | +| `metadata` | string | +| `channelId` | string | +| `messageCount` | string | +| `messages` | string | +| `totalAttachments` | string | +| `attachmentTypes` | string | ### `microsoft_teams_write_channel` +Write or send a message to a Microsoft Teams channel + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `accessToken` | string | Yes | The access token for the Microsoft Teams API | +| `teamId` | string | Yes | The ID of the team to write to | +| `channelId` | string | Yes | The ID of the channel to write to | +| `content` | string | Yes | The content to write to the channel | + +#### Output + +| Parameter | Type | +| --------- | ---- | +| `updatedContent` | string | +| `metadata` | string | diff --git a/apps/sim/tools/airtable/create_records.ts b/apps/sim/tools/airtable/create_records.ts index 5e5524f1c8..6b9134271c 100644 --- a/apps/sim/tools/airtable/create_records.ts +++ b/apps/sim/tools/airtable/create_records.ts @@ -45,14 +45,12 @@ export const airtableCreateRecordsTool: ToolConfig ({ records: params.records }), }, transformResponse: async (response) => { const data = await response.json() if (!response.ok) { - // logger.error('Airtable API error:', data) throw new Error(data.error?.message || 'Failed to create Airtable records') } return { @@ -67,7 +65,6 @@ export const airtableCreateRecordsTool: ToolConfig { - // logger.error('Airtable tool error:', error) return `Failed to create Airtable records: ${error.message || 'Unknown error'}` }, } diff --git a/apps/sim/tools/google_docs/index.ts b/apps/sim/tools/google_docs/index.ts index bf5dc35932..9368fe7205 100644 --- a/apps/sim/tools/google_docs/index.ts +++ b/apps/sim/tools/google_docs/index.ts @@ -2,6 +2,6 @@ import { createTool } from './create' import { readTool } from './read' import { writeTool } from './write' -export const docsReadTool = readTool -export const docsWriteTool = writeTool -export const docsCreateTool = createTool +export const googleDocsReadTool = readTool +export const googleDocsWriteTool = writeTool +export const googleDocsCreateTool = createTool diff --git a/apps/sim/tools/google_drive/index.ts b/apps/sim/tools/google_drive/index.ts index 7680fa6b62..e6a3652243 100644 --- a/apps/sim/tools/google_drive/index.ts +++ b/apps/sim/tools/google_drive/index.ts @@ -3,7 +3,7 @@ import { getContentTool } from './get_content' import { listTool } from './list' import { uploadTool } from './upload' -export const driveCreateFolderTool = createFolderTool -export const driveGetContentTool = getContentTool -export const driveListTool = listTool -export const driveUploadTool = uploadTool +export const googleDriveCreateFolderTool = createFolderTool +export const googleDriveGetContentTool = getContentTool +export const googleDriveListTool = listTool +export const googleDriveUploadTool = uploadTool diff --git a/apps/sim/tools/google_sheets/index.ts b/apps/sim/tools/google_sheets/index.ts index a8d2990db1..e751103f56 100644 --- a/apps/sim/tools/google_sheets/index.ts +++ b/apps/sim/tools/google_sheets/index.ts @@ -3,7 +3,7 @@ import { readTool } from './read' import { updateTool } from './update' import { writeTool } from './write' -export const sheetsReadTool = readTool -export const sheetsWriteTool = writeTool -export const sheetsUpdateTool = updateTool -export const sheetsAppendTool = appendTool +export const googleSheetsReadTool = readTool +export const googleSheetsWriteTool = writeTool +export const googleSheetsUpdateTool = updateTool +export const googleSheetsAppendTool = appendTool diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index 46b6aeebf4..65fdbfaa66 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -27,18 +27,18 @@ import { } from './github' import { gmailReadTool, gmailSearchTool, gmailSendTool } from './gmail' import { searchTool as googleSearchTool } from './google' -import { docsCreateTool, docsReadTool, docsWriteTool } from './google_docs' +import { googleDocsCreateTool, googleDocsReadTool, googleDocsWriteTool } from './google_docs' import { - driveCreateFolderTool, - driveGetContentTool, - driveListTool, - driveUploadTool, + googleDriveCreateFolderTool, + googleDriveGetContentTool, + googleDriveListTool, + googleDriveUploadTool, } from './google_drive' import { - sheetsAppendTool, - sheetsReadTool, - sheetsUpdateTool, - sheetsWriteTool, + googleSheetsAppendTool, + googleSheetsReadTool, + googleSheetsUpdateTool, + googleSheetsWriteTool, } from './google_sheets' import { guestyGuestTool, guestyReservationTool } from './guesty' import { requestTool as httpRequest } from './http' @@ -139,17 +139,17 @@ export const tools: Record = { reddit_hot_posts: redditHotPostsTool, reddit_get_posts: redditGetPostsTool, reddit_get_comments: redditGetCommentsTool, - google_drive_get_content: driveGetContentTool, - google_drive_list: driveListTool, - google_drive_upload: driveUploadTool, - google_drive_create_folder: driveCreateFolderTool, - google_docs_read: docsReadTool, - google_docs_write: docsWriteTool, - google_docs_create: docsCreateTool, - google_sheets_read: sheetsReadTool, - google_sheets_write: sheetsWriteTool, - google_sheets_update: sheetsUpdateTool, - google_sheets_append: sheetsAppendTool, + google_drive_get_content: googleDriveGetContentTool, + google_drive_list: googleDriveListTool, + google_drive_upload: googleDriveUploadTool, + google_drive_create_folder: googleDriveCreateFolderTool, + google_docs_read: googleDocsReadTool, + google_docs_write: googleDocsWriteTool, + google_docs_create: googleDocsCreateTool, + google_sheets_read: googleSheetsReadTool, + google_sheets_write: googleSheetsWriteTool, + google_sheets_update: googleSheetsUpdateTool, + google_sheets_append: googleSheetsAppendTool, guesty_reservation: guestyReservationTool, guesty_guest: guestyGuestTool, perplexity_chat: perplexityChatTool, diff --git a/apps/sim/tools/stagehand/agent.ts b/apps/sim/tools/stagehand/agent.ts index b80055a6d5..8a3df00b2d 100644 --- a/apps/sim/tools/stagehand/agent.ts +++ b/apps/sim/tools/stagehand/agent.ts @@ -10,7 +10,6 @@ export const agentTool: ToolConfig description: 'Run an autonomous web agent to complete tasks and extract structured data', version: '1.0.0', - // Define the input parameters params: { task: { type: 'string', @@ -40,7 +39,6 @@ export const agentTool: ToolConfig }, }, - // Use HTTP request for server-side execution request: { url: '/api/tools/stagehand/agent', method: 'POST', @@ -64,7 +62,6 @@ export const agentTool: ToolConfig }, }, - // Transform the response transformResponse: async (response) => { try { const data = await response.json() diff --git a/apps/sim/tools/stagehand/extract.ts b/apps/sim/tools/stagehand/extract.ts index a6d565f189..ad990fa5a0 100644 --- a/apps/sim/tools/stagehand/extract.ts +++ b/apps/sim/tools/stagehand/extract.ts @@ -10,7 +10,6 @@ export const extractTool: ToolConfig { try { const data = await response.json() diff --git a/scripts/generate-block-docs.ts b/scripts/generate-block-docs.ts index feb27b8643..de933feedc 100644 --- a/scripts/generate-block-docs.ts +++ b/scripts/generate-block-docs.ts @@ -759,20 +759,32 @@ async function getToolInfo(toolName: string): Promise<{ outputs: Record } | null> { try { - // Get tool prefix and suffix - let toolPrefix = toolName.split('_')[0] - let toolSuffix = toolName.split('_').slice(1).join('_') + // Split the tool name into parts + const parts = toolName.split('_') - // Handle special cases for tools that have multiple parts - if ( - (toolPrefix === 'google' && - (toolName.startsWith('google_docs_') || - toolName.startsWith('google_sheets_') || - toolName.startsWith('google_drive_'))) || - toolName.startsWith('browser_use') - ) { - toolPrefix = toolName.split('_').slice(0, 2).join('_') - toolSuffix = toolName.split('_').slice(2).join('_') + // Try to find the correct split point by checking if directories exist + let toolPrefix = '' + let toolSuffix = '' + + // Start from the longest possible prefix and work backwards + for (let i = parts.length - 1; i >= 1; i--) { + const possiblePrefix = parts.slice(0, i).join('_') + const possibleSuffix = parts.slice(i).join('_') + + // Check if a directory exists for this prefix + const toolDirPath = path.join(rootDir, `apps/sim/tools/${possiblePrefix}`) + + if (fs.existsSync(toolDirPath) && fs.statSync(toolDirPath).isDirectory()) { + toolPrefix = possiblePrefix + toolSuffix = possibleSuffix + break + } + } + + // If no directory was found, fall back to single-part prefix + if (!toolPrefix) { + toolPrefix = parts[0] + toolSuffix = parts.slice(1).join('_') } // Simplify the file search strategy