dingtalk-wiki 1.2.12 → 1.2.13
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/index.js +30 -45
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1634,46 +1634,34 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
|
|
1636
1636
|
// Step 10: doc_2.0 API - DocContent (direct dentry content read, async returns taskId)
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1637
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
1638
|
+
try {
|
|
1639
|
+
const docContentRes = await axios({
|
|
1640
|
+
method: 'GET',
|
|
1641
|
+
url: `${DINGTALK_API_V2}/v2.0/doc/dentries/${input}/contents`,
|
|
1642
|
+
headers: { 'x-acs-dingtalk-access-token': token },
|
|
1643
|
+
params: { operatorId: opId }
|
|
1644
|
+
});
|
|
1645
|
+
steps.push({
|
|
1646
|
+
step: `doc_2.0 DocContent (attempt ${attempt})`,
|
|
1647
|
+
result: '成功',
|
|
1648
|
+
raw: docContentRes.data
|
|
1649
|
+
});
|
|
1650
|
+
break;
|
|
1651
|
+
} catch (e) {
|
|
1652
|
+
if (attempt === 3) {
|
|
1653
|
+
steps.push({
|
|
1654
|
+
step: `doc_2.0 DocContent (attempt ${attempt})`,
|
|
1655
|
+
result: '失败',
|
|
1656
|
+
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1657
|
+
});
|
|
1658
|
+
} else {
|
|
1659
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1655
1662
|
}
|
|
1656
1663
|
|
|
1657
|
-
|
|
1658
|
-
try {
|
|
1659
|
-
const getDocContentRes = await axios({
|
|
1660
|
-
method: 'GET',
|
|
1661
|
-
url: `${DINGTALK_API_V2}/v2.0/doc/me/query/${input}/contents`,
|
|
1662
|
-
headers: { 'x-acs-dingtalk-access-token': token },
|
|
1663
|
-
params: { targetFormat: 'markdown' }
|
|
1664
|
-
});
|
|
1665
|
-
steps.push({
|
|
1666
|
-
step: 'doc_2.0 GetDocContent GET /v2.0/doc/me/query/{uuid}/contents',
|
|
1667
|
-
result: '成功',
|
|
1668
|
-
raw: getDocContentRes.data
|
|
1669
|
-
});
|
|
1670
|
-
} catch (e) {
|
|
1671
|
-
steps.push({
|
|
1672
|
-
step: 'doc_2.0 GetDocContent GET /v2.0/doc/me/query/{uuid}/contents',
|
|
1673
|
-
result: '失败',
|
|
1674
|
-
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1675
|
-
});
|
|
1676
|
-
}
|
|
1664
|
+
|
|
1677
1665
|
|
|
1678
1666
|
const lines = ['🔍 docKey 诊断报告', '', `输入: ${input}`, `operatorId: ${opId}`, ''];
|
|
1679
1667
|
steps.forEach(s => {
|
|
@@ -1693,15 +1681,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1693
1681
|
lines.push(' 3️⃣ overwriteContent → ❌ 同上错误');
|
|
1694
1682
|
lines.push(' 4️⃣ doc metadata → ❌ 404(该端点不存在)');
|
|
1695
1683
|
lines.push('');
|
|
1696
|
-
lines.push('📌
|
|
1697
|
-
lines.push('
|
|
1698
|
-
lines.push(' (这类文档返回独立的 docKey,与 nodeId/dentryUuid 不同)');
|
|
1699
|
-
lines.push('');
|
|
1700
|
-
lines.push('📌 现有知识库文档内容读写:无公开 REST API 支持');
|
|
1701
|
-
lines.push(' 若需要读取内容,可用 DingTalk 官方 MCP 服务器的 get_document_content');
|
|
1684
|
+
lines.push('📌 DocContent API (GET /v2.0/doc/dentries/{uuid}/contents) ✅ 接受 dentryUuid');
|
|
1685
|
+
lines.push(' 上次失败原因: 503 ServiceUnavailable(临时服务器问题)');
|
|
1702
1686
|
if (effectiveWsId) {
|
|
1703
|
-
lines.push(`
|
|
1687
|
+
lines.push(` 此文档 workspaceId: ${effectiveWsId}`);
|
|
1704
1688
|
}
|
|
1689
|
+
lines.push('📌 请重新运行此工具,已加自动重试逻辑');
|
|
1705
1690
|
|
|
1706
1691
|
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
1707
1692
|
}
|