Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.
TypeScript agentai-agentai-agentsai-assistantandroidautomationchatgptcoding-agentcomputer-usedesktop-appelectronllmlocal-firstmcpmulti-agentollamaopenaiprivacyself-hostedtypescript
import { sensitiveReadBoundary } from "@pibot/execution";
import { nodeFileSystem, protectedPaths } from "@pibot/policy";
import { RpcError } from "@pibot/protocol-base";
import { abortable } from "../../core/abort.ts";
import type { LocalDependencies } from "../../core/local-types.ts";
/** Associated roots become inside writes, so the outside-write gate can no longer protect them. */
export async function assertWritableFolders(
deps: Pick<LocalDependencies, "platform" | "userHome" | "dataDir" | "env">,
paths: readonly string[],
home: string,
signal: AbortSignal,
) {
const sensitive = await abortable(
sensitiveReadBoundary(deps.platform, [deps.userHome, home], deps.env),
signal,
);
const protection = await protectedPaths(
{
platform: deps.platform,
home: deps.userHome,
cwd: home,
roots: [...paths],
fs: nodeFileSystem,
signal,
},
[...sensitive.denyRead, deps.dataDir],
);
signal.throwIfAborted();
if (paths.some((path) => protection.covers(path))) throw new RpcError(-32602, "protected_path");
}