arc attach reverse-mounts a local directory into a remote arc daemon, exposing it as a provider under /modules/{namespace} on that remote daemon. This is the opposite direction from arc afs mount: instead of mounting something remote into your local AFS, you're making something local visible to a remote AFS.
Usage
arc attach --to <url> [options]--to is the only strictly required flag; what else you need depends on which of the three things you're attaching:
- directory attach (the default):
--namespace <name>+--source <dir>— exposes a local directory as a provider mounted at/modules/{namespace}on the remote - host attach:
--as-host— exports this host's HostFace at/peers/{peer.json.id}on the remote (no--namespace/--sourceneeded) - engine attach:
--as-engine <name>alone — attaches a bare code-agents engine under that id; combined with--as-hostit's just display metadata alongside the HostFace
Options
--to <url>(required): target daemon URL, e.g.ws://host:4900orws://host:4900/ws/attach--namespace <name>: namespace to expose on the target, mounted at/modules/{namespace}(directory attach)--source <dir>: local directory to expose as the provider (directory attach)--as-engine <name>: engine id alone; with--as-hostit's display metadata only (remote id ispeer.json'sid)--as-host: export this host's HostFace at/peers/{peer.json.id}on the target--readonly: expose the source as read-only (directory attach)--replace: replace an existing session at this namespace--token <token>: owner access token for a remote daemon (skipped for loopback targets)--browser: open a browser for the auth flow (defaulttrue); pass--no-browserwith--tokenfor unattended runs--json: print machine-readable events on stdout instead of the default human text--view: output view format (jsonis equivalent to--json)--instance <name>/-i: which local ARC instance this command operates against; omit fordefault--home <dir>: instance root (where this host'speer.jsonand credentials live; usually not needed). To pick which instance, use--instance
On SIGINT (Ctrl+C) arc attach detaches gracefully so the remote side unmounts cleanly.
Example
arc attach --to ws://host:4900 --namespace my-local-src --source ./src --readonly
arc attach --to ws://host:4900 --as-host--json
With --json, every progress line (Attaching..., to:, namespace:, source:, Press Ctrl+C to detach., Detaching...) moves to stderr, and stdout carries only newline-delimited JSON events — a script piping arc attach ... --json can read stdout as pure JSON without filtering out human prose:
$ arc attach --to ws://127.0.0.1:PORT/ws/attach --source /tmp --namespace test --jsonstdout (only this one line, on a successful attach):
{"event":"attached","sessionId":"sess_test_...","namespace":"test","targetPath":"/modules/test"}stderr (all progress, banner omitted):
Attaching...
to: ws://127.0.0.1:PORT/ws/attach
namespace: test
source: /tmp
Press Ctrl+C to detach.On a failure, --json does not add a matching JSON object to stdout — stdout stays empty and the error is still the human ERROR: ... line on stderr, for both a validation failure (missing required combination) and a connection failure, exit 5 either way:
$ arc attach --to ws://127.0.0.1:1/ws/attach --source /tmp --jsonstdout: (empty)
stderr:
ERROR: attach requires --namespace and --source, or --as-engine, or --as-host$ arc attach --to ws://127.0.0.1:9/ws/attach --namespace test --source /tmp --jsonstdout: (empty)
stderr:
Attaching...
to: ws://127.0.0.1:9/ws/attach
namespace: test
source: /tmp
ERROR: attach failed [cockpit-unreachable]: connect ECONNREFUSED 127.0.0.1:9