Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Check, Search, Plug, Terminal, Zap } from 'lucide-react'; |
| 2 | import type { ReactNode } from 'react'; |
| 3 | |
| 4 | const LOGO_CDN = 'https://logos.composio.dev/api'; |
| 5 | |
| 6 | const CONNECTED_APPS: { slug: string; name: string }[] = [ |
| 7 | { slug: 'gmail', name: 'Gmail' }, |
| 8 | { slug: 'github', name: 'GitHub' }, |
| 9 | { slug: 'slack', name: 'Slack' }, |
| 10 | ]; |
| 11 | |
| 12 | const META_TOOLS: { icon: ReactNode; label: string; verb: string }[] = [ |
| 13 | { icon: <Search className="size-3" aria-hidden="true" />, label: 'Search tools', verb: 'discover' }, |
| 14 | { icon: <Plug className="size-3" aria-hidden="true" />, label: 'Manage connections', verb: 'authenticate' }, |
| 15 | { icon: <Zap className="size-3" aria-hidden="true" />, label: 'Execute tool', verb: 'act' }, |
| 16 | { icon: <Terminal className="size-3" aria-hidden="true" />, label: 'Sandbox', verb: 'compute' }, |
| 17 | ]; |
| 18 | |
| 19 | /** |
| 20 | * SessionFlow — branded replacement for the plain `agent → session → meta tools` |
| 21 | * mermaid diagram on the "What is a session?" docs page. |
| 22 | * |
| 23 | * Reads left-to-right as a story: your agent acts for a user; the session is the |
| 24 | * brand-accented runtime context that binds that user's connected accounts + auth |
| 25 | * and exposes meta tools the agent calls to discover, authenticate, and execute. |
| 26 | * |
| 27 | * The centerpiece is the Session card, which surfaces the *user and their |
| 28 | * connected accounts* — the part the old mermaid diagram never showed. |
| 29 | * Server component, no client JS. Adapts to light/dark via fd-* tokens. |
| 30 | */ |
| 31 | export function SessionFlow() { |
| 32 | return ( |
| 33 | <div className="not-prose my-6 overflow-hidden rounded-sm border border-fd-border bg-fd-background"> |
| 34 | {/* header strip — mono, matches the home-feature visuals */} |
| 35 | <div className="flex items-center justify-between border-b border-fd-border px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.06em] text-fd-foreground/45"> |
| 36 | <span>session.runtime</span> |
| 37 | <span className="inline-flex items-center gap-1.5 text-fd-foreground/55"> |
| 38 | <span className="relative inline-flex"> |
| 39 | <span className="size-1.5 rounded-full bg-[var(--composio-brand)]" /> |
| 40 | <span className="absolute inset-0 animate-ping rounded-full bg-[var(--composio-brand)] opacity-60" /> |
| 41 | </span> |
| 42 | scoped to user |
| 43 | </span> |
| 44 | </div> |
| 45 | |
| 46 | <div className="grid items-stretch gap-px bg-fd-border md:grid-cols-[minmax(0,0.85fr)_minmax(0,1.3fr)_minmax(0,1.05fr)]"> |
| 47 | {/* ── Your agent ─────────────────────────────────────────── */} |
| 48 | <Column> |
| 49 | <Lane label="Your agent" /> |
| 50 | <div className="flex flex-1 items-center"> |
| 51 | <div className="w-full border border-fd-border bg-fd-card p-3"> |
| 52 | <div className="flex items-center gap-2"> |
| 53 | <span className="flex size-7 items-center justify-center rounded-sm bg-fd-foreground/[0.06] font-mono text-[13px] text-fd-foreground/70"> |
| 54 | {'{ }'} |
| 55 | </span> |
| 56 | <div className="min-w-0"> |
| 57 | <div className="truncate text-[12px] font-medium leading-tight text-fd-foreground"> |
| 58 | AI agent |
| 59 | </div> |
| 60 | <div className="truncate font-mono text-[10px] text-fd-foreground/45"> |
| 61 | acts for one user |
| 62 | </div> |
| 63 | </div> |
| 64 | </div> |
| 65 | <p className="mt-2.5 text-[11px] leading-snug text-fd-foreground/55"> |
| 66 | Calls the session's meta tools instead of loading hundreds of |
| 67 | tool definitions. |
| 68 | </p> |
| 69 | </div> |
| 70 | </div> |
| 71 | <Connector /> |
| 72 | </Column> |
| 73 | |
| 74 | {/* ── Session (the hub) ──────────────────────────────────── */} |
| 75 | <Column> |
| 76 | <Lane label="Session" accent /> |
| 77 | <div className="flex flex-1 flex-col"> |
| 78 | <div className="relative flex-1 border border-[var(--composio-brand)]/30 bg-[var(--composio-brand)]/[0.04] p-3"> |
| 79 | <span |
| 80 | aria-hidden="true" |
| 81 | className="pointer-events-none absolute inset-y-0 left-0 w-[2px] bg-[var(--composio-brand)]" |
| 82 | /> |
| 83 | <div className="flex items-center justify-between"> |
| 84 | <span className="font-mono text-[10px] uppercase tracking-[0.06em] text-[var(--composio-brand)]"> |
| 85 | runtime context |
| 86 | </span> |
| 87 | <span className="font-mono text-[10px] text-fd-foreground/45"> |
| 88 | usr_9x2kLm7 |
| 89 | </span> |
| 90 | </div> |
| 91 | |
| 92 | {/* The user + their connected accounts — the missing piece */} |
| 93 | <div className="mt-2.5 overflow-hidden rounded-sm border border-fd-border bg-fd-card"> |
| 94 | <div className="flex items-center gap-2 border-b border-fd-border px-2.5 py-1.5"> |
| 95 | <span className="flex size-5 items-center justify-center rounded-full bg-[var(--composio-brand)]/12 font-mono text-[10px] font-medium text-[var(--composio-brand)]"> |
| 96 | U |
| 97 | </span> |
| 98 | <span className="text-[11px] font-medium text-fd-foreground"> |
| 99 | Your user |
| 100 | </span> |
| 101 | <span className="ml-auto font-mono text-[9px] uppercase tracking-[0.05em] text-fd-foreground/40"> |
| 102 | connected accounts |
| 103 | </span> |
| 104 | </div> |
| 105 | <ul className="flex flex-col"> |
| 106 | {CONNECTED_APPS.map((app, i) => ( |
| 107 | <li |
| 108 | key={app.slug} |
| 109 | className={ |
| 110 | 'flex items-center gap-2 px-2.5 py-1.5' + |
| 111 | (i < CONNECTED_APPS.length - 1 |
| 112 | ? ' border-b border-fd-border' |
| 113 | : '') |
| 114 | } |
| 115 | > |
| 116 | <img |
| 117 | alt="" |
| 118 | aria-hidden="true" |
| 119 | className="size-3.5 object-contain" |
| 120 | draggable={false} |
| 121 | src={`${LOGO_CDN}/${app.slug}`} |
| 122 | /> |
| 123 | <span className="text-[11px] text-fd-foreground/75"> |
| 124 | {app.name} |
| 125 | </span> |
| 126 | <span className="ml-auto inline-flex items-center gap-1 font-mono text-[9px] uppercase tracking-[0.05em] text-[var(--composio-brand)]"> |
| 127 | <Check aria-hidden="true" className="size-2.5" /> |
| 128 | linked |
| 129 | </span> |
| 130 | </li> |
| 131 | ))} |
| 132 | </ul> |
| 133 | </div> |
| 134 | |
| 135 | <p className="mt-2.5 text-[11px] leading-snug text-fd-foreground/60"> |
| 136 | Ties the user, toolkits, auth, and connected accounts into one |
| 137 | scoped environment. |
| 138 | </p> |
| 139 | </div> |
| 140 | </div> |
| 141 | <Connector accent /> |
| 142 | </Column> |
| 143 | |
| 144 | {/* ── Meta tools ─────────────────────────────────────────── */} |
| 145 | <Column> |
| 146 | <Lane label="Meta tools" /> |
| 147 | <div className="flex flex-1 items-stretch"> |
| 148 | <ul className="grid w-full grid-cols-2 gap-1.5 md:grid-cols-1"> |
| 149 | {META_TOOLS.map((tool) => ( |
| 150 | <li |
| 151 | key={tool.label} |
| 152 | className="flex items-center gap-2 border border-fd-border bg-fd-card px-2.5 py-1.5" |
| 153 | > |
| 154 | <span className="flex size-5 shrink-0 items-center justify-center rounded-sm bg-[var(--composio-brand)]/10 text-[var(--composio-brand)]"> |
| 155 | {tool.icon} |
| 156 | </span> |
| 157 | <span className="min-w-0"> |
| 158 | <span className="block truncate text-[11px] font-medium leading-tight text-fd-foreground"> |
| 159 | {tool.label} |
| 160 | </span> |
| 161 | <span className="block truncate font-mono text-[9px] uppercase tracking-[0.05em] text-fd-foreground/40"> |
| 162 | {tool.verb} |
| 163 | </span> |
| 164 | </span> |
| 165 | </li> |
| 166 | ))} |
| 167 | </ul> |
| 168 | </div> |
| 169 | </Column> |
| 170 | </div> |
| 171 | |
| 172 | {/* footer caption */} |
| 173 | <div className="border-t border-fd-border px-3 py-2 text-center font-mono text-[10px] text-fd-foreground/45"> |
| 174 | agent <Arrow /> session (user + auth + connections) <Arrow /> discover, |
| 175 | authenticate, execute |
| 176 | </div> |
| 177 | </div> |
| 178 | ); |
| 179 | } |
| 180 | |
| 181 | function Column({ children }: { children: ReactNode }) { |
| 182 | return ( |
| 183 | <div className="relative flex flex-col gap-2 bg-fd-background p-3"> |
| 184 | {children} |
| 185 | </div> |
| 186 | ); |
| 187 | } |
| 188 | |
| 189 | function Lane({ label, accent = false }: { label: string; accent?: boolean }) { |
| 190 | return ( |
| 191 | <div className="flex items-center gap-1.5"> |
| 192 | <span |
| 193 | className={ |
| 194 | 'size-1.5 rounded-full ' + |
| 195 | (accent ? 'bg-[var(--composio-brand)]' : 'bg-fd-foreground/30') |
| 196 | } |
| 197 | aria-hidden="true" |
| 198 | /> |
| 199 | <span |
| 200 | className={ |
| 201 | 'font-mono text-[10px] font-medium uppercase tracking-[0.07em] ' + |
| 202 | (accent ? 'text-[var(--composio-brand)]' : 'text-fd-foreground/55') |
| 203 | } |
| 204 | > |
| 205 | {label} |
| 206 | </span> |
| 207 | </div> |
| 208 | ); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * Directional connector shown between columns. Horizontal arrow on desktop, |
| 213 | * vertical on stacked mobile so the flow still reads top-to-bottom. |
| 214 | */ |
| 215 | function Connector({ accent = false }: { accent?: boolean }) { |
| 216 | const color = accent ? 'bg-[var(--composio-brand)]/40' : 'bg-fd-border'; |
| 217 | const tip = accent |
| 218 | ? 'border-l-[var(--composio-brand)]/50' |
| 219 | : 'border-l-fd-border'; |
| 220 | return ( |
| 221 | <div |
| 222 | aria-hidden="true" |
| 223 | className="pointer-events-none absolute z-10 hidden md:block" |
| 224 | style={{ right: '-7px', top: '50%' }} |
| 225 | > |
| 226 | <div className="flex items-center"> |
| 227 | <span className={'h-px w-3 ' + color} /> |
| 228 | <span |
| 229 | className={ |
| 230 | 'size-0 border-y-[3px] border-l-[5px] border-y-transparent ' + tip |
| 231 | } |
| 232 | /> |
| 233 | </div> |
| 234 | </div> |
| 235 | ); |
| 236 | } |
| 237 | |
| 238 | function Arrow() { |
| 239 | return ( |
| 240 | <span aria-hidden="true" className="text-[var(--composio-brand)]"> |
| 241 | {'→'} |
| 242 | </span> |
| 243 | ); |
| 244 | } |