Files
rea/src/domain/localPath.ts
T
5b172b1042 fix(contracts)!: require absolute local paths for session filesystem inputs (#948)
fix(contracts): require absolute local paths for session filesystem inputs

Snapshot, evidence-bundle export, and managed-target inputs accepted any non-empty string, so relative paths were resolved against the MCP server working directory instead of the caller's intent. Refine these contract fields to absolute host paths (Windows drive and forward-slash forms included), advertise the constraint on the property descriptions, and regenerate the derived catalog, product catalog, and skill catalog digest. Relative CLI options are unaffected because CLI flows do not parse these MCP contracts.

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-08 00:31:55 +08:00

15 lines
540 B
TypeScript

import { isAbsolute, relative, sep } from "node:path";
/** True when the value is an absolute filesystem path on the host platform. */
export const isAbsoluteLocalPath = (value: string): boolean =>
isAbsolute(value);
/** Test lexical containment on the host platform; callers must resolve symlinks first. */
export const isPathWithinRoot = (root: string, path: string): boolean => {
const value = relative(root, path);
return (
value === "" ||
(value !== ".." && !value.startsWith(`..${sep}`) && !isAbsolute(value))
);
};