-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathdelete_draft.ts
More file actions
76 lines (67 loc) · 1.92 KB
/
Copy pathdelete_draft.ts
File metadata and controls
76 lines (67 loc) · 1.92 KB
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
import { GMAIL_API_BASE } from '@/tools/gmail/utils'
import type { ToolConfig } from '@/tools/types'
interface GmailDeleteDraftParams {
accessToken: string
draftId: string
}
interface GmailDeleteDraftResponse {
success: boolean
output: {
deleted: boolean
draftId: string
}
}
export const gmailDeleteDraftV2Tool: ToolConfig<GmailDeleteDraftParams, GmailDeleteDraftResponse> =
{
id: 'gmail_delete_draft_v2',
name: 'Gmail Delete Draft',
description: 'Delete a specific draft from Gmail',
version: '2.0.0',
oauth: {
required: true,
provider: 'google-email',
},
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Access token for Gmail API',
},
draftId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ID of the draft to delete',
},
},
request: {
url: (params: GmailDeleteDraftParams) => `${GMAIL_API_BASE}/drafts/${params.draftId}`,
method: 'DELETE',
headers: (params: GmailDeleteDraftParams) => ({
Authorization: `Bearer ${params.accessToken}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response, params?: GmailDeleteDraftParams) => {
if (!response.ok) {
const data = await response.json()
return {
success: false,
output: { deleted: false, draftId: params?.draftId ?? '' },
error: data.error?.message || 'Failed to delete draft',
}
}
return {
success: true,
output: {
deleted: true,
draftId: params?.draftId ?? '',
},
}
},
outputs: {
deleted: { type: 'boolean', description: 'Whether the draft was successfully deleted' },
draftId: { type: 'string', description: 'ID of the deleted draft' },
},
}