- Remove models snapshot UI section from Models page - Delete models API route handler and related logic - Remove models store implementation and exports - Clean up internationalization messages for removed feature - Update main entry point exports to exclude models store
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { BrowserWindow } from 'electron';
|
|
import { gatewayManager } from '@electron/gateway/manager';
|
|
import { providerApiService } from '@electron/service/provider-api-service';
|
|
import { ClawHubService } from '@electron/gateway/clawhub';
|
|
import type { HostApiContext } from './context';
|
|
import type { HostApiRequest } from './route-utils';
|
|
import { normalizeRequest } from './route-utils';
|
|
import { handleAgentRoutes } from './routes/agents';
|
|
import { handleChannelRoutes } from './routes/channels';
|
|
import { handleCronRoutes } from './routes/cron';
|
|
import { handleFileRoutes } from './routes/files';
|
|
import { handleGatewayRoutes } from './routes/gateway';
|
|
import { handleKnowledgeRoutes } from './routes/knowledge';
|
|
import { handleProviderRoutes } from './routes/providers';
|
|
import { handleSessionRoutes } from './routes/sessions';
|
|
import { handleSkillRoutes } from './routes/skills';
|
|
|
|
type RouteHandler = (
|
|
request: ReturnType<typeof normalizeRequest>,
|
|
ctx: HostApiContext,
|
|
) => Promise<any | null>;
|
|
|
|
const routeHandlers: RouteHandler[] = [
|
|
handleProviderRoutes,
|
|
handleChannelRoutes,
|
|
handleAgentRoutes,
|
|
handleCronRoutes,
|
|
handleGatewayRoutes,
|
|
handleKnowledgeRoutes,
|
|
handleFileRoutes,
|
|
handleSessionRoutes,
|
|
handleSkillRoutes,
|
|
];
|
|
|
|
function createContext(): HostApiContext {
|
|
return {
|
|
gatewayManager,
|
|
providerApiService,
|
|
mainWindow: BrowserWindow.getAllWindows()[0] ?? null,
|
|
clawHubService: new ClawHubService(),
|
|
};
|
|
}
|
|
|
|
export async function dispatchLocalHostApi(request: HostApiRequest) {
|
|
const normalized = normalizeRequest(request);
|
|
const ctx = createContext();
|
|
|
|
for (const handler of routeHandlers) {
|
|
const result = await handler(normalized, ctx);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|