adp-openclaw 0.0.39 → 0.0.41
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/package.json +1 -1
- package/src/adp-upload-tool.ts +16 -5
- package/src/monitor.ts +3 -1
package/package.json
CHANGED
package/src/adp-upload-tool.ts
CHANGED
|
@@ -190,13 +190,20 @@ export async function getStorageCredential(
|
|
|
190
190
|
throw new Error(`获取存储凭证失败: ${response.status} ${errorText}`);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
const
|
|
193
|
+
const responseData = await response.json();
|
|
194
194
|
|
|
195
|
+
// 调试:打印原始响应的所有 key
|
|
196
|
+
console.log(`[ADP-UPLOAD] Response keys: ${Object.keys(responseData).join(', ')}`);
|
|
197
|
+
|
|
198
|
+
// 上游 API 返回的数据可能被包装在 result 字段中
|
|
199
|
+
const result = responseData.result || responseData;
|
|
200
|
+
|
|
201
|
+
console.log(`[ADP-UPLOAD] Result keys: ${Object.keys(result).join(', ')}`);
|
|
195
202
|
console.log(`[ADP-UPLOAD] Response received: bucket=${result.bucket}, region=${result.region}, has_upload_url=${!!result.upload_url}, has_file_url=${!!result.file_url}`);
|
|
196
203
|
|
|
197
204
|
// 检查响应数据的完整性 - 现在主要检查 upload_url 和 file_url
|
|
198
205
|
if (!result.upload_url || !result.file_url) {
|
|
199
|
-
console.error(`[ADP-UPLOAD] Missing required fields in response:`, JSON.stringify(
|
|
206
|
+
console.error(`[ADP-UPLOAD] Missing required fields in response:`, JSON.stringify(responseData).substring(0, 500));
|
|
200
207
|
throw new Error("获取存储凭证失败: 缺少upload_url或file_url信息");
|
|
201
208
|
}
|
|
202
209
|
|
|
@@ -278,8 +285,11 @@ export async function adpUploadFile(
|
|
|
278
285
|
fileType?: string
|
|
279
286
|
): Promise<UploadResult> {
|
|
280
287
|
try {
|
|
288
|
+
// 如果没有传入 fileType,根据文件扩展名推断
|
|
289
|
+
const actualFileType = fileType || inferMimeType(basename(filePath));
|
|
290
|
+
|
|
281
291
|
// 1. 获取预签名URL
|
|
282
|
-
const credential = await getStorageCredential(botToken,
|
|
292
|
+
const credential = await getStorageCredential(botToken, actualFileType);
|
|
283
293
|
|
|
284
294
|
// 2. 上传文件到 COS(返回下载URL)
|
|
285
295
|
const fileUrl = await uploadFileToCos(filePath, credential);
|
|
@@ -701,8 +711,9 @@ export const uploadFilesToAdpEndpoint = async (
|
|
|
701
711
|
fileMetadatas,
|
|
702
712
|
maxConcurrency,
|
|
703
713
|
async (metadata, _index): Promise<UploadedFileInfo> => {
|
|
704
|
-
// 为每个文件获取预签名URL
|
|
705
|
-
const
|
|
714
|
+
// 为每个文件获取预签名URL,优先使用传入的 fileType,否则使用文件的 contentType
|
|
715
|
+
const actualFileType = fileType || metadata.contentType || "";
|
|
716
|
+
const credential = await getStorageCredential(botToken, actualFileType);
|
|
706
717
|
// 上传文件并获取下载URL
|
|
707
718
|
const downloadUrl = await uploadFileToCos(metadata.path, credential);
|
|
708
719
|
return {
|
package/src/monitor.ts
CHANGED
|
@@ -21,9 +21,11 @@ import {
|
|
|
21
21
|
formatUploadResultAsMarkdown,
|
|
22
22
|
} from "./tool-result-message-blocks.js";
|
|
23
23
|
import crypto from "crypto";
|
|
24
|
+
// @ts-ignore - import JSON file
|
|
25
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
24
26
|
|
|
25
27
|
// Plugin version from package.json
|
|
26
|
-
const PLUGIN_VERSION =
|
|
28
|
+
const PLUGIN_VERSION = packageJson.version;
|
|
27
29
|
|
|
28
30
|
// WebSocket reconnect delay (fixed at 1 second)
|
|
29
31
|
const RECONNECT_DELAY_MS = 1000;
|