@devries-cameron20 / composio Mirror · read-only
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 06:00 UTC

next
md 77 lines 2.9 KB
Rendered Raw
1 # Composio Core Files - Cloudflare Workers E2E Test
2
3 This package tests `@composio/core` file operations in Cloudflare Workers environment.
4
5 ## Purpose
6
7 Verifies that:
8 1. `composio.files.upload()` throws the expected "not supported in Cloudflare Workers" error
9 2. `composio.files.download()` throws the expected "not supported in Cloudflare Workers" error
10 3. The `FileToolModifier.workerd.ts` is correctly loaded and surfaces the expected error from `composio.tools.execute()` when `dangerouslyAllowAutoUploadDownloadFiles` is explicitly enabled (covered directly in `test/files.spec.ts`, not via an endpoint)
11 4. Composio initializes correctly with the default configuration (`dangerouslyAllowAutoUploadDownloadFiles: false` in workerd runtime)
12 5. Composio can be explicitly initialized with `dangerouslyAllowAutoUploadDownloadFiles: false`
13
14 ## Endpoints
15
16 | Endpoint | Description |
17 |----------|-------------|
18 | `GET /` | Lists all available test endpoints |
19 | `GET /test/files/upload` | Tests that `files.upload()` throws the expected error |
20 | `GET /test/files/download` | Tests that `files.download()` throws the expected error |
21 | `GET /test/auto-upload-disabled` | Tests Composio initialization with explicit `dangerouslyAllowAutoUploadDownloadFiles: false` |
22 | `GET /test/default-config` | Tests Composio initialization with default configuration (no explicit setting) |
23
24 ## Running Tests
25
26 ```bash
27 # From the package directory
28 pnpm test:e2e
29
30 # Or from the monorepo root
31 pnpm --filter @e2e-tests/cf-workers-files test:e2e:cloudflare
32 ```
33
34 ## Environment Variables
35
36 Copy `.env.example` to `.env` and set your API key:
37
38 ```bash
39 COMPOSIO_API_KEY=your-composio-api-key
40 ```
41
42 Note: For file operation tests, a dummy API key works since the operations throw errors before making API calls.
43
44 ## Default Configuration
45
46 **In Cloudflare Workers (workerd runtime), `dangerouslyAllowAutoUploadDownloadFiles` defaults to `false`.**
47
48 This means you can initialize Composio without any special configuration:
49
50 ```typescript
51 const composio = new Composio({
52 apiKey: 'your-key',
53 });
54 // dangerouslyAllowAutoUploadDownloadFiles is false by default in workerd
55 ```
56
57 ## FileToolModifier Error
58
59 If you explicitly set `dangerouslyAllowAutoUploadDownloadFiles: true` and execute a tool with file properties in Cloudflare Workers, the following error is thrown:
60
61 ```
62 File upload/download modifiers are not available on edge runtimes yet.
63 Please set `dangerouslyAllowAutoUploadDownloadFiles: false` (or unset it; it defaults to false) or run Composio in another JS runtime (Node.js / Bun).
64 ```
65
66 ### Best Practice
67
68 For edge runtimes, use the default configuration or explicitly set `dangerouslyAllowAutoUploadDownloadFiles: false`:
69
70 ```typescript
71 const composio = new Composio({
72 apiKey: 'your-key',
73 dangerouslyAllowAutoUploadDownloadFiles: false, // This is the default for workerd
74 });
75 ```
76
77 Note that with this configuration, file upload/download operations will not be automatically handled.