@devries-cameron20 / composio Mirror · read-only / commits / c3f117e3e
Fork 0

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, 16:00 UTC

docs: assert llms.txt output directly, leave the example snapshot alone

Two review follow-ups: - Revert docs/lib/standup-bot-source.json. It is an upstream source snapshot that gets regenerated, so editing the doc URL in that code comment only desyncs it and would be clobbered anyway. The permanent redirect covers the stale path. - Strengthen the agent-reachability assertion in start-routing.test.ts. Asserting meta.json membership alone is weaker than the assertion it replaced, which checked a string that actually shipped into llms.txt: a break in the page-tree walk would have gone unnoticed. Import the llms.txt route handler and assert its generated output — each of the 8 guide URLs present exactly once, the 7 auth guides under Core concepts -> Authentication, shared-connections under Guides -> Extend sessions, and no trailing "## Authentication guides" section. Follows the existing tests/static/llms-openapi.test.ts pattern of importing an app route directly, so it runs in `bun run test` with no server. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Kshitij Jhunjhunwala committed Aug 14, 2026 at 12:21 UTC c3f117e3e80080018065b678a093f7d7793897aa
2 files changed +64 -11
docs/lib/standup-bot-source.json
+1 -1
@@ -46,7 +46,7 @@
46 },
47 {
48 "path": "scripts/setup.ts",
49 - "contents": "import { Composio } from \"@composio/core\";\nimport { env } from \"../api/_utils/env\";\n\n// One-time setup: connect the bot's Slack (\"slackbot\") account so it can post to\n// the channel and DM members. Run with `npx tsx scripts/setup.ts`, or\n// `--reconnect` to clear and re-do the OAuth (needed after changing Slack scopes).\nconst COMPOSIO_BASE_URL = \"https://backend.composio.dev\";\nconst TOOLKIT_SLUG = \"slackbot\";\n\n// Scopes the bot's OAuth *user* token must carry. Composio freezes the scopes at\n// connect time, so we check them before connecting and tell the user what to add.\nconst REQUIRED_USER_SCOPES = [\"team:read\"];\n\nconst log = {\n ok: (msg: string) => console.log(` ✅ ${msg}`),\n info: (msg: string) => console.log(` · ${msg}`),\n warn: (msg: string) => console.log(` ⚠️ ${msg}`),\n};\n\nfunction errMessage(err: unknown): string {\n if (err && typeof err === \"object\") {\n const e = err as {\n error?: { error?: { message?: string }; message?: string };\n message?: string;\n };\n return e.error?.error?.message ?? e.error?.message ?? e.message ?? String(err);\n }\n return String(err);\n}\n\nasync function main() {\n const RECONNECT = process.argv.includes(\"--reconnect\");\n\n console.log(\"\\n╭─────────────────────────────────────────────────────────╮\");\n console.log(\"│ Daily Standup Bot: One-Time Setup │\");\n console.log(\"╰─────────────────────────────────────────────────────────╯\");\n if (RECONNECT) {\n console.log(\" (--reconnect: will clear and re-do the bot's Slack auth)\");\n }\n\n const composio = new Composio({ apiKey: env.COMPOSIO_API_KEY });\n const authConfigId = env.COMPOSIO_SLACKBOT_AUTH_CONFIG_ID;\n\n // Check the auth config requests the scopes the bot needs.\n // READ-ONLY on purpose. GET returns secrets MASKED, and a PATCH that echoes\n // those masked values back overwrites the real client_secret with the mask.\n // So we never write credentials here; we only check and warn.\n const cfgRes = await fetch(`${COMPOSIO_BASE_URL}/api/v3/auth_configs/${authConfigId}`, {\n headers: { \"x-api-key\": env.COMPOSIO_API_KEY },\n });\n if (cfgRes.ok) {\n const cfg = (await cfgRes.json().catch(() => ({}))) as {\n credentials?: { user_scopes?: string[] };\n };\n const userScopes = cfg.credentials?.user_scopes ?? [];\n const missing = REQUIRED_USER_SCOPES.filter((s) => !userScopes.includes(s));\n if (missing.length > 0) {\n log.warn(`Auth config is missing required user scope(s): ${missing.join(\", \")}`);\n console.log(\n \" Add them under the auth config's User Token Scopes in the Composio\\n\" +\n \" dashboard (Auth Configs → slackbot), then re-run with --reconnect.\"\n );\n } else {\n log.ok(\"Auth config has the required user scopes.\");\n }\n }\n\n // Ensure the bot's Slack connection is active.\n const session = await composio.create(\"default\", {\n authConfigs: { slackbot: authConfigId },\n });\n\n async function listSlackbotAccounts() {\n try {\n const res = await composio.connectedAccounts.list({\n userIds: [\"default\"],\n toolkitSlugs: [TOOLKIT_SLUG],\n });\n return res.items;\n } catch {\n return [];\n }\n }\n\n if (RECONNECT) {\n const accounts = await listSlackbotAccounts();\n if (accounts.length === 0) {\n log.info(\"No existing connections to clear.\");\n } else {\n for (const acc of accounts) {\n try {\n await composio.connectedAccounts.delete(acc.id);\n log.ok(`Removed old connection ${acc.id}.`);\n } catch (err) {\n log.warn(`Could not remove ${acc.id}: ${errMessage(err)}`);\n }\n }\n }\n }\n\n let connected = false;\n if (!RECONNECT) {\n const toolkits = await session.toolkits({ toolkits: [TOOLKIT_SLUG] });\n connected = !!toolkits.items.find((t) => t.slug === TOOLKIT_SLUG)?.connection\n ?.isActive;\n }\n\n if (connected) {\n log.ok(\"Bot is already connected to Slack.\");\n } else {\n log.info(\"Bot is not connected yet. Generating an authorization link…\");\n // Manual authentication: authorize() returns a Connect Link, then\n // waitForConnection() resolves once the bot finishes OAuth in the browser.\n // https://docs.composio.dev/docs/authentication/manually-authenticating\n const connectionRequest = await session.authorize(TOOLKIT_SLUG);\n if (!connectionRequest.redirectUrl) {\n throw new Error(\"Composio did not return an authorization link.\");\n }\n\n console.log(\"\\n Open this URL in your browser to authorize the bot:\\n\");\n console.log(` ${connectionRequest.redirectUrl}\\n`);\n console.log(\" Waiting for you to complete the OAuth flow (Ctrl+C to abort)…\");\n\n const TIMEOUT_MS = 5 * 60 * 1000;\n const account = await connectionRequest.waitForConnection(TIMEOUT_MS);\n log.ok(`Bot connected to Slack (${account.id}).`);\n }\n\n console.log(`\\n${\"─\".repeat(70)}`);\n console.log(\" 🎉 Setup complete. Invite the bot to your standup channel and\");\n console.log(\" point your Slack app's Interactivity Request URL at\");\n console.log(\" https://<your-deployment>/api/interactivity\");\n console.log(`${\"─\".repeat(70)}\\n`);\n}\n\nmain().catch((err) => {\n console.error(`\\n ❌ ${errMessage(err)}\\n`);\n process.exit(1);\n});\n",
49 + "contents": "import { Composio } from \"@composio/core\";\nimport { env } from \"../api/_utils/env\";\n\n// One-time setup: connect the bot's Slack (\"slackbot\") account so it can post to\n// the channel and DM members. Run with `npx tsx scripts/setup.ts`, or\n// `--reconnect` to clear and re-do the OAuth (needed after changing Slack scopes).\nconst COMPOSIO_BASE_URL = \"https://backend.composio.dev\";\nconst TOOLKIT_SLUG = \"slackbot\";\n\n// Scopes the bot's OAuth *user* token must carry. Composio freezes the scopes at\n// connect time, so we check them before connecting and tell the user what to add.\nconst REQUIRED_USER_SCOPES = [\"team:read\"];\n\nconst log = {\n ok: (msg: string) => console.log(` ✅ ${msg}`),\n info: (msg: string) => console.log(` · ${msg}`),\n warn: (msg: string) => console.log(` ⚠️ ${msg}`),\n};\n\nfunction errMessage(err: unknown): string {\n if (err && typeof err === \"object\") {\n const e = err as {\n error?: { error?: { message?: string }; message?: string };\n message?: string;\n };\n return e.error?.error?.message ?? e.error?.message ?? e.message ?? String(err);\n }\n return String(err);\n}\n\nasync function main() {\n const RECONNECT = process.argv.includes(\"--reconnect\");\n\n console.log(\"\\n╭─────────────────────────────────────────────────────────╮\");\n console.log(\"│ Daily Standup Bot: One-Time Setup │\");\n console.log(\"╰─────────────────────────────────────────────────────────╯\");\n if (RECONNECT) {\n console.log(\" (--reconnect: will clear and re-do the bot's Slack auth)\");\n }\n\n const composio = new Composio({ apiKey: env.COMPOSIO_API_KEY });\n const authConfigId = env.COMPOSIO_SLACKBOT_AUTH_CONFIG_ID;\n\n // Check the auth config requests the scopes the bot needs.\n // READ-ONLY on purpose. GET returns secrets MASKED, and a PATCH that echoes\n // those masked values back overwrites the real client_secret with the mask.\n // So we never write credentials here; we only check and warn.\n const cfgRes = await fetch(`${COMPOSIO_BASE_URL}/api/v3/auth_configs/${authConfigId}`, {\n headers: { \"x-api-key\": env.COMPOSIO_API_KEY },\n });\n if (cfgRes.ok) {\n const cfg = (await cfgRes.json().catch(() => ({}))) as {\n credentials?: { user_scopes?: string[] };\n };\n const userScopes = cfg.credentials?.user_scopes ?? [];\n const missing = REQUIRED_USER_SCOPES.filter((s) => !userScopes.includes(s));\n if (missing.length > 0) {\n log.warn(`Auth config is missing required user scope(s): ${missing.join(\", \")}`);\n console.log(\n \" Add them under the auth config's User Token Scopes in the Composio\\n\" +\n \" dashboard (Auth Configs → slackbot), then re-run with --reconnect.\"\n );\n } else {\n log.ok(\"Auth config has the required user scopes.\");\n }\n }\n\n // Ensure the bot's Slack connection is active.\n const session = await composio.create(\"default\", {\n authConfigs: { slackbot: authConfigId },\n });\n\n async function listSlackbotAccounts() {\n try {\n const res = await composio.connectedAccounts.list({\n userIds: [\"default\"],\n toolkitSlugs: [TOOLKIT_SLUG],\n });\n return res.items;\n } catch {\n return [];\n }\n }\n\n if (RECONNECT) {\n const accounts = await listSlackbotAccounts();\n if (accounts.length === 0) {\n log.info(\"No existing connections to clear.\");\n } else {\n for (const acc of accounts) {\n try {\n await composio.connectedAccounts.delete(acc.id);\n log.ok(`Removed old connection ${acc.id}.`);\n } catch (err) {\n log.warn(`Could not remove ${acc.id}: ${errMessage(err)}`);\n }\n }\n }\n }\n\n let connected = false;\n if (!RECONNECT) {\n const toolkits = await session.toolkits({ toolkits: [TOOLKIT_SLUG] });\n connected = !!toolkits.items.find((t) => t.slug === TOOLKIT_SLUG)?.connection\n ?.isActive;\n }\n\n if (connected) {\n log.ok(\"Bot is already connected to Slack.\");\n } else {\n log.info(\"Bot is not connected yet. Generating an authorization link…\");\n // Manual authentication: authorize() returns a Connect Link, then\n // waitForConnection() resolves once the bot finishes OAuth in the browser.\n // https://docs.composio.dev/docs/manually-authenticating\n const connectionRequest = await session.authorize(TOOLKIT_SLUG);\n if (!connectionRequest.redirectUrl) {\n throw new Error(\"Composio did not return an authorization link.\");\n }\n\n console.log(\"\\n Open this URL in your browser to authorize the bot:\\n\");\n console.log(` ${connectionRequest.redirectUrl}\\n`);\n console.log(\" Waiting for you to complete the OAuth flow (Ctrl+C to abort)…\");\n\n const TIMEOUT_MS = 5 * 60 * 1000;\n const account = await connectionRequest.waitForConnection(TIMEOUT_MS);\n log.ok(`Bot connected to Slack (${account.id}).`);\n }\n\n console.log(`\\n${\"─\".repeat(70)}`);\n console.log(\" 🎉 Setup complete. Invite the bot to your standup channel and\");\n console.log(\" point your Slack app's Interactivity Request URL at\");\n console.log(\" https://<your-deployment>/api/interactivity\");\n console.log(`${\"─\".repeat(70)}\\n`);\n}\n\nmain().catch((err) => {\n console.error(`\\n ❌ ${errMessage(err)}\\n`);\n process.exit(1);\n});\n",
50 "composio": true
51 }
52 ]
docs/tests/static/start-routing.test.ts
+63 -10
@@ -4,6 +4,25 @@ import { HOME_INTENTS } from '../../lib/home-navigation';
4
5 const read = (path: string) => Bun.file(new URL(`../../${path}`, import.meta.url)).text();
6
7 +/**
8 + * The 7 auth guides live in the Authentication folder; shared connections is a
9 + * session capability and lives under Extend sessions.
10 + */
11 +const AUTH_GUIDES = [
12 + 'manually-authenticating',
13 + 'managing-multiple-connected-accounts',
14 + 'importing-existing-connections',
15 + 'custom-app-vs-managed-app',
16 + 'programmatic-auth-configs',
17 + 'controlling-scopes',
18 + 'white-labeling-authentication',
19 +];
20 +
21 +const GUIDE_URLS = [
22 + ...AUTH_GUIDES.map(guide => `/docs/authentication/${guide}`),
23 + '/docs/extending-sessions/shared-connections',
24 +];
25 +
26 describe('getting-started routing policy', () => {
27 test('publishes native plugins for both supported agent hosts', async () => {
28 const plugins = await read('content/docs/agent-plugins.mdx');
@@ -38,19 +57,10 @@ describe('getting-started routing policy', () => {
57 read('content/docs/authentication/meta.json'),
58 read('content/docs/extending-sessions/meta.json'),
59 ]);
41 - const authGuides = [
42 - 'manually-authenticating',
43 - 'managing-multiple-connected-accounts',
44 - 'importing-existing-connections',
45 - 'custom-app-vs-managed-app',
46 - 'programmatic-auth-configs',
47 - 'controlling-scopes',
48 - 'white-labeling-authentication',
49 - ];
60 const authPages = JSON.parse(authMeta).pages as string[];
61 const sessionPages = JSON.parse(sessionsMeta).pages as string[];
62
53 - for (const guide of authGuides) {
63 + for (const guide of AUTH_GUIDES) {
64 expect(authentication).toContain(`href="/docs/authentication/${guide}"`);
65 expect(authPages).toContain(guide);
66 }
@@ -58,4 +68,47 @@ describe('getting-started routing policy', () => {
68 expect(authentication).toContain('href="/docs/extending-sessions/shared-connections"');
69 expect(sessionPages).toContain('shared-connections');
70 });
71 +
72 + /**
73 + * Asserts the generated bytes, not the meta.json inputs. These guides used to
74 + * be listed in llms.txt by a hardcoded `AUTHENTICATION_GUIDE_URLS` constant
75 + * because they had been dropped from the page tree; they are emitted by the
76 + * page-tree walk now, so a regression in that walk — not just in the meta
77 + * files — has to fail something.
78 + */
79 + test('emits every authentication guide into llms.txt exactly once', async () => {
80 + const { GET } = await import('../../app/llms.txt/route');
81 + const llms = await (await GET()).text();
82 +
83 + for (const url of GUIDE_URLS) {
84 + const occurrences = llms.split(`https://docs.composio.dev${url}.md`).length - 1;
85 + expect(occurrences, `${url} appears ${occurrences}x in llms.txt`).toBe(1);
86 + }
87 + });
88 +
89 + test('files the authentication guides under Core concepts, not a trailing section', async () => {
90 + const { GET } = await import('../../app/llms.txt/route');
91 + const lines = (await (await GET()).text()).split('\n');
92 +
93 + const sectionOf = (url: string) => {
94 + const index = lines.findIndex(line => line.endsWith(`${url}.md`));
95 + expect(index, `${url} missing from llms.txt`).toBeGreaterThan(-1);
96 + const preceding = lines.slice(0, index);
97 + const last = (prefix: string) => preceding.findLast(line => line.startsWith(prefix));
98 + return [last('## '), last('### ')];
99 + };
100 +
101 + for (const guide of AUTH_GUIDES) {
102 + expect(sectionOf(`/docs/authentication/${guide}`)).toEqual([
103 + '## Core concepts',
104 + '### Authentication',
105 + ]);
106 + }
107 +
108 + expect(sectionOf('/docs/extending-sessions/shared-connections')).toEqual([
109 + '## Guides',
110 + '### Extend sessions',
111 + ]);
112 + expect(lines).not.toContain('## Authentication guides');
113 + });
114 });