// Native web_search tool run over the real SearXNG provider. // Mirrors packages/web/tool-web/tests/integration.spec.ts: nothing bypasses // ctx.tools.execute(). Boots the real seam (web-search-searxng), the model // tool (tool-web), and the tool registry from the BUILT bundles. import { Context } from '@deepseek-ai/cordis' import { CallId } from '@deepseek-ai/dsh-llm' import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import ToolRuntime from '@deepseek-ai/dsh-tools' import WebRuntime from '@deepseek-ai/dsh-web' import * as SearXng from '@deepseek-ai/dsh-web-search-searxng' import * as ToolWeb from '@deepseek-ai/dsh-tool-web' const BASE = process.env.SEARXNG_BASE ?? 'http://192.168.31.240:8066' const QUERY = process.env.SEARCH_QUERY ?? 'deepseek harness' const ctx = new Context() await ctx.plugin(SystemPrompt) await ctx.plugin(ToolRuntime) await ctx.plugin(WebRuntime, { searchProvider: SearXng.SEARXNG_PROVIDER_ID }) await ctx.plugin(SearXng, { baseURL: BASE }) const fiber = await ctx.plugin(ToolWeb, { search: true, fetch: false }) const byName = new Map(ctx.tools.schemas().map((s) => [s.name, s])) if (!byName.has('web_search')) { console.error('web_search tool NOT registered') process.exit(1) } console.error(`tool web_search registered; params=${JSON.stringify(byName.get('web_search').parameters)}`) const out = await ctx.tools.execute({ callId: CallId('searxng-native-1'), name: 'web_search', arguments: { query: QUERY }, signal: new AbortController().signal, }) const text = out.content.map((b) => b.type === 'text' ? b.text : '').join('') console.log(JSON.stringify({ isError: out.isError, errorCode: out.error?.info?.code ?? null, contentLength: text.length, preview: text.slice(0, 400), }, null, 2)) await fiber.dispose()