{"version":3,"file":"llm-Q4On3DH8.mjs","names":["circuit: CircuitState","issues: ValidationIssue[]","schema: ComponentSchema","category: string","componentId: string","query: string","results: ComponentSearchResult[]","matchedFields: string[]","componentsByCategory: Record<string, ComponentInfo[]>","circuit: CircuitState","components: ComponentInstance[]","suggestions: ConnectionSuggestion[]","description: string","wires: Wire[]","circuit: CircuitState","errors: string[]","warnings: string[]","suggestions: string[]","component: ComponentInstance","wire: Wire","components: ComponentInstance[]"],"sources":["../../src/utils/circuitValidation.ts","../../src/llm/componentDiscovery.ts","../../src/llm/circuitGeneration.ts","../../src/llm/validation.ts","../../src/llm/index.ts"],"sourcesContent":["/**\n * Circuit validation utilities\n *\n * Functions to validate circuit connections and integrity.\n */\n\nimport { CircuitState, ComponentInstance, Wire } from '../types';\nimport { getComponentSchema } from '../registry';\nimport { validateCircuitState } from './zodValidation';\nimport { ValidationIssue } from '../schemas/componentSchema';\n\n/**\n * Validate a circuit for common issues\n *\n * @param circuit - The circuit state to validate\n * @returns Array of validation issues\n */\nexport function validateCircuit(circuit: CircuitState): ValidationIssue[] {\n  // First validate the circuit structure using ZOD\n  const validationResult = validateCircuitState(circuit);\n\n  if (!validationResult.success) {\n    return [{\n      type: 'error',\n      message: `Invalid circuit structure: ${validationResult.error}`\n    }];\n  }\n\n  const issues: ValidationIssue[] = [];\n\n  // Check for missing components in wire connections\n  issues.push(...validateWireConnections(circuit));\n\n  // Check for floating inputs/outputs\n  issues.push(...validateFloatingPorts(circuit));\n\n  // Check for short circuits\n  issues.push(...validateShortCircuits(circuit));\n\n  return issues;\n}\n\n/**\n * Validate wire connections to ensure they reference valid components\n */\nfunction validateWireConnections(circuit: CircuitState): ValidationIssue[] {\n  const issues: ValidationIssue[] = [];\n  const componentIds = new Set(circuit.components.map(c => c.id));\n\n  for (const wire of circuit.wires) {\n    // Check source component exists\n    if (!componentIds.has(wire.from.componentId)) {\n      issues.push({\n        type: 'error',\n        message: `Wire connected to non-existent component ID: ${wire.from.componentId}`,\n        wireId: wire.id\n      });\n    }\n\n    // Check destination component exists\n    if (!componentIds.has(wire.to.componentId)) {\n      issues.push({\n        type: 'error',\n        message: `Wire connected to non-existent component ID: ${wire.to.componentId}`,\n        wireId: wire.id\n      });\n    }\n\n    // Validate port IDs\n    const sourceComponent = circuit.components.find(c => c.id === wire.from.componentId);\n    const destComponent = circuit.components.find(c => c.id === wire.to.componentId);\n\n    if (sourceComponent) {\n      const schema = getComponentSchema(sourceComponent.type);\n      if (schema && !schema.ports.some(p => p.id === wire.from.portId)) {\n        issues.push({\n          type: 'error',\n          message: `Wire connected to non-existent port: ${wire.from.portId} on component ${sourceComponent.type}`,\n          wireId: wire.id\n        });\n      }\n    }\n\n    if (destComponent) {\n      const schema = getComponentSchema(destComponent.type);\n      if (schema && !schema.ports.some(p => p.id === wire.to.portId)) {\n        issues.push({\n          type: 'error',\n          message: `Wire connected to non-existent port: ${wire.to.portId} on component ${destComponent.type}`,\n          wireId: wire.id\n        });\n      }\n    }\n  }\n\n  return issues;\n}\n\n/**\n * Check for floating input/output ports that should be connected\n */\nfunction validateFloatingPorts(circuit: CircuitState): ValidationIssue[] {\n  const issues: ValidationIssue[] = [];\n  const connectedPorts = new Map<string, Set<string>>();\n\n  // Build a map of all connected ports\n  for (const wire of circuit.wires) {\n    if (!connectedPorts.has(wire.from.componentId)) {\n      connectedPorts.set(wire.from.componentId, new Set());\n    }\n    if (!connectedPorts.has(wire.to.componentId)) {\n      connectedPorts.set(wire.to.componentId, new Set());\n    }\n\n    connectedPorts.get(wire.from.componentId)!.add(wire.from.portId);\n    connectedPorts.get(wire.to.componentId)!.add(wire.to.portId);\n  }\n\n  // Check each component for floating ports\n  for (const component of circuit.components) {\n    const schema = getComponentSchema(component.type);\n    if (!schema) continue;\n\n    const componentConnectedPorts = connectedPorts.get(component.id) || new Set();\n\n    for (const port of schema.ports) {\n      if (port.type === 'input' && !componentConnectedPorts.has(port.id)) {\n        issues.push({\n          type: 'warning',\n          message: `Floating input port: ${port.id} on ${schema.name} (${component.id})`,\n          componentId: component.id\n        });\n      }\n\n      if (port.type === 'output' && !componentConnectedPorts.has(port.id)) {\n        issues.push({\n          type: 'warning',\n          message: `Floating output port: ${port.id} on ${schema.name} (${component.id})`,\n          componentId: component.id\n        });\n      }\n    }\n  }\n\n  return issues;\n}\n\n/**\n * Check for short circuits (multiple outputs connected together)\n */\nfunction validateShortCircuits(circuit: CircuitState): ValidationIssue[] {\n  const issues: ValidationIssue[] = [];\n  const connectionGraph = new Map<string, Set<string>>();\n\n  // Build a connection graph\n  for (const wire of circuit.wires) {\n    const fromKey = `${wire.from.componentId}-${wire.from.portId}`;\n    const toKey = `${wire.to.componentId}-${wire.to.portId}`;\n\n    if (!connectionGraph.has(fromKey)) {\n      connectionGraph.set(fromKey, new Set());\n    }\n    if (!connectionGraph.has(toKey)) {\n      connectionGraph.set(toKey, new Set());\n    }\n\n    connectionGraph.get(fromKey)!.add(toKey);\n    connectionGraph.get(toKey)!.add(fromKey);\n  }\n\n  // Create a map of port types\n  const portTypes = new Map<string, string>();\n  for (const component of circuit.components) {\n    const schema = getComponentSchema(component.type);\n    if (!schema) continue;\n\n    for (const port of schema.ports) {\n      portTypes.set(`${component.id}-${port.id}`, port.type);\n    }\n  }\n\n  // Find connected output ports\n  const visited = new Set<string>();\n  const connectedComponents = [];\n\n  // For each port\n  for (const [port, connections] of connectionGraph.entries()) {\n    if (visited.has(port)) continue;\n\n    // Do a BFS to find all connected ports\n    const connectedPorts = new Set<string>();\n    const queue = [port];\n    visited.add(port);\n\n    while (queue.length > 0) {\n      const currentPort = queue.shift()!;\n      connectedPorts.add(currentPort);\n\n      for (const connectedPort of connectionGraph.get(currentPort) || []) {\n        if (!visited.has(connectedPort)) {\n          queue.push(connectedPort);\n          visited.add(connectedPort);\n        }\n      }\n    }\n\n    // Count output ports in this connected component\n    const outputPorts = [...connectedPorts].filter(p =>\n      portTypes.get(p) === 'output'\n    );\n\n    if (outputPorts.length > 1) {\n      issues.push({\n        type: 'error',\n        message: `Short circuit detected: ${outputPorts.length} output ports connected together`,\n      });\n    }\n  }\n\n  return issues;\n}\n\nexport default validateCircuit;\n","/**\n * Component Discovery API for LLM Integration\n * \n * This module provides functions that allow LLMs to discover and understand\n * what components are available in the circuit-bricks registry.\n */\n\nimport { \n  getAllComponents, \n  getComponentsByCategory, \n  getComponentSchema \n} from '../registry';\nimport { ComponentSchema } from '../types';\nimport { \n  ComponentInfo, \n  LLMRegistryMetadata, \n  ComponentSearchResult \n} from './types';\n\n/**\n * Convert a ComponentSchema to simplified ComponentInfo for LLM consumption\n */\nfunction schemaToComponentInfo(schema: ComponentSchema): ComponentInfo {\n  return {\n    id: schema.id,\n    name: schema.name,\n    category: schema.category,\n    description: schema.description,\n    ports: schema.ports.map(port => ({\n      id: port.id,\n      type: port.type,\n      label: port.label\n    })),\n    properties: schema.properties.map(prop => ({\n      key: prop.key,\n      label: prop.label,\n      type: prop.type,\n      default: prop.default,\n      unit: prop.unit,\n      options: prop.options\n    }))\n  };\n}\n\n/**\n * List all available components in a format optimized for LLM consumption\n * \n * @returns Array of simplified component information\n */\nexport function listAvailableComponents(): ComponentInfo[] {\n  const allComponents = getAllComponents();\n  return allComponents.map(schemaToComponentInfo);\n}\n\n/**\n * Get components filtered by category\n * \n * @param category - The category to filter by\n * @returns Array of components in the specified category\n */\nexport function listComponentsByCategory(category: string): ComponentInfo[] {\n  const components = getComponentsByCategory(category);\n  return components.map(schemaToComponentInfo);\n}\n\n/**\n * Get detailed information about a specific component\n * \n * @param componentId - The ID of the component to get details for\n * @returns Detailed component information or null if not found\n */\nexport function getComponentDetails(componentId: string): ComponentInfo | null {\n  const schema = getComponentSchema(componentId);\n  if (!schema) {\n    return null;\n  }\n  return schemaToComponentInfo(schema);\n}\n\n/**\n * Get all available component categories\n * \n * @returns Array of unique category names\n */\nexport function getAllCategories(): string[] {\n  const allComponents = getAllComponents();\n  const categories = [...new Set(allComponents.map(c => c.category))];\n  return categories.sort();\n}\n\n/**\n * Search components by name, description, or category\n * \n * @param query - Search query string\n * @returns Array of search results with relevance scores\n */\nexport function searchComponents(query: string): ComponentSearchResult[] {\n  const allComponents = getAllComponents();\n  const searchTerm = query.toLowerCase();\n  \n  const results: ComponentSearchResult[] = [];\n  \n  for (const schema of allComponents) {\n    const matchedFields: string[] = [];\n    let relevanceScore = 0;\n    \n    // Check name match (highest priority)\n    if (schema.name.toLowerCase().includes(searchTerm)) {\n      matchedFields.push('name');\n      relevanceScore += 10;\n    }\n    \n    // Check ID match\n    if (schema.id.toLowerCase().includes(searchTerm)) {\n      matchedFields.push('id');\n      relevanceScore += 8;\n    }\n    \n    // Check category match\n    if (schema.category.toLowerCase().includes(searchTerm)) {\n      matchedFields.push('category');\n      relevanceScore += 5;\n    }\n    \n    // Check description match\n    if (schema.description.toLowerCase().includes(searchTerm)) {\n      matchedFields.push('description');\n      relevanceScore += 3;\n    }\n    \n    // Check property names\n    for (const prop of schema.properties) {\n      if (prop.label.toLowerCase().includes(searchTerm) || \n          prop.key.toLowerCase().includes(searchTerm)) {\n        matchedFields.push('properties');\n        relevanceScore += 1;\n        break;\n      }\n    }\n    \n    if (relevanceScore > 0) {\n      results.push({\n        component: schemaToComponentInfo(schema),\n        relevanceScore,\n        matchedFields\n      });\n    }\n  }\n  \n  // Sort by relevance score (highest first)\n  return results.sort((a, b) => b.relevanceScore - a.relevanceScore);\n}\n\n/**\n * Get registry metadata optimized for LLM consumption\n * \n * @returns Comprehensive registry metadata\n */\nexport function getRegistryMetadata(): LLMRegistryMetadata {\n  const allComponents = getAllComponents();\n  const categories = getAllCategories();\n  \n  const componentsByCategory: Record<string, ComponentInfo[]> = {};\n  \n  for (const category of categories) {\n    componentsByCategory[category] = listComponentsByCategory(category);\n  }\n  \n  return {\n    totalComponents: allComponents.length,\n    categories,\n    componentsByCategory,\n    lastUpdated: new Date().toISOString()\n  };\n}\n\n/**\n * Get a human-readable summary of the component registry\n * \n * @returns String summary of all available components\n */\nexport function getRegistrySummary(): string {\n  const metadata = getRegistryMetadata();\n  \n  let summary = `# Circuit-Bricks Component Registry\\n\\n`;\n  summary += `Total Components: ${metadata.totalComponents}\\n`;\n  summary += `Categories: ${metadata.categories.length}\\n\\n`;\n  \n  for (const category of metadata.categories) {\n    const components = metadata.componentsByCategory[category];\n    summary += `## ${category.charAt(0).toUpperCase() + category.slice(1)} (${components.length} components)\\n\\n`;\n    \n    for (const component of components) {\n      summary += `### ${component.name} (${component.id})\\n`;\n      summary += `${component.description}\\n\\n`;\n      summary += `**Ports:** ${component.ports.map(p => `${p.id} (${p.type})`).join(', ')}\\n`;\n      \n      if (component.properties.length > 0) {\n        summary += `**Properties:** ${component.properties.map(p => `${p.label} (${p.type})`).join(', ')}\\n`;\n      }\n      \n      summary += '\\n';\n    }\n  }\n  \n  summary += `\\n*Last updated: ${metadata.lastUpdated}*`;\n  \n  return summary;\n}\n\n/**\n * Get a detailed summary of a specific component for LLM consumption\n * \n * @param componentId - The ID of the component to summarize\n * @returns Detailed string summary or null if component not found\n */\nexport function getComponentDetailedSummary(componentId: string): string | null {\n  const component = getComponentDetails(componentId);\n  if (!component) {\n    return null;\n  }\n  \n  let summary = `# ${component.name} (${component.id})\\n\\n`;\n  summary += `**Category:** ${component.category}\\n`;\n  summary += `**Description:** ${component.description}\\n\\n`;\n  \n  summary += `## Ports\\n`;\n  for (const port of component.ports) {\n    summary += `- **${port.id}** (${port.type})`;\n    if (port.label) {\n      summary += `: ${port.label}`;\n    }\n    summary += '\\n';\n  }\n  \n  if (component.properties.length > 0) {\n    summary += `\\n## Properties\\n`;\n    for (const prop of component.properties) {\n      summary += `- **${prop.label}** (${prop.key})\\n`;\n      summary += `  - Type: ${prop.type}\\n`;\n      summary += `  - Default: ${prop.default}\\n`;\n      \n      if (prop.unit) {\n        summary += `  - Unit: ${prop.unit}\\n`;\n      }\n      \n      if (prop.options) {\n        summary += `  - Options: ${prop.options.map(o => `${o.value} (${o.label})`).join(', ')}\\n`;\n      }\n      \n      summary += '\\n';\n    }\n  }\n  \n  return summary;\n}\n","/**\n * Circuit Generation Helpers for LLM Integration\n * \n * This module provides functions to help LLMs generate and understand circuits.\n */\n\nimport { ComponentInstance, Wire, CircuitState } from '../types';\nimport { getComponentSchema } from '../registry';\nimport { \n  CircuitDescription, \n  CircuitTemplate, \n  ConnectionSuggestion \n} from './types';\n\n/**\n * Generate a human-readable description of a circuit\n * \n * @param circuit - The circuit state to describe\n * @returns Detailed circuit description\n */\nexport function describeCircuit(circuit: CircuitState): CircuitDescription {\n  const components = circuit.components.map(comp => {\n    const schema = getComponentSchema(comp.type);\n    return {\n      id: comp.id,\n      type: comp.type,\n      name: schema?.name || comp.type,\n      position: comp.position,\n      properties: comp.props\n    };\n  });\n\n  const connections = circuit.wires.map(wire => {\n    const fromComp = circuit.components.find(c => c.id === wire.from.componentId);\n    const toComp = circuit.components.find(c => c.id === wire.to.componentId);\n    const fromSchema = fromComp ? getComponentSchema(fromComp.type) : null;\n    const toSchema = toComp ? getComponentSchema(toComp.type) : null;\n    \n    return {\n      from: { \n        component: fromSchema?.name || wire.from.componentId, \n        port: wire.from.portId \n      },\n      to: { \n        component: toSchema?.name || wire.to.componentId, \n        port: wire.to.portId \n      },\n      description: `${fromSchema?.name || 'Component'} ${wire.from.portId} → ${toSchema?.name || 'Component'} ${wire.to.portId}`\n    };\n  });\n\n  // Analyze circuit\n  const categories = [...new Set(components.map(c => {\n    const schema = getComponentSchema(c.type);\n    return schema?.category || 'unknown';\n  }))];\n\n  const powerSources = components\n    .filter(c => {\n      const schema = getComponentSchema(c.type);\n      return schema?.category === 'power' || \n             schema?.id === 'battery' || \n             schema?.id === 'voltage-source';\n    })\n    .map(c => c.name);\n\n  const hasGround = components.some(c => {\n    const schema = getComponentSchema(c.type);\n    return schema?.id === 'ground';\n  });\n\n  // Generate summary\n  let summary = `This circuit contains ${components.length} components and ${connections.length} connections. `;\n  \n  if (powerSources.length > 0) {\n    summary += `Power is provided by ${powerSources.join(', ')}. `;\n  }\n  \n  if (hasGround) {\n    summary += `The circuit includes a ground connection. `;\n  }\n  \n  summary += `Components span ${categories.length} categories: ${categories.join(', ')}.`;\n\n  return {\n    summary,\n    components,\n    connections,\n    analysis: {\n      totalComponents: components.length,\n      totalConnections: connections.length,\n      categories,\n      powerSources,\n      hasGround\n    }\n  };\n}\n\n/**\n * Suggest valid connections between components in a circuit\n * \n * @param components - Array of component instances\n * @returns Array of connection suggestions\n */\nexport function suggestConnections(components: ComponentInstance[]): ConnectionSuggestion[] {\n  const suggestions: ConnectionSuggestion[] = [];\n  \n  // Get component schemas for analysis\n  const componentData = components.map(comp => ({\n    instance: comp,\n    schema: getComponentSchema(comp.type)\n  })).filter(data => data.schema !== undefined);\n\n  // Find power sources and ground\n  const powerSources = componentData.filter(data => \n    data.schema!.category === 'power' || \n    data.schema!.id === 'battery' || \n    data.schema!.id === 'voltage-source'\n  );\n  \n  const grounds = componentData.filter(data => data.schema!.id === 'ground');\n  \n  // Suggest power connections\n  for (const powerSource of powerSources) {\n    const positivePort = powerSource.schema!.ports.find(p => \n      p.id === 'positive' || p.type === 'output'\n    );\n    \n    if (positivePort) {\n      // Suggest connecting power to input ports of other components\n      for (const comp of componentData) {\n        if (comp.instance.id === powerSource.instance.id) continue;\n        \n        const inputPorts = comp.schema!.ports.filter(p => p.type === 'input');\n        for (const inputPort of inputPorts) {\n          suggestions.push({\n            from: { \n              componentId: powerSource.instance.id, \n              portId: positivePort.id \n            },\n            to: { \n              componentId: comp.instance.id, \n              portId: inputPort.id \n            },\n            reason: `Connect power source to ${comp.schema!.name} input`,\n            confidence: 0.8\n          });\n        }\n      }\n    }\n  }\n\n  // Suggest ground connections\n  if (grounds.length > 0) {\n    const ground = grounds[0];\n    const groundPort = ground.schema!.ports.find(p => p.id === 'terminal');\n    \n    if (groundPort) {\n      // Suggest connecting negative terminals to ground\n      for (const powerSource of powerSources) {\n        const negativePort = powerSource.schema!.ports.find(p => \n          p.id === 'negative'\n        );\n        \n        if (negativePort) {\n          suggestions.push({\n            from: { \n              componentId: powerSource.instance.id, \n              portId: negativePort.id \n            },\n            to: { \n              componentId: ground.instance.id, \n              portId: groundPort.id \n            },\n            reason: 'Connect power source negative to ground',\n            confidence: 0.9\n          });\n        }\n      }\n      \n      // Suggest connecting output ports to ground\n      for (const comp of componentData) {\n        if (comp.instance.id === ground.instance.id) continue;\n        \n        const outputPorts = comp.schema!.ports.filter(p => \n          p.type === 'output' || p.id === 'cathode' || p.id === 'emitter'\n        );\n        \n        for (const outputPort of outputPorts) {\n          suggestions.push({\n            from: { \n              componentId: comp.instance.id, \n              portId: outputPort.id \n            },\n            to: { \n              componentId: ground.instance.id, \n              portId: groundPort.id \n            },\n            reason: `Connect ${comp.schema!.name} output to ground`,\n            confidence: 0.7\n          });\n        }\n      }\n    }\n  }\n\n  // Sort by confidence\n  return suggestions.sort((a, b) => b.confidence - a.confidence);\n}\n\n/**\n * Generate a basic circuit template from a description\n * \n * @param description - Text description of the desired circuit\n * @returns Basic circuit template\n */\nexport function generateCircuitTemplate(description: string): CircuitTemplate {\n  const lowerDesc = description.toLowerCase();\n  \n  // Simple pattern matching for common circuits\n  let templateId = 'basic';\n  let templateName = 'Basic Circuit';\n  let components: ComponentInstance[] = [];\n  let wires: Wire[] = [];\n  \n  // LED circuit pattern\n  if (lowerDesc.includes('led') || lowerDesc.includes('light')) {\n    templateId = 'led-circuit';\n    templateName = 'LED Circuit';\n    \n    components = [\n      {\n        id: 'battery1',\n        type: 'battery',\n        position: { x: 100, y: 150 },\n        props: { voltage: 9 }\n      },\n      {\n        id: 'resistor1',\n        type: 'resistor',\n        position: { x: 250, y: 150 },\n        props: { resistance: 330, tolerance: 5 }\n      },\n      {\n        id: 'led1',\n        type: 'led',\n        position: { x: 400, y: 150 },\n        props: { color: '#ff0000', forwardVoltage: 1.8 }\n      },\n      {\n        id: 'ground1',\n        type: 'ground',\n        position: { x: 250, y: 250 },\n        props: {}\n      }\n    ];\n    \n    wires = [\n      {\n        id: 'wire1',\n        from: { componentId: 'battery1', portId: 'positive' },\n        to: { componentId: 'resistor1', portId: 'left' }\n      },\n      {\n        id: 'wire2',\n        from: { componentId: 'resistor1', portId: 'right' },\n        to: { componentId: 'led1', portId: 'anode' }\n      },\n      {\n        id: 'wire3',\n        from: { componentId: 'led1', portId: 'cathode' },\n        to: { componentId: 'ground1', portId: 'terminal' }\n      },\n      {\n        id: 'wire4',\n        from: { componentId: 'battery1', portId: 'negative' },\n        to: { componentId: 'ground1', portId: 'terminal' }\n      }\n    ];\n  }\n  // Voltage divider pattern\n  else if (lowerDesc.includes('voltage divider') || lowerDesc.includes('divider')) {\n    templateId = 'voltage-divider';\n    templateName = 'Voltage Divider';\n    \n    components = [\n      {\n        id: 'battery1',\n        type: 'battery',\n        position: { x: 100, y: 100 },\n        props: { voltage: 9 }\n      },\n      {\n        id: 'resistor1',\n        type: 'resistor',\n        position: { x: 250, y: 100 },\n        props: { resistance: 1000, tolerance: 5 }\n      },\n      {\n        id: 'resistor2',\n        type: 'resistor',\n        position: { x: 250, y: 200 },\n        props: { resistance: 1000, tolerance: 5 }\n      },\n      {\n        id: 'ground1',\n        type: 'ground',\n        position: { x: 250, y: 300 },\n        props: {}\n      }\n    ];\n    \n    wires = [\n      {\n        id: 'wire1',\n        from: { componentId: 'battery1', portId: 'positive' },\n        to: { componentId: 'resistor1', portId: 'left' }\n      },\n      {\n        id: 'wire2',\n        from: { componentId: 'resistor1', portId: 'right' },\n        to: { componentId: 'resistor2', portId: 'left' }\n      },\n      {\n        id: 'wire3',\n        from: { componentId: 'resistor2', portId: 'right' },\n        to: { componentId: 'ground1', portId: 'terminal' }\n      },\n      {\n        id: 'wire4',\n        from: { componentId: 'battery1', portId: 'negative' },\n        to: { componentId: 'ground1', portId: 'terminal' }\n      }\n    ];\n  }\n  \n  return {\n    id: templateId,\n    name: templateName,\n    description: `Generated template for: ${description}`,\n    category: 'generated',\n    components,\n    wires\n  };\n}\n","/**\n * LLM-Friendly Validation Functions\n * \n * This module provides validation functions optimized for LLM consumption\n * with clear, human-readable error messages and suggestions.\n */\n\nimport { CircuitState, ComponentInstance, Wire } from '../types';\nimport { getComponentSchema } from '../registry';\nimport { validateCircuit } from '../utils/circuitValidation';\nimport { LLMValidationResult } from './types';\n\n/**\n * Validate a circuit design with LLM-friendly output\n * \n * @param circuit - The circuit state to validate\n * @returns Validation result with clear messages\n */\nexport function validateCircuitDesign(circuit: CircuitState): LLMValidationResult {\n  const errors: string[] = [];\n  const warnings: string[] = [];\n  const suggestions: string[] = [];\n\n  // Validate component existence and schemas\n  for (const component of circuit.components) {\n    const schema = getComponentSchema(component.type);\n    \n    if (!schema) {\n      errors.push(`Component type \"${component.type}\" (ID: ${component.id}) is not registered in the component registry.`);\n      continue;\n    }\n\n    // Validate component properties\n    for (const prop of schema.properties) {\n      const value = component.props[prop.key];\n      \n      if (value === undefined && prop.default === undefined) {\n        warnings.push(`Component \"${component.id}\" is missing required property \"${prop.label}\" (${prop.key}).`);\n      }\n      \n      // Type validation\n      if (value !== undefined) {\n        switch (prop.type) {\n          case 'number':\n            if (typeof value !== 'number') {\n              errors.push(`Property \"${prop.label}\" of component \"${component.id}\" must be a number, got ${typeof value}.`);\n            } else {\n              if (prop.min !== undefined && value < prop.min) {\n                errors.push(`Property \"${prop.label}\" of component \"${component.id}\" must be at least ${prop.min}, got ${value}.`);\n              }\n              if (prop.max !== undefined && value > prop.max) {\n                errors.push(`Property \"${prop.label}\" of component \"${component.id}\" must be at most ${prop.max}, got ${value}.`);\n              }\n            }\n            break;\n          case 'boolean':\n            if (typeof value !== 'boolean') {\n              errors.push(`Property \"${prop.label}\" of component \"${component.id}\" must be a boolean, got ${typeof value}.`);\n            }\n            break;\n          case 'select':\n            if (prop.options && !prop.options.some(opt => opt.value === value)) {\n              const validOptions = prop.options.map(opt => opt.value).join(', ');\n              errors.push(`Property \"${prop.label}\" of component \"${component.id}\" must be one of: ${validOptions}, got ${value}.`);\n            }\n            break;\n        }\n      }\n    }\n  }\n\n  // Validate wire connections\n  for (const wire of circuit.wires) {\n    const fromComponent = circuit.components.find(c => c.id === wire.from.componentId);\n    const toComponent = circuit.components.find(c => c.id === wire.to.componentId);\n    \n    if (!fromComponent) {\n      errors.push(`Wire \"${wire.id}\" references non-existent source component \"${wire.from.componentId}\".`);\n      continue;\n    }\n    \n    if (!toComponent) {\n      errors.push(`Wire \"${wire.id}\" references non-existent destination component \"${wire.to.componentId}\".`);\n      continue;\n    }\n    \n    const fromSchema = getComponentSchema(fromComponent.type);\n    const toSchema = getComponentSchema(toComponent.type);\n    \n    if (!fromSchema || !toSchema) {\n      continue; // Already reported above\n    }\n    \n    // Validate port existence\n    const fromPort = fromSchema.ports.find(p => p.id === wire.from.portId);\n    const toPort = toSchema.ports.find(p => p.id === wire.to.portId);\n    \n    if (!fromPort) {\n      errors.push(`Wire \"${wire.id}\" references non-existent port \"${wire.from.portId}\" on component \"${fromComponent.id}\" (${fromSchema.name}).`);\n    }\n    \n    if (!toPort) {\n      errors.push(`Wire \"${wire.id}\" references non-existent port \"${wire.to.portId}\" on component \"${toComponent.id}\" (${toSchema.name}).`);\n    }\n    \n    // Validate port compatibility\n    if (fromPort && toPort) {\n      if (fromPort.type === 'input' && toPort.type === 'input') {\n        warnings.push(`Wire \"${wire.id}\" connects two input ports, which may not be electrically valid.`);\n      }\n      \n      if (fromPort.type === 'output' && toPort.type === 'output') {\n        warnings.push(`Wire \"${wire.id}\" connects two output ports, which may cause conflicts.`);\n      }\n    }\n  }\n\n  // Circuit-level validation\n  const powerSources = circuit.components.filter(comp => {\n    const schema = getComponentSchema(comp.type);\n    return schema?.category === 'power' || \n           schema?.id === 'battery' || \n           schema?.id === 'voltage-source';\n  });\n\n  const grounds = circuit.components.filter(comp => {\n    const schema = getComponentSchema(comp.type);\n    return schema?.id === 'ground';\n  });\n\n  if (powerSources.length === 0) {\n    warnings.push('Circuit has no power sources. Consider adding a battery or voltage source.');\n  }\n\n  if (grounds.length === 0) {\n    warnings.push('Circuit has no ground connection. This may cause issues in real circuits.');\n  }\n\n  if (powerSources.length > 1) {\n    warnings.push(`Circuit has ${powerSources.length} power sources. Ensure they are properly isolated or connected.`);\n  }\n\n  // Check for isolated components\n  const connectedComponents = new Set<string>();\n  for (const wire of circuit.wires) {\n    connectedComponents.add(wire.from.componentId);\n    connectedComponents.add(wire.to.componentId);\n  }\n\n  for (const component of circuit.components) {\n    if (!connectedComponents.has(component.id)) {\n      warnings.push(`Component \"${component.id}\" is not connected to any other components.`);\n    }\n  }\n\n  // Generate suggestions\n  if (powerSources.length > 0 && grounds.length === 0) {\n    suggestions.push('Add a ground component to complete the circuit.');\n  }\n\n  if (circuit.components.length > 0 && circuit.wires.length === 0) {\n    suggestions.push('Add wire connections between components to create a functional circuit.');\n  }\n\n  // Check for common circuit patterns and suggest improvements\n  const hasResistor = circuit.components.some(comp => {\n    const schema = getComponentSchema(comp.type);\n    return schema?.id === 'resistor';\n  });\n\n  const hasLED = circuit.components.some(comp => {\n    const schema = getComponentSchema(comp.type);\n    return schema?.id === 'led';\n  });\n\n  if (hasLED && !hasResistor && powerSources.length > 0) {\n    suggestions.push('Consider adding a current-limiting resistor in series with the LED to prevent damage.');\n  }\n\n  // Use existing circuit validation for additional checks\n  try {\n    const existingValidation = validateCircuit(circuit);\n    for (const issue of existingValidation) {\n      if (issue.type === 'error') {\n        errors.push(issue.message);\n      } else if (issue.type === 'warning') {\n        warnings.push(issue.message);\n      }\n    }\n  } catch (error) {\n    // If existing validation fails, add it as an error\n    errors.push(`Circuit validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n    warnings,\n    suggestions\n  };\n}\n\n/**\n * Validate a single component instance\n * \n * @param component - The component instance to validate\n * @returns Validation result\n */\nexport function validateComponentInstance(component: ComponentInstance): LLMValidationResult {\n  const errors: string[] = [];\n  const warnings: string[] = [];\n  const suggestions: string[] = [];\n\n  const schema = getComponentSchema(component.type);\n  \n  if (!schema) {\n    errors.push(`Component type \"${component.type}\" is not registered.`);\n    return { isValid: false, errors, warnings, suggestions };\n  }\n\n  // Validate required properties\n  for (const prop of schema.properties) {\n    const value = component.props[prop.key];\n    \n    if (value === undefined && prop.default === undefined) {\n      warnings.push(`Missing property \"${prop.label}\" (${prop.key}).`);\n    }\n  }\n\n  // Validate position\n  if (typeof component.position.x !== 'number' || typeof component.position.y !== 'number') {\n    errors.push('Component position must have numeric x and y coordinates.');\n  }\n\n  // Validate ID\n  if (!component.id || typeof component.id !== 'string') {\n    errors.push('Component must have a valid string ID.');\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n    warnings,\n    suggestions\n  };\n}\n\n/**\n * Validate a wire connection\n * \n * @param wire - The wire to validate\n * @param components - Array of components in the circuit\n * @returns Validation result\n */\nexport function validateWireConnection(wire: Wire, components: ComponentInstance[]): LLMValidationResult {\n  const errors: string[] = [];\n  const warnings: string[] = [];\n  const suggestions: string[] = [];\n\n  const fromComponent = components.find(c => c.id === wire.from.componentId);\n  const toComponent = components.find(c => c.id === wire.to.componentId);\n  \n  if (!fromComponent) {\n    errors.push(`Source component \"${wire.from.componentId}\" not found.`);\n  }\n  \n  if (!toComponent) {\n    errors.push(`Destination component \"${wire.to.componentId}\" not found.`);\n  }\n\n  if (fromComponent && toComponent) {\n    const fromSchema = getComponentSchema(fromComponent.type);\n    const toSchema = getComponentSchema(toComponent.type);\n    \n    if (fromSchema && toSchema) {\n      const fromPort = fromSchema.ports.find(p => p.id === wire.from.portId);\n      const toPort = toSchema.ports.find(p => p.id === wire.to.portId);\n      \n      if (!fromPort) {\n        errors.push(`Port \"${wire.from.portId}\" not found on ${fromSchema.name}.`);\n      }\n      \n      if (!toPort) {\n        errors.push(`Port \"${wire.to.portId}\" not found on ${toSchema.name}.`);\n      }\n      \n      if (fromPort && toPort) {\n        if (fromPort.type === 'input' && toPort.type === 'input') {\n          warnings.push('Connecting two input ports may not be electrically valid.');\n        }\n      }\n    }\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n    warnings,\n    suggestions\n  };\n}\n","/**\n * Circuit-Bricks LLM Integration API\n *\n * This module provides a comprehensive API for Large Language Models (LLMs)\n * to interact with the Circuit-Bricks component registry and generate circuits.\n *\n * The API is designed to be intuitive and provide clear, structured responses\n * that LLMs can easily understand and work with.\n */\n\n// Export all types\nexport * from './types';\n\n// Component Discovery API\nexport {\n  listAvailableComponents,\n  listComponentsByCategory,\n  getComponentDetails,\n  getAllCategories,\n  searchComponents,\n  getRegistryMetadata,\n  getRegistrySummary,\n  getComponentDetailedSummary\n} from './componentDiscovery';\n\n// Import for internal use\nimport {\n  listAvailableComponents,\n  getAllCategories,\n  getRegistryMetadata\n} from './componentDiscovery';\n\n// Circuit Generation API\nexport {\n  describeCircuit,\n  suggestConnections,\n  generateCircuitTemplate\n} from './circuitGeneration';\n\n// Validation API\nexport {\n  validateCircuitDesign,\n  validateComponentInstance,\n  validateWireConnection\n} from './validation';\n\n/**\n * Quick start function for LLMs to get an overview of available components\n *\n * @returns A comprehensive overview of the component registry\n */\nexport function getQuickStart(): {\n  totalComponents: number;\n  categories: string[];\n  popularComponents: Array<{\n    id: string;\n    name: string;\n    category: string;\n    description: string;\n  }>;\n  exampleUsage: string;\n} {\n  const allComponents = listAvailableComponents();\n  const categories = getAllCategories();\n\n  // Define popular/essential components for quick reference\n  const popularComponentIds = [\n    'resistor', 'capacitor', 'battery', 'led', 'ground',\n    'switch', 'diode', 'transistor-npn'\n  ];\n\n  const popularComponents = popularComponentIds\n    .map(id => allComponents.find(comp => comp.id === id))\n    .filter(comp => comp !== undefined)\n    .map(comp => ({\n      id: comp!.id,\n      name: comp!.name,\n      category: comp!.category,\n      description: comp!.description\n    }));\n\n  const exampleUsage = `\n// Example: Create a simple LED circuit\nimport { generateCircuitTemplate, validateCircuitDesign } from 'circuit-bricks/llm';\n\n// Generate a basic LED circuit template\nconst circuit = generateCircuitTemplate('LED circuit with battery and resistor');\n\n// Validate the circuit\nconst validation = validateCircuitDesign(circuit);\n\nif (validation.isValid) {\n  console.log('Circuit is valid!');\n} else {\n  console.log('Issues found:', validation.errors);\n}\n  `.trim();\n\n  return {\n    totalComponents: allComponents.length,\n    categories,\n    popularComponents,\n    exampleUsage\n  };\n}\n\n/**\n * Get help information for LLMs on how to use the API\n *\n * @returns Help documentation\n */\nexport function getAPIHelp(): {\n  overview: string;\n  commonTasks: Array<{\n    task: string;\n    functions: string[];\n    example: string;\n  }>;\n  bestPractices: string[];\n} {\n  return {\n    overview: `\nThe Circuit-Bricks LLM API provides functions to discover components, generate circuits,\nand validate designs. All functions return structured data that's easy to parse and understand.\n    `.trim(),\n\n    commonTasks: [\n      {\n        task: 'Discover available components',\n        functions: ['listAvailableComponents()', 'getRegistrySummary()', 'searchComponents(query)'],\n        example: `\n// Get all components\nconst components = listAvailableComponents();\n\n// Search for specific components\nconst results = searchComponents('resistor');\n        `.trim()\n      },\n      {\n        task: 'Get component details',\n        functions: ['getComponentDetails(id)', 'getComponentDetailedSummary(id)'],\n        example: `\n// Get structured component data\nconst resistor = getComponentDetails('resistor');\n\n// Get human-readable summary\nconst summary = getComponentDetailedSummary('resistor');\n        `.trim()\n      },\n      {\n        task: 'Generate circuits',\n        functions: ['generateCircuitTemplate(description)', 'suggestConnections(components)'],\n        example: `\n// Generate a circuit from description\nconst circuit = generateCircuitTemplate('voltage divider circuit');\n\n// Get connection suggestions\nconst suggestions = suggestConnections(circuit.components);\n        `.trim()\n      },\n      {\n        task: 'Validate circuits',\n        functions: ['validateCircuitDesign(circuit)', 'describeCircuit(circuit)'],\n        example: `\n// Validate a circuit design\nconst validation = validateCircuitDesign(circuitState);\n\n// Get human-readable description\nconst description = describeCircuit(circuitState);\n        `.trim()\n      }\n    ],\n\n    bestPractices: [\n      'Always validate circuits after generation or modification',\n      'Use searchComponents() to find components by functionality',\n      'Check component port types before making connections',\n      'Include power sources and ground connections in circuits',\n      'Use suggestConnections() for guidance on valid connections',\n      'Read validation errors and warnings carefully for debugging',\n      'Use getComponentDetailedSummary() for comprehensive component information'\n    ]\n  };\n}\n\n/**\n * Utility function to check if the LLM API is properly initialized\n *\n * @returns Status information\n */\nexport function getAPIStatus(): {\n  isReady: boolean;\n  version: string;\n  componentsLoaded: number;\n  categoriesAvailable: number;\n  lastUpdated: string;\n} {\n  try {\n    const metadata = getRegistryMetadata();\n\n    return {\n      isReady: true,\n      version: '0.1.0',\n      componentsLoaded: metadata.totalComponents,\n      categoriesAvailable: metadata.categories.length,\n      lastUpdated: metadata.lastUpdated\n    };\n  } catch (error) {\n    return {\n      isReady: false,\n      version: '0.1.0',\n      componentsLoaded: 0,\n      categoriesAvailable: 0,\n      lastUpdated: new Date().toISOString()\n    };\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,gBAAgBA,SAA0C;CAExE,MAAM,mBAAmB,qBAAqB,QAAQ;AAEtD,MAAK,iBAAiB,QACpB,QAAO,CAAC;EACN,MAAM;EACN,UAAU,6BAA6B,iBAAiB,MAAM;CAC/D,CAAC;CAGJ,MAAMC,SAA4B,CAAE;AAGpC,QAAO,KAAK,GAAG,wBAAwB,QAAQ,CAAC;AAGhD,QAAO,KAAK,GAAG,sBAAsB,QAAQ,CAAC;AAG9C,QAAO,KAAK,GAAG,sBAAsB,QAAQ,CAAC;AAE9C,QAAO;AACR;;;;AAKD,SAAS,wBAAwBD,SAA0C;CACzE,MAAMC,SAA4B,CAAE;CACpC,MAAM,eAAe,IAAI,IAAI,QAAQ,WAAW,IAAI,OAAK,EAAE,GAAG;AAE9D,MAAK,MAAM,QAAQ,QAAQ,OAAO;AAEhC,OAAK,aAAa,IAAI,KAAK,KAAK,YAAY,CAC1C,QAAO,KAAK;GACV,MAAM;GACN,UAAU,+CAA+C,KAAK,KAAK,YAAY;GAC/E,QAAQ,KAAK;EACd,EAAC;AAIJ,OAAK,aAAa,IAAI,KAAK,GAAG,YAAY,CACxC,QAAO,KAAK;GACV,MAAM;GACN,UAAU,+CAA+C,KAAK,GAAG,YAAY;GAC7E,QAAQ,KAAK;EACd,EAAC;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