Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | "use client"; |
| 2 | |
| 3 | import { AnimatePresence, motion } from "motion/react"; |
| 4 | import { Check, ChevronRight } from "lucide-react"; |
| 5 | import { useEffect, useRef, useState } from "react"; |
| 6 | import { HeroAddToAgentClickEvent } from "./_stub-events"; |
| 7 | import { TrackedLink } from "./_stub-tracked-link"; |
| 8 | import { cn } from "@/lib/utils"; |
| 9 | |
| 10 | // ─── Types & Constants ─────────────────────────────────────── |
| 11 | type ToolId = "search" | "connections" | "execute" | "sandbox"; |
| 12 | |
| 13 | type ChatItem = |
| 14 | | { type: "user"; content: string } |
| 15 | | { type: "assistant"; content: string } |
| 16 | | { type: "tool"; name: string }; |
| 17 | |
| 18 | // Each example is a sequence of timeline steps with its own chat items |
| 19 | interface ToolMatch { |
| 20 | name: string; |
| 21 | description: string; |
| 22 | appSlug: string; |
| 23 | highlighted?: boolean; |
| 24 | } |
| 25 | |
| 26 | interface SearchResult { |
| 27 | /** App slug to highlight in the scanning grid */ |
| 28 | highlightSlug: string; |
| 29 | highlightName: string; |
| 30 | /** Query that was searched */ |
| 31 | query: string; |
| 32 | /** Tools found by the search */ |
| 33 | tools: ToolMatch[]; |
| 34 | /** Execution plan steps */ |
| 35 | plan: string[]; |
| 36 | /** Warnings / warnings */ |
| 37 | pitfalls: string[]; |
| 38 | } |
| 39 | |
| 40 | interface SandboxInstance { |
| 41 | task: string; |
| 42 | code: string; |
| 43 | result: string; |
| 44 | } |
| 45 | |
| 46 | interface ExecuteResult { |
| 47 | tool: string; |
| 48 | params: { key: string; value: string }[]; |
| 49 | status: string; |
| 50 | } |
| 51 | |
| 52 | interface Example { |
| 53 | chatItems: ChatItem[]; |
| 54 | searchResult: SearchResult; |
| 55 | sandboxInstances: SandboxInstance[]; |
| 56 | executeResult: ExecuteResult; |
| 57 | timeline: { |
| 58 | items: number[]; |
| 59 | activeTools: ToolId[]; |
| 60 | thinking: boolean; |
| 61 | delay: number; |
| 62 | }[]; |
| 63 | } |
| 64 | |
| 65 | const EXAMPLES: Example[] = [ |
| 66 | { |
| 67 | chatItems: [ |
| 68 | // 0 |
| 69 | { |
| 70 | type: "user", |
| 71 | content: |
| 72 | "Summarize everything important from Slack in the last 48 hours and send a digest to #daily-digest", |
| 73 | }, |
| 74 | // 1 |
| 75 | { type: "tool", name: "COMPOSIO SEARCH TOOLS" }, |
| 76 | // 2 |
| 77 | { type: "tool", name: "COMPOSIO WORKBENCH" }, |
| 78 | // 3 |
| 79 | { |
| 80 | type: "assistant", |
| 81 | content: |
| 82 | "Processed 2,480 messages across 12 channels in workbench. Classified by urgency — 3 critical, 12 important.", |
| 83 | }, |
| 84 | // 4 |
| 85 | { type: "tool", name: "COMPOSIO EXECUTE TOOL" }, |
| 86 | // 5 |
| 87 | { |
| 88 | type: "assistant", |
| 89 | content: |
| 90 | "Here's your 48-hour Slack digest. 3 critical items need your attention today.", |
| 91 | }, |
| 92 | ], |
| 93 | searchResult: { |
| 94 | highlightSlug: "slack", |
| 95 | highlightName: "Slack", |
| 96 | query: "fetch slack messages and summarize", |
| 97 | tools: [ |
| 98 | { |
| 99 | name: "SLACK_FETCH_MESSAGES", |
| 100 | description: "Fetch messages from a Slack channel", |
| 101 | appSlug: "slack", |
| 102 | highlighted: true, |
| 103 | }, |
| 104 | { |
| 105 | name: "SLACK_LIST_CHANNELS", |
| 106 | description: "List all channels in a workspace", |
| 107 | appSlug: "slack", |
| 108 | highlighted: true, |
| 109 | }, |
| 110 | { |
| 111 | name: "SLACK_GET_THREAD", |
| 112 | description: "Get replies in a message thread", |
| 113 | appSlug: "slack", |
| 114 | }, |
| 115 | ], |
| 116 | plan: [ |
| 117 | "List all channels", |
| 118 | "Fetch messages from last 48h", |
| 119 | "Classify and summarize in workbench", |
| 120 | ], |
| 121 | pitfalls: [ |
| 122 | "Large output auto-saved to file if >40k chars", |
| 123 | "Rate limit: 50 req/min", |
| 124 | ], |
| 125 | }, |
| 126 | sandboxInstances: [ |
| 127 | { |
| 128 | task: "Fetch & process messages", |
| 129 | code: "channels = run_composio_tool(\n 'SLACK_LIST_CHANNELS'\n)\nfor ch in channels:\n msgs = run_composio_tool(\n 'SLACK_FETCH_MESSAGES',\n channel=ch['id'],\n limit=500\n )\n smart_file_extract(msgs,\n out=f'/tmp/{ch[\"name\"]}.json'\n )", |
| 130 | result: "2,480 msgs across 12 channels", |
| 131 | }, |
| 132 | { |
| 133 | task: "Classify & summarize", |
| 134 | code: "files = glob('/tmp/*.json')\nall_msgs = []\nfor f in files:\n all_msgs += json.load(open(f))\n\nranked = invoke_llm(\n f'Classify {len(all_msgs)} messages'\n ' by urgency: P0, P1, P2'\n)\nsummary = invoke_llm(\n f'Summarize the {len(ranked[\"P0\"])}'\n ' critical items concisely'\n)", |
| 135 | result: "3 critical, 12 important → 1.2k chars", |
| 136 | }, |
| 137 | ], |
| 138 | executeResult: { |
| 139 | tool: "SLACK_SEND_MESSAGE", |
| 140 | params: [ |
| 141 | { key: "channel", value: "#daily-digest" }, |
| 142 | { key: "text", value: "summary (1,240 chars)" }, |
| 143 | ], |
| 144 | status: "200 OK · message sent", |
| 145 | }, |
| 146 | timeline: [ |
| 147 | { items: [0], activeTools: [], thinking: false, delay: 950 }, |
| 148 | { items: [0], activeTools: [], thinking: true, delay: 650 }, |
| 149 | { |
| 150 | items: [0, 1], |
| 151 | activeTools: ["search", "connections"], |
| 152 | thinking: false, |
| 153 | delay: 2800, |
| 154 | }, |
| 155 | { |
| 156 | items: [0, 1, 2], |
| 157 | activeTools: ["sandbox"], |
| 158 | thinking: false, |
| 159 | delay: 3200, |
| 160 | }, |
| 161 | { items: [0, 1, 2, 3], activeTools: [], thinking: false, delay: 1200 }, |
| 162 | { |
| 163 | items: [0, 1, 2, 3, 4], |
| 164 | activeTools: ["execute"], |
| 165 | thinking: false, |
| 166 | delay: 1600, |
| 167 | }, |
| 168 | { |
| 169 | items: [0, 1, 2, 3, 4, 5], |
| 170 | activeTools: [], |
| 171 | thinking: false, |
| 172 | delay: 2400, |
| 173 | }, |
| 174 | ], |
| 175 | }, |
| 176 | { |
| 177 | chatItems: [ |
| 178 | // 0 |
| 179 | { |
| 180 | type: "user", |
| 181 | content: |
| 182 | "Download all 250 SVGs from our Figma file and upload them to Google Drive", |
| 183 | }, |
| 184 | // 1 |
| 185 | { type: "tool", name: "COMPOSIO SEARCH TOOLS" }, |
| 186 | // 2 |
| 187 | { type: "tool", name: "COMPOSIO WORKBENCH" }, |
| 188 | // 3 |
| 189 | { |
| 190 | type: "assistant", |
| 191 | content: |
| 192 | "Exported 250 SVGs from Figma in 5 batches and uploaded all files to Drive/assets/icons.", |
| 193 | }, |
| 194 | // 4 |
| 195 | { type: "tool", name: "COMPOSIO EXECUTE TOOL" }, |
| 196 | // 5 |
| 197 | { |
| 198 | type: "assistant", |
| 199 | content: "Done! All 250 SVGs are in your Google Drive. No failures.", |
| 200 | }, |
| 201 | ], |
| 202 | searchResult: { |
| 203 | highlightSlug: "figma", |
| 204 | highlightName: "Figma", |
| 205 | query: "export figma assets and upload to drive", |
| 206 | tools: [ |
| 207 | { |
| 208 | name: "FIGMA_GET_FILE_NODES", |
| 209 | description: "Get nodes from a Figma file", |
| 210 | appSlug: "figma", |
| 211 | highlighted: true, |
| 212 | }, |
| 213 | { |
| 214 | name: "FIGMA_EXPORT_ASSETS", |
| 215 | description: "Export assets as SVG/PNG from Figma", |
| 216 | appSlug: "figma", |
| 217 | highlighted: true, |
| 218 | }, |
| 219 | { |
| 220 | name: "GOOGLEDRIVE_UPLOAD_FILE", |
| 221 | description: "Upload a file to Google Drive", |
| 222 | appSlug: "googledrive", |
| 223 | highlighted: true, |
| 224 | }, |
| 225 | ], |
| 226 | plan: [ |
| 227 | "List all component nodes", |
| 228 | "Batch export as SVG", |
| 229 | "Upload to Drive folder", |
| 230 | ], |
| 231 | pitfalls: [ |
| 232 | "Figma API rate limit: 30 req/min", |
| 233 | "Max 10MB per file upload", |
| 234 | ], |
| 235 | }, |
| 236 | sandboxInstances: [ |
| 237 | { |
| 238 | task: "Export Figma assets", |
| 239 | code: "nodes = run_composio_tool(\n 'FIGMA_GET_FILE_NODES',\n file_key=file_key\n)\nsvgs = []\nfor batch in chunks(nodes, 50):\n result = run_composio_tool(\n 'FIGMA_EXPORT_ASSETS',\n ids=[n['id'] for n in batch],\n format='svg'\n )\n svgs.extend(result['files'])", |
| 240 | result: "250 SVGs exported", |
| 241 | }, |
| 242 | { |
| 243 | task: "Upload to Drive", |
| 244 | code: "folder = run_composio_tool(\n 'GDRIVE_CREATE_FOLDER',\n name='assets/icons'\n)\nfor i, svg in enumerate(svgs):\n upload_local_file(\n svg,\n destination=f'{folder}/{i}.svg'\n )\n if i % 50 == 0:\n print(f'{i}/250 uploaded')", |
| 245 | result: "250/250 uploaded to Drive", |
| 246 | }, |
| 247 | ], |
| 248 | executeResult: { |
| 249 | tool: "GOOGLEDRIVE_SHARE_FOLDER", |
| 250 | params: [ |
| 251 | { key: "folder", value: "assets/icons" }, |
| 252 | { key: "files", value: "250 SVGs" }, |
| 253 | ], |
| 254 | status: "200 OK · folder shared", |
| 255 | }, |
| 256 | timeline: [ |
| 257 | { items: [0], activeTools: [], thinking: false, delay: 950 }, |
| 258 | { items: [0], activeTools: [], thinking: true, delay: 650 }, |
| 259 | { |
| 260 | items: [0, 1], |
| 261 | activeTools: ["search", "connections"], |
| 262 | thinking: false, |
| 263 | delay: 2800, |
| 264 | }, |
| 265 | { |
| 266 | items: [0, 1, 2], |
| 267 | activeTools: ["sandbox"], |
| 268 | thinking: false, |
| 269 | delay: 3200, |
| 270 | }, |
| 271 | { items: [0, 1, 2, 3], activeTools: [], thinking: false, delay: 1200 }, |
| 272 | { |
| 273 | items: [0, 1, 2, 3, 4], |
| 274 | activeTools: ["execute"], |
| 275 | thinking: false, |
| 276 | delay: 1600, |
| 277 | }, |
| 278 | { |
| 279 | items: [0, 1, 2, 3, 4, 5], |
| 280 | activeTools: [], |
| 281 | thinking: false, |
| 282 | delay: 2400, |
| 283 | }, |
| 284 | ], |
| 285 | }, |
| 286 | { |
| 287 | chatItems: [ |
| 288 | // 0 |
| 289 | { |
| 290 | type: "user", |
| 291 | content: |
| 292 | "Triage all open Sentry errors and create Linear issues for P0s", |
| 293 | }, |
| 294 | // 1 |
| 295 | { type: "tool", name: "COMPOSIO SEARCH TOOLS" }, |
| 296 | // 2 |
| 297 | { type: "tool", name: "COMPOSIO WORKBENCH" }, |
| 298 | // 3 |
| 299 | { |
| 300 | type: "assistant", |
| 301 | content: |
| 302 | "Triaged 47 errors in workbench. 5 classified as P0 — created Linear issues LIN-482 through LIN-486 with stack traces.", |
| 303 | }, |
| 304 | // 4 |
| 305 | { type: "tool", name: "COMPOSIO EXECUTE TOOL" }, |
| 306 | // 5 |
| 307 | { |
| 308 | type: "assistant", |
| 309 | content: |
| 310 | "All done. 5 P0 issues created in Linear with full stack traces attached.", |
| 311 | }, |
| 312 | ], |
| 313 | searchResult: { |
| 314 | highlightSlug: "sentry", |
| 315 | highlightName: "Sentry", |
| 316 | query: "list sentry errors and create linear issues", |
| 317 | tools: [ |
| 318 | { |
| 319 | name: "SENTRY_LIST_ISSUES", |
| 320 | description: "List unresolved issues in a project", |
| 321 | appSlug: "sentry", |
| 322 | highlighted: true, |
| 323 | }, |
| 324 | { |
| 325 | name: "SENTRY_GET_EVENT", |
| 326 | description: "Get error event details and stack trace", |
| 327 | appSlug: "sentry", |
| 328 | highlighted: true, |
| 329 | }, |
| 330 | { |
| 331 | name: "LINEAR_CREATE_ISSUE", |
| 332 | description: "Create a new issue in a Linear team", |
| 333 | appSlug: "linear", |
| 334 | highlighted: true, |
| 335 | }, |
| 336 | ], |
| 337 | plan: [ |
| 338 | "Fetch all open Sentry issues", |
| 339 | "Classify severity in workbench", |
| 340 | "Create Linear issues for P0s", |
| 341 | ], |
| 342 | pitfalls: [ |
| 343 | "Sentry project slug required", |
| 344 | "Linear team ID must be configured", |
| 345 | ], |
| 346 | }, |
| 347 | sandboxInstances: [ |
| 348 | { |
| 349 | task: "Fetch & classify errors", |
| 350 | code: "issues = run_composio_tool(\n 'SENTRY_LIST_ISSUES',\n project='api-prod',\n status='unresolved'\n)\nfor issue in issues:\n issue['trace'] = run_composio_tool(\n 'SENTRY_GET_EVENT',\n issue_id=issue['id']\n )\nranked = invoke_llm(\n f'Classify these {len(issues)} errors.'\n ' Return P0/P1/P2 with reasoning.'\n)", |
| 351 | result: "47 errors → 5 P0, 12 P1, 30 P2", |
| 352 | }, |
| 353 | { |
| 354 | task: "Create Linear issues", |
| 355 | code: "p0s = ranked['P0']\nfor error in p0s:\n issue = run_composio_tool(\n 'LINEAR_CREATE_ISSUE',\n title=error['title'],\n team_id='ENG',\n priority=1,\n description=error['trace']\n )\n upload_local_file(\n error['stacktrace'],\n issue_id=issue['id']\n )", |
| 356 | result: "5 issues created: LIN-482 → LIN-486", |
| 357 | }, |
| 358 | ], |
| 359 | executeResult: { |
| 360 | tool: "LINEAR_CREATE_ISSUE", |
| 361 | params: [ |
| 362 | { key: "team", value: "ENG" }, |
| 363 | { key: "issues", value: "LIN-482 → LIN-486" }, |
| 364 | { key: "priority", value: "P0 (urgent)" }, |
| 365 | ], |
| 366 | status: "200 OK · 5 issues created", |
| 367 | }, |
| 368 | timeline: [ |
| 369 | { items: [0], activeTools: [], thinking: false, delay: 950 }, |
| 370 | { items: [0], activeTools: [], thinking: true, delay: 650 }, |
| 371 | { |
| 372 | items: [0, 1], |
| 373 | activeTools: ["search", "connections"], |
| 374 | thinking: false, |
| 375 | delay: 2800, |
| 376 | }, |
| 377 | { |
| 378 | items: [0, 1, 2], |
| 379 | activeTools: ["sandbox"], |
| 380 | thinking: false, |
| 381 | delay: 3200, |
| 382 | }, |
| 383 | { items: [0, 1, 2, 3], activeTools: [], thinking: false, delay: 1200 }, |
| 384 | { |
| 385 | items: [0, 1, 2, 3, 4], |
| 386 | activeTools: ["execute"], |
| 387 | thinking: false, |
| 388 | delay: 1600, |
| 389 | }, |
| 390 | { |
| 391 | items: [0, 1, 2, 3, 4, 5], |
| 392 | activeTools: [], |
| 393 | thinking: false, |
| 394 | delay: 2400, |
| 395 | }, |
| 396 | ], |
| 397 | }, |
| 398 | ]; |
| 399 | |
| 400 | // ─── Chat UI Skins ────────────────────────────────────────── |
| 401 | interface ChatSkin { |
| 402 | name: string; |
| 403 | subtitle?: string; |
| 404 | logo: string; |
| 405 | /** Outer card bg */ |
| 406 | bg: string; |
| 407 | /** Header bg */ |
| 408 | headerBg: string; |
| 409 | /** User message bubble bg */ |
| 410 | userBubbleBg: string; |
| 411 | /** Input area bg */ |
| 412 | inputBg: string; |
| 413 | /** Text colors */ |
| 414 | textColor: string; |
| 415 | textMuted: string; |
| 416 | /** Border color when active */ |
| 417 | borderActive: string; |
| 418 | /** Border color when inactive */ |
| 419 | borderInactive: string; |
| 420 | /** Accent / send button color */ |
| 421 | accent: string; |
| 422 | /** Model label shown in input */ |
| 423 | modelLabel: string; |
| 424 | /** Thinking indicator: image or dots */ |
| 425 | thinkingType: "logo" | "dots"; |
| 426 | /** Invert logo color */ |
| 427 | invertLogo?: boolean; |
| 428 | /** Custom shimmer color (defaults to white) */ |
| 429 | shimmerColor?: string; |
| 430 | /** Rounded corners */ |
| 431 | radius: string; |
| 432 | /** Agent config metadata */ |
| 433 | agentConfig: { |
| 434 | agent: string; |
| 435 | provider: string; |
| 436 | model: string; |
| 437 | framework?: string; |
| 438 | }; |
| 439 | } |
| 440 | |
| 441 | // Theme-aware chat skins — surface / text / border colors reference |
| 442 | // `--hero-*` CSS vars defined in app/global.css so the chat mocks read |
| 443 | // well in both light and dark docs themes. The per-agent identity is |
| 444 | // expressed through the accent color and chat header logo / radius. |
| 445 | const CHAT_SKINS: ChatSkin[] = [ |
| 446 | { |
| 447 | name: "Claude", |
| 448 | subtitle: "Cowork", |
| 449 | logo: "/images/clients/claude.svg", |
| 450 | bg: "var(--hero-surface)", |
| 451 | headerBg: "transparent", |
| 452 | userBubbleBg: "var(--hero-bubble)", |
| 453 | inputBg: "var(--hero-surface-2)", |
| 454 | textColor: "var(--hero-text)", |
| 455 | textMuted: "var(--hero-text-muted)", |
| 456 | borderActive: "var(--hero-border)", |
| 457 | borderInactive: "var(--hero-border-soft)", |
| 458 | accent: "#c4956a", |
| 459 | modelLabel: "Sonnet 4.6", |
| 460 | thinkingType: "logo", |
| 461 | radius: "20px", |
| 462 | shimmerColor: "var(--hero-shimmer)", |
| 463 | agentConfig: { |
| 464 | agent: "Claude Cowork", |
| 465 | provider: "Anthropic", |
| 466 | model: "claude-sonnet-4-6", |
| 467 | framework: "LangChain", |
| 468 | }, |
| 469 | }, |
| 470 | { |
| 471 | name: "ChatGPT", |
| 472 | subtitle: "Codex", |
| 473 | logo: "/images/clients/chatgpt.png", |
| 474 | invertLogo: false, |
| 475 | bg: "var(--hero-surface)", |
| 476 | headerBg: "transparent", |
| 477 | userBubbleBg: "var(--hero-bubble)", |
| 478 | inputBg: "var(--hero-surface-2)", |
| 479 | textColor: "var(--hero-text)", |
| 480 | textMuted: "var(--hero-text-muted)", |
| 481 | borderActive: "var(--hero-border)", |
| 482 | borderInactive: "var(--hero-border-soft)", |
| 483 | accent: "#10a37f", |
| 484 | modelLabel: "GPT-4.1", |
| 485 | thinkingType: "dots", |
| 486 | radius: "14px", |
| 487 | shimmerColor: "var(--hero-shimmer)", |
| 488 | agentConfig: { |
| 489 | agent: "ChatGPT Codex", |
| 490 | provider: "OpenAI", |
| 491 | model: "gpt-4.1", |
| 492 | framework: "CrewAI", |
| 493 | }, |
| 494 | }, |
| 495 | { |
| 496 | name: "Your AI Agent", |
| 497 | logo: "", |
| 498 | bg: "var(--hero-surface)", |
| 499 | headerBg: "transparent", |
| 500 | userBubbleBg: "var(--hero-bubble)", |
| 501 | inputBg: "var(--hero-surface-2)", |
| 502 | textColor: "var(--hero-text)", |
| 503 | textMuted: "var(--hero-text-muted)", |
| 504 | borderActive: "rgba(0,7,205,0.22)", |
| 505 | borderInactive: "rgba(0,7,205,0.08)", |
| 506 | accent: "#0007cd", |
| 507 | modelLabel: "llama-3.3-70b", |
| 508 | thinkingType: "dots", |
| 509 | radius: "20px", |
| 510 | shimmerColor: "var(--composio-brand)", |
| 511 | agentConfig: { |
| 512 | agent: "Your Awesome Agent", |
| 513 | provider: "Custom", |
| 514 | model: "llama-3.3-70b", |
| 515 | }, |
| 516 | }, |
| 517 | ]; |
| 518 | |
| 519 | // ─── Layout constants ─────────────────────────────────────── |
| 520 | // All widths as % of container so they scale below 1240px |
| 521 | const CARD_W_SIDE_PCT = "27.4%"; // 340/1240 |
| 522 | const CHAT_W_PCT = "35.5%"; // 440/1240 |
| 523 | |
| 524 | const TOOL_IDS: ("search" | "connections" | "execute")[] = [ |
| 525 | "search", |
| 526 | "connections", |
| 527 | "execute", |
| 528 | ]; |
| 529 | |
| 530 | const POSITIONS: Record< |
| 531 | "search" | "connections" | "execute", |
| 532 | { x: number; y: number } |
| 533 | > = { |
| 534 | search: { x: 13.7, y: 7 }, |
| 535 | connections: { x: 86.3, y: 7 }, |
| 536 | execute: { x: 13.7, y: 70 }, |
| 537 | }; |
| 538 | |
| 539 | // Sandbox now lives inside the demo zone — right column under |
| 540 | // Connections, in the slot previously occupied by Execute + AgentConfig. |
| 541 | const SANDBOX_POSITION = { x: 86.3, y: 38 }; |
| 542 | |
| 543 | const CHAT = { x: 50, y: 7 }; |
| 544 | |
| 545 | const CONNECTOR_LINES: Record<"search" | "connections" | "execute", string> = { |
| 546 | search: "M 400 180 L 340 180", |
| 547 | connections: "M 840 140 L 900 140", |
| 548 | execute: "M 400 494 L 340 494", |
| 549 | }; |
| 550 | |
| 551 | const SANDBOX_CONNECTOR = "M 840 355 L 900 355"; |
| 552 | |
| 553 | // ─── App logos from Composio CDN ───────────────────────────── |
| 554 | const APP_LOGOS: { slug: string; name: string }[] = [ |
| 555 | { slug: "slack", name: "Slack" }, |
| 556 | { slug: "gmail", name: "Gmail" }, |
| 557 | { slug: "notion", name: "Notion" }, |
| 558 | { slug: "jira", name: "Jira" }, |
| 559 | { slug: "linear", name: "Linear" }, |
| 560 | { slug: "asana", name: "Asana" }, |
| 561 | { slug: "trello", name: "Trello" }, |
| 562 | { slug: "zoom", name: "Zoom" }, |
| 563 | { slug: "discord", name: "Discord" }, |
| 564 | { slug: "figma", name: "Figma" }, |
| 565 | { slug: "dropbox", name: "Dropbox" }, |
| 566 | { slug: "stripe", name: "Stripe" }, |
| 567 | { slug: "shopify", name: "Shopify" }, |
| 568 | { slug: "hubspot", name: "HubSpot" }, |
| 569 | { slug: "salesforce", name: "Salesforce" }, |
| 570 | { slug: "zendesk", name: "Zendesk" }, |
| 571 | { slug: "github", name: "GitHub" }, |
| 572 | { slug: "gitlab", name: "GitLab" }, |
| 573 | { slug: "bitbucket", name: "Bitbucket" }, |
| 574 | { slug: "googlecalendar", name: "Calendar" }, |
| 575 | { slug: "googledrive", name: "Drive" }, |
| 576 | { slug: "googlesheets", name: "Sheets" }, |
| 577 | { slug: "outlook", name: "Outlook" }, |
| 578 | { slug: "microsoft_teams", name: "Teams" }, |
| 579 | { slug: "airtable", name: "Airtable" }, |
| 580 | { slug: "clickup", name: "ClickUp" }, |
| 581 | { slug: "todoist", name: "Todoist" }, |
| 582 | { slug: "intercom", name: "Intercom" }, |
| 583 | { slug: "mailchimp", name: "Mailchimp" }, |
| 584 | { slug: "twitter", name: "X" }, |
| 585 | { slug: "instagram", name: "Instagram" }, |
| 586 | { slug: "youtube", name: "YouTube" }, |
| 587 | { slug: "linkedin", name: "LinkedIn" }, |
| 588 | { slug: "telegram", name: "Telegram" }, |
| 589 | { slug: "whatsapp", name: "WhatsApp" }, |
| 590 | { slug: "snowflake", name: "Snowflake" }, |
| 591 | { slug: "pagerduty", name: "PagerDuty" }, |
| 592 | { slug: "datadog", name: "Datadog" }, |
| 593 | { slug: "sentry", name: "Sentry" }, |
| 594 | { slug: "confluence", name: "Confluence" }, |
| 595 | { slug: "freshdesk", name: "Freshdesk" }, |
| 596 | { slug: "calendly", name: "Calendly" }, |
| 597 | { slug: "typeform", name: "Typeform" }, |
| 598 | { slug: "mixpanel", name: "Mixpanel" }, |
| 599 | { slug: "segment", name: "Segment" }, |
| 600 | { slug: "pipedrive", name: "Pipedrive" }, |
| 601 | { slug: "coda", name: "Coda" }, |
| 602 | { slug: "brevo", name: "Brevo" }, |
| 603 | { slug: "supabase", name: "Supabase" }, |
| 604 | { slug: "vercel", name: "Vercel" }, |
| 605 | { slug: "webflow", name: "Webflow" }, |
| 606 | { slug: "monday", name: "Monday" }, |
| 607 | { slug: "freshbooks", name: "FreshBooks" }, |
| 608 | { slug: "elevenlabs", name: "ElevenLabs" }, |
| 609 | { slug: "spotify", name: "Spotify" }, |
| 610 | ]; |
| 611 | |
| 612 | const LOGO_CDN = "https://logos.composio.dev/api"; |
| 613 | |
| 614 | const AUTH_TYPES: Record<string, string> = { |
| 615 | slack: "OAuth 2.0", |
| 616 | figma: "OAuth 2.0", |
| 617 | googledrive: "OAuth 2.0", |
| 618 | sentry: "API Key", |
| 619 | linear: "OAuth 2.0", |
| 620 | github: "OAuth 2.0", |
| 621 | gmail: "OAuth 2.0", |
| 622 | }; |
| 623 | |
| 624 | // ─── Main Component ───────────────────────────────────────── |
| 625 | export function HeroSection() { |
| 626 | const [isMobile, setIsMobile] = useState<boolean | null>(null); |
| 627 | const [visibleItems, setVisibleItems] = useState< |
| 628 | (ChatItem & { id: number })[] |
| 629 | >([]); |
| 630 | const heroRef = useRef<HTMLElement>(null); |
| 631 | |
| 632 | // (Landing site mutates the navbar background on scroll; in docs we |
| 633 | // don't own the navbar so that effect is removed.) |
| 634 | const [thinking, setThinking] = useState(false); |
| 635 | const [activatedTools, setActivatedTools] = useState<Set<ToolId>>(new Set()); |
| 636 | const [completedTools, setCompletedTools] = useState<Set<ToolId>>(new Set()); |
| 637 | const nextId = useRef(0); |
| 638 | const demoRef = useRef<HTMLDivElement>(null); |
| 639 | const [demoInView, setDemoInView] = useState(false); |
| 640 | |
| 641 | // Current example & step |
| 642 | const [exampleIdx, setExampleIdx] = useState(0); |
| 643 | const [step, setStep] = useState(-1); |
| 644 | |
| 645 | useEffect(() => { |
| 646 | setIsMobile(window.innerWidth < 768); |
| 647 | }, []); |
| 648 | |
| 649 | // Track whether demo section is visible — pause animation when scrolled away |
| 650 | useEffect(() => { |
| 651 | if (!demoRef.current) return; |
| 652 | const observer = new IntersectionObserver( |
| 653 | ([entry]) => { |
| 654 | setDemoInView(!!entry?.isIntersecting); |
| 655 | }, |
| 656 | { rootMargin: "0px 0px -20% 0px" }, |
| 657 | ); |
| 658 | observer.observe(demoRef.current); |
| 659 | return () => observer.disconnect(); |
| 660 | }, []); |
| 661 | |
| 662 | useEffect(() => { |
| 663 | const example = EXAMPLES[exampleIdx % EXAMPLES.length]!; |
| 664 | const timeline = example.timeline; |
| 665 | |
| 666 | if (step === -1) { |
| 667 | setActivatedTools(new Set()); |
| 668 | setCompletedTools(new Set()); |
| 669 | setThinking(false); |
| 670 | // Show first user message immediately, wait for scroll to start |
| 671 | const firstStep = timeline[0]!; |
| 672 | setVisibleItems( |
| 673 | firstStep.items.map((i) => ({ |
| 674 | ...example.chatItems[i]!, |
| 675 | id: exampleIdx * 100 + i, |
| 676 | })), |
| 677 | ); |
| 678 | if (!demoInView) return; |
| 679 | const delay = exampleIdx === 0 ? 100 : 650; |
| 680 | const t = setTimeout(() => setStep(0), delay); |
| 681 | return () => clearTimeout(t); |
| 682 | } |
| 683 | |
| 684 | // Pause timeline when demo is not in view |
| 685 | if (!demoInView) return; |
| 686 | |
| 687 | if (step >= timeline.length) { |
| 688 | setExampleIdx((i) => i + 1); |
| 689 | setStep(-1); |
| 690 | return; |
| 691 | } |
| 692 | |
| 693 | const current = timeline[step]!; |
| 694 | |
| 695 | // Show this step's chat items (only from current example) |
| 696 | setVisibleItems( |
| 697 | current.items.map((i) => ({ |
| 698 | ...example.chatItems[i]!, |
| 699 | id: exampleIdx * 100 + i, |
| 700 | })), |
| 701 | ); |
| 702 | |
| 703 | setThinking(current.thinking); |
| 704 | |
| 705 | if (current.activeTools.length > 0) { |
| 706 | // Sequence per beat: |
| 707 | // (1) chat tool item fades in (~250ms — framer transition) |
| 708 | // (2) connector line draws from chat to card (~250ms — see |
| 709 | // `delay: 0.25, duration: 0.25` on the motion.path below) |
| 710 | // (3) card lights up at the end of the draw (~500ms total). |
| 711 | const drawDuration = 500; |
| 712 | const t2 = setTimeout(() => { |
| 713 | setActivatedTools(new Set(current.activeTools)); |
| 714 | }, drawDuration); |
| 715 | const t = setTimeout(() => { |
| 716 | setCompletedTools((prev) => new Set([...prev, ...current.activeTools])); |
| 717 | setStep((s) => s + 1); |
| 718 | }, current.delay); |
| 719 | return () => { |
| 720 | clearTimeout(t); |
| 721 | clearTimeout(t2); |
| 722 | }; |
| 723 | } |
| 724 | |
| 725 | setActivatedTools(new Set()); |
| 726 | const t = setTimeout(() => setStep((s) => s + 1), current.delay); |
| 727 | return () => clearTimeout(t); |
| 728 | }, [step, exampleIdx, demoInView]); |
| 729 | |
| 730 | const activeSet = new Set( |
| 731 | step >= 0 && |
| 732 | step < (EXAMPLES[exampleIdx % EXAMPLES.length]?.timeline.length ?? 0) |
| 733 | ? (EXAMPLES[exampleIdx % EXAMPLES.length]?.timeline[step]?.activeTools ?? |
| 734 | []) |
| 735 | : [], |
| 736 | ); |
| 737 | |
| 738 | return ( |
| 739 | <section className="relative flex flex-col items-center overflow-hidden"> |
| 740 | {/* Headline */} |
| 741 | <div |
| 742 | className="relative mx-auto flex w-full max-w-[1240px] flex-col items-center justify-center gap-6 px-4 pt-2 pb-2 md:gap-8 md:pt-4 md:pb-3" |
| 743 | ref={heroRef as React.RefObject<HTMLDivElement>} |
| 744 | > |
| 745 | {/* Text content */} |
| 746 | <div className="relative z-10 flex flex-col items-center gap-2 px-1 md:gap-3"> |
| 747 | <h1 className="text-center font-sans text-4xl text-fd-foreground leading-[1.05] tracking-[-0.02em] md:whitespace-nowrap md:text-5xl md:leading-[0.95] lg:text-[56px]"> |
| 748 | Your agent decides |
| 749 | <br className="md:hidden" /> what to do. |
| 750 | </h1> |
| 751 | <p className="text-center font-sans text-4xl text-fd-foreground leading-[1.05] tracking-[-0.02em] md:whitespace-nowrap md:text-5xl md:leading-[0.95] lg:text-[56px]"> |
| 752 | We handle the rest. |
| 753 | </p> |
| 754 | </div> |
| 755 | |
| 756 | {/* Primary CTA */} |
| 757 | <div className="relative z-10"> |
| 758 | <TrackedLink |
| 759 | baseUrl="/docs/quickstart" |
| 760 | className="inline-flex items-center bg-[var(--composio-brand)] px-5 py-3 font-mono text-sm uppercase leading-normal tracking-[-0.28px] no-underline transition-colors hover:bg-[#0006a8]" |
| 761 | event={HeroAddToAgentClickEvent} |
| 762 | placement="hero-get-started" |
| 763 | style={{ color: "#ffffff" }} |
| 764 | > |
| 765 | <span style={{ color: "#ffffff" }}>Get Started</span> |
| 766 | </TrackedLink> |
| 767 | </div> |
| 768 | </div> |
| 769 | |
| 770 | {/* Demo — desktop only */} |
| 771 | <div |
| 772 | className="relative mt-6 hidden h-[620px] w-full max-w-[1240px] lg:block" |
| 773 | ref={demoRef} |
| 774 | > |
| 775 | {/* Connector lines — paths use `currentColor`, so they pick up |
| 776 | this brand-blue tone in both light and dark mode. */} |
| 777 | <svg |
| 778 | className="pointer-events-none absolute inset-0 z-[1] h-full w-full text-[var(--composio-brand)]" |
| 779 | fill="none" |
| 780 | preserveAspectRatio="none" |
| 781 | viewBox="0 0 1240 620" |
| 782 | > |
| 783 | {TOOL_IDS.map((id) => { |
| 784 | const line = CONNECTOR_LINES[id]; |
| 785 | const isActive = activeSet.has(id); |
| 786 | return ( |
| 787 | <g key={id}> |
| 788 | <AnimatePresence> |
| 789 | {isActive && ( |
| 790 | <> |
| 791 | <motion.path |
| 792 | animate={{ pathLength: 1 }} |
| 793 | d={line} |
| 794 | exit={{ opacity: 0, transition: { duration: 0.3 } }} |
| 795 | initial={{ pathLength: 0 }} |
| 796 | key={`${id}-glow`} |
| 797 | pathLength={1} |
| 798 | stroke="currentColor" |
| 799 | strokeLinecap="round" |
| 800 | strokeOpacity={0.15} |
| 801 | strokeWidth={8} |
| 802 | transition={{ duration: 0.25, delay: 0.25, ease: "easeOut" }} |
| 803 | /> |
| 804 | <motion.path |
| 805 | animate={{ pathLength: 1 }} |
| 806 | d={line} |
| 807 | exit={{ opacity: 0, transition: { duration: 0.3 } }} |
| 808 | initial={{ pathLength: 0 }} |
| 809 | key={`${id}-line`} |
| 810 | pathLength={1} |
| 811 | stroke="currentColor" |
| 812 | strokeLinecap="round" |
| 813 | strokeWidth={2} |
| 814 | transition={{ duration: 0.25, delay: 0.25, ease: "easeOut" }} |
| 815 | /> |
| 816 | </> |
| 817 | )} |
| 818 | </AnimatePresence> |
| 819 | </g> |
| 820 | ); |
| 821 | })} |
| 822 | {/* Sandbox connector — vertical from chat bottom to container edge */} |
| 823 | <g> |
| 824 | <AnimatePresence> |
| 825 | {activeSet.has("sandbox") && ( |
| 826 | <> |
| 827 | <motion.path |
| 828 | animate={{ pathLength: 1 }} |
| 829 | d={SANDBOX_CONNECTOR} |
| 830 | exit={{ opacity: 0, transition: { duration: 0.3 } }} |
| 831 | initial={{ pathLength: 0 }} |
| 832 | key="sandbox-glow" |
| 833 | pathLength={1} |
| 834 | stroke="currentColor" |
| 835 | strokeLinecap="round" |
| 836 | strokeOpacity={0.15} |
| 837 | strokeWidth={8} |
| 838 | transition={{ duration: 0.25, delay: 0.25, ease: "easeOut" }} |
| 839 | /> |
| 840 | <motion.path |
| 841 | animate={{ pathLength: 1 }} |
| 842 | d={SANDBOX_CONNECTOR} |
| 843 | exit={{ opacity: 0, transition: { duration: 0.3 } }} |
| 844 | initial={{ pathLength: 0 }} |
| 845 | key="sandbox-line" |
| 846 | pathLength={1} |
| 847 | stroke="currentColor" |
| 848 | strokeLinecap="round" |
| 849 | strokeWidth={2} |
| 850 | transition={{ duration: 0.25, delay: 0.25, ease: "easeOut" }} |
| 851 | /> |
| 852 | </> |
| 853 | )} |
| 854 | </AnimatePresence> |
| 855 | </g> |
| 856 | </svg> |
| 857 | |
| 858 | {/* Chat window — skinned per example with sweep transition */} |
| 859 | <AnimatePresence mode="wait"> |
| 860 | {(() => { |
| 861 | const skin = CHAT_SKINS[exampleIdx % CHAT_SKINS.length]!; |
| 862 | return ( |
| 863 | <motion.div |
| 864 | animate={{ |
| 865 | opacity: demoInView ? 1 : 0.5, |
| 866 | scale: demoInView ? 1 : 0.98, |
| 867 | x: "-50%", |
| 868 | y: 0, |
| 869 | }} |
| 870 | className="absolute z-10 flex flex-col overflow-hidden border shadow-2xl" |
| 871 | exit={{ |
| 872 | opacity: 0, |
| 873 | y: -40, |
| 874 | transition: { duration: 0.35, ease: "easeIn" }, |
| 875 | }} |
| 876 | initial={ |
| 877 | exampleIdx === 0 && !demoInView |
| 878 | ? { opacity: 0.5, scale: 0.98, x: "-50%", y: 0 } |
| 879 | : { opacity: 0, x: "-50%", y: 40 } |
| 880 | } |
| 881 | key={`chat-skin-${exampleIdx}`} |
| 882 | style={{ |
| 883 | width: CHAT_W_PCT, |
| 884 | left: `${CHAT.x}%`, |
| 885 | top: `${CHAT.y}%`, |
| 886 | backgroundColor: skin.bg, |
| 887 | borderColor: demoInView |
| 888 | ? skin.borderActive |
| 889 | : skin.borderInactive, |
| 890 | borderRadius: skin.radius, |
| 891 | }} |
| 892 | transition={{ duration: 0.45, ease: [0.4, 0, 0.2, 1] }} |
| 893 | > |
| 894 | {/* Header */} |
| 895 | <div |
| 896 | className="flex items-center justify-center gap-2 px-5 py-3" |
| 897 | style={{ backgroundColor: skin.headerBg }} |
| 898 | > |
| 899 | {skin.logo ? ( |
| 900 | <img |
| 901 | alt={skin.name} |
| 902 | className={cn("h-4 w-4", skin.invertLogo && "invert")} |
| 903 | src={skin.logo} |
| 904 | /> |
| 905 | ) : ( |
| 906 | <div |
| 907 | className="flex h-4 w-4 items-center justify-center rounded-full" |
| 908 | style={{ backgroundColor: skin.accent }} |
| 909 | > |
| 910 | <svg |
| 911 | fill="none" |
| 912 | height="10" |
| 913 | viewBox="0 0 10 10" |
| 914 | width="10" |
| 915 | > |
| 916 | <path |
| 917 | d="M2.5 3.5L5 6L7.5 3.5" |
| 918 | stroke="white" |
| 919 | strokeLinecap="round" |
| 920 | strokeLinejoin="round" |
| 921 | strokeWidth="1.5" |
| 922 | /> |
| 923 | </svg> |
| 924 | </div> |
| 925 | )} |
| 926 | <span |
| 927 | className="font-medium text-[13px]" |
| 928 | style={{ color: skin.textColor }} |
| 929 | > |
| 930 | {skin.name} |
| 931 | {skin.subtitle && ( |
| 932 | <> |
| 933 | {" "} |
| 934 | <span |
| 935 | className="font-normal" |
| 936 | style={{ color: skin.textMuted }} |
| 937 | > |
| 938 | {skin.subtitle} |
| 939 | </span> |
| 940 | </> |
| 941 | )} |
| 942 | </span> |
| 943 | </div> |
| 944 | |
| 945 | {/* Chat items */} |
| 946 | <ChatScroller items={visibleItems}> |
| 947 | <AnimatePresence mode="popLayout"> |
| 948 | {visibleItems.map((item, idx) => { |
| 949 | const isLatest = idx === visibleItems.length - 1; |
| 950 | return ( |
| 951 | <motion.div |
| 952 | animate={{ |
| 953 | opacity: isLatest ? 1 : 0.35, |
| 954 | y: 0, |
| 955 | scale: 1, |
| 956 | }} |
| 957 | exit={{ opacity: 0, scale: 0.95 }} |
| 958 | initial={{ opacity: 0, y: 8, scale: 0.97 }} |
| 959 | key={item.id} |
| 960 | layout |
| 961 | transition={{ duration: 0.25 }} |
| 962 | > |
| 963 | {item.type === "user" && ( |
| 964 | <div className="flex justify-end"> |
| 965 | <div |
| 966 | className="max-w-[85%] px-4 py-2.5 text-[14px] leading-relaxed" |
| 967 | style={{ |
| 968 | backgroundColor: skin.userBubbleBg, |
| 969 | color: skin.textColor, |
| 970 | borderRadius: `calc(${skin.radius} - 4px)`, |
| 971 | }} |
| 972 | > |
| 973 | {item.content} |
| 974 | </div> |
| 975 | </div> |
| 976 | )} |
| 977 | {item.type === "tool" && ( |
| 978 | <div |
| 979 | className={cn( |
| 980 | "inline-flex items-center gap-1 text-[12px] leading-none tracking-wide", |
| 981 | isLatest && "hero-tool-shimmer", |
| 982 | )} |
| 983 | style={ |
| 984 | isLatest ? undefined : { color: skin.textMuted } |
| 985 | } |
| 986 | > |
| 987 | <span className="font-medium uppercase"> |
| 988 | {item.name} |
| 989 | </span> |
| 990 | <ChevronRight className="h-3 w-3" /> |
| 991 | </div> |
| 992 | )} |
| 993 | {item.type === "assistant" && ( |
| 994 | <div |
| 995 | className="text-[15px] leading-relaxed" |
| 996 | style={{ color: skin.textColor }} |
| 997 | > |
| 998 | {item.content} |
| 999 | </div> |
| 1000 | )} |
| 1001 | </motion.div> |
| 1002 | ); |
| 1003 | })} |
| 1004 | {thinking && ( |
| 1005 | <motion.div |
| 1006 | animate={{ opacity: 1, y: 0 }} |
| 1007 | exit={{ opacity: 0 }} |
| 1008 | initial={{ opacity: 0, y: 8 }} |
| 1009 | key="dots" |
| 1010 | layout |
| 1011 | > |
| 1012 | {skin.thinkingType === "logo" && skin.logo ? ( |
| 1013 | <img |
| 1014 | alt={skin.name} |
| 1015 | className="h-6 w-6" |
| 1016 | src={skin.logo} |
| 1017 | /> |
| 1018 | ) : ( |
| 1019 | <div className="flex gap-1"> |
| 1020 | {[0, 1, 2].map((i) => ( |
| 1021 | <div |
| 1022 | className="h-1.5 w-1.5 animate-[pulse-dot_1.4s_ease-in-out_infinite] rounded-full" |
| 1023 | key={i} |
| 1024 | style={{ |
| 1025 | backgroundColor: skin.accent, |
| 1026 | animationDelay: `${i * 0.2}s`, |
| 1027 | }} |
| 1028 | /> |
| 1029 | ))} |
| 1030 | </div> |
| 1031 | )} |
| 1032 | </motion.div> |
| 1033 | )} |
| 1034 | </AnimatePresence> |
| 1035 | </ChatScroller> |
| 1036 | |
| 1037 | {/* Input */} |
| 1038 | <div className="px-3 pb-3"> |
| 1039 | <div |
| 1040 | className="flex flex-col gap-2 px-4 pt-3 pb-2.5" |
| 1041 | style={{ |
| 1042 | backgroundColor: skin.inputBg, |
| 1043 | borderRadius: `calc(${skin.radius} - 4px)`, |
| 1044 | }} |
| 1045 | > |
| 1046 | <span |
| 1047 | className="text-[14px]" |
| 1048 | style={{ color: skin.textMuted }} |
| 1049 | > |
| 1050 | Reply... |
| 1051 | </span> |
| 1052 | <div className="flex items-center justify-between"> |
| 1053 | <svg |
| 1054 | fill="none" |
| 1055 | height="18" |
| 1056 | style={{ color: skin.textMuted }} |
| 1057 | viewBox="0 0 18 18" |
| 1058 | width="18" |
| 1059 | > |
| 1060 | <path |
| 1061 | d="M9 1.5v15M1.5 9h15" |
| 1062 | stroke="currentColor" |
| 1063 | strokeLinecap="round" |
| 1064 | strokeWidth="1.5" |
| 1065 | /> |
| 1066 | </svg> |
| 1067 | <div className="flex items-center gap-2.5"> |
| 1068 | <span |
| 1069 | className="inline-flex items-center text-[12px] leading-none" |
| 1070 | style={{ color: skin.textMuted }} |
| 1071 | > |
| 1072 | {skin.modelLabel} |
| 1073 | <ChevronRight className="ml-0.5 h-3 w-3" /> |
| 1074 | </span> |
| 1075 | <div |
| 1076 | className="flex h-7 w-7 items-center justify-center rounded-full" |
| 1077 | style={{ backgroundColor: skin.accent }} |
| 1078 | > |
| 1079 | <svg |
| 1080 | fill="none" |
| 1081 | height="14" |
| 1082 | viewBox="0 0 14 14" |
| 1083 | width="14" |
| 1084 | > |
| 1085 | <path |
| 1086 | d="M7 12V2M7 2L3 6M7 2l4 4" |
| 1087 | stroke="white" |
| 1088 | strokeLinecap="round" |
| 1089 | strokeLinejoin="round" |
| 1090 | strokeWidth="1.5" |
| 1091 | /> |
| 1092 | </svg> |
| 1093 | </div> |
| 1094 | </div> |
| 1095 | </div> |
| 1096 | </div> |
| 1097 | </div> |
| 1098 | </motion.div> |
| 1099 | ); |
| 1100 | })()} |
| 1101 | </AnimatePresence> |
| 1102 | |
| 1103 | {/* Tool cards */} |
| 1104 | <SearchCard |
| 1105 | active={activatedTools.has("search")} |
| 1106 | completed={completedTools.has("search")} |
| 1107 | searchResult={EXAMPLES[exampleIdx % EXAMPLES.length]!.searchResult} |
| 1108 | /> |
| 1109 | <ConnectionsCard |
| 1110 | active={activatedTools.has("connections")} |
| 1111 | completed={completedTools.has("connections")} |
| 1112 | connectedApps={EXAMPLES[ |
| 1113 | exampleIdx % EXAMPLES.length |
| 1114 | ]!.searchResult.tools.map((t) => ({ |
| 1115 | name: t.appSlug.charAt(0).toUpperCase() + t.appSlug.slice(1), |
| 1116 | slug: t.appSlug, |
| 1117 | }))} |
| 1118 | /> |
| 1119 | <ExecuteCard |
| 1120 | active={activatedTools.has("execute")} |
| 1121 | completed={completedTools.has("execute")} |
| 1122 | executeResult={EXAMPLES[exampleIdx % EXAMPLES.length]!.executeResult} |
| 1123 | /> |
| 1124 | |
| 1125 | {/* Sandbox card — now positioned inside the demo zone, right |
| 1126 | column under Connections (the slot previously occupied by |
| 1127 | Execute + AgentConfig). */} |
| 1128 | <SandboxCard |
| 1129 | active={activatedTools.has("sandbox")} |
| 1130 | completed={completedTools.has("sandbox")} |
| 1131 | instances={EXAMPLES[exampleIdx % EXAMPLES.length]!.sandboxInstances} |
| 1132 | /> |
| 1133 | </div> |
| 1134 | </section> |
| 1135 | ); |
| 1136 | } |
| 1137 | |
| 1138 | // ─── Chat Scroller ─────────────────────────────────────────── |
| 1139 | function ChatScroller({ |
| 1140 | items, |
| 1141 | children, |
| 1142 | }: { |
| 1143 | items: unknown[]; |
| 1144 | children: React.ReactNode; |
| 1145 | }) { |
| 1146 | const ref = useRef<HTMLDivElement>(null); |
| 1147 | |
| 1148 | useEffect(() => { |
| 1149 | if (ref.current) { |
| 1150 | ref.current.scrollTo({ |
| 1151 | top: ref.current.scrollHeight, |
| 1152 | behavior: "smooth", |
| 1153 | }); |
| 1154 | } |
| 1155 | }, [items.length]); |
| 1156 | |
| 1157 | return ( |
| 1158 | <div |
| 1159 | className="scrollbar-none flex h-[380px] flex-col gap-4 overflow-y-auto px-5 pt-5 pb-3" |
| 1160 | ref={ref} |
| 1161 | style={{ scrollbarWidth: "none" }} |
| 1162 | > |
| 1163 | {children} |
| 1164 | </div> |
| 1165 | ); |
| 1166 | } |
| 1167 | |
| 1168 | // ─── Shared Card Wrapper ───────────────────────────────────── |
| 1169 | function Card({ |
| 1170 | id, |
| 1171 | active, |
| 1172 | className, |
| 1173 | children, |
| 1174 | }: { |
| 1175 | id: "search" | "connections" | "execute"; |
| 1176 | active: boolean; |
| 1177 | className?: string; |
| 1178 | children: React.ReactNode; |
| 1179 | }) { |
| 1180 | const p = POSITIONS[id]; |
| 1181 | return ( |
| 1182 | <motion.div |
| 1183 | animate={{ opacity: active ? 1 : 0.7 }} |
| 1184 | className={cn( |
| 1185 | "absolute z-[5] flex flex-col overflow-hidden border border-fd-border bg-fd-card p-4 font-mono text-xs transition-shadow duration-300", |
| 1186 | active && "hero-card-shadow", |
| 1187 | className, |
| 1188 | )} |
| 1189 | style={{ |
| 1190 | width: CARD_W_SIDE_PCT, |
| 1191 | left: `${p.x}%`, |
| 1192 | top: `${p.y}%`, |
| 1193 | transform: "translateX(-50%)", |
| 1194 | }} |
| 1195 | transition={{ duration: 0.5 }} |
| 1196 | > |
| 1197 | {children} |
| 1198 | </motion.div> |
| 1199 | ); |
| 1200 | } |
| 1201 | |
| 1202 | // ─── Search Card ───────────────────────────────────────────── |
| 1203 | function SearchCard({ |
| 1204 | active, |
| 1205 | completed, |
| 1206 | searchResult, |
| 1207 | }: { |
| 1208 | active: boolean; |
| 1209 | completed: boolean; |
| 1210 | searchResult: SearchResult; |
| 1211 | }) { |
| 1212 | const [phase, setPhase] = useState< |
| 1213 | "idle" | "scanning" | "highlighted" | "found" |
| 1214 | >("idle"); |
| 1215 | const prevActive = useRef(false); |
| 1216 | const prevSlug = useRef(searchResult.highlightSlug); |
| 1217 | |
| 1218 | // Reset phase when example changes (new search result) |
| 1219 | useEffect(() => { |
| 1220 | if (prevSlug.current !== searchResult.highlightSlug) { |
| 1221 | setPhase("idle"); |
| 1222 | prevActive.current = false; |
| 1223 | prevSlug.current = searchResult.highlightSlug; |
| 1224 | } |
| 1225 | }, [searchResult.highlightSlug]); |
| 1226 | |
| 1227 | useEffect(() => { |
| 1228 | if (active && !prevActive.current) { |
| 1229 | setPhase("scanning"); |
| 1230 | const t1 = setTimeout(() => setPhase("highlighted"), 950); |
| 1231 | const t2 = setTimeout(() => setPhase("found"), 1750); |
| 1232 | prevActive.current = active; |
| 1233 | return () => { |
| 1234 | clearTimeout(t1); |
| 1235 | clearTimeout(t2); |
| 1236 | }; |
| 1237 | } |
| 1238 | if (!active && prevActive.current && !completed) { |
| 1239 | setPhase("idle"); |
| 1240 | } |
| 1241 | prevActive.current = active; |
| 1242 | }, [active, completed]); |
| 1243 | |
| 1244 | const showScanning = |
| 1245 | !completed && (phase === "scanning" || phase === "highlighted"); |
| 1246 | const showResults = phase === "found" || completed; |
| 1247 | const showIdle = phase === "idle" && !completed; |
| 1248 | |
| 1249 | return ( |
| 1250 | <Card active={active} className="h-[360px]" id="search"> |
| 1251 | <div className="mb-1 text-[10px] text-fd-foreground/30 uppercase tracking-wider"> |
| 1252 | composio_search_tools |
| 1253 | </div> |
| 1254 | |
| 1255 | <div className="min-h-0 flex-1"> |
| 1256 | {/* Idle state — show stale/sample results */} |
| 1257 | {showIdle && ( |
| 1258 | <div className="flex h-full flex-col font-sans"> |
| 1259 | <div className="mb-2 flex items-center gap-2 border border-fd-border px-2.5 py-1.5"> |
| 1260 | <svg |
| 1261 | className="shrink-0 text-fd-foreground/20" |
| 1262 | fill="none" |
| 1263 | height="12" |
| 1264 | viewBox="0 0 12 12" |
| 1265 | width="12" |
| 1266 | > |
| 1267 | <circle |
| 1268 | cx="5.25" |
| 1269 | cy="5.25" |
| 1270 | r="3.75" |
| 1271 | stroke="currentColor" |
| 1272 | strokeWidth="1" |
| 1273 | /> |
| 1274 | <path |
| 1275 | d="M8 8l2.5 2.5" |
| 1276 | stroke="currentColor" |
| 1277 | strokeLinecap="round" |
| 1278 | strokeWidth="1" |
| 1279 | /> |
| 1280 | </svg> |
| 1281 | <span className="truncate font-mono text-[10px] text-fd-foreground/25"> |
| 1282 | search tools... |
| 1283 | </span> |
| 1284 | </div> |
| 1285 | <div className="flex flex-col gap-1.5"> |
| 1286 | {[ |
| 1287 | { |
| 1288 | name: "GMAIL_SEND_EMAIL", |
| 1289 | desc: "Send an email via Gmail", |
| 1290 | slug: "gmail", |
| 1291 | }, |
| 1292 | { |
| 1293 | name: "SLACK_LIST_CHANNELS", |
| 1294 | desc: "List channels in workspace", |
| 1295 | slug: "slack", |
| 1296 | }, |
| 1297 | { |
| 1298 | name: "GITHUB_CREATE_PR", |
| 1299 | desc: "Create a pull request", |
| 1300 | slug: "github", |
| 1301 | }, |
| 1302 | ].map((t) => ( |
| 1303 | <div |
| 1304 | className="flex items-start gap-2.5 border border-fd-border px-2.5 py-2" |
| 1305 | key={t.name} |
| 1306 | > |
| 1307 | <img |
| 1308 | alt={t.slug} |
| 1309 | className="mt-0.5 h-[14px] w-[14px] shrink-0 object-contain opacity-30" |
| 1310 | draggable={false} |
| 1311 | src={`${LOGO_CDN}/${t.slug}`} |
| 1312 | /> |
| 1313 | <div className="min-w-0 flex-1"> |
| 1314 | <div className="truncate font-mono text-[11px] text-fd-foreground/25 leading-tight"> |
| 1315 | {t.name} |
| 1316 | </div> |
| 1317 | <div className="mt-0.5 truncate text-[10px] text-fd-foreground/15 leading-tight"> |
| 1318 | {t.desc} |
| 1319 | </div> |
| 1320 | </div> |
| 1321 | </div> |
| 1322 | ))} |
| 1323 | </div> |
| 1324 | <div className="mt-3 grid grid-cols-2 gap-2"> |
| 1325 | <div> |
| 1326 | <div className="mb-1 font-mono text-[9px] text-fd-foreground/15 uppercase tracking-wider"> |
| 1327 | Plan |
| 1328 | </div> |
| 1329 | <div className="flex flex-col gap-0.5"> |
| 1330 | <div className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/15 leading-tight"> |
| 1331 | <span>1</span> |
| 1332 | <span>Authenticate user</span> |
| 1333 | </div> |
| 1334 | <div className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/15 leading-tight"> |
| 1335 | <span>2</span> |
| 1336 | <span>Execute tool call</span> |
| 1337 | </div> |
| 1338 | </div> |
| 1339 | </div> |
| 1340 | <div> |
| 1341 | <div className="mb-1 font-mono text-[9px] text-fd-foreground/15 uppercase tracking-wider"> |
| 1342 | Warnings |
| 1343 | </div> |
| 1344 | <div className="flex flex-col gap-0.5"> |
| 1345 | <div className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/15 leading-tight"> |
| 1346 | <span>!</span> |
| 1347 | <span>Check rate limits</span> |
| 1348 | </div> |
| 1349 | <div className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/15 leading-tight"> |
| 1350 | <span>!</span> |
| 1351 | <span>Verify permissions</span> |
| 1352 | </div> |
| 1353 | </div> |
| 1354 | </div> |
| 1355 | </div> |
| 1356 | </div> |
| 1357 | )} |
| 1358 | |
| 1359 | {/* Search bar — visible during scanning and highlighted */} |
| 1360 | {showScanning && ( |
| 1361 | <motion.div |
| 1362 | animate={{ opacity: 1, y: 0 }} |
| 1363 | className="mb-2 flex items-center gap-2 border border-fd-border bg-fd-accent/30 px-2.5 py-1.5" |
| 1364 | initial={{ opacity: 0, y: 4 }} |
| 1365 | transition={{ duration: 0.25 }} |
| 1366 | > |
| 1367 | <svg |
| 1368 | className="shrink-0 text-fd-foreground/20" |
| 1369 | fill="none" |
| 1370 | height="12" |
| 1371 | viewBox="0 0 12 12" |
| 1372 | width="12" |
| 1373 | > |
| 1374 | <circle |
| 1375 | cx="5.25" |
| 1376 | cy="5.25" |
| 1377 | r="3.75" |
| 1378 | stroke="currentColor" |
| 1379 | strokeWidth="1" |
| 1380 | /> |
| 1381 | <path |
| 1382 | d="M8 8l2.5 2.5" |
| 1383 | stroke="currentColor" |
| 1384 | strokeLinecap="round" |
| 1385 | strokeWidth="1" |
| 1386 | /> |
| 1387 | </svg> |
| 1388 | <span className="truncate font-mono text-[10px] text-fd-foreground/35"> |
| 1389 | {searchResult.query} |
| 1390 | </span> |
| 1391 | {phase === "scanning" && ( |
| 1392 | <span className="ml-auto shrink-0 animate-pulse font-mono text-[9px] text-fd-foreground/20"> |
| 1393 | searching... |
| 1394 | </span> |
| 1395 | )} |
| 1396 | {phase === "highlighted" && ( |
| 1397 | <span className="ml-auto shrink-0 font-mono text-[9px] text-fd-foreground/20"> |
| 1398 | {searchResult.tools.length} found |
| 1399 | </span> |
| 1400 | )} |
| 1401 | </motion.div> |
| 1402 | )} |
| 1403 | |
| 1404 | {showScanning && ( |
| 1405 | <div |
| 1406 | className="relative h-full overflow-hidden" |
| 1407 | style={{ |
| 1408 | maskImage: |
| 1409 | "linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%)", |
| 1410 | WebkitMaskImage: |
| 1411 | "linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%)", |
| 1412 | }} |
| 1413 | > |
| 1414 | <AnimatePresence mode="wait"> |
| 1415 | {phase === "scanning" ? ( |
| 1416 | <motion.div |
| 1417 | animate={{ |
| 1418 | y: [0, `-${Math.ceil(APP_LOGOS.length / 7) * 31.5}px`], |
| 1419 | }} |
| 1420 | className="grid grid-cols-7 gap-1.5" |
| 1421 | exit={{ opacity: 0 }} |
| 1422 | key="scanning" |
| 1423 | transition={{ |
| 1424 | duration: 1.2, |
| 1425 | ease: "linear", |
| 1426 | repeat: Number.POSITIVE_INFINITY, |
| 1427 | }} |
| 1428 | > |
| 1429 | {[...APP_LOGOS, ...APP_LOGOS].map((app, i) => ( |
| 1430 | <div |
| 1431 | className="flex h-[30px] w-[30px] items-center justify-center" |
| 1432 | key={`${app.slug}-${i < APP_LOGOS.length ? "a" : "b"}`} |
| 1433 | > |
| 1434 | <img |
| 1435 | alt={app.name} |
| 1436 | className="h-[18px] w-[18px] object-contain" |
| 1437 | draggable={false} |
| 1438 | src={`${LOGO_CDN}/${app.slug}`} |
| 1439 | /> |
| 1440 | </div> |
| 1441 | ))} |
| 1442 | </motion.div> |
| 1443 | ) : ( |
| 1444 | <motion.div |
| 1445 | animate={{ opacity: 1 }} |
| 1446 | className="grid grid-cols-7 gap-1.5" |
| 1447 | initial={{ opacity: 0 }} |
| 1448 | key="highlighted" |
| 1449 | transition={{ duration: 0.4 }} |
| 1450 | > |
| 1451 | {APP_LOGOS.map((app) => { |
| 1452 | const isTarget = app.slug === searchResult.highlightSlug; |
| 1453 | const highlighted = phase === "highlighted" && isTarget; |
| 1454 | const dimmed = phase === "highlighted" && !isTarget; |
| 1455 | return ( |
| 1456 | <div |
| 1457 | className={cn( |
| 1458 | "flex h-[30px] w-[30px] items-center justify-center transition-all duration-500", |
| 1459 | highlighted |
| 1460 | ? "bg-[var(--composio-brand)]/10 ring-2 ring-[var(--composio-brand)]/45 ring-offset-0" |
| 1461 | : dimmed |
| 1462 | ? "opacity-20" |
| 1463 | : "", |
| 1464 | )} |
| 1465 | key={app.slug} |
| 1466 | > |
| 1467 | <img |
| 1468 | alt={app.name} |
| 1469 | className="h-[18px] w-[18px] object-contain" |
| 1470 | draggable={false} |
| 1471 | src={`${LOGO_CDN}/${app.slug}`} |
| 1472 | /> |
| 1473 | </div> |
| 1474 | ); |
| 1475 | })} |
| 1476 | </motion.div> |
| 1477 | )} |
| 1478 | </AnimatePresence> |
| 1479 | </div> |
| 1480 | )} |
| 1481 | |
| 1482 | {showResults && ( |
| 1483 | <motion.div |
| 1484 | animate={{ opacity: 1, y: 0 }} |
| 1485 | className="flex h-full flex-col" |
| 1486 | initial={{ opacity: 0, y: 6 }} |
| 1487 | transition={{ duration: 0.3 }} |
| 1488 | > |
| 1489 | {/* Search query bar */} |
| 1490 | <div className="mb-3 flex items-center gap-2 border border-fd-border bg-fd-accent/30 px-2.5 py-1.5"> |
| 1491 | <svg |
| 1492 | className="shrink-0 text-fd-foreground/20" |
| 1493 | fill="none" |
| 1494 | height="12" |
| 1495 | viewBox="0 0 12 12" |
| 1496 | width="12" |
| 1497 | > |
| 1498 | <circle |
| 1499 | cx="5.25" |
| 1500 | cy="5.25" |
| 1501 | r="3.75" |
| 1502 | stroke="currentColor" |
| 1503 | strokeWidth="1" |
| 1504 | /> |
| 1505 | <path |
| 1506 | d="M8 8l2.5 2.5" |
| 1507 | stroke="currentColor" |
| 1508 | strokeLinecap="round" |
| 1509 | strokeWidth="1" |
| 1510 | /> |
| 1511 | </svg> |
| 1512 | <span className="truncate font-mono text-[10px] text-fd-foreground/35"> |
| 1513 | {searchResult.query} |
| 1514 | </span> |
| 1515 | <span className="ml-auto shrink-0 font-mono text-[9px] text-fd-foreground/20"> |
| 1516 | {searchResult.tools.length} found |
| 1517 | </span> |
| 1518 | </div> |
| 1519 | |
| 1520 | {/* Tool results */} |
| 1521 | <div className="flex flex-col gap-1.5"> |
| 1522 | {searchResult.tools.map((tool) => ( |
| 1523 | <div |
| 1524 | className="flex items-start gap-2.5 border border-fd-border bg-fd-accent/30 px-2.5 py-2" |
| 1525 | key={tool.name} |
| 1526 | > |
| 1527 | <img |
| 1528 | alt={tool.appSlug} |
| 1529 | className="mt-0.5 h-[14px] w-[14px] shrink-0 object-contain" |
| 1530 | draggable={false} |
| 1531 | src={`${LOGO_CDN}/${tool.appSlug}`} |
| 1532 | /> |
| 1533 | <div className="min-w-0 flex-1"> |
| 1534 | <div className="truncate font-mono text-[11px] text-fd-foreground/40 leading-tight"> |
| 1535 | {tool.name} |
| 1536 | </div> |
| 1537 | <div className="mt-0.5 truncate text-[10px] text-fd-foreground/20 leading-tight"> |
| 1538 | {tool.description} |
| 1539 | </div> |
| 1540 | </div> |
| 1541 | {tool.highlighted && ( |
| 1542 | <span className="mt-0.5 shrink-0 bg-blue-500/20 px-1 py-px font-mono text-[8px] text-blue-400 uppercase tracking-wider"> |
| 1543 | match |
| 1544 | </span> |
| 1545 | )} |
| 1546 | </div> |
| 1547 | ))} |
| 1548 | </div> |
| 1549 | |
| 1550 | {/* Plan & Warnings */} |
| 1551 | <div className="mt-3 grid grid-cols-2 gap-2"> |
| 1552 | <div> |
| 1553 | <div className="mb-1 font-mono text-[9px] text-fd-foreground/25 uppercase tracking-wider"> |
| 1554 | Plan |
| 1555 | </div> |
| 1556 | <div className="flex flex-col gap-0.5"> |
| 1557 | {searchResult.plan.map((step, i) => ( |
| 1558 | <div |
| 1559 | className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/35 leading-tight" |
| 1560 | key={step} |
| 1561 | > |
| 1562 | <span className="text-fd-foreground/15">{i + 1}</span> |
| 1563 | <span>{step}</span> |
| 1564 | </div> |
| 1565 | ))} |
| 1566 | </div> |
| 1567 | </div> |
| 1568 | <div> |
| 1569 | <div className="mb-1 font-mono text-[9px] text-amber-500/40 uppercase tracking-wider"> |
| 1570 | Warnings |
| 1571 | </div> |
| 1572 | <div className="flex flex-col gap-0.5"> |
| 1573 | {searchResult.pitfalls.map((pitfall) => ( |
| 1574 | <div |
| 1575 | className="flex items-start gap-1.5 font-mono text-[10px] text-fd-foreground/25 leading-tight" |
| 1576 | key={pitfall} |
| 1577 | > |
| 1578 | <span className="text-amber-500/40">!</span> |
| 1579 | <span>{pitfall}</span> |
| 1580 | </div> |
| 1581 | ))} |
| 1582 | </div> |
| 1583 | </div> |
| 1584 | </div> |
| 1585 | </motion.div> |
| 1586 | )} |
| 1587 | </div> |
| 1588 | </Card> |
| 1589 | ); |
| 1590 | } |
| 1591 | |
| 1592 | // ─── Other Tool Cards ──────────────────────────────────────── |
| 1593 | function ConnectionsCard({ |
| 1594 | active, |
| 1595 | completed, |
| 1596 | connectedApps, |
| 1597 | }: { |
| 1598 | active: boolean; |
| 1599 | completed: boolean; |
| 1600 | connectedApps: { name: string; slug: string }[]; |
| 1601 | }) { |
| 1602 | // Deduplicate apps by slug |
| 1603 | const uniqueApps = connectedApps.filter( |
| 1604 | (app, i, arr) => arr.findIndex((a) => a.slug === app.slug) === i, |
| 1605 | ); |
| 1606 | |
| 1607 | return ( |
| 1608 | <Card active={active} className="h-[174px]" id="connections"> |
| 1609 | <div className="mb-4 text-[10px] text-fd-foreground/30 uppercase tracking-wider"> |
| 1610 | composio_manage_connections |
| 1611 | </div> |
| 1612 | <div className="mb-4 text-[10px] text-fd-foreground/20">USER_ID: usr_9x2kLm7</div> |
| 1613 | <div className="flex flex-1 flex-col gap-2"> |
| 1614 | {uniqueApps.map((app) => { |
| 1615 | const isConnected = active || completed; |
| 1616 | const authType = AUTH_TYPES[app.slug] ?? "OAuth 2.0"; |
| 1617 | return ( |
| 1618 | <div |
| 1619 | className={cn( |
| 1620 | "flex items-center justify-between border px-2.5 py-2", |
| 1621 | isConnected |
| 1622 | ? "border-fd-border bg-fd-accent/30" |
| 1623 | : "border-fd-border", |
| 1624 | )} |
| 1625 | key={app.slug} |
| 1626 | > |
| 1627 | <div className="flex items-center gap-2"> |
| 1628 | <img |
| 1629 | alt={app.name} |
| 1630 | className={cn( |
| 1631 | "h-[14px] w-[14px] object-contain", |
| 1632 | isConnected ? "opacity-80" : "opacity-20", |
| 1633 | )} |
| 1634 | draggable={false} |
| 1635 | src={`${LOGO_CDN}/${app.slug}`} |
| 1636 | /> |
| 1637 | <div className="flex flex-col"> |
| 1638 | <span |
| 1639 | className={cn( |
| 1640 | "text-[11px] leading-tight", |
| 1641 | isConnected ? "text-fd-foreground/50" : "text-fd-foreground/20", |
| 1642 | )} |
| 1643 | > |
| 1644 | {app.name} |
| 1645 | </span> |
| 1646 | <span |
| 1647 | className={cn( |
| 1648 | "text-[9px] leading-tight", |
| 1649 | isConnected ? "text-fd-foreground/25" : "text-fd-foreground/10", |
| 1650 | )} |
| 1651 | > |
| 1652 | {authType} |
| 1653 | </span> |
| 1654 | </div> |
| 1655 | </div> |
| 1656 | <span |
| 1657 | className={cn( |
| 1658 | "flex items-center gap-1.5 text-[10px]", |
| 1659 | isConnected ? "text-green-400" : "text-fd-foreground/20", |
| 1660 | )} |
| 1661 | > |
| 1662 | <span |
| 1663 | className={cn( |
| 1664 | "inline-block h-1.5 w-1.5 rounded-full", |
| 1665 | isConnected ? "bg-green-400" : "bg-fd-accent", |
| 1666 | isConnected && "animate-pulse", |
| 1667 | )} |
| 1668 | /> |
| 1669 | {isConnected ? "Connected" : "—"} |
| 1670 | </span> |
| 1671 | </div> |
| 1672 | ); |
| 1673 | })} |
| 1674 | </div> |
| 1675 | </Card> |
| 1676 | ); |
| 1677 | } |
| 1678 | |
| 1679 | function ExecuteCard({ |
| 1680 | active, |
| 1681 | completed, |
| 1682 | executeResult, |
| 1683 | }: { |
| 1684 | active: boolean; |
| 1685 | completed: boolean; |
| 1686 | executeResult: ExecuteResult; |
| 1687 | }) { |
| 1688 | return ( |
| 1689 | <Card active={active} className="h-[174px]" id="execute"> |
| 1690 | <div className="mb-3 flex items-center justify-between"> |
| 1691 | <div className="text-[10px] text-fd-foreground/30 uppercase tracking-wider"> |
| 1692 | composio_execute_tool |
| 1693 | </div> |
| 1694 | <div className="text-[10px] text-fd-foreground/20"> |
| 1695 | SESSION: {active || completed ? "sx-7k2m" : "—"} |
| 1696 | </div> |
| 1697 | </div> |
| 1698 | {active || completed ? ( |
| 1699 | <div className="flex flex-1 flex-col gap-2"> |
| 1700 | <div className="flex items-center gap-2 border border-fd-border bg-fd-accent/30 px-2.5 py-2"> |
| 1701 | <img |
| 1702 | alt={executeResult.tool.split("_")[0]?.toLowerCase()} |
| 1703 | className="h-[14px] w-[14px] shrink-0 object-contain opacity-80" |
| 1704 | draggable={false} |
| 1705 | src={`${LOGO_CDN}/${executeResult.tool.split("_")[0]?.toLowerCase()}`} |
| 1706 | /> |
| 1707 | <span className="font-mono text-[11px] text-fd-foreground/50 leading-tight"> |
| 1708 | {executeResult.tool} |
| 1709 | </span> |
| 1710 | </div> |
| 1711 | <div className="flex flex-col gap-1 border border-fd-border px-2.5 py-2"> |
| 1712 | {executeResult.params.map((p) => ( |
| 1713 | <div |
| 1714 | className="flex items-center justify-between text-[10px]" |
| 1715 | key={p.key} |
| 1716 | > |
| 1717 | <span className="text-fd-foreground/25">{p.key}</span> |
| 1718 | <span className="text-fd-foreground/40">{p.value}</span> |
| 1719 | </div> |
| 1720 | ))} |
| 1721 | </div> |
| 1722 | <div className="flex items-center gap-1.5 text-[10px] text-green-400"> |
| 1723 | <Check className="h-3 w-3" /> |
| 1724 | <span>{executeResult.status}</span> |
| 1725 | </div> |
| 1726 | </div> |
| 1727 | ) : ( |
| 1728 | <div className="flex flex-1 flex-col gap-2"> |
| 1729 | <div className="flex items-center gap-2 border border-fd-border px-2.5 py-2"> |
| 1730 | <img |
| 1731 | alt="notion" |
| 1732 | className="h-[14px] w-[14px] shrink-0 object-contain opacity-20" |
| 1733 | draggable={false} |
| 1734 | src={`${LOGO_CDN}/notion`} |
| 1735 | /> |
| 1736 | <span className="font-mono text-[11px] text-fd-foreground/20 leading-tight"> |
| 1737 | NOTION_CREATE_PAGE |
| 1738 | </span> |
| 1739 | </div> |
| 1740 | <div className="flex flex-col gap-1 border border-fd-border px-2.5 py-2"> |
| 1741 | <div className="flex items-center justify-between text-[10px]"> |
| 1742 | <span className="text-fd-foreground/15">db</span> |
| 1743 | <span className="text-fd-foreground/20">Tasks</span> |
| 1744 | </div> |
| 1745 | <div className="flex items-center justify-between text-[10px]"> |
| 1746 | <span className="text-fd-foreground/15">title</span> |
| 1747 | <span className="text-fd-foreground/20">Q4 roadmap</span> |
| 1748 | </div> |
| 1749 | </div> |
| 1750 | <div className="flex items-center gap-1.5 text-[10px] text-fd-foreground/15"> |
| 1751 | <Check className="h-3 w-3" /> |
| 1752 | <span>200 OK · page created</span> |
| 1753 | </div> |
| 1754 | </div> |
| 1755 | )} |
| 1756 | </Card> |
| 1757 | ); |
| 1758 | } |
| 1759 | |
| 1760 | // Simple 2D noise for CPU lights |
| 1761 | function noise2d(x: number, y: number, t: number): number { |
| 1762 | const n = Math.sin(x * 12.9898 + y * 78.233 + t * 43.758) * 43758.5453; |
| 1763 | return n - Math.floor(n); |
| 1764 | } |
| 1765 | |
| 1766 | // CPU activity lights — noise-driven blinking blue squares |
| 1767 | function CpuLights({ active, cols = 6 }: { active: boolean; cols?: number }) { |
| 1768 | const COLS = cols; |
| 1769 | const ROWS = 2; |
| 1770 | const [tick, setTick] = useState(0); |
| 1771 | |
| 1772 | useEffect(() => { |
| 1773 | if (!active) return; |
| 1774 | const id = setInterval(() => setTick((t) => t + 1), 80); |
| 1775 | return () => clearInterval(id); |
| 1776 | }, [active]); |
| 1777 | |
| 1778 | return ( |
| 1779 | <div |
| 1780 | className="inline-grid gap-[2px]" |
| 1781 | style={{ |
| 1782 | gridTemplateColumns: `repeat(${COLS}, 5px)`, |
| 1783 | gridTemplateRows: `repeat(${ROWS}, 5px)`, |
| 1784 | }} |
| 1785 | > |
| 1786 | {Array.from({ length: ROWS * COLS }).map((_, idx) => { |
| 1787 | const col = idx % COLS; |
| 1788 | const row = Math.floor(idx / COLS); |
| 1789 | const wave = Math.sin((col * 0.5 - tick * 0.15) * Math.PI) * 0.5 + 0.5; |
| 1790 | const n = noise2d(col * 0.6, row * 0.7, tick * 0.08) * 0.4 + wave * 0.6; |
| 1791 | const lit = active && n > 0.25; |
| 1792 | const brightness = n > 0.7 ? 2 : n > 0.5 ? 1 : 0; |
| 1793 | return ( |
| 1794 | <div |
| 1795 | className={cn( |
| 1796 | "h-[5px] w-[5px] transition-colors duration-300", |
| 1797 | !lit && "bg-fd-accent/30", |
| 1798 | lit && brightness === 2 && "bg-blue-400", |
| 1799 | lit && brightness === 1 && "bg-blue-500/70", |
| 1800 | lit && brightness === 0 && "bg-blue-600/40", |
| 1801 | )} |
| 1802 | key={idx} |
| 1803 | /> |
| 1804 | ); |
| 1805 | })} |
| 1806 | </div> |
| 1807 | ); |
| 1808 | } |
| 1809 | |
| 1810 | |
| 1811 | function SandboxCard({ |
| 1812 | active, |
| 1813 | completed, |
| 1814 | instances, |
| 1815 | }: { |
| 1816 | active: boolean; |
| 1817 | completed: boolean; |
| 1818 | instances: SandboxInstance[]; |
| 1819 | }) { |
| 1820 | const [visibleCount, setVisibleCount] = useState(0); |
| 1821 | const prevActive = useRef(false); |
| 1822 | const prevInstances = useRef(instances); |
| 1823 | |
| 1824 | useEffect(() => { |
| 1825 | if (prevInstances.current !== instances) { |
| 1826 | setVisibleCount(0); |
| 1827 | prevActive.current = false; |
| 1828 | prevInstances.current = instances; |
| 1829 | } |
| 1830 | }, [instances]); |
| 1831 | |
| 1832 | useEffect(() => { |
| 1833 | if (active && !prevActive.current) { |
| 1834 | prevActive.current = true; |
| 1835 | // Show first instance immediately |
| 1836 | setVisibleCount(1); |
| 1837 | let count = 1; |
| 1838 | const interval = setInterval(() => { |
| 1839 | count++; |
| 1840 | setVisibleCount(count); |
| 1841 | if (count >= instances.length) { |
| 1842 | clearInterval(interval); |
| 1843 | } |
| 1844 | }, 1800); |
| 1845 | return () => clearInterval(interval); |
| 1846 | } |
| 1847 | if (!active && prevActive.current && !completed) { |
| 1848 | setVisibleCount(0); |
| 1849 | } |
| 1850 | prevActive.current = active; |
| 1851 | }, [active, completed, instances.length]); |
| 1852 | |
| 1853 | const visibleIdx = completed ? instances.length : visibleCount; |
| 1854 | |
| 1855 | return ( |
| 1856 | <motion.div |
| 1857 | animate={{ opacity: active || completed ? 1 : 0.7 }} |
| 1858 | className={cn( |
| 1859 | "absolute z-[5] flex flex-col overflow-hidden border border-fd-border bg-fd-card p-3 font-mono text-xs transition-shadow duration-300", |
| 1860 | active && "hero-card-shadow", |
| 1861 | )} |
| 1862 | style={{ |
| 1863 | width: CARD_W_SIDE_PCT, |
| 1864 | left: `${SANDBOX_POSITION.x}%`, |
| 1865 | top: `${SANDBOX_POSITION.y}%`, |
| 1866 | transform: "translateX(-50%)", |
| 1867 | height: "360px", |
| 1868 | }} |
| 1869 | transition={{ duration: 0.5 }} |
| 1870 | > |
| 1871 | {/* Header */} |
| 1872 | <div className="mb-2 flex items-center justify-between"> |
| 1873 | <div className="text-[10px] text-fd-foreground/30 uppercase tracking-wider"> |
| 1874 | composio_workbench |
| 1875 | </div> |
| 1876 | <div className="flex items-center gap-1.5 text-[9px] text-fd-foreground/20"> |
| 1877 | <span |
| 1878 | className={cn( |
| 1879 | "h-1.5 w-1.5 rounded-full", |
| 1880 | active ? "animate-pulse bg-green-400" : "bg-fd-accent", |
| 1881 | )} |
| 1882 | /> |
| 1883 | python 3.11 |
| 1884 | </div> |
| 1885 | </div> |
| 1886 | |
| 1887 | {/* Instances — stacked vertically inside the right-column sandbox slot */} |
| 1888 | <div className="flex min-h-0 flex-1 flex-col gap-2 overflow-hidden"> |
| 1889 | {instances.map((inst, i) => { |
| 1890 | const isActive = i < visibleIdx; |
| 1891 | const isDone = isActive && (completed || i < visibleIdx - 1); |
| 1892 | const isRunning = isActive && !isDone && active; |
| 1893 | |
| 1894 | return ( |
| 1895 | <div |
| 1896 | className={cn( |
| 1897 | "flex min-h-0 flex-1 flex-col border transition-all duration-300", |
| 1898 | isRunning |
| 1899 | ? "border-fd-border bg-fd-muted" |
| 1900 | : isActive |
| 1901 | ? "border-fd-border bg-fd-muted" |
| 1902 | : "border-fd-border border-dashed bg-transparent", |
| 1903 | )} |
| 1904 | key={i} |
| 1905 | > |
| 1906 | {/* Toolbar — compact single row: CPU lights + task name on |
| 1907 | the left, status on the right. `min-w-0` + `truncate` |
| 1908 | keeps long task/result strings on one line in the |
| 1909 | narrow right-column slot. */} |
| 1910 | <div className="flex items-center justify-between gap-2 border-fd-border border-b px-2 py-1.5"> |
| 1911 | {isActive ? ( |
| 1912 | <> |
| 1913 | <div className="flex min-w-0 items-center gap-1.5"> |
| 1914 | <CpuLights active={isRunning} cols={4} /> |
| 1915 | <span className="truncate text-[9px] text-fd-foreground/40 uppercase tracking-wider"> |
| 1916 | {inst.task} |
| 1917 | </span> |
| 1918 | </div> |
| 1919 | <span |
| 1920 | className={cn( |
| 1921 | "shrink-0 text-[8px] uppercase tracking-wider", |
| 1922 | isDone |
| 1923 | ? "text-[var(--composio-brand)]" |
| 1924 | : "text-fd-foreground/30", |
| 1925 | )} |
| 1926 | > |
| 1927 | {isDone ? "done" : isRunning ? "running" : ""} |
| 1928 | </span> |
| 1929 | </> |
| 1930 | ) : ( |
| 1931 | <> |
| 1932 | <div className="flex min-w-0 items-center gap-1.5"> |
| 1933 | <CpuLights active={false} cols={4} /> |
| 1934 | <span className="truncate text-[9px] text-fd-foreground/20 uppercase tracking-wider"> |
| 1935 | instance-{i} |
| 1936 | </span> |
| 1937 | </div> |
| 1938 | <span className="shrink-0 text-[8px] text-fd-foreground/20 uppercase tracking-wider"> |
| 1939 | idle |
| 1940 | </span> |
| 1941 | </> |
| 1942 | )} |
| 1943 | </div> |
| 1944 | {/* Code / placeholder — bottom-fade mask so long snippets |
| 1945 | feather out instead of getting clipped flat. */} |
| 1946 | <div |
| 1947 | className="relative min-h-0 flex-1 overflow-hidden px-2 py-1.5" |
| 1948 | style={{ |
| 1949 | maskImage: |
| 1950 | "linear-gradient(to bottom, black 0%, black 70%, transparent 100%)", |
| 1951 | WebkitMaskImage: |
| 1952 | "linear-gradient(to bottom, black 0%, black 70%, transparent 100%)", |
| 1953 | }} |
| 1954 | > |
| 1955 | <pre |
| 1956 | className={cn( |
| 1957 | "overflow-hidden font-mono text-[9px] leading-[1.5]", |
| 1958 | isActive |
| 1959 | ? "text-fd-foreground/55" |
| 1960 | : "text-fd-foreground/15", |
| 1961 | )} |
| 1962 | > |
| 1963 | {isActive |
| 1964 | ? inst.code |
| 1965 | : i === 0 |
| 1966 | ? `data = run_composio_tool( |
| 1967 | 'NOTION_QUERY_DB', |
| 1968 | database='Tasks' |
| 1969 | ) |
| 1970 | results = invoke_llm( |
| 1971 | f'Summarize {len(data)} items' |
| 1972 | )` |
| 1973 | : `pages = run_composio_tool( |
| 1974 | 'NOTION_LIST_PAGES', |
| 1975 | limit=50 |
| 1976 | ) |
| 1977 | for p in pages: |
| 1978 | proxy_execute(p['url']) |
| 1979 | `} |
| 1980 | </pre> |
| 1981 | </div> |
| 1982 | </div> |
| 1983 | ); |
| 1984 | })} |
| 1985 | </div> |
| 1986 | </motion.div> |
| 1987 | ); |
| 1988 | } |