feat(remote): write the --save-script recording to the caller during the session and at close

BR
4h ago
+2758-249

Summary

A remote open --save-script=<path> now works like a local one, with no new command or flag:

agent-device open Settings --platform ios --session journey --save-script=journey.ad
agent-device wait 'label="General"' --session journey   # journey.ad holds open + wait
agent-device close --session journey                    # journey.ad gets the final script
  • The client mints a publication ID and records the destination before the open leaves; the request carries only the ID.
  • The daemon stamps that ID and a growing revision on each version, written 0600 in a private directory, registered for the opening tenant.
  • The client writes only its own record's newer versions: capped at 8 MiB, staged privately, settled crash-safely, first version exclusive unless --force.
  • A failed script write or download keeps the action's success; the daemon RPC response carries scriptDeliveryFailure and a warning. The script-artifacts health capability gates older daemons.
  • A batch that would close an armed remote recording is refused (remote_script_batch_close_unsupported).

Known limitations: #4564 (SDK, CLI and MCP disclosure; batch delivery) and #4565 (writable ancestor directories, shared with local sessions). Local sessions are unchanged. ADR 0016, help and docs updated.

Validation

Head 837f1a477c: typecheck, lint, Fallow, production exports, layering, doc prose, ADR citations, check:daemon-wire-compat and the eager-closure budget (no growth) passed, with daemon, daemon-client and remote unit tests and the remote provider scenarios. Each new test fails when its code is broken. No device run; CI owns the full gate.

🤖 Generated with Claude Code