Overview
Thedist/ directory contains packaged distribution artifacts for consumers. These are generated files, not the source of truth.
Distribution Artifacts
Running./scripts/generate-dist.sh produces five committed artifacts:
dist/safehouse.sh
Single-file executable containing embedded profiles + runtime shell logic. Portable and self-contained.
dist/Claude.app.sandboxed.command
Single-file launcher for Claude Desktop. Fetches latest apps policy from GitHub at runtime.
dist/Claude.app.sandboxed-offline.command
Offline launcher for Claude Desktop with embedded apps policy (no network required).
dist/profiles/safehouse.generated.sb
Static default policy template with
HOME_DIR and workdir placeholders.dist/profiles/safehouse-for-apps.generated.sb
Static apps policy with
--enable=macos-gui,electron,all-agents,all-apps.dist/safehouse.sh: Single-File Executable
Purpose
Thedist/safehouse.sh executable is a self-contained, portable distribution of Agent Safehouse. It embeds:
- All profile files (
profiles/**/*.sb) as heredoc blocks - Full runtime shell logic from
bin/safehouse.shandbin/lib/*.sh - Metadata (embedded profiles last modified timestamp)
Structure
1
Banner and Metadata
2
Profile Keys Array
3
Embedded Profile Bodies
Each profile is embedded as a heredoc:
4
Inlined Runtime Logic
All shell logic from
bin/safehouse.sh, bin/lib/common.sh, bin/lib/policy/*.sh, and bin/lib/cli.sh is concatenated inline.5
Overridden Functions
Key functions are overridden to read from embedded profiles instead of filesystem:
6
Main Entrypoint
Usage
Identical tobin/safehouse.sh:
Static Policy Files
dist/profiles/safehouse.generated.sb
Default policy template with:HOME_DIRplaceholder:"/__SAFEHOUSE_TEMPLATE_HOME__"- Workdir grant placeholder:
"/__SAFEHOUSE_TEMPLATE_WORKDIR__" - All agents enabled (
--enable=all-agents) - No optional integrations (use
--enable=...when generating)
sandbox-exec.
dist/profiles/safehouse-for-apps.generated.sb
Apps policy template with:HOME_DIRplaceholder:"/__SAFEHOUSE_TEMPLATE_HOME__"- Workdir grant placeholder:
"/__SAFEHOUSE_TEMPLATE_WORKDIR__" - All agents + all apps enabled (
--enable=macos-gui,electron,all-agents,all-apps) - Electron and macOS GUI integrations (for Claude Desktop, VS Code, etc.)
Claude.app.sandboxed.command, Claude.app.sandboxed-offline.command).
Generation Process
Invoking the Generator
Requires macOS with
sandbox-exec. The generator invokes bin/safehouse.sh to produce static policies.Generation Steps
1
Collect and Validate Profiles
00-base.sb, 10-system-runtime.sb, etc.) and counts by stage prefix.2
Resolve Embedded Profiles Timestamp
git log for deterministic timestamps across CI/machines. Falls back to filesystem mtime if git is unavailable.3
Generate dist/safehouse.sh
4
Generate Static Policies
bin/safehouse.sh with template paths, then rewrites HOME_DIR and workdir placeholders.5
Generate Claude Launchers
6
Cleanup and Output
Deterministic Output
Why Determinism Matters
Dist artifacts are committed to the repository. Non-deterministic generation causes unnecessary diffs and merge conflicts.How Safehouse Achieves Determinism
Lexicographic Profile Sorting
Lexicographic Profile Sorting
Git-Based Timestamps
Git-Based Timestamps
git log commit timestamp instead of filesystem mtime. Same commit = same timestamp.Template Paths
Template Paths
Fixed HOME Environment
Fixed HOME Environment
HOME to template path during generation. Output is independent of the generator’s actual home directory.CI/CD Integration
Auto-Regeneration Workflow
Safehouse CI automatically regeneratesdist/ when profiles or runtime logic change:
Manual Regeneration
When contributing:Inspecting Dist Artifacts
Verify Embedded Profiles
Extract a Single Embedded Profile
Compare Source vs Embedded
Key Takeaways
Generated, Not Source
dist/ artifacts are generated files. All changes must be made in bin/ and profiles/, then regenerated.Single-File Distribution
dist/safehouse.sh embeds all profiles and runtime logic for portable, self-contained execution.Deterministic Output
Lexicographic sorting, git timestamps, and template paths ensure identical output across machines.
CI Auto-Regeneration
Safehouse CI auto-commits regenerated
dist/ when profiles or runtime logic change.Next Steps
Contributing
Learn how to contribute profiles, runtime logic, and tests to Agent Safehouse.
Policy Architecture
Understand how profiles are assembled and concatenated at runtime.