WebChat: fix packaged root resolution
parent
2ebad55a59
commit
fc1d58b631
|
|
@ -40,16 +40,20 @@ const wsSessions: Map<string, Set<WebSocket>> = new Map();
|
||||||
function resolveWebRoot() {
|
function resolveWebRoot() {
|
||||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const packagedRoot = path.resolve(
|
const candidates = [
|
||||||
path.dirname(process.execPath),
|
// Bundled inside Clawdis.app: .../Contents/Resources/WebChat
|
||||||
"../WebChat",
|
path.resolve(here, "../../../WebChat"),
|
||||||
);
|
// When running from repo without bundling
|
||||||
if (fs.existsSync(packagedRoot)) return packagedRoot;
|
path.resolve(here, "../../WebChat"),
|
||||||
|
// Fallback to source tree location
|
||||||
|
path.resolve(here, "../../apps/macos/Sources/Clawdis/Resources/WebChat"),
|
||||||
|
];
|
||||||
|
|
||||||
return path.resolve(
|
for (const candidate of candidates) {
|
||||||
here,
|
if (fs.existsSync(candidate)) return candidate;
|
||||||
"../../apps/macos/Sources/Clawdis/Resources/WebChat",
|
}
|
||||||
);
|
|
||||||
|
throw new Error(`webchat assets not found; tried: ${candidates.join(", ")}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBody(req: http.IncomingMessage): Promise<Buffer> {
|
function readBody(req: http.IncomingMessage): Promise<Buffer> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue