{
  "name": "free-pbx",
  "displayName": "FreePBX SIP Integration",
  "version": "2.0.0",
  "description": "Complete FreePBX SIP telephony integration with AI voice agent support. Sync extensions, manage assignments, and handle inbound/outbound calls.",
  "author": "Diploy - BTPL Engineering Team",
  "license": "Proprietary",
  "homepage": "https://diploy.in",
  "compatibility": {
    "agentlabs": ">=3.2.0",
    "node": ">=18.0.0"
  },
  "entryPoint": "index.ts",
  "registerFunction": "registerFreePBXSIPRoutes",
  "database": {
    "migrations": ["migrations/001_sip_tables.sql", "migrations/002_sip_tables_v2.sql"],
    "tables": ["freepbx_connections", "sip_extensions", "sip_extension_assignments", "sip_extension_requests", "freepbx_calls"]
  },
  "routes": {
    "api": [
      { "path": "POST /api/webhooks/sip/call/:event", "description": "Call events (start, answer, end, failed, busy)" },
      { "path": "POST /api/webhooks/sip/recording", "description": "Recording ready notification" },
      { "path": "POST /api/webhooks/sip/dtmf", "description": "DTMF events" },
      { "path": "WS /ws/sip", "description": "Real-time audio streaming" },
      { "path": "GET /api/admin/sip/connections", "description": "List FreePBX connections" },
      { "path": "POST /api/admin/sip/connections", "description": "Create connection" },
      { "path": "PUT /api/admin/sip/connections/:id", "description": "Update connection" },
      { "path": "DELETE /api/admin/sip/connections/:id", "description": "Delete connection" },
      { "path": "POST /api/admin/sip/connections/:id/test", "description": "Test connectivity" },
      { "path": "POST /api/admin/sip/connections/:id/sync", "description": "Sync extensions" },
      { "path": "GET /api/admin/sip/extensions", "description": "List all extensions" },
      { "path": "PUT /api/admin/sip/extensions/:id", "description": "Update extension" },
      { "path": "DELETE /api/admin/sip/extensions/:id", "description": "Delete extension" },
      { "path": "GET /api/admin/sip/assignments", "description": "List assignments" },
      { "path": "POST /api/admin/sip/assignments", "description": "Create assignment" },
      { "path": "DELETE /api/admin/sip/assignments/:id", "description": "Remove assignment" },
      { "path": "GET /api/admin/sip/analytics", "description": "Dashboard statistics" },
      { "path": "GET /api/sip/extensions/available", "description": "Browse available extensions" },
      { "path": "GET /api/sip/my-extensions", "description": "My assigned extensions" },
      { "path": "POST /api/sip/requests", "description": "Request extension" },
      { "path": "GET /api/sip/requests", "description": "My extension requests" },
      { "path": "DELETE /api/sip/requests/:id", "description": "Cancel request" },
      { "path": "GET /api/sip/calls", "description": "Call history" },
      { "path": "GET /api/sip/calls/:id", "description": "Call details" },
      { "path": "GET /api/sip/calls/:id/transcript", "description": "Call transcript" },
      { "path": "POST /api/sip/calls/initiate", "description": "Make outbound call" }
    ]
  },
  "ui": {
    "frontendBundle": "client/bootstrap.tsx",
    "adminSettings": [
      { "tab": "connections", "label": "SIP Connections", "component": "SIPConnections", "menu": "/admin/sip/connections", "icon": "Server" },
      { "tab": "extensions", "label": "SIP Extensions", "component": "SIPExtensions", "menu": "/admin/sip/extensions", "icon": "Phone" },
      { "tab": "assignments", "label": "SIP Assignments", "component": "SIPAssignments", "menu": "/admin/sip/assignments", "icon": "Users" }
    ],
    "userSettings": [
      { "tab": "extensions", "label": "My Extensions", "component": "SIPExtensions", "menu": "/app/sip/extensions" },
      { "tab": "calls", "label": "Call History", "component": "SIPCalls", "menu": "/app/sip/calls" }
    ]
  },
  "permissions": {
    "required": ["admin", "user"]
  },
  "features": [
    "FreePBX server integration",
    "SIP extension synchronization",
    "User extension assignment workflow",
    "Inbound/outbound call handling",
    "Call recording and transcription",
    "AI agent integration",
    "Real-time audio streaming",
    "Multi-tenant support"
  ],
  "settings": {
    "webhook_secret": {
      "type": "string",
      "default": "",
      "label": "Webhook Secret",
      "description": "Secret for verifying FreePBX webhook signatures"
    },
    "encryption_key": {
      "type": "string",
      "default": "",
      "label": "SIP Encryption Key",
      "description": "32-character encryption key for SIP credentials"
    }
  }
}
