@klarkxy/dsh-zhihu 0.2.10 → 0.3.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/README.md +2 -7
- package/docs/README.zh-CN.md +2 -7
- package/lib/client.js +3 -1
- package/lib/contracts.d.ts +5 -13
- package/lib/contracts.js +5 -13
- package/lib/contracts.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/open-platform.js.map +1 -1
- package/lib/tools.js +165 -578
- package/lib/tools.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +17 -10
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/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;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,MAAM,SAAS,oBAAoB,KAAK,KAAK,CAAC;CAC5E,KAAK,MAAM,UAAU;EAAC;EAAuB;EAA6B;EAAwB;EAAoB;EAAgC,GAAG;CAAkC,GAAG;EAC5L,MAAM,OAAO,OAAO,OAAO;EAC3B,MAAM,UAAU,KAAK;EACrB,KAAK,MAAM,SAAS;GAAE,GAAG;GAAM,UAAU,MAAe,SACtD,KAAK,MAAM,KAAI,WAAU,QAAQ,MAAM;IAAE,GAAG;IAAM;GAAO,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, ZhihuSearchError, type ZhihuClientOptions } from './zhihu-client.ts'\nimport { ZHIHU_RESEARCH_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 ZHIHU_RESEARCH_ACTIONS = ['search', 'global_search', 'hot_list', 'ask', 'knowledge_search'] as const\nexport type ZhihuResearchAction = (typeof ZHIHU_RESEARCH_ACTIONS)[number]\n\n/** 合并前的五个检索工具各自执行逻辑不变,这里只按 action 分发。 */\nfunction executeResearch(\n action: ZhihuResearchAction,\n args: { query?: string; count?: number; limit?: number; searchDb?: string; model?: string; recallScopes?: unknown },\n client: ZhihuClientOptions,\n signal: AbortSignal,\n): Promise<{ result: ZhihuSearchResult | ZhihuGlobalSearchResult | ZhihuHotListResult | ZhihuAskResult | ZhihuKnowledgeSearchResult; results: number }> {\n const options = { ...client, signal }\n if (action === 'search') {\n return executeZhihuSearch(args.query!, args.count ?? ZHIHU_SEARCH_DEFAULT_COUNT, options)\n .then(result => ({ result, results: result.items.length }))\n }\n if (action === 'global_search') {\n const searchDb: ZhihuGlobalSearchDb = args.searchDb === 'realtime' || args.searchDb === 'static' ? args.searchDb : 'all'\n return executeZhihuGlobalSearch(args.query!, args.count ?? ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT, searchDb, options)\n .then(result => ({ result, results: result.items.length }))\n }\n if (action === 'hot_list') {\n return executeZhihuHotList(args.limit ?? ZHIHU_HOT_LIST_DEFAULT_LIMIT, options)\n .then(result => ({ result, results: result.items.length }))\n }\n if (action === 'ask') {\n const model: ZhihuAskModel = (ZHIHU_ASK_MODELS as readonly string[]).includes(args.model ?? '')\n ? (args.model as ZhihuAskModel)\n : ZHIHU_ASK_DEFAULT_MODEL\n return executeZhihuAsk(args.query!, model, options).then(result => ({ result, results: result.content ? 1 : 0 }))\n }\n return executeZhihuKnowledgeSearch(args.query!, args.limit ?? ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT, normalizeRecallScopes(args.recallScopes), options)\n .then(result => ({ result, results: result.items.length }))\n}\n\nfunction renderResearch(action: ZhihuResearchAction, value: unknown): string {\n if (action === 'search') return renderZhihuSearch(value as ZhihuSearchResult)\n if (action === 'global_search') return renderZhihuGlobalSearch(value as ZhihuGlobalSearchResult)\n if (action === 'hot_list') return renderZhihuHotList(value as ZhihuHotListResult)\n if (action === 'ask') return renderZhihuAsk(value as ZhihuAskResult)\n return renderZhihuKnowledgeSearch(value as ZhihuKnowledgeSearchResult)\n}\n\nexport function createZhihuResearchTool(options: ZhihuToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_RESEARCH_TOOL_NAME,\n description:\n '知乎调研检索与问答,结果仅作社区参考,不构成 canon,不写入项目文件。' +\n 'action:search 站内;global_search 站外;hot_list 热榜;ask 直答;knowledge_search 知识库。',\n parameters: {\n action: { type: 'string', enum: ZHIHU_RESEARCH_ACTIONS, required: true },\n query: { type: 'string', description: '检索词,2-100 字符;除 hot_list 外必填。' },\n count: { type: 'integer', description: `search 1-${ZHIHU_SEARCH_MAX_COUNT}(默认 ${ZHIHU_SEARCH_DEFAULT_COUNT})、global_search 1-${ZHIHU_GLOBAL_SEARCH_MAX_COUNT}(默认 ${ZHIHU_GLOBAL_SEARCH_DEFAULT_COUNT})。` },\n limit: { type: 'integer', description: `hot_list 1-${ZHIHU_HOT_LIST_MAX_LIMIT}(默认 ${ZHIHU_HOT_LIST_DEFAULT_LIMIT})、knowledge_search 1-${ZHIHU_KNOWLEDGE_SEARCH_MAX_LIMIT}(默认 ${ZHIHU_KNOWLEDGE_SEARCH_DEFAULT_LIMIT})。` },\n searchDb: { type: 'string', enum: ['all', 'realtime', 'static'], description: 'global_search 检索库,默认 all。' },\n model: { type: 'string', description: 'ask 模型:zhida-thinking-1p5(默认,带思考)、zhida-fast-1p5(简单事实)、zhida-agent(最慢最强,仅明确要求时用);免费额度不足被拒绝。' },\n recallScopes: { type: 'array', description: 'knowledge_search 召回范围,默认 public;可加 personal/subscription。', items: { type: 'string', enum: [...ZHIHU_RECALL_SCOPES] } },\n },\n output: {\n schema: {\n type: 'object',\n additionalProperties: true,\n properties: {},\n },\n render(args, value) {\n return [{ type: 'text' as const, text: renderResearch((args as { action: ZhihuResearchAction }).action, value) }]\n },\n },\n isConcurrencySafe() { return true },\n async execute(args, exec) {\n const typed = args as { action: ZhihuResearchAction; query?: string; count?: number; limit?: number; searchDb?: string; model?: string; recallScopes?: unknown }\n if (typed.action !== 'hot_list' && (typeof typed.query !== 'string' || !typed.query.trim())) {\n throw new ZhihuSearchError('INVALID_ARGUMENTS', `action ${typed.action} 需要 query 参数。`)\n }\n try {\n const { result, results } = await executeResearch(typed.action, typed, client, exec.signal)\n reportExecuted(onExecuted, { ok: true, results })\n return result\n } catch (error) {\n reportExecuted(onExecuted, { ok: false, results: 0 })\n throw error\n }\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 { ZHIHU_ACCOUNT_TOOL_NAME, ZHIHU_QUOTA_IDS } from './contracts.ts'\nimport { reportExecuted, ZhihuSearchError, 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 }\n\nconst ZHIHU_ACCOUNT_ACTIONS = {\n question_recommendations: 'question.recommendations',\n question_answers: 'question.answers',\n content_detail: 'content.detail',\n content_comments: 'content.comments',\n creator_account_stats: 'creator.account.stats',\n creator_content_stats: 'creator.content.stats',\n quota: 'quota',\n} as const\nexport type ZhihuAccountAction = keyof typeof ZHIHU_ACCOUNT_ACTIONS\n\nconst REQUIRED: Record<ZhihuAccountAction, string> = {\n question_recommendations: '主题 query 可选;省略按画像推荐。',\n question_answers: 'questionUrl 必填。',\n content_detail: 'contentUrl 必填。',\n content_comments: 'contentUrl 必填。',\n creator_account_stats: 'contentType 与日期可选。',\n creator_content_stats: 'contentUrl 必填。',\n quota: 'apiIds 可选。',\n}\n\nexport function createZhihuAccountTool(options: ZhihuOpenPlatformToolOptions = {}) {\n const { onExecuted, ...client } = options\n return defineTool({\n name: ZHIHU_ACCOUNT_TOOL_NAME,\n description:\n '知乎账号数据(Access Secret 鉴权,拒绝 OAuth 切换;结果仅参考,不写入项目文件)。' +\n 'action:question_recommendations 问题推荐;question_answers 回答摘要;content_detail 创作全文;content_comments 评论;creator_account_stats 账号数据;creator_content_stats 单篇数据;quota 额度。',\n parameters: {\n action: { type: 'string', enum: Object.keys(ZHIHU_ACCOUNT_ACTIONS), required: true },\n query: { type: 'string', description: 'question_recommendations 主题;省略按画像推荐。' },\n count: { type: 'integer', description: 'question_recommendations 数量,1-20,默认 5。' },\n questionUrl: { type: 'string', description: 'question_answers 必填,https://www.zhihu.com/question/{id} 链接。' },\n contentUrl: { type: 'string', description: 'content_detail、content_comments、creator_content_stats 必填:本人已发布的 HTTPS 回答/专栏/想法/视频链接。' },\n offset: { type: 'string', description: 'question_answers、content_comments 分页,非负 Int64 字符串,默认 \"0\";翻页只用 paging.nextOffset。' },\n limit: { type: 'integer', description: 'question_answers、content_comments 每页条数,1-50,默认 20。' },\n order: { type: 'string', enum: ['score', 'reverse', 'ascending'], description: 'content_comments 排序,默认 score。' },\n contentType: { type: 'string', enum: ['all', 'answer', 'article', 'pin', 'zvideo'], description: 'creator_account_stats 内容类型,默认 all,不支持 question。' },\n startDate: { type: 'string', description: 'stats action 可选,YYYY-MM-DD,与 endDate 成对;都省略用上游默认范围。' },\n endDate: { type: 'string', description: 'YYYY-MM-DD,不得早于 startDate。' },\n apiIds: { type: 'array', items: { type: 'string', enum: [...ZHIHU_QUOTA_IDS, 'question_answers'] }, description: 'quota 可选额度项,默认全部。' },\n },\n output: {\n schema: { type: 'object', additionalProperties: true, properties: {} },\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 const input = args as { action: ZhihuAccountAction; questionUrl?: string; contentUrl?: string }\n const operation = ZHIHU_ACCOUNT_ACTIONS[input.action]\n if ((operation === 'question.answers' && !input.questionUrl) || ((operation === 'content.detail' || operation === 'content.comments' || operation === 'creator.content.stats') && !input.contentUrl)) {\n throw new ZhihuSearchError('INVALID_ARGUMENTS', `action ${input.action} 缺少必填参数:${REQUIRED[input.action]}`)\n }\n const quotaId = ZHIHU_OPEN_PLATFORM_APIS[operation].quotaId\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","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;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 { createZhihuResearchTool } from './tool-definitions.ts'\nimport { createZhihuAccountTool } 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 [createZhihuResearchTool, createZhihuAccountTool]) {\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,yBAAyB;CAAC;CAAU;CAAiB;CAAY;CAAO;AAAkB;;AAIhG,SAAS,gBACP,QACA,MACA,QACA,QACsJ;CACtJ,MAAM,UAAU;EAAE,GAAG;EAAQ;CAAO;CACpC,IAAI,WAAW,UACb,OAAO,mBAAmB,KAAK,OAAQ,KAAK,SAAA,GAAqC,OAAO,CAAC,CACtF,MAAK,YAAW;EAAE;EAAQ,SAAS,OAAO,MAAM;CAAO,EAAE;CAE9D,IAAI,WAAW,iBAAiB;EAC9B,MAAM,WAAgC,KAAK,aAAa,cAAc,KAAK,aAAa,WAAW,KAAK,WAAW;EACnH,OAAO,yBAAyB,KAAK,OAAQ,KAAK,SAAA,IAA4C,UAAU,OAAO,CAAC,CAC7G,MAAK,YAAW;GAAE;GAAQ,SAAS,OAAO,MAAM;EAAO,EAAE;CAC9D;CACA,IAAI,WAAW,YACb,OAAO,oBAAoB,KAAK,SAAA,IAAuC,OAAO,CAAC,CAC5E,MAAK,YAAW;EAAE;EAAQ,SAAS,OAAO,MAAM;CAAO,EAAE;CAE9D,IAAI,WAAW,OAAO;EACpB,MAAM,QAAwB,iBAAuC,SAAS,KAAK,SAAS,EAAE,IACzF,KAAK,QACN;EACJ,OAAO,gBAAgB,KAAK,OAAQ,OAAO,OAAO,CAAC,CAAC,MAAK,YAAW;GAAE;GAAQ,SAAS,OAAO,UAAU,IAAI;EAAE,EAAE;CAClH;CACA,OAAO,4BAA4B,KAAK,OAAQ,KAAK,SAAA,GAA+C,sBAAsB,KAAK,YAAY,GAAG,OAAO,CAAC,CACnJ,MAAK,YAAW;EAAE;EAAQ,SAAS,OAAO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QAAQ,SAAS,QAAQ,KAAK,UAAU;IAC3D,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;IAC3D,GAAI,KAAK,OAAO,KAAA,IAAY,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG;IAC/C,GAAI,KAAK,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB,KAAK,iBAAiB;IACzF,GAAI,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM;GAC1D,GAAG,KAAK,QAAQ,MAAM;EAExB;CACF,CAAC;AACH;;;AC7DA,MAAa,OAAO;AACpB,MAAa,SAAS,CAAC,SAAS,OAAO;AACvC,SAAgB,MAAM,KAAoB;CACxC,MAAM,OAAO;CACb,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,KAAK,MAAM,UAAU,KAAK,MAAM,SAAS,oBAAoB,KAAK,KAAK,CAAC;CAC5E,KAAK,MAAM,UAAU,CAAC,yBAAyB,sBAAsB,GAAG;EACtE,MAAM,OAAO,OAAO,OAAO;EAC3B,MAAM,UAAU,KAAK;EACrB,KAAK,MAAM,SAAS;GAAE,GAAG;GAAM,UAAU,MAAe,SACtD,KAAK,MAAM,KAAI,WAAU,QAAQ,MAAM;IAAE,GAAG;IAAM;GAAO,CAAC,GAAG,KAAK,MAAM;EAAE,CAAC;CAC/E;AACF"}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Zhihu",
|
|
4
|
-
"description": "Zhihu search,
|
|
4
|
+
"description": "Zhihu site and web search, hot list, Zhida AI answers, knowledge bases, question recommendations and answer summaries, published content and comments, creator stats, quota tracking, and draft sync with image uploads."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarkxy/dsh-zhihu",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Zhihu search,
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Zhihu site and web search, hot list, Zhida AI answers, knowledge bases, question recommendations and answer summaries, published content and comments, creator stats, quota tracking, and draft sync with image uploads.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"type": "module",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"marked": "^18.0.14",
|
|
99
99
|
"parse5": "^8.0.1",
|
|
100
100
|
"zod": "^4.1.5",
|
|
101
|
-
"@klarkxy/dsh-plugin-kit": "0.
|
|
101
|
+
"@klarkxy/dsh-plugin-kit": "0.7.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@deepseek-ai/cordis": ">=4.0.4",
|
|
@@ -107,15 +107,15 @@
|
|
|
107
107
|
"@deepseek-ai/dsh-tools": ">=0.2.0-rc.2"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@deepseek-ai/cordis": "4.0
|
|
111
|
-
"@deepseek-ai/dsh-credentials": "0.2.
|
|
112
|
-
"@deepseek-ai/dsh-storage-domain": "0.2.
|
|
113
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
110
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
111
|
+
"@deepseek-ai/dsh-credentials": "0.2.2-rc.1",
|
|
112
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.2-rc.1",
|
|
113
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
114
114
|
"react": "^18.2.0",
|
|
115
115
|
"@types/react": "18.3.31",
|
|
116
116
|
"react-dom": "^18.2.0",
|
|
117
117
|
"@types/react-dom": "^18.3.1",
|
|
118
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.
|
|
118
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1"
|
|
119
119
|
},
|
|
120
120
|
"peerDependenciesMeta": {
|
|
121
121
|
"@deepseek-ai/cordis": {
|
|
@@ -136,10 +136,17 @@
|
|
|
136
136
|
"dsh-plugin",
|
|
137
137
|
"dsh-plugins",
|
|
138
138
|
"deepseek-harness",
|
|
139
|
+
"deepseek-harness-plugin",
|
|
139
140
|
"zhihu",
|
|
140
141
|
"zhihu-search",
|
|
142
|
+
"zhida",
|
|
143
|
+
"hot-list",
|
|
141
144
|
"knowledge-base",
|
|
142
|
-
"web-search"
|
|
145
|
+
"web-search",
|
|
146
|
+
"questions",
|
|
147
|
+
"answers",
|
|
148
|
+
"creator-stats",
|
|
149
|
+
"drafts"
|
|
143
150
|
],
|
|
144
151
|
"repository": {
|
|
145
152
|
"type": "git",
|
|
@@ -155,6 +162,6 @@
|
|
|
155
162
|
"registry": "https://registry.npmjs.org/"
|
|
156
163
|
},
|
|
157
164
|
"dshRelease": {
|
|
158
|
-
"contentHash": "
|
|
165
|
+
"contentHash": "bbb6ebf020e2a6a73774651b29072cb4c3d9fe6818bdfc5156339535e728b19c"
|
|
159
166
|
}
|
|
160
167
|
}
|