mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
460e3e669c
* fix(dashboard): harden canvas and workspace compatibility * docs(web): add dashboard architecture * chore: remove release-owned changelog entry * docs: update dashboard architecture map
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import type { PluginNodeCapabilitySurface } from "../gateway/plugin-node-capability.js";
|
|
|
|
/** Stable Gateway path used by chat clients for hosted Canvas content. */
|
|
const CANVAS_HOST_PATH = "/__openclaw__/canvas";
|
|
export const CANVAS_DOCUMENTS_PATH = `${CANVAS_HOST_PATH}/documents`;
|
|
|
|
/** Keep the historical Canvas plugin scope so existing capability URLs remain valid. */
|
|
const CANVAS_NODE_CAPABILITY: PluginNodeCapabilitySurface = {
|
|
surface: "canvas",
|
|
scopeKey: "canvas:canvas",
|
|
};
|
|
|
|
/** Returns true only for the core-owned Canvas document subtree. */
|
|
export function isCanvasDocumentHttpPath(pathname: string): boolean {
|
|
return pathname.startsWith(`${CANVAS_DOCUMENTS_PATH}/`);
|
|
}
|
|
|
|
/** Resolves auth for any canonicalized candidate targeting core Canvas documents. */
|
|
export function resolveCanvasNodeCapability(
|
|
pathCandidates: readonly string[],
|
|
): PluginNodeCapabilitySurface | undefined {
|
|
return pathCandidates.some(isCanvasDocumentHttpPath) ? CANVAS_NODE_CAPABILITY : undefined;
|
|
}
|
|
|
|
/** Adds the core Canvas surface while removing stale plugin-owned duplicates. */
|
|
export function withCoreCanvasNodeCapability(
|
|
surfaces: readonly PluginNodeCapabilitySurface[],
|
|
enabled = true,
|
|
): PluginNodeCapabilitySurface[] {
|
|
const withoutStaleCanvas = surfaces.filter(
|
|
(entry) => entry.surface.trim() !== CANVAS_NODE_CAPABILITY.surface,
|
|
);
|
|
return enabled ? [CANVAS_NODE_CAPABILITY, ...withoutStaleCanvas] : withoutStaleCanvas;
|
|
}
|