mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-22 23:53:08 +00:00
* fix(copilot): correct tool.execution_complete event handling The CopilotProvider was using incorrect event type and data structure for tool execution completion events from the @github/copilot-sdk, causing tool call outputs to be empty. Changes: - Update event type from 'tool.execution_end' to 'tool.execution_complete' - Fix data structure to use nested result.content instead of flat result - Fix error structure to use error.message instead of flat error - Add success field to match SDK event structure - Add tests for empty and missing result handling This aligns with the official @github/copilot-sdk v0.1.16 types defined in session-events.d.ts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test(copilot): add edge case test for error with code field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor(copilot): improve error handling and code quality Code review improvements: - Extract magic string '[ERROR]' to TOOL_ERROR_PREFIX constant - Add null-safe error handling with direct error variable assignment - Include error codes in error messages for better debugging - Add JSDoc documentation for tool.execution_complete handler - Update tests to verify error codes are displayed - Add missing tool_use_id assertion in error test These changes improve: - Code maintainability (no magic strings) - Debugging experience (error codes now visible) - Type safety (explicit null checks) - Test coverage (verify error code formatting) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Changes from fix/bug-fixes-1-0 * test(copilot): add edge case test for error with code field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Changes from fix/bug-fixes-1-0 * fix: Handle detached HEAD state in worktree discovery and recovery * fix: Remove unused isDevServerStarting prop and md: breakpoint classes * fix: Add missing dependency and sanitize persisted cache data * feat: Ensure NODE_ENV is set to test in vitest configs * feat: Configure Playwright to run only E2E tests * fix: Improve PR tracking and dev server lifecycle management * feat: Add settings-based defaults for planning mode, model config, and custom providers. Fixes #816 * feat: Add worktree and branch selector to graph view * fix: Add timeout and error handling for worktree HEAD ref resolution * fix: use absolute icon path and place icon outside asar on Linux The hicolor icon theme index only lists sizes up to 512x512, so an icon installed only at 1024x1024 is invisible to GNOME/KDE's theme resolver, causing both the app launcher and taskbar to show a generic icon. Additionally, BrowserWindow.icon cannot be read by the window manager when the file is inside app.asar. - extraResources: copy logo_larger.png to resources/ (outside asar) so it lands at /opt/Automaker/resources/logo_larger.png on install - linux.desktop.Icon: set to the absolute resources path, bypassing the hicolor theme lookup and its size constraints entirely - icon-manager.ts: on Linux production use process.resourcesPath so BrowserWindow receives a real filesystem path the WM can read directly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use linux.desktop.entry for custom desktop Icon field electron-builder v26 rejects arbitrary keys in linux.desktop — the correct schema wraps custom .desktop overrides inside desktop.entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: set desktop name on Linux so taskbar uses the correct app icon Without app.setDesktopName(), the window manager cannot associate the running Electron process with automaker.desktop. GNOME/KDE fall back to _NET_WM_ICON which defaults to Electron's own bundled icon. Calling app.setDesktopName('automaker.desktop') before any window is created sets the _GTK_APPLICATION_ID hint and XDG app_id so the WM picks up the desktop entry's Icon for the taskbar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix: memory and context views mobile friendly (#818) * Changes from fix/memory-and-context-mobile-friendly * fix: Improve file extension detection and add path traversal protection * refactor: Extract file extension utilities and add path traversal guards Code review improvements: - Extract isMarkdownFilename and isImageFilename to shared image-utils.ts - Remove duplicated code from context-view.tsx and memory-view.tsx - Add path traversal guard for context fixture utilities (matching memory) - Add 7 new tests for context fixture path traversal protection - Total 61 tests pass Addresses code review feedback from PR #813 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: Add e2e tests for profiles crud and board background persistence * Update apps/ui/playwright.config.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: Add robust test navigation handling and file filtering * fix: Format NODE_OPTIONS configuration on single line * test: Update profiles and board background persistence tests * test: Replace iPhone 13 Pro with Pixel 5 for mobile test consistency * Update apps/ui/src/components/views/context-view.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: Remove test project directory * feat: Filter context files by type and improve mobile menu visibility --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: Improve test reliability and localhost handling * chore: Use explicit TEST_USE_EXTERNAL_BACKEND env var for server cleanup * feat: Add E2E/CI mock mode for provider factory and auth verification * feat: Add remoteBranch parameter to pull and rebase operations * chore: Enhance E2E testing setup with worker isolation and auth state management - Updated .gitignore to include worker-specific test fixtures. - Modified e2e-tests.yml to implement test sharding for improved CI performance. - Refactored global setup to authenticate once and save session state for reuse across tests. - Introduced worker-isolated fixture paths to prevent conflicts during parallel test execution. - Improved test navigation and loading handling for better reliability. - Updated various test files to utilize new auth state management and fixture paths. * fix: Update Playwright configuration and improve test reliability - Increased the number of workers in Playwright configuration for better parallelism in CI environments. - Enhanced the board background persistence test to ensure dropdown stability by waiting for the list to populate before interaction, improving test reliability. * chore: Simplify E2E test configuration and enhance mock implementations - Updated e2e-tests.yml to run tests in a single shard for streamlined CI execution. - Enhanced unit tests for worktree list handling by introducing a mock for execGitCommand, improving test reliability and coverage. - Refactored setup functions to better manage command mocks for git operations in tests. - Improved error handling in mkdirSafe function to account for undefined stats in certain environments. * refactor: Improve test configurations and enhance error handling - Updated Playwright configuration to clear VITE_SERVER_URL, ensuring the frontend uses the Vite proxy and preventing cookie domain mismatches. - Enhanced MergeRebaseDialog logic to normalize selectedBranch for better handling of various ref formats. - Improved global setup with a more robust backend health check, throwing an error if the backend is not healthy after retries. - Refactored project creation tests to handle file existence checks more reliably. - Added error handling for missing E2E source fixtures to guide setup process. - Enhanced memory navigation to handle sandbox dialog visibility more effectively. * refactor: Enhance Git command execution and improve test configurations - Updated Git command execution to merge environment paths correctly, ensuring proper command execution context. - Refactored the Git initialization process to handle errors more gracefully and ensure user configuration is set before creating the initial commit. - Improved test configurations by updating Playwright test identifiers for better clarity and consistency across different project states. - Enhanced cleanup functions in tests to handle directory removal more robustly, preventing errors during test execution. * fix: Resolve React hooks errors from duplicate instances in dependency tree * style: Format alias configuration for improved readability --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: DhanushSantosh <dhanushsantoshs05@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
449 lines
16 KiB
TypeScript
449 lines
16 KiB
TypeScript
/**
|
|
* Claude Provider - Executes queries using Claude Agent SDK
|
|
*
|
|
* Wraps the @anthropic-ai/claude-agent-sdk for seamless integration
|
|
* with the provider architecture.
|
|
*/
|
|
|
|
import { query, type Options, type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
import { BaseProvider } from './base-provider.js';
|
|
import { classifyError, getUserFriendlyErrorMessage, createLogger } from '@automaker/utils';
|
|
import { getClaudeAuthIndicators } from '@automaker/platform';
|
|
import {
|
|
getThinkingTokenBudget,
|
|
validateBareModelId,
|
|
type ClaudeApiProfile,
|
|
type ClaudeCompatibleProvider,
|
|
type Credentials,
|
|
} from '@automaker/types';
|
|
import type {
|
|
ExecuteOptions,
|
|
ProviderMessage,
|
|
InstallationStatus,
|
|
ModelDefinition,
|
|
} from './types.js';
|
|
|
|
const logger = createLogger('ClaudeProvider');
|
|
|
|
/**
|
|
* ProviderConfig - Union type for provider configuration
|
|
*
|
|
* Accepts either the legacy ClaudeApiProfile or new ClaudeCompatibleProvider.
|
|
* Both share the same connection settings structure.
|
|
*/
|
|
type ProviderConfig = ClaudeApiProfile | ClaudeCompatibleProvider;
|
|
|
|
// System vars are always passed from process.env regardless of profile.
|
|
// Includes filesystem, locale, and temp directory vars that the Claude CLI
|
|
// needs internally for config resolution and temp file creation.
|
|
const SYSTEM_ENV_VARS = [
|
|
'PATH',
|
|
'HOME',
|
|
'SHELL',
|
|
'TERM',
|
|
'USER',
|
|
'LANG',
|
|
'LC_ALL',
|
|
'TMPDIR',
|
|
'XDG_CONFIG_HOME',
|
|
'XDG_DATA_HOME',
|
|
'XDG_CACHE_HOME',
|
|
'XDG_STATE_HOME',
|
|
];
|
|
|
|
/**
|
|
* Check if the config is a ClaudeCompatibleProvider (new system)
|
|
* by checking for the 'models' array property
|
|
*/
|
|
function isClaudeCompatibleProvider(config: ProviderConfig): config is ClaudeCompatibleProvider {
|
|
return 'models' in config && Array.isArray(config.models);
|
|
}
|
|
|
|
/**
|
|
* Build environment for the SDK with only explicitly allowed variables.
|
|
* When a provider/profile is provided, uses its configuration (clean switch - don't inherit from process.env).
|
|
* When no provider is provided, uses direct Anthropic API settings from process.env.
|
|
*
|
|
* Supports both:
|
|
* - ClaudeCompatibleProvider (new system with models[] array)
|
|
* - ClaudeApiProfile (legacy system with modelMappings)
|
|
*
|
|
* @param providerConfig - Optional provider configuration for alternative endpoint
|
|
* @param credentials - Optional credentials object for resolving 'credentials' apiKeySource
|
|
*/
|
|
function buildEnv(
|
|
providerConfig?: ProviderConfig,
|
|
credentials?: Credentials
|
|
): Record<string, string | undefined> {
|
|
const env: Record<string, string | undefined> = {};
|
|
|
|
if (providerConfig) {
|
|
// Use provider configuration (clean switch - don't inherit non-system vars from process.env)
|
|
logger.debug('[buildEnv] Using provider configuration:', {
|
|
name: providerConfig.name,
|
|
baseUrl: providerConfig.baseUrl,
|
|
apiKeySource: providerConfig.apiKeySource ?? 'inline',
|
|
isNewProvider: isClaudeCompatibleProvider(providerConfig),
|
|
});
|
|
|
|
// Resolve API key based on source strategy
|
|
let apiKey: string | undefined;
|
|
const source = providerConfig.apiKeySource ?? 'inline'; // Default to inline for backwards compat
|
|
|
|
switch (source) {
|
|
case 'inline':
|
|
apiKey = providerConfig.apiKey;
|
|
break;
|
|
case 'env':
|
|
apiKey = process.env.ANTHROPIC_API_KEY;
|
|
break;
|
|
case 'credentials':
|
|
apiKey = credentials?.apiKeys?.anthropic;
|
|
break;
|
|
}
|
|
|
|
// Warn if no API key found
|
|
if (!apiKey) {
|
|
logger.warn(`No API key found for provider "${providerConfig.name}" with source "${source}"`);
|
|
}
|
|
|
|
// Authentication
|
|
if (providerConfig.useAuthToken) {
|
|
env['ANTHROPIC_AUTH_TOKEN'] = apiKey;
|
|
} else {
|
|
env['ANTHROPIC_API_KEY'] = apiKey;
|
|
}
|
|
|
|
// Endpoint configuration
|
|
env['ANTHROPIC_BASE_URL'] = providerConfig.baseUrl;
|
|
logger.debug(`[buildEnv] Set ANTHROPIC_BASE_URL to: ${providerConfig.baseUrl}`);
|
|
|
|
if (providerConfig.timeoutMs) {
|
|
env['API_TIMEOUT_MS'] = String(providerConfig.timeoutMs);
|
|
}
|
|
|
|
// Model mappings - only for legacy ClaudeApiProfile
|
|
// For ClaudeCompatibleProvider, the model is passed directly (no mapping needed)
|
|
if (!isClaudeCompatibleProvider(providerConfig) && providerConfig.modelMappings) {
|
|
if (providerConfig.modelMappings.haiku) {
|
|
env['ANTHROPIC_DEFAULT_HAIKU_MODEL'] = providerConfig.modelMappings.haiku;
|
|
}
|
|
if (providerConfig.modelMappings.sonnet) {
|
|
env['ANTHROPIC_DEFAULT_SONNET_MODEL'] = providerConfig.modelMappings.sonnet;
|
|
}
|
|
if (providerConfig.modelMappings.opus) {
|
|
env['ANTHROPIC_DEFAULT_OPUS_MODEL'] = providerConfig.modelMappings.opus;
|
|
}
|
|
}
|
|
|
|
// Traffic control
|
|
if (providerConfig.disableNonessentialTraffic) {
|
|
env['CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC'] = '1';
|
|
}
|
|
} else {
|
|
// Use direct Anthropic API - pass through credentials or environment variables
|
|
// This supports:
|
|
// 1. API Key mode: ANTHROPIC_API_KEY from credentials (UI settings) or env
|
|
// 2. Claude Max plan: Uses CLI OAuth auth (SDK handles this automatically)
|
|
// 3. Custom endpoints via ANTHROPIC_BASE_URL env var (backward compatibility)
|
|
//
|
|
// Priority: credentials file (UI settings) -> environment variable
|
|
// Note: Only auth and endpoint vars are passed. Model mappings and traffic
|
|
// control are NOT passed (those require a profile for explicit configuration).
|
|
if (credentials?.apiKeys?.anthropic) {
|
|
env['ANTHROPIC_API_KEY'] = credentials.apiKeys.anthropic;
|
|
} else if (process.env.ANTHROPIC_API_KEY) {
|
|
env['ANTHROPIC_API_KEY'] = process.env.ANTHROPIC_API_KEY;
|
|
}
|
|
// If using Claude Max plan via CLI auth, the SDK handles auth automatically
|
|
// when no API key is provided. We don't set ANTHROPIC_AUTH_TOKEN here
|
|
// unless it was explicitly set in process.env (rare edge case).
|
|
if (process.env.ANTHROPIC_AUTH_TOKEN) {
|
|
env['ANTHROPIC_AUTH_TOKEN'] = process.env.ANTHROPIC_AUTH_TOKEN;
|
|
}
|
|
// Pass through ANTHROPIC_BASE_URL if set in environment (backward compatibility)
|
|
if (process.env.ANTHROPIC_BASE_URL) {
|
|
env['ANTHROPIC_BASE_URL'] = process.env.ANTHROPIC_BASE_URL;
|
|
}
|
|
}
|
|
|
|
// Always add system vars from process.env
|
|
for (const key of SYSTEM_ENV_VARS) {
|
|
if (process.env[key]) {
|
|
env[key] = process.env[key];
|
|
}
|
|
}
|
|
|
|
return env;
|
|
}
|
|
|
|
export class ClaudeProvider extends BaseProvider {
|
|
getName(): string {
|
|
return 'claude';
|
|
}
|
|
|
|
/**
|
|
* Execute a query using Claude Agent SDK
|
|
*/
|
|
async *executeQuery(options: ExecuteOptions): AsyncGenerator<ProviderMessage> {
|
|
// Validate that model doesn't have a provider prefix
|
|
// AgentService should strip prefixes before passing to providers
|
|
// Claude doesn't use a provider prefix, so we don't need to specify an expected provider
|
|
validateBareModelId(options.model, 'ClaudeProvider');
|
|
|
|
const {
|
|
prompt,
|
|
model,
|
|
cwd,
|
|
systemPrompt,
|
|
maxTurns = 1000,
|
|
allowedTools,
|
|
abortController,
|
|
conversationHistory,
|
|
sdkSessionId,
|
|
thinkingLevel,
|
|
claudeApiProfile,
|
|
claudeCompatibleProvider,
|
|
credentials,
|
|
} = options;
|
|
|
|
// Determine which provider config to use
|
|
// claudeCompatibleProvider takes precedence over claudeApiProfile
|
|
const providerConfig = claudeCompatibleProvider || claudeApiProfile;
|
|
|
|
// Build thinking configuration
|
|
// Adaptive thinking (Opus 4.6): don't set maxThinkingTokens, model uses adaptive by default
|
|
// Manual thinking (Haiku/Sonnet): use budget_tokens
|
|
const maxThinkingTokens =
|
|
thinkingLevel === 'adaptive' ? undefined : getThinkingTokenBudget(thinkingLevel);
|
|
|
|
// Build Claude SDK options
|
|
const sdkOptions: Options = {
|
|
model,
|
|
systemPrompt,
|
|
maxTurns,
|
|
cwd,
|
|
// Pass only explicitly allowed environment variables to SDK
|
|
// When a provider is active, uses provider settings (clean switch)
|
|
// When no provider, uses direct Anthropic API (from process.env or CLI OAuth)
|
|
env: buildEnv(providerConfig, credentials),
|
|
// Pass through allowedTools if provided by caller (decided by sdk-options.ts)
|
|
...(allowedTools && { allowedTools }),
|
|
// Restrict available built-in tools if specified (tools: [] disables all tools)
|
|
...(options.tools && { tools: options.tools }),
|
|
// AUTONOMOUS MODE: Always bypass permissions for fully autonomous operation
|
|
permissionMode: 'bypassPermissions',
|
|
allowDangerouslySkipPermissions: true,
|
|
abortController,
|
|
// Resume existing SDK session if we have a session ID
|
|
...(sdkSessionId && conversationHistory && conversationHistory.length > 0
|
|
? { resume: sdkSessionId }
|
|
: {}),
|
|
// Forward settingSources for CLAUDE.md file loading
|
|
...(options.settingSources && { settingSources: options.settingSources }),
|
|
// Forward MCP servers configuration
|
|
...(options.mcpServers && { mcpServers: options.mcpServers }),
|
|
// Extended thinking configuration
|
|
...(maxThinkingTokens && { maxThinkingTokens }),
|
|
// Subagents configuration for specialized task delegation
|
|
...(options.agents && { agents: options.agents }),
|
|
// Pass through outputFormat for structured JSON outputs
|
|
...(options.outputFormat && { outputFormat: options.outputFormat }),
|
|
};
|
|
|
|
// Build prompt payload
|
|
let promptPayload: string | AsyncIterable<SDKUserMessage>;
|
|
|
|
if (Array.isArray(prompt)) {
|
|
// Multi-part prompt (with images)
|
|
promptPayload = (async function* () {
|
|
const multiPartPrompt: SDKUserMessage = {
|
|
type: 'user' as const,
|
|
session_id: sdkSessionId || '',
|
|
message: {
|
|
role: 'user' as const,
|
|
content: prompt,
|
|
},
|
|
parent_tool_use_id: null,
|
|
};
|
|
yield multiPartPrompt;
|
|
})();
|
|
} else {
|
|
// Simple text prompt
|
|
promptPayload = prompt;
|
|
}
|
|
|
|
// Log the environment being passed to the SDK for debugging
|
|
const envForSdk = sdkOptions.env as Record<string, string | undefined>;
|
|
logger.debug('[ClaudeProvider] SDK Configuration:', {
|
|
model: sdkOptions.model,
|
|
baseUrl: envForSdk?.['ANTHROPIC_BASE_URL'] || '(default Anthropic API)',
|
|
hasApiKey: !!envForSdk?.['ANTHROPIC_API_KEY'],
|
|
hasAuthToken: !!envForSdk?.['ANTHROPIC_AUTH_TOKEN'],
|
|
providerName: providerConfig?.name || '(direct Anthropic)',
|
|
maxTurns: sdkOptions.maxTurns,
|
|
maxThinkingTokens: sdkOptions.maxThinkingTokens,
|
|
});
|
|
|
|
// Execute via Claude Agent SDK
|
|
try {
|
|
const stream = query({ prompt: promptPayload, options: sdkOptions });
|
|
|
|
// Stream messages directly - they're already in the correct format
|
|
for await (const msg of stream) {
|
|
yield msg as ProviderMessage;
|
|
}
|
|
} catch (error) {
|
|
// Enhance error with user-friendly message and classification
|
|
const errorInfo = classifyError(error);
|
|
const userMessage = getUserFriendlyErrorMessage(error);
|
|
|
|
logger.error('executeQuery() error during execution:', {
|
|
type: errorInfo.type,
|
|
message: errorInfo.message,
|
|
isRateLimit: errorInfo.isRateLimit,
|
|
retryAfter: errorInfo.retryAfter,
|
|
stack: (error as Error).stack,
|
|
});
|
|
|
|
// Build enhanced error message with additional guidance for rate limits
|
|
const message = errorInfo.isRateLimit
|
|
? `${userMessage}\n\nTip: If you're running multiple features in auto-mode, consider reducing concurrency (maxConcurrency setting) to avoid hitting rate limits.`
|
|
: userMessage;
|
|
|
|
const enhancedError = new Error(message) as Error & {
|
|
originalError: unknown;
|
|
type: string;
|
|
retryAfter?: number;
|
|
};
|
|
enhancedError.originalError = error;
|
|
enhancedError.type = errorInfo.type;
|
|
|
|
if (errorInfo.isRateLimit) {
|
|
enhancedError.retryAfter = errorInfo.retryAfter;
|
|
}
|
|
|
|
throw enhancedError;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Detect Claude SDK installation (always available via npm)
|
|
*/
|
|
async detectInstallation(): Promise<InstallationStatus> {
|
|
// Claude SDK is always available since it's a dependency
|
|
// Check all four supported auth methods, mirroring the logic in buildEnv():
|
|
// 1. ANTHROPIC_API_KEY environment variable
|
|
// 2. ANTHROPIC_AUTH_TOKEN environment variable
|
|
// 3. credentials?.apiKeys?.anthropic (credentials file, checked via platform indicators)
|
|
// 4. Claude Max CLI OAuth (SDK handles this automatically; detected via getClaudeAuthIndicators)
|
|
const hasEnvApiKey = !!process.env.ANTHROPIC_API_KEY;
|
|
const hasEnvAuthToken = !!process.env.ANTHROPIC_AUTH_TOKEN;
|
|
|
|
// Check credentials file and CLI OAuth indicators (same sources used by buildEnv)
|
|
let hasCredentialsApiKey = false;
|
|
let hasCliOAuth = false;
|
|
try {
|
|
const indicators = await getClaudeAuthIndicators();
|
|
hasCredentialsApiKey = !!indicators.credentials?.hasApiKey;
|
|
hasCliOAuth = !!(
|
|
indicators.credentials?.hasOAuthToken ||
|
|
indicators.hasStatsCacheWithActivity ||
|
|
(indicators.hasSettingsFile && indicators.hasProjectsSessions)
|
|
);
|
|
} catch {
|
|
// If we can't check indicators, fall back to env vars only
|
|
}
|
|
|
|
const hasApiKey = hasEnvApiKey || hasCredentialsApiKey;
|
|
const authenticated = hasEnvApiKey || hasEnvAuthToken || hasCredentialsApiKey || hasCliOAuth;
|
|
|
|
const status: InstallationStatus = {
|
|
installed: true,
|
|
method: 'sdk',
|
|
hasApiKey,
|
|
authenticated,
|
|
};
|
|
|
|
return status;
|
|
}
|
|
|
|
/**
|
|
* Get available Claude models
|
|
*/
|
|
getAvailableModels(): ModelDefinition[] {
|
|
const models = [
|
|
{
|
|
id: 'claude-opus-4-6',
|
|
name: 'Claude Opus 4.6',
|
|
modelString: 'claude-opus-4-6',
|
|
provider: 'anthropic',
|
|
description: 'Most capable Claude model with adaptive thinking',
|
|
contextWindow: 200000,
|
|
maxOutputTokens: 128000,
|
|
supportsVision: true,
|
|
supportsTools: true,
|
|
tier: 'premium' as const,
|
|
default: true,
|
|
},
|
|
{
|
|
id: 'claude-sonnet-4-6',
|
|
name: 'Claude Sonnet 4.6',
|
|
modelString: 'claude-sonnet-4-6',
|
|
provider: 'anthropic',
|
|
description: 'Balanced performance and cost with enhanced reasoning',
|
|
contextWindow: 200000,
|
|
maxOutputTokens: 64000,
|
|
supportsVision: true,
|
|
supportsTools: true,
|
|
tier: 'standard' as const,
|
|
},
|
|
{
|
|
id: 'claude-sonnet-4-20250514',
|
|
name: 'Claude Sonnet 4',
|
|
modelString: 'claude-sonnet-4-20250514',
|
|
provider: 'anthropic',
|
|
description: 'Balanced performance and cost',
|
|
contextWindow: 200000,
|
|
maxOutputTokens: 16000,
|
|
supportsVision: true,
|
|
supportsTools: true,
|
|
tier: 'standard' as const,
|
|
},
|
|
{
|
|
id: 'claude-3-5-sonnet-20241022',
|
|
name: 'Claude 3.5 Sonnet',
|
|
modelString: 'claude-3-5-sonnet-20241022',
|
|
provider: 'anthropic',
|
|
description: 'Fast and capable',
|
|
contextWindow: 200000,
|
|
maxOutputTokens: 8000,
|
|
supportsVision: true,
|
|
supportsTools: true,
|
|
tier: 'standard' as const,
|
|
},
|
|
{
|
|
id: 'claude-haiku-4-5-20251001',
|
|
name: 'Claude Haiku 4.5',
|
|
modelString: 'claude-haiku-4-5-20251001',
|
|
provider: 'anthropic',
|
|
description: 'Fastest Claude model',
|
|
contextWindow: 200000,
|
|
maxOutputTokens: 8000,
|
|
supportsVision: true,
|
|
supportsTools: true,
|
|
tier: 'basic' as const,
|
|
},
|
|
] satisfies ModelDefinition[];
|
|
return models;
|
|
}
|
|
|
|
/**
|
|
* Check if the provider supports a specific feature
|
|
*/
|
|
supportsFeature(feature: string): boolean {
|
|
const supportedFeatures = ['tools', 'text', 'vision', 'thinking'];
|
|
return supportedFeatures.includes(feature);
|
|
}
|
|
}
|