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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Shami's Agent System</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg: #0a0a0a; --surface: #111; --surface2: #1a1a1a;
|
| 10 |
+
--border: #222; --text: #e0e0e0; --text-dim: #666;
|
| 11 |
+
--accent: #4a9eff; --accent-dim: #1a3a5c;
|
| 12 |
+
--green: #4ade80; --yellow: #fbbf24; --red: #f87171;
|
| 13 |
+
}
|
| 14 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 15 |
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; display: flex; }
|
| 16 |
+
|
| 17 |
+
/* Sidebar */
|
| 18 |
+
.sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
|
| 19 |
+
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
|
| 20 |
+
.sidebar-header h1 { font-size: 16px; color: #fff; letter-spacing: -0.3px; }
|
| 21 |
+
.sidebar-header p { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
|
| 22 |
+
.agent-list { flex: 1; overflow-y: auto; padding: 8px; }
|
| 23 |
+
.agent-btn { width: 100%; text-align: left; padding: 12px 14px; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--text); cursor: pointer; margin-bottom: 4px; font-size: 13px; display: flex; align-items: center; gap: 10px; transition: all 0.15s; }
|
| 24 |
+
.agent-btn:hover { background: var(--surface2); border-color: var(--border); }
|
| 25 |
+
.agent-btn.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
|
| 26 |
+
.agent-btn .icon { font-size: 18px; width: 28px; text-align: center; }
|
| 27 |
+
.agent-btn .info { flex: 1; }
|
| 28 |
+
.agent-btn .name { font-weight: 600; display: block; }
|
| 29 |
+
.agent-btn .desc { font-size: 11px; color: var(--text-dim); display: block; margin-top: 2px; }
|
| 30 |
+
.agent-btn.active .desc { color: #aaa; }
|
| 31 |
+
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim); }
|
| 32 |
+
.sidebar-footer a { color: var(--accent); text-decoration: none; }
|
| 33 |
+
|
| 34 |
+
/* Main area */
|
| 35 |
+
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
|
| 36 |
+
.main-header { padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: space-between; }
|
| 37 |
+
.main-header h2 { font-size: 15px; color: #fff; }
|
| 38 |
+
.main-header .tools { font-size: 11px; color: var(--text-dim); }
|
| 39 |
+
.main-header .tools span { background: var(--surface2); padding: 2px 8px; border-radius: 4px; margin-left: 4px; border: 1px solid var(--border); }
|
| 40 |
+
|
| 41 |
+
/* Chat area */
|
| 42 |
+
.chat { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
|
| 43 |
+
.msg { max-width: 85%; padding: 14px 18px; border-radius: 12px; line-height: 1.6; font-size: 14px; }
|
| 44 |
+
.msg.user { align-self: flex-end; background: var(--accent-dim); border: 1px solid #2a4a6c; }
|
| 45 |
+
.msg.assistant { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); }
|
| 46 |
+
.msg pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; font-size: 13px; border: 1px solid var(--border); }
|
| 47 |
+
.msg code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; }
|
| 48 |
+
.msg p code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
|
| 49 |
+
.msg table { border-collapse: collapse; margin: 10px 0; width: 100%; }
|
| 50 |
+
.msg th, .msg td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: 13px; }
|
| 51 |
+
.msg th { background: var(--bg); }
|
| 52 |
+
.msg h1, .msg h2, .msg h3 { margin: 12px 0 6px; color: #fff; }
|
| 53 |
+
.msg h1 { font-size: 18px; } .msg h2 { font-size: 16px; } .msg h3 { font-size: 14px; }
|
| 54 |
+
.msg ul, .msg ol { padding-left: 20px; margin: 6px 0; }
|
| 55 |
+
.msg a { color: var(--accent); }
|
| 56 |
+
.msg strong { color: #fff; }
|
| 57 |
+
|
| 58 |
+
/* Tool call indicator */
|
| 59 |
+
.tool-indicator { align-self: flex-start; font-size: 12px; color: var(--text-dim); padding: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; display: flex; align-items: center; gap: 6px; }
|
| 60 |
+
.tool-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1s infinite; }
|
| 61 |
+
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
|
| 62 |
+
|
| 63 |
+
/* Meta info after response */
|
| 64 |
+
.meta { align-self: flex-start; font-size: 11px; color: var(--text-dim); padding: 4px 0; }
|
| 65 |
+
|
| 66 |
+
/* Input */
|
| 67 |
+
.input-area { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface); display: flex; gap: 12px; }
|
| 68 |
+
.input-area textarea { flex: 1; padding: 12px 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit; outline: none; resize: none; min-height: 44px; max-height: 120px; }
|
| 69 |
+
.input-area textarea:focus { border-color: var(--accent); }
|
| 70 |
+
.input-area button { padding: 12px 24px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 500; align-self: flex-end; }
|
| 71 |
+
.input-area button:hover { background: #3a8eef; }
|
| 72 |
+
.input-area button:disabled { background: #333; cursor: not-allowed; }
|
| 73 |
+
|
| 74 |
+
/* Welcome */
|
| 75 |
+
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
|
| 76 |
+
.welcome h2 { font-size: 22px; margin-bottom: 8px; color: #fff; }
|
| 77 |
+
.welcome p { color: var(--text-dim); font-size: 14px; max-width: 400px; line-height: 1.6; }
|
| 78 |
+
.examples { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
|
| 79 |
+
.example-btn { padding: 10px 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 13px; text-align: left; transition: all 0.15s; }
|
| 80 |
+
.example-btn:hover { border-color: var(--accent); background: var(--accent-dim); }
|
| 81 |
+
|
| 82 |
+
@media (max-width: 768px) {
|
| 83 |
+
body { flex-direction: column; }
|
| 84 |
+
.sidebar { width: 100%; height: auto; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
|
| 85 |
+
}
|
| 86 |
+
</style>
|
| 87 |
+
</head>
|
| 88 |
+
<body>
|
| 89 |
+
<div class="sidebar">
|
| 90 |
+
<div class="sidebar-header">
|
| 91 |
+
<h1>Shami's Agents</h1>
|
| 92 |
+
<p>AI-powered tools for real work</p>
|
| 93 |
+
</div>
|
| 94 |
+
<div class="agent-list" id="agentList"></div>
|
| 95 |
+
<div class="sidebar-footer">
|
| 96 |
+
Groq + Tavily · <a href="/health" target="_blank">API Health</a> · <a href="/docs" target="_blank">API Docs</a>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
<div class="main">
|
| 101 |
+
<div class="main-header" id="mainHeader">
|
| 102 |
+
<h2 id="headerTitle">Select an Agent</h2>
|
| 103 |
+
<div class="tools" id="headerTools"></div>
|
| 104 |
+
</div>
|
| 105 |
+
<div class="chat" id="chat">
|
| 106 |
+
<div class="welcome" id="welcome">
|
| 107 |
+
<h2>What do you need done?</h2>
|
| 108 |
+
<p>Pick an agent from the sidebar, or try an example below.</p>
|
| 109 |
+
<div class="examples" id="examples"></div>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
<div class="input-area">
|
| 113 |
+
<textarea id="input" placeholder="Give the agent a goal..." rows="1"></textarea>
|
| 114 |
+
<button id="send" onclick="sendMessage()">Run</button>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<script>
|
| 119 |
+
let currentAgent = null;
|
| 120 |
+
let agents = {};
|
| 121 |
+
|
| 122 |
+
const EXAMPLES = {
|
| 123 |
+
search: "Find 5 remote AI/LLM engineer jobs paying $5K+/month, Europe or Gulf region",
|
| 124 |
+
research: "Compare Supabase vs Firebase vs PlanetScale for a SaaS with 10K users",
|
| 125 |
+
review: "Review this PR: https://github.com/vercel/next.js/pull/78498",
|
| 126 |
+
upwork: "Draft a proposal for this job: I need a developer to build a custom AI chatbot for my e-commerce store that can answer product questions using our catalog",
|
| 127 |
+
n8n: "Hi, I found your profile on Upwork. We need someone to build an AI agent that processes customer support tickets automatically. Budget is $2000-3000. Are you available?",
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
// Load agents
|
| 131 |
+
fetch("/agents").then(r => r.json()).then(data => {
|
| 132 |
+
agents = {};
|
| 133 |
+
const list = document.getElementById("agentList");
|
| 134 |
+
const examples = document.getElementById("examples");
|
| 135 |
+
data.agents.forEach(a => {
|
| 136 |
+
agents[a.id] = a;
|
| 137 |
+
const btn = document.createElement("button");
|
| 138 |
+
btn.className = "agent-btn";
|
| 139 |
+
btn.dataset.id = a.id;
|
| 140 |
+
btn.innerHTML = `<span class="icon">${a.icon}</span><span class="info"><span class="name">${a.name}</span><span class="desc">${a.description}</span></span>`;
|
| 141 |
+
btn.onclick = () => selectAgent(a.id);
|
| 142 |
+
list.appendChild(btn);
|
| 143 |
+
|
| 144 |
+
if (EXAMPLES[a.id]) {
|
| 145 |
+
const ex = document.createElement("button");
|
| 146 |
+
ex.className = "example-btn";
|
| 147 |
+
ex.textContent = `${a.icon} ${EXAMPLES[a.id].slice(0, 60)}...`;
|
| 148 |
+
ex.onclick = () => { selectAgent(a.id); document.getElementById("input").value = EXAMPLES[a.id]; sendMessage(); };
|
| 149 |
+
examples.appendChild(ex);
|
| 150 |
+
}
|
| 151 |
+
});
|
| 152 |
+
});
|
| 153 |
+
|
| 154 |
+
function selectAgent(id) {
|
| 155 |
+
currentAgent = id;
|
| 156 |
+
const a = agents[id];
|
| 157 |
+
document.querySelectorAll(".agent-btn").forEach(b => b.classList.toggle("active", b.dataset.id === id));
|
| 158 |
+
document.getElementById("headerTitle").textContent = `${a.icon} ${a.name}`;
|
| 159 |
+
document.getElementById("headerTools").innerHTML = a.tools.map(t => `<span>${t}</span>`).join("");
|
| 160 |
+
document.getElementById("welcome")?.remove();
|
| 161 |
+
document.getElementById("input").placeholder = `Goal for ${a.name}...`;
|
| 162 |
+
document.getElementById("input").focus();
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
const input = document.getElementById("input");
|
| 166 |
+
input.addEventListener("keydown", e => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); sendMessage(); } });
|
| 167 |
+
input.addEventListener("input", () => { input.style.height = "auto"; input.style.height = Math.min(input.scrollHeight, 120) + "px"; });
|
| 168 |
+
|
| 169 |
+
async function sendMessage() {
|
| 170 |
+
const msg = input.value.trim();
|
| 171 |
+
if (!msg || !currentAgent) { if (!currentAgent) alert("Pick an agent first"); return; }
|
| 172 |
+
input.value = "";
|
| 173 |
+
input.style.height = "auto";
|
| 174 |
+
const btn = document.getElementById("send");
|
| 175 |
+
btn.disabled = true;
|
| 176 |
+
const chat = document.getElementById("chat");
|
| 177 |
+
|
| 178 |
+
chat.innerHTML += `<div class="msg user">${esc(msg)}</div>`;
|
| 179 |
+
const toolDiv = document.createElement("div");
|
| 180 |
+
toolDiv.className = "tool-indicator";
|
| 181 |
+
toolDiv.innerHTML = `<span class="dot"></span> ${agents[currentAgent].name} working...`;
|
| 182 |
+
chat.appendChild(toolDiv);
|
| 183 |
+
chat.scrollTop = chat.scrollHeight;
|
| 184 |
+
|
| 185 |
+
const start = Date.now();
|
| 186 |
+
try {
|
| 187 |
+
const res = await fetch(`/agent/${currentAgent}`, {
|
| 188 |
+
method: "POST",
|
| 189 |
+
headers: { "Content-Type": "application/json" },
|
| 190 |
+
body: JSON.stringify({ message: msg, conversation_id: `web-${currentAgent}-${Date.now()}` }),
|
| 191 |
+
});
|
| 192 |
+
const data = await res.json();
|
| 193 |
+
toolDiv.remove();
|
| 194 |
+
|
| 195 |
+
if (!res.ok) {
|
| 196 |
+
chat.innerHTML += `<div class="msg assistant" style="border-color:var(--red)">Error: ${esc(data.detail || JSON.stringify(data))}</div>`;
|
| 197 |
+
} else {
|
| 198 |
+
chat.innerHTML += `<div class="msg assistant">${renderMd(data.result)}</div>`;
|
| 199 |
+
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
| 200 |
+
const toolsInfo = data.tools_used.length > 0 ? ` · Tools: ${data.tools_used.join(", ")}` : "";
|
| 201 |
+
chat.innerHTML += `<div class="meta">${data.tool_calls_made} tool calls · ${data.iterations} iterations · ${elapsed}s${toolsInfo}</div>`;
|
| 202 |
+
}
|
| 203 |
+
} catch (e) {
|
| 204 |
+
toolDiv.remove();
|
| 205 |
+
chat.innerHTML += `<div class="msg assistant" style="border-color:var(--red)">Connection error: ${esc(e.message)}</div>`;
|
| 206 |
+
}
|
| 207 |
+
chat.scrollTop = chat.scrollHeight;
|
| 208 |
+
btn.disabled = false;
|
| 209 |
+
input.focus();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
function esc(s) { return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"); }
|
| 213 |
+
|
| 214 |
+
function renderMd(s) {
|
| 215 |
+
// Basic markdown rendering
|
| 216 |
+
let html = esc(s);
|
| 217 |
+
// Code blocks
|
| 218 |
+
html = html.replace(/```(\w*)\n([\s\S]*?)```/g, (_, lang, code) => `<pre><code>${code}</code></pre>`);
|
| 219 |
+
// Inline code
|
| 220 |
+
html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
|
| 221 |
+
// Headers
|
| 222 |
+
html = html.replace(/^### (.+)$/gm, "<h3>$1</h3>");
|
| 223 |
+
html = html.replace(/^## (.+)$/gm, "<h2>$1</h2>");
|
| 224 |
+
html = html.replace(/^# (.+)$/gm, "<h1>$1</h1>");
|
| 225 |
+
// Bold
|
| 226 |
+
html = html.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
|
| 227 |
+
// Italic
|
| 228 |
+
html = html.replace(/\*([^*]+)\*/g, "<em>$1</em>");
|
| 229 |
+
// Links
|
| 230 |
+
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
|
| 231 |
+
// Lists
|
| 232 |
+
html = html.replace(/^- (.+)$/gm, "<li>$1</li>");
|
| 233 |
+
html = html.replace(/(<li>.*<\/li>\n?)+/g, m => `<ul>${m}</ul>`);
|
| 234 |
+
// Line breaks
|
| 235 |
+
html = html.replace(/\n\n/g, "</p><p>");
|
| 236 |
+
html = html.replace(/\n/g, "<br>");
|
| 237 |
+
return `<p>${html}</p>`;
|
| 238 |
+
}
|
| 239 |
+
</script>
|
| 240 |
+
</body>
|
| 241 |
+
</html>
|