export function getStatusPluginPostSource(hookPathname: string): string[] { return [ 'async function post(hookEventName, extraProperties) {', ' // Why: resolve coords per post — the endpoint file may have been', ' // rewritten by a newer Orca since the last call. Pane/tab/worktree IDs', ' // stay on process.env because they are per-PTY (stable for the life of', ' // the OpenCode process), not per-Orca-instance.', ' const coords = resolveHookCoords();', ' const paneKey = process.env.ORCA_PANE_KEY;', ' if (!coords.port || !coords.token || !paneKey) return false;', ` const url = \`http://127.0.0.1:\${coords.port}${hookPathname}\`;`, ' const body = JSON.stringify({', ' paneKey,', ' 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,', // opencodeMajor is set only by the OpenCode 2 setup() path, never read from OpenCode's version. ' ...(reportingOpenCodeMajor ? { opencodeMajor: reportingOpenCodeMajor } : {}),', ' 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 {', ' // Why: OpenCode session events must never fail the agent run just', ' // because Orca is unavailable or the local loopback request failed.', ' return false;', ' } finally {', ' clearTimeout(timeout);', ' }', '}' ] }