app wizard is not openning any apps by the prompt
Browse files- api.html +13 -41
- index.html +39 -23
api.html
CHANGED
|
@@ -18,61 +18,33 @@
|
|
| 18 |
|
| 19 |
<div class="mt-8 space-y-8">
|
| 20 |
<div class="bg-gray-50 p-6 rounded-lg">
|
| 21 |
-
<h2 class="text-xl font-semibold mb-4 text-purple-700">
|
| 22 |
<div class="bg-gray-800 text-gray-100 p-4 rounded-md mb-4 overflow-x-auto">
|
| 23 |
<code class="text-sm">
|
| 24 |
-
POST /api/
|
| 25 |
-
Content-Type: application/json<br><br>
|
| 26 |
-
Response:<br>
|
| 27 |
-
{<br>
|
| 28 |
-
"success": boolean,<br>
|
| 29 |
-
"message": string,<br>
|
| 30 |
-
"redirectUrl": string<br>
|
| 31 |
-
}
|
| 32 |
-
</code>
|
| 33 |
-
</div>
|
| 34 |
-
</div>
|
| 35 |
-
|
| 36 |
-
<div class="bg-gray-50 p-6 rounded-lg">
|
| 37 |
-
<h2 class="text-xl font-semibold mb-4 text-purple-700">Text Command API</h2>
|
| 38 |
-
<div class="bg-gray-800 text-gray-100 p-4 rounded-md mb-4 overflow-x-auto">
|
| 39 |
-
<code class="text-sm">
|
| 40 |
-
POST /api/text-command<br>
|
| 41 |
Content-Type: application/json<br><br>
|
| 42 |
Request Body:<br>
|
| 43 |
{<br>
|
| 44 |
-
"command": string<br>
|
|
|
|
| 45 |
}<br><br>
|
| 46 |
Response:<br>
|
| 47 |
{<br>
|
| 48 |
"success": boolean,<br>
|
| 49 |
"message": string,<br>
|
| 50 |
-
"redirectUrl": string<br>
|
|
|
|
| 51 |
}
|
| 52 |
</code>
|
| 53 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</div>
|
| 55 |
-
|
| 56 |
-
<div class="bg-gray-50 p-6 rounded-lg">
|
| 57 |
-
<h2 class="text-xl font-semibold mb-4 text-purple-700">Quick Command API</h2>
|
| 58 |
-
<div class="bg-gray-800 text-gray-100 p-4 rounded-md overflow-x-auto">
|
| 59 |
-
<code class="text-sm">
|
| 60 |
-
POST /api/quick-command<br>
|
| 61 |
-
Content-Type: application/json<br><br>
|
| 62 |
-
Request Body:<br>
|
| 63 |
-
{<br>
|
| 64 |
-
"category": string<br>
|
| 65 |
-
}<br><br>
|
| 66 |
-
Response:<br>
|
| 67 |
-
{<br>
|
| 68 |
-
"success": boolean,<br>
|
| 69 |
-
"message": string,<br>
|
| 70 |
-
"redirectUrl": string<br>
|
| 71 |
-
}
|
| 72 |
-
</code>
|
| 73 |
-
</div>
|
| 74 |
-
</div>
|
| 75 |
-
</div>
|
| 76 |
|
| 77 |
<div class="mt-8 pt-4 border-t border-gray-200">
|
| 78 |
<a href="/" class="text-purple-600 hover:text-purple-800 flex items-center">
|
|
|
|
| 18 |
|
| 19 |
<div class="mt-8 space-y-8">
|
| 20 |
<div class="bg-gray-50 p-6 rounded-lg">
|
| 21 |
+
<h2 class="text-xl font-semibold mb-4 text-purple-700">Command Processing API</h2>
|
| 22 |
<div class="bg-gray-800 text-gray-100 p-4 rounded-md mb-4 overflow-x-auto">
|
| 23 |
<code class="text-sm">
|
| 24 |
+
POST /api/process-command<br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
Content-Type: application/json<br><br>
|
| 26 |
Request Body:<br>
|
| 27 |
{<br>
|
| 28 |
+
"command": string,<br>
|
| 29 |
+
"type": "voice"|"text"|"quick"<br>
|
| 30 |
}<br><br>
|
| 31 |
Response:<br>
|
| 32 |
{<br>
|
| 33 |
"success": boolean,<br>
|
| 34 |
"message": string,<br>
|
| 35 |
+
"redirectUrl": string,<br>
|
| 36 |
+
"action": "open"|"search"|"navigate"<br>
|
| 37 |
}
|
| 38 |
</code>
|
| 39 |
</div>
|
| 40 |
+
<p class="text-gray-600 mt-2">
|
| 41 |
+
The API will process the command and return an appropriate action. The frontend should then:<br>
|
| 42 |
+
1. If action is "open", immediately redirect to redirectUrl<br>
|
| 43 |
+
2. If action is "search", show search results<br>
|
| 44 |
+
3. If action is "navigate", show navigation options
|
| 45 |
+
</p>
|
| 46 |
</div>
|
| 47 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
<div class="mt-8 pt-4 border-t border-gray-200">
|
| 50 |
<a href="/" class="text-purple-600 hover:text-purple-800 flex items-center">
|
index.html
CHANGED
|
@@ -67,17 +67,35 @@
|
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
<script>
|
| 70 |
-
//
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
try {
|
| 73 |
-
const
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
if (data.success) {
|
| 83 |
// Process the command and launch appropriate app
|
|
@@ -99,15 +117,14 @@
|
|
| 99 |
if (!command) return;
|
| 100 |
|
| 101 |
try {
|
| 102 |
-
const response = await fetch('/api/
|
| 103 |
method: 'POST',
|
| 104 |
headers: {
|
| 105 |
'Content-Type': 'application/json',
|
| 106 |
},
|
| 107 |
-
body: JSON.stringify({ command })
|
| 108 |
});
|
| 109 |
-
|
| 110 |
-
const data = await response.json();
|
| 111 |
|
| 112 |
if (data.success) {
|
| 113 |
// Process the command and launch appropriate app
|
|
@@ -128,15 +145,14 @@
|
|
| 128 |
const category = button.textContent.trim().split('\n')[0];
|
| 129 |
|
| 130 |
try {
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
const data = await response.json();
|
| 140 |
|
| 141 |
if (data.success) {
|
| 142 |
window.location.href = data.redirectUrl || '#';
|
|
|
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
<script>
|
| 70 |
+
// Check for speech recognition support
|
| 71 |
+
if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) {
|
| 72 |
+
document.querySelector('.fa-microphone').parentElement.style.display = 'none';
|
| 73 |
+
alert('Voice commands not supported in your browser. Try Chrome or Edge.');
|
| 74 |
+
}
|
| 75 |
+
document.querySelector('.fa-microphone').parentElement.addEventListener('click', async () => {
|
| 76 |
try {
|
| 77 |
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 78 |
+
if (!SpeechRecognition) {
|
| 79 |
+
alert('Speech recognition not supported in your browser');
|
| 80 |
+
return;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
const recognition = new SpeechRecognition();
|
| 84 |
+
recognition.lang = 'en-US';
|
| 85 |
+
recognition.interimResults = false;
|
| 86 |
+
recognition.maxAlternatives = 1;
|
| 87 |
+
|
| 88 |
+
recognition.start();
|
| 89 |
+
recognition.onresult = async (event) => {
|
| 90 |
+
const command = event.results[0][0].transcript;
|
| 91 |
+
const response = await fetch('/api/process-command', {
|
| 92 |
+
method: 'POST',
|
| 93 |
+
headers: {
|
| 94 |
+
'Content-Type': 'application/json',
|
| 95 |
+
},
|
| 96 |
+
body: JSON.stringify({ command, type: 'voice' })
|
| 97 |
+
});
|
| 98 |
+
const data = await response.json();
|
| 99 |
|
| 100 |
if (data.success) {
|
| 101 |
// Process the command and launch appropriate app
|
|
|
|
| 117 |
if (!command) return;
|
| 118 |
|
| 119 |
try {
|
| 120 |
+
const response = await fetch('/api/process-command', {
|
| 121 |
method: 'POST',
|
| 122 |
headers: {
|
| 123 |
'Content-Type': 'application/json',
|
| 124 |
},
|
| 125 |
+
body: JSON.stringify({ command, type: 'text' })
|
| 126 |
});
|
| 127 |
+
const data = await response.json();
|
|
|
|
| 128 |
|
| 129 |
if (data.success) {
|
| 130 |
// Process the command and launch appropriate app
|
|
|
|
| 145 |
const category = button.textContent.trim().split('\n')[0];
|
| 146 |
|
| 147 |
try {
|
| 148 |
+
const response = await fetch('/api/process-command', {
|
| 149 |
+
method: 'POST',
|
| 150 |
+
headers: {
|
| 151 |
+
'Content-Type': 'application/json',
|
| 152 |
+
},
|
| 153 |
+
body: JSON.stringify({ command: category, type: 'quick' })
|
| 154 |
+
});
|
| 155 |
+
const data = await response.json();
|
|
|
|
| 156 |
|
| 157 |
if (data.success) {
|
| 158 |
window.location.href = data.redirectUrl || '#';
|