dsh-web-search-enhanced 0.0.1
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 +9 -0
- package/README.md +77 -0
- package/cordis.patch.yml +20 -0
- package/docs/design.zh-CN.md +79 -0
- package/docs/harness-contract.md +30 -0
- package/docs/template-comparison.md +35 -0
- package/lib/client.js +872 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +507 -0
- package/lib/types/client/SearchSettingsCard.d.ts +62 -0
- package/lib/types/client/index.d.ts +11 -0
- package/lib/types/client/locales.d.ts +61 -0
- package/lib/types/index.d.ts +54 -0
- package/lib/types/protocols.d.ts +45 -0
- package/lib/types/provider.d.ts +16 -0
- package/package.json +129 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type LocaleKey } from './locales.ts';
|
|
3
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
4
|
+
interface LocaleNamespaceMap {
|
|
5
|
+
'settings.webSearchEnhanced': LocaleKey;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Browser plugin dependencies. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/** Register the localized card under Settings -> Plugins -> Plugin configuration. */
|
|
11
|
+
export declare function apply(ctx: Context): void;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
readonly title: "Web Search Enhanced";
|
|
3
|
+
readonly description: "Choose the model route and built-in search settings used by web_search.";
|
|
4
|
+
readonly expand: "Expand";
|
|
5
|
+
readonly collapse: "Collapse";
|
|
6
|
+
readonly unsaved: "Unsaved";
|
|
7
|
+
readonly modelMode: "Model route";
|
|
8
|
+
readonly modelModeHint: "Use the fixed search route or follow the model and calling protocol of the current session.";
|
|
9
|
+
readonly configuredMode: "Fixed configuration";
|
|
10
|
+
readonly currentSessionMode: "Current session model";
|
|
11
|
+
readonly protocol: "API protocol";
|
|
12
|
+
readonly protocolHint: "The fixed or fallback route protocol. Follow mode uses the current model protocol when available.";
|
|
13
|
+
readonly anthropic: "Anthropic Messages v1";
|
|
14
|
+
readonly responses: "OpenAI Responses API";
|
|
15
|
+
readonly chat: "OpenAI Chat Completions API";
|
|
16
|
+
readonly baseURL: "Endpoint base URL";
|
|
17
|
+
readonly baseURLHint: "The protocol endpoint suffix is appended only when it is not already present.";
|
|
18
|
+
readonly model: "Model ID";
|
|
19
|
+
readonly modelHint: "The model used by the fixed route and when no session model is available.";
|
|
20
|
+
readonly fallbackModel: "Fallback search model";
|
|
21
|
+
readonly fallbackModelHint: "Optional model used when the current session route cannot be resolved; blank uses Model ID.";
|
|
22
|
+
readonly apiKeyEnv: "API key environment variable";
|
|
23
|
+
readonly apiKeyEnvHint: "The fixed and fallback route reads the API key from this credential reference.";
|
|
24
|
+
readonly apiKey: "API key";
|
|
25
|
+
readonly apiKeyHint: "Enter a new key to store it securely. The field is cleared after saving.";
|
|
26
|
+
readonly credentialConfigured: "A credential is configured for this reference.";
|
|
27
|
+
readonly toolIdentifier: "Internal search identifier";
|
|
28
|
+
readonly toolHintAnthropic: "Anthropic tool type. Leave blank for web_search_20250305.";
|
|
29
|
+
readonly toolHintResponses: "Responses built-in tool type. Leave blank for web_search.";
|
|
30
|
+
readonly toolHintChatOfficial: "Official Chat search models use the fixed web_search_options field.";
|
|
31
|
+
readonly toolHintChatVendor: "Vendor-specific Chat search options field. Leave blank for web_search_options.";
|
|
32
|
+
readonly maxTokens: "Max output tokens";
|
|
33
|
+
readonly maxTokensHint: "Positive integer sent as max_tokens or max_output_tokens for one search request.";
|
|
34
|
+
readonly maxUses: "Max search uses";
|
|
35
|
+
readonly maxUsesHint: "Anthropic-only maximum number of server-tool uses in one request.";
|
|
36
|
+
readonly apiVersion: "Anthropic API version";
|
|
37
|
+
readonly apiVersionHint: "Value sent in the anthropic-version request header.";
|
|
38
|
+
readonly chatSearchMode: "Chat search capability";
|
|
39
|
+
readonly chatSearchModeHint: "Use the official specialized-search-model contract unless the gateway documents a custom options field.";
|
|
40
|
+
readonly chatOfficial: "Official search model";
|
|
41
|
+
readonly chatVendor: "Vendor custom options field";
|
|
42
|
+
readonly searchContextSize: "Search context size";
|
|
43
|
+
readonly searchContextSizeHint: "Optional OpenAI-compatible context budget.";
|
|
44
|
+
readonly contextDefault: "Provider default";
|
|
45
|
+
readonly contextLow: "Low";
|
|
46
|
+
readonly contextMedium: "Medium";
|
|
47
|
+
readonly contextHigh: "High";
|
|
48
|
+
readonly save: "Save";
|
|
49
|
+
readonly saving: "Saving…";
|
|
50
|
+
readonly reset: "Reset to Profile";
|
|
51
|
+
readonly discard: "Discard";
|
|
52
|
+
readonly readOnly: "This connection cannot persist Host Profile settings.";
|
|
53
|
+
readonly failed: "The Host rejected the change. Review the fields and try again.";
|
|
54
|
+
readonly invalidURL: "Enter an absolute HTTP(S) endpoint URL.";
|
|
55
|
+
readonly invalidRequired: "This field must not be blank.";
|
|
56
|
+
readonly invalidCredentialRef: "Use a valid environment-variable name such as WEB_SEARCH_ENHANCED_API.";
|
|
57
|
+
readonly invalidIdentifier: "Use 1–128 identifier characters and start with a letter.";
|
|
58
|
+
readonly invalidInteger: "Enter a positive integer.";
|
|
59
|
+
};
|
|
60
|
+
export type LocaleKey = keyof typeof en;
|
|
61
|
+
export declare const zh: Record<LocaleKey, string>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-protocol web search provider for DeepSeek Harness.
|
|
3
|
+
* @module dsh-web-search-enhanced
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
import z from '@deepseek-ai/schemastery';
|
|
7
|
+
import { EnhancedSearchProvider } from './provider.ts';
|
|
8
|
+
import type { ChatSearchMode, ModelMode, ResolvedConfig, SearchContextSize, SearchProtocol } from './protocols.ts';
|
|
9
|
+
/** Provider id selected by the bundled Web Profile patch. */
|
|
10
|
+
export declare const DEFAULT_PROVIDER_ID = "enhanced-search";
|
|
11
|
+
/** Default Anthropic-compatible search endpoint. */
|
|
12
|
+
export declare const DEFAULT_BASE_URL = "https://api.deepseek.com/anthropic/v1";
|
|
13
|
+
/** Default model aligned with DSH's built-in search provider. */
|
|
14
|
+
export declare const DEFAULT_MODEL = "deepseek-v4-flash";
|
|
15
|
+
/** Credential reference owned by this plugin's fixed and fallback routes. */
|
|
16
|
+
export declare const DEFAULT_API_KEY_ENV = "WEB_SEARCH_ENHANCED_API";
|
|
17
|
+
/** Settings namespace paired with the plugin configuration card. */
|
|
18
|
+
export declare const SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
|
|
19
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
20
|
+
export declare const name = "web-search-enhanced";
|
|
21
|
+
/** The web seam this provider contributes to. */
|
|
22
|
+
export declare const inject: string[];
|
|
23
|
+
/** Host configuration. Values may be overridden live from the Web Profile settings card. */
|
|
24
|
+
export interface Config {
|
|
25
|
+
providerId?: string;
|
|
26
|
+
modelMode?: ModelMode;
|
|
27
|
+
protocol?: SearchProtocol;
|
|
28
|
+
baseURL?: string;
|
|
29
|
+
model?: string;
|
|
30
|
+
fallbackModel?: string;
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
apiKeyEnv?: string;
|
|
33
|
+
apiVersion?: string;
|
|
34
|
+
toolIdentifier?: string;
|
|
35
|
+
maxTokens?: number;
|
|
36
|
+
maxUses?: number;
|
|
37
|
+
chatSearchMode?: ChatSearchMode;
|
|
38
|
+
searchContextSize?: SearchContextSize;
|
|
39
|
+
}
|
|
40
|
+
/** Schema shared by composition defaults and the live settings section. */
|
|
41
|
+
export declare const Config: z<Config>;
|
|
42
|
+
/** Resolve and validate one fixed/fallback route. */
|
|
43
|
+
export declare function resolveConfig(config: Config): ResolvedConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the current Session route at search time. The fixed route is also the
|
|
46
|
+
* fallback route, so a configured fallback remains useful outside an Agent turn.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveRuntimeConfig(ctx: Context, config: Config): Promise<ResolvedConfig>;
|
|
49
|
+
/** Construct a fixed-config provider for tests or custom compositions. */
|
|
50
|
+
export declare function createProvider(config?: Config, fetcher?: typeof fetch): EnhancedSearchProvider;
|
|
51
|
+
/** Register the provider and its live Web Profile settings section. */
|
|
52
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
53
|
+
export { EnhancedSearchProvider } from './provider.ts';
|
|
54
|
+
export type { ChatSearchMode, ModelMode, ResolvedConfig, SearchContextSize, SearchProtocol } from './protocols.ts';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
2
|
+
/** Upstream HTTP envelope used for one server-side web search. */
|
|
3
|
+
export type SearchProtocol = 'anthropic-messages' | 'openai-responses' | 'openai-chat-completions';
|
|
4
|
+
/** Select whether the search route is fixed or follows the active model. */
|
|
5
|
+
export type ModelMode = 'configured' | 'current-session';
|
|
6
|
+
/** Search context size accepted by OpenAI-compatible search endpoints. */
|
|
7
|
+
export type SearchContextSize = 'low' | 'medium' | 'high';
|
|
8
|
+
/** Chat Completions search activation: official search-model semantics or an explicit vendor extension. */
|
|
9
|
+
export type ChatSearchMode = 'search-model' | 'vendor-options';
|
|
10
|
+
/** Fully resolved settings captured at one search operation's entry. */
|
|
11
|
+
export interface ResolvedConfig {
|
|
12
|
+
readonly providerId: string;
|
|
13
|
+
readonly modelMode: ModelMode;
|
|
14
|
+
readonly protocol: SearchProtocol;
|
|
15
|
+
readonly baseURL: string;
|
|
16
|
+
readonly model: string;
|
|
17
|
+
readonly fallbackModel: string | undefined;
|
|
18
|
+
readonly apiKey: string | undefined;
|
|
19
|
+
readonly apiKeyEnv: string;
|
|
20
|
+
readonly apiVersion: string;
|
|
21
|
+
readonly toolIdentifier: string;
|
|
22
|
+
readonly maxTokens: number;
|
|
23
|
+
readonly maxUses: number;
|
|
24
|
+
readonly chatSearchMode: ChatSearchMode;
|
|
25
|
+
readonly searchContextSize: SearchContextSize | undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Secret-bearing HTTP request produced immediately before dispatch. */
|
|
28
|
+
interface WireRequest {
|
|
29
|
+
readonly endpoint: string;
|
|
30
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
31
|
+
readonly body: Readonly<Record<string, unknown>>;
|
|
32
|
+
}
|
|
33
|
+
/** Return the protocol-specific built-in search identifier. */
|
|
34
|
+
export declare function defaultToolIdentifier(protocol: SearchProtocol): string;
|
|
35
|
+
/** Build one protocol request from resolved settings and a model-facing search query. */
|
|
36
|
+
export declare function buildWireRequest(config: ResolvedConfig, query: string, apiKey: string): WireRequest;
|
|
37
|
+
/** Parse a protocol response into DSH's provider-neutral search result. */
|
|
38
|
+
export declare function parseSearchResponse(protocol: SearchProtocol, payload: unknown): WebSearchResult;
|
|
39
|
+
/** Parse Anthropic Messages server-tool result blocks and citation snippets. */
|
|
40
|
+
export declare function parseAnthropicResponse(payload: unknown): WebSearchResult;
|
|
41
|
+
/** Parse Responses web_search_call items, message text, and URL annotations. */
|
|
42
|
+
export declare function parseResponsesResponse(payload: unknown): WebSearchResult;
|
|
43
|
+
/** Parse Chat Completions message text and URL citation annotations. */
|
|
44
|
+
export declare function parseChatCompletionsResponse(payload: unknown): WebSearchResult;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WebSearchProvider, WebSearchRequest, WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
2
|
+
import type { ResolvedConfig } from './protocols.ts';
|
|
3
|
+
/** Multi-protocol search provider. One resolved settings snapshot serves each operation. */
|
|
4
|
+
export declare class EnhancedSearchProvider implements WebSearchProvider {
|
|
5
|
+
private readonly resolveConfig;
|
|
6
|
+
private readonly fetcher;
|
|
7
|
+
private readonly resolveApiKey;
|
|
8
|
+
/** Stable provider id selected by ctx.web. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** Create a provider backed by a dynamic settings resolver. */
|
|
11
|
+
constructor(resolveConfig: () => ResolvedConfig, fetcher?: typeof fetch, resolveApiKey?: (config: ResolvedConfig) => Promise<string | undefined>);
|
|
12
|
+
/** Report whether local configuration can attempt a request without network I/O. */
|
|
13
|
+
available(): boolean;
|
|
14
|
+
/** Execute one server-side web search and normalize its citations. */
|
|
15
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-web-search-enhanced",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Multi-protocol web_search provider for DeepSeek Harness",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "^22.19.0 || >=24.0.0",
|
|
9
|
+
"dsh": ">=0.1.1-rc.2"
|
|
10
|
+
},
|
|
11
|
+
"main": "./lib/index.js",
|
|
12
|
+
"types": "./lib/types/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./lib/types/index.d.ts",
|
|
16
|
+
"default": "./lib/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./client": {
|
|
19
|
+
"types": "./lib/types/client/index.d.ts",
|
|
20
|
+
"default": "./lib/client.js"
|
|
21
|
+
},
|
|
22
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/index.js",
|
|
27
|
+
"lib/client.js",
|
|
28
|
+
"lib/client.js.map",
|
|
29
|
+
"lib/types/**/*.d.ts",
|
|
30
|
+
"cordis.patch.yml",
|
|
31
|
+
"docs",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dsh": {
|
|
39
|
+
"bundle": {
|
|
40
|
+
"patch": "./cordis.patch.yml"
|
|
41
|
+
},
|
|
42
|
+
"client": {
|
|
43
|
+
"platform": "web",
|
|
44
|
+
"inject": [
|
|
45
|
+
"@deepseek-ai/dsh-client-locale",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins",
|
|
49
|
+
"@deepseek-ai/dsh-api-remotes"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
55
|
+
"@deepseek-ai/dsh-credentials": "^0.1.1-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-launch-environment": "^0.1.1-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-web": "^0.1.1-rc.2",
|
|
66
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
67
|
+
"react": "^18.2.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"@deepseek-ai/dsh-client-locale": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@deepseek-ai/dsh-client-runtime": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-renderer": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@deepseek-ai/dsh-client-ui-settings": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"@deepseek-ai/dsh-client-ui-slots": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"react": {
|
|
89
|
+
"optional": true
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
94
|
+
"@deepseek-ai/dsh-credentials": "^0.1.1-rc.2",
|
|
95
|
+
"@deepseek-ai/dsh-launch-environment": "^0.1.1-rc.2",
|
|
96
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
97
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2",
|
|
99
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
|
|
100
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
|
|
101
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.2",
|
|
102
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
|
|
103
|
+
"@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
|
|
104
|
+
"@deepseek-ai/dsh-web": "^0.1.1-rc.2",
|
|
105
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
106
|
+
"@types/node": "^22.20.0",
|
|
107
|
+
"@types/react": "~18.3.1",
|
|
108
|
+
"react": "^18.2.0",
|
|
109
|
+
"tsdown": "^0.22.2",
|
|
110
|
+
"typescript": "^6.0.3",
|
|
111
|
+
"vitest": "^4.1.8"
|
|
112
|
+
},
|
|
113
|
+
"keywords": [
|
|
114
|
+
"deepseek-harness",
|
|
115
|
+
"dsh-plugin",
|
|
116
|
+
"web-search",
|
|
117
|
+
"anthropic",
|
|
118
|
+
"openai"
|
|
119
|
+
],
|
|
120
|
+
"scripts": {
|
|
121
|
+
"clean": "node scripts/clean.mjs",
|
|
122
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
123
|
+
"test": "vitest run",
|
|
124
|
+
"test:watch": "vitest",
|
|
125
|
+
"build": "pnpm run clean && tsc -p tsconfig.build.json && tsdown --config tsdown.config.ts",
|
|
126
|
+
"check": "pnpm run typecheck && pnpm run test && pnpm run build && pnpm run verify:package",
|
|
127
|
+
"verify:package": "node scripts/verify-package.mjs"
|
|
128
|
+
}
|
|
129
|
+
}
|