Providers

LlamaIndex Provider

Use Composio tools with LlamaIndex

The LlamaIndex Provider transforms Composio tools into a format compatible with LlamaIndex's function calling capabilities.

Setup

pip install composio_llamaindex==0.8.0 llama-index
npm install @composio/llamaindex @llamaindex/openai @llamaindex/workflow

Usage

import asyncio
import dotenv
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

from composio import Composio

# Load environment variables from .env
dotenv.load_dotenv()

# Setup client
llm = OpenAI(model="gpt-5")
composio = Composio(provider=LlamaIndexProvider())

tools = composio.tools.get(
    user_id="user@acme.com",
    tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],
)

workflow = FunctionAgent(
    tools=tools,
    llm=llm,
    system_prompt="You are an agent that performs github actions.",
)


async def main():
    result = await workflow.run(
        user_msg="Hello! I would like to star a repo composiohq/composio on GitHub"
    )
    print(result)


if __name__ == "__main__":
    asyncio.run(main())
import { class Composio<TProvider extends BaseComposioProvider<unknown, unknown, unknown> = OpenAIProvider>
This is the core class for Composio. It is used to initialize the Composio SDK and provide a global configuration.
Composio
} from '@composio/core';
import { class LlamaindexProviderLlamaindexProvider } from '@composio/llamaindex'; import { const openai: (init?: ConstructorParameters<typeof OpenAI>[0]) => OpenAI
Convenience function to create a new OpenAI instance.
@paraminit - Optional initialization parameters for the OpenAI instance.@returnsA new OpenAI instance.
openai
} from '@llamaindex/openai';
import { const agent: (params: SingleAgentParams) => AgentWorkflow
Create a simple workflow with a single agent and specified tools
@paramparams - Parameters for the single agent workflow@returnsA new AgentWorkflow instance
agent
} from '@llamaindex/workflow';
import 'dotenv/config'; // Initialize Composio with LlamaIndex provider const const composio: Composio<LlamaindexProvider>composio = new new Composio<LlamaindexProvider>(config?: ComposioConfig<LlamaindexProvider> | undefined): Composio<LlamaindexProvider>
Creates a new instance of the Composio SDK. The constructor initializes the SDK with the provided configuration options, sets up the API client, and initializes all core models (tools, toolkits, etc.).
@paramconfig - Configuration options for the Composio SDK@paramconfig.apiKey - The API key for authenticating with the Composio API@paramconfig.baseURL - The base URL for the Composio API (defaults to production URL)@paramconfig.allowTracking - Whether to allow anonymous usage analytics@paramconfig.provider - The provider to use for this Composio instance (defaults to OpenAIProvider)@example```typescript // Initialize with default configuration const composio = new Composio(); // Initialize with custom API key and base URL const composio = new Composio({ apiKey: 'your-api-key', baseURL: 'https://api.composio.dev' }); // Initialize with custom provider const composio = new Composio({ apiKey: 'your-api-key', provider: new CustomProvider() }); ```
Composio
({
apiKey?: string | null | undefined
The API key for the Composio API.
@example'sk-1234567890'
apiKey
: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedCOMPOSIO_API_KEY,
provider?: LlamaindexProvider | undefined
The tool provider to use for this Composio instance.
@examplenew OpenAIProvider()
provider
: new new LlamaindexProvider<FunctionTool<unknown, JSONValue | Promise<JSONValue>, object>[], FunctionTool<unknown, JSONValue | Promise<JSONValue>, object>, McpServerGetResponse>(): LlamaindexProviderLlamaindexProvider(),
}); async function function main(): Promise<void>main() { // Get tools const const tools: LlamaindexToolCollectiontools = await const composio: Composio<LlamaindexProvider>composio.Composio<LlamaindexProvider>.tools: Tools<unknown, unknown, LlamaindexProvider>
List, retrieve, and execute tools
tools
.Tools<unknown, unknown, LlamaindexProvider>.get<LlamaindexProvider>(userId: string, filters: ToolListParams, options?: AgenticToolOptions | undefined): Promise<LlamaindexToolCollection> (+1 overload)
Get a list of tools from Composio based on filters. This method fetches the tools from the Composio API and wraps them using the provider.
@paramuserId - The user id to get the tools for@paramfilters - The filters to apply when fetching tools@paramoptions - Optional provider options including modifiers@returnsThe wrapped tools collection@example```typescript // Get tools from the GitHub toolkit const tools = await composio.tools.get('default', { toolkits: ['github'], limit: 10 }); // Get tools with search const searchTools = await composio.tools.get('default', { search: 'user', limit: 10 }); // Get a specific tool by slug const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER'); // Get a tool with schema modifications const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', { modifySchema: (toolSlug, toolkitSlug, schema) => { // Customize the tool schema return {...schema, description: 'Custom description'}; } }); ```
get
('user@acme.com', {
tools: string[]tools: ['GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER'], }); // Create LlamaIndex agent with Composio tools const const githubAgent: AgentWorkflowgithubAgent = function agent(params: SingleAgentParams): AgentWorkflow
Create a simple workflow with a single agent and specified tools
@paramparams - Parameters for the single agent workflow@returnsA new AgentWorkflow instance
agent
({
name?: string | undefined
Agent name
name
: 'GitHub Agent',
description?: string | undefined
Description of the agent, useful for task assignment. Should provide the capabilities or responsibilities of the agent.
description
: 'An agent that performs GitHub actions',
llm?: ToolCallLLM<object, ToolCallLLMMessageOptions> | undefined
LLM to use for the agent, required.
llm
: function openai(init?: ConstructorParameters<typeof OpenAI>[0]): OpenAI
Convenience function to create a new OpenAI instance.
@paraminit - Optional initialization parameters for the OpenAI instance.@returnsA new OpenAI instance.
openai
({ model?: ChatModel | (string & {}) | undefinedmodel: 'gpt-4o-mini' }),
systemPrompt?: string | undefined
Custom system prompt for the agent
systemPrompt
: 'You are an agent that performs github actions.',
tools?: BaseToolWithCall[] | undefined
List of tools that the agent can use, requires at least one tool.
tools
,
}); // Run the agent const const result: WorkflowEventData<AgentResultData<any>>result = await const githubAgent: AgentWorkflowgithubAgent.
AgentWorkflow.run<ZodSchema>(userInput: MessageContent, params?: {
    chatHistory?: ChatMessage[];
    state?: AgentWorkflowState;
    responseFormat?: ZodSchema | undefined;
} | undefined): Promise<WorkflowEventData<AgentResultData<any>>>
run
(
'Hello! I would like to star a repo composiohq/composio on GitHub' ); var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(const result: WorkflowEventData<AgentResultData<any>>result);
} function main(): Promise<void>main().Promise<void>.catch<void>(onrejected?: ((reason: any) => void | PromiseLike<void>) | null | undefined): Promise<void>
Attaches a callback for only the rejection of the Promise.
@paramonrejected The callback to execute when the Promise is rejected.@returnsA Promise for the completion of the callback.
catch
(var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.error(...data: any[]): void (+1 overload)
The **`console.error()`** static method outputs a message to the console at the 'error' log level. [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
error
);

Advanced Usage

Streaming Agent with Multiple Toolkits

import { class Composio<TProvider extends BaseComposioProvider<unknown, unknown, unknown> = OpenAIProvider>
This is the core class for Composio. It is used to initialize the Composio SDK and provide a global configuration.
Composio
} from '@composio/core';
import { class LlamaindexProviderLlamaindexProvider } from '@composio/llamaindex'; import { const openai: (init?: ConstructorParameters<typeof OpenAI>[0]) => OpenAI
Convenience function to create a new OpenAI instance.
@paraminit - Optional initialization parameters for the OpenAI instance.@returnsA new OpenAI instance.
openai
} from '@llamaindex/openai';
import { const agent: (params: SingleAgentParams) => AgentWorkflow
Create a simple workflow with a single agent and specified tools
@paramparams - Parameters for the single agent workflow@returnsA new AgentWorkflow instance
agent
,
const agentStreamEvent: WorkflowEvent<{
    delta: string;
    response: string;
    currentAgentName: string;
    raw: unknown;
}, string>
agentStreamEvent
} from '@llamaindex/workflow';
import 'dotenv/config'; const const composio: Composio<LlamaindexProvider>composio = new new Composio<LlamaindexProvider>(config?: ComposioConfig<LlamaindexProvider> | undefined): Composio<LlamaindexProvider>
Creates a new instance of the Composio SDK. The constructor initializes the SDK with the provided configuration options, sets up the API client, and initializes all core models (tools, toolkits, etc.).
@paramconfig - Configuration options for the Composio SDK@paramconfig.apiKey - The API key for authenticating with the Composio API@paramconfig.baseURL - The base URL for the Composio API (defaults to production URL)@paramconfig.allowTracking - Whether to allow anonymous usage analytics@paramconfig.provider - The provider to use for this Composio instance (defaults to OpenAIProvider)@example```typescript // Initialize with default configuration const composio = new Composio(); // Initialize with custom API key and base URL const composio = new Composio({ apiKey: 'your-api-key', baseURL: 'https://api.composio.dev' }); // Initialize with custom provider const composio = new Composio({ apiKey: 'your-api-key', provider: new CustomProvider() }); ```
Composio
({
apiKey?: string | null | undefined
The API key for the Composio API.
@example'sk-1234567890'
apiKey
: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedCOMPOSIO_API_KEY,
provider?: LlamaindexProvider | undefined
The tool provider to use for this Composio instance.
@examplenew OpenAIProvider()
provider
: new new LlamaindexProvider<FunctionTool<unknown, JSONValue | Promise<JSONValue>, object>[], FunctionTool<unknown, JSONValue | Promise<JSONValue>, object>, McpServerGetResponse>(): LlamaindexProviderLlamaindexProvider(),
}); async function function streamingExample(): Promise<void>streamingExample() { // Get tools from multiple toolkits with execution modifiers const const tools: LlamaindexToolCollectiontools = await const composio: Composio<LlamaindexProvider>composio.Composio<LlamaindexProvider>.tools: Tools<unknown, unknown, LlamaindexProvider>
List, retrieve, and execute tools
tools
.Tools<unknown, unknown, LlamaindexProvider>.get<LlamaindexProvider>(userId: string, filters: ToolListParams, options?: AgenticToolOptions | undefined): Promise<LlamaindexToolCollection> (+1 overload)
Get a list of tools from Composio based on filters. This method fetches the tools from the Composio API and wraps them using the provider.
@paramuserId - The user id to get the tools for@paramfilters - The filters to apply when fetching tools@paramoptions - Optional provider options including modifiers@returnsThe wrapped tools collection@example```typescript // Get tools from the GitHub toolkit const tools = await composio.tools.get('default', { toolkits: ['github'], limit: 10 }); // Get tools with search const searchTools = await composio.tools.get('default', { search: 'user', limit: 10 }); // Get a specific tool by slug const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER'); // Get a tool with schema modifications const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', { modifySchema: (toolSlug, toolkitSlug, schema) => { // Customize the tool schema return {...schema, description: 'Custom description'}; } }); ```
get
(
'default', { toolkits: [string, string, string]toolkits: ['gmail', 'googlecalendar', 'slack'], limit: numberlimit: 20, }, { beforeExecute?: beforeExecuteModifier | undefined
Function to intercept and modify tool execution parameters before the tool is executed. This allows customizing the request based on tool-specific needs.
beforeExecute
: ({ toolSlug: stringtoolSlug,
params: {
    version?: string | undefined;
    allowTracing?: boolean | undefined;
    connectedAccountId?: string | undefined;
    customAuthParams?: {
        parameters: {
            name: string;
            value: string | number;
            in: "query" | "header";
        }[];
        baseURL?: string | undefined;
        body?: Record<string, unknown> | undefined;
    } | undefined;
    customConnectionData?: {
        authScheme: "OAUTH2";
        val: {
            access_token: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
            webhook_signature?: string | undefined;
            id_token?: string | undefined;
            token_type?: string | undefined;
            refresh_token?: string | null | undefined;
            expires_in?: string | number | null | undefined;
            scope?: string | string[] | null | undefined;
            authed_user?: {
                access_token?: string | undefined;
                scope?: string | undefined;
            } | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "DCR_OAUTH";
        val: {
            access_token: string;
            client_id: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "API_KEY";
        val: {
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name ...
params
}) => {
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`🔄 Executing ${toolSlug: stringtoolSlug} with:`,
params: {
    version?: string | undefined;
    allowTracing?: boolean | undefined;
    connectedAccountId?: string | undefined;
    customAuthParams?: {
        parameters: {
            name: string;
            value: string | number;
            in: "query" | "header";
        }[];
        baseURL?: string | undefined;
        body?: Record<string, unknown> | undefined;
    } | undefined;
    customConnectionData?: {
        authScheme: "OAUTH2";
        val: {
            access_token: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
            webhook_signature?: string | undefined;
            id_token?: string | undefined;
            token_type?: string | undefined;
            refresh_token?: string | null | undefined;
            expires_in?: string | number | null | undefined;
            scope?: string | string[] | null | undefined;
            authed_user?: {
                access_token?: string | undefined;
                scope?: string | undefined;
            } | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "DCR_OAUTH";
        val: {
            access_token: string;
            client_id: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "API_KEY";
        val: {
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name ...
params
);
return
params: {
    version?: string | undefined;
    allowTracing?: boolean | undefined;
    connectedAccountId?: string | undefined;
    customAuthParams?: {
        parameters: {
            name: string;
            value: string | number;
            in: "query" | "header";
        }[];
        baseURL?: string | undefined;
        body?: Record<string, unknown> | undefined;
    } | undefined;
    customConnectionData?: {
        authScheme: "OAUTH2";
        val: {
            access_token: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
            webhook_signature?: string | undefined;
            id_token?: string | undefined;
            token_type?: string | undefined;
            refresh_token?: string | null | undefined;
            expires_in?: string | number | null | undefined;
            scope?: string | string[] | null | undefined;
            authed_user?: {
                access_token?: string | undefined;
                scope?: string | undefined;
            } | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "DCR_OAUTH";
        val: {
            access_token: string;
            client_id: string;
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name?: string | undefined;
            instanceName?: string | undefined;
            account_id?: string | undefined;
            your_server?: string | undefined;
            server_location?: string | undefined;
            base_url?: string | undefined;
            api_key?: string | undefined;
            generic_api_key?: string | undefined;
            bearer_token?: string | undefined;
            basic_encoded?: string | undefined;
            long_redirect_url?: boolean | undefined;
            state_prefix?: string | undefined;
            registration_access_token?: string | undefined;
            registration_client_uri?: string | undefined;
            composio_link_redirect_url?: string | undefined;
        } & {
            [k: string]: unknown;
        };
        toolkitSlug: string;
    } | {
        authScheme: "API_KEY";
        val: {
            version?: string | undefined;
            "your-domain"?: string | undefined;
            subdomain?: string | undefined;
            region?: string | undefined;
            shop?: string | undefined;
            account_url?: string | undefined;
            COMPANYDOMAIN?: string | undefined;
            extension?: string | undefined;
            form_api_base_url?: string | undefined;
            instanceEndpoint?: string | undefined;
            api_url?: string | undefined;
            borneo_dashboard_url?: string | undefined;
            proxy_username?: string | undefined;
            proxy_password?: string | undefined;
            domain?: string | undefined;
            dc?: string | undefined;
            site_name ...
params
;
}, afterExecute?: afterExecuteModifier | undefined
Function to intercept and modify tool execution responses after the tool has executed. This allows transforming the response or implementing custom error handling.
afterExecute
: ({ toolSlug: stringtoolSlug,
result: {
    error: string | null;
    data: Record<string, unknown>;
    successful: boolean;
    logId?: string | undefined;
    sessionInfo?: unknown;
}
result
}) => {
var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`✅ ${toolSlug: stringtoolSlug} completed:`,
result: {
    error: string | null;
    data: Record<string, unknown>;
    successful: boolean;
    logId?: string | undefined;
    sessionInfo?: unknown;
}
result
);
return
result: {
    error: string | null;
    data: Record<string, unknown>;
    successful: boolean;
    logId?: string | undefined;
    sessionInfo?: unknown;
}
result
;
}, } ); // Create streaming agent const const assistantAgent: AgentWorkflowassistantAgent = function agent(params: SingleAgentParams): AgentWorkflow
Create a simple workflow with a single agent and specified tools
@paramparams - Parameters for the single agent workflow@returnsA new AgentWorkflow instance
agent
({
name?: string | undefined
Agent name
name
: 'Personal Assistant',
description?: string | undefined
Description of the agent, useful for task assignment. Should provide the capabilities or responsibilities of the agent.
description
: 'A helpful personal assistant',
llm?: ToolCallLLM<object, ToolCallLLMMessageOptions> | undefined
LLM to use for the agent, required.
llm
: function openai(init?: ConstructorParameters<typeof OpenAI>[0]): OpenAI
Convenience function to create a new OpenAI instance.
@paraminit - Optional initialization parameters for the OpenAI instance.@returnsA new OpenAI instance.
openai
({ model?: ChatModel | (string & {}) | undefinedmodel: 'gpt-4o-mini' }),
systemPrompt?: string | undefined
Custom system prompt for the agent
systemPrompt
: 'You are a helpful personal assistant that can manage emails, calendar events, and slack messages.',
tools?: BaseToolWithCall[] | undefined
List of tools that the agent can use, requires at least one tool.
tools
,
}); // Stream the response const const stream: WorkflowStream<WorkflowEventData<AgentResultData<any>>>stream = await const assistantAgent: AgentWorkflowassistantAgent.
AgentWorkflow.runStream<ZodSchema>(userInput: MessageContent, params?: {
    chatHistory?: ChatMessage[];
    state?: AgentWorkflowState;
    responseFormat?: ZodSchema | undefined;
} | undefined): WorkflowStream<WorkflowEventData<AgentResultData<any>>>
runStream
(
'Schedule a meeting for tomorrow at 2 PM and send a slack message about it' ); for await (const const event: WorkflowEventData<AgentResultData<any>>event of const stream: WorkflowStream<WorkflowEventData<AgentResultData<any>>>stream) { if (
const agentStreamEvent: WorkflowEvent<{
    delta: string;
    response: string;
    currentAgentName: string;
    raw: unknown;
}, string>
agentStreamEvent
.
function include(event: unknown): event is WorkflowEventData<{
    delta: string;
    response: string;
    currentAgentName: string;
    raw: unknown;
}, string>
Type guard to check if unknown event data belongs to this event type.
@paramevent - Unknown event data to check@returnsTrue if the event data is of this event type
include
(const event: WorkflowEventData<AgentResultData<any>>event)) {
var process: NodeJS.Processprocess.
NodeJS.Process.stdout: NodeJS.WriteStream & {
    fd: 1;
}
The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is a `Writable` stream. For example, to copy `process.stdin` to `process.stdout`: ```js import { stdin, stdout } from 'node:process'; stdin.pipe(stdout); ``` `process.stdout` differs from other Node.js streams in important ways. See `note on process I/O` for more information.
stdout
.Socket.write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean (+1 overload)
Sends data on the socket. The second parameter specifies the encoding in the case of a string. It defaults to UTF8 encoding. Returns `true` if the entire data was flushed successfully to the kernel buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free. The optional `callback` parameter will be executed when the data is finally written out, which may not be immediately. See `Writable` stream `write()` method for more information.
@sincev0.1.90@paramencoding Only used when data is `string`.
write
(
const event: {
    readonly data: AgentResultData<any>;
} & {
    readonly [opaqueSymbol]: string;
} & {
    readonly data: {
        delta: string;
        response: string;
        currentAgentName: string;
        raw: unknown;
    };
}
event
.
data: AgentResultData<any> & {
    delta: string;
    response: string;
    currentAgentName: string;
    raw: unknown;
}
data
.delta: stringdelta);
} } } function streamingExample(): Promise<void>streamingExample().Promise<void>.catch<void>(onrejected?: ((reason: any) => void | PromiseLike<void>) | null | undefined): Promise<void>
Attaches a callback for only the rejection of the Promise.
@paramonrejected The callback to execute when the Promise is rejected.@returnsA Promise for the completion of the callback.
catch
(var console: Console
The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
@see[source](https://github.com/nodejs/node/blob/v24.x/lib/console.js)
console
.Console.error(...data: any[]): void (+1 overload)
The **`console.error()`** static method outputs a message to the console at the 'error' log level. [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
error
);