feat: support multiple workspace roots (#584)

This commit is contained in:
junes
2026-05-07 08:30:52 +08:00
committed by GitHub
parent e17d7e5995
commit 0006d04f9e
16 changed files with 302 additions and 126 deletions
+12 -7
View File
@@ -1,17 +1,22 @@
import { isAbsolute } from 'node:path'
/**
* Resolves the runner's workspace root — the directory tree the runner is
* Resolves the runner's workspace roots — the directory trees the runner is
* allowed to browse and spawn sessions in. Returns `undefined` when the
* user hasn't explicitly opted in; in that case the runner behaves like
* the legacy hapi (no scoping, no /browse feature surfaced in the web UI).
* legacy hapi (no scoping, no /browse feature surfaced in the web UI).
*
* The only signal is the `explicit` argument — typically the resolved
* `--workspace-root` flag. Non-absolute values are ignored.
* `--workspace-root` flag values. Non-absolute values are ignored.
*/
export function resolveWorkspaceRoot(explicit?: string): string | undefined {
if (explicit && isAbsolute(explicit)) {
return explicit
export function resolveWorkspaceRoots(explicit?: string[]): string[] | undefined {
if (!explicit?.length) {
return undefined
}
return undefined
const uniqueRoots = Array.from(
new Set(explicit.filter((path): path is string => typeof path === 'string' && isAbsolute(path)))
)
return uniqueRoots.length > 0 ? uniqueRoots : undefined
}