Files
composiohq__composio/ts
Anas Khan 040ffd49a2 chore(cli): remove dead duplicate maybe-advice-spans-usage file (#3757)
The captured-errors pretty-printer in the CLI has two files that export
the same
`maybeAdviseSpansUsage` symbol:

-
`ts/packages/cli/src/effect-errors/pretty-print/captured-errors/maybe-advise-spans-usage.ts`
(the live one, spelled `advise`), re-exported by
`captured-errors/index.ts` and
  consumed by `format-captured-error.ts`.
-
`ts/packages/cli/src/effect-errors/pretty-print/captured-errors/maybe-advice-spans-usage.ts`
(spelled `advice`), which is never exported through the barrel and never
imported
  anywhere.

The `advice` file is a leftover from an `advice -> advise` rename: both
files were
originally introduced identical, and only the `advise` copy was later
updated (its
leading `''` became `' '` for color-contrast spacing) and wired up. The
`advice`
copy has since sat as unreferenced dead code that still returns the
stale
pre-fix value. It ships in the bundle as dead code and is a copy-paste /
confusion
hazard. This PR deletes it.

No linked issue (self-identified cleanup).

Fixes #

## Changes
- Delete the unused, stale duplicate
`ts/packages/cli/src/effect-errors/pretty-print/captured-errors/maybe-advice-spans-usage.ts`.
The live `maybe-advise-spans-usage.ts` is unchanged and remains the only
exported/imported copy.

## Type of change
- [ ] Bug fix
- [ ] New feature
- [x] Refactor/Chore
- [ ] Documentation
- [ ] Breaking change

## How Has This Been Tested?
Confirmed the removed file is unreferenced, then ran the CLI's checks
with the
deletion in place (local Node 26 / pnpm 10; CI will verify the pinned
toolchain):

- Unreferenced check: searched the repo for both the path
`maybe-advice-spans-usage`
and the token `advice` under `ts/packages/cli/src/` -> 0 matches. Only
the live
`./maybe-advise-spans-usage` is re-exported by
`captured-errors/index.ts`, and
`format-captured-error.ts` imports `maybeAdviseSpansUsage` through that
barrel.
- Build workspace deps: `pnpm run build:packages` -> all packages built.
- Typecheck (required when touching CLI code, per
`ts/packages/cli/AGENTS.md`):
`pnpm exec turbo typecheck --filter=@composio/cli --force` -> pass,
fully
re-executed (no cache). A missing-module error would surface here if
anything had
  imported the deleted file.
- Lint: `pnpm exec eslint ts/packages/cli/src/effect-errors --ext .ts`
-> clean.
- Tests: `pnpm exec vitest run` in `ts/packages/cli` -> 720 passed, 1
skipped,
  80 files. No regressions.

## Screenshots (if applicable)
N/A.

## Checklist
- [x] I have read the Code of Conduct and this PR adheres to it
- [x] I ran linters/tests locally and they passed
- [x] I updated documentation as needed (none needed; internal dead
code)
- [x] I added tests or explain why not applicable
- [x] I added a changeset if this change affects published packages

Tests: not applicable. This is a pure deletion of unreachable code with
no
behavior change; nothing references the file, so there is nothing to
regression-test. The live `maybeAdviseSpansUsage` path is already
exercised by the
existing effect-errors tests via `format-captured-error`.

Changeset: not needed. The CLI package is not published to npm and this
is an
internal, non-published-surface change.

## Additional context
Git history for the curious: both files were introduced identical in
`333b03c3b`;
the live `maybe-advise-spans-usage.ts` diverged in `fe5acc7d7` (leading
`''` -> `' '`
for color contrast) and became the wired-up copy, leaving
`maybe-advice-spans-usage.ts`
behind as the stale duplicate removed here.

Co-authored-by: Alberto Schiabel <jkomyno@users.noreply.github.com>
2026-07-07 12:22:23 +00:00
..

Composio SDK v3

The Composio SDK is a powerful toolkit that enables you to integrate third-party tools and services into your applications. It helps you connect to various services (toolkits), execute tools, and manage user connections seamlessly.

Features

  • Execute tools from various services (GitHub, Gmail, Slack, etc.)
  • Manage user connections to external services
  • Create session-scoped custom tools with your own logic
  • Integrate with AI providers like OpenAI
  • Powerful middleware and modifier support
  • Extensive error handling

Documentation

The SDK is thoroughly documented in the docs directory:

API Reference

Provider Documentation

Advanced Topics

Internal Documentation

For SDK maintainers and contributors:

Installation

# Using npm
npm install @composio/core

# Using yarn
yarn add @composio/core

# Using pnpm
pnpm add @composio/core

Quick Start

import { Composio } from '@composio/core';

// Initialize the SDK
const composio = new Composio({
  apiKey: 'your-api-key',
});

// Get tools from a specific toolkit
const tools = await composio.tools.get('default', {
  toolkits: ['github'],
});

// Get a specific tool
const specificTool = await composio.tools.get('default', 'GITHUB_GET_REPOS');

// Execute a tool
const result = await composio.tools.execute('GITHUB_GET_REPO', {
  userId: 'default',
  arguments: {
    owner: 'composio',
    repo: 'sdk',
  },
});

console.log(result.data);

OpenAI Integration

import { Composio } from '@composio/core';
import OpenAI from 'openai';

// Initialize Composio and OpenAI
const composio = new Composio({
  apiKey: 'your-composio-api-key',
});

const openai = new OpenAI({
  apiKey: 'your-openai-api-key',
});

// Get GitHub tools
const tools = await composio.tools.get('default', {
  toolkits: ['github'],
});


// Create a chat completion with the tools
const completion = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'system', content: 'You are a helpful assistant with access to GitHub tools.' },
    { role: 'user', content: 'Find information about the Composio SDK repository' },
  ],
  tools, // Pass the tools to OpenAI
});

// If the model wants to use a tool
if (completion.choices[0].message.tool_calls) {
  const toolCall = completion.choices[0].message.tool_calls[0];
  const args = JSON.parse(toolCall.function.arguments);

  // Execute the tool
  const result = await composio.tools.execute(toolCall.function.name, {
    userId: 'default',
    arguments: args,
  });

  console.log(result.data);
}

Creating Custom Tools

import { Composio, experimental_createTool } from '@composio/core';
import { z } from 'zod';

const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });

const weatherForecast = experimental_createTool('WEATHER_FORECAST', {
  name: 'Weather Forecast',
  description: 'Get the weather forecast for a location',
  inputParams: z.object({
    location: z.string().describe('The location to get the forecast for'),
    days: z.number().optional().default(3).describe('Number of days for the forecast'),
  }),
  execute: async (input) => {
    const { location, days = 3 } = input;
    const forecast = await getWeatherForecast(location, days);
    return { forecast };
  },
});

const session = await composio.create('default', {
  experimental: { customTools: [weatherForecast] },
});

const result = await session.execute('WEATHER_FORECAST', {
  location: 'San Francisco, CA',
});

Project Structure

composio/
├── packages/                  # Main packages directory
│   ├── core/                  # Core SDK package
│   └── providers/             # Provider implementations
├── examples/                  # Example implementations
│   ├── connected-accounts/    # Connected accounts examples
│   ├── langchain/            # LangChain integration examples
│   ├── openai/               # OpenAI integration examples
│   ├── modifiers/            # Modifiers examples
│   ├── toolkits/             # Toolkits examples
│   └── vercel/               # Vercel AI examples
├── docs/                      # Documentation
├── scripts/                   # Development and build scripts
└── .github/                   # GitHub configuration

Development Setup

  1. Prerequisites

    • Node.js (Latest LTS version recommended)
    • pnpm (v10.8.0 or later)
    • bun for productivity (optional)
  2. Clone and Install

    git clone https://github.com/ComposioHQ/sdk-v3-ts.git
    cd composio
    pnpm install
    
  3. Build

    pnpm build
    
  4. Development Commands

    # Lint code
    pnpm lint
    
    # Fix linting issues
    pnpm lint:fix
    
    # Format code
    pnpm format
    
    # Create a new provider
    pnpm create:provider <provider-name> [--agentic]
    
    # Create a new example
    pnpm create:example <example-name>
    
    # Check peer dependencies
    pnpm check:peer-deps
    
    # Update peer dependencies
    pnpm update:peer-deps
    

Creating a New Example

  1. Use the create:example script:

    pnpm create:example my-example
    
  2. The script will create a new example in examples/my-example with:

    • package.json with minimal dependencies (@composio/core and dotenv)
    • tsconfig.json for TypeScript configuration
    • .env.example and .env files for environment variables
    • src/index.ts with basic Composio SDK setup
    • README.md with setup and usage instructions
    • Dependencies automatically installed
  3. Next steps after creation:

    • Edit .env and add your COMPOSIO_API_KEY
    • Customize src/index.ts with your example logic
    • Add any additional dependencies as needed
    • Run with pnpm start or pnpm dev (with file watching)

Creating a New Provider

  1. Use the create:provider script:

    pnpm create:provider my-provider [--agentic]
    
  2. The script will create a new provider in packages/providers/my-provider with:

    • Basic provider implementation
    • TypeScript configuration
    • Package configuration
    • README template
  3. Implement the required methods in src/index.ts:

    • For non-agentic providers: wrapTool and wrapTools
    • For agentic providers: wrapTool, wrapTools, and execution handlers

Release Process

For detailed information about both automated and manual release processes, please refer to our Release Process Documentation.

Environment Variables

  • COMPOSIO_API_KEY: Your Composio API key
  • COMPOSIO_BASE_URL: Custom API base URL (optional)
  • COMPOSIO_LOG_LEVEL: Logging level (silent, error, warn, info, debug)
  • COMPOSIO_DISABLE_TELEMETRY: Disable telemetry when set to "true"
  • COMPOSIO_TOOLKIT_VERSION_<TOOLKIT_NAME>: Specific version for a toolkit (e.g., COMPOSIO_TOOLKIT_VERSION_GITHUB=20250902_00)
  • DEVELOPMENT: Development mode flag
  • CI: CI environment flag

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

License

ISC License

Support

For support, please visit our Documentation or join our Discord Community.