# Entangle setup for AI agents ## 0. Start here Set up Entangle on this machine: install it, register its MCP server, verify the connection, and report the result. Group membership—not LAN access or `--context`—defines trust. Ask the human before installing or upgrading, changing firewall rules, or editing a configuration file you did not create; show the proposed configuration diff first. | Who | Responsibilities | | --- | --- | | Agent | Detect, install or upgrade, register MCP, verify, and report. | | Human | Approve installs, firewall changes, and config edits; reload the MCP client; run all human-only group commands. | This guide sets up one machine. For every other machine, give the human this exact line to paste into that machine's agent: > Read https://raw.githubusercontent.com/DailenG/entangle/main/docs/AGENT_SETUP.md and follow it to set up Entangle on this machine. For scenario walkthroughs, see the [playbooks](playbooks/README.md). ### Running commands on Windows Write each Windows command or check to a temporary `.ps1` file, run it with `powershell.exe -NoProfile -ExecutionPolicy Bypass -File `, then delete the file. Never pass inline `-Command` strings: an outer shell (often bash in omp) can mangle quotes and `$` variables. In Windows PowerShell 5.1, module cmdlets may be unavailable in spawned processes. For SHA-256, set `$path` to the file and use .NET rather than `Get-FileHash`: ```powershell $s=[System.Security.Cryptography.SHA256]::Create(); $f=[IO.File]::OpenRead($path); -join ($s.ComputeHash($f) | ForEach-Object { $_.ToString('x2') }); $f.Dispose() ``` If another cmdlet is reported as not recognized, import its module by full path and retry. For example, use the Utility module for `Get-FileHash` and friends, or the Management module for `Get-Process` and `Get-Item`: ```powershell Import-Module "$PSHOME\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1" Import-Module "$PSHOME\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1" ``` **Verify:** Confirm the human understands who installs, reloads, and runs group commands. **If this fails:** Ask the human to clarify the goal or any ground rule before proceeding. ## 1. Detect 1. Detect the OS, architecture, MCP client, and whether `entangle` is installed. If it is installed, record `entangle --version`. On Linux or macOS: ```sh uname -s uname -m if command -v entangle >/dev/null 2>&1; then command -v entangle entangle --version else printf 'entangle is not installed\n' fi ``` On Windows, run these through the temporary `.ps1` procedure above: ```powershell Get-CimInstance Win32_OperatingSystem | Select-Object Caption, OSArchitecture $entangle = Get-Command entangle -ErrorAction SilentlyContinue if ($entangle) { $entangle.Source; entangle --version } else { "entangle is not installed" } ``` Identify whether this agent runs through Claude Desktop, Claude Code, LM Studio, omp, or another MCP client. Ask the human if it is unclear. **Verify:** Record the OS, architecture, MCP client, and installed version (or that Entangle is not installed). **If this fails:** Ask the human which client hosts this agent and which operating system this machine uses. ## 2. Install or upgrade 2. Install the latest published Entangle release. If an older version is installed, explain the upgrade and ask the human first; after approval, rerun the same installer. Every machine in a group must use the same release line: `0.7.x`. On Windows PowerShell, after approval, run this through a temporary `.ps1`: ```powershell irm https://raw.githubusercontent.com/DailenG/entangle/main/install.ps1 | iex ``` On macOS or Linux: ```sh curl -fsSL https://raw.githubusercontent.com/DailenG/entangle/main/install.sh | sh ``` Prebuilt binaries require a published release. If no release or prebuilt binary is available, use the source fallback only when Cargo is already installed: ```sh cargo install --git https://github.com/DailenG/entangle entangle ``` Ask before installing Rust or changing the toolchain. See [SETUP.md](SETUP.md) for installer defaults and platform details. Record the absolute executable path printed by the installer: Unix prints `Entangle MCP executable: ` and Windows prints `Entangle executable: `. If it did not print a path, use `$HOME/.local/bin/entangle` on Unix or `$env:LOCALAPPDATA\Programs\entangle\bin\entangle.exe` on Windows (PowerShell syntax; write the fully expanded path into config files). Use this absolute path for every later CLI check and MCP registration. Groups created with Entangle 0.6 are incompatible with 0.7 and remain only on each machine's local disk. `entangle group list` prints this row for a group named `work`: ```text work outdated -- group work was created by Entangle 0.6; run `entangle group leave work` and create it again ``` To replace an outdated group, the human must do these steps in order: 1. Upgrade every machine to Entangle 0.7.x. 2. Quit and reload the MCP clients on every machine. 3. On each machine, run `entangle group leave ` in a terminal. This deletes only that machine's local outdated group. 4. On one machine only, run `entangle group create --invite `, where `` is the number of other machines. 5. On every other machine, run `entangle group join ` in its terminal. Only one machine recreates the group; the others join it. After an upgrade, an old process can still hold the saved-identity lock and TCP port 7337. A new server can then use an ephemeral identity and fallback link port; with the default name, its displayed name may change. Ask the human to quit every MCP client, then inspect `pgrep -a entangle` on Linux/macOS or Task Manager on Windows. Do not kill processes yourself. **Verify:** Run ` --version` and ` --help`. The help must list `serve`, `node`, `scan`, `group`, `peer`, and `repeater`. **If this fails:** Check release availability and the executable path. Report the first failing command. Do not install system packages or change the toolchain without approval. ## 3. Identity 3. Keep the default identity unless the human requests a custom name. Entangle saves a particle ID in its data directory, then defaults the display name to `-`. The ID and default name stay stable across restarts; `--name` is optional. Do not assume your particle name from the prompt: read your ID and name from the `self` object returned by `find_entangled_particles`. A second Entangle server using the same data directory while another holds its lock gets an ephemeral identity. If chosen, `--context` is only a project label/filter; it does not establish trust. Ask for a `--context` only if the human wants agents scoped to one project; use exactly the same string on both machines. Context is optional. **Verify:** Record the agreed context, if applicable. Once connected, use `find_entangled_particles.self` to identify this particle's actual ID and name. **If this fails:** Ask the human whether the context should match the other machine; do not invent a shared project identifier or assume a name from the prompt. ## 4. Network 4. Review the required ports. Entangle uses TCP `7337` for the encrypted link and UDP `5353` for mDNS by default. `--link-port` changes the link port. If that port is occupied, Entangle falls back to an ephemeral port. Group invitations use a separate ephemeral TCP listener, open only while the invite is active. The inviter prints its direct `--via ` address. Do not ask the human to open a guessed invite port: it is random for each invite. `--via` bypasses mDNS discovery, not a firewall. **Elevation rule.** Firewall changes need administrator rights. Elevate only through an operating-system consent prompt that the human answers: UAC on Windows, or the polkit password dialog that `pkexec` opens on a Linux desktop. Before launching it, show the human the exact script, say that a prompt will appear, and wait for approval. Never use `sudo` (including `sudo -n`), `runas /savecred`, or stored credentials: they can reuse cached rights without the human seeing a prompt. If the prompt is declined, cannot appear (SSH or headless session), or fails, stop, report it, and give the human the commands below to run in their own administrator terminal. Do not retry. Delete temporary scripts afterwards. **Linux (UFW).** Act only if UFW is installed (`command -v ufw` or `/usr/sbin/ufw`). These fixed-port rules cover the default link and optional mDNS discovery; they do not open the random invite listener. On a local desktop session (`DISPLAY` or `WAYLAND_DISPLAY` set, no `SSH_CONNECTION`) with `pkexec` available, write this script to a file created with `mktemp`: ```sh set -eu if ! ufw status | grep -q '^Status: active'; then echo 'UFW is not active; no rule changed.' exit 0 fi ufw allow 7337/tcp ufw allow 5353/udp ``` After the human approves, run `pkexec /bin/sh