composio-sdk 0.2.0

Minimal Rust SDK for Composio Tool Router REST API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# Arquitetura do Sistema de Arquivos


## ๐Ÿ—๏ธ Visรฃo Geral da Arquitetura


```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         USUรRIO / AGENTE IA                      โ”‚
โ”‚  "Envie este relatรณrio.pdf por email para cliente@empresa.com"  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      COMPOSIO SDK (Rust)                         โ”‚
โ”‚                                                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚ FileHelper                                               โ”‚   โ”‚
โ”‚  โ”‚ - Processa schemas de ferramentas                        โ”‚   โ”‚
โ”‚  โ”‚ - Identifica campos file_uploadable/file_downloadable   โ”‚   โ”‚
โ”‚  โ”‚ - Transforma schemas para formato simples               โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                             โ”‚                                     โ”‚
โ”‚                             โ–ผ                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚ FileUploadable                                           โ”‚   โ”‚
โ”‚  โ”‚ - from_path(): Upload de arquivo local                  โ”‚   โ”‚
โ”‚  โ”‚ - from_url(): Upload de URL pรบblica                     โ”‚   โ”‚
โ”‚  โ”‚ - Calcula MD5 hash                                       โ”‚   โ”‚
โ”‚  โ”‚ - Detecta MIME type                                      โ”‚   โ”‚
โ”‚  โ”‚ - Valida tamanho e permissรตes                           โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                             โ”‚                                     โ”‚
โ”‚                             โ–ผ                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚ HTTP Client (reqwest)                                    โ”‚   โ”‚
โ”‚  โ”‚ - POST /api/v3/files/upload/request                     โ”‚   โ”‚
โ”‚  โ”‚ - Recebe presigned URL do S3                            โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    COMPOSIO BACKEND API                          โ”‚
โ”‚                                                                   โ”‚
โ”‚  1. Valida API key                                               โ”‚
โ”‚  2. Verifica MD5 hash (deduplicaรงรฃo)                            โ”‚
โ”‚  3. Gera presigned URL do S3                                    โ”‚
โ”‚  4. Retorna: { id, key, type, new_presigned_url }              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      AMAZON S3 STORAGE                           โ”‚
โ”‚                                                                   โ”‚
โ”‚  - Recebe arquivo via PUT request                               โ”‚
โ”‚  - Armazena com chave รบnica                                     โ”‚
โ”‚  - Gera URLs temporรกrias para download                          โ”‚
โ”‚  - Gerencia expiraรงรฃo de arquivos                               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    COMPOSIO TOOL ROUTER                          โ”‚
โ”‚                                                                   โ”‚
โ”‚  - Recebe parรขmetros com s3key                                  โ”‚
โ”‚  - Baixa arquivo de S3 se necessรกrio                            โ”‚
โ”‚  - Executa ferramenta (Gmail, Slack, etc.)                      โ”‚
โ”‚  - Retorna resultado (pode incluir arquivos)                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      API EXTERNA (Gmail)                         โ”‚
โ”‚                                                                   โ”‚
โ”‚  - Recebe requisiรงรฃo com arquivo                                โ”‚
โ”‚  - Processa (envia email com anexo)                             โ”‚
โ”‚  - Retorna confirmaรงรฃo                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ”„ Fluxo de Upload Detalhado


```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Arquivo Localโ”‚
โ”‚ report.pdf   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 1. FileUploadable::from_path()
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Validaรงรตes                            โ”‚
โ”‚ โœ“ Arquivo existe?                    โ”‚
โ”‚ โœ“ ร‰ um arquivo (nรฃo diretรณrio)?     โ”‚
โ”‚ โœ“ Tem permissรฃo de leitura?         โ”‚
โ”‚ โœ“ Calcula MD5 hash                  โ”‚
โ”‚ โœ“ Detecta MIME type                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 2. Request presigned URL
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ POST /api/v3/files/upload/request    โ”‚
โ”‚ {                                     โ”‚
โ”‚   "md5": "abc123...",                โ”‚
โ”‚   "filename": "report.pdf",          โ”‚
โ”‚   "mimetype": "application/pdf",     โ”‚
โ”‚   "tool_slug": "GMAIL_SEND_EMAIL",  โ”‚
โ”‚   "toolkit_slug": "gmail"            โ”‚
โ”‚ }                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 3. Resposta da API
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Response                              โ”‚
โ”‚ {                                     โ”‚
โ”‚   "id": "file_xyz",                  โ”‚
โ”‚   "key": "s3://bucket/path/file",   โ”‚
โ”‚   "type": "application/pdf",         โ”‚
โ”‚   "new_presigned_url": "https://..." โ”‚
โ”‚ }                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 4. Upload para S3
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ PUT https://s3.amazonaws.com/...     โ”‚
โ”‚ Content-Type: application/pdf        โ”‚
โ”‚ Body: [binary file content]          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 5. Retorno
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ FileUploadable {                      โ”‚
โ”‚   name: "report.pdf",                โ”‚
โ”‚   mimetype: "application/pdf",       โ”‚
โ”‚   s3key: "s3://bucket/path/file"    โ”‚
โ”‚ }                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ”ฝ Fluxo de Download Detalhado


```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Tool Response                         โ”‚
โ”‚ {                                     โ”‚
โ”‚   "success": true,                   โ”‚
โ”‚   "receipt": {                       โ”‚
โ”‚     "name": "receipt.pdf",           โ”‚
โ”‚     "mimetype": "application/pdf",   โ”‚
โ”‚     "s3url": "https://s3.../file"   โ”‚
โ”‚   }                                   โ”‚
โ”‚ }                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 1. SDK detecta file_downloadable
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ FileDownloadable::download()          โ”‚
โ”‚ - Cria diretรณrio de saรญda            โ”‚
โ”‚ - Faz GET request para s3url         โ”‚
โ”‚ - Valida status HTTP                 โ”‚
โ”‚ - Salva arquivo localmente           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 2. Download de S3
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ GET https://s3.amazonaws.com/...     โ”‚
โ”‚ Response: [binary file content]      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚ 3. Salvar localmente
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ~/.composio/outputs/                 โ”‚
โ”‚   gmail/                              โ”‚
โ”‚     GMAIL_SEND_EMAIL/                โ”‚
โ”‚       receipt.pdf                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ›ก๏ธ Recursos de Seguranรงa


### 1. Validaรงรฃo de Arquivos Locais


```rust
// Verificaรงรตes antes do upload
โœ“ Arquivo existe
โœ“ ร‰ um arquivo regular (nรฃo link simbรณlico)
โœ“ Tem permissรฃo de leitura
โœ“ Tamanho dentro do limite
```

### 2. Proteรงรตes para URLs Pรบblicas


```rust
// Proteรงรตes ao baixar de URLs
โœ“ Apenas HTTP/HTTPS permitido
โœ“ Redirects desabilitados (previne ataques)
โœ“ Timeout de conexรฃo: 5 segundos
โœ“ Timeout de leitura: 60 segundos
โœ“ Limite de tamanho: 100 MB
โœ“ Validaรงรฃo de Content-Type
```

### 3. Deduplicaรงรฃo com MD5


```rust
// Evita uploads duplicados
1. Calcula MD5 do arquivo
2. Envia hash para API
3. API verifica se arquivo jรก existe
4. Se existe, retorna chave existente
5. Se nรฃo existe, faz upload
```

### 4. URLs Temporรกrias

```
- Presigned URLs expiram apรณs uso
- Nรฃo expรตem credenciais AWS
- Acesso controlado por tempo
```

## ๐Ÿ“Š Processamento de Schemas

### Schema Original (Complexo)

```json
{
  "properties": {
    "attachment": {
      "type": "object",
      "file_uploadable": true,
      "properties": {
        "name": {"type": "string"},
        "mimetype": {"type": "string"},
        "s3key": {"type": "string"}
      },
      "required": ["name", "mimetype", "s3key"]
    }
  }
}
```

### Schema Processado (Simples)


```json
{
  "properties": {
    "attachment": {
      "type": "string",
      "format": "path",
      "description": "Path to file. Please provide a value of type string.",
      "file_uploadable": true
    }
  }
}
```

### Transformaรงรฃo de Parรขmetros


```
Entrada do Agente:
{
  "attachment": "/home/user/report.pdf"
}

        โ†“ SDK processa

Enviado para API:
{
  "attachment": {
    "name": "report.pdf",
    "mimetype": "application/pdf",
    "s3key": "s3://composio-bucket/files/abc123"
  }
}
```

## ๐ŸŽฏ Casos de Uso por Toolkit


### ๐Ÿ“ง Gmail / Outlook


```
Upload:
- Anexos de email
- Imagens inline
- Documentos

Download:
- Anexos recebidos
- Backups de emails
```

### ๐Ÿ’ฌ Slack / Discord / WhatsApp

```
Upload:
- Imagens
- Vรญdeos
- Documentos
- GIFs

Download:
- Mรญdia compartilhada
- Arquivos de canais
```

### ๐Ÿ—‚๏ธ Google Drive / Dropbox

```
Upload:
- Qualquer tipo de arquivo
- Backups
- Sincronizaรงรฃo

Download:
- Arquivos compartilhados
- Backups restaurados
```

### ๐Ÿ“Š Processamento de Documentos

```
Upload:
- PDFs para anรกlise
- Imagens para OCR
- Planilhas para processamento

Download:
- Relatรณrios gerados
- Dados extraรญdos
- Resultados de anรกlise
```

### ๐ŸŽจ Geraรงรฃo de Conteรบdo (DALL-E, Midjourney)

```
Upload:
- Templates
- Referรชncias
- Assets

Download:
- Imagens geradas
- Vรญdeos renderizados
- Designs criados
```

## ๐Ÿ’พ Estrutura de Diretรณrios

```
~/.composio/                    # Diretรณrio raiz
โ”œโ”€โ”€ outputs/                    # Arquivos baixados
โ”‚   โ”œโ”€โ”€ gmail/
โ”‚   โ”‚   โ”œโ”€โ”€ GMAIL_SEND_EMAIL/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ receipt_001.pdf
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ receipt_002.pdf
โ”‚   โ”‚   โ””โ”€โ”€ GMAIL_GET_ATTACHMENT/
โ”‚   โ”‚       โ”œโ”€โ”€ document.docx
โ”‚   โ”‚       โ””โ”€โ”€ image.png
โ”‚   โ”œโ”€โ”€ slack/
โ”‚   โ”‚   โ””โ”€โ”€ SLACK_SEND_MESSAGE/
โ”‚   โ”‚       โ”œโ”€โ”€ screenshot.png
โ”‚   โ”‚       โ””โ”€โ”€ video.mp4
โ”‚   โ””โ”€โ”€ github/
โ”‚       โ””โ”€โ”€ GITHUB_CREATE_RELEASE/
โ”‚           โ””โ”€โ”€ release_notes.md
โ””โ”€โ”€ cache/                      # Cache temporรกrio
    โ””โ”€โ”€ uploads/
        โ”œโ”€โ”€ temp_file_001.tmp
        โ””โ”€โ”€ temp_file_002.tmp
```

## ๐Ÿ”ง Configuraรงรฃo

### Variรกveis de Ambiente

```bash
# Diretรณrio de cache customizado
export COMPOSIO_CACHE_DIR="/custom/path/.composio"

# API Key
export COMPOSIO_API_KEY="your-api-key"
```

### Limites Configurรกveis

```rust
// Constantes que podem ser ajustadas
const MAX_RESPONSE_SIZE: usize = 100 * 1024 * 1024;  // 100 MB
const MAX_FILENAME_LENGTH: usize = 100;
const CONNECT_TIMEOUT_SECS: u64 = 5;
const READ_TIMEOUT_SECS: u64 = 60;
const DEFAULT_CHUNK_SIZE: usize = 1024 * 1024;  // 1 MB
```

## ๐Ÿ“ˆ Mรฉtricas e Monitoramento


### Informaรงรตes Rastreadas


```
- Tamanho do arquivo
- Tempo de upload
- Tempo de download
- MD5 hash (deduplicaรงรฃo)
- Tool slug (qual ferramenta usou)
- Toolkit slug (qual serviรงo)
- MIME type
- Timestamp de criaรงรฃo
```

### Logs Importantes

```
[INFO] Uploading file: report.pdf (2.5 MB)
[INFO] MD5 hash: abc123...
[INFO] Requesting presigned URL...
[INFO] Uploading to S3...
[INFO] Upload complete: s3://bucket/path/file
[INFO] File available for tool: GMAIL_SEND_EMAIL
```

## ๐Ÿš€ Performance

### Otimizaรงรตes Implementadas

1. **Streaming de Arquivos**
   - Leitura em chunks de 1 MB
   - Nรฃo carrega arquivo inteiro na memรณria

2. **Deduplicaรงรฃo**
   - MD5 hash evita uploads duplicados
   - Economiza banda e tempo

3. **Async/Await**
   - Operaรงรตes nรฃo bloqueantes
   - Mรบltiplos uploads simultรขneos

4. **Timeouts Inteligentes**
   - Connect timeout curto (5s)
   - Read timeout longo (60s)
   - Previne travamentos

## ๐Ÿ”ฎ Futuras Melhorias

1. **Compressรฃo Automรกtica**
   - Comprimir arquivos grandes antes do upload
   - Descomprimir automaticamente no download

2. **Retry com Backoff**
   - Retry automรกtico em falhas temporรกrias
   - Exponential backoff

3. **Progress Callbacks**
   - Notificar progresso de upload/download
   - รštil para arquivos grandes

4. **Cache Local**
   - Cache de arquivos baixados
   - Evita downloads duplicados

5. **Streaming de Vรญdeo**
   - Suporte para streaming de arquivos grandes
   - รštil para vรญdeos e รกudio