@klarkxy/dsh-zhihu 0.2.6 → 0.2.8
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 +18 -11
- package/docs/README.zh-CN.md +14 -7
- package/lib/client.js +447 -86
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2426 -1
- package/lib/index.js.map +1 -1
- package/lib/tools.js +188 -0
- package/lib/tools.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +6 -4
package/lib/tools.js
CHANGED
|
@@ -735,12 +735,200 @@ const ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES = [
|
|
|
735
735
|
createZhihuQuotaTool
|
|
736
736
|
];
|
|
737
737
|
//#endregion
|
|
738
|
+
//#region src/sync-tools.ts
|
|
739
|
+
/** Publishing is a human confirmation action in the preview pane. The tool can
|
|
740
|
+
* prepare the same saved draft, but never receives a UI review ticket. */
|
|
741
|
+
function createZhihuSyncTool(service) {
|
|
742
|
+
return defineTool({
|
|
743
|
+
name: "zhihu_sync",
|
|
744
|
+
description: "管理知乎文章、提问和想法草稿,校验预览或上传配图。上传会将图片发送到知乎;实际发布需用户在预览界面确认,当前分支未提供发布界面。",
|
|
745
|
+
parameters: {
|
|
746
|
+
action: {
|
|
747
|
+
type: "string",
|
|
748
|
+
enum: [
|
|
749
|
+
"list",
|
|
750
|
+
"get",
|
|
751
|
+
"save",
|
|
752
|
+
"prepare",
|
|
753
|
+
"upload_image"
|
|
754
|
+
],
|
|
755
|
+
required: true
|
|
756
|
+
},
|
|
757
|
+
offset: {
|
|
758
|
+
type: "integer",
|
|
759
|
+
description: "list 分页位置;省略从头读取,后续使用返回的 nextOffset。"
|
|
760
|
+
},
|
|
761
|
+
id: {
|
|
762
|
+
type: "string",
|
|
763
|
+
description: "get、prepare 或更新草稿时填写已有 ID。"
|
|
764
|
+
},
|
|
765
|
+
expectedRevision: {
|
|
766
|
+
type: "integer",
|
|
767
|
+
description: "prepare 或更新时填写上次读取的 revision。"
|
|
768
|
+
},
|
|
769
|
+
image: {
|
|
770
|
+
type: "object",
|
|
771
|
+
description: "upload_image 时填写图片内容。",
|
|
772
|
+
properties: {
|
|
773
|
+
fileName: {
|
|
774
|
+
type: "string",
|
|
775
|
+
required: true
|
|
776
|
+
},
|
|
777
|
+
contentBase64: {
|
|
778
|
+
type: "string",
|
|
779
|
+
required: true,
|
|
780
|
+
description: "JPEG、PNG、GIF、WebP 或 BMP 的标准 base64。GIF最大15 MB,其他最大30 MB。"
|
|
781
|
+
},
|
|
782
|
+
scene: {
|
|
783
|
+
type: "string",
|
|
784
|
+
required: true,
|
|
785
|
+
enum: [
|
|
786
|
+
"article",
|
|
787
|
+
"question",
|
|
788
|
+
"pin"
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
additionalProperties: false
|
|
793
|
+
},
|
|
794
|
+
draft: {
|
|
795
|
+
type: "object",
|
|
796
|
+
description: "save 时提供完整草稿;只做格式适配,不自动删改正文。",
|
|
797
|
+
properties: {
|
|
798
|
+
type: {
|
|
799
|
+
type: "string",
|
|
800
|
+
enum: [
|
|
801
|
+
"article",
|
|
802
|
+
"question",
|
|
803
|
+
"pin"
|
|
804
|
+
],
|
|
805
|
+
required: true
|
|
806
|
+
},
|
|
807
|
+
title: {
|
|
808
|
+
type: "string",
|
|
809
|
+
required: true
|
|
810
|
+
},
|
|
811
|
+
body: {
|
|
812
|
+
type: "string",
|
|
813
|
+
required: true
|
|
814
|
+
},
|
|
815
|
+
format: {
|
|
816
|
+
type: "string",
|
|
817
|
+
enum: ["markdown", "html"],
|
|
818
|
+
required: true
|
|
819
|
+
},
|
|
820
|
+
images: {
|
|
821
|
+
type: "array",
|
|
822
|
+
description: "已上传的知乎图片;本地图片请通过 upload_image 上传后引用。",
|
|
823
|
+
items: {
|
|
824
|
+
type: "object",
|
|
825
|
+
properties: {
|
|
826
|
+
url: {
|
|
827
|
+
type: "string",
|
|
828
|
+
required: true
|
|
829
|
+
},
|
|
830
|
+
originalUrl: {
|
|
831
|
+
type: "string",
|
|
832
|
+
description: "正文中的原始图片引用。"
|
|
833
|
+
},
|
|
834
|
+
width: { type: "number" },
|
|
835
|
+
height: { type: "number" },
|
|
836
|
+
watermark: { type: "boolean" },
|
|
837
|
+
mediaId: { type: "string" }
|
|
838
|
+
},
|
|
839
|
+
additionalProperties: false
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
linkCard: {
|
|
843
|
+
type: "object",
|
|
844
|
+
description: "想法的独立链接卡片,与图片互斥。",
|
|
845
|
+
properties: {
|
|
846
|
+
url: {
|
|
847
|
+
type: "string",
|
|
848
|
+
required: true
|
|
849
|
+
},
|
|
850
|
+
title: { type: "string" },
|
|
851
|
+
cover: { type: "string" }
|
|
852
|
+
},
|
|
853
|
+
additionalProperties: false
|
|
854
|
+
},
|
|
855
|
+
settings: {
|
|
856
|
+
type: "object",
|
|
857
|
+
properties: {
|
|
858
|
+
commentPermission: {
|
|
859
|
+
type: "string",
|
|
860
|
+
enum: [
|
|
861
|
+
"all",
|
|
862
|
+
"nobody",
|
|
863
|
+
"followee",
|
|
864
|
+
"censor",
|
|
865
|
+
"follower",
|
|
866
|
+
"follower_n_days"
|
|
867
|
+
]
|
|
868
|
+
},
|
|
869
|
+
creationStatement: {
|
|
870
|
+
type: "string",
|
|
871
|
+
enum: [
|
|
872
|
+
"spoiler",
|
|
873
|
+
"medical_advice",
|
|
874
|
+
"fictional_creation",
|
|
875
|
+
"contain_finance",
|
|
876
|
+
"ai_creation"
|
|
877
|
+
]
|
|
878
|
+
},
|
|
879
|
+
tableOfContentsEnabled: { type: "boolean" },
|
|
880
|
+
topics: {
|
|
881
|
+
type: "array",
|
|
882
|
+
items: { type: "string" },
|
|
883
|
+
description: "用户提供的知乎话题链接,文章最多3个,提问最多5个。"
|
|
884
|
+
},
|
|
885
|
+
ring: {
|
|
886
|
+
type: "string",
|
|
887
|
+
description: "想法的知乎圈子链接。"
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
additionalProperties: false
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
additionalProperties: false
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
output: {
|
|
897
|
+
schema: {
|
|
898
|
+
type: "object",
|
|
899
|
+
additionalProperties: true,
|
|
900
|
+
properties: {}
|
|
901
|
+
},
|
|
902
|
+
render(_args, value) {
|
|
903
|
+
return [{
|
|
904
|
+
type: "text",
|
|
905
|
+
text: JSON.stringify(value)
|
|
906
|
+
}];
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
isConcurrencySafe(args) {
|
|
910
|
+
return args.action === "list" || args.action === "get";
|
|
911
|
+
},
|
|
912
|
+
async execute(args, exec) {
|
|
913
|
+
if (!service.syncCall) throw new Error("知乎同步服务未启用。");
|
|
914
|
+
if (args.action === "upload_image") return await service.syncCall("sync.media.upload", args.image, exec.signal, "tool");
|
|
915
|
+
return await service.syncCall(`sync.${args.action}`, {
|
|
916
|
+
...args.offset === void 0 ? {} : { offset: args.offset },
|
|
917
|
+
...args.id === void 0 ? {} : { id: args.id },
|
|
918
|
+
...args.expectedRevision === void 0 ? {} : { expectedRevision: args.expectedRevision },
|
|
919
|
+
...args.draft === void 0 ? {} : { draft: args.draft }
|
|
920
|
+
}, exec.signal, "tool");
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
//#endregion
|
|
738
925
|
//#region src/tools.ts
|
|
739
926
|
const name = "dsh-zhihu-tools";
|
|
740
927
|
const inject = ["zhihu", "tools"];
|
|
741
928
|
function apply(ctx) {
|
|
742
929
|
const host = ctx;
|
|
743
930
|
const options = host.zhihu.toolOptions;
|
|
931
|
+
if (host.zhihu.syncCall) host.tools.register(createZhihuSyncTool(host.zhihu));
|
|
744
932
|
for (const create of [
|
|
745
933
|
createZhihuSearchTool,
|
|
746
934
|
createZhihuGlobalSearchTool,
|
package/lib/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","names":[],"sources":["../src/tool-definitions.ts","../src/open-platform-render.ts","../src/open-platform-tools.ts","../src/tools.ts"],"sourcesContent":["import { defineTool } from '@deepseek-ai/dsh-tools'\nimport { reportExecuted, type ZhihuClientOptions } from './zhihu-client.ts'\nimport { ZHIHU_SEARCH_TOOL_NAME, ZHIHU_GLOBAL_SEARCH_TOOL_NAME, ZHIHU_HOT_LIST_TOOL_NAME, ZHIHU_ASK_TOOL_NAME, ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME } from './contracts.ts'\nimport { executeZhihuSearch, renderZhihuSearch, ZHIHU_SEARCH_DEFAULT_COUNT, ZHIHU_SEARCH_MAX_COUNT, type ZhihuSearchResult } from './search-api.ts'\nimport {\n ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT, ZHIHU_GLOBAL_SEARCH_MAX_COUNT,\n ZHIHU_HOT_LIST_DEFAULT_LIMIT, ZHIHU_HOT_LIST_MAX_LIMIT,\n ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT, ZHIHU_KNOWLEDGE_SEARCH_MAX_LIMIT,\n ZHIHU_ASK_MODELS, ZHIHU_ASK_DEFAULT_MODEL, ZHIHU_RECALL_SCOPES,\n executeZhihuGlobalSearch, renderZhihuGlobalSearch,\n executeZhihuHotList, renderZhihuHotList,\n executeZhihuAsk, renderZhihuAsk,\n normalizeRecallScopes, executeZhihuKnowledgeSearch, renderZhihuKnowledgeSearch,\n type ZhihuAskModel, type ZhihuToolOptions, type ZhihuGlobalSearchDb,\n type ZhihuGlobalSearchResult, type ZhihuHotListResult, type ZhihuAskResult,\n type ZhihuKnowledgeSearchResult,\n} from './operations.ts'\nexport type CreateZhihuSearchToolOptions = ZhihuClientOptions & {\n /** Best-effort metering hook; invoked after every execution, failures included. */\n onExecuted?: (event: { ok: boolean; results: number }) => void\n}\n\nconst SEARCH_ITEM_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n type: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n votes: { type: 'integer', required: true },\n comments: { type: 'integer', required: true },\n author: { type: 'string', required: true },\n authority: { type: 'string', required: true },\n editTime: { type: 'string', required: true },\n },\n} as const\n\nexport function createZhihuSearchTool(options: CreateZhihuSearchToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_SEARCH_TOOL_NAME,\n description: '知乎站内搜索(GET /api/v1/content/zhihu_search),取社区证据;仅作社区/读者反馈参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '搜索词,2-100 字符。' },\n count: { type: 'integer', description: `返回条数,1-${ZHIHU_SEARCH_MAX_COUNT},默认 ${ZHIHU_SEARCH_DEFAULT_COUNT}。` },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n count: { type: 'integer', required: true },\n items: {\n type: 'array',\n required: true,\n items: SEARCH_ITEM_SCHEMA,\n },\n emptyReason: { type: 'string' },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuSearch(value as ZhihuSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; count?: number }\n try {\n const result = await executeZhihuSearch(typed.query, typed.count ?? ZHIHU_SEARCH_DEFAULT_COUNT, {\n ...client,\n signal: exec.signal,\n })\n reportExecuted(onExecuted, { ok: true, results: result.items.length })\n return result\n } catch (error) {\n reportExecuted(onExecuted, { ok: false, results: 0 })\n throw error\n }\n },\n })\n}\n\nconst OTHER_SEARCH_ITEM_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n type: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n votes: { type: 'integer', required: true },\n comments: { type: 'integer', required: true },\n author: { type: 'string', required: true },\n authority: { type: 'string', required: true },\n editTime: { type: 'string', required: true },\n },\n} as const\n\n/** 包一层计量:成功报 results,失败报 ok:false 再原样抛出。 */\nasync function metered<T>(onExecuted: ZhihuToolOptions['onExecuted'], run: () => Promise<T>, results: (value: T) => number): Promise<T> {\n try {\n const value = await run()\n reportExecuted(onExecuted, { ok: true, results: results(value) })\n return value\n } catch (error) {\n reportExecuted(onExecuted, { ok: false, results: 0 })\n throw error\n }\n}\n\nexport function createZhihuGlobalSearchTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_GLOBAL_SEARCH_TOOL_NAME,\n description: '知乎开放平台全网搜索(GET /api/v1/content/global_search),检索站外公开网页资料;仅作参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '搜索词,2-100 字符。' },\n count: { type: 'integer', description: `返回条数,1-${ZHIHU_GLOBAL_SEARCH_MAX_COUNT},默认 ${ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT}。` },\n searchDb: { type: 'string', description: '检索库:all(默认)、realtime(实时)、static(静态)。' },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n count: { type: 'integer', required: true },\n searchDb: { type: 'string', required: true },\n items: { type: 'array', required: true, items: OTHER_SEARCH_ITEM_SCHEMA },\n emptyReason: { type: 'string' },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuGlobalSearch(value as ZhihuGlobalSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; count?: number; searchDb?: string }\n const searchDb: ZhihuGlobalSearchDb = typed.searchDb === 'realtime' || typed.searchDb === 'static' ? typed.searchDb : 'all'\n return await metered(onExecuted, () => executeZhihuGlobalSearch(\n typed.query,\n typed.count ?? ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT,\n searchDb,\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n\nexport function createZhihuHotListTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_HOT_LIST_TOOL_NAME,\n description: '知乎热榜(GET /api/v1/content/hot_list),了解当前社区热点;仅作题材参考,不构成 canon,不写入项目文件。',\n parameters: {\n limit: { type: 'integer', description: `返回条数,1-${ZHIHU_HOT_LIST_MAX_LIMIT},默认 ${ZHIHU_HOT_LIST_DEFAULT_LIMIT}。` },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n limit: { type: 'integer', required: true },\n items: {\n type: 'array',\n required: true,\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n },\n },\n },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuHotList(value as ZhihuHotListResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { limit?: number }\n return await metered(onExecuted, () => executeZhihuHotList(\n typed.limit ?? ZHIHU_HOT_LIST_DEFAULT_LIMIT,\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n\nexport function createZhihuAskTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_ASK_TOOL_NAME,\n description: '知乎直答(POST /v1/chat/completions,OpenAI 兼容),基于社区内容生成综合回答,适合考据与背景调研;仅作参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '要问的问题。' },\n model: { type: 'string', description: 'zhida-thinking-1p5(默认,带思考过程)、zhida-fast-1p5(快,仅适合简单事实查询)或 zhida-agent(最慢最强,仅在明确要求时使用)。fast/thinking 仅在免费额度足够时允许;付费模式拒绝未确认计费的模型。' },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n model: { type: 'string', required: true },\n content: { type: 'string', required: true },\n reasoning: { type: 'string', required: true },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuAsk(value as ZhihuAskResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; model?: string }\n const model: ZhihuAskModel = (ZHIHU_ASK_MODELS as readonly string[]).includes(typed.model ?? '')\n ? (typed.model as ZhihuAskModel)\n : ZHIHU_ASK_DEFAULT_MODEL\n return await metered(onExecuted, () => executeZhihuAsk(\n typed.query,\n model,\n { ...client, signal: exec.signal },\n ), (result) => (result.content ? 1 : 0))\n },\n })\n}\n\nexport function createZhihuKnowledgeSearchTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME,\n description: '知乎知识库检索(POST /api/v1/knowledge/search,RAG 片段),默认只查公开库;网页端上传过资料后可加 personal/subscription 召回;仅作背景参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '检索词。' },\n limit: { type: 'integer', description: `返回条数,1-${ZHIHU_KNOWLEDGE_SEARCH_MAX_LIMIT},默认 ${ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT}。` },\n recallScopes: {\n type: 'array',\n description: '召回范围:public(公开库,默认)、personal(个人库)、subscription(订阅库),可多选。',\n items: { type: 'string', enum: [...ZHIHU_RECALL_SCOPES] },\n },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n limit: { type: 'integer', required: true },\n recallScopes: { type: 'array', required: true, items: { type: 'string' } },\n items: {\n type: 'array',\n required: true,\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n docName: { type: 'string', required: true },\n originUrl: { type: 'string', required: true },\n snippets: { type: 'array', required: true, items: { type: 'string' } },\n },\n },\n },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuKnowledgeSearch(value as ZhihuKnowledgeSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; limit?: number; recallScopes?: unknown }\n return await metered(onExecuted, () => executeZhihuKnowledgeSearch(\n typed.query,\n typed.limit ?? ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT,\n normalizeRecallScopes(typed.recallScopes),\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n","import { ZHIHU_OPEN_PLATFORM_APIS, type ZhihuOpenPlatformResult } from './open-platform.ts'\n\n/** Display only: the structured result always retains the original upstream HTML. */\nexport function plainZhihuText(value: string): string {\n const entities: Record<string, string> = { amp: '&', lt: '<', gt: '>', quot: '\"', apos: \"'\", nbsp: ' ' }\n const decoded = value.replace(/&(#x[\\da-f]+|#\\d+|amp|lt|gt|quot|apos|nbsp);/gi, (match, entity: string) => {\n if (!entity.startsWith('#')) return entities[entity.toLowerCase()] ?? match\n const hex = entity[1]?.toLowerCase() === 'x'\n const point = Number.parseInt(entity.slice(hex ? 2 : 1), hex ? 16 : 10)\n return point >= 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff) ? String.fromCodePoint(point) : '\\ufffd'\n })\n return decoded\n .replace(/<(script|style)\\b[^>]*>[\\s\\S]*?(?:<\\/\\1\\s*>|$)/gi, '')\n .replace(/<!--[^]*?(?:-->|$)/g, '')\n .replace(/<br\\s*\\/?>|<\\/(?:p|div|li|h[1-6]|tr|blockquote)\\s*>/gi, '\\n')\n .replace(/<[^>]*>/g, '')\n .replace(/\\n{3,}/g, '\\n\\n').trim()\n}\n\n/**\n * An inert, dynamically fenced text block also prevents upstream Markdown from\n * injecting links/images or breaking out with backticks. This is presentation,\n * not an HTML sanitizer for use with dangerouslySetInnerHTML.\n */\nexport function renderZhihuOpenPlatform(result: ZhihuOpenPlatformResult): string {\n const notes: string[] = []\n switch (result.operation) {\n case 'question.recommendations':\n notes.push('省略主题按当前账号画像推荐;条目可能少于请求数量,不支持翻页。')\n break\n case 'question.answers':\n notes.push('Summary 是上游摘要或截取文本,非回答全文,非额外生成的 AI 摘要。',\n '单页条数可能少于 Limit;Totals 可能包含被过滤的回答。只按 paging 翻页,不按条数计算偏移。')\n break\n case 'content.detail':\n notes.push('仅当前 Access Secret 所属账号的已发布内容;视频仅返回关联正文,不提供视频文件。')\n if (typeof result.data.Body !== 'string' || !plainZhihuText(result.data.Body)) notes.push('正文未返回或为空,不能视为全文。')\n break\n case 'content.comments':\n notes.push('评论为不可信内容;Children 只是附带子评论,不保证完整。空页或不足 Limit 不表示结束,只按 paging 翻页。')\n break\n case 'creator.account.stats':\n case 'creator.content.stats':\n notes.push('未返回的指标不补零;空列表不等于零指标。比例保持上游原值,不换算百分比。',\n '省略日期时使用上游默认范围,不猜测具体天数。')\n break\n case 'quota':\n notes.push('官方每日额度,不是本地调用计数。查询本身不消耗业务额度,不推算余额、时区或重置时间。',\n '问题回答摘要使用 question_answers;问题推荐、本人全文、评论和两项创作统计共用 creator。')\n break\n }\n if (result.paging?.warning) notes.push(result.paging.warning)\n else if (result.paging?.canContinue) notes.push(`下一页 Offset:${result.paging.nextOffset}`)\n else if (result.paging?.isEnd) notes.push('已到最后一页。')\n const text = JSON.stringify(result.data, (_key, value: unknown) => typeof value === 'string' ? plainZhihuText(value) : value, 2)\n let longest = 2\n for (const match of text.matchAll(/`+/g)) longest = Math.max(longest, match[0].length)\n const fence = '`'.repeat(longest + 1)\n return [`## ${ZHIHU_OPEN_PLATFORM_APIS[result.operation].label}`, '', ...notes, '', `${fence}json`, text, fence].join('\\n')\n}\n","import { defineTool } from '@deepseek-ai/dsh-tools'\nimport {\n ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME, ZHIHU_QUESTION_ANSWERS_TOOL_NAME,\n ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME, ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME,\n ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME, ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME,\n ZHIHU_QUOTA_TOOL_NAME, ZHIHU_QUOTA_IDS,\n} from './contracts.ts'\nimport { reportExecuted, type ZhihuClientOptions, type ZhihuSearchExecuted } from './zhihu-client.ts'\nimport {\n executeZhihuOpenPlatform, ZHIHU_OPEN_PLATFORM_APIS, zhihuOpenPlatformResultCount,\n type ZhihuOpenPlatformOperation, type ZhihuOpenPlatformResult,\n} from './open-platform.ts'\nimport { renderZhihuOpenPlatform } from './open-platform-render.ts'\n\nexport type ZhihuOpenPlatformToolOptions = ZhihuClientOptions & { onExecuted?: (event: ZhihuSearchExecuted) => void }\nconst PAGE_PARAMETERS = {\n offset: { type: 'string', description: '非负 Int64 十进制字符串,默认 \"0\"。下一页只用 paging.nextOffset,不按条数推算,不接受不透明游标。' },\n limit: { type: 'integer', description: '每页数量,1-50,默认 20。单页不足或为空不表示结束。' },\n} as const\nconst DATE_PARAMETERS = {\n startDate: { type: 'string', description: 'YYYY-MM-DD,必须与 endDate 同时提供。省略两者使用上游默认范围,不猜测天数。' },\n endDate: { type: 'string', description: 'YYYY-MM-DD,不得早于 startDate。' },\n} as const\nconst CONTENT_URL = { type: 'string', required: true, description: '当前账号已发布内容的 HTTPS 知乎回答、专栏文章、想法或视频链接;不是任意网页抓取。' } as const\n\nconst DEFINITIONS = {\n 'question.recommendations': {\n name: ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME,\n description: '推荐适合当前账号回答的问题;省略主题按画像推荐,条目可能少于 Count,不支持分页。使用 question_discovery 额度;免费模式须有足够额度,付费模式因计费未确认而阻止。',\n parameters: {\n query: { type: 'string', description: '可选主题;不传才按画像推荐,空白字符串无效。' },\n count: { type: 'integer', description: '推荐数量,1-20,默认 5。' },\n },\n },\n 'question.answers': {\n name: ZHIHU_QUESTION_ANSWERS_TOOL_NAME,\n description: '读取问题下的回答摘要,非全文,也非新生成的 AI 摘要。一次一页,只有 paging.canContinue=true 时才用 nextOffset。使用 question_discovery 额度。',\n parameters: {\n questionUrl: { type: 'string', required: true, description: 'https://www.zhihu.com/question/{id} 形式的问题链接。' },\n ...PAGE_PARAMETERS,\n },\n },\n 'content.detail': {\n name: ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME,\n description: '读取当前账号已发布创作的全文。不能读其他账号全文;视频只给关联正文。空正文不能视为全文。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL },\n },\n 'content.comments': {\n name: ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME,\n description: '读取当前账号创作下的根评论及附带 Children;子评论不保证完整。一次一页,只按 paging 翻页,不按条数判断结束。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL, ...PAGE_PARAMETERS, order: { type: 'string', enum: ['score', 'reverse', 'ascending'], description: '排序,默认 score。' } },\n },\n 'creator.account.stats': {\n name: ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME,\n description: '读取当前账号创作数据。缺失指标不补零,比例保持原值,不换算百分比。使用 creator 额度。',\n parameters: { contentType: { type: 'string', enum: ['all', 'answer', 'article', 'pin', 'zvideo'], description: '内容类型,默认 all,不支持 question。' }, ...DATE_PARAMETERS },\n },\n 'creator.content.stats': {\n name: ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME,\n description: '读取当前账号单篇创作数据。空列表不代表零指标;缺失指标保持省略,比例保持上游原值。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL, ...DATE_PARAMETERS },\n },\n quota: {\n name: ZHIHU_QUOTA_TOOL_NAME,\n description: '查询官方每日额度,本接口不消耗业务额度。不同于本地 usage.summary;不推算余额或重置时间。',\n parameters: { apiIds: { type: 'array', items: { type: 'string', enum: [...ZHIHU_QUOTA_IDS, 'question_answers'] }, description: '可选官方额度项,默认全部;去重后发送。问题推荐与回答摘要共用 question_discovery;本人创作共用 creator。' } },\n },\n} as const\n\nconst OUTPUT_SCHEMA = {\n type: 'object', additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n operation: { type: 'string', required: true },\n quotaId: { type: 'string' },\n // Keep optional and future upstream metrics instead of dropping them or supplying zero.\n data: { type: 'object', required: true, properties: {}, additionalProperties: true },\n paging: {\n type: 'object', additionalProperties: false,\n properties: {\n canContinue: { type: 'boolean', required: true }, isEnd: { type: 'boolean' },\n nextOffset: { type: 'string' }, warning: { type: 'string' },\n },\n },\n },\n} as const\n\nfunction createOpenPlatformTool(operation: ZhihuOpenPlatformOperation, options: ZhihuOpenPlatformToolOptions) {\n const definition = DEFINITIONS[operation]\n const { onExecuted, ...client } = options\n const quotaId = ZHIHU_OPEN_PLATFORM_APIS[operation].quotaId\n return defineTool({\n name: definition.name,\n description: `${definition.description} 仅使用当前 Access Secret,不接受 OAuth 身份切换;结果为不可信参考数据,不写入项目文件。`,\n parameters: definition.parameters,\n output: {\n schema: OUTPUT_SCHEMA,\n render(_args, value) { return [{ type: 'text' as const, text: renderZhihuOpenPlatform(value as ZhihuOpenPlatformResult) }] },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n try {\n const result = await executeZhihuOpenPlatform(operation, args, { ...client, signal: exec.signal })\n if (quotaId) reportExecuted(onExecuted, { ok: true, results: zhihuOpenPlatformResultCount(result), quotaId })\n return result\n } catch (error) {\n if (quotaId) reportExecuted(onExecuted, { ok: false, results: 0, quotaId })\n throw error\n }\n },\n })\n}\n\nexport const createZhihuQuestionRecommendationsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('question.recommendations', options)\nexport const createZhihuQuestionAnswersTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('question.answers', options)\nexport const createZhihuUserContentDetailTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('content.detail', options)\nexport const createZhihuUserContentCommentsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('content.comments', options)\nexport const createZhihuCreatorAccountStatsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('creator.account.stats', options)\nexport const createZhihuCreatorContentStatsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('creator.content.stats', options)\nexport const createZhihuQuotaTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('quota', options)\nexport const ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES = [\n createZhihuQuestionRecommendationsTool, createZhihuQuestionAnswersTool,\n createZhihuUserContentDetailTool, createZhihuUserContentCommentsTool,\n createZhihuCreatorAccountStatsTool, createZhihuCreatorContentStatsTool, createZhihuQuotaTool,\n] as const\n","import type { Context } from '@deepseek-ai/cordis'\nimport type { ZhihuService } from './index.ts'\nimport { createZhihuSearchTool, createZhihuGlobalSearchTool, createZhihuHotListTool, createZhihuAskTool, createZhihuKnowledgeSearchTool } from './tool-definitions.ts'\nimport { ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES } from './open-platform-tools.ts'\nexport const name = 'dsh-zhihu-tools'\nexport const inject = ['zhihu', 'tools'] as const\nexport function apply(ctx: Context): void {\n const host = ctx as Context & { zhihu: ZhihuService; tools: { register: (tool: unknown) => unknown } }\n const options = host.zhihu.toolOptions\n for (const create of [createZhihuSearchTool, createZhihuGlobalSearchTool, createZhihuHotListTool, createZhihuAskTool, createZhihuKnowledgeSearchTool, ...ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES]) {\n const tool = create(options)\n const execute = tool.execute as unknown as (args: unknown, exec: { signal: AbortSignal }) => Promise<unknown>\n host.tools.register({ ...tool, execute: (args: unknown, exec: { signal: AbortSignal }) =>\n host.zhihu.run(signal => execute(args, { ...exec, signal }), exec.signal) })\n }\n}\n"],"mappings":";;;;AAsBA,MAAM,qBAAqB;CACzB,MAAM;CACN,sBAAsB;CACtB,YAAY;EACV,OAAO;GAAE,MAAM;GAAU,UAAU;EAAK;EACxC,MAAM;GAAE,MAAM;GAAU,UAAU;EAAK;EACvC,KAAK;GAAE,MAAM;GAAU,UAAU;EAAK;EACtC,SAAS;GAAE,MAAM;GAAU,UAAU;EAAK;EAC1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,CAAC,GAAG,KAAK,MAAM;EAAE,CAAC;CAC/E;AACF"}
|
|
1
|
+
{"version":3,"file":"tools.js","names":[],"sources":["../src/tool-definitions.ts","../src/open-platform-render.ts","../src/open-platform-tools.ts","../src/sync-tools.ts","../src/tools.ts"],"sourcesContent":["import { defineTool } from '@deepseek-ai/dsh-tools'\nimport { reportExecuted, type ZhihuClientOptions } from './zhihu-client.ts'\nimport { ZHIHU_SEARCH_TOOL_NAME, ZHIHU_GLOBAL_SEARCH_TOOL_NAME, ZHIHU_HOT_LIST_TOOL_NAME, ZHIHU_ASK_TOOL_NAME, ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME } from './contracts.ts'\nimport { executeZhihuSearch, renderZhihuSearch, ZHIHU_SEARCH_DEFAULT_COUNT, ZHIHU_SEARCH_MAX_COUNT, type ZhihuSearchResult } from './search-api.ts'\nimport {\n ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT, ZHIHU_GLOBAL_SEARCH_MAX_COUNT,\n ZHIHU_HOT_LIST_DEFAULT_LIMIT, ZHIHU_HOT_LIST_MAX_LIMIT,\n ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT, ZHIHU_KNOWLEDGE_SEARCH_MAX_LIMIT,\n ZHIHU_ASK_MODELS, ZHIHU_ASK_DEFAULT_MODEL, ZHIHU_RECALL_SCOPES,\n executeZhihuGlobalSearch, renderZhihuGlobalSearch,\n executeZhihuHotList, renderZhihuHotList,\n executeZhihuAsk, renderZhihuAsk,\n normalizeRecallScopes, executeZhihuKnowledgeSearch, renderZhihuKnowledgeSearch,\n type ZhihuAskModel, type ZhihuToolOptions, type ZhihuGlobalSearchDb,\n type ZhihuGlobalSearchResult, type ZhihuHotListResult, type ZhihuAskResult,\n type ZhihuKnowledgeSearchResult,\n} from './operations.ts'\nexport type CreateZhihuSearchToolOptions = ZhihuClientOptions & {\n /** Best-effort metering hook; invoked after every execution, failures included. */\n onExecuted?: (event: { ok: boolean; results: number }) => void\n}\n\nconst SEARCH_ITEM_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n type: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n votes: { type: 'integer', required: true },\n comments: { type: 'integer', required: true },\n author: { type: 'string', required: true },\n authority: { type: 'string', required: true },\n editTime: { type: 'string', required: true },\n },\n} as const\n\nexport function createZhihuSearchTool(options: CreateZhihuSearchToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_SEARCH_TOOL_NAME,\n description: '知乎站内搜索(GET /api/v1/content/zhihu_search),取社区证据;仅作社区/读者反馈参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '搜索词,2-100 字符。' },\n count: { type: 'integer', description: `返回条数,1-${ZHIHU_SEARCH_MAX_COUNT},默认 ${ZHIHU_SEARCH_DEFAULT_COUNT}。` },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n count: { type: 'integer', required: true },\n items: {\n type: 'array',\n required: true,\n items: SEARCH_ITEM_SCHEMA,\n },\n emptyReason: { type: 'string' },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuSearch(value as ZhihuSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; count?: number }\n try {\n const result = await executeZhihuSearch(typed.query, typed.count ?? ZHIHU_SEARCH_DEFAULT_COUNT, {\n ...client,\n signal: exec.signal,\n })\n reportExecuted(onExecuted, { ok: true, results: result.items.length })\n return result\n } catch (error) {\n reportExecuted(onExecuted, { ok: false, results: 0 })\n throw error\n }\n },\n })\n}\n\nconst OTHER_SEARCH_ITEM_SCHEMA = {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n type: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n votes: { type: 'integer', required: true },\n comments: { type: 'integer', required: true },\n author: { type: 'string', required: true },\n authority: { type: 'string', required: true },\n editTime: { type: 'string', required: true },\n },\n} as const\n\n/** 包一层计量:成功报 results,失败报 ok:false 再原样抛出。 */\nasync function metered<T>(onExecuted: ZhihuToolOptions['onExecuted'], run: () => Promise<T>, results: (value: T) => number): Promise<T> {\n try {\n const value = await run()\n reportExecuted(onExecuted, { ok: true, results: results(value) })\n return value\n } catch (error) {\n reportExecuted(onExecuted, { ok: false, results: 0 })\n throw error\n }\n}\n\nexport function createZhihuGlobalSearchTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_GLOBAL_SEARCH_TOOL_NAME,\n description: '知乎开放平台全网搜索(GET /api/v1/content/global_search),检索站外公开网页资料;仅作参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '搜索词,2-100 字符。' },\n count: { type: 'integer', description: `返回条数,1-${ZHIHU_GLOBAL_SEARCH_MAX_COUNT},默认 ${ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT}。` },\n searchDb: { type: 'string', description: '检索库:all(默认)、realtime(实时)、static(静态)。' },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n count: { type: 'integer', required: true },\n searchDb: { type: 'string', required: true },\n items: { type: 'array', required: true, items: OTHER_SEARCH_ITEM_SCHEMA },\n emptyReason: { type: 'string' },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuGlobalSearch(value as ZhihuGlobalSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; count?: number; searchDb?: string }\n const searchDb: ZhihuGlobalSearchDb = typed.searchDb === 'realtime' || typed.searchDb === 'static' ? typed.searchDb : 'all'\n return await metered(onExecuted, () => executeZhihuGlobalSearch(\n typed.query,\n typed.count ?? ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT,\n searchDb,\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n\nexport function createZhihuHotListTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_HOT_LIST_TOOL_NAME,\n description: '知乎热榜(GET /api/v1/content/hot_list),了解当前社区热点;仅作题材参考,不构成 canon,不写入项目文件。',\n parameters: {\n limit: { type: 'integer', description: `返回条数,1-${ZHIHU_HOT_LIST_MAX_LIMIT},默认 ${ZHIHU_HOT_LIST_DEFAULT_LIMIT}。` },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n limit: { type: 'integer', required: true },\n items: {\n type: 'array',\n required: true,\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n title: { type: 'string', required: true },\n url: { type: 'string', required: true },\n summary: { type: 'string', required: true },\n },\n },\n },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuHotList(value as ZhihuHotListResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { limit?: number }\n return await metered(onExecuted, () => executeZhihuHotList(\n typed.limit ?? ZHIHU_HOT_LIST_DEFAULT_LIMIT,\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n\nexport function createZhihuAskTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_ASK_TOOL_NAME,\n description: '知乎直答(POST /v1/chat/completions,OpenAI 兼容),基于社区内容生成综合回答,适合考据与背景调研;仅作参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '要问的问题。' },\n model: { type: 'string', description: 'zhida-thinking-1p5(默认,带思考过程)、zhida-fast-1p5(快,仅适合简单事实查询)或 zhida-agent(最慢最强,仅在明确要求时使用)。fast/thinking 仅在免费额度足够时允许;付费模式拒绝未确认计费的模型。' },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n model: { type: 'string', required: true },\n content: { type: 'string', required: true },\n reasoning: { type: 'string', required: true },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuAsk(value as ZhihuAskResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; model?: string }\n const model: ZhihuAskModel = (ZHIHU_ASK_MODELS as readonly string[]).includes(typed.model ?? '')\n ? (typed.model as ZhihuAskModel)\n : ZHIHU_ASK_DEFAULT_MODEL\n return await metered(onExecuted, () => executeZhihuAsk(\n typed.query,\n model,\n { ...client, signal: exec.signal },\n ), (result) => (result.content ? 1 : 0))\n },\n })\n}\n\nexport function createZhihuKnowledgeSearchTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_KNOWLEDGE_SEARCH_TOOL_NAME,\n description: '知乎知识库检索(POST /api/v1/knowledge/search,RAG 片段),默认只查公开库;网页端上传过资料后可加 personal/subscription 召回;仅作背景参考,不构成 canon,不写入项目文件。',\n parameters: {\n query: { type: 'string', required: true, description: '检索词。' },\n limit: { type: 'integer', description: `返回条数,1-${ZHIHU_KNOWLEDGE_SEARCH_MAX_LIMIT},默认 ${ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT}。` },\n recallScopes: {\n type: 'array',\n description: '召回范围:public(公开库,默认)、personal(个人库)、subscription(订阅库),可多选。',\n items: { type: 'string', enum: [...ZHIHU_RECALL_SCOPES] },\n },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n query: { type: 'string', required: true },\n limit: { type: 'integer', required: true },\n recallScopes: { type: 'array', required: true, items: { type: 'string' } },\n items: {\n type: 'array',\n required: true,\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n docName: { type: 'string', required: true },\n originUrl: { type: 'string', required: true },\n snippets: { type: 'array', required: true, items: { type: 'string' } },\n },\n },\n },\n },\n },\n render(_args, value) {\n return [{ type: 'text' as const, text: renderZhihuKnowledgeSearch(value as ZhihuKnowledgeSearchResult) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { query: string; limit?: number; recallScopes?: unknown }\n return await metered(onExecuted, () => executeZhihuKnowledgeSearch(\n typed.query,\n typed.limit ?? ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT,\n normalizeRecallScopes(typed.recallScopes),\n { ...client, signal: exec.signal },\n ), (result) => result.items.length)\n },\n })\n}\n","import { ZHIHU_OPEN_PLATFORM_APIS, type ZhihuOpenPlatformResult } from './open-platform.ts'\n\n/** Display only: the structured result always retains the original upstream HTML. */\nexport function plainZhihuText(value: string): string {\n const entities: Record<string, string> = { amp: '&', lt: '<', gt: '>', quot: '\"', apos: \"'\", nbsp: ' ' }\n const decoded = value.replace(/&(#x[\\da-f]+|#\\d+|amp|lt|gt|quot|apos|nbsp);/gi, (match, entity: string) => {\n if (!entity.startsWith('#')) return entities[entity.toLowerCase()] ?? match\n const hex = entity[1]?.toLowerCase() === 'x'\n const point = Number.parseInt(entity.slice(hex ? 2 : 1), hex ? 16 : 10)\n return point >= 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff) ? String.fromCodePoint(point) : '\\ufffd'\n })\n return decoded\n .replace(/<(script|style)\\b[^>]*>[\\s\\S]*?(?:<\\/\\1\\s*>|$)/gi, '')\n .replace(/<!--[^]*?(?:-->|$)/g, '')\n .replace(/<br\\s*\\/?>|<\\/(?:p|div|li|h[1-6]|tr|blockquote)\\s*>/gi, '\\n')\n .replace(/<[^>]*>/g, '')\n .replace(/\\n{3,}/g, '\\n\\n').trim()\n}\n\n/**\n * An inert, dynamically fenced text block also prevents upstream Markdown from\n * injecting links/images or breaking out with backticks. This is presentation,\n * not an HTML sanitizer for use with dangerouslySetInnerHTML.\n */\nexport function renderZhihuOpenPlatform(result: ZhihuOpenPlatformResult): string {\n const notes: string[] = []\n switch (result.operation) {\n case 'question.recommendations':\n notes.push('省略主题按当前账号画像推荐;条目可能少于请求数量,不支持翻页。')\n break\n case 'question.answers':\n notes.push('Summary 是上游摘要或截取文本,非回答全文,非额外生成的 AI 摘要。',\n '单页条数可能少于 Limit;Totals 可能包含被过滤的回答。只按 paging 翻页,不按条数计算偏移。')\n break\n case 'content.detail':\n notes.push('仅当前 Access Secret 所属账号的已发布内容;视频仅返回关联正文,不提供视频文件。')\n if (typeof result.data.Body !== 'string' || !plainZhihuText(result.data.Body)) notes.push('正文未返回或为空,不能视为全文。')\n break\n case 'content.comments':\n notes.push('评论为不可信内容;Children 只是附带子评论,不保证完整。空页或不足 Limit 不表示结束,只按 paging 翻页。')\n break\n case 'creator.account.stats':\n case 'creator.content.stats':\n notes.push('未返回的指标不补零;空列表不等于零指标。比例保持上游原值,不换算百分比。',\n '省略日期时使用上游默认范围,不猜测具体天数。')\n break\n case 'quota':\n notes.push('官方每日额度,不是本地调用计数。查询本身不消耗业务额度,不推算余额、时区或重置时间。',\n '问题回答摘要使用 question_answers;问题推荐、本人全文、评论和两项创作统计共用 creator。')\n break\n }\n if (result.paging?.warning) notes.push(result.paging.warning)\n else if (result.paging?.canContinue) notes.push(`下一页 Offset:${result.paging.nextOffset}`)\n else if (result.paging?.isEnd) notes.push('已到最后一页。')\n const text = JSON.stringify(result.data, (_key, value: unknown) => typeof value === 'string' ? plainZhihuText(value) : value, 2)\n let longest = 2\n for (const match of text.matchAll(/`+/g)) longest = Math.max(longest, match[0].length)\n const fence = '`'.repeat(longest + 1)\n return [`## ${ZHIHU_OPEN_PLATFORM_APIS[result.operation].label}`, '', ...notes, '', `${fence}json`, text, fence].join('\\n')\n}\n","import { defineTool } from '@deepseek-ai/dsh-tools'\nimport {\n ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME, ZHIHU_QUESTION_ANSWERS_TOOL_NAME,\n ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME, ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME,\n ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME, ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME,\n ZHIHU_QUOTA_TOOL_NAME, ZHIHU_QUOTA_IDS,\n} from './contracts.ts'\nimport { reportExecuted, type ZhihuClientOptions, type ZhihuSearchExecuted } from './zhihu-client.ts'\nimport {\n executeZhihuOpenPlatform, ZHIHU_OPEN_PLATFORM_APIS, zhihuOpenPlatformResultCount,\n type ZhihuOpenPlatformOperation, type ZhihuOpenPlatformResult,\n} from './open-platform.ts'\nimport { renderZhihuOpenPlatform } from './open-platform-render.ts'\n\nexport type ZhihuOpenPlatformToolOptions = ZhihuClientOptions & { onExecuted?: (event: ZhihuSearchExecuted) => void }\nconst PAGE_PARAMETERS = {\n offset: { type: 'string', description: '非负 Int64 十进制字符串,默认 \"0\"。下一页只用 paging.nextOffset,不按条数推算,不接受不透明游标。' },\n limit: { type: 'integer', description: '每页数量,1-50,默认 20。单页不足或为空不表示结束。' },\n} as const\nconst DATE_PARAMETERS = {\n startDate: { type: 'string', description: 'YYYY-MM-DD,必须与 endDate 同时提供。省略两者使用上游默认范围,不猜测天数。' },\n endDate: { type: 'string', description: 'YYYY-MM-DD,不得早于 startDate。' },\n} as const\nconst CONTENT_URL = { type: 'string', required: true, description: '当前账号已发布内容的 HTTPS 知乎回答、专栏文章、想法或视频链接;不是任意网页抓取。' } as const\n\nconst DEFINITIONS = {\n 'question.recommendations': {\n name: ZHIHU_QUESTION_RECOMMENDATIONS_TOOL_NAME,\n description: '推荐适合当前账号回答的问题;省略主题按画像推荐,条目可能少于 Count,不支持分页。使用 question_discovery 额度;免费模式须有足够额度,付费模式因计费未确认而阻止。',\n parameters: {\n query: { type: 'string', description: '可选主题;不传才按画像推荐,空白字符串无效。' },\n count: { type: 'integer', description: '推荐数量,1-20,默认 5。' },\n },\n },\n 'question.answers': {\n name: ZHIHU_QUESTION_ANSWERS_TOOL_NAME,\n description: '读取问题下的回答摘要,非全文,也非新生成的 AI 摘要。一次一页,只有 paging.canContinue=true 时才用 nextOffset。使用 question_discovery 额度。',\n parameters: {\n questionUrl: { type: 'string', required: true, description: 'https://www.zhihu.com/question/{id} 形式的问题链接。' },\n ...PAGE_PARAMETERS,\n },\n },\n 'content.detail': {\n name: ZHIHU_USER_CONTENT_DETAIL_TOOL_NAME,\n description: '读取当前账号已发布创作的全文。不能读其他账号全文;视频只给关联正文。空正文不能视为全文。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL },\n },\n 'content.comments': {\n name: ZHIHU_USER_CONTENT_COMMENTS_TOOL_NAME,\n description: '读取当前账号创作下的根评论及附带 Children;子评论不保证完整。一次一页,只按 paging 翻页,不按条数判断结束。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL, ...PAGE_PARAMETERS, order: { type: 'string', enum: ['score', 'reverse', 'ascending'], description: '排序,默认 score。' } },\n },\n 'creator.account.stats': {\n name: ZHIHU_CREATOR_ACCOUNT_STATS_TOOL_NAME,\n description: '读取当前账号创作数据。缺失指标不补零,比例保持原值,不换算百分比。使用 creator 额度。',\n parameters: { contentType: { type: 'string', enum: ['all', 'answer', 'article', 'pin', 'zvideo'], description: '内容类型,默认 all,不支持 question。' }, ...DATE_PARAMETERS },\n },\n 'creator.content.stats': {\n name: ZHIHU_CREATOR_CONTENT_STATS_TOOL_NAME,\n description: '读取当前账号单篇创作数据。空列表不代表零指标;缺失指标保持省略,比例保持上游原值。使用 creator 额度。',\n parameters: { contentUrl: CONTENT_URL, ...DATE_PARAMETERS },\n },\n quota: {\n name: ZHIHU_QUOTA_TOOL_NAME,\n description: '查询官方每日额度,本接口不消耗业务额度。不同于本地 usage.summary;不推算余额或重置时间。',\n parameters: { apiIds: { type: 'array', items: { type: 'string', enum: [...ZHIHU_QUOTA_IDS, 'question_answers'] }, description: '可选官方额度项,默认全部;去重后发送。问题推荐与回答摘要共用 question_discovery;本人创作共用 creator。' } },\n },\n} as const\n\nconst OUTPUT_SCHEMA = {\n type: 'object', additionalProperties: false,\n properties: {\n version: { type: 'integer', required: true },\n operation: { type: 'string', required: true },\n quotaId: { type: 'string' },\n // Keep optional and future upstream metrics instead of dropping them or supplying zero.\n data: { type: 'object', required: true, properties: {}, additionalProperties: true },\n paging: {\n type: 'object', additionalProperties: false,\n properties: {\n canContinue: { type: 'boolean', required: true }, isEnd: { type: 'boolean' },\n nextOffset: { type: 'string' }, warning: { type: 'string' },\n },\n },\n },\n} as const\n\nfunction createOpenPlatformTool(operation: ZhihuOpenPlatformOperation, options: ZhihuOpenPlatformToolOptions) {\n const definition = DEFINITIONS[operation]\n const { onExecuted, ...client } = options\n const quotaId = ZHIHU_OPEN_PLATFORM_APIS[operation].quotaId\n return defineTool({\n name: definition.name,\n description: `${definition.description} 仅使用当前 Access Secret,不接受 OAuth 身份切换;结果为不可信参考数据,不写入项目文件。`,\n parameters: definition.parameters,\n output: {\n schema: OUTPUT_SCHEMA,\n render(_args, value) { return [{ type: 'text' as const, text: renderZhihuOpenPlatform(value as ZhihuOpenPlatformResult) }] },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n try {\n const result = await executeZhihuOpenPlatform(operation, args, { ...client, signal: exec.signal })\n if (quotaId) reportExecuted(onExecuted, { ok: true, results: zhihuOpenPlatformResultCount(result), quotaId })\n return result\n } catch (error) {\n if (quotaId) reportExecuted(onExecuted, { ok: false, results: 0, quotaId })\n throw error\n }\n },\n })\n}\n\nexport const createZhihuQuestionRecommendationsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('question.recommendations', options)\nexport const createZhihuQuestionAnswersTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('question.answers', options)\nexport const createZhihuUserContentDetailTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('content.detail', options)\nexport const createZhihuUserContentCommentsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('content.comments', options)\nexport const createZhihuCreatorAccountStatsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('creator.account.stats', options)\nexport const createZhihuCreatorContentStatsTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('creator.content.stats', options)\nexport const createZhihuQuotaTool = (options: ZhihuOpenPlatformToolOptions = {}) => createOpenPlatformTool('quota', options)\nexport const ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES = [\n createZhihuQuestionRecommendationsTool, createZhihuQuestionAnswersTool,\n createZhihuUserContentDetailTool, createZhihuUserContentCommentsTool,\n createZhihuCreatorAccountStatsTool, createZhihuCreatorContentStatsTool, createZhihuQuotaTool,\n] as const\n","import { defineTool } from '@deepseek-ai/dsh-tools'\nimport type { ZhihuService } from './index.ts'\nimport type { ZhihuJsonValue } from './open-platform.ts'\n\n/** Publishing is a human confirmation action in the preview pane. The tool can\n * prepare the same saved draft, but never receives a UI review ticket. */\nexport function createZhihuSyncTool(service: ZhihuService) {\n return defineTool({\n name: 'zhihu_sync',\n description: '管理知乎文章、提问和想法草稿,校验预览或上传配图。上传会将图片发送到知乎;实际发布需用户在预览界面确认,当前分支未提供发布界面。',\n parameters: {\n action: { type: 'string', enum: ['list', 'get', 'save', 'prepare', 'upload_image'], required: true },\n offset: { type: 'integer', description: 'list 分页位置;省略从头读取,后续使用返回的 nextOffset。' },\n id: { type: 'string', description: 'get、prepare 或更新草稿时填写已有 ID。' },\n expectedRevision: { type: 'integer', description: 'prepare 或更新时填写上次读取的 revision。' },\n image: { type: 'object', description: 'upload_image 时填写图片内容。', properties: {\n fileName: { type: 'string', required: true },\n contentBase64: { type: 'string', required: true, description: 'JPEG、PNG、GIF、WebP 或 BMP 的标准 base64。GIF最大15 MB,其他最大30 MB。' },\n scene: { type: 'string', required: true, enum: ['article', 'question', 'pin'] },\n }, additionalProperties: false },\n draft: {\n type: 'object', description: 'save 时提供完整草稿;只做格式适配,不自动删改正文。',\n properties: {\n type: { type: 'string', enum: ['article', 'question', 'pin'], required: true },\n title: { type: 'string', required: true },\n body: { type: 'string', required: true },\n format: { type: 'string', enum: ['markdown', 'html'], required: true },\n images: { type: 'array', description: '已上传的知乎图片;本地图片请通过 upload_image 上传后引用。', items: {\n type: 'object', properties: {\n url: { type: 'string', required: true }, originalUrl: { type: 'string', description: '正文中的原始图片引用。' },\n width: { type: 'number' }, height: { type: 'number' }, watermark: { type: 'boolean' }, mediaId: { type: 'string' },\n }, additionalProperties: false,\n } },\n linkCard: { type: 'object', description: '想法的独立链接卡片,与图片互斥。', properties: {\n url: { type: 'string', required: true }, title: { type: 'string' }, cover: { type: 'string' },\n }, additionalProperties: false },\n settings: { type: 'object', properties: {\n commentPermission: { type: 'string', enum: ['all', 'nobody', 'followee', 'censor', 'follower', 'follower_n_days'] },\n creationStatement: { type: 'string', enum: ['spoiler', 'medical_advice', 'fictional_creation', 'contain_finance', 'ai_creation'] },\n tableOfContentsEnabled: { type: 'boolean' },\n topics: { type: 'array', items: { type: 'string' }, description: '用户提供的知乎话题链接,文章最多3个,提问最多5个。' },\n ring: { type: 'string', description: '想法的知乎圈子链接。' },\n }, additionalProperties: false },\n },\n additionalProperties: false,\n },\n },\n output: {\n schema: { type: 'object', additionalProperties: true, properties: {} },\n render(_args, value) { return [{ type: 'text' as const, text: JSON.stringify(value) }] },\n },\n isConcurrencySafe(args) { return args.action === 'list' || args.action === 'get' },\n async execute(args, exec) {\n if (!service.syncCall) throw new Error('知乎同步服务未启用。')\n if (args.action === 'upload_image') {\n return await service.syncCall('sync.media.upload', args.image, exec.signal, 'tool') as Record<string, ZhihuJsonValue>\n }\n const result = await service.syncCall(`sync.${args.action}`, {\n ...(args.offset === undefined ? {} : { offset: args.offset }),\n ...(args.id === undefined ? {} : { id: args.id }),\n ...(args.expectedRevision === undefined ? {} : { expectedRevision: args.expectedRevision }),\n ...(args.draft === undefined ? {} : { draft: args.draft }),\n }, exec.signal, 'tool')\n return result as Record<string, ZhihuJsonValue>\n },\n })\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport type { ZhihuService } from './index.ts'\nimport { createZhihuSearchTool, createZhihuGlobalSearchTool, createZhihuHotListTool, createZhihuAskTool, createZhihuKnowledgeSearchTool } from './tool-definitions.ts'\nimport { ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES } from './open-platform-tools.ts'\nimport { createZhihuSyncTool } from './sync-tools.ts'\nexport const name = 'dsh-zhihu-tools'\nexport const inject = ['zhihu', 'tools'] as const\nexport function apply(ctx: Context): void {\n const host = ctx as Context & { zhihu: ZhihuService; tools: { register: (tool: unknown) => unknown } }\n const options = host.zhihu.toolOptions\n if (host.zhihu.syncCall) host.tools.register(createZhihuSyncTool(host.zhihu))\n for (const create of [createZhihuSearchTool, createZhihuGlobalSearchTool, createZhihuHotListTool, createZhihuAskTool, createZhihuKnowledgeSearchTool, ...ZHIHU_OPEN_PLATFORM_TOOL_FACTORIES]) {\n const tool = create(options)\n const execute = tool.execute as unknown as (args: unknown, exec: { signal: AbortSignal }) => Promise<unknown>\n host.tools.register({ ...tool, execute: (args: unknown, exec: { signal: AbortSignal }) =>\n host.zhihu.run(signal => execute(args, { ...exec, signal }), exec.signal) })\n }\n}\n"],"mappings":";;;;AAsBA,MAAM,qBAAqB;CACzB,MAAM;CACN,sBAAsB;CACtB,YAAY;EACV,OAAO;GAAE,MAAM;GAAU,UAAU;EAAK;EACxC,MAAM;GAAE,MAAM;GAAU,UAAU;EAAK;EACvC,KAAK;GAAE,MAAM;GAAU,UAAU;EAAK;EACtC,SAAS;GAAE,MAAM;GAAU,UAAU;EAAK;EAC1C,OAAO;GAAE,MAAM;GAAW,UAAU;EAAK;EACzC,UAAU;GAAE,MAAM;GAAW,UAAU;EAAK;EAC5C,QAAQ;GAAE,MAAM;GAAU,UAAU;EAAK;EACzC,WAAW;GAAE,MAAM;GAAU,UAAU;EAAK;EAC5C,UAAU;GAAE,MAAM;GAAU,UAAU;EAAK;CAC7C;AACF;AAEA,SAAgB,sBAAsB,UAAwC,CAAC,GAAG;CAChF,MAAM,EAAE,YAAY,GAAG,WAAW;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HANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarkxy/dsh-zhihu",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Zhihu search, agent tools, knowledge bases,
|
|
3
|
+
"version": "0.2.8",
|
|
4
|
+
"description": "Zhihu search, agent tools, knowledge bases, usage tracking, and draft management for DeepSeek Harness.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"type": "module",
|
|
@@ -95,8 +95,10 @@
|
|
|
95
95
|
"test": "vitest run --root ../.. --config vitest.editor-plugins.config.ts --maxWorkers=2 plugins/dsh-zhihu/src"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
+
"marked": "^18.0.14",
|
|
99
|
+
"parse5": "^8.0.1",
|
|
98
100
|
"zod": "^4.1.5",
|
|
99
|
-
"@klarkxy/dsh-plugin-kit": "0.
|
|
101
|
+
"@klarkxy/dsh-plugin-kit": "0.5.0"
|
|
100
102
|
},
|
|
101
103
|
"peerDependencies": {
|
|
102
104
|
"@deepseek-ai/cordis": ">=4.0.4",
|
|
@@ -153,6 +155,6 @@
|
|
|
153
155
|
"registry": "https://registry.npmjs.org/"
|
|
154
156
|
},
|
|
155
157
|
"dshRelease": {
|
|
156
|
-
"contentHash": "
|
|
158
|
+
"contentHash": "f52f84d9285e71a24a27c7e6882efb0ecb43b59dd09778cc3edac926886c7fc0"
|
|
157
159
|
}
|
|
158
160
|
}
|