import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const ollamaDomain = "ollama";
export const ollamaDefaultName = "Ollama";

export type TOllamaRawData = TSimpleLocalRawData;
export interface IOllamaSnapshot extends ISimpleLocalSnapshot {}
export interface IOllamaConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOllamaConfig extends IOllamaConfig {}

export const ollamaProfile: ISimpleLocalIntegrationProfile = {
  domain: ollamaDomain,
  displayName: "Ollama",
  manufacturer: "Ollama",
  model: "Ollama local integration",
  defaultName: ollamaDefaultName,
  defaultPort: 11434,
  defaultProtocol: 'http',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "ollama",
    "Ollama",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/ollama",
    "upstreamDomain": "ollama",
    "integrationType": "service",
    "iotClass": "local_polling",
    "requirements": [
      "ollama==0.5.1",
    ],
    "dependencies": [
      "conversation",
    ],
    "afterDependencies": [
      "assist_pipeline",
      "intent",
    ],
    "codeowners": [
      "@synesthesiam",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/ollama",
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "implemented": [
        "native HTTP polling for Ollama /api/tags and /api/ps endpoints",
        "Bearer API key headers matching Home Assistant's Ollama client setup",
        "manual local setup for Ollama endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Ollama device snapshots and Home Assistant platform metadata",
      ],
      "explicitUnsupported": [
        "hosting Home Assistant conversation agents or AI task pipelines inside this runtime",
        "streaming chat/generate calls; this runtime only reports local server/model status",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
