// Copyright (c) 2026 defconxt. All rights reserved.
// Licensed under AGPL-3.0 — see LICENSE file for details.

/**
 * pi-imports.js — Import resolver for pi-mono packages.
 *
 * pi-mono publishes under @nerf/* as workspace packages.
 * These are direct dependencies of nerf-pi — they resolve from node_modules
 * in all distribution channels (npm, Docker, AUR, git clone).
 *
 * Usage:
 *   const { getModel, stream, complete } = await importPiAi();
 *   const { createAgentSession } = await importPiCodingAgent();
 */

/** @returns {Promise<typeof import('@nerf/pi-ai')>} */
export function importPiAi() {
  return import('@nerf/pi-ai');
}

/** @returns {Promise<typeof import('@nerf/pi-agent-core')>} */
export function importPiAgentCore() {
  return import('@nerf/pi-agent-core');
}

/** @returns {Promise<typeof import('@nerf/pi-coding-agent')>} */
export function importPiCodingAgent() {
  return import('@nerf/pi-coding-agent');
}

/** @returns {Promise<typeof import('@nerf/pi-tui')>} */
export function importPiTui() {
  return import('@nerf/pi-tui');
}

/**
 * Check if pi-mono SDK packages are available in this runtime.
 * @returns {Promise<boolean>}
 */
export async function isPiMonoAvailable() {
  try {
    await importPiAi();
    return true;
  } catch {
    return false;
  }
}

/**
 * Check if the full coding agent SDK is available (superset of pi-ai).
 * @returns {Promise<boolean>}
 */
export async function isPiCodingAgentAvailable() {
  try {
    await importPiCodingAgent();
    return true;
  } catch {
    return false;
  }
}
