@composio/llamaindex 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,154 +1,18 @@
1
1
  # @composio/llamaindex
2
2
 
3
- Agentic Provider for Llamaindex in Composio SDK.
4
-
5
- ## Features
6
-
7
- - **Seamless LlamaIndex Integration**: Tools are automatically compatible with LlamaIndex agents and workflows
8
- - **Full Modifier Support**: Support for both schema and execution modifiers with beforeExecute/afterExecute hooks
9
- - **Streaming Support**: Works with LlamaIndex streaming agents using `agentStreamEvent`
10
- - **Tool Execution**: Execute tools with proper parameter handling and JSON schema validation
11
- - **Type Safety**: Full TypeScript support with proper type definitions
12
- - **Zod Schema Integration**: Automatic conversion from JSON Schema to Zod for LlamaIndex compatibility
3
+ The LlamaIndex provider turns Composio tools into LlamaIndex tools that execute themselves, ready to hand to a LlamaIndex agent.
13
4
 
14
5
  ## Installation
15
6
 
16
7
  ```bash
17
- npm install @composio/llamaindex
18
- # or
19
- yarn add @composio/llamaindex
20
- # or
21
- pnpm add @composio/llamaindex
22
- ```
23
-
24
- ## Quick Start
25
-
26
- ```typescript
27
- import { Composio } from '@composio/core';
28
- import { LlamaindexProvider } from '@composio/llamaindex';
29
-
30
- // Initialize Composio with Llamaindex provider
31
- const composio = new Composio({
32
- apiKey: 'your-composio-api-key',
33
- provider: new LlamaindexProvider(),
34
- });
35
-
36
- // Get available tools
37
- const tools = await composio.tools.get('user123', {
38
- toolkits: ['gmail', 'googlecalendar'],
39
- limit: 10,
40
- });
41
- ```
42
-
43
- ## Prerequisites
44
-
45
- Before using the LlamaIndex provider, make sure you have:
46
-
47
- 1. **Composio API Key**: Get your API key from [Composio Dashboard](https://app.composio.dev)
48
- 2. **Environment Setup**: Set up your environment variables
49
- 3. **LlamaIndex Dependencies**: Install required LlamaIndex packages
50
-
51
- ```bash
52
- # Install LlamaIndex dependencies
53
- npm install @llamaindex/openai @llamaindex/workflow
8
+ npm install @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
54
9
  ```
55
10
 
56
- ```bash
57
- # Set up environment variables
58
- export COMPOSIO_API_KEY="your-composio-api-key"
59
- export OPENAI_API_KEY="your-openai-api-key" # For LlamaIndex OpenAI integration
60
- ```
61
-
62
- ## Usage Examples
63
-
64
- ### Basic Example
65
-
66
- ```typescript
67
- import { Composio } from '@composio/core';
68
- import { LlamaindexProvider } from '@composio/llamaindex';
69
-
70
- // Initialize Composio
71
- const composio = new Composio({
72
- apiKey: process.env.COMPOSIO_API_KEY,
73
- provider: new LlamaindexProvider(),
74
- });
75
-
76
- // Get tools
77
- const tools = await composio.tools.get('default', {
78
- toolkits: ['gmail'],
79
- limit: 10,
80
- });
81
-
82
- console.log(`Found ${tools.length} tools`);
83
- ```
84
-
85
- ### Complete Agent Example with HackerNews
86
-
87
- ```typescript
88
- import { Composio } from '@composio/core';
89
- import { LlamaindexProvider } from '@composio/llamaindex';
90
- import { openai } from '@llamaindex/openai';
91
- import { agent, agentStreamEvent } from '@llamaindex/workflow';
92
- import 'dotenv/config';
93
-
94
- // Initialize Composio with LlamaIndex provider
95
- const composio = new Composio({
96
- apiKey: process.env.COMPOSIO_API_KEY,
97
- provider: new LlamaindexProvider(),
98
- });
99
-
100
- async function main() {
101
- try {
102
- console.log('🚀 Starting LlamaIndex Example...');
103
-
104
- // Get available tools with modifiers
105
- const tools = await composio.tools.get(
106
- 'default',
107
- {
108
- toolkits: ['hackernews'],
109
- limit: 10,
110
- },
111
- {
112
- beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
113
- console.log(`🔄 Executing tool ${toolSlug}/${toolkitSlug} with params:`, { params });
114
- return params;
115
- },
116
- afterExecute: ({ toolSlug, toolkitSlug, result }) => {
117
- console.log(`✅ Executed tool ${toolSlug}/${toolkitSlug} with result:`, { result });
118
- return result;
119
- },
120
- }
121
- );
122
-
123
- console.log(`✅ Found ${tools.length} tools`);
11
+ Set `COMPOSIO_API_KEY` with your API key from [the dashboard](https://dashboard.composio.dev/settings), and `OPENAI_API_KEY` (or your LLM provider's key).
124
12
 
125
- // Create LlamaIndex agent with Composio tools
126
- const hackernewsAgent = agent({
127
- name: 'Hackernews Agent',
128
- description: 'A helpful hackernews assistant',
129
- llm: openai({ model: 'gpt-4o-mini' }),
130
- systemPrompt:
131
- 'You are a helpful hackernews assistant that helps users with their queries related to hackernews',
132
- tools, // Composio tools are automatically compatible with LlamaIndex
133
- });
13
+ ## Quickstart
134
14
 
135
- // Run the agent with streaming
136
- const stream = await hackernewsAgent.runStream('Summarize the front page of hackernews');
137
-
138
- for await (const event of stream) {
139
- if (agentStreamEvent.include(event)) {
140
- process.stdout.write(event.data.delta);
141
- }
142
- }
143
- } catch (error) {
144
- console.error('❌ Error running example:', error);
145
- }
146
- }
147
-
148
- main().catch(console.error);
149
- ```
150
-
151
- ### Using Tools with Different Toolkits
15
+ Create a session for your user, fetch its tools, and hand them to an agent:
152
16
 
153
17
  ```typescript
154
18
  import { Composio } from '@composio/core';
@@ -157,87 +21,28 @@ import { openai } from '@llamaindex/openai';
157
21
  import { agent } from '@llamaindex/workflow';
158
22
 
159
23
  const composio = new Composio({
160
- apiKey: process.env.COMPOSIO_API_KEY,
161
24
  provider: new LlamaindexProvider(),
162
25
  });
163
26
 
164
- // Get tools from multiple toolkits
165
- const tools = await composio.tools.get('default', {
166
- toolkits: ['gmail', 'googlecalendar', 'slack'],
167
- limit: 20,
168
- });
27
+ // Create a session for your user
28
+ const session = await composio.create('user_123');
29
+ const tools = await session.tools();
169
30
 
170
- // Create a multi-purpose agent
171
- const assistantAgent = agent({
172
- name: 'Personal Assistant',
173
- description: 'A helpful personal assistant',
174
- llm: openai({ model: 'gpt-4' }),
175
- systemPrompt:
176
- 'You are a helpful personal assistant that can manage emails, calendar events, and slack messages.',
31
+ const myAgent = agent({
32
+ llm: openai({ model: 'gpt-5.2' }),
177
33
  tools,
178
34
  });
179
35
 
180
- // Use the agent
181
- const response = await assistantAgent.run(
182
- 'Schedule a meeting for tomorrow at 2 PM and send a slack message about it'
36
+ const result = await myAgent.run(
37
+ "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
183
38
  );
184
- console.log(response);
185
- ```
186
-
187
- ## API Reference
188
-
189
- ### LlamaindexProvider Class
190
-
191
- The `LlamaindexProvider` class extends `BaseAgenticProvider` and provides llamaindex-specific functionality.
192
-
193
- #### Methods
194
39
 
195
- ##### `wrapTool(tool: Tool, executeTool: ExecuteToolFn): LlamaindexTool`
196
-
197
- Wraps a single Composio tool in the LlamaIndex format with proper Zod schema conversion.
198
-
199
- ```typescript
200
- const llamaindexTool = provider.wrapTool(composioTool, executeTool);
201
-
202
- // The wrapped tool has LlamaIndex-compatible structure:
203
- // - metadata.name: Tool slug
204
- // - metadata.description: Tool description
205
- // - metadata.parameters: Zod schema for parameters
206
- // - call(): Function to execute the tool
40
+ console.log(result.data.result);
207
41
  ```
208
42
 
209
- ##### `wrapTools(tools: Tool[], executeTool: ExecuteToolFn): LlamaindexTool[]`
210
-
211
- Wraps multiple Composio tools for use with LlamaIndex agents.
212
-
213
- ```typescript
214
- const llamaindexTools = provider.wrapTools(composioTools, executeTool);
215
-
216
- // Use directly with LlamaIndex agents
217
- const agent = agent({
218
- name: 'My Agent',
219
- llm: openai({ model: 'gpt-4' }),
220
- tools: llamaindexTools, // Ready to use!
221
- });
222
- ```
223
-
224
- ##### `wrapMcpServerResponse(data: McpUrlResponse): McpServerGetResponse`
225
-
226
- Transforms MCP URL responses into the standard format with URL objects.
227
-
228
- ```typescript
229
- const mcpServers = provider.wrapMcpServerResponse(urlResponse);
230
- // Returns: [{ url: URL, name: string }, ...]
231
- ```
232
-
233
- ## Contributing
234
-
235
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
236
-
237
- ## License
238
-
239
- ISC License
43
+ The provider converts each tool's JSON Schema parameters to Zod and wires execution through Composio, so LlamaIndex can call the tools directly.
240
44
 
241
- ## Support
45
+ ## Links
242
46
 
243
- For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
47
+ - [LlamaIndex provider docs](https://docs.composio.dev/docs/providers/llamaindex)
48
+ - [Composio documentation](https://docs.composio.dev)
package/dist/index.d.mts CHANGED
@@ -19,9 +19,9 @@ declare class LlamaindexProvider extends BaseAgenticProvider<Array<LlamaindexToo
19
19
  */
20
20
  wrapTools(tools: Tool[], executeTool: ExecuteToolFn): LlamaindexToolCollection;
21
21
  /**
22
- * Transform MCP URL response into Anthropic-specific format.
23
- * By default, Anthropic uses the standard format (same as default),
24
- * but this method is here to show providers can customize if needed.
22
+ * Transform an MCP URL response into the LlamaIndex provider's format.
23
+ * LlamaIndex uses the standard MCP server response shape, mapping each
24
+ * entry to an object with a `URL` instance and its name.
25
25
  *
26
26
  * @param data - The MCP URL response data
27
27
  * @returns Standard MCP server response format
package/dist/index.mjs CHANGED
@@ -39,9 +39,9 @@ var LlamaindexProvider = class extends BaseAgenticProvider {
39
39
  return tools.map((tool) => this.wrapTool(tool, executeTool));
40
40
  }
41
41
  /**
42
- * Transform MCP URL response into Anthropic-specific format.
43
- * By default, Anthropic uses the standard format (same as default),
44
- * but this method is here to show providers can customize if needed.
42
+ * Transform an MCP URL response into the LlamaIndex provider's format.
43
+ * LlamaIndex uses the standard MCP server response shape, mapping each
44
+ * entry to an object with a `URL` instance and its name.
45
45
  *
46
46
  * @param data - The MCP URL response data
47
47
  * @returns Standard MCP server response format
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/llamaindex",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Agentic Provider for llamaindex in Composio SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/ComposioHQ/composio/issues"
14
14
  },
15
- "homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/llamaindex#readme",
15
+ "homepage": "https://github.com/ComposioHQ/composio/tree/next/ts/packages/providers/llamaindex#readme",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "tsdown": "^0.22.3",
42
42
  "typescript": "^6.0.3",
43
- "@composio/core": "0.12.0"
43
+ "@composio/core": "0.14.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsdown",