@klarkxy/dsh-zhihu 0.2.11 → 0.3.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/README.md +3 -9
- package/docs/README.zh-CN.md +3 -9
- package/lib/client.js +10 -4
- package/lib/contracts.d.ts +5 -13
- package/lib/contracts.js +5 -13
- package/lib/contracts.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/open-platform.js +3 -9
- package/lib/open-platform.js.map +1 -1
- package/lib/tools.js +165 -578
- package/lib/tools.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -35,25 +35,19 @@ These model tools are enabled by default in your agent presets:
|
|
|
35
35
|
|
|
36
36
|
| Tool | Purpose |
|
|
37
37
|
| --- | --- |
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `zhihu_knowledge_search` | Search knowledge bases |
|
|
41
|
-
| `zhihu_question_recommendations`, `zhihu_question_answers` | Find questions and read answer summaries |
|
|
42
|
-
| `zhihu_user_content_detail`, `zhihu_user_content_comments` | Read your published content and its comments |
|
|
43
|
-
| `zhihu_creator_account_stats`, `zhihu_creator_content_stats` | Your creator statistics |
|
|
44
|
-
| `zhihu_quota` | Check official quota |
|
|
38
|
+
| `zhihu_research` | Research actions: `search` (site search), `global_search` (web search), `hot_list`, `ask` (Zhida AI answers), `knowledge_search` |
|
|
39
|
+
| `zhihu_account` | Account actions: `question_recommendations`, `question_answers`, `content_detail`/`content_comments` on your posts, `creator_account_stats`, `creator_content_stats`, `quota` |
|
|
45
40
|
| `zhihu_sync` | Save, list, read, and validate drafts or upload images |
|
|
46
41
|
|
|
47
42
|
Site search and web search return an empty list when nothing matches, along with the service's explanation when provided.
|
|
48
43
|
|
|
49
44
|
## Cost protection
|
|
50
45
|
|
|
51
|
-
By default research requests use only Zhihu's free allowance: before each request the plugin checks the official quota and sends the request only when free quota remains.
|
|
46
|
+
By default research requests use only Zhihu's free allowance: before each request the plugin checks the official quota for that API and sends the request only when free quota remains. There is no extra local daily call limit. Paid use remains an explicit setting:
|
|
52
47
|
|
|
53
48
|
```yaml
|
|
54
49
|
config:
|
|
55
50
|
allowPaid: false
|
|
56
|
-
dailyCallLimit: 100
|
|
57
51
|
```
|
|
58
52
|
|
|
59
53
|
Paid use is enabled only when you set `allowPaid: true` yourself.
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -35,25 +35,19 @@ dsh plugin --profile web add @klarkxy/dsh-zhihu
|
|
|
35
35
|
|
|
36
36
|
| 工具 | 用途 |
|
|
37
37
|
| --- | --- |
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `zhihu_knowledge_search` | 检索知识库 |
|
|
41
|
-
| `zhihu_question_recommendations`、`zhihu_question_answers` | 发现问题、读取回答摘要 |
|
|
42
|
-
| `zhihu_user_content_detail`、`zhihu_user_content_comments` | 读取自己已发布的内容及评论 |
|
|
43
|
-
| `zhihu_creator_account_stats`、`zhihu_creator_content_stats` | 自己的创作数据 |
|
|
44
|
-
| `zhihu_quota` | 查询官方额度 |
|
|
38
|
+
| `zhihu_research` | 调研检索:`search`(站内搜索)、`global_search`(全网搜索)、`hot_list`(热榜)、`ask`(直答)、`knowledge_search`(知识库) |
|
|
39
|
+
| `zhihu_account` | 账号数据:`question_recommendations`(问题推荐)、`question_answers`(回答摘要)、`content_detail`/`content_comments`(本人创作与评论)、`creator_account_stats`/`creator_content_stats`(创作数据)、`quota`(官方额度) |
|
|
45
40
|
| `zhihu_sync` | 保存、列出、读取并校验草稿,上传配图 |
|
|
46
41
|
|
|
47
42
|
站内搜索和全网搜索无匹配内容时返回空列表;服务提供原因说明时会一并显示。
|
|
48
43
|
|
|
49
44
|
## 费用保护
|
|
50
45
|
|
|
51
|
-
|
|
46
|
+
检索与创作查询默认只用知乎的免费额度:每次请求前查询对应接口的官方额度,确认有剩余免费额度才发送。不再设置额外的本地每日次数上限。付费调用仍须显式配置:
|
|
52
47
|
|
|
53
48
|
```yaml
|
|
54
49
|
config:
|
|
55
50
|
allowPaid: false
|
|
56
|
-
dailyCallLimit: 100
|
|
57
51
|
```
|
|
58
52
|
|
|
59
53
|
仅在你主动将 `allowPaid` 设为 `true` 时才启用付费调用。
|
package/lib/client.js
CHANGED
|
@@ -266,7 +266,9 @@ Object.values({
|
|
|
266
266
|
"--dsh-scrollbar-thumb-hover",
|
|
267
267
|
"--dsh-content-font-size-secondary",
|
|
268
268
|
"--dsh-content-font-delta",
|
|
269
|
-
"--dsh-frame-top-clearance"
|
|
269
|
+
"--dsh-frame-top-clearance",
|
|
270
|
+
"--dsh-composer-model-icon-display",
|
|
271
|
+
"--dsh-composer-model-text-display"
|
|
270
272
|
]
|
|
271
273
|
}).flat();
|
|
272
274
|
/**
|
|
@@ -1318,7 +1320,7 @@ function ZhihuCallPolicySummary({ policy }) {
|
|
|
1318
1320
|
const t = useT();
|
|
1319
1321
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1320
1322
|
className: "dsh-ui-help",
|
|
1321
|
-
children:
|
|
1323
|
+
children: policy.allowPaid ? t("已显式允许付费", "Paid calls explicitly enabled") : t("按各接口官方免费额度调用", "Official free allowance per API")
|
|
1322
1324
|
});
|
|
1323
1325
|
}
|
|
1324
1326
|
function ZhihuCallPolicySection({ rpc }) {
|
|
@@ -1330,7 +1332,7 @@ function ZhihuCallPolicySection({ rpc }) {
|
|
|
1330
1332
|
rpc.call(ZHIHU_RPC_CHANNEL, "policy.status", {}).then((result) => {
|
|
1331
1333
|
if (!alive) return;
|
|
1332
1334
|
const value = result;
|
|
1333
|
-
if (value?.ok && typeof value.value?.allowPaid === "boolean"
|
|
1335
|
+
if (value?.ok && typeof value.value?.allowPaid === "boolean") setPolicy(value.value);
|
|
1334
1336
|
else setFailed(true);
|
|
1335
1337
|
}, () => {
|
|
1336
1338
|
if (alive) setFailed(true);
|
|
@@ -1677,7 +1679,11 @@ function ZhihuQuotaSection({ rpc }) {
|
|
|
1677
1679
|
}),
|
|
1678
1680
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ZhihuDetails, {
|
|
1679
1681
|
title: t("说明", "Details"),
|
|
1680
|
-
children: [
|
|
1682
|
+
children: [
|
|
1683
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("仅显示官方返回字段,不补零,不推算费用。", "Shows only the fields Zhihu returns; nothing is zero-filled or priced.") }),
|
|
1684
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("官方额度与本地每日调用计数分开,额度查询不计入本地调用次数。", "Official quota is separate from local daily counts; quota checks are not counted locally.") }),
|
|
1685
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("调用前查询对应接口的官方免费额度,不设置额外的本地每日次数上限。", "Each call checks its API’s official free allowance. There is no extra local daily call limit.") })
|
|
1686
|
+
]
|
|
1681
1687
|
}),
|
|
1682
1688
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1683
1689
|
className: "dsh-ui-actions",
|
package/lib/contracts.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
//#region src/contracts.d.ts
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME = "zhihu_knowledge_search";
|
|
2
|
+
/** 合并后的模型工具:检索类合并进 zhihu_research,账号/创作类合并进 zhihu_account。 */
|
|
3
|
+
declare const ZHIHU_RESEARCH_TOOL_NAME = "zhihu_research";
|
|
4
|
+
declare const ZHIHU_ACCOUNT_TOOL_NAME = "zhihu_account";
|
|
5
|
+
declare const ZHIHU_SYNC_TOOL_NAME = "zhihu_sync";
|
|
7
6
|
declare const ZHIHU_RPC_CHANNEL = "/zhihu";
|
|
8
7
|
declare const ZHIHU_CREDENTIAL_REF = "ZHIHU_ACCESS_TOKEN";
|
|
9
8
|
declare const ZHIHU_SEARCH_EVENT = "dsh-editor/zhihu-search";
|
|
@@ -18,17 +17,10 @@ type ZhihuRpcResult<T = unknown> = {
|
|
|
18
17
|
details: Record<string, unknown>;
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
|
-
declare const ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME = "zhihu_question_recommendations";
|
|
22
|
-
declare const ZHIHU_QUESTION_ANSWERS_TOOL_NAME = "zhihu_question_answers";
|
|
23
|
-
declare const ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME = "zhihu_user_content_detail";
|
|
24
|
-
declare const ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME = "zhihu_user_content_comments";
|
|
25
|
-
declare const ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME = "zhihu_creator_account_stats";
|
|
26
|
-
declare const ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME = "zhihu_creator_content_stats";
|
|
27
|
-
declare const ZHIHU_QUOTA_TOOL_NAME = "zhihu_quota";
|
|
28
20
|
/** Official quota IDs, not local execution counters or predicted balances. */
|
|
29
21
|
declare const ZHIHU_QUOTA_IDS: readonly ["global_search", "zhihu_search", "hot_list", "question_discovery", "zhida_openai", "tools", "knowledge", "user_data", "creator"];
|
|
30
22
|
declare const normalizeZhihuQuotaId: (value: unknown) => unknown;
|
|
31
23
|
type ZhihuQuotaId = typeof ZHIHU_QUOTA_IDS[number];
|
|
32
24
|
//#endregion
|
|
33
|
-
export {
|
|
25
|
+
export { ZHIHU_ACCOUNT_TOOL_NAME, ZHIHU_CREDENTIAL_REF, ZHIHU_QUOTA_IDS, ZHIHU_RESEARCH_TOOL_NAME, ZHIHU_RPC_CHANNEL, ZHIHU_SEARCH_EVENT, ZHIHU_SYNC_TOOL_NAME, ZhihuQuotaId, ZhihuRpcResult, normalizeZhihuQuotaId };
|
|
34
26
|
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
//#region src/contracts.ts
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME = "zhihu_knowledge_search";
|
|
2
|
+
/** 合并后的模型工具:检索类合并进 zhihu_research,账号/创作类合并进 zhihu_account。 */
|
|
3
|
+
const ZHIHU_RESEARCH_TOOL_NAME = "zhihu_research";
|
|
4
|
+
const ZHIHU_ACCOUNT_TOOL_NAME = "zhihu_account";
|
|
5
|
+
const ZHIHU_SYNC_TOOL_NAME = "zhihu_sync";
|
|
7
6
|
const ZHIHU_RPC_CHANNEL = "/zhihu";
|
|
8
7
|
const ZHIHU_CREDENTIAL_REF = "ZHIHU_ACCESS_TOKEN";
|
|
9
8
|
const ZHIHU_SEARCH_EVENT = "dsh-editor/zhihu-search";
|
|
10
|
-
const ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME = "zhihu_question_recommendations";
|
|
11
|
-
const ZHIHU_QUESTION_ANSWERS_TOOL_NAME = "zhihu_question_answers";
|
|
12
|
-
const ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME = "zhihu_user_content_detail";
|
|
13
|
-
const ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME = "zhihu_user_content_comments";
|
|
14
|
-
const ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME = "zhihu_creator_account_stats";
|
|
15
|
-
const ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME = "zhihu_creator_content_stats";
|
|
16
|
-
const ZHIHU_QUOTA_TOOL_NAME = "zhihu_quota";
|
|
17
9
|
/** Official quota IDs, not local execution counters or predicted balances. */
|
|
18
10
|
const ZHIHU_QUOTA_IDS = [
|
|
19
11
|
"global_search",
|
|
@@ -28,6 +20,6 @@ const ZHIHU_QUOTA_IDS = [
|
|
|
28
20
|
];
|
|
29
21
|
const normalizeZhihuQuotaId = (value) => value === "question_answers" ? "question_discovery" : value;
|
|
30
22
|
//#endregion
|
|
31
|
-
export {
|
|
23
|
+
export { ZHIHU_ACCOUNT_TOOL_NAME, ZHIHU_CREDENTIAL_REF, ZHIHU_QUOTA_IDS, ZHIHU_RESEARCH_TOOL_NAME, ZHIHU_RPC_CHANNEL, ZHIHU_SEARCH_EVENT, ZHIHU_SYNC_TOOL_NAME, normalizeZhihuQuotaId };
|
|
32
24
|
|
|
33
25
|
//# sourceMappingURL=contracts.js.map
|
package/lib/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"contracts.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["/** 合并后的模型工具:检索类合并进 zhihu_research,账号/创作类合并进 zhihu_account。 */\nexport const ZHIHU_RESEARCH_TOOL_NAME = 'zhihu_research'\nexport const ZHIHU_ACCOUNT_TOOL_NAME = 'zhihu_account'\nexport const ZHIHU_SYNC_TOOL_NAME = 'zhihu_sync'\nexport const ZHIHU_RPC_CHANNEL = '/zhihu'\nexport const ZHIHU_CREDENTIAL_REF = 'ZHIHU_ACCESS_TOKEN'\nexport const ZHIHU_SEARCH_EVENT = 'dsh-editor/zhihu-search'\nexport type ZhihuRpcResult<T = unknown> = { ok: true; value: T } | { ok: false; error: { code: string; message: string; details: Record<string, unknown> } }\n\n/** Official quota IDs, not local execution counters or predicted balances. */\nexport const ZHIHU_QUOTA_IDS = [\n 'global_search', 'zhihu_search', 'hot_list', 'question_discovery',\n 'zhida_openai', 'tools', 'knowledge', 'user_data', 'creator',\n] as const\nexport const normalizeZhihuQuotaId = (value: unknown): unknown => value === 'question_answers' ? 'question_discovery' : value\nexport type ZhihuQuotaId = typeof ZHIHU_QUOTA_IDS[number]\n"],"mappings":";;AACA,MAAa,2BAA2B;AACxC,MAAa,0BAA0B;AACvC,MAAa,uBAAuB;AACpC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;;AAIlC,MAAa,kBAAkB;CAC7B;CAAiB;CAAgB;CAAY;CAC7C;CAAgB;CAAS;CAAa;CAAa;AACrD;AACA,MAAa,yBAAyB,UAA4B,UAAU,qBAAqB,uBAAuB"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ import { ZhihuQuotaId, ZhihuRpcResult } from "./contracts.js";
|
|
|
2
2
|
import { ZhihuUsageRecorder } from "./usage.js";
|
|
3
3
|
import { Context } from "@deepseek-ai/cordis";
|
|
4
4
|
//#region src/call-policy.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/** Ledger format is shared with zhihu-search/call_policy.py; counters are not limits. */
|
|
6
6
|
type ZhihuCallPolicyOptions = {
|
|
7
7
|
allowPaid?: boolean;
|
|
8
|
-
dailyCallLimit?: number;
|
|
9
8
|
directory?: string;
|
|
10
9
|
lockTimeoutMs?: number;
|
|
11
10
|
};
|
package/lib/index.js
CHANGED
|
@@ -152,7 +152,7 @@ function registerHostRpc(ctx, channel, handler) {
|
|
|
152
152
|
//#region src/web-search-provider.ts
|
|
153
153
|
/**
|
|
154
154
|
* Native ctx.web backend. Configuration and credentials belong to Zhihu.
|
|
155
|
-
* Official model tool remains `web_search`.
|
|
155
|
+
* Official model tool remains `web_search`. The `global_search` action of `zhihu_research` is unchanged.
|
|
156
156
|
*/
|
|
157
157
|
const ZHIHU_WEB_SEARCH_ID = "zhihu-global";
|
|
158
158
|
const ZHIHU_WEB_SEARCH_DESCRIPTOR = {
|