circuit-bricks
Version:
A modular, Lego-style SVG circuit component system for React (ALPHA - Not for production use)
1 lines • 65.5 kB
Source Map (JSON)
{"version":3,"file":"llm-2eJb9yAY.mjs","names":["circuit: CircuitState","issues: ValidationIssue[]","schema: ComponentSchema","componentId: string","query: string","results: ComponentSearchResult[]","matchedFields: string[]","category: string","componentsByCategory: Record<string, number>","componentId: string","description: string","components: ComponentInstance[]","wires: Wire[]","circuit: CircuitTemplate | CircuitState","componentDescriptions: string[]","connectionDescriptions: string[]","suggestions: ConnectionSuggestion[]","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/registryMetadata.ts","../../src/llm/circuitGeneration.ts","../../src/llm/getAllSchemas.ts","../../src/llm/utilities.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 '../schemas/componentSchema';\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 getComponentSchema,\n getComponentsByCategory\n} from '../registry';\nimport { ComponentSchema } from '../schemas/componentSchema';\nimport {\n ComponentInfo,\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?.map(option => ({\n value: option.value,\n label: option.label\n }))\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\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\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 all unique categories available in the registry\n *\n * @returns Array of category names\n */\nexport function getAllCategories(): string[] {\n const allComponents = getAllComponents();\n const categories = [...new Set(allComponents.map(schema => schema.category))];\n return categories.sort();\n}\n\n/**\n * List components in a specific 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 componentsInCategory = getComponentsByCategory(category);\n return componentsInCategory.map(schemaToComponentInfo);\n}\n","/**\n * Registry Metadata API for LLM Integration\n *\n * This module provides metadata about the component registry for LLM consumption.\n */\n\nimport { getAllComponents } from '../registry';\nimport { RegistryMetadata } from './types';\n\n/**\n * Get comprehensive metadata about the component registry\n *\n * @returns Registry metadata including counts, categories, and organization\n */\nexport function getRegistryMetadata(): RegistryMetadata {\n const allComponents = getAllComponents();\n const categorySet = new Set(allComponents.map(schema => schema.category));\n const categories = Array.from(categorySet).sort();\n \n const componentsByCategory: Record<string, number> = {};\n for (const category of categories) {\n componentsByCategory[category] = allComponents.filter(schema => schema.category === category).length;\n }\n\n return {\n totalComponents: allComponents.length,\n categories,\n componentsByCategory,\n lastUpdated: new Date().toISOString()\n };\n}\n\n/**\n * Generate a human-readable summary of the component registry\n *\n * @returns A comprehensive text summary of the registry\n */\nexport function getRegistrySummary(): string {\n const metadata = getRegistryMetadata();\n const allComponents = getAllComponents();\n\n let summary = `# Circuit-Bricks Component Registry Summary\n\n## Overview\nThe Circuit-Bricks component registry contains ${metadata.totalComponents} components organized into ${metadata.categories.length} categories.\n\n## Categories and Components:\n`;\n\n for (const category of metadata.categories) {\n const categoryComponents = allComponents.filter(schema => schema.category === category);\n summary += `\\n### ${category.charAt(0).toUpperCase() + category.slice(1)} (${categoryComponents.length} components)\n`;\n for (const component of categoryComponents) {\n summary += `- **${component.name}** (${component.id}): ${component.description}\n`;\n }\n }\n\n summary += `\n## Component Capabilities\nTotal ports across all components: ${allComponents.reduce((total, comp) => total + comp.ports.length, 0)}\nTotal configurable properties: ${allComponents.reduce((total, comp) => total + comp.properties.length, 0)}\n\n## Popular Components\nBased on common circuit patterns, the most frequently used components are:\n- Resistor: Essential for current limiting and voltage division\n- Battery/Voltage Source: Power supply components\n- Ground: Reference point for circuits\n- LED: Visual output indicator\n- Switch: User input control\n\nLast updated: ${metadata.lastUpdated}\n`;\n\n return summary;\n}\n\n/**\n * Get a detailed summary for a specific component\n *\n * @param componentId - The ID of the component to summarize\n * @returns Detailed component summary or null if not found\n */\nexport function getComponentDetailedSummary(componentId: string): string | null {\n const allComponents = getAllComponents();\n const component = allComponents.find(schema => schema.id === componentId);\n \n if (!component) {\n return null;\n }\n\n let summary = `# ${component.name} (${component.id})\n\n## Description\n${component.description}\n\n## Category\n${component.category.charAt(0).toUpperCase() + component.category.slice(1)}\n\n## Physical Properties\n- Default Width: ${component.defaultWidth}px\n- Default Height: ${component.defaultHeight}px\n\n## Ports (${component.ports.length} total)\n`;\n\n for (const port of component.ports) {\n summary += `- **${port.id}** (${port.type}): Located at (${port.x}, ${port.y})${port.label ? ` - ${port.label}` : ''}\n`;\n }\n\n if (component.properties.length > 0) {\n summary += `\n## Configurable Properties (${component.properties.length} total)\n`;\n for (const prop of component.properties) {\n let propLine = `- **${prop.label}** (${prop.key}): ${prop.type}`;\n if (prop.default !== undefined) {\n propLine += `, default: ${prop.default}`;\n }\n if (prop.unit) {\n propLine += ` ${prop.unit}`;\n }\n if (prop.min !== undefined || prop.max !== undefined) {\n propLine += ` (range: ${prop.min ?? 'unlimited'} to ${prop.max ?? 'unlimited'})`;\n }\n summary += propLine + '\\n';\n }\n } else {\n summary += `\n## Configurable Properties\nThis component has no configurable properties.\n`;\n }\n\n summary += `\n## Usage Notes\nThis component can be connected to other components through its ${component.ports.length} port${component.ports.length !== 1 ? 's' : ''}. `;\n\n if (component.ports.some(p => p.type === 'input')) {\n summary += 'It has input ports that can receive signals from other components. ';\n }\n if (component.ports.some(p => p.type === 'output')) {\n summary += 'It has output ports that can send signals to other components. ';\n }\n if (component.ports.some(p => p.type === 'inout')) {\n summary += 'It has bidirectional ports that can both send and receive signals. ';\n }\n\n return summary;\n}\n","/**\n * Circuit Generation API for LLM Integration\n *\n * This module provides functions for generating and describing circuits\n * based on natural language descriptions.\n */\n\nimport { getAllComponents } from '../registry';\nimport { CircuitState, ComponentInstance, Wire } from '../schemas/componentSchema';\nimport { CircuitTemplate, CircuitDescriptionSummary, ConnectionSuggestion } from './types';\n\n/**\n * Generate a circuit template from a natural language description\n *\n * @param description - Natural language description of the desired circuit\n * @returns A basic circuit template\n */\nexport function generateCircuitTemplate(description: string): CircuitTemplate {\n const desc = description.toLowerCase();\n const components: ComponentInstance[] = [];\n const wires: Wire[] = [];\n const allSchemas = getAllComponents();\n\n // Simple pattern matching for common circuit types\n let componentId = 1;\n let wireId = 1;\n\n // Always include ground for reference\n if (allSchemas.find(s => s.id === 'ground')) {\n components.push({\n id: `ground_${componentId++}`,\n type: 'ground',\n position: { x: 100, y: 200 },\n props: {}\n });\n }\n\n // LED circuit patterns\n if (desc.includes('led') || desc.includes('light')) {\n if (allSchemas.find(s => s.id === 'led')) {\n components.push({\n id: `led_${componentId++}`,\n type: 'led',\n position: { x: 200, y: 100 },\n props: { color: '#ff0000' }\n });\n }\n\n // Add current limiting resistor\n if (allSchemas.find(s => s.id === 'resistor')) {\n components.push({\n id: `resistor_${componentId++}`,\n type: 'resistor',\n position: { x: 100, y: 100 },\n props: { resistance: 330 }\n });\n }\n\n // Add power source\n if (allSchemas.find(s => s.id === 'battery')) {\n components.push({\n id: `battery_${componentId++}`,\n type: 'battery',\n position: { x: 50, y: 150 },\n props: { voltage: 9 }\n });\n }\n\n // Create basic connections for LED circuit\n if (components.length >= 3) {\n wires.push({\n id: `wire_${wireId++}`,\n from: { componentId: components[2].id, portId: 'positive' },\n to: { componentId: components[1].id, portId: 'terminal_1' }\n });\n wires.push({\n id: `wire_${wireId++}`,\n from: { componentId: components[1].id, portId: 'terminal_2' },\n to: { componentId: components[0].id, portId: 'anode' }\n });\n wires.push({\n id: `wire_${wireId++}`,\n from: { componentId: components[0].id, portId: 'cathode' },\n to: { componentId: components[2].id, portId: 'negative' }\n });\n }\n }\n\n // Simple resistor circuit\n else if (desc.includes('resistor') && !desc.includes('led')) {\n if (allSchemas.find(s => s.id === 'resistor')) {\n components.push({\n id: `resistor_${componentId++}`,\n type: 'resistor',\n position: { x: 150, y: 100 },\n props: { resistance: 1000 }\n });\n }\n\n if (allSchemas.find(s => s.id === 'battery')) {\n components.push({\n id: `battery_${componentId++}`,\n type: 'battery',\n position: { x: 50, y: 150 },\n props: { voltage: 9 }\n });\n }\n }\n\n // Capacitor circuit\n else if (desc.includes('capacitor') || desc.includes('filter')) {\n if (allSchemas.find(s => s.id === 'capacitor')) {\n components.push({\n id: `capacitor_${componentId++}`,\n type: 'capacitor',\n position: { x: 150, y: 100 },\n props: { capacitance: 100 }\n });\n }\n\n if (allSchemas.find(s => s.id === 'battery')) {\n components.push({\n id: `battery_${componentId++}`,\n type: 'battery',\n position: { x: 50, y: 150 },\n props: { voltage: 9 }\n });\n }\n }\n\n // If no specific pattern matched, create a basic circuit with available components\n if (components.length === 1) { // Only ground was added\n const basicComponents = ['resistor', 'battery'];\n for (const compType of basicComponents) {\n if (allSchemas.find(s => s.id === compType)) {\n components.push({\n id: `${compType}_${componentId++}`,\n type: compType,\n position: { x: 100 + components.length * 50, y: 100 },\n props: compType === 'battery' ? { voltage: 9 } : { resistance: 1000 }\n });\n }\n }\n }\n\n return {\n id: `circuit_${Date.now()}`,\n name: `Generated Circuit: ${description}`,\n description: `Auto-generated circuit based on: \"${description}\"`,\n components,\n wires\n };\n}\n\n/**\n * Generate a human-readable description of a circuit\n *\n * @param circuit - The circuit to describe\n * @returns Detailed circuit description\n */\nexport function describeCircuit(circuit: CircuitTemplate | CircuitState): CircuitDescriptionSummary {\n const components = circuit.components;\n const wires = circuit.wires;\n const allSchemas = getAllComponents();\n\n const componentDescriptions: string[] = [];\n const connectionDescriptions: string[] = [];\n\n // Describe components\n for (const comp of components) {\n const schema = allSchemas.find(s => s.id === comp.type);\n if (schema) {\n let desc = `${schema.name} (${comp.id})`;\n if (Object.keys(comp.props).length > 0) {\n const propStrs = Object.entries(comp.props).map(([key, value]) => `${key}: ${value}`);\n desc += ` with properties: ${propStrs.join(', ')}`;\n }\n componentDescriptions.push(desc);\n }\n }\n\n // Describe connections\n for (const wire of wires) {\n const fromComp = components.find(c => c.id === wire.from.componentId);\n const toComp = components.find(c => c.id === wire.to.componentId);\n if (fromComp && toComp) {\n connectionDescriptions.push(\n `${fromComp.type}(${fromComp.id}).${wire.from.portId} → ${toComp.type}(${toComp.id}).${wire.to.portId}`\n );\n }\n }\n\n // Generate analysis\n let analysis = `This circuit contains ${components.length} component${components.length !== 1 ? 's' : ''} and ${wires.length} connection${wires.length !== 1 ? 's' : ''}. `;\n\n const componentTypes = [...new Set(components.map(c => c.type))];\n if (componentTypes.includes('battery') || componentTypes.includes('voltage-source')) {\n analysis += 'It includes a power source. ';\n }\n if (componentTypes.includes('ground')) {\n analysis += 'It has a ground reference. ';\n }\n if (componentTypes.includes('resistor')) {\n analysis += 'It uses resistors for current control. ';\n }\n if (componentTypes.includes('led')) {\n analysis += 'It includes LED indicators. ';\n }\n if (componentTypes.includes('capacitor')) {\n analysis += 'It uses capacitors for filtering or energy storage. ';\n }\n\n return {\n summary: `Circuit with ${components.length} components including: ${componentTypes.join(', ')}`,\n components: componentDescriptions,\n connections: connectionDescriptions,\n analysis\n };\n}\n\n/**\n * Suggest connections between components in a circuit\n *\n * @param components - Array of components to analyze for connections\n * @returns Array of connection suggestions\n */\nexport function suggestConnections(components: ComponentInstance[]): ConnectionSuggestion[] {\n const suggestions: ConnectionSuggestion[] = [];\n const allSchemas = getAllComponents();\n\n for (let i = 0; i < components.length; i++) {\n for (let j = i + 1; j < components.length; j++) {\n const comp1 = components[i];\n const comp2 = components[j];\n \n const schema1 = allSchemas.find(s => s.id === comp1.type);\n const schema2 = allSchemas.find(s => s.id === comp2.type);\n\n if (!schema1 || !schema2) continue;\n\n // Suggest power connections\n if (comp1.type === 'battery' && comp2.type !== 'ground') {\n if (schema1.ports.find(p => p.id === 'positive') && schema2.ports.find(p => p.type === 'input' || p.type === 'inout')) {\n suggestions.push({\n from: { componentId: comp1.id, portId: 'positive' },\n to: { componentId: comp2.id, portId: schema2.ports.find(p => p.type === 'input' || p.type === 'inout')!.id },\n reason: 'Connect power source positive terminal to component input',\n confidence: 0.8\n });\n }\n }\n\n // Suggest ground connections\n if (comp2.type === 'ground') {\n const outputPort = schema1.ports.find(p => p.type === 'output' || p.type === 'inout');\n if (outputPort) {\n suggestions.push({\n from: { componentId: comp1.id, portId: outputPort.id },\n to: { componentId: comp2.id, portId: 'terminal' },\n reason: 'Connect component output to ground reference',\n confidence: 0.7\n });\n }\n }\n\n // Suggest series connections for resistors and LEDs\n if (comp1.type === 'resistor' && comp2.type === 'led') {\n suggestions.push({\n from: { componentId: comp1.id, portId: 'terminal_2' },\n to: { componentId: comp2.id, portId: 'anode' },\n reason: 'Connect resistor output to LED anode for current limiting',\n confidence: 0.9\n });\n }\n }\n }\n\n return suggestions.sort((a, b) => b.confidence - a.confidence);\n}\n","/**\n * Simple tool to get all component schema information for LLM\n * \n * This tool returns all the schema definitions from componentSchema.ts\n */\n\nimport {\n portTypeSchema,\n pointSchema,\n sizeSchema,\n portSchema,\n propertySchema,\n componentSchema,\n componentInstanceSchema,\n wireSchema,\n circuitStateSchema,\n validationIssueSchema\n} from '../schemas/componentSchema';\n\n/**\n * Get all component schema information\n * \n * Returns all the Zod schemas and their structure from componentSchema.ts\n * \n * @returns Object containing all schema definitions\n */\nexport function getAllComponentSchemas() {\n return {\n portTypeSchema,\n pointSchema,\n sizeSchema,\n portSchema,\n propertySchema,\n componentSchema,\n componentInstanceSchema,\n wireSchema,\n circuitStateSchema,\n validationIssueSchema,\n \n // Schema descriptions for LLM understanding\n descriptions: {\n portTypeSchema: \"Enum of all available port types: input, output, inout, positive, negative, anode, cathode, collector, base, emitter, drain, gate, source, vcc, vdd, vss, gnd, clock, reset, enable\",\n pointSchema: \"2D point with x and y coordinates (numbers)\",\n sizeSchema: \"Size dimensions with width and height (numbers)\",\n portSchema: \"Component port with id (string), x (number), y (number), type (portType), optional label (string)\",\n propertySchema: \"Component property with key (string), label (string), type (number|boolean|select|text|color), optional unit (string), optional options array, default value, optional min/max (numbers)\",\n componentSchema: \"Complete component definition with id (string), name (string), category (string), description (string), defaultWidth (number), defaultHeight (number), ports array, properties array, svgPath (string)\",\n componentInstanceSchema: \"Component instance with id (string), type (string), position (point), optional size, props (record), optional rotation (number)\",\n wireSchema: \"Wire connection with id (string), from (componentId, portId), to (componentId, portId), optional style (color, strokeWidth, dashArray)\",\n circuitStateSchema: \"Complete circuit with components array, wires array, selectedComponentIds array, selectedWireIds array\",\n validationIssueSchema: \"Validation issue with type (error|warning), message (string), optional componentId, optional wireId\"\n }\n };\n}\n","/**\n * Utility Functions for LLM Integration\n *\n * This module provides helper functions and information for LLMs working\n * with the Circuit-Bricks library.\n */\n\nimport { getAllComponents } from '../registry';\nimport { getRegistryMetadata } from './registryMetadata';\nimport { QuickStartInfo, APIHelp, APIStatus } from './types';\n\n/**\n * Get quick start information for LLMs new to Circuit-Bricks\n *\n * @returns Quick start guide and essential information\n */\nexport function getQuickStart(): QuickStartInfo {\n const metadata = getRegistryMetadata();\n const allComponents = getAllComponents();\n \n // Find popular/essential components\n const essentialComponents = ['resistor', 'battery', 'ground', 'led', 'switch'];\n const popularComponents = allComponents\n .filter(comp => essentialComponents.includes(comp.id))\n .map(comp => ({\n id: comp.id,\n name: comp.name,\n description: comp.description,\n category: comp.category\n }));\n\n return {\n totalComponents: metadata.totalComponents,\n categories: metadata.categories,\n popularComponents,\n exampleUsage: `// Quick Start Example\nimport { LLM } from 'circuit-bricks';\n\n// 1. Discover available components\nconst components = LLM.listAvailableComponents();\nconsole.log(\\`Found \\${components.length} components\\`);\n\n// 2. Search for specific components\nconst resistors = LLM.searchComponents('resistor');\n\n// 3. Generate a simple circuit\nconst circuit = LLM.generateCircuitTemplate('LED circuit with current limiting resistor');\n\n// 4. Validate the circuit\nconst validation = LLM.validateCircuitDesign(circuit);\nif (!validation.isValid) {\n console.log('Issues found:', validation.errors);\n}\n\n// 5. Get a description of the circuit\nconst description = LLM.describeCircuit(circuit);\nconsole.log(description.summary);`\n };\n}\n\n/**\n * Get comprehensive API help for LLMs\n *\n * @returns Detailed API documentation and guidance\n */\nexport function getAPIHelp(): APIHelp {\n return {\n overview: `Circuit-Bricks LLM Integration API provides a comprehensive set of functions for discovering components, generating circuits, and validating designs. The API is designed to be intuitive for LLMs with clear, structured responses and helpful error messages.`,\n \n commonTasks: [\n {\n task: 'Discover available components',\n function: 'listAvailableComponents()',\n description: 'Get all components with their basic information',\n example: 'const components = LLM.listAvailableComponents();'\n },\n {\n task: 'Search for specific components',\n function: 'searchComponents(query)',\n description: 'Find components by name, description, or category',\n example: 'const results = LLM.searchComponents(\"resistor\");'\n },\n {\n task: 'Get component details',\n function: 'getComponentDetails(id)',\n description: 'Get detailed information about a specific component',\n example: 'const details = LLM.getComponentDetails(\"resistor\");'\n },\n {\n task: 'Generate a circuit',\n function: 'generateCircuitTemplate(description)',\n description: 'Create a circuit from natural language description',\n example: 'const circuit = LLM.generateCircuitTemplate(\"LED circuit\");'\n },\n {\n task: 'Validate a circuit',\n function: 'validateCircuitDesign(circuit)',\n description: 'Check circuit for errors and get suggestions',\n example: 'const validation = LLM.validateCircuitDesign(myCircuit);'\n },\n {\n task: 'Describe a circuit',\n function: 'describeCircuit(circuit)',\n description: 'Get human-readable description of a circuit',\n example: 'const description = LLM.describeCircuit(myCircuit);'\n }\n ],\n \n bestPractices: [\n 'Always validate circuits after generation or modification',\n 'Use getComponentDetails() to understand component capabilities before using them',\n 'Check validation.errors and validation.warnings for circuit issues',\n 'Use searchComponents() to find alternatives if needed components don\\'t exist',\n 'Include ground references in circuits for proper voltage reference',\n 'Use descriptive IDs for components to make circuits easier to understand',\n 'Consider electrical compatibility when connecting components',\n 'Start with simple circuits and gradually add complexity'\n ]\n };\n}\n\n/**\n * Get current API status and system information\n *\n * @returns Current status of the LLM API\n */\nexport function getAPIStatus(): APIStatus {\n const metadata = getRegistryMetadata();\n \n return {\n isReady: true,\n version: '0.1.2', // Should match package.json version\n componentsLoaded: metadata.totalComponents,\n categoriesAvailable: metadata.categories.length,\n lastUpdated: metadata.lastUpdated,\n capabilities: [\n 'Component discovery and search',\n 'Circuit generation from descriptions',\n 'Circuit validation with detailed feedback',\n 'Connection suggestions',\n 'Registry metadata access',\n 'Human-readable circuit descriptions'\n ],\n limitations: [\n 'Circuit generation is pattern-based, not AI-powered',\n 'Validation is structural, not electrical simulation',\n 'Limited to registered component types',\n 'Connection suggestions are heuristic-based'\n ]\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 '../schemas/componentSchema';\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 dynamically\n const componentsByCategory = circuit.components.reduce((acc, comp) => {\n const schema = getComponentSchema(comp.type);\n if (schema) {\n if (!acc[schema.category]) acc[schema.category] = [];\n acc[schema.category].push(comp);\n }\n return acc;\n }, {} as Record<string, ComponentInstance[]>);\n\n // Dynamic LED + resistor check\n const outputComponents = componentsByCategory['output'] || [];\n const passiveComponents = componentsByCategory['passive'] || [];\n\n const hasLEDLikeComponent = outputComponents.some(comp => {\n const schema = getComponentSchema(comp.type);\n return schema?.name.toLowerCase().includes('led') ||\n schema?.description.toLowerCase().includes('light') ||\n schema?.description.toLowerCase().includes('diode');\n });\n\n const hasCurrentLimitingComponent = passiveComponents.some(comp => {\n const schema = getComponentSchema(comp.type);\n return schema?.name.toLowerCase().includes('resistor') ||\n schema?.description.toLowerCase().includes('resistance') ||\n schema?.description.toLowerCase().includes('current limiting');\n });\n\n if (hasLEDLikeComponent && !hasCurrentLimitingComponent && powerSources.length > 0) {\n suggestions.push('Consider adding a current-limiting component (like a resistor) in series with light-emitting components 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 getComponentDetails,\n searchComponents,\n getAllCategories,\n listComponentsByCategory\n} from './componentDiscovery';\n\n// Registry Metadata API\nexport {\n getRegistryMetadata,\n getRegistrySummary,\n getComponentDetailedSummary\n} from './registryMetadata';\n\n// Circuit Generation API\nexport {\n generateCircuitTemplate,\n describeCircuit,\n suggestConnections\n} from './circuitGeneration';\n\n// Schema API\nexport {\n getAllComponentSchemas\n} from './getAllSchemas';\n\n// Utilities API\nexport {\n getQuickStart,\n getAPIHelp,\n getAPIStatus\n} from './utilities';\n\n// Validation API\nexport {\n validateCircuitDesign,\n validateComponentInstance,\n validateWireConnection\n} from './validation';\n\n\n\n\n\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,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