feat: add useApiSettings hook for managing API settings, including providers, endpoints, cache, and model pools

- Implemented hooks for CRUD operations on providers and endpoints.
- Added cache management hooks for cache stats and settings.
- Introduced model pool management hooks for high availability and load balancing.
- Created localization files for English and Chinese translations of API settings.
This commit is contained in:
catlog22
2026-02-01 23:14:55 +08:00
parent b76424feef
commit e5252f8a77
27 changed files with 4370 additions and 201 deletions

View File

@@ -77,6 +77,7 @@ interface CliStreamState extends BlockCacheState {
outputs: Record<string, CliOutputLine[]>;
executions: Record<string, CliExecutionState>;
currentExecutionId: string | null;
userClosedExecutions: Set<string>; // Track executions closed by user
// Legacy methods
addOutput: (executionId: string, line: CliOutputLine) => void;
@@ -87,6 +88,9 @@ interface CliStreamState extends BlockCacheState {
getAllExecutions: () => CliExecutionState[];
upsertExecution: (executionId: string, exec: Partial<CliExecutionState> & { tool?: string; mode?: string }) => void;
removeExecution: (executionId: string) => void;
markExecutionClosedByUser: (executionId: string) => void;
isExecutionClosedByUser: (executionId: string) => boolean;
cleanupUserClosedExecutions: (serverIds: Set<string>) => void;
setCurrentExecution: (executionId: string | null) => void;
// Block cache methods
@@ -320,6 +324,7 @@ export const useCliStreamStore = create<CliStreamState>()(
outputs: {},
executions: {},
currentExecutionId: null,
userClosedExecutions: new Set<string>(),
// Block cache state
blocks: {},
@@ -426,6 +431,35 @@ export const useCliStreamStore = create<CliStreamState>()(
}, false, 'cliStream/removeExecution');
},
markExecutionClosedByUser: (executionId: string) => {
set((state) => {
const newUserClosedExecutions = new Set(state.userClosedExecutions);
newUserClosedExecutions.add(executionId);
return {
userClosedExecutions: newUserClosedExecutions,
};
}, false, 'cliStream/markExecutionClosedByUser');
},
isExecutionClosedByUser: (executionId: string) => {
return get().userClosedExecutions.has(executionId);
},
cleanupUserClosedExecutions: (serverIds: Set<string>) => {
set((state) => {
const newUserClosedExecutions = new Set<string>();
for (const executionId of state.userClosedExecutions) {
// Only keep if still on server (user might want to keep it closed)
if (serverIds.has(executionId)) {
newUserClosedExecutions.add(executionId);
}
}
return {
userClosedExecutions: newUserClosedExecutions,
};
}, false, 'cliStream/cleanupUserClosedExecutions');
},
setCurrentExecution: (executionId: string | null) => {
set({ currentExecutionId: executionId }, false, 'cliStream/setCurrentExecution');
},