dsh-all-search 0.1.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.md +63 -0
- package/README.zh.md +63 -0
- package/cordis.patch.yml +11 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +102 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexandre@AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/readme/hero.svg" alt="dsh-all-search — AnySearch web search for DeepSeek Harness" width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# dsh-all-search
|
|
6
|
+
|
|
7
|
+
Adds an **AnySearch** web-search provider to DeepSeek Harness, registered into `ctx.web`. AnySearch is a single MCP gateway that aggregates exa / tavily / firecrawl / context7 behind **one API key**.
|
|
8
|
+
|
|
9
|
+
> Port of [pi-all-search](https://github.com/RealAlexandreAI/pi-all-search).
|
|
10
|
+
|
|
11
|
+
[English](README.md) · [中文](README.zh.md)
|
|
12
|
+
|
|
13
|
+
## Why
|
|
14
|
+
|
|
15
|
+
dsh ships Exa / Perplexity / DeepSeek search. This plugin adds AnySearch: one key, many backends, no per-backend credentials.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
dsh plugin add dsh-all-search
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The provider registers as `anysearch` on `ctx.web` — the built-in `web_search` tool picks it up alongside the stock providers.
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
- id: search
|
|
27
|
+
name: dsh-all-search
|
|
28
|
+
config:
|
|
29
|
+
api_key_ref: ANYSEARCH_API_KEY # env var name — recommended
|
|
30
|
+
# api_key: <direct value>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| key | required | meaning |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `api_key_ref` | * | env-var name of the AnySearch key (via `ctx.credentials`) |
|
|
36
|
+
| `api_key` | * | direct key value (fallback) |
|
|
37
|
+
| `base_url` | – | MCP endpoint override |
|
|
38
|
+
|
|
39
|
+
\* one of the two key keys. Without a key the provider reports `available() = false` and the seam skips it.
|
|
40
|
+
|
|
41
|
+
## Privacy
|
|
42
|
+
|
|
43
|
+
- The key is resolved per operation via `ctx.credentials` — never logged.
|
|
44
|
+
- Only your query and result count go to the AnySearch gateway.
|
|
45
|
+
|
|
46
|
+
## Development
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
npm run typecheck
|
|
51
|
+
npm test # result parsing / maxResults / HTTP errors
|
|
52
|
+
npm run build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Live search test:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
ANYSEARCH_API_KEY=<key> node --import tsx tests/real/real-search.mjs
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/readme/hero.zh.svg" alt="dsh-all-search —— 给 DeepSeek Harness 加 AnySearch 搜索" width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# dsh-all-search
|
|
6
|
+
|
|
7
|
+
给 DeepSeek Harness 加一个 **AnySearch** 搜索 provider,注册进 `ctx.web`。AnySearch 是单 MCP 网关,一把 API key 聚合 exa / tavily / firecrawl / context7 等多家搜索。
|
|
8
|
+
|
|
9
|
+
> 由 [pi-all-search](https://github.com/RealAlexandreAI/pi-all-search) 移植。
|
|
10
|
+
|
|
11
|
+
[English](README.md) · [中文](README.zh.md)
|
|
12
|
+
|
|
13
|
+
## 为什么需要它
|
|
14
|
+
|
|
15
|
+
dsh 自带 Exa / Perplexity / DeepSeek 搜索。本插件补 AnySearch:一把 key 多个后端,不用为每家单独配凭据。
|
|
16
|
+
|
|
17
|
+
## 快速开始
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
dsh plugin add dsh-all-search
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
provider 以 `anysearch` 注册到 `ctx.web`,内置的 `web_search` 工具会自动识别,与自带 provider 并存。
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
- id: search
|
|
27
|
+
name: dsh-all-search
|
|
28
|
+
config:
|
|
29
|
+
api_key_ref: ANYSEARCH_API_KEY # 推荐:环境变量名
|
|
30
|
+
# api_key: <直接填 key>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| 键 | 必填 | 说明 |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `api_key_ref` | * | AnySearch key 的环境变量名(经 `ctx.credentials` 解析) |
|
|
36
|
+
| `api_key` | * | 直接填 key(备用) |
|
|
37
|
+
| `base_url` | – | MCP 端点覆盖 |
|
|
38
|
+
|
|
39
|
+
\* 两个 key 键填其一。没有 key 时 provider `available() = false`,seam 自动跳过。
|
|
40
|
+
|
|
41
|
+
## 隐私
|
|
42
|
+
|
|
43
|
+
- key 每次搜索经 `ctx.credentials` 解析——不写日志
|
|
44
|
+
- 只向 AnySearch 网关发送查询词和结果数量
|
|
45
|
+
|
|
46
|
+
## 开发
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install
|
|
50
|
+
npm run typecheck
|
|
51
|
+
npm test # 结果解析 / maxResults / HTTP 错误
|
|
52
|
+
npm run build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
真实搜索测试:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
ANYSEARCH_API_KEY=<key> node --import tsx tests/real/real-search.mjs
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Plugin bundle for dsh-all-search.
|
|
2
|
+
# Registers the AnySearch search provider into ctx.web. Configure the API key
|
|
3
|
+
# via a credential ref (recommended) or a direct value:
|
|
4
|
+
#
|
|
5
|
+
# - id: search
|
|
6
|
+
# name: 'dsh-all-search'
|
|
7
|
+
# config:
|
|
8
|
+
# api_key_ref: ANYSEARCH_API_KEY # env var name (recommended)
|
|
9
|
+
- insert:
|
|
10
|
+
- id: search
|
|
11
|
+
name: 'dsh-all-search'
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
import type { WebSearchProvider, WebSearchRequest, WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
4
|
+
export declare const name = "dsh-search";
|
|
5
|
+
export declare const inject: string[];
|
|
6
|
+
export interface Config {
|
|
7
|
+
/** Env-var name of the AnySearch API key (recommended; resolved via ctx.credentials). */
|
|
8
|
+
api_key_ref?: string;
|
|
9
|
+
/** Direct API key value (fallback when no ref is set). */
|
|
10
|
+
api_key?: string;
|
|
11
|
+
/** AnySearch MCP endpoint override. */
|
|
12
|
+
base_url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const Config: z<Config>;
|
|
15
|
+
export declare class AnysearchProvider implements WebSearchProvider {
|
|
16
|
+
private readonly apiKey;
|
|
17
|
+
private readonly baseUrl;
|
|
18
|
+
readonly id = "anysearch";
|
|
19
|
+
constructor(apiKey: string, baseUrl?: string);
|
|
20
|
+
/** Cheap local check — no network. */
|
|
21
|
+
available(): boolean;
|
|
22
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
23
|
+
private parseResults;
|
|
24
|
+
}
|
|
25
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// dsh-search — DeepSeek Harness (Cordis) plugin.
|
|
2
|
+
//
|
|
3
|
+
// Registers an AnySearch-backed WebSearchProvider with ctx.web. AnySearch is
|
|
4
|
+
// a single MCP gateway that aggregates exa / tavily / firecrawl / context7
|
|
5
|
+
// behind one API key, so one provider covers many backends.
|
|
6
|
+
//
|
|
7
|
+
// Ported from pi-all-search (providers/anysearch.ts) with the pi UI/typebox
|
|
8
|
+
// surface replaced by the dsh WebSearchProvider seam.
|
|
9
|
+
//
|
|
10
|
+
// Privacy: the API key is read via ctx.credentials from an env-var reference
|
|
11
|
+
// (recommended) or a direct config value; it is never logged.
|
|
12
|
+
import z from '@deepseek-ai/schemastery';
|
|
13
|
+
import { credentialRef } from '@deepseek-ai/dsh-credentials';
|
|
14
|
+
export const name = 'dsh-search';
|
|
15
|
+
export const inject = ['web', 'credentials'];
|
|
16
|
+
export const Config = z.object({
|
|
17
|
+
api_key_ref: z.string().description('Env-var name of the AnySearch API key (recommended)'),
|
|
18
|
+
api_key: z.string().description('Direct API key value (fallback when no ref is set)'),
|
|
19
|
+
base_url: z.string().description('AnySearch MCP endpoint override (default https://api.anysearch.com/mcp)'),
|
|
20
|
+
});
|
|
21
|
+
const DEFAULT_BASE_URL = 'https://api.anysearch.com/mcp';
|
|
22
|
+
export class AnysearchProvider {
|
|
23
|
+
apiKey;
|
|
24
|
+
baseUrl;
|
|
25
|
+
id = 'anysearch';
|
|
26
|
+
constructor(apiKey, baseUrl = DEFAULT_BASE_URL) {
|
|
27
|
+
this.apiKey = apiKey;
|
|
28
|
+
this.baseUrl = baseUrl;
|
|
29
|
+
}
|
|
30
|
+
/** Cheap local check — no network. */
|
|
31
|
+
available() {
|
|
32
|
+
return Boolean(this.apiKey);
|
|
33
|
+
}
|
|
34
|
+
async search(request, signal) {
|
|
35
|
+
const resp = await fetch(this.baseUrl, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
40
|
+
},
|
|
41
|
+
signal,
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
jsonrpc: '2.0',
|
|
44
|
+
id: 1,
|
|
45
|
+
method: 'tools/call',
|
|
46
|
+
params: { name: 'search', arguments: { query: request.query, max_results: request.maxResults ?? 5 } },
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
if (!resp.ok)
|
|
50
|
+
throw new Error(`AnySearch HTTP ${resp.status}`);
|
|
51
|
+
const data = (await resp.json());
|
|
52
|
+
const text = data.result?.content?.[0]?.text ?? '';
|
|
53
|
+
const sources = this.parseResults(text);
|
|
54
|
+
const truncated = request.maxResults !== undefined && sources.length > request.maxResults;
|
|
55
|
+
return {
|
|
56
|
+
sources: truncated ? sources.slice(0, request.maxResults) : sources,
|
|
57
|
+
truncated,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
parseResults(text) {
|
|
61
|
+
const results = [];
|
|
62
|
+
const sections = text.split(/^### \d+\. /m).slice(1);
|
|
63
|
+
for (const section of sections) {
|
|
64
|
+
const lines = section.trim().split('\n');
|
|
65
|
+
const title = lines[0]?.trim() ?? '';
|
|
66
|
+
const urlLine = lines.find((l) => l.startsWith('- **URL**:'));
|
|
67
|
+
const url = urlLine?.replace('- **URL**: ', '').replace(/\*\*/g, '').trim() ?? '';
|
|
68
|
+
const snippet = lines
|
|
69
|
+
.filter((l) => !l.startsWith('- **URL**:') && l.trim() && !l.startsWith('#'))
|
|
70
|
+
.join(' ')
|
|
71
|
+
.slice(0, 300);
|
|
72
|
+
if (title && url)
|
|
73
|
+
results.push({ url, title, snippet });
|
|
74
|
+
}
|
|
75
|
+
return results;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function apply(ctx, config) {
|
|
79
|
+
// Credentials resolve per operation (never at boot): a changed env var
|
|
80
|
+
// reaches the next search without a restart, and the key never lands in
|
|
81
|
+
// config/logs. `available()` is a cheap local check — no network.
|
|
82
|
+
const wrapper = {
|
|
83
|
+
id: 'anysearch',
|
|
84
|
+
available: () => Boolean(config.api_key_ref ?? config.api_key),
|
|
85
|
+
async search(request, signal) {
|
|
86
|
+
let key = config.api_key;
|
|
87
|
+
if (config.api_key_ref) {
|
|
88
|
+
try {
|
|
89
|
+
const resolved = await ctx.credentials.resolve(credentialRef(config.api_key_ref));
|
|
90
|
+
key = resolved.value;
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
throw new Error(`api_key_ref '${config.api_key_ref}' unresolvable: ${String(e).slice(0, 120)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!key)
|
|
97
|
+
throw new Error('AnySearch API key not configured (set api_key_ref or api_key)');
|
|
98
|
+
return new AnysearchProvider(key, config.base_url ?? DEFAULT_BASE_URL).search(request, signal);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
ctx.web.registerSearchProvider(wrapper);
|
|
102
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-all-search",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DeepSeek Harness plugin: AnySearch-backed web search provider (aggregates exa/tavily/firecrawl via one MCP gateway) registered into ctx.web.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"cordis.patch.yml",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"test": "node --import tsx --test tests/*.mjs",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"dsh",
|
|
23
|
+
"dsh-plugin",
|
|
24
|
+
"deepseek-harness",
|
|
25
|
+
"cordis",
|
|
26
|
+
"anysearch",
|
|
27
|
+
"search"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
32
|
+
"@deepseek-ai/dsh-credentials": "^0.0.1-rc.1",
|
|
33
|
+
"@deepseek-ai/dsh-web": "^0.0.1-rc.1",
|
|
34
|
+
"@deepseek-ai/schemastery": "^3.18.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.0.0",
|
|
38
|
+
"tsx": "^4.19.0",
|
|
39
|
+
"typescript": "^5.5.0"
|
|
40
|
+
},
|
|
41
|
+
"dsh": {
|
|
42
|
+
"bundle": {
|
|
43
|
+
"patch": "./cordis.patch.yml"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/RealAlexandreAI/dsh-all-search"
|
|
49
|
+
}
|
|
50
|
+
}
|