/**
 * Host: gautams-imac (user: exult).
 *
 * Today's .mcp.json at /Users/exult/exult-agent/.mcp.json launches sendblue
 * (under user `exult`) plus a bunch of channels owned by user `Work` from the
 * same iMac (cross-user via absolute paths). Phase 1 mirrors that exactly.
 *
 * Launch style is `bun-run-abs` (bun run <abs path> with cwd set), not the
 * `bash -c cd && exec` form used by the other hosts. This was the team's
 * original style and we keep it byte-identical in phase 1.
 */

import type { HostDef } from "../types.ts";

const WORK_REPO = "/Users/Work/Documents/GitHub/exult-agent";
const WORK_BUN = "/Users/Work/.bun/bin/bun";

export const host: HostDef = {
  hostname: "gautams-imac-exult",
  user: "exult",
  repoRoot: "/Users/exult/exult-agent",
  binaries: {
    bun: "/opt/homebrew/bin/bun",
  },
  tailscaleHost: "gautams-imac.tail053faf.ts.net",
  channels: [
    {
      channel: "sendblue",
      launchStyle: "bun-run-abs",
      env: {
        SENDBLUE_OWN_NUMBER: "+13053333940",
        SENDBLUE_WEBHOOK_URL: "https://gautams-imac.tail053faf.ts.net",
        SENDBLUE_WEBHOOK_PORT: "18800",
        SENDBLUE_WEBHOOK_PATH: "/webhook/13df5edcb8054a5e",
        SENDBLUE_STATE_DIR: "/Users/exult/.claude/channels/sendblue",
        HOME: "/Users/exult",
      },
    },
    {
      // teams-channel on this host launches from user Work's exult-agent checkout
      // (cross-user), using user Work's bun. Override path + launch style.
      //
      // RC_* and AMD_* secrets used to live inline here as <REDACTED_*>
      // placeholders. That shadowed real values from hosts/gautams-imac-exult.env
      // at production render time (priority: ref.env -> hostEnv -> spec.default),
      // so .mcp.json would emit the placeholder text rather than the real secret
      // and break teams-channel auth in prod. They now flow through hostEnv only;
      // see hosts/gautams-imac-exult.env.example for the keys, and render.test.ts
      // for the test-fixture placeholders that preserve golden parity.
      channel: "teams",
      launchStyle: "bun-run-abs",
      toolDirAbs: `${WORK_REPO}/tools/teams-channel`,
      bunOverride: WORK_BUN,
      env: {
        MSTEAMS_WEBHOOK_PORT: "3978",
        // AMD_APPNAME is a real AdvancedMD identifier; "TEMP" is the actual
        // app handle our integration uses against the AdvancedMD sandbox
        // tenant, NOT a placeholder. Keep as a literal so the value stays
        // version-controlled and reproducible across host renders.
        AMD_APPNAME: "TEMP",
      },
    },
    // HTTP-launched MCP channels. The servers physically live on
    // claude-cloud (Tailscale VM); this host consumes them remotely with a
    // shared MCP_BEARER_TOKEN read from the per-host .env at render time.
    // Replaces the prior local-spawn extraServers entries for advancedmd,
    // ringcentral, ringcentral-admin, docstrange, and email-channel.
    { channel: "advancedmd" },
    { channel: "ringcentral" },
    { channel: "ringcentral-admin" },
    { channel: "docstrange" },
    { channel: "rippling" },
    { channel: "email" },
    { channel: "teams-mcp" },
  ],
  // Passthrough channels not yet modeled. Phase 2+ promotes these to proper channels.
  extraServers: {
    playwright: {
      command: "npx",
      args: ["@playwright/mcp@latest", "--browser", "chromium", "--caps", "vision,pdf"],
    },
  },
};

export default host;
