import type { AgentNetwork, AgentSandboxGrants } from '../agent/folder.js'; /** Filename of the generated per-agent nono profile, written into the agent's state dir. */ export declare const AGENT_PROFILE_FILE = "nono-profile.json"; /** True when `target` is `ancestor` itself, or nested under it. */ export declare function isAncestorOrSelf(ancestor: string, target: string): boolean; /** * A sandboxed run's cwd becomes an `allow` grant in the generated profile (see * `buildProfileJson`). nono refuses to start if any grant overlaps its own * protected state root, `~/.local/state/nono` (see ARCHITECTURE.md: "never * grant `/Users` or `~/`") — so a cwd of the user's home dir, an ancestor of * it (`/Users`, `/`), or a directory that itself contains the protected root * (`~/.local`, `~/.local/state`) would make nono reject the profile with an * opaque error. Returns the offending `cwd` so the caller can fail fast with * a friendly one instead; `undefined` when `cwd` is safe to grant. */ export declare function findDegenerateSandboxCwd(cwd: string, home: string): string | undefined; /** Expand a leading `~` or `$HOME` against `home`; other paths pass through unchanged. */ export declare function expandHome(path: string, home: string): string; export interface ProfileSpec { readonly home: string; /** pi's working dir (the target project) — granted read+write. */ readonly cwd: string; /** The portable agent folder — granted read. */ readonly agentDir: string; /** The agent's per-agent state dir — granted read+write, and where this profile is written. */ readonly stateDir: string; /** * The real git dir when `cwd` is a linked worktree or submodule checkout, * resolved from the `.git` pointer file (see `./linked-git-dir.js`). * Granted `allow`: git writes the index, locks, objects, and refs there, and * without it every git command inside the sandbox fails with * `fatal: not a git repository`. Absent for regular repos — a `.git` * directory already sits inside the cwd grant. */ readonly linkedGitDir?: string; /** Extra grants from the agent folder's `sandbox/nono.json`. */ readonly grants: AgentSandboxGrants; /** Raw Seatbelt s-expr rules from the agent's `sandbox/nono.json`, merged after the base's. */ readonly rules: readonly string[]; /** Precedence-resolved network posture, emitted as the profile's `network` block. Absent ⇒ nono default (open). */ readonly network?: AgentNetwork; /** Active host terminal sockets, granted connect access without bind or directory writes. */ readonly terminalSocketPaths?: readonly string[]; /** Installed hook files, including custom Pi homes and symlink targets outside the default Pi grant. */ readonly terminalExtensionFiles?: readonly string[]; } /** * Build the per-agent nono profile: the embedded `cradle-pi` base (which * `extends default`, pulls the `node_runtime` group, and grants mise/pi/say * paths) merged with this run's grants — the target cwd, the agent folder, the * state dir, the linked git dir when cwd is a worktree/submodule checkout, and * the agent's own path and direct-child Unix socket grants from `sandbox/nono.json`. Regenerated every run into the * state dir, so there is no shared global profile: each agent's permissions * are fully described by its own directory. * * `meta.name` is derived from the state-dir basename so every agent gets a * distinct profile identity (no cross-agent collisions in nono's state). * `~`/`$HOME` in the agent's grants are expanded here; base entries keep their * `$HOME` form (nono expands those). Net posture stays a `nono run` flag. * * The agent's `unsafe_macos_seatbelt_rules` are appended AFTER the base's rules: * Seatbelt is last-match-wins, so a later agent rule can widen (or override) a * base allow, never the reverse. * * The resolved `network` posture is emitted as the profile's `network` block * (nono's canonical key names). Absent ⇒ no `network` block ⇒ nono default * (open). nono enforces it — including failing closed on a bad key or an * unenforceable platform — so there is no cradle-side fallback here. */ export declare function buildProfileJson(spec: ProfileSpec): string;