- Updated MarketplaceDrawer to include security notes and manual installation hints. - Refactored SkillDetailDrawer to display default icons for skills. - Simplified SkillListItem to use default icons for better readability. - Integrated gateway status checks and warnings in SkillsPage for improved user awareness. - Enhanced error handling for skill installation and fetching, providing clearer feedback to users. - Added new translations for error messages and gateway warnings to improve localization support.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 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 { handleModelRoutes } from './routes/models';
|
|
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,
|
|
handleModelRoutes,
|
|
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;
|
|
}
|