MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / resolveWorkspace

Function resolveWorkspace

src/lib/workspace-resolver.ts:19–41  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

17 * - Any other workspace-* directory that exists
18 */
19export function resolveWorkspace(workspaceId: string): string | null {
20 if (!workspaceId) return null;
21
22 // Direct workspace match
23 if (workspaceId === 'workspace') {
24 const p = path.join(OPENCLAW_DIR, 'workspace');
25 return fs.existsSync(p) ? p : null;
26 }
27
28 // workspace-* match (e.g., workspace-codev, workspace-linkedin)
29 if (workspaceId.startsWith('workspace-')) {
30 const p = path.join(OPENCLAW_DIR, workspaceId);
31 return fs.existsSync(p) ? p : null;
32 }
33
34 // Check if it's a subdirectory of the main workspace (e.g., mission-control, mission-control-v2)
35 const subdir = path.join(OPENCLAW_DIR, 'workspace', workspaceId);
36 if (fs.existsSync(subdir)) {
37 return subdir;
38 }
39
40 return null;
41}
42
43/**
44 * Validate that a resolved file path is within its workspace base.

Callers 3

POSTFunction · 0.90
POSTFunction · 0.90
resolveAndValidatePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected