@devries-cameron20 / composio-1 / commits / 09d736fef
Fork 0

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

Update examp-les

haxzie committed May 29, 2025 at 10:52 UTC 09d736fefea7eaccad703939cc336ff6559f9914
2 files changed +67 -5
examples/toolkits/src/index.ts
+12 -2
@@ -2,5 +2,15 @@ import { Composio } from '@composio/core';
2
3 const composio = new Composio();
4
5 -const toolkit = await composio.tools.get('default', 'INvalid tool');
6 -// const client = composio.getClient();
5 +const toolkit = await composio.toolkits.get('gmail');
6 +console.log(toolkit);
7 +
8 +const connectionRequest = await composio.toolkits.authorize('default', 'gmail');
9 +console.log(connectionRequest.toJSON());
10 +
11 +const redirectURL = connectionRequest.redirectUrl;
12 +console.log(`Please visit the following URL to authorize the toolkit: ${redirectURL}`);
13 +
14 +const connectedAccount = await connectionRequest.waitForConnection();
15 +
16 +console.log(connectedAccount);
packages/providers/anthropic/README.md
+55 -3
@@ -208,7 +208,7 @@ const tools = provider.wrapTools(composioTools);
208 Executes a tool call from Anthropic and returns the result as a string.
209
210 ```typescript
211 -const result = await provider.executeToolCall(
211 +const result = await composio.provider.executeToolCall(
212 'user123',
213 {
214 type: 'tool_use',
@@ -231,10 +231,62 @@ const result = await provider.executeToolCall(
231
232 ##### `handleToolCalls(userId: string, message: Message, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string[]>`
233
234 -Handles tool calls from an Anthropic message response.
234 +Processes and executes all tool calls found in an Anthropic message response. This method automatically extracts tool calls from the message content, executes them, and returns their results.
235 +
236 +**Parameters:**
237 +
238 +- `userId` (string): The ID of the user making the tool calls
239 +- `message` (Message): The Anthropic message response containing tool calls
240 +- `options` (optional): Additional options for tool execution
241 + - `connectedAccountId`: ID of the connected account
242 + - `customAuthParams`: Custom authentication parameters
243 +- `modifiers` (optional): Functions to modify tool execution
244 + - `beforeExecute`: Transform parameters before execution
245 + - `afterExecute`: Transform response after execution
246 +
247 +**Returns:**
248 +Promise<string[]>: Array of JSON-stringified results from each tool execution
249 +
250 +**Example:**
251
252 ```typescript
237 -const results = await provider.handleToolCalls('user123', message, options, modifiers);
253 +const message = {
254 + id: 'msg_123',
255 + content: [
256 + { type: 'text', text: 'Hello' },
257 + {
258 + type: 'tool_use',
259 + id: 'tu_123',
260 + name: 'test-tool',
261 + input: { param: 'value' },
262 + },
263 + {
264 + type: 'tool_use',
265 + id: 'tu_456',
266 + name: 'another-tool',
267 + input: { param: 'value2' },
268 + },
269 + ],
270 +};
271 +
272 +const results = await provider.handleToolCalls(
273 + 'user123',
274 + message,
275 + {
276 + connectedAccountId: 'account123',
277 + customAuthParams: {
278 + parameters: [{ name: 'token', value: 'abc123', in: 'header' }],
279 + },
280 + },
281 + {
282 + beforeExecute: params => params,
283 + afterExecute: response => response,
284 + }
285 +);
286 +
287 +// results will be an array of stringified JSON responses
288 +// from each tool execution in the order they appeared
289 +// in the message content
290 ```
291
292 ## Contributing