mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
feat: unified Claude API key and profile system with z.AI, MiniMax, OpenRouter support (#600)
* 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:
committed by
GitHub
parent
63b8eb0991
commit
d97c4b7b57
@@ -23,6 +23,7 @@ export function useProjectSettingsLoader() {
|
||||
const setAutoDismissInitScriptIndicator = useAppStore(
|
||||
(state) => state.setAutoDismissInitScriptIndicator
|
||||
);
|
||||
const setCurrentProject = useAppStore((state) => state.setCurrentProject);
|
||||
|
||||
const loadingRef = useRef<string | null>(null);
|
||||
const currentProjectRef = useRef<string | null>(null);
|
||||
@@ -107,6 +108,28 @@ export function useProjectSettingsLoader() {
|
||||
result.settings.autoDismissInitScriptIndicator
|
||||
);
|
||||
}
|
||||
|
||||
// Apply activeClaudeApiProfileId if present
|
||||
// This is stored directly on the project, so we need to update the currentProject
|
||||
// Type assertion needed because API returns Record<string, unknown>
|
||||
const settingsWithProfile = result.settings as Record<string, unknown>;
|
||||
const activeClaudeApiProfileId = settingsWithProfile.activeClaudeApiProfileId as
|
||||
| string
|
||||
| null
|
||||
| undefined;
|
||||
if (activeClaudeApiProfileId !== undefined) {
|
||||
const updatedProject = useAppStore.getState().currentProject;
|
||||
if (
|
||||
updatedProject &&
|
||||
updatedProject.path === requestedProjectPath &&
|
||||
updatedProject.activeClaudeApiProfileId !== activeClaudeApiProfileId
|
||||
) {
|
||||
setCurrentProject({
|
||||
...updatedProject,
|
||||
activeClaudeApiProfileId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load project settings:', error);
|
||||
|
||||
@@ -206,6 +206,10 @@ export function parseLocalStorageSettings(): Partial<GlobalSettings> | null {
|
||||
worktreePanelCollapsed === 'true' || (state.worktreePanelCollapsed as boolean),
|
||||
lastProjectDir: lastProjectDir || (state.lastProjectDir as string),
|
||||
recentFolders: recentFolders ? JSON.parse(recentFolders) : (state.recentFolders as string[]),
|
||||
// Claude API Profiles
|
||||
claudeApiProfiles: (state.claudeApiProfiles as GlobalSettings['claudeApiProfiles']) ?? [],
|
||||
activeClaudeApiProfileId:
|
||||
(state.activeClaudeApiProfileId as GlobalSettings['activeClaudeApiProfileId']) ?? null,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error('Failed to parse localStorage settings:', error);
|
||||
@@ -326,6 +330,20 @@ export function mergeSettings(
|
||||
merged.currentProjectId = localSettings.currentProjectId;
|
||||
}
|
||||
|
||||
// Claude API Profiles - preserve from localStorage if server is empty
|
||||
if (
|
||||
(!serverSettings.claudeApiProfiles || serverSettings.claudeApiProfiles.length === 0) &&
|
||||
localSettings.claudeApiProfiles &&
|
||||
localSettings.claudeApiProfiles.length > 0
|
||||
) {
|
||||
merged.claudeApiProfiles = localSettings.claudeApiProfiles;
|
||||
}
|
||||
|
||||
// Active Claude API Profile ID - preserve from localStorage if server doesn't have one
|
||||
if (!serverSettings.activeClaudeApiProfileId && localSettings.activeClaudeApiProfileId) {
|
||||
merged.activeClaudeApiProfileId = localSettings.activeClaudeApiProfileId;
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
@@ -671,6 +689,8 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
|
||||
},
|
||||
mcpServers: settings.mcpServers ?? [],
|
||||
promptCustomization: settings.promptCustomization ?? {},
|
||||
claudeApiProfiles: settings.claudeApiProfiles ?? [],
|
||||
activeClaudeApiProfileId: settings.activeClaudeApiProfileId ?? null,
|
||||
projects,
|
||||
currentProject,
|
||||
trashedProjects: settings.trashedProjects ?? [],
|
||||
@@ -732,6 +752,8 @@ function buildSettingsUpdateFromStore(): Record<string, unknown> {
|
||||
keyboardShortcuts: state.keyboardShortcuts,
|
||||
mcpServers: state.mcpServers,
|
||||
promptCustomization: state.promptCustomization,
|
||||
claudeApiProfiles: state.claudeApiProfiles,
|
||||
activeClaudeApiProfileId: state.activeClaudeApiProfileId,
|
||||
projects: state.projects,
|
||||
trashedProjects: state.trashedProjects,
|
||||
currentProjectId: state.currentProject?.id ?? null,
|
||||
|
||||
@@ -72,6 +72,8 @@ const SETTINGS_FIELDS_TO_SYNC = [
|
||||
'defaultTerminalId',
|
||||
'promptCustomization',
|
||||
'eventHooks',
|
||||
'claudeApiProfiles',
|
||||
'activeClaudeApiProfileId',
|
||||
'projects',
|
||||
'trashedProjects',
|
||||
'currentProjectId', // ID of currently open project
|
||||
@@ -628,6 +630,8 @@ export async function refreshSettingsFromServer(): Promise<boolean> {
|
||||
defaultEditorCommand: serverSettings.defaultEditorCommand ?? null,
|
||||
defaultTerminalId: serverSettings.defaultTerminalId ?? null,
|
||||
promptCustomization: serverSettings.promptCustomization ?? {},
|
||||
claudeApiProfiles: serverSettings.claudeApiProfiles ?? [],
|
||||
activeClaudeApiProfileId: serverSettings.activeClaudeApiProfileId ?? null,
|
||||
projects: serverSettings.projects,
|
||||
trashedProjects: serverSettings.trashedProjects,
|
||||
projectHistory: serverSettings.projectHistory,
|
||||
|
||||
Reference in New Issue
Block a user