fn cwd_state_path() -> Option<PathBuf>Expand description
Per-instance state file path. Keyed by AGENTMUX_INSTANCE_SLUG — set by
agent-model.ts to a per-launch slug that also seeds that instance’s own
unique working directory (${agentmuxHome()}/agents/${instanceSlug}) —
NOT AGENTMUX_AGENT_ID, which is the definition-wide slug shared by every
named instance launched from the same agent definition (codex P1 on this
PR: keying by AGENTMUX_AGENT_ID made two concurrently-running instances
of the same definition silently share one cwd file, so one instance’s
cd could redirect the other’s next command into the wrong worktree).
Falls back to AGENTMUX_AGENT_ID for older callers that only set that,
then to a sanitized form of this process’s own cwd (always the instance’s
fixed home directory either way) for the rare case neither is set, e.g. a
manual invocation outside AgentMux.