Files
EJClaw/src/attachment-base-dirs.ts
Eyejoker 4859c58f48 Fix runtime image attachment paths
Allow nested /tmp generated images and per-room runtime workspace attachments after realpath/image validation.
2026-05-02 22:02:13 +09:00

22 lines
668 B
TypeScript

import path from 'path';
import { DATA_DIR } from './config.js';
import { isValidGroupFolder } from './group-folder.js';
import type { RegisteredGroup } from './types.js';
function unique(values: Array<string | null | undefined>): string[] {
return [
...new Set(values.filter((value): value is string => Boolean(value))),
];
}
export function resolveRuntimeAttachmentBaseDirs(
group: RegisteredGroup,
): string[] | undefined {
const workspaceRoot = isValidGroupFolder(group.folder)
? path.resolve(DATA_DIR, 'workspaces', group.folder)
: null;
const dirs = unique([group.workDir, workspaceRoot]);
return dirs.length > 0 ? dirs : undefined;
}