Files
openclaw/src/canvas/constants.ts
Peter Steinberger 460e3e669c fix(canvas): restore shipped policy/host-disable contracts; harden workspaces doctor cleanup (#110927)
* fix(dashboard): harden canvas and workspace compatibility

* docs(web): add dashboard architecture

* chore: remove release-owned changelog entry

* docs: update dashboard architecture map
2026-07-18 23:00:00 +01:00

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;
}