---
name: ncn-apple
description: ncn apple profile. Connect to a Mac on the mesh over SSH and work inside a contained box (apple/container disposable Linux VM) instead of on the bare host. Used by the ncn conductor when the chosen node is a Mac; also use when the user asks to reach a Mac device safely or run contained work on another Mac.
---

# ncn-apple: contained session on a remote Mac

You are the **host conductor**. The pane to your right is a live SSH session on
a Mac on the mesh. Do **not** run heavy or risky work on its bare host. Use a
**contained** session (`box`, an apple/container disposable Linux VM). That gives
you isolation (blast radius = one worktree), a reproducible Linux environment,
and no host-credential exposure: the same safety model as the cluster's
Apptainer, but for a Mac.

```
 HOST (you, cxx) ──ssh (Tailscale)──▶ REMOTE MAC ──box──▶ disposable Linux VM
                                       worktree mounted at its real path
                                       box has its own IP (192.168.64.x)
 localhost:PORT ◀──ncn tunnel <box-ip>:PORT── service bound to 0.0.0.0 in the box
```

Recover state from window options:

```bash
SSH_PANE=$(tmux show-options -wqv @ncn_ssh_pane)
HOST=$(tmux show-options -wqv @ncn_host)     # user@tailscale-ip
```

Drive the Mac through `$SSH_PANE`: `tmux send-keys -t $SSH_PANE '<cmd>' Enter`,
read back with `tmux capture-pane -p -t $SSH_PANE`.

Your mode is in `@ncn_mode`: **connect** (`nc`, a contained box session you
drive) or **endpoint** (`ncn`, that plus a program in the box exposed at this
host's localhost). Do the matching section.

## nc: connect (contained box session)

**0. Confirm the session.** `capture-pane` the right pane; make sure SSH is at a
shell prompt on the Mac.

**1. Pick the project.** Ask the user which repo/dir to work in, then `cd` there
in the right pane. (`box` mounts the current worktree at its real path; the main
repo too if it's a linked worktree.)

**2. Enter a contained session.** In the right pane:

```bash
box bash        # disposable Linux VM; edits/commits land in the real worktree,
                # execution stays inside the VM; no host creds enter the box
```

Confirm with `capture-pane` that you're now at a Linux prompt inside the box
(`uname -a` shows Linux). If `box` is missing, the Mac needs anu + apple/container
(`box doctor` / `box build`). Surface that to the user rather than falling back
to the bare host.

**3. Work inside the box.** Build/run/test here. Because it's contained, an
autonomous step can't harm the Mac's host. For an *agent* on the Mac rather than a
shell, `cxc` (= `box claude --dangerously-skip-permissions`, full-auto) is the
contained-agent form.

## ncn: expose a live endpoint

A box has its **own IP** on the apple/container network (192.168.64.x) and is
**not** on the Mac's localhost. Bind the service to `0.0.0.0`, read the box IP on
the Mac, then tunnel to that IP (the ssh -L remote-side target is the box IP, not
localhost).

**1. Launch** the program **inside the box**, bound to `0.0.0.0`, e.g.
`jupyter lab --no-browser --ip 0.0.0.0 --port 8888 --allow-root` (or a model
server, dashboard, or API). Grab the port (and token, if any).

**2. Find the box IP on the Mac** (in the SSH pane, not the box):

```bash
container ls                                   # name is box-<dirname>-<random>
container inspect <box-name> | grep -i address  # the 192.168.64.x box IP
```

**3. Expose** the box's port to your localhost from this host:

```bash
ncn tunnel <box-ip> <port>     # localhost:<port> here → the box's <box-ip>:<port>
```

**4. Hand off** `http://localhost:<port>` (browser, or a headless agent drives
it). `ncn down` closes the tunnel.

## Notes

- **Push from the Mac's host, not the box.** Boxes hold no SSH/gh creds. Commit
  inside the box (lands in the real worktree), then push from the Mac host pane.
- **Arch:** an Apple-silicon box is linux/arm64 by default; build `--platform
  linux/amd64` if you need parity with an x86 target.
- **No GPU** in a Mac box.
- Caps: `ANU_BOX_CPUS` (default 2), `ANU_BOX_MEMORY` (default 4G) on that Mac.
