### Setup and Run JManus Development Environment (Bash) Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README.md This snippet outlines the steps to set up the JManus development environment. It includes cloning the repository, installing dependencies using Maven, applying code formatting, and starting the development server. ```bash # Fork and clone the repository git clone git@github.com:spring-ai-alibaba/JManus.git cd JManus # Install project dependencies mvn clean install # Apply code formatting standards mvn spotless:apply # Start the development server mvn spring-boot:run ``` -------------------------------- ### Install Project Dependencies and Start Development Server Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Commands to install project dependencies using pnpm and start the development server. Assumes the repository has been cloned. ```bash pnpm install pnpm run dev ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Installs project dependencies using pnpm and starts the development server. Assumes the repository has already been cloned and the UI directory is navigated to. ```bash # git clone https://github.com/spring-ai-alibaba/spring-ai-alibaba.git # cd spring-ai-alibaba-jmanus/ui-vue3 pnpm install pnpm run dev ``` -------------------------------- ### Install Node.js and npm on Linux Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Instructions for installing Node.js and npm on Linux systems using a package manager. It includes verification commands. ```bash sudo apt update sudo apt install nodejs npm ``` -------------------------------- ### Verify Node.js and npm Installation Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Commands to verify the successful installation of Node.js and npm by checking their versions. ```bash node -v npm -v ``` -------------------------------- ### Install pnpm Package Manager Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Instructions for installing the pnpm package manager globally using npm. It also includes a verification command. ```bash npm install -g pnpm pnpm -v ``` -------------------------------- ### Set Up JManus Development Environment Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-zh.md Commands for setting up the development environment for JManus, including forking and cloning the repository, installing project dependencies using Maven, applying code formatting standards, and running the development server. ```bash # Fork and clone the repository git clone git@github.com:spring-ai-alibaba/JManus.git cd JManus # Install project dependencies mvn clean install # Application code formatting standards mvn spotless:apply # Start development server mvn spring-boot:run ``` -------------------------------- ### Available Development Scripts Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Lists common development scripts available in the project, including starting the dev server, building, previewing, type checking, linting, formatting, and running tests. ```bash - pnpm run dev - pnpm run build - pnpm run preview - pnpm run type-check - pnpm run lint - pnpm run format - pnpm run test:unit - pnpm run test:e2e ``` -------------------------------- ### Install Node.js and npm on Linux Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Installs Node.js and npm on Ubuntu/Debian Linux systems using the apt package manager. Verifies the installation by checking the versions of Node.js and npm. ```bash sudo apt update sudo apt install nodejs npm node -v npm -v ``` -------------------------------- ### Download and Run JManus JAR File Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README.md This snippet shows how to download the latest JManus JAR file using wget or curl and then how to run it using the Java command. It assumes Java 17+ is installed. ```bash # Download the latest JAR file wget https://github.com/spring-ai-alibaba/JManus/releases/latest/download/jmanus.jar # Or using curl curl -L -o jmanus.jar https://github.com/spring-ai-alibaba/JManus/releases/latest/download/jmanus.jar # Run the JAR file java -jar jmanus.jar ``` -------------------------------- ### Install pnpm Package Manager Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Installs the pnpm package manager globally using npm. Verifies the installation by checking the pnpm version. pnpm is recommended for its efficiency. ```bash npm install -g pnpm pnpm -v ``` -------------------------------- ### Download and Run JManus JAR Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-zh.md This snippet shows how to download the latest JManus JAR file using wget or curl and then run it using the Java command. It's a recommended method for quickly getting JManus up and running. ```bash # Download the latest JAR file wget https://github.com/spring-ai-alibaba/JManus/releases/latest/download/jmanus.jar # Or use curl curl -L -o jmanus.jar https://github.com/spring-ai-alibaba/JManus/releases/latest/download/jmanus.jar # Run the JAR file java -jar jmanus.jar ``` -------------------------------- ### Format Commit Message Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/CONTRIBUTING-zh.md Example of a correctly formatted commit message according to the project's guidelines. This ensures consistency and clarity in the commit history. ```bash git commit -m "feat(docs): 更新贡献指南" ``` -------------------------------- ### Execute Plan Synchronously (GET) Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Executes a plan synchronously using a GET request to the specified tool name. Requires a `userId` query parameter. Returns a JSON object containing the plan ID, status, and execution results. ```bash curl "http://localhost:18080/api/executor/executeByToolNameSync/get_user_profile?userId=user-67890" ``` -------------------------------- ### Environment Variables for UI Configuration Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Defines example environment variables used to configure the JManus UI. This includes the base URL for the API and other potential configurations. ```env # API Configuration VITE_API_BASE_URL=http://localhost:8080 # Other configurations... ``` -------------------------------- ### Query Available AI Models (GET) Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Retrieves a list of available AI models that can be utilized by agents. Each model is described with its name, provider, supported capabilities (e.g., chat, function-calling), and context window size. This helps in selecting the appropriate model for agent tasks. ```bash # Get available AI models curl http://localhost:18080/api/config/available-models ``` -------------------------------- ### Query Available Tools (GET) Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Retrieves a list of all available tools that can be assigned to agents. Each tool is represented by a JSON object including its key, name, description, and enabled status. This endpoint is useful for understanding agent capabilities. ```bash # Get all available tools curl http://localhost:18080/api/agents/tools ``` -------------------------------- ### Launch JManus Application from Source Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README.md These commands show how to launch the JManus application using the Maven wrapper ('mvnw' or 'mvnw.cmd') when running from source code. Separate commands are provided for Unix-like systems and Windows. ```bash # For Unix-like systems (macOS, Linux): ../mvnw spring-boot:run # For Windows systems: ../mvnw.cmd spring-boot:run ``` -------------------------------- ### JManus 项目启动与配置 Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/征文.md 展示了在 Linux/macOS 环境下,设置 API Key、克隆 JManus 项目仓库并使用 Maven 启动项目的基本步骤。需要确保已安装 JDK 17+,并替换为实际的 API 密钥。 ```bash # 确保 JDK 17+ java -version # 设置 API Key export AI_DASHSCOPE_API_KEY=your_api_key # 克隆项目 git clone https://github.com/spring-ai-alibaba/spring-ai-alibaba.git cd spring-ai-alibaba-jmanus # 启动项目 mvn spring-boot:run ``` -------------------------------- ### Configuration Module API Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-dev-en.md Manages system configurations, allowing retrieval and batch updates of configuration items. ```APIDOC ## GET /api/config/group/{groupName} ### Description Retrieves all configuration items belonging to a specific group. ### Method GET ### Endpoint /api/config/group/{groupName} ### Parameters #### Path Parameters - **groupName** (string) - Required - The name of the configuration group to retrieve. ### Response #### Success Response (200) - **configurations** (array) - A list of configuration items, where each item is an object with key-value pairs. #### Response Example ```json { "configurations": [ { "key": "timeout", "value": "30000" }, { "key": "retries", "value": "3" } ] } ``` ``` ```APIDOC ## POST /api/config/batch-update ### Description Performs a batch update of multiple configuration items. This allows for efficient modification of several settings at once. ### Method POST ### Endpoint /api/config/batch-update ### Parameters #### Request Body - **updates** (array) - Required - A list of configuration updates, where each update is an object with 'key', 'value', and optionally 'groupName'. ### Request Example ```json { "updates": [ { "key": "timeout", "value": "60000", "groupName": "default" }, { "key": "logLevel", "value": "DEBUG", "groupName": "logging" } ] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the batch update was successful. #### Response Example ```json { "message": "Batch configuration update successful." } ``` ``` -------------------------------- ### Get Plan Details Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Retrieves the current details and status of a specific plan. ```APIDOC ## GET /api/executor/details/{planId} ### Description Retrieves the current status and details of a specific plan. ### Method GET ### Endpoint `/api/executor/details/{planId}` ### Parameters #### Path Parameters - **planId** (string) - Required - The ID of the plan to retrieve details for. ### Request Example ```bash curl http://localhost:18080/api/executor/details/plan-interactive-001 ``` ### Response #### Success Response (200) - **planId** (string) - The unique identifier for the plan. - **status** (string) - The current status of the plan (e.g., WAITING_FOR_INPUT, IN_PROGRESS, COMPLETED). - **message** (string, optional) - A message associated with the plan's status, often for user interaction. - **inputType** (string, optional) - The type of input expected if the plan is waiting. - **timeout** (string, optional) - The timeout duration for waiting input. - **currentStep** (string, optional) - The current step being executed in the plan. - **progress** (string, optional) - Progress information for the current step. #### Response Example ```json { "planId": "plan-interactive-001", "status": "WAITING_FOR_INPUT", "message": "About to delete 157 records from customer_archive table. Please confirm: [yes/no]", "inputType": "TEXT", "timeout": "300s" } ``` ``` -------------------------------- ### Get System Configuration Group Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Retrieves the current system-wide configuration parameters for a specified group. ```APIDOC ## GET /api/config/group/{groupName} ### Description Retrieves the current system-wide configuration parameters for a specified group. This endpoint allows viewing settings related to agent behavior, execution limits, and features. ### Method GET ### Endpoint /api/config/group/{groupName} ### Parameters #### Path Parameters - **groupName** (string) - Required - The name of the configuration group to retrieve (e.g., `agent_execution`). ### Request Example ```bash curl http://localhost:18080/api/config/group/agent_execution ``` ### Response #### Success Response (200) - **key** (string) - The name of the configuration parameter. - **value** (string) - The current value of the parameter. - **defaultValue** (string) - The default value of the parameter. - **description** (string) - A description of the parameter's purpose. - **inputType** (string) - The expected input type for the parameter (e.g., NUMBER, BOOLEAN). - **group** (string) - The configuration group the parameter belongs to. #### Response Example ```json [ { "key": "maxSteps", "value": "30", "defaultValue": "30", "description": "Maximum thinking-acting steps per agent execution", "inputType": "NUMBER", "group": "agent_execution" } ] ``` ``` -------------------------------- ### JSON: 纯并行执行示例 Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/mapreduce_planning_tool_examples.md 此示例展示了如何使用 MapReducePlanningTool 创建一个纯粹的并行执行计划。所有包含的步骤将同时执行,适用于独立且无依赖关系的任务。 ```json { "command": "create", "planId": "parallel-data-collection", "title": "并行数据收集任务", "steps": [ { "type": "parallel", "steps": [ { "stepRequirement": "[WEB_SCRAPER] 抓取电商网站的商品信息", "outputColumns": "商品ID,商品名称,价格,库存" }, { "stepRequirement": "[API_CLIENT] 调用第三方API获取商品评价", "outputColumns": "商品ID,评分,评价数量" }, { "stepRequirement": "[DATABASE_READER] 从数据库读取历史销售数据", "outputColumns": "商品ID,销售量,销售额" } ] } ] } ``` -------------------------------- ### GET /api/executor/details/{planId} Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Retrieves the current status and progress details of a specific asynchronous plan execution. This endpoint allows monitoring of long-running tasks. ```APIDOC ## GET /api/executor/details/{planId} ### Description Retrieves the current status and progress details of a specific asynchronous plan execution. ### Method GET ### Endpoint /api/executor/details/{planId} ### Parameters #### Path Parameters - **planId** (string) - Required - The unique identifier of the plan to retrieve details for. ### Request Example (No request body for GET requests, parameters are in the path) ```bash curl http://localhost:18080/api/executor/details/plan-abc123def456 ``` ### Response #### Success Response (200) - **planId** (string) - The unique identifier of the plan. - **status** (string) - The current overall status of the plan (e.g., "IN_PROGRESS", "COMPLETED", "FAILED"). - **steps** (array of objects) - A list of steps within the plan and their individual statuses. - **stepName** (string) - The name of the step. - **status** (string) - The status of the step (e.g., "COMPLETED", "IN_PROGRESS", "PENDING"). - **output** (string) - The output or result of the step, if completed. - **currentStep** (integer) - The index of the currently executing step. - **totalSteps** (integer) - The total number of steps in the plan. #### Response Example ```json { "planId": "plan-abc123def456", "status": "IN_PROGRESS", "steps": [ {"stepName": "Parse log file", "status": "COMPLETED", "output": "Found 1247 ERROR entries"}, {"stepName": "Pattern matching", "status": "IN_PROGRESS", "output": "Processing..."}, {"stepName": "Generate report", "status": "PENDING"} ], "currentStep": 2, "totalSteps": 3 } ``` ``` -------------------------------- ### JSON: 纯顺序执行示例 Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/mapreduce_planning_tool_examples.md 此示例演示了如何使用 MapReducePlanningTool 构建一个纯粹的顺序执行计划。每个步骤将按顺序执行,适用于存在依赖关系的任务流程。 ```json { "command": "create", "planId": "sequential-data-process", "title": "顺序数据处理流程", "steps": [ { "type": "sequential", "steps": [ { "stepRequirement": "[DATA_COLLECTOR] 收集原始数据文件", "outputColumns": "文件路径,文件大小,记录数" }, { "stepRequirement": "[DATA_CLEANER] 清洗和标准化数据", "outputColumns": "清洗后数据,错误记录,清洗报告" }, { "stepRequirement": "[DATA_VALIDATOR] 验证数据质量", "outputColumns": "验证结果,质量评分,问题列表" }, { "stepRequirement": "[REPORT_GENERATOR] 生成数据处理报告", "outputColumns": "报告文件,处理统计,结果摘要" } ] } ] } ``` -------------------------------- ### Compile and Format Code with Maven Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/CONTRIBUTING.md Before submitting your code, it is recommended to compile and format it using Maven. The `mvn clean package` command not only ensures your code compiles locally but also automatically formats it according to project specifications. ```bash mvn clean package ``` -------------------------------- ### POST /api/executor/executeByToolNameAsync Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Submits a plan template for asynchronous execution with parameter substitution and file uploads, enabling long-running tasks without blocking. This endpoint is used to start a process that will run in the background. ```APIDOC ## POST /api/executor/executeByToolNameAsync ### Description Submits a plan template for asynchronous execution with parameter substitution and file uploads, enabling long-running tasks without blocking. ### Method POST ### Endpoint /api/executor/executeByToolNameAsync ### Parameters #### Request Body - **toolName** (string) - Required - The name of the tool or plan template to execute. - **replacementParams** (object) - Optional - Key-value pairs for substituting parameters within the plan. - **key** (string) - The parameter name to replace. - **value** (string) - The value to substitute. - **uploadedFiles** (array of strings) - Optional - A list of file paths to be uploaded and used by the plan. - **conversationId** (string) - Optional - An identifier for the conversation context. ### Request Example ```json { "toolName": "log_analyzer", "replacementParams": { "logFile": "/var/logs/app.log", "timeRange": "last_24h", "severity": "ERROR" }, "uploadedFiles": ["error-patterns.json"], "conversationId": "conv-analytics-001" } ``` ### Response #### Success Response (200) - **planId** (string) - The unique identifier for the executed plan. - **status** (string) - The initial status of the plan execution (e.g., "processing"). - **conversationId** (string) - The conversation ID associated with the plan. - **startTime** (string) - The timestamp when the plan execution started. #### Response Example ```json { "planId": "plan-abc123def456", "status": "processing", "conversationId": "conv-analytics-001", "startTime": "2024-01-15T10:30:00Z" } ``` ``` -------------------------------- ### Build Production Version and Copy to Resources Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Commands to build the production version of the UI using pnpm and then copy the built files to the `src/main/resources/static/` directory for a Spring Boot application. This step is for deployment purposes. ```bash pnpm run build cp -r ui-vue3/ui src/main/resources/static/ ``` -------------------------------- ### JSON: 纯MapReduce执行示例 Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/mapreduce_planning_tool_examples.md 此示例展示了如何使用 MapReducePlanningTool 创建一个纯粹的 MapReduce 执行计划,用于大数据处理任务。它包含 mapSteps 和 reduceSteps,模拟分布式计算流程。 ```json { "command": "create", "planId": "mapreduce-analysis", "title": "大数据分析任务", "steps": [ { "type": "mapreduce", "mapSteps": [ { "stepRequirement": "[USER_BEHAVIOR_ANALYZER] 分析用户行为数据", "outputColumns": "用户ID,行为模式,活跃度" }, { "stepRequirement": "[PURCHASE_ANALYZER] 分析购买行为数据", "outputColumns": "用户ID,购买偏好,消费能力" }, { "stepRequirement": "[CONTENT_ANALYZER] 分析内容浏览数据", "outputColumns": "用户ID,兴趣标签,浏览时长" } ], "reduceSteps": [ { "stepRequirement": "[DATA_AGGREGATOR] 汇总所有分析结果", "outputColumns": "用户画像,综合评分,推荐策略" }, { "stepRequirement": "[REPORT_GENERATOR] 生成最终分析报告", "outputColumns": "分析报告,关键洞察,业务建议" } ] } ] } ``` -------------------------------- ### Simplified Configuration Mapping to Parallel Agent Parameters Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/parallel_agent_params.md Illustrates how a simplified configuration, often used in command-line interfaces, maps to the detailed predefined parameters of the Parallel Agent. This helps in understanding the relationship between different configuration styles. ```json { "agentType": "PARALLEL_AGENT", "stepRequirement": "Map阶段:并行处理文件块和内容总结", "subAgents": [...] } ``` -------------------------------- ### Build and Preview Production Build Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README.md Builds the project for production deployment and then previews the production build. These commands are typically used after development is complete. ```bash pnpm run build pnpm run preview ``` -------------------------------- ### Manage Agent Configuration via REST API Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Provides RESTful endpoints for managing agent configurations. This section includes examples using curl to retrieve, update, and delete agents within a specified namespace. ```shell # Get all agents in namespace curl http://localhost:18080/api/agents?namespace=production # Update agent configuration curl -X PUT http://localhost:18080/api/agents/agent-001 \ -H "Content-Type: application/json" \ -d '{ "id": "agent-001", "name": "CustomerSupportAgent", "description": "Enhanced customer support with multilingual capabilities", "nextStepPrompt": "Analyze customer inquiry, check knowledge base, provide solution or escalate if needed.", "availableTools": ["ticket_system", "knowledge_base", "email_sender", "translation_service"], "namespace": "production" }' # Delete non-built-in agent curl -X DELETE http://localhost:18080/api/agents/agent-001 ``` -------------------------------- ### Clone and Navigate JManus Repository Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-zh.md Instructions for cloning the JManus project from GitHub and navigating into the project directory. This is the first step for running JManus from source code. ```bash git clone https://github.com/spring-ai-alibaba/JManus.git cd JManus ``` -------------------------------- ### Task Initiation API Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-dev-en.md Initiates a new AI plan task. The system automatically assigns a planId and executes the task asynchronously. ```APIDOC ## POST /api/executor/execute ### Description Initiates a new AI plan task, automatically assigns a planId, and executes asynchronously. ### Method POST ### Endpoint /api/executor/execute ### Parameters #### Query Parameters - **query** (string) - Required - The user's query content to initiate the task. ### Request Example ```json { "query": "What is the weather like today?" } ``` ### Response #### Success Response (200) - **planId** (string) - The unique identifier for the initiated task. #### Response Example ```json { "planId": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ``` -------------------------------- ### Execute Tool Synchronously via REST Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Enables synchronous execution of plan templates via REST API, returning immediate results. This curl example demonstrates invoking a tool with specific parameters for data validation. ```shell # Execute data validation tool with parameters curl -X POST http://localhost:18080/api/executor/executeByToolNameSync \ -H "Content-Type: application/json" \ -d '{ "toolName": "validate_user_data", "replacementParams": { "userId": "user-12345", "fields": ["email", "phone", "address"] } }' ``` -------------------------------- ### Clone JManus Repository Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/CONTRIBUTING.md To begin contributing, fork the JManus repository to your GitHub account and then clone it to your local machine. This involves using the `git clone` command with your forked repository's URL. ```git git clone https://github.com/yourname/JManus.git ``` -------------------------------- ### List Available MCP Tools via Curl Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Demonstrates how to list available Machine Coordination Protocol (MCP) tools using a simple curl command. This is useful for discovering available services and their capabilities. ```shell curl http://localhost:18080/api/mcp/list ``` -------------------------------- ### Configuration Management API Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-dev.md APIs for managing system configurations, including retrieving configurations by group and updating them in batches. ```APIDOC ## GET /api/config/group/{groupName} ### Description Retrieves configuration items for a specified group. ### Method GET ### Endpoint /api/config/group/{groupName} ### Parameters #### Path Parameters - **groupName** (string) - Required - The name of the configuration group. ### Response #### Success Response (200) - **configurations** (array) - An array of configuration objects. #### Response Example ```json { "groupName": "my-group", "configurations": [ { "key": "configKey1", "value": "configValue1" }, { "key": "configKey2", "value": "configValue2" } ] } ``` ## POST /api/config/batch-update ### Description Performs a batch update of configuration items. This operation does not require a service restart. ### Method POST ### Endpoint /api/config/batch-update ### Parameters #### Request Body - **updates** (array) - Required - An array of configuration objects to update. - **key** (string) - Required - The key of the configuration item. - **value** (string) - Required - The new value for the configuration item. ### Request Example ```json { "updates": [ { "key": "configKey1", "value": "new-value1" }, { "key": "configKey2", "value": "new-value2" } ] } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the batch update was successful. #### Response Example ```json { "message": "Batch configuration update successful." } ``` ``` -------------------------------- ### Create and Execute Dynamic AI Agent (Java) Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Demonstrates creating a dynamic AI agent configuration in Java, including setting name, description, prompts, tools, and namespace. It then instantiates and runs the agent, specifying initial settings, expected return, and model for execution. This snippet showcases the core agent creation and execution flow within the JManus framework. ```java import java.util.Arrays; // ... inside a service or controller class ... // Create agent configuration AgentConfig config = new AgentConfig(); config.setName("DataAnalysisAgent"); config.setDescription("Analyzes datasets and generates reports"); config.setNextStepPrompt("Analyze the current data and determine the next action. Consider available tools and the task objective."); config.setAvailableTools(Arrays.asList("database_query", "data_processor", "report_generator", "TerminateTool")); config.setNamespace("analytics"); // Create agent via service AgentConfig created = agentService.createAgent(config); // Instantiate and execute agent BaseAgent agent = agentService.createDynamicBaseAgent( "DataAnalysisAgent", "plan-12345", // planId "root-plan-67890", // rootPlanId "{ \"dataSource\": \"sales_db\", \"period\": \"2024-Q1\" }", // initialSettings "Provide summary statistics and trend analysis", // expectedReturn "Process sales data", // step description "qwen-max", // modelName Arrays.asList("database_query", "data_processor", "report_generator", "TerminateTool") ); agent.setState(AgentState.IN_PROGRESS); String result = agent.run(); // Executes think-act loop until completion System.out.println("Agent Result: " + result); // Output: "Analysis complete. Q1 sales increased 23% compared to previous quarter. Top performing region: APAC." ``` -------------------------------- ### Create and Execute Dynamic Agent Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt This section details how to create an AI agent configuration and then instantiate and execute it dynamically using the JManus framework. It demonstrates setting up agent properties, tools, and executing the agent's run cycle. ```APIDOC ## Create and Execute Dynamic Agent ### Description Creates a configurable AI agent with custom prompts, tool selection, and model assignment, then executes it to completion following the ReAct pattern. ### Method (Implicitly through Java Service calls shown in example) ### Endpoint (Not a direct HTTP endpoint, but a conceptual API within the Java framework) ### Parameters (These are parameters for the Java methods, not HTTP requests) ### Request Example ```java // Create agent configuration AgentConfig config = new AgentConfig(); config.setName("DataAnalysisAgent"); config.setDescription("Analyzes datasets and generates reports"); config.setNextStepPrompt("Analyze the current data and determine the next action. Consider available tools and the task objective."); config.setAvailableTools(Arrays.asList("database_query", "data_processor", "report_generator", "TerminateTool")); config.setNamespace("analytics"); // Create agent via service AgentConfig created = agentService.createAgent(config); // Instantiate and execute agent BaseAgent agent = agentService.createDynamicBaseAgent( "DataAnalysisAgent", "plan-12345", // planId "root-plan-67890", // rootPlanId "{ \"dataSource\": \"sales_db\", \"period\": \"2024-Q1\" }", // initialSettings "Provide summary statistics and trend analysis", // expectedReturn "Process sales data", // step description "qwen-max", // modelName Arrays.asList("database_query", "data_processor", "report_generator", "TerminateTool") ); agent.setState(AgentState.IN_PROGRESS); String result = agent.run(); // Executes think-act loop until completion System.out.println("Agent Result: " + result); ``` ### Response #### Success Response (Output from the Java `run()` method) - **result** (string) - The final output or result of the agent's execution. #### Response Example ``` Agent Result: Analysis complete. Q1 sales increased 23% compared to previous quarter. Top performing region: APAC. ``` ``` -------------------------------- ### JSON: 混合模式执行示例 Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/mapreduce_planning_tool_examples.md 此示例展示了 MapReducePlanningTool 如何支持混合模式执行,在一个计划中组合使用 parallel、sequential 和 mapreduce 节点类型,以构建复杂的数据处理流水线。 ```json { "command": "create", "planId": "complex-data-pipeline", "title": "复杂数据处理流水线", "steps": [ { "type": "parallel", "steps": [ { "stepRequirement": "[SOCIAL_DATA_COLLECTOR] 收集社交媒体数据", "outputColumns": "用户ID,社交数据,发布时间" }, { "stepRequirement": "[TRANSACTION_COLLECTOR] 收集交易数据", "outputColumns": "交易ID,用户ID,交易金额,交易时间" }, { "stepRequirement": "[BEHAVIOR_COLLECTOR] 收集用户行为数据", "outputColumns": "用户ID,行为类型,时间戳" } ] }, { "type": "sequential", "steps": [ { "stepRequirement": "[DATA_MERGER] 合并所有收集的数据", "outputColumns": "统一用户数据,数据完整性报告" }, { "stepRequirement": "[DATA_CLEANER] 清洗合并后的数据", "outputColumns": "清洗后数据,数据质量报告" } ] }, { "type": "mapreduce", "mapSteps": [ { "stepRequirement": "[PATTERN_ANALYZER] 分析用户行为模式", "outputColumns": "行为模式,模式强度,时间分布" }, { "stepRequirement": "[PREFERENCE_ANALYZER] 分析用户偏好", "outputColumns": "偏好类别,偏好强度,变化趋势" } ], "reduceSteps": [ { "stepRequirement": "[INSIGHT_GENERATOR] 生成用户洞察", "outputColumns": "用户洞察,商业价值,行动建议" } ] }, { "type": "sequential", "steps": [ { "stepRequirement": "[REPORT_GENERATOR] 生成最终报告", "outputColumns": "综合报告,执行摘要,数据图表" }, { "stepRequirement": "[NOTIFICATION_SENDER] 发送完成通知", "outputColumns": "通知状态,接收确认" } ] } ] } ``` -------------------------------- ### Run Local CI Checks Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/CONTRIBUTING-zh.md Execute local Continuous Integration (CI) checks using the 'make' command provided in the tools directory. This verifies code quality and standards before submitting a PR. ```bash make ``` ```bash make help ``` -------------------------------- ### Plan Template Management API Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-dev.md APIs for managing plan templates, including generation, execution, versioning, and listing. ```APIDOC ## POST /api/plan-template/generate ### Description Generates a new plan template. ### Method POST ### Endpoint /api/plan-template/generate ### Parameters #### Request Body - **planDetails** (object) - Required - Details for the new plan template. ### Request Example ```json { "planDetails": { "name": "New Marketing Plan", "description": "Template for creating marketing plans." } } ``` ### Response #### Success Response (200) - **templateId** (string) - The ID of the newly generated plan template. #### Response Example ```json { "templateId": "template-abc-123" } ``` ## POST /api/plan-template/executePlanByTemplateId ### Description Executes a plan based on a specified template ID. This can also be accessed via GET. ### Method POST ### Endpoint /api/plan-template/executePlanByTemplateId ### Parameters #### Request Body - **templateId** (string) - Required - The ID of the plan template to execute. - **executionParams** (object) - Optional - Parameters for the plan execution. ### Request Example ```json { "templateId": "template-abc-123", "executionParams": { "targetAudience": "Young Adults" } } ``` ### Response #### Success Response (200) - **planId** (string) - The ID of the executed plan. #### Response Example ```json { "planId": "executed-plan-xyz-789" } ``` ## POST /api/plan-template/save ### Description Saves a new version of a plan template. ### Method POST ### Endpoint /api/plan-template/save ### Parameters #### Request Body - **templateData** (object) - Required - The data for the plan template to save. ### Request Example ```json { "templateData": { "templateId": "template-abc-123", "version": "1.1", "content": "Updated plan content." } } ``` ### Response #### Success Response (200) - **versionId** (string) - The ID of the saved plan template version. #### Response Example ```json { "versionId": "version-def-456" } ``` ## POST /api/plan-template/versions ### Description Retrieves the version history for a given plan template. ### Method POST ### Endpoint /api/plan-template/versions ### Parameters #### Request Body - **templateId** (string) - Required - The ID of the plan template. ### Request Example ```json { "templateId": "template-abc-123" } ``` ### Response #### Success Response (200) - **versions** (array) - An array of version objects for the template. #### Response Example ```json { "versions": [ { "version": "1.0", "timestamp": "2023-10-27T10:00:00Z" }, { "version": "1.1", "timestamp": "2023-10-27T11:00:00Z" } ] } ``` ## POST /api/plan-template/get-version ### Description Retrieves a specific version of a plan template. ### Method POST ### Endpoint /api/plan-template/get-version ### Parameters #### Request Body - **templateId** (string) - Required - The ID of the plan template. - **version** (string) - Required - The specific version to retrieve. ### Request Example ```json { "templateId": "template-abc-123", "version": "1.1" } ``` ### Response #### Success Response (200) - **templateContent** (string) - The content of the requested plan template version. #### Response Example ```json { "templateContent": "Content of version 1.1." } ``` ## GET /api/plan-template/list ### Description Retrieves a list of all available plan templates. ### Method GET ### Endpoint /api/plan-template/list ### Response #### Success Response (200) - **templates** (array) - An array of available plan template objects. #### Response Example ```json { "templates": [ { "templateId": "template-abc-123", "name": "Marketing Plan" }, { "templateId": "template-def-456", "name": "Sales Strategy" } ] } ``` ## POST /api/plan-template/update ### Description Updates an existing plan template. ### Method POST ### Endpoint /api/plan-template/update ### Parameters #### Request Body - **templateData** (object) - Required - The updated data for the plan template. ### Request Example ```json { "templateData": { "templateId": "template-abc-123", "name": "Updated Marketing Plan", "description": "Revised marketing plan template." } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the update was successful. #### Response Example ```json { "message": "Plan template updated successfully." } ``` ## POST /api/plan-template/delete ### Description Deletes a plan template. ### Method POST ### Endpoint /api/plan-template/delete ### Parameters #### Request Body - **templateId** (string) - Required - The ID of the plan template to delete. ### Request Example ```json { "templateId": "template-abc-123" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating deletion. #### Response Example ```json { "message": "Plan template deleted successfully." } ``` ``` -------------------------------- ### Task Initiation API Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/README-dev.md Initiates a new plan execution task asynchronously. The system automatically assigns a planId and handles the execution. ```APIDOC ## POST /api/executor/execute ### Description Initiates a new plan execution task. The system automatically assigns a planId and executes it asynchronously. ### Method POST ### Endpoint /api/executor/execute ### Parameters #### Query Parameters - **query** (string) - Required - The user's query content to initiate the task. ### Request Example ```json { "query": "Generate a marketing plan for a new product." } ``` ### Response #### Success Response (200) - **planId** (string) - The unique identifier for the initiated plan execution. #### Response Example ```json { "planId": "generated-plan-id-123" } ``` ``` -------------------------------- ### Apply Code Formatting and Clean Imports Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/CONTRIBUTING-zh.md Maven command to automatically format code and remove unused imports. This keeps the codebase clean and maintainable. ```bash mvn spotless:apply ``` -------------------------------- ### Git Branching and Committing for Contributions Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/ui-vue3/README-zh.md Standard Git commands for contributing to the project: forking, creating a feature branch, committing changes, pushing to the remote, and creating a pull request. ```bash git checkout -b feature/amazing-feature git commit -m 'Add some amazing features' git push origin feature/amazing-feature ``` -------------------------------- ### Create Coordinator Tool with MCP Integration Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt Defines and creates a coordinator tool that links plan templates to MCP endpoints, enabling agents to invoke external services. ```APIDOC ## POST /api/coordinator/tool (Conceptual) ### Description Creates a coordinator tool that integrates with MCP endpoints. This allows agents to call external services through defined plan templates. ### Method POST (Conceptual - actual API might differ, this illustrates the Java SDK usage) ### Endpoint `/api/coordinator/tool` (Conceptual) ### Parameters #### Request Body (Illustrative Java object) - **toolName** (string) - The name of the coordinator tool. - **toolDescription** (string) - Description of the tool's purpose. - **planTemplateId** (string) - The ID of the plan template to link. - **enableInternalToolcall** (boolean) - Whether to enable internal tool calls. - **enableHttpService** (boolean) - Whether to enable direct HTTP service calls. - **enableMcpService** (boolean) - Whether to enable MCP service integration. - **mcpEndpoint** (string) - The MCP endpoint to connect to. - **serviceGroup** (string) - The service group the tool belongs to. - **inputSchema** (string - JSON array) - JSON schema defining the tool's input parameters. ### Request Example (Java SDK) ```java CoordinatorToolVO toolVO = new CoordinatorToolVO(); toolVO.setToolName("analyze_database"); toolVO.setToolDescription("Analyzes database schema and generates optimization recommendations"); toolVO.setPlanTemplateId("db-analysis-template-v2"); toolVO.setEnableInternalToolcall(true); toolVO.setEnableHttpService(false); toolVO.setEnableMcpService(true); toolVO.setMcpEndpoint("postgres-mcp"); toolVO.setServiceGroup("database"); toolVO.setInputSchema("[" + "{\"name\":\"connectionString\",\"type\":\"string\",\"description\":\"PostgreSQL connection string\",\"required\":true},\" + "{\"name\":\"schemaName\",\"type\":\"string\",\"description\":\"Database schema to analyze\",\"required\":false},\" + "{\"name\":\"includeIndexes\",\"type\":\"boolean\",\"description\":\"Include index analysis\",\"required\":false}" + "]"); CoordinatorToolVO created = coordinatorToolService.createCoordinatorTool(toolVO); System.out.println("Tool created with ID: " + created.getId()); System.out.println("Available at MCP endpoint: " + created.getMcpEndpoint()); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the created coordinator tool. - **mcpEndpoint** (string) - The MCP endpoint associated with the created tool. #### Response Example (Conceptual - based on SDK output) ```json { "id": "tool-abc-123", "mcpEndpoint": "postgres-mcp" } ``` ``` -------------------------------- ### Register and Enable MCP Server (Bash/HTTP) Source: https://context7.com/spring-ai-alibaba/jmanus/llms.txt This snippet illustrates how to register and enable a Model Context Protocol (MCP) server using JNames's HTTP API. It shows `curl` commands for both adding a new MCP server (e.g., for database operations) with its configuration and then enabling it. This process allows agents to leverage external services and tools. ```bash # Add MCP server for database operations curl -X POST http://localhost:18080/api/mcp/server \ -H "Content-Type: application/json" \ -d '{ "name": "postgres-mcp", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost/analytics"], "env": { "POSTGRES_MAX_CONNECTIONS": "10" }, "type": "STDIO" }' # Response { "id": 42, "name": "postgres-mcp", "status": "INACTIVE" } # Enable the MCP server curl -X POST http://localhost:18080/api/mcp/enable/42 ``` -------------------------------- ### Parallel Agent Input/Output Handling Configuration Source: https://github.com/spring-ai-alibaba/jmanus/blob/main/src/temp/parallel_agent_params.md Manages how input data is read and processed, and how output results are formatted and aggregated. It includes settings for input format detection, encoding, preprocessing, output format, aggregation strategy, and output key. ```json { "inputHandling": { "inputFormat": "AUTO_DETECT", // 输入格式自动检测 "encoding": "UTF-8", // 文件编码 "preprocessor": "TextNormalizer" // 预处理器 }, "outputHandling": { "outputFormat": "JSON", // 输出格式 "aggregationStrategy": "MERGE", // 结果聚合策略 "outputKey": "parallel_result" // 输出键名 } } ```