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 | export type DocsProduct = 'for-you' | 'platform'; |
| 2 | |
| 3 | type ProductSidebarGroupLink = |
| 4 | | { type?: 'page'; url: string; label?: string } |
| 5 | | { type: 'folder'; path: string; label?: string } |
| 6 | | { type: 'link'; url: string; label: string; external?: boolean }; |
| 7 | |
| 8 | export type ProductSidebarItem = |
| 9 | | { type: 'page'; url: string; label?: string } |
| 10 | | { type: 'folder'; path: string; label?: string } |
| 11 | | { type: 'link'; url: string; label: string; external?: boolean } |
| 12 | | { type: 'group'; label: string; links: readonly ProductSidebarGroupLink[] }; |
| 13 | |
| 14 | export interface ProductSidebarGroup { |
| 15 | label: string; |
| 16 | items: readonly ProductSidebarItem[]; |
| 17 | } |
| 18 | |
| 19 | export interface HomeIntentLink { |
| 20 | title: string; |
| 21 | description: string; |
| 22 | href: string; |
| 23 | } |
| 24 | |
| 25 | export interface HomeIntent { |
| 26 | id: 'build' | 'use'; |
| 27 | productId: DocsProduct; |
| 28 | product: 'Platform' | 'For You'; |
| 29 | title: string; |
| 30 | description: string; |
| 31 | links: readonly HomeIntentLink[]; |
| 32 | } |
| 33 | |
| 34 | interface DocsProductConfig { |
| 35 | id: DocsProduct; |
| 36 | product: HomeIntent['product']; |
| 37 | switcherDescription: string; |
| 38 | landingRoute: string; |
| 39 | theme: 'light' | 'dark'; |
| 40 | themeColor: '#131211' | '#ffffff'; |
| 41 | routePrefixes: readonly string[]; |
| 42 | sidebar: readonly ProductSidebarGroup[]; |
| 43 | home: Omit<HomeIntent, 'productId' | 'product'>; |
| 44 | } |
| 45 | |
| 46 | /** A sidebar entry that both products list: one page or one content folder. */ |
| 47 | type SharedSidebarItem = Extract<ProductSidebarItem, { type: 'page' | 'folder' }>; |
| 48 | |
| 49 | const SHARED_SIDEBAR_ITEMS: readonly SharedSidebarItem[] = [ |
| 50 | { type: 'page', url: '/docs/using-composio-skill' }, |
| 51 | ]; |
| 52 | |
| 53 | const SHARED_ROUTE_PREFIXES = SHARED_SIDEBAR_ITEMS.map(item => |
| 54 | item.type === 'page' ? item.url : `/docs/${item.path}` |
| 55 | ); |
| 56 | |
| 57 | /** |
| 58 | * Canonical product model for the docs shell and homepage. |
| 59 | * |
| 60 | * Platform is the documented first-visit default because it preserves the |
| 61 | * existing SDK-first docs behavior. Audience-specific URLs take precedence, |
| 62 | * followed by the persisted cookie on shared URLs. |
| 63 | */ |
| 64 | export const DEFAULT_DOCS_PRODUCT: DocsProduct = 'platform'; |
| 65 | export const DOCS_PRODUCT_COOKIE = 'composio-docs-product'; |
| 66 | export const DOCS_PRODUCT_HEADER = 'x-composio-docs-product'; |
| 67 | |
| 68 | export const DOCS_PRODUCTS = { |
| 69 | 'for-you': { |
| 70 | id: 'for-you', |
| 71 | product: 'For You', |
| 72 | switcherDescription: 'Connect your apps to AI clients.', |
| 73 | landingRoute: '/docs/agent-plugins', |
| 74 | theme: 'light', |
| 75 | themeColor: '#ffffff', |
| 76 | routePrefixes: [ |
| 77 | '/docs/agent-plugins', |
| 78 | '/docs/claude-code-plugin', |
| 79 | '/docs/cli', |
| 80 | '/docs/composio-connect', |
| 81 | ], |
| 82 | sidebar: [ |
| 83 | { |
| 84 | label: 'Get started', |
| 85 | items: [ |
| 86 | { type: 'page', url: '/docs/agent-plugins' }, |
| 87 | { type: 'page', url: '/docs/cli' }, |
| 88 | { type: 'page', url: '/docs/composio-connect', label: 'Connect with MCP' }, |
| 89 | ], |
| 90 | }, |
| 91 | { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS }, |
| 92 | ], |
| 93 | home: { |
| 94 | id: 'use', |
| 95 | title: 'Use Composio', |
| 96 | description: 'Use Composio yourself with agents you already have.', |
| 97 | links: [ |
| 98 | { |
| 99 | title: 'Agent plugins', |
| 100 | description: 'Install the native Composio plugin for Codex or Claude Code.', |
| 101 | href: '/docs/agent-plugins', |
| 102 | }, |
| 103 | { |
| 104 | title: 'Composio CLI', |
| 105 | description: 'Search, connect, and run tools from your terminal.', |
| 106 | href: '/docs/cli', |
| 107 | }, |
| 108 | { |
| 109 | title: 'Connect over MCP', |
| 110 | description: 'Use Composio with Cursor or another existing MCP client.', |
| 111 | href: '/docs/composio-connect', |
| 112 | }, |
| 113 | ], |
| 114 | }, |
| 115 | }, |
| 116 | platform: { |
| 117 | id: 'platform', |
| 118 | product: 'Platform', |
| 119 | switcherDescription: 'Build agents with the Composio SDK.', |
| 120 | landingRoute: '/docs/quickstart', |
| 121 | theme: 'dark', |
| 122 | themeColor: '#131211', |
| 123 | routePrefixes: [ |
| 124 | '/docs/agent-setup', |
| 125 | '/docs/quickstart', |
| 126 | '/docs/consumer-agents', |
| 127 | '/docs/b2b-agents', |
| 128 | '/docs/production-readiness', |
| 129 | '/docs/providers', |
| 130 | '/docs/how-composio-works', |
| 131 | '/docs/apps-and-toolkits', |
| 132 | '/docs/configuring-sessions', |
| 133 | '/docs/session-configs', |
| 134 | '/docs/governance/action-permissions', |
| 135 | '/docs/governance/approvals', |
| 136 | '/docs/firewall', |
| 137 | '/docs/instant-tools', |
| 138 | '/docs/toolkits', |
| 139 | '/docs/governance/tool-hints', |
| 140 | '/docs/authentication', |
| 141 | '/docs/triggers', |
| 142 | '/docs/skills', |
| 143 | '/docs/sessions-via-mcp', |
| 144 | '/docs/sandbox', |
| 145 | '/docs/extending-sessions', |
| 146 | '/docs/setting-up-triggers', |
| 147 | '/docs/poc-to-prod', |
| 148 | '/docs/security', |
| 149 | '/docs/sessions-vs-direct-execution', |
| 150 | '/docs/tools-direct', |
| 151 | '/docs/auth-configuration', |
| 152 | '/docs/migration-guide', |
| 153 | '/docs/single-toolkit-mcp', |
| 154 | ], |
| 155 | sidebar: [ |
| 156 | { |
| 157 | label: 'Get started', |
| 158 | items: [ |
| 159 | { type: 'folder', path: 'agent-setup' }, |
| 160 | { type: 'page', url: '/docs/quickstart' }, |
| 161 | { type: 'folder', path: 'providers', label: 'SDKs and frameworks' }, |
| 162 | ], |
| 163 | }, |
| 164 | { |
| 165 | label: 'Build', |
| 166 | items: [ |
| 167 | { |
| 168 | type: 'group', |
| 169 | label: 'Sessions', |
| 170 | links: [ |
| 171 | { url: '/docs/how-composio-works', label: 'What is a Session?' }, |
| 172 | { url: '/docs/configuring-sessions' }, |
| 173 | { url: '/docs/session-configs' }, |
| 174 | { url: '/docs/sessions-via-mcp' }, |
| 175 | ], |
| 176 | }, |
| 177 | { |
| 178 | type: 'group', |
| 179 | label: 'Toolkits & Tools', |
| 180 | links: [ |
| 181 | { url: '/docs/toolkits' }, |
| 182 | { type: 'folder', path: 'apps-and-toolkits' }, |
| 183 | { url: '/docs/instant-tools' }, |
| 184 | { url: '/docs/extending-sessions/local-tools-and-toolkits' }, |
| 185 | { url: '/docs/extending-sessions/custom-mcp' }, |
| 186 | ], |
| 187 | }, |
| 188 | { |
| 189 | type: 'group', |
| 190 | label: 'Governance', |
| 191 | links: [ |
| 192 | { url: '/docs/governance/action-permissions' }, |
| 193 | { url: '/docs/governance/tool-hints' }, |
| 194 | { url: '/docs/governance/approvals' }, |
| 195 | { url: '/docs/firewall' }, |
| 196 | ], |
| 197 | }, |
| 198 | { |
| 199 | type: 'group', |
| 200 | label: 'Authentication', |
| 201 | links: [ |
| 202 | { url: '/docs/authentication', label: 'Authentication with Composio' }, |
| 203 | { url: '/docs/authentication/managed-auth-for-custom-tools' }, |
| 204 | { |
| 205 | url: '/docs/authentication/managing-multiple-connected-accounts', |
| 206 | label: 'Multiple connected accounts', |
| 207 | }, |
| 208 | { url: '/docs/authentication/session-cant-find-account' }, |
| 209 | { url: '/docs/authentication/controlling-scopes' }, |
| 210 | { url: '/docs/authentication/manually-authenticating' }, |
| 211 | { url: '/docs/authentication/programmatic-auth-configs' }, |
| 212 | { url: '/docs/authentication/importing-existing-connections' }, |
| 213 | ], |
| 214 | }, |
| 215 | { type: 'page', url: '/docs/skills', label: 'Skills' }, |
| 216 | { |
| 217 | type: 'group', |
| 218 | label: 'Triggers', |
| 219 | links: [{ url: '/docs/triggers' }, { type: 'folder', path: 'setting-up-triggers' }], |
| 220 | }, |
| 221 | ], |
| 222 | }, |
| 223 | { |
| 224 | label: 'Customize', |
| 225 | items: [ |
| 226 | { |
| 227 | type: 'group', |
| 228 | label: 'Extend sessions', |
| 229 | links: [ |
| 230 | { url: '/docs/extending-sessions/proxy-execute' }, |
| 231 | { url: '/docs/extending-sessions/shared-connections' }, |
| 232 | ], |
| 233 | }, |
| 234 | { type: 'folder', path: 'sandbox' }, |
| 235 | { |
| 236 | type: 'group', |
| 237 | label: 'Guides & Examples', |
| 238 | links: [ |
| 239 | { url: '/docs/consumer-agents' }, |
| 240 | { url: '/docs/b2b-agents' }, |
| 241 | { type: 'link', url: '/examples', label: 'Examples' }, |
| 242 | ], |
| 243 | }, |
| 244 | ], |
| 245 | }, |
| 246 | { |
| 247 | label: 'Ship', |
| 248 | items: [ |
| 249 | { type: 'page', url: '/docs/production-readiness' }, |
| 250 | { type: 'page', url: '/docs/authentication/white-labeling-authentication' }, |
| 251 | { type: 'folder', path: 'poc-to-prod' }, |
| 252 | ], |
| 253 | }, |
| 254 | { |
| 255 | label: 'Security and Compliance', |
| 256 | items: [ |
| 257 | { type: 'page', url: '/docs/security/overview' }, |
| 258 | { |
| 259 | type: 'group', |
| 260 | label: 'Compliance', |
| 261 | links: [ |
| 262 | { |
| 263 | type: 'page', |
| 264 | url: '/docs/security/vendor-security-review', |
| 265 | label: 'Vendor security review', |
| 266 | }, |
| 267 | { type: 'link', url: 'https://trust.composio.dev', label: 'Trust Center', external: true }, |
| 268 | ], |
| 269 | }, |
| 270 | { |
| 271 | type: 'group', |
| 272 | label: 'Data privacy', |
| 273 | links: [ |
| 274 | { url: '/docs/security/data-retention' }, |
| 275 | { url: '/docs/security/zero-data-retention' }, |
| 276 | ], |
| 277 | }, |
| 278 | { |
| 279 | type: 'group', |
| 280 | label: 'Security controls', |
| 281 | links: [ |
| 282 | { url: '/docs/security/token-custody' }, |
| 283 | { url: '/docs/security/audit-logs' }, |
| 284 | { url: '/docs/security/outbound-ips' }, |
| 285 | ], |
| 286 | }, |
| 287 | ], |
| 288 | }, |
| 289 | { |
| 290 | label: 'Reference and Migration', |
| 291 | items: [ |
| 292 | { type: 'link', url: '/reference', label: 'API reference' }, |
| 293 | { |
| 294 | type: 'group', |
| 295 | label: 'Migration and legacy', |
| 296 | links: [ |
| 297 | { type: 'page', url: '/docs/sessions-vs-direct-execution' }, |
| 298 | { type: 'folder', path: 'migration-guide' }, |
| 299 | { type: 'folder', path: 'tools-direct' }, |
| 300 | { type: 'folder', path: 'auth-configuration' }, |
| 301 | ], |
| 302 | }, |
| 303 | ], |
| 304 | }, |
| 305 | { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS }, |
| 306 | ], |
| 307 | home: { |
| 308 | id: 'build', |
| 309 | title: 'Build with Composio', |
| 310 | description: 'Add Composio into your agent or app.', |
| 311 | links: [ |
| 312 | { |
| 313 | title: 'Quickstart', |
| 314 | description: 'Build an agent that discovers tools and works across your apps.', |
| 315 | href: '/docs/quickstart', |
| 316 | }, |
| 317 | { |
| 318 | title: 'Framework guides', |
| 319 | description: 'Use OpenAI, Anthropic, Vercel AI SDK, or another framework.', |
| 320 | href: '/docs/providers', |
| 321 | }, |
| 322 | { |
| 323 | title: 'Sessions via MCP', |
| 324 | description: 'Expose a Composio session through a hosted MCP endpoint.', |
| 325 | href: '/docs/sessions-via-mcp', |
| 326 | }, |
| 327 | ], |
| 328 | }, |
| 329 | }, |
| 330 | } as const satisfies Record<DocsProduct, DocsProductConfig>; |
| 331 | |
| 332 | export const DOCS_PRODUCT_ORDER = ['for-you', 'platform'] as const; |
| 333 | const HOME_PRODUCT_ORDER = ['platform', 'for-you'] as const; |
| 334 | |
| 335 | export const HOME_INTENTS: readonly HomeIntent[] = HOME_PRODUCT_ORDER.map(productId => { |
| 336 | const config = DOCS_PRODUCTS[productId]; |
| 337 | return { ...config.home, productId, product: config.product }; |
| 338 | }); |
| 339 | |
| 340 | const PRODUCT_COUNTERPARTS = [ |
| 341 | { platform: '/docs/quickstart', 'for-you': '/docs/agent-plugins' }, |
| 342 | { platform: '/docs/sessions-via-mcp', 'for-you': '/docs/composio-connect' }, |
| 343 | ] as const; |
| 344 | |
| 345 | function matchesRoute(pathname: string, prefix: string): boolean { |
| 346 | return pathname === prefix || pathname.startsWith(`${prefix}/`); |
| 347 | } |
| 348 | |
| 349 | export function parseDocsProduct(value: string | null | undefined): DocsProduct | null { |
| 350 | return value === 'for-you' || value === 'platform' ? value : null; |
| 351 | } |
| 352 | |
| 353 | export function classifyDocsProduct(pathname: string): DocsProduct | null { |
| 354 | for (const productId of DOCS_PRODUCT_ORDER) { |
| 355 | if (DOCS_PRODUCTS[productId].routePrefixes.some(prefix => matchesRoute(pathname, prefix))) { |
| 356 | return productId; |
| 357 | } |
| 358 | } |
| 359 | return null; |
| 360 | } |
| 361 | |
| 362 | export function resolveDocsProduct( |
| 363 | pathname: string, |
| 364 | persistedProduct?: string | null |
| 365 | ): DocsProduct { |
| 366 | return ( |
| 367 | classifyDocsProduct(pathname) ?? parseDocsProduct(persistedProduct) ?? DEFAULT_DOCS_PRODUCT |
| 368 | ); |
| 369 | } |
| 370 | |
| 371 | export function docsProductDestination(pathname: string, target: DocsProduct): string { |
| 372 | const sourceProduct = target === 'platform' ? 'for-you' : 'platform'; |
| 373 | const counterpart = PRODUCT_COUNTERPARTS.find(pair => |
| 374 | matchesRoute(pathname, pair[sourceProduct]) |
| 375 | ); |
| 376 | if (counterpart) return counterpart[target]; |
| 377 | if ( |
| 378 | classifyDocsProduct(pathname) !== sourceProduct && |
| 379 | SHARED_ROUTE_PREFIXES.some(prefix => matchesRoute(pathname, prefix)) |
| 380 | ) |
| 381 | return pathname; |
| 382 | return DOCS_PRODUCTS[target].landingRoute; |
| 383 | } |
| 384 | |
| 385 | export function serializeDocsProductCookie(product: DocsProduct): string { |
| 386 | return `${DOCS_PRODUCT_COOKIE}=${product}; Path=/; Max-Age=31536000; SameSite=Lax`; |
| 387 | } |
| 388 | |
| 389 | export function shouldAnimateDocsProductSwitch( |
| 390 | supportsViewTransitions: boolean, |
| 391 | prefersReducedMotion: boolean |
| 392 | ): boolean { |
| 393 | return supportsViewTransitions && !prefersReducedMotion; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Slugify an intent's heading label into an anchor id. Called with |
| 398 | * `intent.product`, so the ids are `#platform` / `#for-you`. |
| 399 | */ |
| 400 | export function homeIntentAnchor(label: string): string { |
| 401 | return label |
| 402 | .toLowerCase() |
| 403 | .replace(/[^a-z0-9]+/g, '-') |
| 404 | .replace(/(^-|-$)/g, ''); |
| 405 | } |
| 406 | |
| 407 | export function homeIntentsToMarkdown(): string { |
| 408 | const sections = HOME_INTENTS.map(intent => { |
| 409 | const links = intent.links |
| 410 | .map(link => `- [${link.title}](${link.href}): ${link.description}`) |
| 411 | .join('\n'); |
| 412 | |
| 413 | return `### ${intent.title}\n\n**${intent.product}**\n\n${intent.description}\n\n${links}`; |
| 414 | }).join('\n\n'); |
| 415 | |
| 416 | return `## Two ways to start\n\n${sections}`; |
| 417 | } |
| 418 | |
| 419 | export function replaceHomeNavigationMarkdown(content: string): string { |
| 420 | return content.replace(/<HomeSurfaces\s*\/>/g, homeIntentsToMarkdown()); |
| 421 | } |