Skip to main content

Overview

The dist/ directory contains packaged distribution artifacts for consumers. These are generated files, not the source of truth.
Never hand-edit dist/ files. All changes must be made in bin/ and profiles/, then regenerated via ./scripts/generate-dist.sh.

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

The dist/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.sh and bin/lib/*.sh
  • Metadata (embedded profiles last modified timestamp)
Consumers can download one file and run it without cloning the repo.

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 to bin/safehouse.sh:

Static Policy Files

dist/profiles/safehouse.generated.sb

Default policy template with:
  • HOME_DIR placeholder: "/__SAFEHOUSE_TEMPLATE_HOME__"
  • Workdir grant placeholder: "/__SAFEHOUSE_TEMPLATE_WORKDIR__"
  • All agents enabled (--enable=all-agents)
  • No optional integrations (use --enable=... when generating)
Use case: Consumers who want to manually replace placeholders and use the policy directly with sandbox-exec.

dist/profiles/safehouse-for-apps.generated.sb

Apps policy template with:
  • HOME_DIR placeholder: "/__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.)
Use case: Embedded in Claude Desktop launchers (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

Validates required profiles (00-base.sb, 10-system-runtime.sb, etc.) and counts by stage prefix.
2

Resolve Embedded Profiles Timestamp

Uses git log for deterministic timestamps across CI/machines. Falls back to filesystem mtime if git is unavailable.
3

Generate dist/safehouse.sh

Concatenates banner, profile keys, embedded heredocs, runtime logic, and overrides into a single executable.
4

Generate Static Policies

Invokes bin/safehouse.sh with template paths, then rewrites HOME_DIR and workdir placeholders.
5

Generate Claude Launchers

Creates single-file launchers for Claude Desktop (online and offline variants).
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

Forces consistent ordering across different machines and locales.
Uses git log commit timestamp instead of filesystem mtime. Same commit = same timestamp.
Static placeholders instead of actual home directory paths. Ensures generated policies are portable.
Overrides 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 regenerates dist/ when profiles or runtime logic change:

Manual Regeneration

When contributing:
PRs that modify profiles/ or bin/ must include regenerated dist/ files. CI will fail if dist/ is out of sync.

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.