Some checks failed
CI / node 22.19 (push) Has been skipped
CI / node 26 (push) Has been skipped
CI / python 3.10 / keyless SDK (push) Has been skipped
CI / python runtime / release-shaped Linux x64 (push) Has been skipped
CI / windows node 24 / wine blocking (push) Has been skipped
CI / wine apt cache (push) Successful in 58s
CI / serial / linux (push) Has been skipped
Deploy documentation / build (push) Failing after 2m46s
Deploy documentation / deploy (push) Has been skipped
E2E (real DeepSeek API) / e2e (push) Failing after 1m18s
Sandbox / sandbox e2e (bwrap, ubuntu-latest) (push) Failing after 1m18s
Landlock Run / Matrix (push) Successful in 13s
Release (vendor) / Pack npm tarballs (push) Failing after 3m43s
Release (dsh) / Pack npm tarballs (push) Failing after 1m53s
Sandbox / sandbox e2e (landlock, ubuntu-24.04) (push) Failing after 1m51s
Release (vendor) / Publish to npm (push) Has been skipped
Release (dsh) / Publish to npm (push) Has been skipped
CI / node 24 / static (push) Has been cancelled
CI / node 24 / coverage (push) Has been cancelled
CI / node 24 / snapshots and artifacts (push) Has been cancelled
CI / windows node 24 / native complete (push) Has been cancelled
CI / serial / linux (self-hosted standby) (push) Has been cancelled
CI / serial / macos (push) Has been cancelled
CI / serial / windows (self-hosted standby) (push) Has been cancelled
CI / larger-runner-benchmark (16, linux, dsh-ubuntu-24-04-16core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (16, windows, dsh-windows-2025-16core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (32, linux, dsh-ubuntu-24-04-32core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (32, windows, dsh-windows-2025-32core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (4, linux, dsh-ubuntu-24-04-4core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (4, windows, dsh-windows-2025-4core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (64, linux, dsh-ubuntu-24-04-64core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (64, windows, dsh-windows-2025-64core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (8, linux, dsh-ubuntu-24-04-8core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (8, windows, dsh-windows-2025-8core, production-site) (push) Has been cancelled
CI / larger-runner-benchmark (96, linux, dsh-ubuntu-24-04-96core, typecheck) (push) Has been cancelled
CI / larger-runner-benchmark (96, windows, dsh-windows-2025-96core, production-site) (push) Has been cancelled
CI / consolidated-runner-benchmark (16, linux, dsh-ubuntu-24-04-16core, 16) (push) Has been cancelled
CI / consolidated-runner-benchmark (16, windows, dsh-windows-2025-16core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (32, linux, dsh-ubuntu-24-04-32core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (32, windows, dsh-windows-2025-32core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (4, linux, dsh-ubuntu-24-04-4core, 4) (push) Has been cancelled
CI / consolidated-runner-benchmark (4, windows, dsh-windows-2025-4core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (64, linux, dsh-ubuntu-24-04-64core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (64, windows, dsh-windows-2025-64core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (8, linux, dsh-ubuntu-24-04-8core, 8) (push) Has been cancelled
CI / consolidated-runner-benchmark (8, windows, dsh-windows-2025-8core, 2) (push) Has been cancelled
CI / consolidated-runner-benchmark (96, linux, dsh-ubuntu-24-04-96core, 32) (push) Has been cancelled
CI / consolidated-runner-benchmark (96, windows, dsh-windows-2025-96core, 2) (push) Has been cancelled
CI / all checks passed (push) Has been cancelled
Sandbox / sandbox e2e (seatbelt, macos-latest) (push) Has been cancelled
Sandbox / sandbox e2e (landlock, ubuntu-24.04-arm) (push) Has been cancelled
Landlock Run / ${{ matrix.platform }} (push) Has been cancelled
Landlock Run / darwin (no platform package — degradation proof) (push) Has been cancelled
80 lines
3.2 KiB
TypeScript
80 lines
3.2 KiB
TypeScript
/**
|
|
* `@deepseek-ai/dsh-web-search-searxng`: registers a SearXNG-backed
|
|
* `WebSearchProvider` with `ctx.web`. A function/namespace plugin (NOT a
|
|
* default-export service): a search provider does not own the `ctx.web` key —
|
|
* it registers INTO the seam's provider registry, exactly as
|
|
* `@deepseek-ai/dsh-web-search-exa` does. The key is owned by
|
|
* `@deepseek-ai/dsh-web`.
|
|
*
|
|
* @module @deepseek-ai/dsh-web-search-searxng
|
|
*/
|
|
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import z from '@deepseek-ai/schemastery'
|
|
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
import type {} from '@deepseek-ai/dsh-web'
|
|
import { SearXngSearchProvider } from './provider.ts'
|
|
|
|
export {
|
|
SEARXNG_DEFAULT_LANGUAGE,
|
|
SEARXNG_NO_TIME_RANGE,
|
|
SEARXNG_PROVIDER_ID,
|
|
SEARXNG_TIME_RANGES,
|
|
SearXngSearchProvider,
|
|
} from './provider.ts'
|
|
export type {
|
|
SearXngSearchProviderOptions,
|
|
SearXngSearchProviderSource,
|
|
SearXngTimeRange,
|
|
} from './provider.ts'
|
|
|
|
/** Cordis plugin name used by loader diagnostics. */
|
|
export const name = 'web-search-searxng'
|
|
|
|
/** The web seam this provider registers into. */
|
|
export const inject = ['web']
|
|
|
|
/** Plugin config. `baseURL` is optional in the schema so an omitted value
|
|
* surfaces as an unavailable provider (the seam's `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`)
|
|
* rather than failing boot; `apply` fills constant defaults. */
|
|
export interface Config {
|
|
/** SearXNG instance base; `/search` is appended. Empty/unparseable makes the provider unavailable. */
|
|
baseURL?: string
|
|
/** SearXNG `language` to request. Defaults to `auto`. */
|
|
language?: string
|
|
/** SearXNG `time_range` recency filter. Omitted = no filter. */
|
|
timeRange?: 'day' | 'week' | 'month' | 'year'
|
|
}
|
|
|
|
export const Config: z<Config> = z.object({
|
|
baseURL: z.string(),
|
|
language: z.string(),
|
|
timeRange: z.union(['day', 'week', 'month', 'year'] as const),
|
|
})
|
|
|
|
/** Settings namespace carrying the SearXNG instance and any per-search filters. */
|
|
export const SEARXNG_SETTINGS_NAMESPACE = settingsNamespace('web-search-searxng')
|
|
|
|
/** Register the SearXNG search provider with `ctx.web`, reading the live section
|
|
* per search so an in-session settings edit applies without re-registration. */
|
|
export function apply(ctx: Context, config: Config): void {
|
|
let current: () => Config = () => config
|
|
installSettingsSection(ctx, SEARXNG_SETTINGS_NAMESPACE, Config, config, {
|
|
setSource: (source) => {
|
|
current = source
|
|
},
|
|
// The registration carries no resolved value: the provider projects the
|
|
// section per search, so a committed change needs no re-registration.
|
|
onChange: () => {},
|
|
})
|
|
ctx.web.registerSearchProvider(new SearXngSearchProvider(() => ({
|
|
// SearXNG exposes no uniform public endpoint and the product requires
|
|
// evidence over an unsupported default, so `baseURL` has no constant
|
|
// fallback: an omitted value surfaces as an unavailable provider (the
|
|
// seam's `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`), not a silent endpoint.
|
|
baseURL: current().baseURL ?? '',
|
|
...current().language !== undefined ? { language: current().language } : {},
|
|
...current().timeRange !== undefined ? { timeRange: current().timeRange } : {},
|
|
})))
|
|
}
|