6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
165 lines
5.1 KiB
TypeScript
165 lines
5.1 KiB
TypeScript
import type { UpdateDraftParams, UpdateDraftResult } from '@/tools/agentmail/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const agentmailUpdateDraftTool: ToolConfig<UpdateDraftParams, UpdateDraftResult> = {
|
|
id: 'agentmail_update_draft',
|
|
name: 'Update Draft',
|
|
description: 'Update an existing email draft in AgentMail',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'AgentMail API key',
|
|
},
|
|
inboxId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the inbox containing the draft',
|
|
},
|
|
draftId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the draft to update',
|
|
},
|
|
to: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Recipient email addresses (comma-separated)',
|
|
},
|
|
subject: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Draft subject line',
|
|
},
|
|
text: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Plain text draft body',
|
|
},
|
|
html: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'HTML draft body',
|
|
},
|
|
cc: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'CC recipient email addresses (comma-separated)',
|
|
},
|
|
bcc: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'BCC recipient email addresses (comma-separated)',
|
|
},
|
|
sendAt: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'ISO 8601 timestamp to schedule sending',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) =>
|
|
`https://api.agentmail.to/v0/inboxes/${params.inboxId.trim()}/drafts/${params.draftId.trim()}`,
|
|
method: 'PATCH',
|
|
headers: (params) => ({
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params) => {
|
|
const body: Record<string, unknown> = {}
|
|
if (params.to) body.to = params.to.split(',').map((e) => e.trim())
|
|
if (params.subject) body.subject = params.subject
|
|
if (params.text) body.text = params.text
|
|
if (params.html) body.html = params.html
|
|
if (params.cc) body.cc = params.cc.split(',').map((e) => e.trim())
|
|
if (params.bcc) body.bcc = params.bcc.split(',').map((e) => e.trim())
|
|
if (params.sendAt) body.send_at = params.sendAt
|
|
return body
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response): Promise<UpdateDraftResult> => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
error: data.message ?? 'Failed to update draft',
|
|
output: {
|
|
draftId: '',
|
|
inboxId: '',
|
|
subject: null,
|
|
to: [],
|
|
cc: [],
|
|
bcc: [],
|
|
text: null,
|
|
html: null,
|
|
preview: null,
|
|
labels: [],
|
|
inReplyTo: null,
|
|
sendStatus: null,
|
|
sendAt: null,
|
|
createdAt: '',
|
|
updatedAt: '',
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
draftId: data.draft_id ?? '',
|
|
inboxId: data.inbox_id ?? '',
|
|
subject: data.subject ?? null,
|
|
to: data.to ?? [],
|
|
cc: data.cc ?? [],
|
|
bcc: data.bcc ?? [],
|
|
text: data.text ?? null,
|
|
html: data.html ?? null,
|
|
preview: data.preview ?? null,
|
|
labels: data.labels ?? [],
|
|
inReplyTo: data.in_reply_to ?? null,
|
|
sendStatus: data.send_status ?? null,
|
|
sendAt: data.send_at ?? null,
|
|
createdAt: data.created_at ?? '',
|
|
updatedAt: data.updated_at ?? '',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
draftId: { type: 'string', description: 'Unique identifier for the draft' },
|
|
inboxId: { type: 'string', description: 'Inbox the draft belongs to' },
|
|
subject: { type: 'string', description: 'Draft subject', optional: true },
|
|
to: { type: 'array', description: 'Recipient email addresses' },
|
|
cc: { type: 'array', description: 'CC email addresses' },
|
|
bcc: { type: 'array', description: 'BCC email addresses' },
|
|
text: { type: 'string', description: 'Plain text content', optional: true },
|
|
html: { type: 'string', description: 'HTML content', optional: true },
|
|
preview: { type: 'string', description: 'Draft preview text', optional: true },
|
|
labels: { type: 'array', description: 'Labels assigned to the draft' },
|
|
inReplyTo: { type: 'string', description: 'Message ID this draft replies to', optional: true },
|
|
sendStatus: {
|
|
type: 'string',
|
|
description: 'Send status (scheduled, sending, failed)',
|
|
optional: true,
|
|
},
|
|
sendAt: { type: 'string', description: 'Scheduled send time', optional: true },
|
|
createdAt: { type: 'string', description: 'Creation timestamp' },
|
|
updatedAt: { type: 'string', description: 'Last updated timestamp' },
|
|
},
|
|
}
|