/**
 * Capability presets for switchboard hosts (WP-03).
 * Declared explicitly — Core never guesses by adapter name.
 */

import type { HostCapabilities } from "../contracts/HostCapabilities.ts";
import { normalizeHostCapabilities } from "../contracts/HostCapabilities.ts";

export const IN_MEMORY_HOST_CAPABILITIES: HostCapabilities = normalizeHostCapabilities({
  level: "H1",
  persistentSession: true,
  resumableSession: true,
  structuredEvents: true,
  cancellableRun: true,
  inspectableSession: true,
  workspaceBinding: false,
  concurrentWorkers: true,
  extensions: { transport: "in-memory", switchboard_mode: "off" },
});

export const LEGACY_SDK_HOST_CAPABILITIES: HostCapabilities = normalizeHostCapabilities({
  level: "H2",
  persistentSession: true,
  resumableSession: true,
  structuredEvents: true,
  cancellableRun: true,
  inspectableSession: true,
  workspaceBinding: true,
  concurrentWorkers: false,
  extensions: {
    transport: "legacy-sdk",
    wraps: "AgentSdkAdapter",
    switchboard_mode: "off",
  },
});

const LEVEL_RANK: Record<string, number> = { H0: 0, H1: 1, H2: 2, H3: 3 };

export function capabilityLevelMeets(
  actual: HostCapabilities["level"],
  minimum: HostCapabilities["level"],
): boolean {
  return (LEVEL_RANK[actual] ?? 0) >= (LEVEL_RANK[minimum] ?? 0);
}
