Something went wrong. Try again.
Where attention appears to go across agent threads: collector, web explorer, and native iOS client
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import jsonimport shutilfrom pathlib import Pathimport sys
def profile(root, role, port=8766): home = Path.home() python = (root / '.venv/bin/python').resolve() runtime = python.parent.parent quote = lambda path: json.dumps(str(path)) rules = [ '(version 1)', '(deny default)', '(import "system.sb")', '(allow file-read-metadata)', '(allow sysctl-read)', f'(allow process-exec (literal {quote(python)}))', f'(allow file-read* file-map-executable (subpath {quote(runtime)}) (subpath {quote(root)}))', '(allow file-read* (subpath "/private/etc") (literal "/dev/urandom") (literal "/dev/random") (literal "/dev/null"))', '(allow file-write* (literal "/dev/null"))', ] if role == 'web': rules += [ f'(allow file-read* file-write* (subpath {quote(home / ".local/state/agents-mcp-auth")}))', f'(allow file-read* (literal {quote(home / ".config/agents-mcp/server.env")}) (literal {quote(home / ".local/state/agents-mcp-export/sessions.json")}) (literal {quote(home / ".local/state/agents-mcp-export/attention.json")}) (literal {quote(home / ".local/state/agents-mcp-export/attention-digest.json")}))', '(allow network-outbound)', f'(allow network-inbound (local ip "localhost:{port}"))', '(allow mach-lookup (global-name "com.apple.SystemConfiguration.configd") (global-name "com.apple.system.opendirectoryd.libinfo") (global-name "com.apple.trustd") (global-name "com.apple.trustd.agent") (global-name "com.apple.networkd"))', ] elif role == 'collector': rules += [ f'(allow file-read* (subpath {quote(home / ".codex/sessions")}) (subpath {quote(home / ".codex/archived_sessions")}) (subpath {quote(home / ".claude/projects")}))', f'(allow file-read* (literal {quote(home / ".codex")}))', f'(allow file-read* (regex {quote(str(home / ".codex") + r"/state_[0-9]+\.sqlite(-wal|-shm)?$")}))', f'(allow file-read* file-write* (subpath {quote(home / ".local/state/agents-mcp-export")}))', ] for root in [home / '.pi/agent/sessions', home / 'Library/Application Support/Orca/codex-runtime-home/home/sessions', home / 'Library/Application Support/Orca/codex-runtime-home/home/archived_sessions']: rules.append(f'(allow file-read* (subpath {quote(root)}))') orca = home / 'Library/Application Support/Orca' runtime = orca / 'codex-runtime-home/home' rules += [ f'(allow file-read* (literal {quote(runtime)}) (literal {quote(orca / "profiles")}) (literal {quote(orca / "claude-accounts")}))', f'(allow file-read* (regex {quote(str(runtime) + r"/state_[0-9]+\.sqlite(-wal|-shm)?$")}))', f'(allow file-read* (regex {quote(str(orca / "profiles") + r"/[^/]+/profile-state\.db(-wal|-shm)?$")}))', f'(allow file-read* (regex {quote(str(orca / "claude-accounts") + r"/[^/]+/home/projects(/.*)?$")}))', ] for base in [home, Path('/private/tmp')]: rules.append(f'(allow file-read* (regex {quote(str(base) + r"/.*[/]\.git(/.*)?/(config|HEAD|commondir)$")}) (regex {quote(str(base) + r"/.*[/]\.git$")}))') elif role == 'summarizer': sops = Path(shutil.which('sops') or '/opt/homebrew/bin/sops').resolve() export = home / '.local/state/agents-mcp-export' rules += [ f'(allow process-fork)', f'(allow process-exec (literal {quote(sops)}))', f'(allow file-read* file-map-executable (literal {quote(sops)}))', f'(allow file-read* (literal {quote(home / "tangled.org/zzstoatzz.io/secrets/prod.yaml")}) (literal {quote(home / "Library/Application Support/sops/age/keys.txt")}) (literal {quote(home / ".config/sops/age/keys.txt")}) (literal {quote(export / "attention-evidence.json")}) (literal {quote(home / ".local/state/agents-mcp-auth/viewer-zones.json")}))', '(allow network-outbound)', '(allow mach-lookup (global-name "com.apple.SystemConfiguration.configd") (global-name "com.apple.system.opendirectoryd.libinfo") (global-name "com.apple.trustd") (global-name "com.apple.trustd.agent") (global-name "com.apple.networkd"))', ] for name in ['attention-digest.json', 'attention-digest.tmp', 'attention-digest-cache.json', 'attention-digest-cache.tmp', 'attention-digest.lock']: rules.append(f'(allow file-read* file-write* (literal {quote(export / name)}))') else: raise ValueError('Unknown sandbox role') return '\n'.join(rules) + '\n'
if __name__ == '__main__': root = Path(__file__).resolve().parents[1] destination = Path(sys.argv[2]) destination.write_text(profile(root, sys.argv[1]))