dsh-querit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README-zh.md +120 -0
- package/README.md +158 -0
- package/lib/client.d.ts +86 -0
- package/lib/client.js +254 -0
- package/lib/index.d.ts +89 -0
- package/lib/index.js +175 -0
- package/lib/invariant.d.ts +18 -0
- package/lib/invariant.js +20 -0
- package/lib/provider.d.ts +89 -0
- package/lib/provider.js +292 -0
- package/lib/sanitize.d.ts +7 -0
- package/lib/sanitize.js +98 -0
- package/package.json +97 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register Querit-backed search and fetch providers in `ctx.web`.
|
|
3
|
+
* Both providers call the public Querit API (`POST /v1/search`,
|
|
4
|
+
* `POST /v1/contents`) with a Bearer key resolved per operation through the
|
|
5
|
+
* optional `ctx.credentials` seam, falling back to the launching environment.
|
|
6
|
+
* The model-facing `web_search` / `web_fetch` tools keep routing through the
|
|
7
|
+
* seam; this package never registers a tool.
|
|
8
|
+
* @module dsh-querit
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
11
|
+
import z from "@deepseek-ai/schemastery";
|
|
12
|
+
import { type CredentialRef } from "@deepseek-ai/dsh-credentials";
|
|
13
|
+
import { type QueritProviderOptions } from "./provider.js";
|
|
14
|
+
export { COUNTRY_VALUES, LANGUAGE_VALUES, QUERIT_PROVIDER_ID, TIME_RANGE_PATTERN, QueritFetchProvider, QueritSearchProvider, } from "./provider.js";
|
|
15
|
+
export type { QueritClientLike, QueritProviderOptions } from "./provider.js";
|
|
16
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
17
|
+
export declare const name = "web-search-querit";
|
|
18
|
+
/**
|
|
19
|
+
* The web seam both providers register into, plus the registries the optional
|
|
20
|
+
* model-facing `web_fetch` tool needs (reused from `@deepseek-ai/dsh-tool-web`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const inject: string[];
|
|
23
|
+
export declare const DEFAULT_API_KEY_ENV = "QUERIT_API_KEY";
|
|
24
|
+
/** Plugin config (all optional — `apply` fills env-var and constant defaults). */
|
|
25
|
+
export interface Config {
|
|
26
|
+
/** Literal Querit API key; prefer `apiKeyEnv` so no secret enters configuration files. */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
/** Credential reference resolved per operation; defaults to `QUERIT_API_KEY`. */
|
|
29
|
+
apiKeyEnv?: string;
|
|
30
|
+
/** Querit API base URL; `/v1/search` and `/v1/contents` are appended. */
|
|
31
|
+
baseURL?: string;
|
|
32
|
+
/** Per-request timeout in ms. Defaults to 70000. */
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
/** Result count used when the seam passes no `maxResults` bound (1–20). */
|
|
35
|
+
count?: number;
|
|
36
|
+
/** Relative (`d7`, `w2`, `m3`, `y1`) or `YYYY-MM-DDtoYYYY-MM-DD` date range. */
|
|
37
|
+
timeRange?: string;
|
|
38
|
+
/** Country bias; values from the Querit country list. */
|
|
39
|
+
countries?: string[];
|
|
40
|
+
/** Language filter; values from the Querit language list. */
|
|
41
|
+
languages?: string[];
|
|
42
|
+
/** Whitelist hostnames (only these domains return results). */
|
|
43
|
+
includeDomains?: string[];
|
|
44
|
+
/** Blacklist hostnames (these domains never return results). */
|
|
45
|
+
excludeDomains?: string[];
|
|
46
|
+
/** Request sentence-level content excerpts (`needContent`). */
|
|
47
|
+
includeContent?: boolean;
|
|
48
|
+
/** Content chunks per result (1–3). */
|
|
49
|
+
chunksPerDoc?: number;
|
|
50
|
+
/** Format requested from `/v1/contents` for fetch calls. */
|
|
51
|
+
fetchFormat?: "markdown" | "text" | "html";
|
|
52
|
+
/** Per-page crawl timeout in seconds (1–60). */
|
|
53
|
+
fetchCrawlTimeout?: number;
|
|
54
|
+
/** Cap applied to one fetched page's decoded body, in chars. */
|
|
55
|
+
fetchMaxChars?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Register the model-facing `web_fetch` tool (via `dsh-tool-web`'s
|
|
58
|
+
* `applyWebFetchTool`). Defaults to true; set false when another row
|
|
59
|
+
* already registers `web_fetch` in the same scope.
|
|
60
|
+
*/
|
|
61
|
+
fetch?: boolean;
|
|
62
|
+
/** Cooperative tool-call timeout budget (ms) for `web_fetch`. Defaults to 30000. */
|
|
63
|
+
fetchTimeoutMs?: number;
|
|
64
|
+
/** Cap on one `web_fetch` rendered output, in chars. Defaults to 200000. */
|
|
65
|
+
fetchMaxOutputChars?: number;
|
|
66
|
+
}
|
|
67
|
+
export declare const Config: z<Config>;
|
|
68
|
+
/** Settings namespace carrying this provider's endpoint, key reference, and search defaults. */
|
|
69
|
+
export declare const WEB_SEARCH_QUERIT_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
|
|
70
|
+
/**
|
|
71
|
+
* Project one resolved section into the options both providers serve their
|
|
72
|
+
* next operation with. Environment fallbacks stay here rather than in the
|
|
73
|
+
* providers: every value they read is already fully defaulted.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveOptions(ctx: Context, config: Config): QueritProviderOptions;
|
|
76
|
+
/** Register both Querit providers with `ctx.web`, the `web_fetch` tool, and the first-load key check. */
|
|
77
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve the Querit API key for one operation in priority order: literal row
|
|
80
|
+
* `apiKey`, then the credentials service (which itself reads the inherited
|
|
81
|
+
* environment before the managed document), then the launching environment.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveQueritApiKey(ctx: Context, apiKeyEnv: CredentialRef, literalApiKey: string | undefined): Promise<string | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* Reject a resolved settings section this plugin could not act on, for
|
|
86
|
+
* constraints the schema cannot express. Throwing here keeps the settings UI
|
|
87
|
+
* from committing an invalid section while the previous good value stays live.
|
|
88
|
+
*/
|
|
89
|
+
export declare function validateSection(value: Config): void;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
3
|
+
import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
4
|
+
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
5
|
+
import { DEFAULT_FETCH_MAX_OUTPUT_CHARS, DEFAULT_WEB_TOOL_TIMEOUT_MS, applyWebFetchTool, } from "@deepseek-ai/dsh-tool-web";
|
|
6
|
+
import { DEFAULT_REQUEST_TIMEOUT_MS, QUERIT_API_BASE_URL } from "./client.js";
|
|
7
|
+
import { COUNTRY_VALUES, LANGUAGE_VALUES, QueritFetchProvider, QueritSearchProvider, isTimeRange, normalizeDomains, } from "./provider.js";
|
|
8
|
+
export { COUNTRY_VALUES, LANGUAGE_VALUES, QUERIT_PROVIDER_ID, TIME_RANGE_PATTERN, QueritFetchProvider, QueritSearchProvider, } from "./provider.js";
|
|
9
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
10
|
+
export const name = "web-search-querit";
|
|
11
|
+
/**
|
|
12
|
+
* The web seam both providers register into, plus the registries the optional
|
|
13
|
+
* model-facing `web_fetch` tool needs (reused from `@deepseek-ai/dsh-tool-web`).
|
|
14
|
+
*/
|
|
15
|
+
export const inject = ["web", "tools", "systemPrompt"];
|
|
16
|
+
export const DEFAULT_API_KEY_ENV = "QUERIT_API_KEY";
|
|
17
|
+
const BASE_URL_ENV = "QUERIT_BASE_URL";
|
|
18
|
+
export const Config = z.object({
|
|
19
|
+
apiKey: z.string().role("secret"),
|
|
20
|
+
apiKeyEnv: z.string().role("credential-ref").default(DEFAULT_API_KEY_ENV),
|
|
21
|
+
baseURL: z.string(),
|
|
22
|
+
timeoutMs: z.number().step(1).min(1_000).default(DEFAULT_REQUEST_TIMEOUT_MS),
|
|
23
|
+
count: z.number().step(1).min(1).max(20).default(5),
|
|
24
|
+
timeRange: z.string(),
|
|
25
|
+
countries: z.array(z.string()),
|
|
26
|
+
languages: z.array(z.string()),
|
|
27
|
+
includeDomains: z.array(z.string()),
|
|
28
|
+
excludeDomains: z.array(z.string()),
|
|
29
|
+
includeContent: z.boolean().default(false),
|
|
30
|
+
chunksPerDoc: z.number().step(1).min(1).max(3).default(1),
|
|
31
|
+
fetchFormat: z.union([z.const("markdown"), z.const("text"), z.const("html")]).default("markdown"),
|
|
32
|
+
fetchCrawlTimeout: z.number().step(1).min(1).max(60).default(10),
|
|
33
|
+
fetchMaxChars: z.number().step(1).min(256).default(8_000),
|
|
34
|
+
fetch: z.boolean().default(true),
|
|
35
|
+
fetchTimeoutMs: z.number().step(1).min(1_000).default(DEFAULT_WEB_TOOL_TIMEOUT_MS),
|
|
36
|
+
fetchMaxOutputChars: z.number().step(1).min(256).default(DEFAULT_FETCH_MAX_OUTPUT_CHARS),
|
|
37
|
+
});
|
|
38
|
+
/** Settings namespace carrying this provider's endpoint, key reference, and search defaults. */
|
|
39
|
+
export const WEB_SEARCH_QUERIT_SETTINGS_NAMESPACE = settingsNamespace("web-search-querit");
|
|
40
|
+
/**
|
|
41
|
+
* Project one resolved section into the options both providers serve their
|
|
42
|
+
* next operation with. Environment fallbacks stay here rather than in the
|
|
43
|
+
* providers: every value they read is already fully defaulted.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveOptions(ctx, config) {
|
|
46
|
+
const apiKeyEnv = credentialRef(config.apiKeyEnv ?? DEFAULT_API_KEY_ENV);
|
|
47
|
+
const literalApiKey = config.apiKey !== undefined && config.apiKey.trim().length > 0
|
|
48
|
+
? config.apiKey.trim()
|
|
49
|
+
: undefined;
|
|
50
|
+
const environment = launchEnvironmentOf(ctx);
|
|
51
|
+
return {
|
|
52
|
+
...(literalApiKey === undefined ? {} : { apiKey: literalApiKey }),
|
|
53
|
+
resolveApiKey: () => resolveQueritApiKey(ctx, apiKeyEnv, literalApiKey),
|
|
54
|
+
apiKeyEnv,
|
|
55
|
+
baseURL: (config.baseURL ?? environment.get(BASE_URL_ENV)?.value ?? QUERIT_API_BASE_URL).replace(/\/+$/, ""),
|
|
56
|
+
timeoutMs: config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
57
|
+
count: config.count ?? 5,
|
|
58
|
+
timeRange: normalizeTimeRange(config.timeRange),
|
|
59
|
+
countries: normalizeEnumList(config.countries, COUNTRY_VALUES),
|
|
60
|
+
languages: normalizeEnumList(config.languages, LANGUAGE_VALUES),
|
|
61
|
+
includeDomains: normalizeDomains(config.includeDomains),
|
|
62
|
+
excludeDomains: normalizeDomains(config.excludeDomains),
|
|
63
|
+
includeContent: config.includeContent ?? false,
|
|
64
|
+
chunksPerDoc: config.chunksPerDoc ?? 1,
|
|
65
|
+
fetchFormat: config.fetchFormat ?? "markdown",
|
|
66
|
+
fetchCrawlTimeout: config.fetchCrawlTimeout ?? 10,
|
|
67
|
+
fetchMaxChars: config.fetchMaxChars ?? 8_000,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Register both Querit providers with `ctx.web`, the `web_fetch` tool, and the first-load key check. */
|
|
71
|
+
export async function apply(ctx, config) {
|
|
72
|
+
let current = () => config;
|
|
73
|
+
installSettingsSection(ctx, WEB_SEARCH_QUERIT_SETTINGS_NAMESPACE, Config, config, {
|
|
74
|
+
setSource: (source) => {
|
|
75
|
+
current = source;
|
|
76
|
+
},
|
|
77
|
+
onChange: () => { },
|
|
78
|
+
validate: (value) => validateSection(value),
|
|
79
|
+
});
|
|
80
|
+
ctx.web.registerSearchProvider(new QueritSearchProvider(() => resolveOptions(ctx, current())));
|
|
81
|
+
ctx.web.registerFetchProvider(new QueritFetchProvider(() => resolveOptions(ctx, current())));
|
|
82
|
+
// The model-facing web_fetch tool. In this deployment's web app the host
|
|
83
|
+
// `tool-web` row is disabled and the shipped presets keep `fetch: false`, so
|
|
84
|
+
// this package owns the one global registration; `fetch: false` opts out when
|
|
85
|
+
// a preset already registers it.
|
|
86
|
+
if (config.fetch !== false) {
|
|
87
|
+
applyWebFetchTool(ctx, config.fetchTimeoutMs ?? DEFAULT_WEB_TOOL_TIMEOUT_MS, config.fetchMaxOutputChars ?? DEFAULT_FETCH_MAX_OUTPUT_CHARS);
|
|
88
|
+
}
|
|
89
|
+
// First-load configuration prompt: this deployment has no settings page for
|
|
90
|
+
// out-of-tree plugins, so the loudest surface available is the host log. The
|
|
91
|
+
// probe never blocks loading and never throws; a search without a key still
|
|
92
|
+
// fails per call with the actionable WEB_PROVIDER_CREDENTIAL_MISSING message.
|
|
93
|
+
try {
|
|
94
|
+
const apiKeyEnv = credentialRef(config.apiKeyEnv ?? DEFAULT_API_KEY_ENV);
|
|
95
|
+
const literalApiKey = config.apiKey !== undefined && config.apiKey.trim().length > 0
|
|
96
|
+
? config.apiKey.trim()
|
|
97
|
+
: undefined;
|
|
98
|
+
const key = await resolveQueritApiKey(ctx, apiKeyEnv, literalApiKey);
|
|
99
|
+
if (key === undefined) {
|
|
100
|
+
ctx.logger.warn(`web-search-querit: Querit web search is not configured yet — searches will fail until a key is provided. ` +
|
|
101
|
+
`In priority order: export ${apiKeyEnv} in the launching environment, add it to the credentials store ` +
|
|
102
|
+
`($DSH_HOME/.credentials.yaml), or set "apiKey" on the web-search-querit row. See the dsh-querit README for details.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Probe-only; provider calls surface credential failures with full detail.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolve the Querit API key for one operation in priority order: literal row
|
|
111
|
+
* `apiKey`, then the credentials service (which itself reads the inherited
|
|
112
|
+
* environment before the managed document), then the launching environment.
|
|
113
|
+
*/
|
|
114
|
+
export async function resolveQueritApiKey(ctx, apiKeyEnv, literalApiKey) {
|
|
115
|
+
if (literalApiKey !== undefined && literalApiKey.length > 0)
|
|
116
|
+
return literalApiKey;
|
|
117
|
+
const credentials = ctx.get("credentials");
|
|
118
|
+
if (credentials !== undefined)
|
|
119
|
+
return (await credentials.resolve(apiKeyEnv))?.value;
|
|
120
|
+
const ambient = launchEnvironmentOf(ctx).get(apiKeyEnv);
|
|
121
|
+
return ambient !== undefined && ambient.value.length > 0 ? ambient.value : undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reject a resolved settings section this plugin could not act on, for
|
|
125
|
+
* constraints the schema cannot express. Throwing here keeps the settings UI
|
|
126
|
+
* from committing an invalid section while the previous good value stays live.
|
|
127
|
+
*/
|
|
128
|
+
export function validateSection(value) {
|
|
129
|
+
if (value.baseURL !== undefined && !URL.canParse(value.baseURL)) {
|
|
130
|
+
throw new Error("baseURL must be a parseable HTTP(S) URL.");
|
|
131
|
+
}
|
|
132
|
+
if (value.timeRange !== undefined && !isTimeRange(value.timeRange)) {
|
|
133
|
+
throw new Error("timeRange must be a relative range (d7, w2, m3, y1, ...) or YYYY-MM-DDtoYYYY-MM-DD.");
|
|
134
|
+
}
|
|
135
|
+
if (value.countries !== undefined)
|
|
136
|
+
rejectUnknownValues(value.countries, COUNTRY_VALUES, "countries");
|
|
137
|
+
if (value.languages !== undefined)
|
|
138
|
+
rejectUnknownValues(value.languages, LANGUAGE_VALUES, "languages");
|
|
139
|
+
if (value.includeDomains !== undefined)
|
|
140
|
+
rejectInvalidDomains(value.includeDomains, "includeDomains");
|
|
141
|
+
if (value.excludeDomains !== undefined)
|
|
142
|
+
rejectInvalidDomains(value.excludeDomains, "excludeDomains");
|
|
143
|
+
}
|
|
144
|
+
function normalizeTimeRange(value) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return undefined;
|
|
147
|
+
const trimmed = value.trim();
|
|
148
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
149
|
+
}
|
|
150
|
+
function normalizeEnumList(values, allowed) {
|
|
151
|
+
const allowedSet = new Set(allowed);
|
|
152
|
+
const matched = new Set();
|
|
153
|
+
for (const entry of values ?? []) {
|
|
154
|
+
const normalized = entry.trim().toLowerCase();
|
|
155
|
+
if (allowedSet.has(normalized))
|
|
156
|
+
matched.add(normalized);
|
|
157
|
+
}
|
|
158
|
+
return [...matched];
|
|
159
|
+
}
|
|
160
|
+
function rejectUnknownValues(values, allowed, field) {
|
|
161
|
+
const allowedSet = new Set(allowed);
|
|
162
|
+
const unknown = [...new Set(values.map((value) => value.trim().toLowerCase()))].filter((value) => !allowedSet.has(value));
|
|
163
|
+
if (unknown.length > 0) {
|
|
164
|
+
throw new Error(`${field} contains unsupported values: ${unknown.join(", ")}. Allowed: ${allowed.join(", ")}.`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function rejectInvalidDomains(values, field) {
|
|
168
|
+
const invalid = values.filter((value) => {
|
|
169
|
+
const trimmed = value.trim().toLowerCase();
|
|
170
|
+
return trimmed.length === 0 || trimmed.length > 253 || /\s/u.test(trimmed) || !trimmed.includes(".");
|
|
171
|
+
});
|
|
172
|
+
if (invalid.length > 0) {
|
|
173
|
+
throw new Error(`${field} contains invalid hostnames: ${invalid.join(", ")}. Use bare hostnames like github.com.`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `dsh-querit`.
|
|
3
|
+
* @module dsh-querit/invariant
|
|
4
|
+
*/
|
|
5
|
+
/** Cordis companion plugin name. */
|
|
6
|
+
declare const name = "web-querit-invariant";
|
|
7
|
+
/** Service required before the companion can reserve package ownership. */
|
|
8
|
+
declare const inject: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Register this package's invariant companion.
|
|
11
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
12
|
+
*/
|
|
13
|
+
declare const apply: (ctx: {
|
|
14
|
+
invariants: {
|
|
15
|
+
register(packageName: string, installer: () => void): () => void;
|
|
16
|
+
};
|
|
17
|
+
}) => Promise<() => void>;
|
|
18
|
+
export { apply, inject, name };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `dsh-querit`.
|
|
3
|
+
* @module dsh-querit/invariant
|
|
4
|
+
*/
|
|
5
|
+
const PACKAGE_NAME = "dsh-querit";
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
const name = "web-querit-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
const inject = ["invariants"];
|
|
10
|
+
/**
|
|
11
|
+
* No runtime invariant: the package performs stateless upstream calls and owns
|
|
12
|
+
* no durable dispatch event stream to relate to a later authoritative event.
|
|
13
|
+
*/
|
|
14
|
+
const install = () => { };
|
|
15
|
+
/**
|
|
16
|
+
* Register this package's invariant companion.
|
|
17
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
18
|
+
*/
|
|
19
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
20
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Querit-backed `WebSearchProvider` and `WebFetchProvider` for the harness web
|
|
3
|
+
* capability seam (`ctx.web`). Each search resolves the credential for the
|
|
4
|
+
* NEXT operation, honors the caller's `AbortSignal`, maps failures to the
|
|
5
|
+
* seam's `WebError` taxonomy, and never emits provider-generated answer text
|
|
6
|
+
* as trusted `content` — only citeable sources.
|
|
7
|
+
* @module dsh-querit/provider
|
|
8
|
+
*/
|
|
9
|
+
import type { WebFetchProvider, WebFetchResult, WebSearchProvider, WebSearchResult } from "@deepseek-ai/dsh-web";
|
|
10
|
+
import type { CredentialRef } from "@deepseek-ai/dsh-credentials";
|
|
11
|
+
import { type QueritClientOptions, type QueritContentsRequest, type QueritContentsResponse, type QueritSearchRequest, type QueritSearchResponse } from "./client.js";
|
|
12
|
+
/** Stable id both providers register under. */
|
|
13
|
+
export declare const QUERIT_PROVIDER_ID = "querit";
|
|
14
|
+
export declare const COUNTRY_VALUES: readonly ["argentina", "australia", "brazil", "canada", "colombia", "france", "germany", "india", "indonesia", "japan", "mexico", "nigeria", "philippines", "south korea", "spain", "united kingdom", "united states"];
|
|
15
|
+
export declare const LANGUAGE_VALUES: readonly ["english", "japanese", "korean", "german", "french", "spanish", "portuguese"];
|
|
16
|
+
/** `dN`/`wN`/`mN`/`yN` (N ≥ 1) or an inclusive `YYYY-MM-DDtoYYYY-MM-DD` range. */
|
|
17
|
+
export declare const TIME_RANGE_PATTERN: RegExp;
|
|
18
|
+
export interface QueritClientLike {
|
|
19
|
+
search(request: QueritSearchRequest, signal?: AbortSignal): Promise<QueritSearchResponse>;
|
|
20
|
+
contents(request: QueritContentsRequest, signal?: AbortSignal): Promise<QueritContentsResponse>;
|
|
21
|
+
}
|
|
22
|
+
export interface QueritProviderOptions {
|
|
23
|
+
/** Literal Querit API key; when present it wins over `resolveApiKey`. */
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
/** Resolve the current Querit API key for one operation. */
|
|
26
|
+
resolveApiKey?: () => Promise<string | undefined>;
|
|
27
|
+
/** Credential reference named by missing-credential diagnostics. */
|
|
28
|
+
apiKeyEnv?: CredentialRef;
|
|
29
|
+
/** Querit API base URL (`/v1/search` and `/v1/contents` are appended). */
|
|
30
|
+
baseURL: string;
|
|
31
|
+
/** Per-request timeout in ms. */
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
/** Result count used when the seam passes no `maxResults` bound. */
|
|
34
|
+
count: number;
|
|
35
|
+
/** Relative (`d7`, `m3`) or absolute date range filter. */
|
|
36
|
+
timeRange?: string;
|
|
37
|
+
/** Country bias list (validated against `COUNTRY_VALUES`). */
|
|
38
|
+
countries: string[];
|
|
39
|
+
/** Language filter list (validated against `LANGUAGE_VALUES`). */
|
|
40
|
+
languages: string[];
|
|
41
|
+
/** Whitelist hostnames; only these domains return results. */
|
|
42
|
+
includeDomains: string[];
|
|
43
|
+
/** Blacklist hostnames; these domains never return results. */
|
|
44
|
+
excludeDomains: string[];
|
|
45
|
+
/** Request sentence-level content excerpts (`needContent`). */
|
|
46
|
+
includeContent: boolean;
|
|
47
|
+
/** Content chunks per result, 1–3. */
|
|
48
|
+
chunksPerDoc: number;
|
|
49
|
+
/** Format requested from `/v1/contents` for fetch calls. */
|
|
50
|
+
fetchFormat: "markdown" | "text" | "html";
|
|
51
|
+
/** Per-page crawl timeout in seconds, 1–60. */
|
|
52
|
+
fetchCrawlTimeout: number;
|
|
53
|
+
/** Cap applied to one fetched page's decoded body, in chars. */
|
|
54
|
+
fetchMaxChars: number;
|
|
55
|
+
/** Client factory used by tests; defaults to `QueritClient`. */
|
|
56
|
+
clientFactory?: (options: QueritClientOptions) => QueritClientLike;
|
|
57
|
+
}
|
|
58
|
+
export declare function isTimeRange(value: unknown): value is string;
|
|
59
|
+
/**
|
|
60
|
+
* Normalize a configured hostname list: lowercase, drop schemes/ports/paths,
|
|
61
|
+
* and keep at most 100 unique entries. Invalid entries are dropped.
|
|
62
|
+
*/
|
|
63
|
+
export declare function normalizeDomains(values: readonly string[] | undefined): string[];
|
|
64
|
+
export declare function normalizeHostname(value: string): string | undefined;
|
|
65
|
+
export declare class QueritSearchProvider implements WebSearchProvider {
|
|
66
|
+
private readonly resolveOptions;
|
|
67
|
+
readonly id = "querit";
|
|
68
|
+
/**
|
|
69
|
+
* @param resolveOptions - options for the NEXT operation, snapshotted once
|
|
70
|
+
* at each operation's entry so one search never mixes two settings sections.
|
|
71
|
+
*/
|
|
72
|
+
constructor(resolveOptions: () => QueritProviderOptions);
|
|
73
|
+
available(): boolean;
|
|
74
|
+
search(request: {
|
|
75
|
+
query: string;
|
|
76
|
+
maxResults?: number;
|
|
77
|
+
}, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
78
|
+
private client;
|
|
79
|
+
}
|
|
80
|
+
export declare class QueritFetchProvider implements WebFetchProvider {
|
|
81
|
+
private readonly resolveOptions;
|
|
82
|
+
readonly id = "querit";
|
|
83
|
+
constructor(resolveOptions: () => QueritProviderOptions);
|
|
84
|
+
available(): boolean;
|
|
85
|
+
fetch(request: {
|
|
86
|
+
url: string;
|
|
87
|
+
}, signal?: AbortSignal): Promise<WebFetchResult>;
|
|
88
|
+
private client;
|
|
89
|
+
}
|