dsh-zhihu-search 1.4.0 → 1.4.2
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/lib/tools/global-search.js +12 -2
- package/lib/tools/search.js +13 -2
- package/package.json +1 -1
|
@@ -15,11 +15,16 @@ import { mapError } from '../utils/errors.js';
|
|
|
15
15
|
import { sanitizeSnippet, stripTrackingParams } from '../utils/text.js';
|
|
16
16
|
import { LocalRateLimitError } from '../state.js';
|
|
17
17
|
import { presentSearchCall, presentSearchResult, renderSearch, searchMetaFromValue } from '../present/search.js';
|
|
18
|
+
import { GLOBAL_SEARCH_MAX_COUNT } from '../transport.js';
|
|
18
19
|
import { cacheKeyFor } from './deps.js';
|
|
19
20
|
/** 工具名。 */
|
|
20
21
|
export const ZHIHU_GLOBAL_SEARCH_TOOL = 'zhihu_global_search';
|
|
21
|
-
/**
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 全网搜索的 `Count` 上限(实测:比站内搜索宽,可达 20)。
|
|
24
|
+
*
|
|
25
|
+
* 与站内搜索同理:数字只住在传输层的端点契约常量里,这里取别名。
|
|
26
|
+
*/
|
|
27
|
+
const MAX_COUNT = GLOBAL_SEARCH_MAX_COUNT;
|
|
23
28
|
/** 未指定时使用的条数。 */
|
|
24
29
|
const DEFAULT_COUNT = 8;
|
|
25
30
|
/** 协作式超时预算。 */
|
|
@@ -94,6 +99,11 @@ export function createZhihuGlobalSearchTool(deps) {
|
|
|
94
99
|
snippet: { type: 'string', required: true },
|
|
95
100
|
author: { type: 'string', required: true },
|
|
96
101
|
voteUpCount: { type: 'number' },
|
|
102
|
+
// ⚠ 可选字段也必须在这里声明:output.schema 是 additionalProperties: false,
|
|
103
|
+
// **宿主按它校验工具返回值** —— 投影了却没声明 = 整个调用被判非法
|
|
104
|
+
// (v1.4.0 就是这样让所有搜索调用失败的,回归守卫见 test/tool.test.ts)。
|
|
105
|
+
commentCount: { type: 'number' },
|
|
106
|
+
editTime: { type: 'number' },
|
|
97
107
|
contentType: { type: 'string', required: true },
|
|
98
108
|
},
|
|
99
109
|
},
|
package/lib/tools/search.js
CHANGED
|
@@ -14,11 +14,17 @@ import { mapError } from '../utils/errors.js';
|
|
|
14
14
|
import { sanitizeSnippet, stripTrackingParams } from '../utils/text.js';
|
|
15
15
|
import { LocalRateLimitError } from '../state.js';
|
|
16
16
|
import { presentSearchCall, presentSearchResult, renderSearch, searchMetaFromValue } from '../present/search.js';
|
|
17
|
+
import { ZHIHU_SEARCH_MAX_COUNT } from '../transport.js';
|
|
17
18
|
import { cacheKeyFor } from './deps.js';
|
|
18
19
|
/** 工具名。 */
|
|
19
20
|
export const ZHIHU_SEARCH_TOOL = 'zhihu_search';
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 站内搜索的 `Count` 上限(实测:超出由服务端截断)。
|
|
23
|
+
*
|
|
24
|
+
* 单一来源是传输层的端点契约常量(它同时负责发请求前夹取),这里只是别名 ——
|
|
25
|
+
* 同一个上游事实在两层各写一个数字,改一处漏一处就会让描述与实际行为不一致。
|
|
26
|
+
*/
|
|
27
|
+
const MAX_COUNT = ZHIHU_SEARCH_MAX_COUNT;
|
|
22
28
|
/** 未指定时使用的条数。 */
|
|
23
29
|
const DEFAULT_COUNT = 5;
|
|
24
30
|
/**
|
|
@@ -143,6 +149,11 @@ export function createZhihuSearchTool(deps) {
|
|
|
143
149
|
snippet: { type: 'string', required: true },
|
|
144
150
|
author: { type: 'string', required: true },
|
|
145
151
|
voteUpCount: { type: 'number' },
|
|
152
|
+
// ⚠ 可选字段也必须在这里声明:output.schema 是 additionalProperties: false,
|
|
153
|
+
// **宿主按它校验工具返回值** —— 投影了却没声明 = 整个调用被判非法
|
|
154
|
+
// (v1.4.0 就是这样让所有搜索调用失败的,回归守卫见 test/tool.test.ts)。
|
|
155
|
+
commentCount: { type: 'number' },
|
|
156
|
+
editTime: { type: 'number' },
|
|
146
157
|
contentType: { type: 'string', required: true },
|
|
147
158
|
},
|
|
148
159
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-zhihu-search",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "DSH plugin: Zhihu in-site search, global web search, and Zhida over the official Zhihu Open Platform API — with a native settings card and source-cited results.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|