MCPcopy Create free account
hub / github.com/clawbot7/cli-gateway / resolveWorkspacePath

Function resolveWorkspacePath

src/tools/workspace.ts:3–18  ·  view source on GitHub ↗
(
  workspaceRoot: string,
  requestedPath: string,
)

Source from the content-addressed store, hash-verified

1import path from 'node:path';
2
3export function resolveWorkspacePath(
4 workspaceRoot: string,
5 requestedPath: string,
6): string {
7 if (!path.isAbsolute(requestedPath)) {
8 throw new Error(`ACP path must be absolute: ${requestedPath}`);
9 }
10
11 const resolved = path.resolve(requestedPath);
12 const root = path.resolve(workspaceRoot);
13
14 if (resolved === root) return resolved;
15 if (resolved.startsWith(root + path.sep)) return resolved;
16
17 throw new Error(`Path escapes WORKSPACE_ROOT: ${requestedPath}`);
18}

Callers 5

workspace.test.tsFile · 0.85
handleAgentRequestMethod · 0.85
terminalCreateMethod · 0.85
normalizeWhitelistPrefixFunction · 0.85
normalizePathPrefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected