Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ function detectProvider(env: Record<string, string>): ProviderConfig {
};
}

if (hasRealValue(env["ATLASCLOUD_API_KEY"])) {
return {
provider: "atlascloud",
model: env["ATLASCLOUD_MODEL"] || "deepseek-ai/deepseek-v4-pro",
maxTokens,
baseURL: env["ATLASCLOUD_BASE_URL"] || "https://api.atlascloud.ai/v1",
};
}
Comment on lines +66 to +73

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Include Atlas Cloud in the no-provider setup guidance.

The no-key warning still lists supported providers without ATLASCLOUD_API_KEY, so the newly supported provider is omitted from the remediation users see.

Proposed fix
-Set ANTHROPIC_API_KEY (or GEMINI/OPENAI/OPENROUTER/MINIMAX)
+Set ANTHROPIC_API_KEY (or ATLASCLOUD/GEMINI/OPENAI/OPENROUTER/MINIMAX)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/config.ts` around lines 66 - 73, Update the no-provider warning or setup
guidance in the configuration flow to include Atlas Cloud and its
ATLASCLOUD_API_KEY environment variable alongside the existing supported
providers. Keep the provider selection behavior in the atlascloud branch
unchanged.


// MiniMax: Anthropic-compatible API, requires raw fetch to avoid SDK stainless headers
if (hasRealValue(env["MINIMAX_API_KEY"])) {
return {
Expand Down Expand Up @@ -203,6 +212,7 @@ export function detectLlmProviderKind(): "llm" | "noop" {
const env = getMergedEnv();
if (
hasRealValue(env["ANTHROPIC_API_KEY"]) ||
hasRealValue(env["ATLASCLOUD_API_KEY"]) ||
hasRealValue(env["GEMINI_API_KEY"]) ||
hasRealValue(env["GOOGLE_API_KEY"]) ||
hasRealValue(env["OPENROUTER_API_KEY"]) ||
Expand Down Expand Up @@ -362,7 +372,8 @@ function hasLLMProviderConfigured(env: Record<string, string | undefined>): bool
env["OPENAI_API_KEY"] &&
(env["OPENAI_API_KEY_FOR_LLM"] || "").toLowerCase() !== "false";
return Boolean(
env["ANTHROPIC_API_KEY"] ||
env["ANTHROPIC_API_KEY"] ||
env["ATLASCLOUD_API_KEY"] ||
openaiKeyForLlm ||
env["OPENROUTER_API_KEY"] ||
env["GEMINI_API_KEY"] ||
Expand Down Expand Up @@ -414,6 +425,7 @@ export function getStandalonePersistPath(): string {

const VALID_PROVIDERS = new Set([
"anthropic",
"atlascloud",
"gemini",
"openrouter",
"agent-sdk",
Expand Down
9 changes: 9 additions & 0 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function defaultModelFor(providerType: ProviderConfig["provider"]): string {
switch (providerType) {
case "openai":
return getEnvVar("OPENAI_MODEL") || "gpt-4o-mini";
case "atlascloud":
return getEnvVar("ATLASCLOUD_MODEL") || "deepseek-ai/deepseek-v4-pro";
case "anthropic":
return getEnvVar("ANTHROPIC_MODEL") || "claude-sonnet-4-20250514";
case "gemini":
Expand Down Expand Up @@ -94,6 +96,13 @@ export function createFallbackProvider(

function createBaseProvider(config: ProviderConfig): MemoryProvider {
switch (config.provider) {
case "atlascloud":
return new OpenAIProvider(
requireEnvVar("ATLASCLOUD_API_KEY"),
config.model,
config.maxTokens,
config.baseURL || "https://api.atlascloud.ai/v1",
);
Comment on lines +99 to +105

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Honor ATLASCLOUD_BASE_URL when Atlas Cloud is a fallback.

Fallback configs omit baseURL, so this branch always uses the public endpoint and ignores a custom Atlas Cloud endpoint. That breaks fallback deployments using a proxy or private gateway.

Proposed fix
-        config.baseURL || "https://api.atlascloud.ai/v1",
+        config.baseURL ||
+          getEnvVar("ATLASCLOUD_BASE_URL") ||
+          "https://api.atlascloud.ai/v1",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case "atlascloud":
return new OpenAIProvider(
requireEnvVar("ATLASCLOUD_API_KEY"),
config.model,
config.maxTokens,
config.baseURL || "https://api.atlascloud.ai/v1",
);
case "atlascloud":
return new OpenAIProvider(
requireEnvVar("ATLASCLOUD_API_KEY"),
config.model,
config.maxTokens,
config.baseURL ||
getEnvVar("ATLASCLOUD_BASE_URL") ||
"https://api.atlascloud.ai/v1",
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/providers/index.ts` around lines 99 - 105, Update the "atlascloud" branch
in the provider selection logic to resolve the endpoint from ATLASCLOUD_BASE_URL
when config.baseURL is absent, while retaining config.baseURL precedence and the
existing public URL as the final default. Use the existing environment-variable
helper used by this branch, such as requireEnvVar, to honor custom fallback
deployments.

case "minimax":
return new MinimaxProvider(
requireEnvVar("MINIMAX_API_KEY"),
Expand Down
10 changes: 9 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ export interface ProviderConfig {
baseURL?: string;
}

export type ProviderType = "agent-sdk" | "anthropic" | "gemini" | "openrouter" | "minimax" | "openai" | "noop";
export type ProviderType =
| "agent-sdk"
| "anthropic"
| "atlascloud"
| "gemini"
| "openrouter"
| "minimax"
| "openai"
| "noop";

export interface MemoryProvider {
name: string;
Expand Down
54 changes: 54 additions & 0 deletions test/atlascloud-provider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { loadConfig, loadFallbackConfig } from "../src/config.js";
import { createProvider } from "../src/providers/index.js";

const providerEnvKeys = [
"ANTHROPIC_API_KEY",
"ATLASCLOUD_API_KEY",
"ATLASCLOUD_BASE_URL",
"ATLASCLOUD_MODEL",
"GEMINI_API_KEY",
"GOOGLE_API_KEY",
"MINIMAX_API_KEY",
"OPENAI_API_KEY",
"OPENROUTER_API_KEY",
"FALLBACK_PROVIDERS",
];
Comment on lines +5 to +16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Isolate MAX_TOKENS before asserting the default.

An ambient MAX_TOKENS makes line 43 differ from 4096, causing environment-dependent test failures.

Proposed fix
 const providerEnvKeys = [
+  "MAX_TOKENS",
   "ANTHROPIC_API_KEY",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const providerEnvKeys = [
"ANTHROPIC_API_KEY",
"ATLASCLOUD_API_KEY",
"ATLASCLOUD_BASE_URL",
"ATLASCLOUD_MODEL",
"GEMINI_API_KEY",
"GOOGLE_API_KEY",
"MINIMAX_API_KEY",
"OPENAI_API_KEY",
"OPENROUTER_API_KEY",
"FALLBACK_PROVIDERS",
];
const providerEnvKeys = [
"MAX_TOKENS",
"ANTHROPIC_API_KEY",
"ATLASCLOUD_API_KEY",
"ATLASCLOUD_BASE_URL",
"ATLASCLOUD_MODEL",
"GEMINI_API_KEY",
"GOOGLE_API_KEY",
"MINIMAX_API_KEY",
"OPENAI_API_KEY",
"OPENROUTER_API_KEY",
"FALLBACK_PROVIDERS",
];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/atlascloud-provider.test.ts` around lines 5 - 16, Update the provider
environment setup in atlascloud-provider.test.ts to include MAX_TOKENS in
providerEnvKeys, ensuring it is removed or isolated before the default assertion
near line 43. Preserve the assertion that the default value is 4096 and keep
other environment-key handling unchanged.


describe("Atlas Cloud provider", () => {
const savedEnv: Record<string, string | undefined> = {};

beforeEach(() => {
for (const key of providerEnvKeys) {
savedEnv[key] = process.env[key];
process.env[key] = "";
}
});

afterEach(() => {
for (const key of providerEnvKeys) {
if (savedEnv[key] === undefined) delete process.env[key];
else process.env[key] = savedEnv[key];
}
});

it("selects Atlas Cloud defaults from ATLASCLOUD_API_KEY", () => {
process.env.ATLASCLOUD_API_KEY = "atlas-test-key";

const config = loadConfig();

expect(config.provider).toEqual({
provider: "atlascloud",
model: "deepseek-ai/deepseek-v4-pro",
maxTokens: 4096,
baseURL: "https://api.atlascloud.ai/v1",
});
expect(() => createProvider(config.provider)).not.toThrow();
});

it("supports Atlas Cloud as a fallback provider", () => {
process.env.FALLBACK_PROVIDERS = "atlascloud";

expect(loadFallbackConfig().providers).toEqual(["atlascloud"]);
});
});