From e9d1bc2385521c08374a85eba7899e878a51066c Mon Sep 17 00:00:00 2001 From: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> Date: Fri, 20 Jun 2025 17:18:03 +0300 Subject: [PATCH] Feature/compatibleapisupport (#830) * add compatible platform api support * Adjust the code according to the suggestions * Fully revised as requested: restored all required checks, improved compatibility, and converted all comments to English. * feat: Add support for compatible API endpoints via baseURL * chore: Add changeset for compatible API support * chore: cleanup * chore: improve changeset * fix: package-lock.json * fix: package-lock.json --------- Co-authored-by: He-Xun <1226807142@qq.com> --- .changeset/huge-moose-prove.md | 8 ++++++++ .changeset/tiny-dogs-change.md | 5 +++++ docs/configuration.md | 6 ++++-- scripts/modules/config-manager.js | 19 +++++++++++++------ 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .changeset/huge-moose-prove.md create mode 100644 .changeset/tiny-dogs-change.md diff --git a/.changeset/huge-moose-prove.md b/.changeset/huge-moose-prove.md new file mode 100644 index 00000000..f45e24fb --- /dev/null +++ b/.changeset/huge-moose-prove.md @@ -0,0 +1,8 @@ +--- +"task-master-ai": minor +--- + +Can now configure baseURL of provider with `_BASE_URL` + +- For example: + - `OPENAI_BASE_URL` diff --git a/.changeset/tiny-dogs-change.md b/.changeset/tiny-dogs-change.md new file mode 100644 index 00000000..0396f2f4 --- /dev/null +++ b/.changeset/tiny-dogs-change.md @@ -0,0 +1,5 @@ +--- +"task-master-ai": patch +--- + +Improve mcp keys check in cursor diff --git a/docs/configuration.md b/docs/configuration.md index 77b5c228..867f29ac 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -72,6 +72,7 @@ Taskmaster uses two primary methods for configuration: - `XAI_API_KEY`: Your X-AI API key. - **Optional Endpoint Overrides:** - **Per-role `baseURL` in `.taskmasterconfig`:** You can add a `baseURL` property to any model role (`main`, `research`, `fallback`) to override the default API endpoint for that provider. If omitted, the provider's standard endpoint is used. + - **Environment Variable Overrides (`_BASE_URL`):** For greater flexibility, especially with third-party services, you can set an environment variable like `OPENAI_BASE_URL` or `MISTRAL_BASE_URL`. This will override any `baseURL` set in the configuration file for that provider. This is the recommended way to connect to OpenAI-compatible APIs. - `AZURE_OPENAI_ENDPOINT`: Required if using Azure OpenAI key (can also be set as `baseURL` for the Azure model role). - `OLLAMA_BASE_URL`: Override the default Ollama API URL (Default: `http://localhost:11434/api`). - `VERTEX_PROJECT_ID`: Your Google Cloud project ID for Vertex AI. Required when using the 'vertex' provider. @@ -131,13 +132,14 @@ PERPLEXITY_API_KEY=pplx-your-key-here # etc. # Optional Endpoint Overrides +# Use a specific provider's base URL, e.g., for an OpenAI-compatible API +# OPENAI_BASE_URL=https://api.third-party.com/v1 +# # AZURE_OPENAI_ENDPOINT=https://your-azure-endpoint.openai.azure.com/ # OLLAMA_BASE_URL=http://custom-ollama-host:11434/api # Google Vertex AI Configuration (Required if using 'vertex' provider) # VERTEX_PROJECT_ID=your-gcp-project-id -# VERTEX_LOCATION=us-central1 -# GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-credentials.json ``` ## Troubleshooting diff --git a/scripts/modules/config-manager.js b/scripts/modules/config-manager.js index 30630452..c9ba8ad3 100644 --- a/scripts/modules/config-manager.js +++ b/scripts/modules/config-manager.js @@ -571,10 +571,11 @@ function getMcpApiKeyStatus(providerName, projectRoot = null) { const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8'); const mcpConfig = JSON.parse(mcpConfigRaw); - const mcpEnv = mcpConfig?.mcpServers?.['taskmaster-ai']?.env; + const mcpEnv = + mcpConfig?.mcpServers?.['task-master-ai']?.env || + mcpConfig?.mcpServers?.['taskmaster-ai']?.env; if (!mcpEnv) { - // console.warn(chalk.yellow('Warning: Could not find taskmaster-ai env in mcp.json.')); - return false; // Structure missing + return false; } let apiKeyToCheck = null; @@ -782,9 +783,15 @@ function getAllProviders() { function getBaseUrlForRole(role, explicitRoot = null) { const roleConfig = getModelConfigForRole(role, explicitRoot); - return roleConfig && typeof roleConfig.baseURL === 'string' - ? roleConfig.baseURL - : undefined; + if (roleConfig && typeof roleConfig.baseURL === 'string') { + return roleConfig.baseURL; + } + const provider = roleConfig?.provider; + if (provider) { + const envVarName = `${provider.toUpperCase()}_BASE_URL`; + return resolveEnvVariable(envVarName, null, explicitRoot); + } + return undefined; } export {