UNPKG

@mastra/core

Version:
60 lines • 2.46 kB
/** * Seatbelt (macOS sandbox-exec) * * macOS built-in sandboxing using sandbox-exec with SBPL profiles. * * Important: Uses `-p` (inline profile) instead of `-f` (file) because * `-f` doesn't work reliably with path filters on modern macOS. * * Note on macOS sandbox limitations: * - `(allow file-read* (subpath ...))` only works WITH a preceding `(allow file-read*)` * - So for reads: allow all, then deny specific paths * - For writes: allow specific paths with subpath filters * * Based on the approach used by Claude Code's sandbox-runtime: * https://github.com/anthropic-experimental/sandbox-runtime */ import type { NativeSandboxConfig } from './types.js'; /** * SBPL comment that marks a profile as generated by Mastra. * * Written into every generated profile. A profile file that carries this marker is ours, * even when it sits at a path the user configured, so Mastra regenerates it instead of * treating it as user-authored SBPL. */ export declare const GENERATED_PROFILE_MARKER = "; mastra-generated-profile (regenerated on every start)"; /** * Check whether a profile file was generated by Mastra. * * @param profile - The SBPL profile content read from disk * @returns True when the content carries the generated-profile marker */ export declare function isGeneratedSeatbeltProfile(profile: string): boolean; /** * Generate a seatbelt profile for the given configuration. * * The profile: * - Allows all file reads (can't restrict with subpath on macOS) * - Restricts file writes to temp directories, configured writable paths, and the workspace unless read-only * - Blocks network unless explicitly allowed * * @param workspacePath - The workspace directory to sandbox * @param config - Additional sandbox configuration * @returns The generated SBPL profile content */ export declare function generateSeatbeltProfile(workspacePath: string, config: NativeSandboxConfig): string; /** * Build the command arguments for sandbox-exec. * * Uses `-p` (inline profile) instead of `-f` (file) because * `-f` doesn't work reliably with path filters on modern macOS. * * @param command - The full shell command string to run * @param profile - The SBPL profile content (not a file path) * @returns Wrapped command and arguments for sandbox-exec */ export declare function buildSeatbeltCommand(command: string, profile: string): { command: string; args: string[]; }; //# sourceMappingURL=seatbelt.d.ts.map