mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: add Claude API provider profiles for alternative endpoints
Add support for managing multiple Claude-compatible API endpoints (z.AI GLM, AWS Bedrock, etc.) through provider profiles in settings. Features: - New ClaudeApiProfile type with base URL, API key, model mappings - Pre-configured z.AI GLM template with correct model names - Profile selector in Settings > Claude > API Profiles - Clean switching between profiles and direct Anthropic API - Immediate persistence to prevent data loss on restart Profile support added to all execution paths: - Agent service (chat) - Ideation service - Auto-mode service (feature agents, enhancements) - Simple query service (title generation, descriptions, etc.) - Backlog planning, commit messages, spec generation - GitHub issue validation, suggestions Environment variables set when profile is active: - ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN/API_KEY - ANTHROPIC_DEFAULT_HAIKU/SONNET/OPUS_MODEL - API_TIMEOUT_MS, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
This commit is contained in:
@@ -158,6 +158,9 @@ export type {
|
||||
EventHookHttpAction,
|
||||
EventHookAction,
|
||||
EventHook,
|
||||
// Claude API profile types
|
||||
ClaudeApiProfile,
|
||||
ClaudeApiProfileTemplate,
|
||||
} from './settings.js';
|
||||
export {
|
||||
DEFAULT_KEYBOARD_SHORTCUTS,
|
||||
@@ -172,6 +175,8 @@ export {
|
||||
getThinkingTokenBudget,
|
||||
// Event hook constants
|
||||
EVENT_HOOK_TRIGGER_LABELS,
|
||||
// Claude API profile constants
|
||||
CLAUDE_API_PROFILE_TEMPLATES,
|
||||
} from './settings.js';
|
||||
|
||||
// Model display constants
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Shared types for AI model providers
|
||||
*/
|
||||
|
||||
import type { ThinkingLevel } from './settings.js';
|
||||
import type { ThinkingLevel, ClaudeApiProfile } from './settings.js';
|
||||
import type { CodexSandboxMode, CodexApprovalPolicy } from './codex.js';
|
||||
|
||||
/**
|
||||
@@ -209,6 +209,12 @@ export interface ExecuteOptions {
|
||||
type: 'json_schema';
|
||||
schema: Record<string, unknown>;
|
||||
};
|
||||
/**
|
||||
* Active Claude API profile for alternative endpoint configuration.
|
||||
* When set, uses profile's settings (base URL, auth, model mappings) instead of direct Anthropic API.
|
||||
* When undefined, uses direct Anthropic API (via API key or Claude Max CLI OAuth).
|
||||
*/
|
||||
claudeApiProfile?: ClaudeApiProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,6 +101,72 @@ export function getThinkingTokenBudget(level: ThinkingLevel | undefined): number
|
||||
/** ModelProvider - AI model provider for credentials and API key management */
|
||||
export type ModelProvider = 'claude' | 'cursor' | 'codex' | 'opencode';
|
||||
|
||||
// ============================================================================
|
||||
// Claude API Profiles - Configuration for Claude-compatible API endpoints
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* ClaudeApiProfile - Configuration for a Claude-compatible API endpoint
|
||||
*
|
||||
* Allows using alternative providers like z.AI GLM, AWS Bedrock, etc.
|
||||
*/
|
||||
export interface ClaudeApiProfile {
|
||||
/** Unique identifier (uuid) */
|
||||
id: string;
|
||||
/** Display name (e.g., "z.AI GLM", "AWS Bedrock") */
|
||||
name: string;
|
||||
/** ANTHROPIC_BASE_URL - custom API endpoint */
|
||||
baseUrl: string;
|
||||
/** API key value */
|
||||
apiKey: string;
|
||||
/** If true, use ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY */
|
||||
useAuthToken?: boolean;
|
||||
/** API_TIMEOUT_MS override in milliseconds */
|
||||
timeoutMs?: number;
|
||||
/** Optional model name mappings */
|
||||
modelMappings?: {
|
||||
/** Maps to ANTHROPIC_DEFAULT_HAIKU_MODEL */
|
||||
haiku?: string;
|
||||
/** Maps to ANTHROPIC_DEFAULT_SONNET_MODEL */
|
||||
sonnet?: string;
|
||||
/** Maps to ANTHROPIC_DEFAULT_OPUS_MODEL */
|
||||
opus?: string;
|
||||
};
|
||||
/** Set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 */
|
||||
disableNonessentialTraffic?: boolean;
|
||||
}
|
||||
|
||||
/** Known provider templates for quick setup */
|
||||
export interface ClaudeApiProfileTemplate {
|
||||
name: string;
|
||||
baseUrl: string;
|
||||
useAuthToken: boolean;
|
||||
timeoutMs?: number;
|
||||
modelMappings?: ClaudeApiProfile['modelMappings'];
|
||||
disableNonessentialTraffic?: boolean;
|
||||
description: string;
|
||||
apiKeyUrl?: string;
|
||||
}
|
||||
|
||||
/** Predefined templates for known Claude-compatible providers */
|
||||
export const CLAUDE_API_PROFILE_TEMPLATES: ClaudeApiProfileTemplate[] = [
|
||||
{
|
||||
name: 'z.AI GLM',
|
||||
baseUrl: 'https://api.z.ai/api/anthropic',
|
||||
useAuthToken: true,
|
||||
timeoutMs: 3000000,
|
||||
modelMappings: {
|
||||
haiku: 'GLM-4.5-Air',
|
||||
sonnet: 'GLM-4.7',
|
||||
opus: 'GLM-4.7',
|
||||
},
|
||||
disableNonessentialTraffic: true,
|
||||
description: '3× usage at fraction of cost via GLM Coding Plan',
|
||||
apiKeyUrl: 'https://z.ai/manage-apikey/apikey-list',
|
||||
},
|
||||
// Future: Add AWS Bedrock, Google Vertex, etc.
|
||||
];
|
||||
|
||||
// ============================================================================
|
||||
// Event Hooks - Custom actions triggered by system events
|
||||
// ============================================================================
|
||||
@@ -650,6 +716,19 @@ export interface GlobalSettings {
|
||||
* @see EventHook for configuration details
|
||||
*/
|
||||
eventHooks?: EventHook[];
|
||||
|
||||
// Claude API Profiles Configuration
|
||||
/**
|
||||
* Claude-compatible API endpoint profiles
|
||||
* Allows using alternative providers like z.AI GLM, AWS Bedrock, etc.
|
||||
*/
|
||||
claudeApiProfiles?: ClaudeApiProfile[];
|
||||
|
||||
/**
|
||||
* Active profile ID (null/undefined = use direct Anthropic API)
|
||||
* When set, the corresponding profile's settings will be used for Claude API calls
|
||||
*/
|
||||
activeClaudeApiProfileId?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -896,6 +975,8 @@ export const DEFAULT_GLOBAL_SETTINGS: GlobalSettings = {
|
||||
skillsSources: ['user', 'project'],
|
||||
enableSubagents: true,
|
||||
subagentsSources: ['user', 'project'],
|
||||
claudeApiProfiles: [],
|
||||
activeClaudeApiProfileId: null,
|
||||
};
|
||||
|
||||
/** Default credentials (empty strings - user must provide API keys) */
|
||||
|
||||
Reference in New Issue
Block a user