chore: update MCP servers list (#5195)
* chore: update MCP servers list * chore: rename * chore: attempt to stop models before updating * chore: clean up logs * chore: fix bug refresh
This commit is contained in:
parent
f97a51b34d
commit
fb7dc21135
@ -121,7 +121,6 @@ pub fn readdir_sync<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let path = resolve_path(app_handle, &args[0]);
|
let path = resolve_path(app_handle, &args[0]);
|
||||||
log::error!("Reading directory: {:?}", path);
|
|
||||||
let entries = fs::read_dir(&path).map_err(|e| e.to_string())?;
|
let entries = fs::read_dir(&path).map_err(|e| e.to_string())?;
|
||||||
let paths: Vec<String> = entries
|
let paths: Vec<String> = entries
|
||||||
.filter_map(|entry| entry.ok())
|
.filter_map(|entry| entry.ok())
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use tokio::{process::Command, sync::Mutex, time::timeout};
|
|||||||
|
|
||||||
use super::{cmd::get_jan_data_folder_path, state::AppState};
|
use super::{cmd::get_jan_data_folder_path, state::AppState};
|
||||||
|
|
||||||
const DEFAULT_MCP_CONFIG: &str = r#"{"mcpServers":{"browsermcp":{"command":"npx","args":["@browsermcp/mcp"],"env":{},"active":false},"fetch":{"command":"uvx","args":["mcp-server-fetch"],"env":{},"active":false},"filesystem":{"command":"npx","args":["-y","/path/to/other/allowed/dir"],"env":{},"active":false},"playwright":{"command":"npx","args":["@playwright/mcp","--isolated"],"env":{},"active":false},"mindmap":{"command":"uvx","args":["mindmap-mcp-server","--return-type","filePath"],"env":{},"active":false}}}"#;
|
const DEFAULT_MCP_CONFIG: &str = r#"{"mcpServers":{"browsermcp":{"command":"npx","args":["@browsermcp/mcp"],"env":{},"active":false},"fetch":{"command":"uvx","args":["mcp-server-fetch"],"env":{},"active":false},"filesystem":{"command":"npx","args":["-y","/path/to/other/allowed/dir"],"env":{},"active":false},"playwright":{"command":"npx","args":["@playwright/mcp","--isolated"],"env":{},"active":false},"sequential-thinking":{"command":"npx","args":["-y","@modelcontextprotocol/server-sequential-thinking"],"env":{},"active":false},"tavily":{"command":"npx","args":["-y","tavily-mcp"],"env":{"TAVILY_API_KEY": "tvly-YOUR_API_KEY-here"},"active":false}}}"#;
|
||||||
|
|
||||||
// Timeout for MCP tool calls (30 seconds)
|
// Timeout for MCP tool calls (30 seconds)
|
||||||
const MCP_TOOL_CALL_TIMEOUT: Duration = Duration::from_secs(30);
|
const MCP_TOOL_CALL_TIMEOUT: Duration = Duration::from_secs(30);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { IconSettings } from '@tabler/icons-react'
|
import { IconSettings } from '@tabler/icons-react'
|
||||||
|
import debounce from 'lodash.debounce'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sheet,
|
Sheet,
|
||||||
@ -10,7 +11,7 @@ import {
|
|||||||
} from '@/components/ui/sheet'
|
} from '@/components/ui/sheet'
|
||||||
import { DynamicControllerSetting } from '@/containers/dynamicControllerSetting'
|
import { DynamicControllerSetting } from '@/containers/dynamicControllerSetting'
|
||||||
import { useModelProvider } from '@/hooks/useModelProvider'
|
import { useModelProvider } from '@/hooks/useModelProvider'
|
||||||
import { updateModel } from '@/services/models'
|
import { updateModel, stopModel } from '@/services/models'
|
||||||
import { ModelSettingParams } from '@janhq/core'
|
import { ModelSettingParams } from '@janhq/core'
|
||||||
|
|
||||||
type ModelSettingProps = {
|
type ModelSettingProps = {
|
||||||
@ -21,6 +22,11 @@ type ModelSettingProps = {
|
|||||||
export function ModelSetting({ model, provider }: ModelSettingProps) {
|
export function ModelSetting({ model, provider }: ModelSettingProps) {
|
||||||
const { updateProvider } = useModelProvider()
|
const { updateProvider } = useModelProvider()
|
||||||
|
|
||||||
|
// Create a debounced version of stopModel that waits 500ms after the last call
|
||||||
|
const debouncedStopModel = debounce((modelId: string) => {
|
||||||
|
stopModel(modelId)
|
||||||
|
}, 500)
|
||||||
|
|
||||||
const handleSettingChange = (
|
const handleSettingChange = (
|
||||||
key: string,
|
key: string,
|
||||||
value: string | boolean | number
|
value: string | boolean | number
|
||||||
@ -66,11 +72,15 @@ export function ModelSetting({ model, provider }: ModelSettingProps) {
|
|||||||
},
|
},
|
||||||
{} as Record<string, unknown>
|
{} as Record<string, unknown>
|
||||||
) as ModelSettingParams
|
) as ModelSettingParams
|
||||||
|
|
||||||
updateModel({
|
updateModel({
|
||||||
id: model.id,
|
id: model.id,
|
||||||
settings: params,
|
settings: params,
|
||||||
...(params as unknown as object),
|
...(params as unknown as object),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Call debounced stopModel after updating the model
|
||||||
|
debouncedStopModel(model.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,9 @@ import { isDev } from '@/lib/utils'
|
|||||||
import { check, Update } from '@tauri-apps/plugin-updater'
|
import { check, Update } from '@tauri-apps/plugin-updater'
|
||||||
import { useState, useCallback, useEffect } from 'react'
|
import { useState, useCallback, useEffect } from 'react'
|
||||||
import { events, AppEvent } from '@janhq/core'
|
import { events, AppEvent } from '@janhq/core'
|
||||||
|
import { emit } from '@tauri-apps/api/event'
|
||||||
|
import { SystemEvent } from '@/types/events'
|
||||||
|
import { stopAllModels } from '@/services/models'
|
||||||
|
|
||||||
export interface UpdateState {
|
export interface UpdateState {
|
||||||
isUpdateAvailable: boolean
|
isUpdateAvailable: boolean
|
||||||
@ -155,6 +158,9 @@ export const useAppUpdater = () => {
|
|||||||
|
|
||||||
let downloaded = 0
|
let downloaded = 0
|
||||||
let contentLength = 0
|
let contentLength = 0
|
||||||
|
await stopAllModels()
|
||||||
|
emit(SystemEvent.KILL_SIDECAR)
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||||
|
|
||||||
await updateState.updateInfo.downloadAndInstall((event) => {
|
await updateState.updateInfo.downloadAndInstall((event) => {
|
||||||
switch (event.event) {
|
switch (event.event) {
|
||||||
|
|||||||
@ -82,9 +82,6 @@ function Hub() {
|
|||||||
[modelId]: !prev[modelId],
|
[modelId]: !prev[modelId],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
|
||||||
fetchModelHub().then(fetchSources)
|
|
||||||
}, [fetchSources])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (search.repo) {
|
if (search.repo) {
|
||||||
@ -150,6 +147,7 @@ function Hub() {
|
|||||||
}, [searchValue, sortedModels, showOnlyDownloaded, llamaProvider?.models])
|
}, [searchValue, sortedModels, showOnlyDownloaded, llamaProvider?.models])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
fetchModelHub()
|
||||||
fetchSources()
|
fetchSources()
|
||||||
}, [fetchSources])
|
}, [fetchSources])
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ import { toast } from 'sonner'
|
|||||||
import { isDev } from '@/lib/utils'
|
import { isDev } from '@/lib/utils'
|
||||||
import { emit } from '@tauri-apps/api/event'
|
import { emit } from '@tauri-apps/api/event'
|
||||||
import { stopAllModels } from '@/services/models'
|
import { stopAllModels } from '@/services/models'
|
||||||
|
import { SystemEvent } from '@/types/events'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export const Route = createFileRoute(route.settings.general as any)({
|
export const Route = createFileRoute(route.settings.general as any)({
|
||||||
@ -149,7 +150,7 @@ function General() {
|
|||||||
if (selectedNewPath) {
|
if (selectedNewPath) {
|
||||||
try {
|
try {
|
||||||
await stopAllModels()
|
await stopAllModels()
|
||||||
emit('kill-sidecar')
|
emit(SystemEvent.KILL_SIDECAR)
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
await relocateJanDataFolder(selectedNewPath)
|
await relocateJanDataFolder(selectedNewPath)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { AppConfiguration, fs } from '@janhq/core'
|
|||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { emit } from '@tauri-apps/api/event'
|
import { emit } from '@tauri-apps/api/event'
|
||||||
import { stopAllModels } from './models'
|
import { stopAllModels } from './models'
|
||||||
|
import { SystemEvent } from '@/types/events'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description This function is used to reset the app to its factory settings.
|
* @description This function is used to reset the app to its factory settings.
|
||||||
@ -11,7 +12,7 @@ import { stopAllModels } from './models'
|
|||||||
export const factoryReset = async () => {
|
export const factoryReset = async () => {
|
||||||
// Kill background processes and remove data folder
|
// Kill background processes and remove data folder
|
||||||
await stopAllModels()
|
await stopAllModels()
|
||||||
emit('kill-sidecar')
|
emit(SystemEvent.KILL_SIDECAR)
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const janDataFolderPath = await getJanDataFolder()
|
const janDataFolderPath = await getJanDataFolder()
|
||||||
if (janDataFolderPath) await fs.rm(janDataFolderPath)
|
if (janDataFolderPath) await fs.rm(janDataFolderPath)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
export enum SystemEvent {
|
export enum SystemEvent {
|
||||||
MCP_UPDATE = 'mcp-update',
|
MCP_UPDATE = 'mcp-update',
|
||||||
|
KILL_SIDECAR = 'kill-sidecar',
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user