'use strict';

const registry = require('./registry');
const ClaudeCodeJsonlAdapter = require('./claude-code-jsonl');
const CodexJsonlAdapter = require('./codex-jsonl');
const GeminiJsonlAdapter = require('./gemini-jsonl');
const WalleJsonlAdapter = require('./walle-jsonl');

const BUILTIN_SOURCE_ADAPTERS = Object.freeze([
  ClaudeCodeJsonlAdapter,
  CodexJsonlAdapter,
  GeminiJsonlAdapter,
  WalleJsonlAdapter,
]);

function ensureBuiltinSourceAdapters() {
  for (const Adapter of BUILTIN_SOURCE_ADAPTERS) {
    const instance = new Adapter();
    if (!registry.has(instance.schema.adapterId)) {
      registry.register(Adapter);
    }
  }
  return registry;
}

module.exports = {
  BUILTIN_SOURCE_ADAPTERS,
  ClaudeCodeJsonlAdapter,
  CodexJsonlAdapter,
  GeminiJsonlAdapter,
  WalleJsonlAdapter,
  ensureBuiltinSourceAdapters,
};
