Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix: correct usage examples for nested classes in SDK reference
Sushmitha Mallesh7e924fb97d19
diff --git a/docs/content/reference/sdk-reference/typescript/remote-file.mdx b/docs/content/reference/sdk-reference/typescript/remote-file.mdxindex 7bff04403..eba583510 100644--- a/docs/content/reference/sdk-reference/typescript/remote-file.mdx+++ b/docs/content/reference/sdk-reference/typescript/remote-file.mdx@@ -5,11 +5,14 @@ description: Represents a file stored in a tool router session's file mount. Pro## Usage-Access this class through the `composio.remoteFile` property:+`RemoteFile` is returned by session file operations such as `session.files.download()` and `session.files.upload()`:```typescriptconst composio = new Composio({ apiKey: 'your-api-key' });-const result = await composio.remoteFile.list();+const session = await composio.toolRouter.use('session_123');+const file = await session.files.download('/output/report.pdf');+// file is a RemoteFile instance+const content = await file.text();```## Propertiesdiff --git a/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx b/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdxindex f9bad6b19..64d45036e 100644--- a/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx+++ b/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx@@ -5,11 +5,12 @@ description: ToolRouterSessionFilesMount class reference## Usage-Access this class through the `composio.toolRouterSessionFilesMount` property:+Access via the `files` property on a session:```typescriptconst composio = new Composio({ apiKey: 'your-api-key' });-const result = await composio.toolRouterSessionFilesMount.list();+const session = await composio.toolRouter.use('session_123');+const { items } = await session.files.list({ path: '/' });```## Methodsdiff --git a/docs/content/reference/sdk-reference/typescript/tool-router-session.mdx b/docs/content/reference/sdk-reference/typescript/tool-router-session.mdxindex c35b78e1c..5ec083a12 100644--- a/docs/content/reference/sdk-reference/typescript/tool-router-session.mdx+++ b/docs/content/reference/sdk-reference/typescript/tool-router-session.mdx@@ -5,11 +5,16 @@ description: ToolRouterSession class reference## Usage-Access this class through the `composio.toolRouterSession` property:+Obtain a session via `composio.toolRouter`:```typescriptconst composio = new Composio({ apiKey: 'your-api-key' });-const result = await composio.toolRouterSession.list();++// Use an existing session+const session = await composio.toolRouter.use('session_123');++// Or create a new session+const session = await composio.toolRouter.create('user_123', { toolkits: ['github'] });```## Propertiesdiff --git a/ts/packages/core/scripts/generate-docs.ts b/ts/packages/core/scripts/generate-docs.tsindex 46f50aa97..e15e2b601 100644--- a/ts/packages/core/scripts/generate-docs.ts+++ b/ts/packages/core/scripts/generate-docs.ts@@ -31,6 +31,35 @@ const INTERNAL_CLASSES = new Set([// Classes that users instantiate directly (show constructor)const USER_INSTANTIATED_CLASSES = new Set(['Composio']);+// Custom usage examples for classes that aren't top-level composio.* properties+const CLASS_CUSTOM_USAGE: Record<string, { intro: string; code: string }> = {+ RemoteFile: {+ intro:+ '`RemoteFile` is returned by session file operations such as `session.files.download()` and `session.files.upload()`:',+ code: `const composio = new Composio({ apiKey: 'your-api-key' });+const session = await composio.toolRouter.use('session_123');+const file = await session.files.download('/output/report.pdf');+// file is a RemoteFile instance+const content = await file.text();`,+ },+ ToolRouterSession: {+ intro: 'Obtain a session via `composio.toolRouter`:',+ code: `const composio = new Composio({ apiKey: 'your-api-key' });++// Use an existing session+const session = await composio.toolRouter.use('session_123');++// Or create a new session+const session = await composio.toolRouter.create('user_123', { toolkits: ['github'] });`,+ },+ ToolRouterSessionFilesMount: {+ intro: 'Access via the `files` property on a session:',+ code: `const composio = new Composio({ apiKey: 'your-api-key' });+const session = await composio.toolRouter.use('session_123');+const { items } = await session.files.list({ path: '/' });`,+ },+};+// Discover model files automaticallyasync function discoverModelFiles(): Promise<string[]> {const files = await readdir(MODELS_DIR);@@ -538,20 +567,30 @@ function generateClassMdx(classDoc: ClassDoc): string {lines.push('');lines.push(generateMethodMdx(classDoc.constructor));} else if (!USER_INSTANTIATED_CLASSES.has(classDoc.name)) {- // Show usage hint for non-instantiated classes- // Handle acronyms (e.g., "MCP" -> "mcp") vs PascalCase (e.g., "AuthConfigs" -> "authConfigs")- const accessorName =- classDoc.name === classDoc.name.toUpperCase()- ? classDoc.name.toLowerCase()- : classDoc.name.charAt(0).toLowerCase() + classDoc.name.slice(1);lines.push('## Usage');lines.push('');- lines.push(`Access this class through the \`composio.${accessorName}\` property:`);- lines.push('');- lines.push('```typescript');- lines.push(`const composio = new Composio({ apiKey: 'your-api-key' });`);- lines.push(`const result = await composio.${accessorName}.list();`);- lines.push('```');++ const customUsage = CLASS_CUSTOM_USAGE[classDoc.name];+ if (customUsage) {+ lines.push(customUsage.intro);+ lines.push('');+ lines.push('```typescript');+ lines.push(customUsage.code);+ lines.push('```');+ } else {+ // Default: show as top-level composio.* property+ // Handle acronyms (e.g., "MCP" -> "mcp") vs PascalCase (e.g., "AuthConfigs" -> "authConfigs")+ const accessorName =+ classDoc.name === classDoc.name.toUpperCase()+ ? classDoc.name.toLowerCase()+ : classDoc.name.charAt(0).toLowerCase() + classDoc.name.slice(1);+ lines.push(`Access this class through the \`composio.${accessorName}\` property:`);+ lines.push('');+ lines.push('```typescript');+ lines.push(`const composio = new Composio({ apiKey: 'your-api-key' });`);+ lines.push(`const result = await composio.${accessorName}.list();`);+ lines.push('```');+ }lines.push('');}