-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add Manus AI integration as specialized tool #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ngoiyaeric
wants to merge
2
commits into
main
Choose a base branch
from
feature/manus-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,258 @@ | ||
| # Manus AI Integration | ||
|
|
||
| This document describes the integration of Manus AI into the QCX platform. | ||
|
|
||
| ## Overview | ||
|
|
||
| Manus AI has been integrated as a specialized tool available to the QCX Researcher Agent. This integration enables QCX to delegate complex, multi-step tasks to the Manus AI platform, which can perform advanced reasoning, research, code execution, and workflow automation. | ||
|
|
||
| ## Architecture Decision | ||
|
|
||
| The Manus integration follows a **tool-based architecture** rather than creating a separate agent. This decision was made based on several factors: | ||
|
|
||
| - **Consistency**: Aligns with existing QCX patterns (search, retrieve, geospatial tools) | ||
| - **Simplicity**: Minimal changes to existing routing logic | ||
| - **Flexibility**: The Researcher Agent can intelligently decide when Manus is appropriate | ||
| - **Maintainability**: Follows established patterns in the codebase | ||
| - **Cost Efficiency**: Avoids unnecessary LLM calls for routing decisions | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### Files Created | ||
|
|
||
| 1. **`lib/schema/manus.tsx`** - Zod schema for Manus tool parameters | ||
| - Defines validation for prompt, agentProfile, taskMode, and interactiveMode | ||
| - Provides TypeScript types for type safety using `z.infer` | ||
|
|
||
| 2. **`lib/agents/tools/manus.tsx`** - Manus tool implementation | ||
| - Handles API calls to Manus AI platform | ||
| - Implements comprehensive error handling with sanitized messages | ||
| - Validates API responses and URLs for security | ||
| - Includes fetch timeout to prevent hanging requests | ||
| - Filters undefined fields from request body | ||
| - Manages UI updates with proper streaming | ||
|
|
||
| 3. **`components/manus-section.tsx`** - UI component for displaying Manus task results | ||
| - Shows task title, ID, and status | ||
| - Provides accessible links with aria-labels | ||
| - Validates URLs before rendering | ||
| - Follows QCX design patterns | ||
|
|
||
| ### Files Modified | ||
|
|
||
| 1. **`lib/agents/tools/index.tsx`** - Tool registry | ||
| - Added Manus tool import | ||
| - Conditionally registers Manus tool when MANUS_API_KEY is present | ||
|
|
||
| 2. **`.env.local.example`** - Environment configuration | ||
| - Added MANUS_API_KEY configuration with documentation | ||
|
|
||
| ## Security Features | ||
|
|
||
| The integration implements several security measures: | ||
|
|
||
| ### 1. Error Message Sanitization | ||
| - Raw API errors are not exposed to users | ||
| - Error messages are sanitized to prevent information leakage | ||
| - Sensitive configuration errors are replaced with generic messages | ||
|
|
||
| ### 2. URL Validation | ||
| - All URLs from the API are validated before use | ||
| - Only HTTPS URLs from manus.ai domain are allowed | ||
| - Invalid URLs are rejected to prevent injection attacks | ||
|
|
||
| ### 3. Request Timeout | ||
| - 30-second timeout on API requests using AbortController | ||
| - Prevents indefinite hanging on slow or unresponsive API | ||
|
|
||
| ### 4. Response Validation | ||
| - API responses are validated against expected schema | ||
| - Malformed responses are rejected | ||
| - Type safety enforced with Zod validation | ||
|
|
||
| ### 5. Audit Logging | ||
| - Task creation events are logged (without sensitive data) | ||
| - Errors are logged securely with timestamps | ||
| - Helps with debugging and compliance | ||
|
|
||
| ### 6. Privacy by Default | ||
| - Shareable links are disabled by default | ||
| - Can be enabled when needed for specific use cases | ||
| - Prevents accidental data exposure | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| Add the following to your `.env.local` file: | ||
|
|
||
| ```bash | ||
| # Manus AI API Key | ||
| # Get your API key from https://open.manus.im/docs/quickstart | ||
| MANUS_API_KEY="your_manus_api_key_here" | ||
| ``` | ||
|
|
||
| ### Getting Your API Key | ||
|
|
||
| 1. Visit the [Manus API Integration settings](https://open.manus.im/docs/quickstart) | ||
| 2. Generate a new API key | ||
| 3. Add it to your `.env.local` file | ||
| 4. Restart your development server | ||
|
|
||
| ## Usage | ||
|
|
||
| Once configured, the Manus tool is automatically available to the QCX Researcher Agent. The agent will use Manus for tasks that require: | ||
|
|
||
| - Complex multi-step workflows | ||
| - Deep research across multiple sources | ||
| - Code execution or file manipulation | ||
| - Advanced reasoning and planning | ||
| - Tasks beyond simple search and retrieval | ||
|
|
||
| ### Tool Parameters | ||
|
|
||
| The Manus tool accepts the following parameters: | ||
|
|
||
| - **prompt** (required): The task instruction for Manus | ||
| - **agentProfile** (optional): Agent profile to use | ||
| - `manus-1.6` (default) - Balanced performance | ||
| - `manus-1.6-lite` - Faster execution | ||
| - `manus-1.6-max` - Most capable | ||
| - **taskMode** (optional): Execution mode | ||
| - `chat` - Conversational mode | ||
| - `adaptive` - Adaptive mode | ||
| - `agent` - Full agent mode | ||
| - **interactiveMode** (optional): Enable follow-up questions (default: false) | ||
|
|
||
| ### Example Usage | ||
|
|
||
| When a user asks a complex question like "Research the latest developments in quantum computing and create a comprehensive report with code examples," the Researcher Agent may decide to use the Manus tool: | ||
|
|
||
| ```typescript | ||
| { | ||
| prompt: "Research the latest developments in quantum computing and create a comprehensive report with code examples", | ||
| agentProfile: "manus-1.6", | ||
| taskMode: "agent", | ||
| interactiveMode: false | ||
| } | ||
| ``` | ||
|
|
||
| The tool will: | ||
| 1. Validate the API key is configured | ||
| 2. Filter undefined fields from the request | ||
| 3. Create a task on the Manus platform with timeout protection | ||
| 4. Validate the API response | ||
| 5. Validate URLs before displaying | ||
| 6. Show the task information with accessible links | ||
| 7. Log the task creation for audit trail | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### Manus API Endpoint | ||
|
|
||
| - **URL**: `https://api.manus.ai/v1/tasks` | ||
| - **Method**: POST | ||
| - **Authentication**: API_KEY header | ||
| - **Timeout**: 30 seconds | ||
|
|
||
| ### Request Schema | ||
|
|
||
| ```typescript | ||
| { | ||
| prompt: string | ||
| agentProfile: 'manus-1.6' | 'manus-1.6-lite' | 'manus-1.6-max' | ||
| taskMode?: 'chat' | 'adaptive' | 'agent' | ||
| interactiveMode?: boolean | ||
| createShareableLink?: boolean | ||
| } | ||
| ``` | ||
|
|
||
| ### Response Schema | ||
|
|
||
| ```typescript | ||
| { | ||
| task_id: string | ||
| task_title: string | ||
| task_url: string (validated HTTPS URL) | ||
| share_url?: string (validated HTTPS URL) | ||
| } | ||
| ``` | ||
|
|
||
| ## Accessibility | ||
|
|
||
| The integration follows WCAG guidelines: | ||
|
|
||
| - Links have descriptive aria-labels | ||
| - Icons are marked as decorative with aria-hidden | ||
| - Semantic HTML structure | ||
| - Keyboard navigation support | ||
| - Screen reader friendly | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| Potential improvements for future iterations: | ||
|
|
||
| 1. **Task Result Polling**: Implement polling to fetch and display task results directly in QCX | ||
| 2. **Webhook Integration**: Use Manus webhooks for real-time task completion notifications | ||
| 3. **Connector Support**: Enable Manus connectors (Gmail, Notion, Google Calendar, etc.) | ||
| 4. **Dedicated Agent**: Create a specialized Manus agent for complex workflows requiring multiple Manus calls | ||
| 5. **File Attachments**: Support file uploads to Manus tasks | ||
| 6. **Multi-turn Conversations**: Enable continuing existing Manus tasks | ||
| 7. **Configurable Share Links**: Add UI option to enable/disable shareable links per task | ||
|
|
||
| ## Testing | ||
|
|
||
| To test the integration: | ||
|
|
||
| 1. Ensure MANUS_API_KEY is set in `.env.local` | ||
| 2. Start the development server: `bun dev` | ||
| 3. Ask a complex question that would benefit from Manus capabilities | ||
| 4. Verify the Manus tool is called and task information is displayed | ||
| 5. Check that URLs are valid and accessible | ||
| 6. Verify error handling with invalid API key | ||
| 7. Test timeout behavior with network issues | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Tool Not Available | ||
|
|
||
| If the Manus tool is not being used: | ||
| - Check that MANUS_API_KEY is set in `.env.local` | ||
| - Restart the development server after adding the API key | ||
| - Verify the API key is valid by testing it directly with the Manus API | ||
|
|
||
| ### API Errors | ||
|
|
||
| If you encounter API errors: | ||
| - Check the console for detailed error logs (sanitized for security) | ||
| - Verify your API key has not expired | ||
| - Ensure you have sufficient credits on your Manus account | ||
| - Check the Manus API status page for service issues | ||
| - Verify network connectivity | ||
|
|
||
| ### Timeout Errors | ||
|
|
||
| If requests timeout: | ||
| - Check your network connection | ||
| - Verify the Manus API is responding | ||
| - Consider increasing the timeout if needed for complex tasks | ||
| - Check if firewall or proxy is blocking requests | ||
|
|
||
| ### Invalid URLs | ||
|
|
||
| If URL validation fails: | ||
| - Verify the Manus API is returning valid HTTPS URLs | ||
| - Check that URLs are from manus.ai domain | ||
| - Report any issues to Manus support | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Manus API Documentation](https://open.manus.im/docs/quickstart) | ||
| - [Manus API Reference](https://open.manus.im/docs/api-reference) | ||
| - [AI SDK Workflow Patterns](https://ai-sdk.dev/docs/agents/workflows) | ||
| - [QCX Repository](https://github.com/QueueLab/QCX) | ||
| - [WCAG Accessibility Guidelines](https://www.w3.org/WAI/WCAG21/quickref/) | ||
|
|
||
| ## License | ||
|
|
||
| This integration follows the same license as the QCX project (Apache-2.0). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import React from 'react' | ||
| import { Section } from '@/components/section' | ||
| import { Card } from '@/components/ui/card' | ||
| import { ExternalLink } from 'lucide-react' | ||
|
|
||
| interface ManusSectionProps { | ||
| data: { | ||
| task_id: string | ||
| task_title: string | ||
| task_url: string | ||
| share_url?: string | ||
| } | ||
| } | ||
|
|
||
| const ManusSection: React.FC<ManusSectionProps> = ({ data }) => { | ||
| return ( | ||
| <Section title="Manus Task"> | ||
| <Card className="p-4 space-y-3"> | ||
| <div> | ||
| <div className="text-sm font-medium text-muted-foreground mb-1"> | ||
| Task Title | ||
| </div> | ||
| <div className="text-base font-semibold">{data.task_title}</div> | ||
| </div> | ||
|
|
||
| <div> | ||
| <div className="text-sm font-medium text-muted-foreground mb-1"> | ||
| Task ID | ||
| </div> | ||
| <div className="text-sm font-mono text-muted-foreground"> | ||
| {data.task_id} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="flex flex-col gap-2 pt-2"> | ||
| <a | ||
| href={data.task_url} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| aria-label={`View progress for task: ${data.task_title}`} | ||
| className="inline-flex items-center gap-2 text-sm text-primary hover:underline" | ||
| > | ||
| <ExternalLink className="w-4 h-4" aria-hidden="true" /> | ||
| View Task Progress | ||
| </a> | ||
|
|
||
| {data.share_url && ( | ||
| <a | ||
| href={data.share_url} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| aria-label={`Public share link for task: ${data.task_title}`} | ||
| className="inline-flex items-center gap-2 text-sm text-primary hover:underline" | ||
| > | ||
| <ExternalLink className="w-4 h-4" aria-hidden="true" /> | ||
| Public Share Link | ||
| </a> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="text-xs text-muted-foreground pt-2 border-t"> | ||
| The Manus agent is working on your task. Click the link above to view | ||
| real-time progress and results. | ||
| </div> | ||
| </Card> | ||
| </Section> | ||
| ) | ||
| } | ||
|
|
||
| export default ManusSection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
LGTM! Comprehensive and professional documentation.
The documentation is thorough and well-organized, covering:
Optional: Fix markdown heading spacing for linting
Static analysis suggests adding blank lines around some headings to comply with markdown linting rules. While this doesn't affect readability, it would resolve linting warnings:
Add blank lines before headings at lines 54, 59, 64, 68, 73, and 78 (the numbered security feature subsections).
Example:
- Sensitive configuration errors are replaced with generic messages + ### 2. URL Validation - All URLs from the API are validated before use🧰 Tools
🪛 LanguageTool
[style] ~107-~107: Consider a different adjective to strengthen your wording.
Context: ...uire: - Complex multi-step workflows - Deep research across multiple sources - Code...
(DEEP_PROFOUND)
[grammar] ~235-~235: Ensure spelling is correct
Context: ...tivity ### Timeout Errors If requests timeout: - Check your network connection - Verify t...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🪛 markdownlint-cli2 (0.18.1)
54-54: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
59-59: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
64-64: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
68-68: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
73-73: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
78-78: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents