const DEXTO_API_KEY_ENV_REF = "$DEXTO_API_KEY";
function buildDextoNovaRefreshUpdate(model) {
  return {
    provider: "dexto-nova",
    model,
    apiKey: DEXTO_API_KEY_ENV_REF
  };
}
async function refreshDextoNovaAuthAfterLogin(agent, sessionId) {
  let refreshed = false;
  const globalConfig = agent.getCurrentLLMConfig();
  if (globalConfig.provider === "dexto-nova") {
    await agent.switchLLM(buildDextoNovaRefreshUpdate(globalConfig.model));
    refreshed = true;
  }
  if (!sessionId) {
    return refreshed;
  }
  if (!agent.hasSessionLLMOverride(sessionId)) {
    return refreshed;
  }
  const sessionConfig = agent.getCurrentLLMConfig(sessionId);
  if (sessionConfig.provider !== "dexto-nova") {
    return refreshed;
  }
  await agent.switchLLM(buildDextoNovaRefreshUpdate(sessionConfig.model), sessionId);
  return true;
}
export {
  refreshDextoNovaAuthAfterLogin
};
