mirror of
https://github.com/hansjone/dsh-search-mcp.git
synced 2026-10-13 08:33:19 +08:00
Fix Desktop search-mcp takeover so web_search uses Bailian.
Drop nested Config.volatile that left the fiber inactive, unwrap the cordis web proxy to pin/wrap search at runtime, and restore deepseek on disable. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d729b03f70
commit
23685cd545
8 changed files with 343 additions and 72 deletions
73
scripts/_validate-config.mjs
Normal file
73
scripts/_validate-config.mjs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Reproduce Desktop Config validation for search-mcp.
|
||||
* Usage: node scripts/_validate-config.mjs
|
||||
*/
|
||||
import { createRequire } from 'node:module'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { join, dirname } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const nm = join(process.env.USERPROFILE || '', '.dsh', 'profiles', 'node_modules')
|
||||
const req = createRequire(join(nm, 'package.json'))
|
||||
const cordisUrl = pathToFileURL(req.resolve('@deepseek-ai/cordis')).href
|
||||
const { Context, Service } = await import(cordisUrl)
|
||||
const mod = await import(pathToFileURL(join(pkgRoot, 'lib', 'index.js')).href)
|
||||
|
||||
class WebRuntime extends Service {
|
||||
searchProviders = new Map()
|
||||
searchProviderId = 'deepseek-official'
|
||||
constructor(ctx) {
|
||||
super(ctx, 'web')
|
||||
}
|
||||
registerSearchProvider(p) {
|
||||
this.searchProviders.set(p.id, p)
|
||||
return () => this.searchProviders.delete(p.id)
|
||||
}
|
||||
async search() {
|
||||
return { used: this.searchProviderId }
|
||||
}
|
||||
}
|
||||
|
||||
function plugin(ctx, config) {
|
||||
mod.apply(ctx, config)
|
||||
}
|
||||
plugin.inject = ['web']
|
||||
plugin.Config = mod.Config
|
||||
|
||||
const root = new Context()
|
||||
try {
|
||||
await root.plugin(WebRuntime)
|
||||
await root.plugin(plugin, {
|
||||
defaultServer: 'bailian',
|
||||
maxResults: 8,
|
||||
searchTimeoutMs: 30000,
|
||||
servers: [{ id: 'bailian', kind: 'bailian', apiKeyEnv: 'DASHSCOPE_API_KEY' }],
|
||||
})
|
||||
const raw = root.web[Symbol.for('cordis.original')]
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
{
|
||||
ok: true,
|
||||
faceId: root.web.searchProviderId,
|
||||
rawId: raw?.searchProviderId,
|
||||
wrapped: !!raw?.search?.__searchMcpWrapped,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
{
|
||||
ok: false,
|
||||
message: String(e?.message || e),
|
||||
stack: String(e?.stack || '').slice(0, 1200),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue