dingtalk-wiki 1.2.9 → 1.2.10
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 +45 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1419,8 +1419,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1419
1419
|
});
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
|
-
// Step 6: search docs API (v1.0/doc/docs) — 需要 workspaceId
|
|
1422
|
+
// Step 6: search docs API (v1.0/doc/docs) — 需要 workspaceId + keyword
|
|
1423
1423
|
if (effectiveWsId) {
|
|
1424
|
+
// Try without keyword first (might list all)
|
|
1424
1425
|
try {
|
|
1425
1426
|
const searchRes = await axios({
|
|
1426
1427
|
method: 'GET',
|
|
@@ -1431,17 +1432,41 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1431
1432
|
const docs = searchRes.data?.docs || [];
|
|
1432
1433
|
const matched = docs.find(d => d.nodeBO?.nodeId === input || d.nodeBO?.dentryUuid === input || d.docKey === input || d.nodeBO?.dentryId === input);
|
|
1433
1434
|
steps.push({
|
|
1434
|
-
step: `doc search API (workspace=${effectiveWsId})`,
|
|
1435
|
+
step: `doc search API (workspace=${effectiveWsId}, no keyword)`,
|
|
1435
1436
|
result: `成功 (${docs.length} 篇文档)` + (matched ? ', 找到匹配!' : ', 未找到匹配'),
|
|
1436
|
-
raw:
|
|
1437
|
+
raw: docs.length > 0 ? { count: docs.length, firstDocDocKey: docs[0]?.docKey || '(无)', firstDocNodeId: docs[0]?.nodeBO?.nodeId || '(无)', firstDocName: docs[0]?.name || '(无)' } : '空结果'
|
|
1437
1438
|
});
|
|
1438
1439
|
} catch (e) {
|
|
1439
1440
|
steps.push({
|
|
1440
|
-
step: `doc search API (workspace=${effectiveWsId})`,
|
|
1441
|
+
step: `doc search API (workspace=${effectiveWsId}, no keyword)`,
|
|
1441
1442
|
result: '失败',
|
|
1442
1443
|
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1443
1444
|
});
|
|
1444
1445
|
}
|
|
1446
|
+
// Try with keyword from wiki/nodes name if available
|
|
1447
|
+
const wikiName = wikiNodeResponse?.node?.name || wikiNodeResponse?.name || '';
|
|
1448
|
+
if (wikiName) {
|
|
1449
|
+
try {
|
|
1450
|
+
const searchRes = await axios({
|
|
1451
|
+
method: 'GET',
|
|
1452
|
+
url: `${DINGTALK_API_V2}/v1.0/doc/docs`,
|
|
1453
|
+
headers: { 'x-acs-dingtalk-access-token': token },
|
|
1454
|
+
params: { operatorId: opId, workspaceId: effectiveWsId, keyword: wikiName.replace(/\.\w+$/, ''), maxResults: 10 }
|
|
1455
|
+
});
|
|
1456
|
+
const docs = searchRes.data?.docs || [];
|
|
1457
|
+
steps.push({
|
|
1458
|
+
step: `doc search API (keyword="${wikiName}")`,
|
|
1459
|
+
result: `成功 (${docs.length} 篇)`,
|
|
1460
|
+
raw: docs.length > 0 ? docs.map(d => ({ docKey: d.docKey || '(无)', name: d.name || '(无)', nodeId: d.nodeBO?.nodeId || '(无)', dentryUuid: d.nodeBO?.dentryUuid || '(无)' })) : '空结果'
|
|
1461
|
+
});
|
|
1462
|
+
} catch (e) {
|
|
1463
|
+
steps.push({
|
|
1464
|
+
step: `doc search API (keyword="${wikiName}")`,
|
|
1465
|
+
result: '失败',
|
|
1466
|
+
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1445
1470
|
} else {
|
|
1446
1471
|
steps.push({ step: 'doc search API', result: '跳过(无法获取 workspace_id)' });
|
|
1447
1472
|
}
|
|
@@ -1506,16 +1531,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1506
1531
|
}
|
|
1507
1532
|
lines.push('');
|
|
1508
1533
|
});
|
|
1509
|
-
lines.push('💡
|
|
1510
|
-
lines.push(
|
|
1511
|
-
lines.push(
|
|
1512
|
-
lines.push('
|
|
1513
|
-
lines.push('
|
|
1534
|
+
lines.push('💡 诊断结论:');
|
|
1535
|
+
lines.push(` 输入 ID: ${input}`);
|
|
1536
|
+
lines.push(` 操作者: ${opId}`);
|
|
1537
|
+
lines.push('');
|
|
1538
|
+
lines.push(' 1️⃣ wiki/nodes API → ✅ 成功。节点存在,但无 document.docKey');
|
|
1539
|
+
lines.push(' 2️⃣ blocks API → ❌ "doc key is illegal"');
|
|
1540
|
+
lines.push(' 3️⃣ overwriteContent → ❌ 同上错误');
|
|
1541
|
+
lines.push(' 4️⃣ doc metadata → ❌ 404(该端点不存在)');
|
|
1542
|
+
lines.push('');
|
|
1543
|
+
lines.push('📌 结论:此 dentryUuid 在 Wiki API 中有效,但在 Doc Suite API 中无效。');
|
|
1544
|
+
lines.push(' blocks/overwriteContent 仅对通过 create_wiki_doc 创建的文档有效');
|
|
1545
|
+
lines.push(' (这类文档返回独立的 docKey,与 nodeId/dentryUuid 不同)');
|
|
1546
|
+
lines.push('');
|
|
1547
|
+
lines.push('📌 现有知识库文档内容读写:无公开 REST API 支持');
|
|
1548
|
+
lines.push(' 若需要读取内容,可用 DingTalk 官方 MCP 服务器的 get_document_content');
|
|
1514
1549
|
if (effectiveWsId) {
|
|
1515
|
-
lines.push(` -
|
|
1516
|
-
}
|
|
1517
|
-
if (workspaceId) {
|
|
1518
|
-
lines.push(' - 已提供 workspaceId: ' + workspaceId);
|
|
1550
|
+
lines.push(` - 此文档 workspaceId: ${effectiveWsId}`);
|
|
1519
1551
|
}
|
|
1520
1552
|
|
|
1521
1553
|
return { content: [{ type: 'text', text: lines.join('\n') }] };
|