Skip to content

Commit e9be4a5

Browse files
committed
fix(agentmail,incidentio): remove a phantom delete option and v1-only fields
AgentMail's delete-thread endpoint takes no 'permanent' parameter and always deletes permanently, but the block defaulted to 'No (move to trash)' -- the safe-looking option was the destructive one. The subBlock id is kept as a read-only notice so the correction appears where the choice was made. incident.io emitted incident_url (never on IncidentV2), due_at, external_issue_reference and options (all v1-only) off v2 responses, all permanently undefined. incident_url is now populated from permalink and kept as a documented alias so existing references start working instead of breaking. total_record_count is removed only from users_list; incidents_list uses a pagination schema that really does carry it.
1 parent f14cd7e commit e9be4a5

19 files changed

Lines changed: 414 additions & 103 deletions

apps/sim/blocks/blocks/agentmail.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,22 @@ export const AgentMailBlock: BlockConfig = {
335335
},
336336

337337
// Delete Thread fields
338+
/**
339+
* AgentMail's DELETE thread endpoint takes no deletion-mode parameter and its own
340+
* description reads "Permanently deletes a thread and all of its messages." There is no
341+
* trash to move a thread to, so this id — which used to render a dropdown defaulting to
342+
* "No (move to trash)" — is now a read-only notice. Keeping the id claimed means the
343+
* warning appears exactly where the misleading choice used to sit, and no future subBlock
344+
* inherits the orphaned 'true'/'false' value still stored in existing workflows.
345+
*/
338346
{
339347
id: 'permanent',
340348
title: 'Permanent Delete',
341-
type: 'dropdown',
342-
options: [
343-
{ label: 'No (move to trash)', id: 'false' },
344-
{ label: 'Yes (permanent)', id: 'true' },
345-
],
346-
value: () => 'false',
349+
type: 'text',
350+
hideFromPreview: true,
351+
defaultValue:
352+
'Deleting a thread is permanent. AgentMail removes the thread and every message in it immediately, and this cannot be undone.',
347353
condition: { field: 'operation', value: 'delete_thread' },
348-
mode: 'advanced',
349354
},
350355

351356
// Forward Message fields
@@ -586,10 +591,6 @@ export const AgentMailBlock: BlockConfig = {
586591
rest.inboxId = inboxIdParam
587592
}
588593

589-
if (operation === 'delete_thread' && permanent !== undefined) {
590-
rest.permanent = permanent === 'true'
591-
}
592-
593594
if (operation === 'reply_message' && replyAll !== undefined) {
594595
rest.replyAll = replyAll === 'true'
595596
}
@@ -665,7 +666,6 @@ export const AgentMailBlock: BlockConfig = {
665666
threadId: { type: 'string', description: 'Thread ID' },
666667
addLabels: { type: 'string', description: 'Labels to add to thread (comma-separated)' },
667668
removeLabels: { type: 'string', description: 'Labels to remove from thread (comma-separated)' },
668-
permanent: { type: 'string', description: 'Whether to permanently delete' },
669669
messageId: { type: 'string', description: 'Message ID' },
670670
draftId: { type: 'string', description: 'Draft ID' },
671671
draftInReplyTo: { type: 'string', description: 'Message ID this draft replies to' },
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* @vitest-environment node
3+
*
4+
* AgentMail's `DELETE /v0/inboxes/{inbox_id}/threads/{thread_id}` declares exactly three
5+
* parameters — `inbox_id`, `thread_id`, `Authorization` — and its description reads
6+
* "Permanently deletes a thread and all of its messages."
7+
*
8+
* There is no `permanent` query parameter, so a `?permanent=` we appended was inert and the
9+
* block's "No (move to trash)" default told the user the opposite of what the request did.
10+
* These pin that no delete request carries a phantom parameter and that the editor no longer
11+
* offers a non-permanent choice.
12+
*/
13+
import { describe, expect, it } from 'vitest'
14+
import { AgentMailBlock } from '@/blocks/blocks/agentmail'
15+
import { agentmailDeleteDraftTool } from '@/tools/agentmail/delete_draft'
16+
import { agentmailDeleteInboxTool } from '@/tools/agentmail/delete_inbox'
17+
import { agentmailDeleteThreadTool } from '@/tools/agentmail/delete_thread'
18+
import type { ToolConfig } from '@/tools/types'
19+
20+
function buildUrl(tool: ToolConfig<any, any>, params: Record<string, unknown>): string {
21+
const url = tool.request.url
22+
return typeof url === 'function' ? url(params as never) : url
23+
}
24+
25+
const INBOX = 'yourinbox@agentmail.to'
26+
const THREAD = 'thread_01HQ8ZK4N2XW9V'
27+
28+
describe('agentmail delete tools carry no phantom parameters', () => {
29+
it('never appends a `permanent` query parameter, whatever the caller passes', () => {
30+
for (const extra of [{}, { permanent: true }, { permanent: false }, { permanent: 'true' }]) {
31+
const url = new URL(
32+
buildUrl(agentmailDeleteThreadTool, { inboxId: INBOX, threadId: THREAD, ...extra })
33+
)
34+
expect(url.searchParams.has('permanent')).toBe(false)
35+
expect(url.search).toBe('')
36+
}
37+
})
38+
39+
it('produces the byte-identical URL today`s legitimate call produced, minus the phantom param', () => {
40+
expect(buildUrl(agentmailDeleteThreadTool, { inboxId: INBOX, threadId: THREAD })).toBe(
41+
`https://api.agentmail.to/v0/inboxes/${encodeURIComponent(INBOX)}/threads/${THREAD}`
42+
)
43+
})
44+
45+
it('does not declare a `permanent` tool param', () => {
46+
expect(Object.keys(agentmailDeleteThreadTool.params)).not.toContain('permanent')
47+
})
48+
49+
it('leaves the sibling delete tools query-free', () => {
50+
expect(
51+
new URL(buildUrl(agentmailDeleteDraftTool, { inboxId: INBOX, draftId: 'd_1' })).search
52+
).toBe('')
53+
expect(new URL(buildUrl(agentmailDeleteInboxTool, { inboxId: INBOX })).search).toBe('')
54+
})
55+
56+
it('describes thread deletion as permanent and irreversible', () => {
57+
expect(agentmailDeleteThreadTool.description.toLowerCase()).toContain('permanent')
58+
expect(agentmailDeleteThreadTool.description.toLowerCase()).not.toContain('trash')
59+
})
60+
})
61+
62+
describe('the AgentMail block offers no non-permanent delete option', () => {
63+
const permanentSubBlock = AgentMailBlock.subBlocks.find((sub) => sub.id === 'permanent')
64+
65+
it('no longer renders a selectable control for `permanent`', () => {
66+
if (!permanentSubBlock) return
67+
expect(permanentSubBlock.type).toBe('text')
68+
expect(permanentSubBlock).not.toHaveProperty('options')
69+
})
70+
71+
it('states plainly that the deletion cannot be undone', () => {
72+
if (!permanentSubBlock) return
73+
const content = String(permanentSubBlock.defaultValue ?? '').toLowerCase()
74+
expect(content).toContain('permanent')
75+
expect(content).toContain('cannot be undone')
76+
})
77+
78+
it('never forwards a `permanent` value to the tool', () => {
79+
const transform = AgentMailBlock.tools.config!.params!
80+
const resolved = transform({
81+
operation: 'delete_thread',
82+
inboxId: INBOX,
83+
threadId: THREAD,
84+
permanent: 'false',
85+
} as never) as Record<string, unknown>
86+
87+
expect(resolved).not.toHaveProperty('permanent')
88+
})
89+
90+
it('does not declare `permanent` as a block input', () => {
91+
expect(Object.keys(AgentMailBlock.inputs)).not.toContain('permanent')
92+
})
93+
})

apps/sim/tools/agentmail/delete_thread.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const agentmailDeleteThreadTool: ToolConfig<DeleteThreadParams, DeleteThr
66
id: 'agentmail_delete_thread',
77
name: 'Delete Thread',
88
description:
9-
'Delete an email thread in AgentMail (moves to trash, or permanently deletes if already in trash)',
9+
'Permanently delete an email thread in AgentMail and all of its messages. This cannot be undone.',
1010
version: '1.0.0',
1111

1212
params: {
@@ -28,21 +28,11 @@ export const agentmailDeleteThreadTool: ToolConfig<DeleteThreadParams, DeleteThr
2828
visibility: 'user-or-llm',
2929
description: 'ID of the thread to delete',
3030
},
31-
permanent: {
32-
type: 'boolean',
33-
required: false,
34-
visibility: 'user-or-llm',
35-
description: 'Force permanent deletion instead of moving to trash',
36-
},
3731
},
3832

3933
request: {
40-
url: (params) => {
41-
const query = new URLSearchParams()
42-
if (params.permanent) query.set('permanent', 'true')
43-
const qs = query.toString()
44-
return `https://api.agentmail.to/v0/inboxes/${safeUrlPathSegment(params.inboxId, 'inboxId')}/threads/${safeUrlPathSegment(params.threadId, 'threadId')}${qs ? `?${qs}` : ''}`
45-
},
34+
url: (params) =>
35+
`https://api.agentmail.to/v0/inboxes/${safeUrlPathSegment(params.inboxId, 'inboxId')}/threads/${safeUrlPathSegment(params.threadId, 'threadId')}`,
4636
method: 'DELETE',
4737
headers: (params) => ({
4838
Authorization: `Bearer ${params.apiKey}`,

apps/sim/tools/agentmail/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ export interface DeleteThreadParams {
394394
apiKey: string
395395
inboxId: string
396396
threadId: string
397-
permanent?: boolean
398397
}
399398

400399
export interface DeleteThreadResult extends ToolResponse {

apps/sim/tools/incidentio/actions_list.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export const actionsListTool: ToolConfig<
7474
}
7575
: undefined,
7676
status: action.status,
77-
due_at: action.due_at,
7877
created_at: action.created_at,
7978
updated_at: action.updated_at,
8079
incident_id: action.incident_id,
@@ -86,13 +85,6 @@ export const actionsListTool: ToolConfig<
8685
}
8786
: undefined,
8887
completed_at: action.completed_at,
89-
external_issue_reference: action.external_issue_reference
90-
? {
91-
provider: action.external_issue_reference.provider,
92-
issue_name: action.external_issue_reference.issue_name,
93-
issue_permalink: action.external_issue_reference.issue_permalink,
94-
}
95-
: undefined,
9688
})) || [],
9789
},
9890
}
@@ -117,7 +109,6 @@ export const actionsListTool: ToolConfig<
117109
},
118110
},
119111
status: { type: 'string', description: 'Action status' },
120-
due_at: { type: 'string', description: 'Due date/time' },
121112
created_at: { type: 'string', description: 'Creation timestamp' },
122113
updated_at: { type: 'string', description: 'Last update timestamp' },
123114
incident_id: { type: 'string', description: 'Associated incident ID' },
@@ -131,19 +122,6 @@ export const actionsListTool: ToolConfig<
131122
},
132123
},
133124
completed_at: { type: 'string', description: 'Completion timestamp' },
134-
external_issue_reference: {
135-
type: 'object',
136-
description: 'External issue tracking reference',
137-
optional: true,
138-
properties: {
139-
provider: {
140-
type: 'string',
141-
description: 'Issue tracking provider (e.g., Jira, Linear)',
142-
},
143-
issue_name: { type: 'string', description: 'Issue identifier' },
144-
issue_permalink: { type: 'string', description: 'URL to the external issue' },
145-
},
146-
},
147125
},
148126
},
149127
},

apps/sim/tools/incidentio/actions_show.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export const actionsShowTool: ToolConfig<
5555
}
5656
: undefined,
5757
status: data.action.status,
58-
due_at: data.action.due_at,
5958
created_at: data.action.created_at,
6059
updated_at: data.action.updated_at,
6160
incident_id: data.action.incident_id,
@@ -67,13 +66,6 @@ export const actionsShowTool: ToolConfig<
6766
}
6867
: undefined,
6968
completed_at: data.action.completed_at,
70-
external_issue_reference: data.action.external_issue_reference
71-
? {
72-
provider: data.action.external_issue_reference.provider,
73-
issue_name: data.action.external_issue_reference.issue_name,
74-
issue_permalink: data.action.external_issue_reference.issue_permalink,
75-
}
76-
: undefined,
7769
},
7870
},
7971
}
@@ -96,7 +88,6 @@ export const actionsShowTool: ToolConfig<
9688
},
9789
},
9890
status: { type: 'string', description: 'Action status' },
99-
due_at: { type: 'string', description: 'Due date/time' },
10091
created_at: { type: 'string', description: 'Creation timestamp' },
10192
updated_at: { type: 'string', description: 'Last update timestamp' },
10293
incident_id: { type: 'string', description: 'Associated incident ID' },
@@ -110,19 +101,6 @@ export const actionsShowTool: ToolConfig<
110101
},
111102
},
112103
completed_at: { type: 'string', description: 'Completion timestamp' },
113-
external_issue_reference: {
114-
type: 'object',
115-
description: 'External issue tracking reference',
116-
optional: true,
117-
properties: {
118-
provider: {
119-
type: 'string',
120-
description: 'Issue tracking provider (e.g., Jira, Linear)',
121-
},
122-
issue_name: { type: 'string', description: 'Issue identifier' },
123-
issue_permalink: { type: 'string', description: 'URL to the external issue' },
124-
},
125-
},
126104
},
127105
},
128106
},

apps/sim/tools/incidentio/custom_fields_create.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const customFieldsCreateTool: ToolConfig<
6767
field_type: data.custom_field.field_type,
6868
created_at: data.custom_field.created_at,
6969
updated_at: data.custom_field.updated_at,
70-
options: data.custom_field.options,
7170
},
7271
},
7372
}

apps/sim/tools/incidentio/custom_fields_list.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const customFieldsListTool: ToolConfig<CustomFieldsListParams, CustomFiel
3838
field_type: field.field_type,
3939
created_at: field.created_at,
4040
updated_at: field.updated_at,
41-
options: field.options,
4241
})),
4342
},
4443
}

apps/sim/tools/incidentio/custom_fields_show.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export const customFieldsShowTool: ToolConfig<CustomFieldsShowParams, CustomFiel
4646
field_type: data.custom_field.field_type,
4747
created_at: data.custom_field.created_at,
4848
updated_at: data.custom_field.updated_at,
49-
options: data.custom_field.options,
5049
},
5150
},
5251
}

apps/sim/tools/incidentio/custom_fields_update.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export const customFieldsUpdateTool: ToolConfig<
6969
field_type: data.custom_field.field_type,
7070
created_at: data.custom_field.created_at,
7171
updated_at: data.custom_field.updated_at,
72-
options: data.custom_field.options,
7372
},
7473
},
7574
}

0 commit comments

Comments
 (0)