@xgjktech/xg_cwork_im 1.10.1 → 1.10.2
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/channel.ts +3 -0
- package/src/inbound-media-local.ts +13 -4
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -693,6 +693,9 @@ export const xgCworkImChannelPlugin: XgImChannelPlugin = {
|
|
|
693
693
|
|
|
694
694
|
const inboundSub = config.inboundMediaWorkspaceSubdir?.trim();
|
|
695
695
|
if (inboundSub && fileItems.length > 0 && normalizeInboundWorkspaceSubdir(inboundSub)) {
|
|
696
|
+
log.info(
|
|
697
|
+
`${logPrefix} [inbound-local] enabled subdir=${inboundSub} sender=${senderId ?? "unknown"} files=${fileItems.length} pathStyle=${config.inboundMediaOpenClawPath ?? "workspaceRelative"} sandboxPrefix=${config.inboundMediaSandboxRootPrefix ?? "(none)"}`,
|
|
698
|
+
);
|
|
696
699
|
fileItems = await saveInboundFilesToWorkspace({
|
|
697
700
|
rt,
|
|
698
701
|
cfg: ctx.cfg,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 时间取写入时的本地时区。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
8
|
+
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
import type { OpenClawConfig } from "openclaw/plugin-sdk";
|
|
@@ -177,6 +177,12 @@ export async function saveInboundFilesToWorkspace(args: {
|
|
|
177
177
|
const maxBytes = resolveMaxAttachmentBytes(config);
|
|
178
178
|
const userSeg = sanitizeUserIdForPath(senderUserId ?? "unknown");
|
|
179
179
|
const relParts = normalized.split("/");
|
|
180
|
+
const pathStyle = config.inboundMediaOpenClawPath ?? "workspaceRelative";
|
|
181
|
+
const sandboxPrefix = config.inboundMediaSandboxRootPrefix?.trim() || "";
|
|
182
|
+
|
|
183
|
+
log?.info?.(
|
|
184
|
+
`[cwork_im:inbound-local] begin files=${fileItems.length} cwd=${process.cwd()} workspaceRoot=${workspaceRoot} subdir=${normalized} user=${userSeg} style=${pathStyle} sandboxPrefix=${sandboxPrefix || "(none)"}`,
|
|
185
|
+
);
|
|
180
186
|
|
|
181
187
|
const out: MsgFileVO[] = [];
|
|
182
188
|
for (const item of fileItems) {
|
|
@@ -192,19 +198,22 @@ export async function saveInboundFilesToWorkspace(args: {
|
|
|
192
198
|
const absPath = path.join(dir, localName);
|
|
193
199
|
|
|
194
200
|
try {
|
|
201
|
+
log?.info?.(
|
|
202
|
+
`[cwork_im:inbound-local] prepare src=${srcUrl.slice(0, 120)} dir=${dir} abs=${absPath}`,
|
|
203
|
+
);
|
|
195
204
|
await mkdir(dir, { recursive: true });
|
|
196
205
|
const { buffer } = await downloadMediaBuffer(srcUrl, maxBytes, log);
|
|
197
206
|
await writeFile(absPath, buffer);
|
|
198
|
-
const pathStyle = config.inboundMediaOpenClawPath ?? "workspaceRelative";
|
|
199
207
|
const mediaRef = openClawMediaRefForSavedFile({
|
|
200
208
|
workspaceRoot,
|
|
201
209
|
absPath,
|
|
202
210
|
style: pathStyle,
|
|
203
|
-
sandboxRootPrefix:
|
|
211
|
+
sandboxRootPrefix: sandboxPrefix,
|
|
204
212
|
log,
|
|
205
213
|
});
|
|
214
|
+
const st = await stat(absPath);
|
|
206
215
|
log?.info?.(
|
|
207
|
-
`[cwork_im:inbound-local] saved ${localName} bytes=${buffer.length} abs=${absPath} openclawRef=${mediaRef
|
|
216
|
+
`[cwork_im:inbound-local] saved ${localName} bytes=${buffer.length} stat.size=${st.size} stat.mtime=${st.mtime.toISOString()} abs=${absPath} openclawRef=${mediaRef}`,
|
|
208
217
|
);
|
|
209
218
|
out.push({
|
|
210
219
|
...item,
|