export function getStatusPluginPostSource(hookPathname: string): string[] { return [ 'async function post(hookEventName, extraProperties) {', ' // Refresh endpoint coordinates per post after Orca restarts; per-PTY identity stays in process.env.', ' const coords = resolveHookCoords();', ' const paneKey = process.env.ORCA_PANE_KEY;', ' if (!coords.port || !coords.token || !paneKey) return false;', ' const tmuxMatch = /^(.*),[0-9]+,[0-9]+$/.exec(process.env.TMUX || "");', ' const tmuxPane = process.env.TMUX_PANE;', ' if (reportingOpenCodeTui && coords.openCodeTui !== "1") return false;', ` const url = \`http://127.0.0.1:\${coords.port}${hookPathname}\`;`, ' const body = JSON.stringify({', ' paneKey,', ' ...(tmuxMatch && /^%[0-9]+$/.test(tmuxPane || "") ? { tmux: { socket: tmuxMatch[1], pane: tmuxPane } } : {}),', ' launchToken: process.env.ORCA_AGENT_LAUNCH_TOKEN || "",', ' tabId: process.env.ORCA_TAB_ID || "",', ' worktreeId: process.env.ORCA_WORKTREE_ID || "",', ' env: coords.env,', ' version: coords.version,', // Mark only recognized OpenCode 2 setup contexts, never infer from binary version. ' ...(reportingOpenCodeMajor ? { opencodeMajor: reportingOpenCodeMajor } : {}),', ' ...(reportingOpenCodeTui ? { opencodeTui: 1 } : {}),', ' ...(reportingOpenCodeMajor < 2 && isOpenCodeCommandProcess("serve") && coords.openCodeTui === "1" ? { opencodeSharedServer: 1 } : {}),', ' payload: { hook_event_name: hookEventName, ...(extraProperties || {}) },', ' });', ' const controller = new AbortController();', ' const timeout = setTimeout(() => controller.abort(), HOOK_POST_TIMEOUT_MS);', ' if (timeout.unref) timeout.unref();', ' try {', ' const response = await fetch(url, {', ' method: "POST",', ' headers: {', ' "Content-Type": "application/json",', ' "X-Orca-Agent-Hook-Token": coords.token,', ' },', ' body,', ' signal: controller.signal,', ' });', ' return response.ok;', ' } catch {', ' // Orca/loopback failures must never fail the agent run.', ' return false;', ' } finally {', ' clearTimeout(timeout);', ' }', '}' ] }