@danyow/lark-mcp 0.5.3 → 0.5.4
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.
|
@@ -87,12 +87,21 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
87
87
|
const filePath = path.join(outputDir, fileName);
|
|
88
88
|
// Use SDK's built-in download method which returns writeFile/getReadableStream
|
|
89
89
|
let response;
|
|
90
|
+
const debug = [];
|
|
91
|
+
debug.push(`fileToken: ${fileToken}`);
|
|
92
|
+
debug.push(`useUAT: ${params === null || params === void 0 ? void 0 : params.useUAT}, hasUserAccessToken: ${!!userAccessToken}`);
|
|
90
93
|
if (userAccessToken && (params === null || params === void 0 ? void 0 : params.useUAT)) {
|
|
91
94
|
response = await client.drive.exportTask.download({ path: { file_token: fileToken } }, lark.withUserAccessToken(userAccessToken));
|
|
92
95
|
}
|
|
93
96
|
else {
|
|
94
97
|
response = await client.drive.exportTask.download({ path: { file_token: fileToken } });
|
|
95
98
|
}
|
|
99
|
+
debug.push(`response type: ${typeof response}`);
|
|
100
|
+
debug.push(`response keys: ${response ? Object.keys(response).join(', ') : 'null/undefined'}`);
|
|
101
|
+
debug.push(`response.code: ${response === null || response === void 0 ? void 0 : response.code}`);
|
|
102
|
+
debug.push(`response.msg: ${response === null || response === void 0 ? void 0 : response.msg}`);
|
|
103
|
+
debug.push(`has writeFile: ${typeof (response === null || response === void 0 ? void 0 : response.writeFile)}`);
|
|
104
|
+
debug.push(`has getReadableStream: ${typeof (response === null || response === void 0 ? void 0 : response.getReadableStream)}`);
|
|
96
105
|
// Check if response contains an API error
|
|
97
106
|
if ((response === null || response === void 0 ? void 0 : response.code) && response.code !== 0) {
|
|
98
107
|
return {
|
|
@@ -101,23 +110,29 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
101
110
|
msg: 'API error',
|
|
102
111
|
code: response.code,
|
|
103
112
|
error: response.msg || 'Unknown error',
|
|
104
|
-
hint: 'The file_token may be invalid or expired. Export files are deleted 10 minutes after the export task completes.'
|
|
113
|
+
hint: 'The file_token may be invalid or expired. Export files are deleted 10 minutes after the export task completes.',
|
|
114
|
+
debug
|
|
105
115
|
}) }],
|
|
106
116
|
};
|
|
107
117
|
}
|
|
108
118
|
// Use the SDK's writeFile method to save the file
|
|
109
119
|
if (response === null || response === void 0 ? void 0 : response.writeFile) {
|
|
120
|
+
debug.push('using writeFile method');
|
|
110
121
|
await response.writeFile(filePath);
|
|
122
|
+
debug.push('writeFile completed');
|
|
111
123
|
}
|
|
112
124
|
else if (response === null || response === void 0 ? void 0 : response.getReadableStream) {
|
|
125
|
+
debug.push('using getReadableStream method');
|
|
113
126
|
// Fallback to stream if writeFile is not available
|
|
114
127
|
const readableStream = response.getReadableStream();
|
|
128
|
+
debug.push(`readableStream: ${readableStream ? 'exists' : 'undefined'}`);
|
|
115
129
|
if (!readableStream) {
|
|
116
130
|
return {
|
|
117
131
|
isError: true,
|
|
118
132
|
content: [{ type: 'text', text: JSON.stringify({
|
|
119
133
|
msg: 'Failed to download file: getReadableStream returned undefined',
|
|
120
|
-
hint: 'The file_token may be invalid or expired. Export files are deleted 10 minutes after the export task completes.'
|
|
134
|
+
hint: 'The file_token may be invalid or expired. Export files are deleted 10 minutes after the export task completes.',
|
|
135
|
+
debug
|
|
121
136
|
}) }],
|
|
122
137
|
};
|
|
123
138
|
}
|
|
@@ -128,13 +143,14 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
128
143
|
writableStream.on('error', reject);
|
|
129
144
|
readableStream.on('error', reject);
|
|
130
145
|
});
|
|
146
|
+
debug.push('stream completed');
|
|
131
147
|
}
|
|
132
148
|
else {
|
|
133
149
|
return {
|
|
134
150
|
isError: true,
|
|
135
151
|
content: [{ type: 'text', text: JSON.stringify({
|
|
136
152
|
msg: 'Failed to download file: SDK response does not contain writeFile or getReadableStream',
|
|
137
|
-
debug
|
|
153
|
+
debug
|
|
138
154
|
}) }],
|
|
139
155
|
};
|
|
140
156
|
}
|
|
@@ -87,12 +87,21 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
87
87
|
const filePath = path.join(outputDir, fileName);
|
|
88
88
|
// Use SDK's built-in download method which returns writeFile/getReadableStream
|
|
89
89
|
let response;
|
|
90
|
+
const debug = [];
|
|
91
|
+
debug.push(`fileToken: ${fileToken}`);
|
|
92
|
+
debug.push(`useUAT: ${params === null || params === void 0 ? void 0 : params.useUAT}, hasUserAccessToken: ${!!userAccessToken}`);
|
|
90
93
|
if (userAccessToken && (params === null || params === void 0 ? void 0 : params.useUAT)) {
|
|
91
94
|
response = await client.drive.exportTask.download({ path: { file_token: fileToken } }, lark.withUserAccessToken(userAccessToken));
|
|
92
95
|
}
|
|
93
96
|
else {
|
|
94
97
|
response = await client.drive.exportTask.download({ path: { file_token: fileToken } });
|
|
95
98
|
}
|
|
99
|
+
debug.push(`response type: ${typeof response}`);
|
|
100
|
+
debug.push(`response keys: ${response ? Object.keys(response).join(', ') : 'null/undefined'}`);
|
|
101
|
+
debug.push(`response.code: ${response === null || response === void 0 ? void 0 : response.code}`);
|
|
102
|
+
debug.push(`response.msg: ${response === null || response === void 0 ? void 0 : response.msg}`);
|
|
103
|
+
debug.push(`has writeFile: ${typeof (response === null || response === void 0 ? void 0 : response.writeFile)}`);
|
|
104
|
+
debug.push(`has getReadableStream: ${typeof (response === null || response === void 0 ? void 0 : response.getReadableStream)}`);
|
|
96
105
|
// Check if response contains an API error
|
|
97
106
|
if ((response === null || response === void 0 ? void 0 : response.code) && response.code !== 0) {
|
|
98
107
|
return {
|
|
@@ -101,23 +110,29 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
101
110
|
msg: 'API 错误',
|
|
102
111
|
code: response.code,
|
|
103
112
|
error: response.msg || '未知错误',
|
|
104
|
-
hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。'
|
|
113
|
+
hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。',
|
|
114
|
+
debug
|
|
105
115
|
}) }],
|
|
106
116
|
};
|
|
107
117
|
}
|
|
108
118
|
// Use the SDK's writeFile method to save the file
|
|
109
119
|
if (response === null || response === void 0 ? void 0 : response.writeFile) {
|
|
120
|
+
debug.push('using writeFile method');
|
|
110
121
|
await response.writeFile(filePath);
|
|
122
|
+
debug.push('writeFile completed');
|
|
111
123
|
}
|
|
112
124
|
else if (response === null || response === void 0 ? void 0 : response.getReadableStream) {
|
|
125
|
+
debug.push('using getReadableStream method');
|
|
113
126
|
// Fallback to stream if writeFile is not available
|
|
114
127
|
const readableStream = response.getReadableStream();
|
|
128
|
+
debug.push(`readableStream: ${readableStream ? 'exists' : 'undefined'}`);
|
|
115
129
|
if (!readableStream) {
|
|
116
130
|
return {
|
|
117
131
|
isError: true,
|
|
118
132
|
content: [{ type: 'text', text: JSON.stringify({
|
|
119
133
|
msg: '下载文件失败:getReadableStream 返回 undefined',
|
|
120
|
-
hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。'
|
|
134
|
+
hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。',
|
|
135
|
+
debug
|
|
121
136
|
}) }],
|
|
122
137
|
};
|
|
123
138
|
}
|
|
@@ -128,13 +143,14 @@ exports.larkDriveExportTaskDownloadTool = {
|
|
|
128
143
|
writableStream.on('error', reject);
|
|
129
144
|
readableStream.on('error', reject);
|
|
130
145
|
});
|
|
146
|
+
debug.push('stream completed');
|
|
131
147
|
}
|
|
132
148
|
else {
|
|
133
149
|
return {
|
|
134
150
|
isError: true,
|
|
135
151
|
content: [{ type: 'text', text: JSON.stringify({
|
|
136
152
|
msg: '下载文件失败:SDK 响应不包含 writeFile 或 getReadableStream',
|
|
137
|
-
debug
|
|
153
|
+
debug
|
|
138
154
|
}) }],
|
|
139
155
|
};
|
|
140
156
|
}
|