* add platform guards * add service management * fix types * move to zustand for servicehub * update App Updater * update tauri missing move * update app updater * refactor: move PlatformFeatures to separate const file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * change tauri fetch name * update implementation * update extension fetch * make web version run properly * disabled unused web settings * fix all tests * fix lint * fix tests * add mock for extension * fix build * update make and mise * fix tsconfig for web-extensions * fix loader type * cleanup * fix test * update error handling + mcp should be working * Update mcp init * use separate is_web_app build property * Remove fixed model catalog url * fix additional tests * fix download issue (event emitter not implemented correctly) * Update Title html * fix app logs * update root tsx render timing --------- Co-authored-by: Claude <noreply@anthropic.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { CoreRoutes, APIRoutes } from '@janhq/core'
|
|
import { getServiceHub } from '@/hooks/useServiceHub'
|
|
import { isPlatformTauri } from '@/lib/platform'
|
|
import type { InvokeArgs } from '@/services/core/types'
|
|
|
|
export const AppRoutes = [
|
|
'installExtensions',
|
|
'getTools',
|
|
'callTool',
|
|
'cancelToolCall',
|
|
'listThreads',
|
|
'createThread',
|
|
'modifyThread',
|
|
'deleteThread',
|
|
'listMessages',
|
|
'createMessage',
|
|
'modifyMessage',
|
|
'deleteMessage',
|
|
'getThreadAssistant',
|
|
'createThreadAssistant',
|
|
'modifyThreadAssistant',
|
|
'saveMcpConfigs',
|
|
'getMcpConfigs',
|
|
'restartMcpServers',
|
|
'getConnectedServers',
|
|
'readLogs',
|
|
'changeAppDataFolder',
|
|
]
|
|
// Define API routes based on different route types
|
|
export const Routes = [...CoreRoutes, ...APIRoutes, ...AppRoutes].map((r) => ({
|
|
path: `app`,
|
|
route: r,
|
|
}))
|
|
|
|
// Function to open an external URL in a new browser window
|
|
export function openExternalUrl(url: string) {
|
|
window?.open(url, '_blank')
|
|
}
|
|
|
|
export const APIs = {
|
|
...Object.values(Routes).reduce((acc, proxy) => {
|
|
return {
|
|
...acc,
|
|
[proxy.route]: (args?: InvokeArgs) => {
|
|
if (isPlatformTauri()) {
|
|
// For Tauri platform, use the service hub to invoke commands
|
|
return getServiceHub().core().invoke(
|
|
proxy.route.replace(/([A-Z])/g, '_$1').toLowerCase(),
|
|
args
|
|
)
|
|
} else {
|
|
// For Web platform, provide fallback implementations
|
|
console.warn(`API call '${proxy.route}' not supported in web environment`, args)
|
|
return Promise.resolve(null)
|
|
}
|
|
},
|
|
}
|
|
}, {}),
|
|
openExternalUrl,
|
|
}
|