// @bun
import {
  checkRemoteAgentEligibility,
  formatPreconditionError,
  getRemoteTaskSessionUrl,
  init_RemoteAgentTask,
  init_teleport,
  registerCompletionChecker,
  registerCompletionHook,
  registerContentExtractor,
  registerRemoteAgentTask,
  teleportToRemote
} from "./chunk-4vz571bb.js";
import"./chunk-14p6wvsq.js";
import"./chunk-8hseq8b1.js";
import"./chunk-ddtxq6k5.js";
import"./chunk-28jd8qjx.js";
import"./chunk-djt39ze3.js";
import"./chunk-ptxteaeh.js";
import"./chunk-wd53a7m4.js";
import"./chunk-hms8ge0k.js";
import"./chunk-whpphypt.js";
import"./chunk-pht800m5.js";
import"./chunk-pjkqh1kq.js";
import"./chunk-9a9g5hbj.js";
import"./chunk-9hn8e6h1.js";
import"./chunk-rgyzsbs3.js";
import"./chunk-qn6me9n1.js";
import"./chunk-qd3r2s2n.js";
import"./chunk-djzd7tef.js";
import"./chunk-gyhnpbkx.js";
import"./chunk-71sdcaq6.js";
import"./chunk-60gf7p5s.js";
import"./chunk-sj3d0nqx.js";
import"./chunk-9pk9rk2w.js";
import"./chunk-javpza6a.js";
import"./chunk-6v7bre98.js";
import"./chunk-24kv69g3.js";
import"./chunk-fcqebw9m.js";
import"./chunk-dnfd3c9s.js";
import"./chunk-15ezj4ww.js";
import"./chunk-1h284c6e.js";
import"./chunk-582g9yce.js";
import"./chunk-y3ztgztb.js";
import"./chunk-4spgkgr3.js";
import"./chunk-n8kbhswc.js";
import"./chunk-60fkafk2.js";
import"./chunk-fgbkrbk3.js";
import"./chunk-ssw61jfd.js";
import"./chunk-093ej2sf.js";
import"./chunk-7tfdhkpy.js";
import"./chunk-nde5ym6a.js";
import"./chunk-k8wq4qsj.js";
import"./chunk-g7d3xx1p.js";
import"./chunk-3wrx2943.js";
import"./chunk-7p9kkh0f.js";
import"./chunk-qp8cgz66.js";
import"./chunk-1mg610h2.js";
import"./chunk-93hc149s.js";
import"./chunk-935nrvdb.js";
import"./chunk-8zz4z1q3.js";
import"./chunk-nnat9jw5.js";
import"./chunk-hqxp6b72.js";
import"./chunk-4jzkqgf1.js";
import"./chunk-33rd41ng.js";
import"./chunk-f257kqw9.js";
import"./chunk-w5hnghah.js";
import"./chunk-36twraxy.js";
import"./chunk-1bkvnj0y.js";
import"./chunk-akdpcc5p.js";
import"./chunk-7rrkrej7.js";
import"./chunk-6r0bxrh6.js";
import"./chunk-d6500tvx.js";
import"./chunk-jg4bw4hp.js";
import"./chunk-epvbnq43.js";
import"./chunk-tn2sx7j6.js";
import"./chunk-6tzyv21c.js";
import"./chunk-8kf8h7xf.js";
import"./chunk-bgan4cpf.js";
import"./chunk-jmv7k0jn.js";
import"./chunk-ch4pgvwq.js";
import"./chunk-99jc4tcw.js";
import"./chunk-fghczfqt.js";
import"./chunk-vwenx8ke.js";
import"./chunk-f86mwfyd.js";
import"./chunk-v4ypszbb.js";
import"./chunk-bk6ck5c2.js";
import"./chunk-ym6j0wv1.js";
import"./chunk-hjmatcgt.js";
import"./chunk-6mdh70q0.js";
import"./chunk-ch92ycde.js";
import"./chunk-e4dsy4g1.js";
import"./chunk-326zehp8.js";
import"./chunk-kc67kt75.js";
import"./chunk-40t1d75v.js";
import"./chunk-nt5dmk8q.js";
import"./chunk-e3abfxpy.js";
import"./chunk-q44zc68f.js";
import"./chunk-fejeqe61.js";
import"./chunk-0gp4q8aq.js";
import"./chunk-hn4w9pkj.js";
import {
  ThemedBox_default,
  ThemedText,
  init_src,
  require_react
} from "./chunk-0r6npc3t.js";
import {
  require_jsx_runtime
} from "./chunk-gxyx8b8w.js";
import {
  init_analytics,
  logEvent
} from "./chunk-j1mep9ck.js";
import"./chunk-6x35ffpx.js";
import"./chunk-1zbwhcbt.js";
import {
  detectCurrentRepositoryWithHost,
  init_detectRepository
} from "./chunk-t0450ma3.js";
import"./chunk-0cqw3y8h.js";
import"./chunk-k1sw7km0.js";
import"./chunk-e3j7m7k2.js";
import"./chunk-sc9ycxra.js";
import"./chunk-hhta0nge.js";
import"./chunk-8wsj9fff.js";
import"./chunk-m28vg9w4.js";
import"./chunk-f8prtxs3.js";
import"./chunk-41a6f2kv.js";
import"./chunk-c1yc761e.js";
import"./chunk-c5g9shkw.js";
import"./chunk-byd20vdq.js";
import"./chunk-kb3758f7.js";
import {
  getSessionId,
  init_state
} from "./chunk-3j8w0rq8.js";
import"./chunk-tj0dzck2.js";
import"./chunk-aeysytks.js";
import"./chunk-ns1htxgd.js";
import"./chunk-ztqzmfx1.js";
import"./chunk-6k1rsk85.js";
import"./chunk-nxzx0ey9.js";
import"./chunk-yes1my80.js";
import"./chunk-pecy49yr.js";
import"./chunk-azbab59e.js";
import"./chunk-3nk9q8dr.js";
import {
  __esm,
  __toESM
} from "./chunk-hhsxm2yr.js";

// src/commands/autofix-pr/AutofixProgress.tsx
function phaseIndex(phase) {
  return PHASE_ORDER.indexOf(phase);
}
function AutofixProgress({ phase, target, sessionUrl, errorMessage }) {
  const currentIdx = phaseIndex(phase);
  const isError = phase === "error";
  return /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
    flexDirection: "column",
    marginTop: 1,
    marginBottom: 1,
    children: [
      /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            bold: true,
            children: "Autofix PR "
          }),
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            color: "claude",
            children: target
          })
        ]
      }),
      PHASE_ORDER.map((p, i) => {
        const isDone = currentIdx > i;
        const isActive = currentIdx === i && !isError;
        const symbol = isDone ? "\u2713" : isActive ? "\u2192" : "\xB7";
        const color = isDone ? "success" : isActive ? "warning" : "subtle";
        return /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
          marginLeft: 2,
          children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
            color,
            children: [
              symbol,
              " ",
              PHASE_LABELS[p]
            ]
          })
        }, p);
      }),
      isError && errorMessage && /* @__PURE__ */ jsx_runtime.jsx(ThemedBox_default, {
        marginLeft: 2,
        marginTop: 1,
        children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
          color: "error",
          children: [
            "\u2717 ",
            errorMessage
          ]
        })
      }),
      sessionUrl && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
        marginTop: 1,
        marginLeft: 2,
        children: [
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            color: "subtle",
            children: "Track: "
          }),
          /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
            color: "claude",
            children: sessionUrl
          })
        ]
      })
    ]
  });
}
var jsx_runtime, PHASE_LABELS, PHASE_ORDER;
var init_AutofixProgress = __esm(() => {
  init_src();
  jsx_runtime = __toESM(require_jsx_runtime(), 1);
  PHASE_LABELS = {
    detecting: "Detecting repository...",
    checking_eligibility: "Checking remote agent eligibility...",
    acquiring_lock: "Acquiring monitor lock...",
    launching: "Launching remote session...",
    registered: "Session registered",
    done: "Autofix launched",
    error: "Error"
  };
  PHASE_ORDER = [
    "detecting",
    "checking_eligibility",
    "acquiring_lock",
    "launching",
    "registered",
    "done"
  ];
});

// src/commands/autofix-pr/inProcessAgent.ts
import { randomUUID } from "crypto";
function createAutofixTeammate(_initialMessage, _target) {
  return {
    agentId: randomUUID(),
    agentName: "autofix-pr",
    teamName: "_autofix",
    color: undefined,
    planModeRequired: false,
    parentSessionId: getSessionId(),
    abortController: new AbortController,
    taskId: randomUUID()
  };
}
var init_inProcessAgent = __esm(() => {
  init_state();
});

// src/commands/autofix-pr/monitorState.ts
function getActiveMonitor() {
  return active;
}
function trySetActiveMonitor(state) {
  if (active)
    return false;
  active = state;
  return true;
}
function clearActiveMonitor(taskId) {
  if (!active)
    return;
  if (taskId && active.taskId !== taskId)
    return;
  active.abortController.abort();
  active = null;
}
function updateActiveMonitor(partial) {
  if (!active)
    return false;
  active = { ...active, ...partial };
  return true;
}
function isMonitoring(owner, repo, prNumber) {
  return active?.owner === owner && active?.repo === repo && active?.prNumber === prNumber;
}
var active = null;
var init_monitorState = () => {};

// src/commands/autofix-pr/extractAutofixResult.ts
function extractAutofixResultFromLog(log) {
  for (let i = log.length - 1;i >= 0; i--) {
    const msg = log[i];
    if (!msg)
      continue;
    if (msg.type === "system" && (msg.subtype === "hook_progress" || msg.subtype === "hook_response")) {
      const stdout = msg.stdout;
      if (typeof stdout === "string") {
        const extracted = extractBetween(stdout, TAG_OPEN, TAG_CLOSE);
        if (extracted)
          return extracted;
      }
      continue;
    }
    if (msg.type === "assistant") {
      const content = msg.message?.content;
      if (!content || typeof content === "string")
        continue;
      for (const block of content) {
        if (block.type !== "text" || typeof block.text !== "string")
          continue;
        if (!block.text.includes(TAG_OPEN))
          continue;
        const extracted = extractBetween(block.text, TAG_OPEN, TAG_CLOSE);
        if (extracted)
          return extracted;
      }
    }
  }
  return null;
}
function extractBetween(text, open, close) {
  let searchFrom = text.length;
  while (searchFrom >= 0) {
    const start = text.lastIndexOf(open, searchFrom);
    if (start === -1)
      return null;
    const end = text.indexOf(close, start + open.length);
    if (end !== -1)
      return text.slice(start, end + close.length);
    searchFrom = start - 1;
  }
  return null;
}
var AUTOFIX_RESULT_TAG = "autofix-result", TAG_OPEN, TAG_CLOSE;
var init_extractAutofixResult = __esm(() => {
  TAG_OPEN = `<${AUTOFIX_RESULT_TAG}>`;
  TAG_CLOSE = `</${AUTOFIX_RESULT_TAG}>`;
});

// src/commands/autofix-pr/parseArgs.ts
function parsePrNumber(raw) {
  if (!/^[1-9]\d{0,9}$/.test(raw))
    return null;
  const n = Number(raw);
  return Number.isSafeInteger(n) ? n : null;
}
function parseAutofixArgs(raw) {
  const trimmed = raw.trim();
  if (!trimmed)
    return { action: "invalid", reason: "empty" };
  if (trimmed === "stop" || trimmed === "off")
    return { action: "stop" };
  const bareNum = parsePrNumber(trimmed);
  if (bareNum !== null) {
    return { action: "start", prNumber: bareNum };
  }
  const cross = trimmed.match(/^([\w.-]+)\/([\w.-]+)#(\d+)$/);
  if (cross) {
    const crossNum = parsePrNumber(cross[3]);
    if (crossNum === null)
      return { action: "invalid", reason: "pr_number_out_of_range" };
    return {
      action: "start",
      owner: cross[1],
      repo: cross[2],
      prNumber: crossNum
    };
  }
  return { action: "freeform", prompt: trimmed };
}
var init_parseArgs = () => {};

// src/commands/autofix-pr/prOutcomeCheck.ts
function summariseAutofixOutcome(payload, identity) {
  const { owner, repo, prNumber, initialHeadSha } = identity;
  if (payload.state === "MERGED") {
    return {
      completed: true,
      summary: `${owner}/${repo}#${prNumber} merged. Autofix monitoring complete.`
    };
  }
  if (payload.state === "CLOSED") {
    return {
      completed: true,
      summary: `${owner}/${repo}#${prNumber} closed without merge. Autofix monitoring complete.`
    };
  }
  if (!initialHeadSha)
    return { completed: false };
  if (payload.headRefOid === initialHeadSha)
    return { completed: false };
  const ciState = summariseCiRollup(payload.statusCheckRollup);
  if (ciState.state === "pending")
    return { completed: false };
  if (ciState.state === "failure") {
    return {
      completed: true,
      summary: `Autofix pushed commits to ${owner}/${repo}#${prNumber} but CI is failing (${ciState.detail}).`
    };
  }
  return {
    completed: true,
    summary: `Autofix pushed commits to ${owner}/${repo}#${prNumber}, CI green.`
  };
}
function summariseCiRollup(rollup) {
  if (!rollup || rollup.length === 0) {
    return { state: "success", detail: "no checks configured" };
  }
  let pending = 0;
  let failed = 0;
  const total = rollup.length;
  for (const check of rollup) {
    const status = (check.status ?? "").toUpperCase();
    const conclusion = (check.conclusion ?? "").toUpperCase();
    if (status && status !== "COMPLETED") {
      pending++;
      continue;
    }
    if (conclusion === "SUCCESS" || conclusion === "NEUTRAL" || conclusion === "SKIPPED") {
      continue;
    }
    if (conclusion === "") {
      pending++;
      continue;
    }
    failed++;
  }
  if (pending > 0)
    return { state: "pending", detail: `${pending}/${total} checks pending` };
  if (failed > 0)
    return { state: "failure", detail: `${failed}/${total} checks failing` };
  return { state: "success", detail: `${total}/${total} checks passing` };
}
var init_prOutcomeCheck = () => {};

// src/commands/autofix-pr/prFetch.ts
import { spawn } from "child_process";
async function checkPrAutofixOutcome(input) {
  const { owner, repo, prNumber, initialHeadSha, timeoutMs } = input;
  let payload;
  try {
    payload = await runGhPrView(owner, repo, prNumber, timeoutMs ?? DEFAULT_TIMEOUT_MS);
  } catch {
    return { completed: false };
  }
  return summariseAutofixOutcome(payload, {
    owner,
    repo,
    prNumber,
    initialHeadSha
  });
}
async function fetchPrHeadSha(owner, repo, prNumber, timeoutMs = DEFAULT_TIMEOUT_MS) {
  try {
    const payload = await runGhPrView(owner, repo, prNumber, timeoutMs);
    return payload.headRefOid || null;
  } catch {
    return null;
  }
}
function runGhPrView(owner, repo, prNumber, timeoutMs) {
  return new Promise((resolve, reject) => {
    const proc = spawn("gh", [
      "pr",
      "view",
      String(prNumber),
      "--repo",
      `${owner}/${repo}`,
      "--json",
      "headRefOid,state,statusCheckRollup"
    ], { stdio: ["ignore", "pipe", "pipe"] });
    const stdoutChunks = [];
    const stderrChunks = [];
    let settled = false;
    const timer = setTimeout(() => {
      if (settled)
        return;
      settled = true;
      proc.kill("SIGKILL");
      reject(new Error(`gh pr view timed out after ${timeoutMs}ms`));
    }, timeoutMs);
    proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
    proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
    proc.on("error", (err) => {
      if (settled)
        return;
      settled = true;
      clearTimeout(timer);
      reject(err);
    });
    proc.on("close", (code) => {
      if (settled)
        return;
      settled = true;
      clearTimeout(timer);
      if (code !== 0) {
        const stderr = Buffer.concat(stderrChunks).toString("utf8").trim();
        reject(new Error(`gh pr view exited ${code}: ${stderr || "<no stderr>"}`));
        return;
      }
      const stdout = Buffer.concat(stdoutChunks).toString("utf8").trim();
      try {
        const parsed = JSON.parse(stdout);
        resolve(parsed);
      } catch (e) {
        reject(new Error(`gh pr view JSON parse failed: ${e.message}`));
      }
    });
  });
}
var DEFAULT_TIMEOUT_MS = 5000;
var init_prFetch = __esm(() => {
  init_prOutcomeCheck();
});

// src/commands/autofix-pr/skillDetect.ts
import { existsSync } from "fs";
import { join } from "path";
function detectAutofixSkills(cwd) {
  const candidates = [
    "AUTOFIX.md",
    ".claude/skills/autofix.md",
    ".claude/skills/autofix-pr/SKILL.md"
  ];
  return candidates.filter((rel) => existsSync(join(cwd, rel)));
}
function formatSkillsHint(skills) {
  if (skills.length === 0)
    return "";
  return ` Run ${skills.join(" and ")} for custom instructions on how to autofix.`;
}
var init_skillDetect = () => {};

// src/commands/autofix-pr/launchAutofixPr.ts
function throttleKey(meta) {
  return `${meta.owner}/${meta.repo}#${meta.prNumber}`;
}
function makeErrorText(message, code) {
  logEvent("tengu_autofix_pr_result", {
    result: "failed",
    error_code: code
  });
  return `Autofix PR failed: ${message}`;
}
var import_react, lastCheckAt, CHECK_INTERVAL_MS = 5000, callAutofixPr = async (onDone, context, args) => {
  try {
    const parsed = parseAutofixArgs(args);
    if (parsed.action === "stop") {
      const m = getActiveMonitor();
      if (!m) {
        onDone("No active autofix monitor.", { display: "system" });
        return null;
      }
      clearActiveMonitor();
      onDone(`Stopped local monitoring of ${m.repo}#${m.prNumber}. Any already-running remote session continues until it finishes or is cancelled from claude.ai/code.`, { display: "system" });
      return null;
    }
    if (parsed.action === "invalid") {
      onDone(`Invalid args: ${parsed.reason}. Use /autofix-pr <pr-number> | stop | <owner>/<repo>#<n>`, {
        display: "system"
      });
      return null;
    }
    if (parsed.action === "freeform") {
      onDone("Freeform prompt mode not yet supported. Use /autofix-pr <pr-number>.", {
        display: "system"
      });
      return null;
    }
    logEvent("tengu_autofix_pr_started", {
      action: "start",
      has_pr_number: "true",
      has_repo_path: String(!!(parsed.owner && parsed.repo))
    });
    let detected;
    try {
      detected = await detectCurrentRepositoryWithHost();
    } catch {
      onDone(makeErrorText("Cannot detect GitHub repo from current directory.", "session_create_failed"), { display: "system" });
      return null;
    }
    if (!detected || detected.host !== "github.com") {
      onDone(makeErrorText("Cannot detect GitHub repo from current directory.", "session_create_failed"), { display: "system" });
      return null;
    }
    if (parsed.owner && parsed.owner !== detected.owner || parsed.repo && parsed.repo !== detected.name) {
      onDone(makeErrorText(`Cross-repo autofix is not supported from this directory. Run from ${detected.owner}/${detected.name} or pass only the PR number.`, "repo_mismatch"), { display: "system" });
      return null;
    }
    const owner = detected.owner;
    const repo = detected.name;
    const { prNumber } = parsed;
    if (isMonitoring(owner, repo, prNumber)) {
      logEvent("tengu_autofix_pr_result", {
        result: "success_rc"
      });
      onDone(`Already monitoring ${repo}#${prNumber} in background.`, {
        display: "system"
      });
      return null;
    }
    const eligibility = await checkRemoteAgentEligibility({ skipBundle: true });
    if (!eligibility.eligible) {
      const blockers = eligibility.errors.filter((e) => e.type !== "no_remote_environment");
      if (blockers.length > 0) {
        const reasons = blockers.map(formatPreconditionError).join(`
`);
        onDone(makeErrorText(`Remote agent not available:
${reasons}`, "session_create_failed"), { display: "system" });
        return null;
      }
    }
    const skills = detectAutofixSkills(process.cwd());
    const skillsHint = formatSkillsHint(skills);
    const target = `${owner}/${repo}#${prNumber}`;
    const branchName = `refs/pull/${prNumber}/head`;
    const initialMessage = `Auto-fix failing CI checks on PR #${prNumber} in ${owner}/${repo}.${skillsHint}

When you finish (or hit a blocker you can't recover from), output the following XML tag as your final message so the local user gets a structured summary:

<autofix-result>
  <pr-number>${prNumber}</pr-number>
  <commits-pushed>
    <commit sha="...">commit message</commit>
  </commits-pushed>
  <files-changed>
    <file path="...">N changes</file>
  </files-changed>
  <ci-status>green | red | pending | unknown</ci-status>
  <summary>One-sentence summary of what was fixed or why it could not be fixed.</summary>
</autofix-result>

If no fix was needed, omit <commits-pushed> and <files-changed> and explain in <summary>. If you only attempted partial work, list the commits you did push and explain the remainder in <summary>.`;
    const teammate = createAutofixTeammate(initialMessage, target);
    const lockAcquired = trySetActiveMonitor({
      taskId: teammate.taskId,
      owner,
      repo,
      prNumber,
      abortController: teammate.abortController,
      startedAt: Date.now()
    });
    if (!lockAcquired) {
      const existing = getActiveMonitor();
      onDone(makeErrorText(`already monitoring ${existing?.repo}#${existing?.prNumber}. Run /autofix-pr stop first.`, "rc_already_monitoring_other"), { display: "system" });
      return null;
    }
    let teleportFailMsg;
    const captureFailMsg = (msg) => {
      teleportFailMsg = msg;
    };
    let session = null;
    try {
      session = await teleportToRemote({
        initialMessage,
        source: "autofix_pr",
        branchName,
        skipBundle: true,
        title: `Autofix PR: ${target}`,
        useDefaultEnvironment: true,
        signal: teammate.abortController.signal,
        githubPr: { owner, repo, number: prNumber },
        onBundleFail: captureFailMsg,
        onCreateFail: captureFailMsg
      });
    } catch (teleErr) {
      clearActiveMonitor(teammate.taskId);
      const teleMsg = teleErr instanceof Error ? teleErr.message : String(teleErr);
      onDone(makeErrorText(`teleport failed: ${teleMsg}`, "teleport_failed"), {
        display: "system"
      });
      return null;
    }
    if (!session) {
      clearActiveMonitor(teammate.taskId);
      onDone(makeErrorText(teleportFailMsg ?? "remote session creation failed.", "session_create_failed"), { display: "system" });
      return null;
    }
    const initialHeadSha = await fetchPrHeadSha(owner, repo, prNumber).catch(() => null) ?? undefined;
    try {
      const { taskId: frameworkTaskId } = registerRemoteAgentTask({
        remoteTaskType: "autofix-pr",
        session,
        command: `/autofix-pr ${prNumber}`,
        context,
        isLongRunning: true,
        remoteTaskMetadata: { owner, repo, prNumber, initialHeadSha }
      });
      updateActiveMonitor({ taskId: frameworkTaskId });
    } catch (regErr) {
      clearActiveMonitor(teammate.taskId);
      const regMsg = regErr instanceof Error ? regErr.message : String(regErr);
      onDone(makeErrorText(`task registration failed: ${regMsg}`, "registration_failed"), { display: "system" });
      return null;
    }
    if (false) {}
    const sessionUrl = getRemoteTaskSessionUrl(session.id);
    logEvent("tengu_autofix_pr_result", {
      result: "success_rc"
    });
    onDone(`Autofix launched for ${target}. Track: ${sessionUrl}`, {
      display: "system"
    });
    return import_react.default.createElement(AutofixProgress, {
      phase: "done",
      target,
      sessionUrl
    });
  } catch (err) {
    const msg = err instanceof Error ? err.message : String(err);
    logEvent("tengu_autofix_pr_result", {
      result: "failed",
      error_code: "exception"
    });
    onDone(`Autofix PR failed: ${msg}`, { display: "system" });
    return null;
  }
};
var init_launchAutofixPr = __esm(() => {
  init_analytics();
  init_RemoteAgentTask();
  init_detectRepository();
  init_teleport();
  init_AutofixProgress();
  init_inProcessAgent();
  init_monitorState();
  init_extractAutofixResult();
  init_parseArgs();
  init_prFetch();
  init_skillDetect();
  import_react = __toESM(require_react(), 1);
  lastCheckAt = new Map;
  registerCompletionChecker("autofix-pr", async (metadata) => {
    const meta = metadata;
    if (!meta)
      return null;
    const key = throttleKey(meta);
    const now = Date.now();
    if (now - (lastCheckAt.get(key) ?? 0) < CHECK_INTERVAL_MS)
      return null;
    lastCheckAt.set(key, now);
    const result = await checkPrAutofixOutcome({
      owner: meta.owner,
      repo: meta.repo,
      prNumber: meta.prNumber,
      initialHeadSha: meta.initialHeadSha
    });
    return result.completed ? result.summary : null;
  });
  registerCompletionHook("autofix-pr", (taskId, metadata) => {
    clearActiveMonitor(taskId);
    const meta = metadata;
    if (meta)
      lastCheckAt.delete(throttleKey(meta));
  });
  registerContentExtractor("autofix-pr", (log) => extractAutofixResultFromLog(log));
});
init_launchAutofixPr();

export {
  callAutofixPr
};

//# debugId=E40745D8231321FA64756E2164756E21
//# sourceMappingURL=chunk-6hhk6cgt.js.map
