@jiangyuan1209/yuan-claw 0.1.3 → 0.1.4
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/README.md +11 -28
- package/dist/config/init-user-config.js +1 -2
- package/dist/config/load-config.js +1 -2
- package/dist/tools/registry.js +7 -10
- package/dist/tools/web/index.js +1 -1
- package/dist/tools/web/search-providers/baidu.js +36 -0
- package/package.json +1 -1
- package/.env.example +0 -28
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ yuan-claw
|
|
|
124
124
|
"MODEL_API_KEY": "your_api_key",
|
|
125
125
|
"MODEL_BASE_URL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
126
126
|
"MODEL_NAME": "qwen3-max-2026-01-23",
|
|
127
|
-
"
|
|
127
|
+
"BAIDU_API_KEY": "your_baidu_search_api_key",
|
|
128
128
|
"HTTP_PROXY": "http://127.0.0.1:33210",
|
|
129
129
|
"HTTPS_PROXY": "http://127.0.0.1:33210"
|
|
130
130
|
}
|
|
@@ -144,7 +144,7 @@ yuan-claw
|
|
|
144
144
|
|
|
145
145
|
```json
|
|
146
146
|
{
|
|
147
|
-
"
|
|
147
|
+
"BAIDU_API_KEY": "your_baidu_search_api_key"
|
|
148
148
|
}
|
|
149
149
|
```
|
|
150
150
|
|
|
@@ -197,7 +197,7 @@ yuan-claw "帮我搜索 OpenAI 最新消息"
|
|
|
197
197
|
- `OPENAI_API_KEY`
|
|
198
198
|
- `OPENAI_BASE_URL`
|
|
199
199
|
- `OPENAI_MODEL`
|
|
200
|
-
- `
|
|
200
|
+
- `BAIDU_API_KEY`
|
|
201
201
|
- `HTTP_PROXY`
|
|
202
202
|
- `HTTPS_PROXY`
|
|
203
203
|
- `http_proxy`
|
|
@@ -222,7 +222,7 @@ yuan-claw "帮我搜索 OpenAI 最新消息"
|
|
|
222
222
|
"MODEL_API_KEY": "your_dashscope_api_key",
|
|
223
223
|
"MODEL_BASE_URL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
224
224
|
"MODEL_NAME": "qwen3-max-2026-01-23",
|
|
225
|
-
"
|
|
225
|
+
"BAIDU_API_KEY": "your_baidu_search_api_key",
|
|
226
226
|
"HTTP_PROXY": "http://127.0.0.1:33210",
|
|
227
227
|
"HTTPS_PROXY": "http://127.0.0.1:33210"
|
|
228
228
|
}
|
|
@@ -230,28 +230,11 @@ yuan-claw "帮我搜索 OpenAI 最新消息"
|
|
|
230
230
|
|
|
231
231
|
---
|
|
232
232
|
|
|
233
|
-
## Environment Variables
|
|
233
|
+
## Environment Variables(已废弃)
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
项目已不再通过 `.env` 加载配置,所有配置均通过 `~/.yuan-claw/settings.json` 管理。
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
MODEL_API_KEY=
|
|
239
|
-
MODEL_BASE_URL=
|
|
240
|
-
MODEL_NAME=
|
|
241
|
-
|
|
242
|
-
BRAVE_SEARCH_API_KEY=
|
|
243
|
-
|
|
244
|
-
HTTP_PROXY=
|
|
245
|
-
HTTPS_PROXY=
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
也支持 OpenAI 风格变量名:
|
|
249
|
-
|
|
250
|
-
```env
|
|
251
|
-
OPENAI_API_KEY=
|
|
252
|
-
OPENAI_BASE_URL=
|
|
253
|
-
OPENAI_MODEL=
|
|
254
|
-
```
|
|
237
|
+
如果你仍习惯使用 `.env`,可以自行在项目中通过 `dotenv` 加载,但不再推荐。
|
|
255
238
|
|
|
256
239
|
> 普通 CLI 用户更推荐使用:
|
|
257
240
|
>
|
|
@@ -362,7 +345,7 @@ npm run start
|
|
|
362
345
|
|
|
363
346
|
```json
|
|
364
347
|
{
|
|
365
|
-
"
|
|
348
|
+
"BAIDU_API_KEY": "your_baidu_search_api_key"
|
|
366
349
|
}
|
|
367
350
|
```
|
|
368
351
|
|
|
@@ -587,13 +570,13 @@ yuan-claw
|
|
|
587
570
|
|
|
588
571
|
---
|
|
589
572
|
|
|
590
|
-
### `web_search disabled: set
|
|
573
|
+
### `web_search disabled: set BAIDU_API_KEY`
|
|
591
574
|
|
|
592
|
-
|
|
575
|
+
说明未配置百度搜索 API Key。请添加:
|
|
593
576
|
|
|
594
577
|
```json
|
|
595
578
|
{
|
|
596
|
-
"
|
|
579
|
+
"BAIDU_API_KEY": "your_baidu_search_api_key"
|
|
597
580
|
}
|
|
598
581
|
```
|
|
599
582
|
|
|
@@ -8,8 +8,7 @@ const userSettingsSchema = z.object({
|
|
|
8
8
|
OPENAI_API_KEY: z.string().optional(),
|
|
9
9
|
OPENAI_BASE_URL: z.string().optional(),
|
|
10
10
|
OPENAI_MODEL: z.string().optional(),
|
|
11
|
-
|
|
12
|
-
BRAVE_API_KEY: z.string().optional(),
|
|
11
|
+
BAIDU_API_KEY: z.string().optional(),
|
|
13
12
|
HTTP_PROXY: z.string().optional(),
|
|
14
13
|
HTTPS_PROXY: z.string().optional(),
|
|
15
14
|
http_proxy: z.string().optional(),
|
package/dist/tools/registry.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createGrepTextTool } from "./file/grep-text.js";
|
|
|
5
5
|
import { createShellExecTool } from "./shell/shell-exec.js";
|
|
6
6
|
import { createGitStatusTool } from "./git/git-status.js";
|
|
7
7
|
import { createGitDiffTool } from "./git/git-diff.js";
|
|
8
|
-
import { createHttpFetchTool, createWebSearchTool, createExtractReadableTextTool,
|
|
8
|
+
import { createHttpFetchTool, createWebSearchTool, createExtractReadableTextTool, createBaiduSearchProvider, } from "./web/index.js";
|
|
9
9
|
export function createToolRegistry(options) {
|
|
10
10
|
const tools = [
|
|
11
11
|
createReadFileTool({ workspaceRoot: options.workspaceRoot }),
|
|
@@ -19,20 +19,17 @@ export function createToolRegistry(options) {
|
|
|
19
19
|
createExtractReadableTextTool(),
|
|
20
20
|
];
|
|
21
21
|
const config = options.config ?? {};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
process.env.BRAVE_SEARCH_API_KEY ??
|
|
25
|
-
process.env.BRAVE_API_KEY;
|
|
26
|
-
if (braveApiKey) {
|
|
22
|
+
const baiduApiKey = config.BAIDU_API_KEY;
|
|
23
|
+
if (baiduApiKey) {
|
|
27
24
|
tools.push(createWebSearchTool({
|
|
28
|
-
provider:
|
|
29
|
-
apiKey:
|
|
25
|
+
provider: createBaiduSearchProvider({
|
|
26
|
+
apiKey: baiduApiKey,
|
|
30
27
|
}),
|
|
31
28
|
}));
|
|
32
|
-
console.warn("[tools] web_search enabled via
|
|
29
|
+
console.warn("[tools] web_search enabled via Baidu Search API");
|
|
33
30
|
}
|
|
34
31
|
else {
|
|
35
|
-
console.warn("[tools] web_search disabled: set
|
|
32
|
+
console.warn("[tools] web_search disabled: set BAIDU_API_KEY in settings.json");
|
|
36
33
|
}
|
|
37
34
|
return new Map(tools.map((tool) => [tool.name, tool]));
|
|
38
35
|
}
|
package/dist/tools/web/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createHttpFetchTool } from "./http-fetch.js";
|
|
2
2
|
export { createWebSearchTool } from "./web-search.js";
|
|
3
3
|
export { createExtractReadableTextTool } from "./extract-readable-text.js";
|
|
4
|
-
export {
|
|
4
|
+
export { createBaiduSearchProvider } from "./search-providers/baidu.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function createBaiduSearchProvider(options) {
|
|
2
|
+
const baseUrl = options.baseUrl ?? "https://qianfan.baidubce.com/v2/ai_search/web_search";
|
|
3
|
+
return async function baiduSearch(query, count) {
|
|
4
|
+
const response = await fetch(baseUrl, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: {
|
|
7
|
+
"Content-Type": "application/json",
|
|
8
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
9
|
+
"X-Appbuilder-From": "yuan-claw",
|
|
10
|
+
"User-Agent": "Mozilla/5.0 (compatible; XSimpleWebSearch/1.0)",
|
|
11
|
+
},
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
messages: [{ content: query, role: "user" }],
|
|
14
|
+
search_source: "baidu_search_v2",
|
|
15
|
+
resource_type_filter: [{ type: "web", top_k: count }],
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
const errorText = await response.text().catch(() => "");
|
|
20
|
+
throw new Error(`Baidu search failed: ${response.status} ${response.statusText}${errorText ? ` - ${errorText}` : ""}`);
|
|
21
|
+
}
|
|
22
|
+
const data = (await response.json());
|
|
23
|
+
if (data.code) {
|
|
24
|
+
throw new Error(`Baidu search error: ${data.message ?? data.code}`);
|
|
25
|
+
}
|
|
26
|
+
return (data.references ?? [])
|
|
27
|
+
.slice(0, count)
|
|
28
|
+
.map((item) => ({
|
|
29
|
+
title: item.title ?? "",
|
|
30
|
+
url: item.url ?? "",
|
|
31
|
+
snippet: item.content ?? "",
|
|
32
|
+
source: "baidu",
|
|
33
|
+
}))
|
|
34
|
+
.filter((item) => item.url.trim().length > 0);
|
|
35
|
+
};
|
|
36
|
+
}
|
package/package.json
CHANGED
package/.env.example
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# =========================
|
|
2
|
-
# 模型服务配置(推荐)
|
|
3
|
-
# =========================
|
|
4
|
-
|
|
5
|
-
MODEL_API_KEY=
|
|
6
|
-
MODEL_BASE_URL=
|
|
7
|
-
MODEL_NAME=
|
|
8
|
-
|
|
9
|
-
# =========================
|
|
10
|
-
# OpenAI 风格兼容变量(可选)
|
|
11
|
-
# =========================
|
|
12
|
-
|
|
13
|
-
OPENAI_API_KEY=
|
|
14
|
-
OPENAI_BASE_URL=
|
|
15
|
-
OPENAI_MODEL=
|
|
16
|
-
|
|
17
|
-
# =========================
|
|
18
|
-
# 网页搜索配置
|
|
19
|
-
# =========================
|
|
20
|
-
|
|
21
|
-
BRAVE_SEARCH_API_KEY=
|
|
22
|
-
|
|
23
|
-
# =========================
|
|
24
|
-
# 代理配置(可选)
|
|
25
|
-
# =========================
|
|
26
|
-
|
|
27
|
-
HTTP_PROXY=
|
|
28
|
-
HTTPS_PROXY=
|