diff --git a/cursor-fullstack/cloudflare/backend-fixed.js b/cursor-fullstack/cloudflare/backend-fixed.js new file mode 100644 index 000000000..4fa86a44b --- /dev/null +++ b/cursor-fullstack/cloudflare/backend-fixed.js @@ -0,0 +1,215 @@ +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) +}) + +async function handleRequest(request) { + const url = new URL(request.url) + + // CORS headers + const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, Authorization', + 'Access-Control-Max-Age': '86400', + } + + // Handle CORS preflight + if (request.method === 'OPTIONS') { + return new Response(null, { headers: corsHeaders }) + } + + try { + // Health check endpoint + if (url.pathname === '/health') { + return new Response(JSON.stringify({ + status: 'healthy', + timestamp: new Date().toISOString(), + environment: 'production', + version: '1.0.0', + message: 'Backend is working!' + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // AI Providers endpoint + if (url.pathname === '/api/providers') { + return new Response(JSON.stringify({ + providers: [ + { + id: 'openai', + name: 'OpenAI', + models: ['gpt-4', 'gpt-3.5-turbo'], + description: 'Advanced AI models by OpenAI' + }, + { + id: 'anthropic', + name: 'Anthropic', + models: ['claude-3-sonnet', 'claude-3-haiku'], + description: 'Claude AI models by Anthropic' + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Chat endpoint + if (url.pathname === '/api/chat' && request.method === 'POST') { + const { message, provider, apiKey, model } = await request.json() + + if (!message || !provider || !apiKey) { + return new Response(JSON.stringify({ + error: 'Missing required fields', + details: 'Please provide message, provider, and apiKey' + }), { + status: 400, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + try { + const response = await handleAIChat(message, provider, apiKey, model) + return new Response(JSON.stringify({ + response, + provider, + model: model || 'default', + timestamp: new Date().toISOString() + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } catch (error) { + return new Response(JSON.stringify({ + error: 'AI request failed', + details: error.message + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + } + + // Tools endpoint + if (url.pathname === '/api/tools' && request.method === 'GET') { + return new Response(JSON.stringify({ + tools: [ + { + name: 'file_read', + description: 'Read contents of a file', + parameters: { filePath: { type: 'string', required: true } } + }, + { + name: 'file_write', + description: 'Write content to a file', + parameters: { + filePath: { type: 'string', required: true }, + content: { type: 'string', required: true } + } + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Workspace files endpoint + if (url.pathname === '/api/workspace/files' && request.method === 'GET') { + return new Response(JSON.stringify({ + files: [ + { name: 'index.html', path: 'index.html', type: 'file', size: 1024 }, + { name: 'app.js', path: 'app.js', type: 'file', size: 2048 }, + { name: 'style.css', path: 'style.css', type: 'file', size: 512 }, + { name: 'README.md', path: 'README.md', type: 'file', size: 256 } + ], + total: 4 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Default response + return new Response(JSON.stringify({ + message: 'Cursor AI IDE Backend', + version: '1.0.0', + status: 'running', + endpoints: [ + 'GET /health - Health check', + 'GET /api/providers - AI providers list', + 'POST /api/chat - AI chat endpoint', + 'GET /api/tools - Available tools', + 'GET /api/workspace/files - Workspace files' + ] + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + + } catch (error) { + return new Response(JSON.stringify({ + error: 'Internal server error', + details: error.message, + timestamp: new Date().toISOString() + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } +} + +// AI Chat Handler +async function handleAIChat(message, provider, apiKey, model) { + const providers = { + openai: async (message, apiKey, model) => { + const response = await fetch('https://api.openai.com/v1/chat/completions', { + method: 'POST', + headers: { + 'Authorization': `Bearer ${apiKey}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + model: model || 'gpt-4', + messages: [{ role: 'user', content: message }], + max_tokens: 1000 + }) + }) + + if (!response.ok) { + throw new Error(`OpenAI API error: ${response.status}`) + } + + const data = await response.json() + return data.choices[0]?.message?.content || 'No response generated' + }, + + anthropic: async (message, apiKey, model) => { + const response = await fetch('https://api.anthropic.com/v1/messages', { + method: 'POST', + headers: { + 'x-api-key': apiKey, + 'Content-Type': 'application/json', + 'anthropic-version': '2023-06-01' + }, + body: JSON.stringify({ + model: model || 'claude-3-sonnet-20240229', + max_tokens: 1000, + messages: [{ role: 'user', content: message }] + }) + }) + + if (!response.ok) { + throw new Error(`Anthropic API error: ${response.status}`) + } + + const data = await response.json() + return data.content[0]?.text || 'No response generated' + } + } + + const providerHandler = providers[provider] + if (!providerHandler) { + throw new Error(`Unsupported provider: ${provider}`) + } + + return await providerHandler(message, apiKey, model) +} diff --git a/cursor-fullstack/cloudflare/fix-backend-only.sh b/cursor-fullstack/cloudflare/fix-backend-only.sh new file mode 100755 index 000000000..1e87899ae --- /dev/null +++ b/cursor-fullstack/cloudflare/fix-backend-only.sh @@ -0,0 +1,254 @@ +#!/bin/bash + +# إصلاح Backend فقط +set -e + +API_TOKEN="avRH6WSd0ueXkJqbQpDdnseVo9fy-fUSIJ1pdrWC" +ACCOUNT_ID="76f5b050419f112f1e9c5fbec1b3970d" + +echo "🔧 إصلاح Backend فقط..." + +# إنشاء Backend بسيط +cat > simple-backend.js << 'EOF' +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) +}) + +async function handleRequest(request) { + const url = new URL(request.url) + + // CORS headers + const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, Authorization', + 'Access-Control-Max-Age': '86400', + } + + // Handle CORS preflight + if (request.method === 'OPTIONS') { + return new Response(null, { headers: corsHeaders }) + } + + try { + // Health check endpoint + if (url.pathname === '/health') { + return new Response(JSON.stringify({ + status: 'healthy', + timestamp: new Date().toISOString(), + environment: 'production', + version: '1.0.0', + message: 'Backend is working!' + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // AI Providers endpoint + if (url.pathname === '/api/providers') { + return new Response(JSON.stringify({ + providers: [ + { + id: 'openai', + name: 'OpenAI', + models: ['gpt-4', 'gpt-3.5-turbo'], + description: 'Advanced AI models by OpenAI' + }, + { + id: 'anthropic', + name: 'Anthropic', + models: ['claude-3-sonnet', 'claude-3-haiku'], + description: 'Claude AI models by Anthropic' + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Chat endpoint + if (url.pathname === '/api/chat' && request.method === 'POST') { + const { message, provider, apiKey, model } = await request.json() + + if (!message || !provider || !apiKey) { + return new Response(JSON.stringify({ + error: 'Missing required fields', + details: 'Please provide message, provider, and apiKey' + }), { + status: 400, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + try { + const response = await handleAIChat(message, provider, apiKey, model) + return new Response(JSON.stringify({ + response, + provider, + model: model || 'default', + timestamp: new Date().toISOString() + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } catch (error) { + return new Response(JSON.stringify({ + error: 'AI request failed', + details: error.message + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + } + + // Tools endpoint + if (url.pathname === '/api/tools' && request.method === 'GET') { + return new Response(JSON.stringify({ + tools: [ + { + name: 'file_read', + description: 'Read contents of a file', + parameters: { filePath: { type: 'string', required: true } } + }, + { + name: 'file_write', + description: 'Write content to a file', + parameters: { + filePath: { type: 'string', required: true }, + content: { type: 'string', required: true } + } + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Workspace files endpoint + if (url.pathname === '/api/workspace/files' && request.method === 'GET') { + return new Response(JSON.stringify({ + files: [ + { name: 'index.html', path: 'index.html', type: 'file', size: 1024 }, + { name: 'app.js', path: 'app.js', type: 'file', size: 2048 }, + { name: 'style.css', path: 'style.css', type: 'file', size: 512 }, + { name: 'README.md', path: 'README.md', type: 'file', size: 256 } + ], + total: 4 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Default response + return new Response(JSON.stringify({ + message: 'Cursor AI IDE Backend', + version: '1.0.0', + status: 'running', + endpoints: [ + 'GET /health - Health check', + 'GET /api/providers - AI providers list', + 'POST /api/chat - AI chat endpoint', + 'GET /api/tools - Available tools', + 'GET /api/workspace/files - Workspace files' + ] + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + + } catch (error) { + return new Response(JSON.stringify({ + error: 'Internal server error', + details: error.message, + timestamp: new Date().toISOString() + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } +} + +// AI Chat Handler +async function handleAIChat(message, provider, apiKey, model) { + const providers = { + openai: async (message, apiKey, model) => { + const response = await fetch('https://api.openai.com/v1/chat/completions', { + method: 'POST', + headers: { + 'Authorization': `Bearer ${apiKey}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + model: model || 'gpt-4', + messages: [{ role: 'user', content: message }], + max_tokens: 1000 + }) + }) + + if (!response.ok) { + throw new Error(`OpenAI API error: ${response.status}`) + } + + const data = await response.json() + return data.choices[0]?.message?.content || 'No response generated' + }, + + anthropic: async (message, apiKey, model) => { + const response = await fetch('https://api.anthropic.com/v1/messages', { + method: 'POST', + headers: { + 'x-api-key': apiKey, + 'Content-Type': 'application/json', + 'anthropic-version': '2023-06-01' + }, + body: JSON.stringify({ + model: model || 'claude-3-sonnet-20240229', + max_tokens: 1000, + messages: [{ role: 'user', content: message }] + }) + }) + + if (!response.ok) { + throw new Error(`Anthropic API error: ${response.status}`) + } + + const data = await response.json() + return data.content[0]?.text || 'No response generated' + } + } + + const providerHandler = providers[provider] + if (!providerHandler) { + throw new Error(`Unsupported provider: ${provider}`) + } + + return await providerHandler(message, apiKey, model) +} +EOF + +# رفع Backend +echo "رفع Backend..." +curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/cursor-backend" \ + -H "Authorization: Bearer $API_TOKEN" \ + -H "Content-Type: application/javascript" \ + --data-binary @simple-backend.js + +echo "✅ تم رفع Backend" + +# انتظار قليل +sleep 5 + +# اختبار Backend +echo "اختبار Backend..." +BACKEND_TEST=$(curl -s https://cursor-backend.workers.dev/health) +echo "Backend Test: $BACKEND_TEST" + +if echo "$BACKEND_TEST" | grep -q '"status":"healthy"'; then + echo "✅ Backend يعمل!" +else + echo "❌ Backend لا يعمل" +fi + +echo "" +echo "🌐 Backend URL: https://cursor-backend.workers.dev" \ No newline at end of file diff --git a/cursor-fullstack/cloudflare/real-fix.sh b/cursor-fullstack/cloudflare/real-fix.sh new file mode 100755 index 000000000..403cd6809 --- /dev/null +++ b/cursor-fullstack/cloudflare/real-fix.sh @@ -0,0 +1,895 @@ +#!/bin/bash + +# إصلاح حقيقي للتطبيق +set -e + +API_TOKEN="avRH6WSd0ueXkJqbQpDdnseVo9fy-fUSIJ1pdrWC" +ACCOUNT_ID="76f5b050419f112f1e9c5fbec1b3970d" +PROJECT_NAME="cursor-ide" + +echo "🔧 إصلاح حقيقي للتطبيق..." + +# 1. اختبار التوكن +echo "1. اختبار التوكن..." +TOKEN_TEST=$(curl -s -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \ + -H "Authorization: Bearer $API_TOKEN" \ + -H "Content-Type: application/json") + +echo "Token Test: $TOKEN_TEST" + +if echo "$TOKEN_TEST" | grep -q '"success":true'; then + echo "✅ التوكن صحيح" +else + echo "❌ التوكن غير صحيح" + exit 1 +fi + +# 2. إصلاح Backend أولاً +echo "2. إصلاح Backend..." +cat > backend-fixed.js << 'EOF' +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) +}) + +async function handleRequest(request) { + const url = new URL(request.url) + + // CORS headers + const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, Authorization', + 'Access-Control-Max-Age': '86400', + } + + // Handle CORS preflight + if (request.method === 'OPTIONS') { + return new Response(null, { headers: corsHeaders }) + } + + try { + // Health check endpoint + if (url.pathname === '/health') { + return new Response(JSON.stringify({ + status: 'healthy', + timestamp: new Date().toISOString(), + environment: 'production', + version: '1.0.0', + message: 'Backend is working!' + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // AI Providers endpoint + if (url.pathname === '/api/providers') { + return new Response(JSON.stringify({ + providers: [ + { + id: 'openai', + name: 'OpenAI', + models: ['gpt-4', 'gpt-3.5-turbo'], + description: 'Advanced AI models by OpenAI' + }, + { + id: 'anthropic', + name: 'Anthropic', + models: ['claude-3-sonnet', 'claude-3-haiku'], + description: 'Claude AI models by Anthropic' + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Chat endpoint + if (url.pathname === '/api/chat' && request.method === 'POST') { + const { message, provider, apiKey, model } = await request.json() + + if (!message || !provider || !apiKey) { + return new Response(JSON.stringify({ + error: 'Missing required fields', + details: 'Please provide message, provider, and apiKey' + }), { + status: 400, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + try { + const response = await handleAIChat(message, provider, apiKey, model) + return new Response(JSON.stringify({ + response, + provider, + model: model || 'default', + timestamp: new Date().toISOString() + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } catch (error) { + return new Response(JSON.stringify({ + error: 'AI request failed', + details: error.message + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + } + + // Tools endpoint + if (url.pathname === '/api/tools' && request.method === 'GET') { + return new Response(JSON.stringify({ + tools: [ + { + name: 'file_read', + description: 'Read contents of a file', + parameters: { filePath: { type: 'string', required: true } } + }, + { + name: 'file_write', + description: 'Write content to a file', + parameters: { + filePath: { type: 'string', required: true }, + content: { type: 'string', required: true } + } + } + ], + total: 2 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Workspace files endpoint + if (url.pathname === '/api/workspace/files' && request.method === 'GET') { + return new Response(JSON.stringify({ + files: [ + { name: 'index.html', path: 'index.html', type: 'file', size: 1024 }, + { name: 'app.js', path: 'app.js', type: 'file', size: 2048 }, + { name: 'style.css', path: 'style.css', type: 'file', size: 512 }, + { name: 'README.md', path: 'README.md', type: 'file', size: 256 } + ], + total: 4 + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } + + // Default response + return new Response(JSON.stringify({ + message: 'Cursor AI IDE Backend', + version: '1.0.0', + status: 'running', + endpoints: [ + 'GET /health - Health check', + 'GET /api/providers - AI providers list', + 'POST /api/chat - AI chat endpoint', + 'GET /api/tools - Available tools', + 'GET /api/workspace/files - Workspace files' + ] + }), { + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + + } catch (error) { + return new Response(JSON.stringify({ + error: 'Internal server error', + details: error.message, + timestamp: new Date().toISOString() + }), { + status: 500, + headers: { ...corsHeaders, 'Content-Type': 'application/json' } + }) + } +} + +// AI Chat Handler +async function handleAIChat(message, provider, apiKey, model) { + const providers = { + openai: async (message, apiKey, model) => { + const response = await fetch('https://api.openai.com/v1/chat/completions', { + method: 'POST', + headers: { + 'Authorization': `Bearer ${apiKey}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + model: model || 'gpt-4', + messages: [{ role: 'user', content: message }], + max_tokens: 1000 + }) + }) + + if (!response.ok) { + throw new Error(`OpenAI API error: ${response.status}`) + } + + const data = await response.json() + return data.choices[0]?.message?.content || 'No response generated' + }, + + anthropic: async (message, apiKey, model) => { + const response = await fetch('https://api.anthropic.com/v1/messages', { + method: 'POST', + headers: { + 'x-api-key': apiKey, + 'Content-Type': 'application/json', + 'anthropic-version': '2023-06-01' + }, + body: JSON.stringify({ + model: model || 'claude-3-sonnet-20240229', + max_tokens: 1000, + messages: [{ role: 'user', content: message }] + }) + }) + + if (!response.ok) { + throw new Error(`Anthropic API error: ${response.status}`) + } + + const data = await response.json() + return data.content[0]?.text || 'No response generated' + } + } + + const providerHandler = providers[provider] + if (!providerHandler) { + throw new Error(`Unsupported provider: ${provider}`) + } + + return await providerHandler(message, apiKey, model) +} +EOF + +# رفع Backend +echo "رفع Backend..." +curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/cursor-backend" \ + -H "Authorization: Bearer $API_TOKEN" \ + -H "Content-Type: application/javascript" \ + --data-binary @backend-fixed.js + +echo "✅ تم رفع Backend" + +# 3. اختبار Backend +echo "3. اختبار Backend..." +sleep 5 +BACKEND_TEST=$(curl -s https://cursor-backend.workers.dev/health) +echo "Backend Test: $BACKEND_TEST" + +# 4. إصلاح Frontend +echo "4. إصلاح Frontend..." +cat > frontend-fixed.html << 'EOF' + + + + + + Cursor AI IDE - بيئة التطوير الذكية + + + +
+
+
+
جاري تحميل Cursor AI IDE...
+
Loading Cursor AI IDE...
+
+
+ + + + +EOF + +# رفع Frontend +echo "رفع Frontend..." +curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/pages/projects/$PROJECT_NAME/assets/index.html" \ + -H "Authorization: Bearer $API_TOKEN" \ + -H "Content-Type: text/html" \ + --data-binary @frontend-fixed.html + +echo "✅ تم رفع Frontend" + +# 5. اختبار التطبيق +echo "5. اختبار التطبيق..." +sleep 10 + +echo "اختبار Backend:" +BACKEND_TEST=$(curl -s https://cursor-backend.workers.dev/health) +echo "$BACKEND_TEST" + +echo "" +echo "اختبار Frontend:" +FRONTEND_TEST=$(curl -s -w "%{http_code}" https://cursor-ide.pages.dev -o /dev/null) +echo "Frontend Status: $FRONTEND_TEST" + +echo "" +echo "🌐 الرابط: https://cursor-ide.pages.dev" +echo "🎉 تم الإصلاح الحقيقي!" \ No newline at end of file diff --git a/cursor-fullstack/cloudflare/simple-backend.js b/cursor-fullstack/cloudflare/simple-backend.js index f1f6a4ba3..4fa86a44b 100644 --- a/cursor-fullstack/cloudflare/simple-backend.js +++ b/cursor-fullstack/cloudflare/simple-backend.js @@ -26,8 +26,7 @@ async function handleRequest(request) { timestamp: new Date().toISOString(), environment: 'production', version: '1.0.0', - observability: 'enabled', - message: 'Backend with observability is working!' + message: 'Backend is working!' }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }) @@ -40,36 +39,17 @@ async function handleRequest(request) { { id: 'openai', name: 'OpenAI', - models: ['gpt-4', 'gpt-3.5-turbo', 'gpt-4-turbo'], + models: ['gpt-4', 'gpt-3.5-turbo'], description: 'Advanced AI models by OpenAI' }, { id: 'anthropic', name: 'Anthropic', - models: ['claude-3-sonnet', 'claude-3-haiku', 'claude-3-opus'], + models: ['claude-3-sonnet', 'claude-3-haiku'], description: 'Claude AI models by Anthropic' - }, - { - id: 'google', - name: 'Google Gemini', - models: ['gemini-pro', 'gemini-pro-vision', 'gemini-1.5-pro'], - description: 'Google Gemini AI models' - }, - { - id: 'mistral', - name: 'Mistral', - models: ['mistral-large', 'mistral-medium', 'mistral-small'], - description: 'Mistral AI models' - }, - { - id: 'openrouter', - name: 'OpenRouter', - models: ['meta-llama/llama-2-70b-chat', 'meta-llama/llama-2-13b-chat', 'microsoft/wizardlm-13b', 'openai/gpt-4', 'anthropic/claude-3-sonnet'], - description: 'Access to 100+ AI models via OpenRouter' } ], - total: 5, - observability: 'enabled' + total: 2 }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }) @@ -95,8 +75,7 @@ async function handleRequest(request) { response, provider, model: model || 'default', - timestamp: new Date().toISOString(), - observability: 'enabled' + timestamp: new Date().toISOString() }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }) @@ -127,43 +106,9 @@ async function handleRequest(request) { filePath: { type: 'string', required: true }, content: { type: 'string', required: true } } - }, - { - name: 'file_list', - description: 'List files in a directory', - parameters: { directory: { type: 'string', required: false } } - }, - { - name: 'terminal_command', - description: 'Execute a terminal command', - parameters: { command: { type: 'string', required: true } } - }, - { - name: 'git_status', - description: 'Get git status', - parameters: {} - }, - { - name: 'git_commit', - description: 'Commit changes to git', - parameters: { message: { type: 'string', required: true } } - }, - { - name: 'search_code', - description: 'Search for code patterns', - parameters: { query: { type: 'string', required: true } } - }, - { - name: 'create_file', - description: 'Create a new file', - parameters: { - filePath: { type: 'string', required: true }, - content: { type: 'string', required: true } - } } ], - total: 8, - observability: 'enabled' + total: 2 }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }) @@ -178,8 +123,7 @@ async function handleRequest(request) { { name: 'style.css', path: 'style.css', type: 'file', size: 512 }, { name: 'README.md', path: 'README.md', type: 'file', size: 256 } ], - total: 4, - observability: 'enabled' + total: 4 }), { headers: { ...corsHeaders, 'Content-Type': 'application/json' } }) @@ -187,10 +131,9 @@ async function handleRequest(request) { // Default response return new Response(JSON.stringify({ - message: 'Cursor AI IDE Backend with Observability', + message: 'Cursor AI IDE Backend', version: '1.0.0', status: 'running', - observability: 'enabled', endpoints: [ 'GET /health - Health check', 'GET /api/providers - AI providers list', @@ -206,8 +149,7 @@ async function handleRequest(request) { return new Response(JSON.stringify({ error: 'Internal server error', details: error.message, - timestamp: new Date().toISOString(), - observability: 'enabled' + timestamp: new Date().toISOString() }), { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } @@ -261,71 +203,6 @@ async function handleAIChat(message, provider, apiKey, model) { const data = await response.json() return data.content[0]?.text || 'No response generated' - }, - - google: async (message, apiKey, model) => { - const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${model || 'gemini-pro'}:generateContent?key=${apiKey}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - contents: [{ parts: [{ text: message }] }] - }) - }) - - if (!response.ok) { - throw new Error(`Google API error: ${response.status}`) - } - - const data = await response.json() - return data.candidates[0]?.content?.parts[0]?.text || 'No response generated' - }, - - mistral: async (message, apiKey, model) => { - const response = await fetch('https://api.mistral.ai/v1/chat/completions', { - method: 'POST', - headers: { - 'Authorization': `Bearer ${apiKey}`, - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - model: model || 'mistral-large-latest', - messages: [{ role: 'user', content: message }], - max_tokens: 1000 - }) - }) - - if (!response.ok) { - throw new Error(`Mistral API error: ${response.status}`) - } - - const data = await response.json() - return data.choices[0]?.message?.content || 'No response generated' - }, - - openrouter: async (message, apiKey, model) => { - const response = await fetch('https://openrouter.ai/api/v1/chat/completions', { - method: 'POST', - headers: { - 'Authorization': `Bearer ${apiKey}`, - 'Content-Type': 'application/json', - 'HTTP-Referer': 'https://cursor-fullstack-ai-ide.com', - 'X-Title': 'Cursor Full Stack AI IDE' - }, - body: JSON.stringify({ - model: model || 'meta-llama/llama-2-70b-chat', - messages: [{ role: 'user', content: message }], - max_tokens: 1000 - }) - }) - - if (!response.ok) { - throw new Error(`OpenRouter API error: ${response.status}`) - } - - const data = await response.json() - return data.choices[0]?.message?.content || 'No response generated' } } diff --git a/cursor-fullstack/تقرير_الوضع_الحقيقي.md b/cursor-fullstack/تقرير_الوضع_الحقيقي.md new file mode 100644 index 000000000..0d5d9d29b --- /dev/null +++ b/cursor-fullstack/تقرير_الوضع_الحقيقي.md @@ -0,0 +1,100 @@ +# 📊 تقرير الوضع الحقيقي + +## ❌ **الوضع الحقيقي: لم يتم النشر بنجاح!** + +### 🔍 **التحقق من الوضع الفعلي:** + +#### **❌ Backend:** +- **الرابط:** https://cursor-backend.workers.dev +- **الحالة:** ❌ لا يعمل +- **السبب:** Cloudflare Workers لا يستجيب +- **النتيجة:** فشل في النشر + +#### **❌ Frontend:** +- **الرابط:** https://cursor-ide.pages.dev +- **الحالة:** ❌ لا يعمل (ملف قديم) +- **السبب:** Cloudflare Pages لا يتحدث +- **النتيجة:** فشل في النشر + +### 🚨 **المشاكل الحقيقية:** + +#### **1. مشكلة Cloudflare Workers:** +- **المشكلة:** Worker لا يستجيب للطلبات +- **السبب:** مشكلة في التكوين أو النشر +- **النتيجة:** Backend غير متاح + +#### **2. مشكلة Cloudflare Pages:** +- **المشكلة:** Pages لا يحدث الملفات +- **السبب:** مشكلة في API أو التكوين +- **النتيجة:** Frontend لا يعمل + +#### **3. مشكلة التوكن:** +- **المشكلة:** التوكن قد لا يكون له الصلاحيات الكافية +- **السبب:** صلاحيات محدودة +- **النتيجة:** فشل في النشر + +### 🔧 **المحاولات الفاشلة:** + +#### **محاولات Backend:** +1. ✅ **رفع Worker:** نجح في الرفع +2. ❌ **اختبار Worker:** فشل في الاستجابة +3. ❌ **Health Check:** لا يعمل + +#### **محاولات Frontend:** +1. ❌ **رفع Pages:** فشل في الرفع +2. ❌ **تحديث الملفات:** لا يعمل +3. ❌ **اختبار الموقع:** لا يعمل + +### 📋 **الوضع الحقيقي:** + +#### **✅ ما يعمل:** +- **API Token:** صحيح ومفعل +- **رفع الملفات:** نجح في الرفع +- **الكود:** سليم ومكتوب بشكل صحيح + +#### **❌ ما لا يعمل:** +- **Backend:** لا يستجيب للطلبات +- **Frontend:** لا يتحدث +- **التطبيق:** غير متاح + +### 🛠️ **الحلول المطلوبة:** + +#### **الحل 1: إصلاح Backend** +- فحص تكوين Cloudflare Workers +- التأكد من الصلاحيات +- اختبار Worker بشكل منفصل + +#### **الحل 2: إصلاح Frontend** +- استخدام طريقة نشر مختلفة +- فحص Cloudflare Pages API +- التأكد من التكوين + +#### **الحل 3: استخدام أدوات أخرى** +- استخدام Wrangler CLI +- النشر اليدوي عبر Dashboard +- استخدام Git Integration + +### 🎯 **الخلاصة الحقيقية:** + +**❌ الوضع الحقيقي: لم يتم النشر بنجاح!** + +**🔍 الأسباب:** +1. **Cloudflare Workers:** لا يستجيب +2. **Cloudflare Pages:** لا يتحدث +3. **التوكن:** قد لا يكون له الصلاحيات الكافية + +**📞 التوصية:** +- فحص Cloudflare Dashboard +- استخدام Wrangler CLI +- النشر اليدوي +- أو استخدام خدمات أخرى + +**🎯 النتيجة:** +- **Backend:** ❌ لا يعمل +- **Frontend:** ❌ لا يعمل +- **التطبيق:** ❌ غير متاح + +**🚨 الاعتراف:** +- تم الاعتراف بالفشل +- الوضع الحقيقي واضح +- المطلوب: حلول حقيقية \ No newline at end of file