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 | import assert from 'node:assert/strict'; |
| 2 | |
| 3 | // Reviewed expectations, independent of the converter and its shared constants. |
| 4 | // Keep commands with their arguments and warnings with their limiting condition. |
| 5 | export const parityPages = [ |
| 6 | { |
| 7 | url: '/docs', |
| 8 | facts: [ |
| 9 | ['platform-choice', 'Platform'], |
| 10 | ['for-you-choice', 'For You'], |
| 11 | ['platform-selection', 'Add Composio into your agent or app.'], |
| 12 | ['for-you-selection', 'Use Composio yourself with agents you already have.'], |
| 13 | ['build-destination', '/docs/quickstart'], |
| 14 | ['use-destination', '/docs/agent-plugins'], |
| 15 | ], |
| 16 | }, |
| 17 | { |
| 18 | url: '/docs/quickstart', |
| 19 | facts: [ |
| 20 | ['typescript-install', 'npm install @composio/core @composio/openai-agents @openai/agents'], |
| 21 | ['python-install', 'uv add python-dotenv composio composio-openai-agents openai-agents'], |
| 22 | ['package-choice', 'Use @composio/slim for a smaller install with the same API.'], |
| 23 | ['legacy-package-warning', 'it calls deprecated APIs and does not work with sessions'], |
| 24 | ['current-python-package', 'The current Python package is `composio`. The package `composio-core` is the legacy v1 SDK'], |
| 25 | ['python-session-example', 'session = composio.sessions.create(user_id=user_id)'], |
| 26 | ['typescript-session-example', 'const session = await composio.create(userId);'], |
| 27 | ], |
| 28 | }, |
| 29 | { |
| 30 | url: '/docs/providers/anthropic', |
| 31 | facts: [ |
| 32 | ['typescript-provider-install', 'npm install @composio/core @composio/anthropic @anthropic-ai/sdk'], |
| 33 | ['python-provider-install', 'pip install composio composio_anthropic anthropic'], |
| 34 | ['provider-version-condition', 'requires `composio` newer than 0.19.0 (Python) or `@composio/core` ≥ 0.17.0 with `@composio/anthropic` ≥ 0.11.0 (TypeScript)'], |
| 35 | ], |
| 36 | }, |
| 37 | { |
| 38 | url: '/docs/agent-plugins', |
| 39 | facts: [ |
| 40 | ['cli-install', 'curl -fsSL https://composio.dev/install | sh'], |
| 41 | ['login-and-setup', 'composio login\ncomposio setup --target auto'], |
| 42 | ['noninteractive-setup', 'composio setup --target auto --yes'], |
| 43 | ['sdk-alternative', '/docs/quickstart'], |
| 44 | ], |
| 45 | }, |
| 46 | { |
| 47 | url: '/docs/agent-setup/clients', |
| 48 | facts: [ |
| 49 | ['codex-project-skill', 'npx skills add ComposioHQ/composio --skill composio --agent codex'], |
| 50 | ['codex-prompt', 'Use the $composio skill'], |
| 51 | ['claude-prompt', 'Use the /composio skill'], |
| 52 | ], |
| 53 | }, |
| 54 | { |
| 55 | url: '/reference/api-reference/tools', |
| 56 | facts: [ |
| 57 | ['current-list-endpoint', '`/api/v3.1/tools`'], |
| 58 | ['toolkit-version-requirement', 'Manual tool execution requires an explicit toolkit version.'], |
| 59 | ['proxy-security-boundary', 'Proxy execute rejects cross-domain requests'], |
| 60 | ['typescript-proxy-example', "const { status, data } = await composio.tools.proxyExecute({\n endpoint: '/repos/composiohq/composio/issues/1',\n method: 'GET',\n connectedAccountId: 'ca_github_user_123',\n parameters: [{ name: 'Accept', value: 'application/vnd.github.v3+json', in: 'header' }],\n});"], |
| 61 | ], |
| 62 | }, |
| 63 | { |
| 64 | url: '/reference/v3/api-reference/tools', |
| 65 | facts: [ |
| 66 | ['legacy-list-endpoint', '`/api/v3/tools`'], |
| 67 | ['legacy-execute-endpoint', '`/api/v3/tools/execute/{tool_slug}`'], |
| 68 | ], |
| 69 | }, |
| 70 | { |
| 71 | url: '/examples/standup-slackbot', |
| 72 | facts: [ |
| 73 | ['toolkit-selection', 'Rule of thumb: posting *as the bot* uses `slackbot`; doing something *as a person* uses `slack`.'], |
| 74 | ['selection-image', '\n*Pick Slackbot, not Slack*'], |
| 75 | ['staged-setup-example', "const session = await composio.create('default', {\n authConfigs: { slackbot: AUTH_CONFIG },\n });"], |
| 76 | ['repository-availability-warning', 'The standup bot browser is a documentation snapshot; a public repository is not available.'], |
| 77 | ['setup-command', 'npx tsx scripts/setup.ts'], |
| 78 | ], |
| 79 | }, |
| 80 | ] as const; |
| 81 | |
| 82 | export type ParityPage = (typeof parityPages)[number]; |
| 83 | |
| 84 | export function assertPageFacts(text: string, page: ParityPage, surface: string) { |
| 85 | // Line wrapping and paragraph separators can change during ingestion. |
| 86 | // Keep every non-whitespace character, including command flags and API versions. |
| 87 | const normalized = text.replace(/\s+/g, ' '); |
| 88 | const failures = page.facts |
| 89 | .filter(([, expected]) => !normalized.includes(expected.replace(/\s+/g, ' '))) |
| 90 | .map(([id, expected]) => `${surface} ${page.url} lost fact ${id}: ${expected}`); |
| 91 | assert.equal(failures.length, 0, failures.join('\n')); |
| 92 | } |
| 93 | |
| 94 | // Scope corpus assertions to one page so another page cannot hide missing facts. |
| 95 | export function corpusPages(text: string): Map<string, string> { |
| 96 | const headings = [...text.matchAll(/^# [^\n]+ \((\/[^\s)]+)\)\r?$/gm)]; |
| 97 | return new Map(headings.map((heading, index) => [ |
| 98 | heading[1], |
| 99 | text.slice(heading.index, headings[index + 1]?.index ?? text.length), |
| 100 | ])); |
| 101 | } |