duclaw-cli 1.4.0 → 1.6.0
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/dist/bundle.js +53 -67
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -30242,7 +30242,7 @@ function printHelp() {
|
|
|
30242
30242
|
`);
|
|
30243
30243
|
}
|
|
30244
30244
|
function printVersion() {
|
|
30245
|
-
console.log(`duclaw-cli v${true ? "1.
|
|
30245
|
+
console.log(`duclaw-cli v${true ? "1.6.0" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -30266,22 +30266,6 @@ export ANTHROPIC_MODEL="claude-sonnet-4-20250514"
|
|
|
30266
30266
|
|
|
30267
30267
|
# ====== Redis \u914D\u7F6E\uFF08\u5FC5\u586B\uFF09======
|
|
30268
30268
|
export REDIS_URL="redis://localhost:6379"
|
|
30269
|
-
|
|
30270
|
-
# ====== \u963F\u91CC\u4E91 OSS \u914D\u7F6E\uFF08\u6309\u9700\u586B\u5199\uFF0C\u7528\u4E8E\u6587\u4EF6\u5B58\u50A8\uFF09======
|
|
30271
|
-
# export OSS_ENDPOINT="oss-cn-shenzhen"
|
|
30272
|
-
# export OSS_BUCKET="your-bucket-name"
|
|
30273
|
-
# export OSS_ACCESS_KEY_ID="your-access-key-id"
|
|
30274
|
-
# export OSS_ACCESS_KEY_SECRET="your-access-key-secret"
|
|
30275
|
-
|
|
30276
|
-
# ====== \u8DEF\u5F84\u914D\u7F6E\uFF08\u9ED8\u8BA4 ~/.duclaw/\uFF0C\u901A\u5E38\u65E0\u9700\u4FEE\u6539\uFF09======
|
|
30277
|
-
# export JOB_PATH="~/.duclaw/cron/jobs.json"
|
|
30278
|
-
# export JOB_HISTORY_DIR="~/.duclaw/cron"
|
|
30279
|
-
# export APP_TEMP_DIR="~/.duclaw/data"
|
|
30280
|
-
|
|
30281
|
-
# ====== \u56FE\u7247\u7406\u89E3\u5DE5\u5177 LLM \u914D\u7F6E\uFF08\u6309\u9700\u586B\u5199\uFF09======
|
|
30282
|
-
# export TOOL_IMAGE_ANTHROPIC_AUTH_TOKEN="your-api-key"
|
|
30283
|
-
# export TOOL_IMAGE_ANTHROPIC_BASE_URL="https://api.anthropic.com"
|
|
30284
|
-
# export TOOL_IMAGE_ANTHROPIC_MODEL="claude-sonnet-4-20250514"
|
|
30285
30269
|
`;
|
|
30286
30270
|
}
|
|
30287
30271
|
|
|
@@ -41810,10 +41794,18 @@ var RedisMessageDeduplication = class {
|
|
|
41810
41794
|
}
|
|
41811
41795
|
};
|
|
41812
41796
|
|
|
41797
|
+
// src/channels/feishu/MessageProcess.ts
|
|
41798
|
+
var import_node_path10 = require("node:path");
|
|
41799
|
+
var import_node_os4 = require("node:os");
|
|
41800
|
+
var import_node_fs5 = require("node:fs");
|
|
41801
|
+
|
|
41813
41802
|
// src/oss/AliyunOSSClient.ts
|
|
41814
41803
|
var import_ali_oss = __toESM(require("ali-oss"));
|
|
41815
41804
|
loadEnv();
|
|
41816
41805
|
var aliyunOssClient = void 0;
|
|
41806
|
+
var isOssConfigured = () => {
|
|
41807
|
+
return !!(process.env.OSS_ACCESS_KEY_ID && process.env.OSS_ACCESS_KEY_SECRET && process.env.OSS_ENDPOINT && process.env.OSS_BUCKET);
|
|
41808
|
+
};
|
|
41817
41809
|
var createAliyunOssClient = () => {
|
|
41818
41810
|
const key = process.env.OSS_ACCESS_KEY_ID;
|
|
41819
41811
|
const secret = process.env.OSS_ACCESS_KEY_SECRET;
|
|
@@ -41841,6 +41833,26 @@ var createAliyunOssClient = () => {
|
|
|
41841
41833
|
};
|
|
41842
41834
|
|
|
41843
41835
|
// src/channels/feishu/MessageProcess.ts
|
|
41836
|
+
var saveToLocal = (userId, subDir, fileName, buffer) => {
|
|
41837
|
+
const dir = (0, import_node_path10.join)((0, import_node_os4.homedir)(), ".duclaw", "workspace", userId, subDir);
|
|
41838
|
+
(0, import_node_fs5.mkdirSync)(dir, { recursive: true });
|
|
41839
|
+
const filePath = (0, import_node_path10.join)(dir, fileName);
|
|
41840
|
+
(0, import_node_fs5.writeFileSync)(filePath, buffer);
|
|
41841
|
+
return filePath;
|
|
41842
|
+
};
|
|
41843
|
+
var tryUploadToOss = async (ossPath, buffer) => {
|
|
41844
|
+
if (!isOssConfigured()) return null;
|
|
41845
|
+
try {
|
|
41846
|
+
const ossClient = createAliyunOssClient();
|
|
41847
|
+
await ossClient.put(ossPath, buffer);
|
|
41848
|
+
const url = await ossClient.signatureUrlV4("GET", 3600, void 0, ossPath);
|
|
41849
|
+
console.log(`[MessageProcess] OSS \u4E0A\u4F20\u6210\u529F\uFF0C\u4E34\u65F6\u8BBF\u95EE\u94FE\u63A5: ${url}`);
|
|
41850
|
+
return url;
|
|
41851
|
+
} catch (err) {
|
|
41852
|
+
console.warn(`[MessageProcess] OSS \u4E0A\u4F20\u5931\u8D25\uFF0C\u4F7F\u7528\u672C\u5730\u8DEF\u5F84: ${err}`);
|
|
41853
|
+
return null;
|
|
41854
|
+
}
|
|
41855
|
+
};
|
|
41844
41856
|
var processImageMsg = async (userRequest) => {
|
|
41845
41857
|
if (!userRequest.metadata) {
|
|
41846
41858
|
throw new Error(`[MessageProcess] \u98DE\u4E66\u56FE\u7247\u6D88\u606F\u5E94\u8981\u6709metadata,\u5F53\u524D:${userRequest.metadata}`);
|
|
@@ -41855,30 +41867,13 @@ var processImageMsg = async (userRequest) => {
|
|
|
41855
41867
|
if (!image_key) {
|
|
41856
41868
|
throw new Error(`[MessageProcess] \u98DE\u4E66\u56FE\u7247\u6D88\u606F\u5E94\u8981\u6709image_key`);
|
|
41857
41869
|
}
|
|
41858
|
-
const
|
|
41859
|
-
|
|
41860
|
-
|
|
41861
|
-
|
|
41862
|
-
|
|
41863
|
-
|
|
41864
|
-
|
|
41865
|
-
console.log("\u6587\u4EF6\u4E0A\u4F20oss\u5B8C\u6210:", result);
|
|
41866
|
-
const publicReadableUrl = await ossClient.signatureUrlV4(
|
|
41867
|
-
`GET`,
|
|
41868
|
-
3600,
|
|
41869
|
-
// 过期时间(秒),1小时
|
|
41870
|
-
void 0,
|
|
41871
|
-
// 不需要额外的 headers/queries
|
|
41872
|
-
`${userRequest.userId}/images/${image_key}`
|
|
41873
|
-
// obj name
|
|
41874
|
-
);
|
|
41875
|
-
console.log(`[MessageProcess] \u4E34\u65F6\u8BBF\u95EE\u94FE\u63A5: ${publicReadableUrl}\uFF0C\u6709\u6548\u65F6\u957F: 1h`);
|
|
41876
|
-
userRequest.metadata.imageUrl = publicReadableUrl;
|
|
41877
|
-
userRequest.content = `<system-reminder>\u63A5\u6536\u5230\u7528\u6237\u53D1\u6765\u7684\u56FE\u7247\u6D88\u606F,\u56FE\u7247\u5DF2\u5B58\u50A8\u5728\u4E0A\u4E0B\u6587\u4E2D,\u8BF7\u4F7F\u7528image_understand\u5DE5\u5177\u5206\u6790\u56FE\u7247(\u4E0D\u9700\u8981\u4F20image_url\u53C2\u6570,\u5DE5\u5177\u4F1A\u81EA\u52A8\u83B7\u53D6\u56FE\u7247)</system-reminder>`;
|
|
41878
|
-
return userRequest;
|
|
41879
|
-
} catch (err) {
|
|
41880
|
-
throw new Error(`[MessageProcess] \u4E0A\u4F20\u56FE\u7247\u5230\u963F\u91CC\u4E91oss\u5931\u8D25:${err}`);
|
|
41881
|
-
}
|
|
41870
|
+
const buffer = await downloadMessageImage(message.message_id, image_key);
|
|
41871
|
+
const localPath = saveToLocal(userRequest.userId, "images", `${image_key}.png`, buffer);
|
|
41872
|
+
console.log(`[MessageProcess] \u56FE\u7247\u5DF2\u4FDD\u5B58\u5230\u672C\u5730: ${localPath}`);
|
|
41873
|
+
const ossUrl = await tryUploadToOss(`${userRequest.userId}/images/${image_key}`, buffer);
|
|
41874
|
+
userRequest.metadata.imageUrl = ossUrl || localPath;
|
|
41875
|
+
userRequest.content = `<system-reminder>\u63A5\u6536\u5230\u7528\u6237\u53D1\u6765\u7684\u56FE\u7247\u6D88\u606F,\u56FE\u7247\u5DF2\u5B58\u50A8\u5728\u4E0A\u4E0B\u6587\u4E2D,\u8BF7\u4F7F\u7528image_understand\u5DE5\u5177\u5206\u6790\u56FE\u7247(\u4E0D\u9700\u8981\u4F20image_url\u53C2\u6570,\u5DE5\u5177\u4F1A\u81EA\u52A8\u83B7\u53D6\u56FE\u7247)</system-reminder>`;
|
|
41876
|
+
return userRequest;
|
|
41882
41877
|
};
|
|
41883
41878
|
var processFileMsg = async (userRequest) => {
|
|
41884
41879
|
const metadata = userRequest.metadata;
|
|
@@ -41891,31 +41886,22 @@ var processFileMsg = async (userRequest) => {
|
|
|
41891
41886
|
if (!messageId || !fileKey || !fileName) {
|
|
41892
41887
|
throw new Error(`[MessageProcess] \u98DE\u4E66\u6587\u4EF6\u6D88\u606F\u7F3A\u5C11 message_id/file_key/file_name`);
|
|
41893
41888
|
}
|
|
41894
|
-
const
|
|
41895
|
-
|
|
41896
|
-
|
|
41897
|
-
|
|
41898
|
-
|
|
41899
|
-
|
|
41900
|
-
|
|
41901
|
-
|
|
41902
|
-
|
|
41903
|
-
|
|
41904
|
-
|
|
41905
|
-
|
|
41906
|
-
|
|
41907
|
-
|
|
41908
|
-
|
|
41909
|
-
|
|
41910
|
-
`\u7528\u6237\u901A\u8FC7\u98DE\u4E66\u53D1\u9001\u4E86\u4E00\u4E2A\u6587\u4EF6\u3002`,
|
|
41911
|
-
`\u6587\u4EF6\u540D: ${fileName}`,
|
|
41912
|
-
`\u6587\u4EF6\u5DF2\u4E0A\u4F20\u81F3\u4E91\u5B58\u50A8\uFF0C\u53EF\u901A\u8FC7\u4EE5\u4E0B URL \u8BBF\u95EE\uFF081\u5C0F\u65F6\u6709\u6548\uFF09:`,
|
|
41913
|
-
publicReadableUrl
|
|
41914
|
-
].join("\n");
|
|
41915
|
-
return userRequest;
|
|
41916
|
-
} catch (err) {
|
|
41917
|
-
throw new Error(`[MessageProcess] \u4E0A\u4F20\u6587\u4EF6\u5230\u963F\u91CC\u4E91oss\u5931\u8D25:${err}`);
|
|
41918
|
-
}
|
|
41889
|
+
const buffer = await downloadMessageFile(messageId, fileKey);
|
|
41890
|
+
console.log(`[MessageProcess] \u6587\u4EF6\u4E0B\u8F7D\u5B8C\u6210: ${fileName}, \u5927\u5C0F: ${buffer.length} bytes`);
|
|
41891
|
+
const localPath = saveToLocal(userRequest.userId, "files", fileName, buffer);
|
|
41892
|
+
console.log(`[MessageProcess] \u6587\u4EF6\u5DF2\u4FDD\u5B58\u5230\u672C\u5730: ${localPath}`);
|
|
41893
|
+
const ossPath = `${userRequest.userId}/files/${fileKey}_${fileName}`;
|
|
41894
|
+
const ossUrl = await tryUploadToOss(ossPath, buffer);
|
|
41895
|
+
const fileLocation = ossUrl || localPath;
|
|
41896
|
+
userRequest.metadata.fileUrl = fileLocation;
|
|
41897
|
+
userRequest.content = [
|
|
41898
|
+
`\u7528\u6237\u901A\u8FC7\u98DE\u4E66\u53D1\u9001\u4E86\u4E00\u4E2A\u6587\u4EF6\u3002`,
|
|
41899
|
+
`\u6587\u4EF6\u540D: ${fileName}`,
|
|
41900
|
+
ossUrl ? `\u6587\u4EF6\u5DF2\u4E0A\u4F20\u81F3\u4E91\u5B58\u50A8\uFF0C\u53EF\u901A\u8FC7\u4EE5\u4E0B URL \u8BBF\u95EE\uFF081\u5C0F\u65F6\u6709\u6548\uFF09:
|
|
41901
|
+
${ossUrl}` : `\u6587\u4EF6\u5DF2\u4FDD\u5B58\u5230\u672C\u5730\u8DEF\u5F84:
|
|
41902
|
+
${localPath}`
|
|
41903
|
+
].join("\n");
|
|
41904
|
+
return userRequest;
|
|
41919
41905
|
};
|
|
41920
41906
|
|
|
41921
41907
|
// src/channels/feishu/feishuChannelsPlugin.ts
|
|
@@ -46310,7 +46296,7 @@ var systemRoutes = new Hono2();
|
|
|
46310
46296
|
var startTime = Date.now();
|
|
46311
46297
|
systemRoutes.get("/system/info", (c) => {
|
|
46312
46298
|
return c.json({
|
|
46313
|
-
version: true ? "1.
|
|
46299
|
+
version: true ? "1.6.0" : "unknown",
|
|
46314
46300
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
46315
46301
|
env: process.env.NODE_ENV || "development",
|
|
46316
46302
|
nodeVersion: process.version
|