From d410b29a59a4dfbf2c5f77661ad6e258ac975897 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 1 May 2025 01:17:55 -0700 Subject: [PATCH] fix(docs): updated doc generator to handle arrays --- docs/content/docs/tools/browser_use.mdx | 21 +++++++++++++++++++++ docs/content/docs/tools/mem0.mdx | 3 --- scripts/generate-block-docs.ts | 22 +++++++++++++++++++--- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/docs/content/docs/tools/browser_use.mdx b/docs/content/docs/tools/browser_use.mdx index 26b214841..c5cf6d993 100644 --- a/docs/content/docs/tools/browser_use.mdx +++ b/docs/content/docs/tools/browser_use.mdx @@ -65,6 +65,27 @@ Execute browser automation tasks with BrowserUse to navigate the web, scrape dat ### `browser_use_run_task` +Runs a browser automation task using BrowserUse + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `task` | string | Yes | What should the browser agent do | +| `apiKey` | string | Yes | API key for BrowserUse API | +| `pollInterval` | number | No | Interval between polling requests in milliseconds \(default: 5000\) | +| `maxPollTime` | number | No | Maximum time to poll for task completion in milliseconds \(default: 300000 - 5 minutes\) | + +#### Output + +| Parameter | Type | +| --------- | ---- | +| `id` | string | +| `task` | string | +| `output` | string | +| `status` | string | +| `steps` | string | +| `live_url` | string | diff --git a/docs/content/docs/tools/mem0.mdx b/docs/content/docs/tools/mem0.mdx index 92a113830..f37a945ec 100644 --- a/docs/content/docs/tools/mem0.mdx +++ b/docs/content/docs/tools/mem0.mdx @@ -49,7 +49,6 @@ Add memories to Mem0 for persistent storage and retrieval | `apiKey` | string | Yes | Your Mem0 API key | | `userId` | string | Yes | User ID associated with the memory | | `messages` | json | Yes | Array of message objects with role and content | -| `version` | string | No | API version to use \(v1 or v2\). Use v2 if unsure. | #### Output @@ -69,7 +68,6 @@ Search for memories in Mem0 using semantic search | `userId` | string | Yes | User ID to search memories for | | `query` | string | Yes | Search query to find relevant memories | | `limit` | number | No | Maximum number of results to return | -| `version` | string | No | API version to use \(v1 or v2\). Use v2 if unsure. | #### Output @@ -92,7 +90,6 @@ Retrieve memories from Mem0 by ID or filter criteria | `startDate` | string | No | Start date for filtering by created_at \(format: YYYY-MM-DD\) | | `endDate` | string | No | End date for filtering by created_at \(format: YYYY-MM-DD\) | | `limit` | number | No | Maximum number of results to return | -| `version` | string | No | API version to use \(v1 or v2\). Use v2 if unsure. | #### Output diff --git a/scripts/generate-block-docs.ts b/scripts/generate-block-docs.ts index e4cf4c3e1..443642d7f 100644 --- a/scripts/generate-block-docs.ts +++ b/scripts/generate-block-docs.ts @@ -526,7 +526,7 @@ function extractToolInfo(toolName: string, fileContent: string, filePath: string // If we couldn't extract outputs from transformResponse, try an alternative approach if (Object.keys(outputs).length === 0) { // Look for output in successful response in transformResponse - const successOutputRegex = /success\s*:\s*true,\s*output\s*:\s*(\{[^}]*\}|\w+(\.\w+)+\s*\|\|\s*\{[^}]*\})/ + const successOutputRegex = /success\s*:\s*true,\s*output\s*:\s*(\{[^}]*\}|\w+(\.\w+)+\s*\|\|\s*\{[^}]*\}|\w+(\.\w+)+\.map\s*\()/ const successOutputMatch = fileContent.match(successOutputRegex) if (successOutputMatch) { @@ -536,6 +536,22 @@ function extractToolInfo(toolName: string, fileContent: string, filePath: string if (outputExpression.includes('||')) { outputs.data = 'json' } + // Handle array mapping like "data.issues.map(...)" + else if (outputExpression.includes('.map')) { + // Try to extract the array object being mapped + const arrayMapMatch = outputExpression.match(/(\w+(?:\.\w+)+)\.map/) + if (arrayMapMatch) { + const arrayPath = arrayMapMatch[1] + // Get the base object being mapped to an array + const arrayObject = arrayPath.split('.').pop() + if (arrayObject) { + outputs[arrayObject] = 'Array of mapped items' + } + } else { + // Fallback if we can't extract the exact array object + outputs.items = 'Array of mapped items' + } + } // Handle direct object assignment like "output: { field1, field2 }" else if (outputExpression.startsWith('{')) { const fieldMatches = outputExpression.match(/(\w+)\s*:/g) @@ -657,8 +673,8 @@ async function getToolInfo(toolName: string): Promise<{ let toolPrefix = toolName.split('_')[0] let toolSuffix = toolName.split('_').slice(1).join('_') - // Handle special cases for Google tools - if (toolPrefix === 'google' && (toolName.startsWith('google_docs_') || toolName.startsWith('google_sheets_') || toolName.startsWith('google_drive_'))) { + // 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('_') }