Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(docs): render KB identifier URLs as code spans, not dead links

jkomyno3fb74d5c989d
diff --git a/docs/content/kb/guide/toolkits-ahrefs.mdx b/docs/content/kb/guide/toolkits-ahrefs.mdx
index 57b9d5c67..67eea2f62 100644
--- a/docs/content/kb/guide/toolkits-ahrefs.mdx
+++ b/docs/content/kb/guide/toolkits-ahrefs.mdx
@@ -13,4 +13,4 @@ aliases: ["/kb/toolkits/ahrefs-actions-use-the-api-host","ahrefs-actions-use-the
---
## Ahrefs actions must call api.ahrefs.com, not ahrefs.com
-Ahrefs API calls should use the API host https://api.ahrefs.com/v3. If Ahrefs actions or connection checks are hitting https://ahrefs.com/v3 and returning 404 HTML, treat it as a connector base-URL configuration problem rather than an API-key or request-payload issue. Confirm the failing request is using api.ahrefs.com; if it is not, contact Composio support with the redacted request or log ID for connector review.
+Ahrefs API calls should use the API host `https://api.ahrefs.com/v3`. If Ahrefs actions or connection checks are hitting `https://ahrefs.com/v3` and returning 404 HTML, treat it as a connector base-URL configuration problem rather than an API-key or request-payload issue. Confirm the failing request is using api.ahrefs.com; if it is not, contact Composio support with the redacted request or log ID for connector review.
diff --git a/docs/content/kb/guide/toolkits-googlemeet.mdx b/docs/content/kb/guide/toolkits-googlemeet.mdx
index 9d59b804f..0f46784ad 100644
--- a/docs/content/kb/guide/toolkits-googlemeet.mdx
+++ b/docs/content/kb/guide/toolkits-googlemeet.mdx
@@ -17,7 +17,7 @@ Google Super is a separate toolkit with its own tool slugs. If the connected acc
## Configure Meet scopes and enable the Google Meet API before creating Meet spaces
-For Meet space creation/settings through Google Super, include the Meet scopes https://www.googleapis.com/auth/meetings.space.created and https://www.googleapis.com/auth/meetings.space.settings in the auth config, then initiate a new connection so the new scopes are granted. Also enable the Google Meet API in the Google Cloud Console project backing the OAuth app.
+For Meet space creation/settings through Google Super, include the Meet scopes `https://www.googleapis.com/auth/meetings.space.created` and `https://www.googleapis.com/auth/meetings.space.settings` in the auth config, then initiate a new connection so the new scopes are granted. Also enable the Google Meet API in the Google Cloud Console project backing the OAuth app.
## Fetch transcript entries by first resolving the conference record
diff --git a/docs/decisions/public-knowledge-base.md b/docs/decisions/public-knowledge-base.md
index 5eb36329e..0078ae24c 100644
--- a/docs/decisions/public-knowledge-base.md
+++ b/docs/decisions/public-knowledge-base.md
@@ -110,6 +110,18 @@ gap that is not already answered by current docs or a published KB guide.
Volatile pricing, entitlement, and security claims require an authoritative
public source and are not copied from dashboard FAQ prose by default.
+### Identifier URLs
+
+KB prose cites machine identifiers that happen to look like URLs: OAuth
+scope URIs such as `https://www.googleapis.com/auth/…` and API surface roots
+such as `https://api.ahrefs.com/v3`. These are not documents; fetching them
+404s by design, so they can never survive the nightly external-link sweep as
+links. The generation layer therefore demotes bare citations and `<url>`
+autolinks of these two shapes to inline code spans. Explicit markdown links
+keep their authored form — if one points at an identifier URL, the nightly
+sweep flags it for an upstream fix instead of the pipeline silently rewriting
+navigation the author wrote.
+
## Routes and Navigation
- `/kb` is the knowledge-base landing page.
diff --git a/docs/lib/kb/generate.ts b/docs/lib/kb/generate.ts
index 0bc87eda3..c295b2985 100644
--- a/docs/lib/kb/generate.ts
+++ b/docs/lib/kb/generate.ts
@@ -89,12 +89,56 @@ function relatedFrontmatter(
];
}
+/**
+ * Identifier URLs cite machine identifiers — OAuth scope URIs and API
+ * surface roots such as `https://api.example.com/v3` — not documents. They
+ * respond 404 by design, so they must never publish as links the nightly
+ * external-link sweep would have to keep alive: they render as code spans.
+ */
+export function isIdentifierUrl(raw: string): boolean {
+ let url: URL;
+ try {
+ url = new URL(raw);
+ } catch {
+ return false;
+ }
+ if ((url.protocol !== 'https:' && url.protocol !== 'http:') || url.search || url.hash) {
+ return false;
+ }
+ // Google OAuth scope URIs (https://www.googleapis.com/auth/…) identify a
+ // permission; the namespace serves no pages.
+ if (url.hostname === 'www.googleapis.com' && url.pathname.startsWith('/auth/')) {
+ return true;
+ }
+ // An API surface root: a version-only path such as `/v3` or `/v1beta/`.
+ // Deep paths (`/v3/tools/X`) stay links because they name real resources.
+ return /^\/v\d[\w.-]*\/?$/.test(url.pathname);
+}
+
+/**
+ * Wraps bare identifier URLs in code spans. URLs already presented as links —
+ * markdown link labels `[url](…)`, link targets `](url)`, and anything
+ * adjacent to a code span — keep their form; only bare citations and
+ * `<url>` autolinks (normalized earlier) become code.
+ */
+function identifierUrlsToCodeSpans(segment: string): string {
+ return segment.replace(/(?<![`(\]\[])https?:\/\/[^\s`<>\[\]()]+/g, match => {
+ // GFM autolinks drop trailing punctuation; keep it outside the code span.
+ const url = match.replace(/[.,;:!?'"]+$/, '');
+ if (!isIdentifierUrl(url)) return match;
+ return `\`${url}\`${match.slice(url.length)}`;
+ });
+}
+
function escapeMdxProse(line: string): string {
- const escapeSegment = (segment: string): string => segment
- .replace(/<(https?:\/\/[^>\s]+)>/g, '[$1]($1)')
- .replace(/<([^>\n]+)>/g, '&lt;$1&gt;')
- .replace(/\{/g, '&#123;')
- .replace(/\}/g, '&#125;');
+ const escapeSegment = (segment: string): string => identifierUrlsToCodeSpans(
+ segment
+ .replace(/<(https?:\/\/[^>\s]+)>/g, (match, url: string) =>
+ isIdentifierUrl(url) ? `\`${url}\`` : `[${url}](${url})`)
+ .replace(/<([^>\n]+)>/g, '&lt;$1&gt;')
+ .replace(/\{/g, '&#123;')
+ .replace(/\}/g, '&#125;'),
+ );
let result = '';
let cursor = 0;
@@ -117,7 +161,8 @@ function escapeMdxProse(line: string): string {
/**
* Converts authoritative CommonMark into MDX-safe Markdown. The source and
* article snapshots stay verbatim; only the generated presentation escapes MDX
- * expressions, normalizes autolinks, and opts support snippets out of Twoslash.
+ * expressions, normalizes autolinks, demotes identifier URLs to code spans,
+ * and opts support snippets out of Twoslash.
*/
export function markdownForMdx(markdown: string): string {
let fence: { marker: string; length: number } | null = null;
diff --git a/docs/tests/static/kb-generation.test.ts b/docs/tests/static/kb-generation.test.ts
index 41d0d107a..afa1a247d 100644
--- a/docs/tests/static/kb-generation.test.ts
+++ b/docs/tests/static/kb-generation.test.ts
@@ -38,6 +38,30 @@ describe('public KB content generation', () => {
].join('\n'));
});
+ test('demotes bare identifier URLs to code spans so they never publish as dead links', () => {
+ expect(markdownForMdx([
+ 'Ahrefs API calls should use the API host https://api.ahrefs.com/v3. If actions are hitting https://ahrefs.com/v3 and returning 404 HTML, treat it as a configuration problem.',
+ 'Include the Meet scopes https://www.googleapis.com/auth/meetings.space.created and https://www.googleapis.com/auth/meetings.space.settings in the auth config.',
+ 'Read https://developers.google.com/identity/protocols/oauth2 and [the policy](https://developers.google.com/identity/protocols/oauth2/policies) for details.',
+ 'Explicit syntax keeps its form: <https://developers.google.com/identity/protocols/oauth2> stays a link, [scope](https://www.googleapis.com/auth/gmail.send) and <https://www.googleapis.com/auth/gmail.send> cite identifiers, so only the first remains a link.',
+ 'Already code: `https://www.googleapis.com/auth/drive` and deep API paths such as https://backend.composio.dev/api/v3/tools/X remain links.',
+ '',
+ '```text',
+ 'const scope = "https://www.googleapis.com/auth/drive";',
+ '```',
+ ].join('\n'))).toBe([
+ 'Ahrefs API calls should use the API host `https://api.ahrefs.com/v3`. If actions are hitting `https://ahrefs.com/v3` and returning 404 HTML, treat it as a configuration problem.',
+ 'Include the Meet scopes `https://www.googleapis.com/auth/meetings.space.created` and `https://www.googleapis.com/auth/meetings.space.settings` in the auth config.',
+ 'Read https://developers.google.com/identity/protocols/oauth2 and [the policy](https://developers.google.com/identity/protocols/oauth2/policies) for details.',
+ 'Explicit syntax keeps its form: [https://developers.google.com/identity/protocols/oauth2](https://developers.google.com/identity/protocols/oauth2) stays a link, [scope](https://www.googleapis.com/auth/gmail.send) and `https://www.googleapis.com/auth/gmail.send` cite identifiers, so only the first remains a link.',
+ 'Already code: `https://www.googleapis.com/auth/drive` and deep API paths such as https://backend.composio.dev/api/v3/tools/X remain links.',
+ '',
+ '```text',
+ 'const scope = "https://www.googleapis.com/auth/drive";',
+ '```',
+ ].join('\n'));
+ });
+
test('defines multi-source provenance in the KB frontmatter schema', () => {
const sourceConfig = readFileSync(join(process.cwd(), 'source.config.ts'), 'utf8');