import { BestAgentError } from "@best-agent/foundation";
import type { AgentProfile } from "../../agent/profile-registry.js";
import type { ProviderReplayRepairRuntime } from "./provider-replay-context.js";

export function requireReplayRepairProfile(input: {
  missingProfileMessage: string;
  profileName?: string;
  runtime: Pick<ProviderReplayRepairRuntime, "requireProfile">;
}): { profile: AgentProfile; profileName: string } {
  if (!input.profileName) {
    throw new BestAgentError("RUN_CHECKPOINT_INVALID", input.missingProfileMessage);
  }
  return {
    profile: input.runtime.requireProfile(input.profileName),
    profileName: input.profileName,
  };
}
