@danyow/lark-mcp 0.5.2 → 0.5.3

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.
@@ -93,6 +93,18 @@ exports.larkDriveExportTaskDownloadTool = {
93
93
  else {
94
94
  response = await client.drive.exportTask.download({ path: { file_token: fileToken } });
95
95
  }
96
+ // Check if response contains an API error
97
+ if ((response === null || response === void 0 ? void 0 : response.code) && response.code !== 0) {
98
+ return {
99
+ isError: true,
100
+ content: [{ type: 'text', text: JSON.stringify({
101
+ msg: 'API error',
102
+ code: response.code,
103
+ 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.'
105
+ }) }],
106
+ };
107
+ }
96
108
  // Use the SDK's writeFile method to save the file
97
109
  if (response === null || response === void 0 ? void 0 : response.writeFile) {
98
110
  await response.writeFile(filePath);
@@ -100,6 +112,15 @@ exports.larkDriveExportTaskDownloadTool = {
100
112
  else if (response === null || response === void 0 ? void 0 : response.getReadableStream) {
101
113
  // Fallback to stream if writeFile is not available
102
114
  const readableStream = response.getReadableStream();
115
+ if (!readableStream) {
116
+ return {
117
+ isError: true,
118
+ content: [{ type: 'text', text: JSON.stringify({
119
+ 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.'
121
+ }) }],
122
+ };
123
+ }
103
124
  const writableStream = fs.createWriteStream(filePath);
104
125
  await new Promise((resolve, reject) => {
105
126
  readableStream.pipe(writableStream);
@@ -93,6 +93,18 @@ exports.larkDriveExportTaskDownloadTool = {
93
93
  else {
94
94
  response = await client.drive.exportTask.download({ path: { file_token: fileToken } });
95
95
  }
96
+ // Check if response contains an API error
97
+ if ((response === null || response === void 0 ? void 0 : response.code) && response.code !== 0) {
98
+ return {
99
+ isError: true,
100
+ content: [{ type: 'text', text: JSON.stringify({
101
+ msg: 'API 错误',
102
+ code: response.code,
103
+ error: response.msg || '未知错误',
104
+ hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。'
105
+ }) }],
106
+ };
107
+ }
96
108
  // Use the SDK's writeFile method to save the file
97
109
  if (response === null || response === void 0 ? void 0 : response.writeFile) {
98
110
  await response.writeFile(filePath);
@@ -100,6 +112,15 @@ exports.larkDriveExportTaskDownloadTool = {
100
112
  else if (response === null || response === void 0 ? void 0 : response.getReadableStream) {
101
113
  // Fallback to stream if writeFile is not available
102
114
  const readableStream = response.getReadableStream();
115
+ if (!readableStream) {
116
+ return {
117
+ isError: true,
118
+ content: [{ type: 'text', text: JSON.stringify({
119
+ msg: '下载文件失败:getReadableStream 返回 undefined',
120
+ hint: 'file_token 可能无效或已过期。导出的文件将在导出任务完成后 10 分钟内被删除。'
121
+ }) }],
122
+ };
123
+ }
103
124
  const writableStream = fs.createWriteStream(filePath);
104
125
  await new Promise((resolve, reject) => {
105
126
  readableStream.pipe(writableStream);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danyow/lark-mcp",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Feishu/Lark OpenAPI MCP",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",