From 21bcda9fc77988d7428a432906904d3eba9a3c61 Mon Sep 17 00:00:00 2001 From: hiroyuki117339 <214048059+hiroyuki117339@users.noreply.github.com> Date: Sun, 6 Sep 2026 06:03:43 +0900 Subject: [PATCH] fix(codex): discover a ws:// app-server in the SessionStart plug Discovery tried the AGMSG_CODEX_BRIDGE_APP_SERVER variable, a `unix://` token in the agent cmdline, and a `.sock` file. A ws:// (TCP) app-server matches none of them: codex-monitor.sh hands the URL to `codex --remote` and records the port in a `.port` file, so the plug hit `exit 0` before writing codex-bridge-request.. The launcher then kept using the stale request file and pinned every relaunch to a dead port. Fall back to _agmsg_codex_app_server_url, the helper _app-server.sh already provides for exactly this and codex-record-session.sh already uses. --- scripts/drivers/types/codex/_session-start.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/drivers/types/codex/_session-start.sh b/scripts/drivers/types/codex/_session-start.sh index 1aa55fb9b..ca6b0e6d0 100644 --- a/scripts/drivers/types/codex/_session-start.sh +++ b/scripts/drivers/types/codex/_session-start.sh @@ -137,6 +137,17 @@ agmsg_session_start() { app_server="unix://$socket_path" fi fi + if [ -z "$app_server" ]; then + # A ws:// (TCP) app-server has no socket file to find, and codex-monitor.sh + # passes the URL to `codex --remote`, not as a `unix://` token this script can + # scrape — so none of the three probes above can see it. The port file does + # carry the URL; reuse the helper codex-record-session.sh already uses for it. + if ! command -v _agmsg_codex_app_server_url >/dev/null 2>&1; then + # shellcheck disable=SC1091 + . "$SKILL_DIR/scripts/drivers/types/codex/_app-server.sh" + fi + app_server="$(_agmsg_codex_app_server_url "$PROJECT")" + fi [ -n "$app_server" ] || exit 0 if [ "${AGMSG_CODEX_BRIDGE_LAUNCHER:-}" = "1" ]; then