chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (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 / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import type { AddListMemberParams, AddListMemberResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunAddListMemberTool: ToolConfig<AddListMemberParams, AddListMemberResult> = {
|
||||
id: 'mailgun_add_list_member',
|
||||
name: 'Mailgun Add List Member',
|
||||
description: 'Add a member to a mailing list',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
listAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Mailing list address (e.g., list@mg.example.com)',
|
||||
},
|
||||
address: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Member email address to add (e.g., user@example.com)',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Member name',
|
||||
},
|
||||
vars: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'JSON string of custom variables',
|
||||
},
|
||||
subscribed: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Whether the member is subscribed',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => `https://api.mailgun.net/v3/lists/${params.listAddress}/members`,
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const formData = new FormData()
|
||||
formData.append('address', params.address)
|
||||
|
||||
if (params.name) {
|
||||
formData.append('name', params.name)
|
||||
}
|
||||
if (params.vars) {
|
||||
formData.append('vars', params.vars)
|
||||
}
|
||||
if (params.subscribed !== undefined) {
|
||||
formData.append('subscribed', params.subscribed ? 'yes' : 'no')
|
||||
}
|
||||
|
||||
return { body: formData }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<AddListMemberResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to add list member')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
message: result.message,
|
||||
member: {
|
||||
address: result.member.address,
|
||||
name: result.member.name,
|
||||
subscribed: result.member.subscribed,
|
||||
vars: result.member.vars,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the member was added successfully' },
|
||||
message: { type: 'string', description: 'Response message' },
|
||||
member: { type: 'json', description: 'Added member details' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import type { CreateMailingListParams, CreateMailingListResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunCreateMailingListTool: ToolConfig<
|
||||
CreateMailingListParams,
|
||||
CreateMailingListResult
|
||||
> = {
|
||||
id: 'mailgun_create_mailing_list',
|
||||
name: 'Mailgun Create Mailing List',
|
||||
description: 'Create a new mailing list',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
address: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Mailing list address (e.g., newsletter@mg.example.com)',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Mailing list name',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Mailing list description',
|
||||
},
|
||||
accessLevel: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Access level: readonly, members, or everyone',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => 'https://api.mailgun.net/v3/lists',
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const formData = new FormData()
|
||||
formData.append('address', params.address)
|
||||
|
||||
if (params.name) {
|
||||
formData.append('name', params.name)
|
||||
}
|
||||
if (params.description) {
|
||||
formData.append('description', params.description)
|
||||
}
|
||||
if (params.accessLevel) {
|
||||
formData.append('access_level', params.accessLevel)
|
||||
}
|
||||
|
||||
return { body: formData }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<CreateMailingListResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to create mailing list')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
message: result.message,
|
||||
list: {
|
||||
address: result.list.address,
|
||||
name: result.list.name,
|
||||
description: result.list.description,
|
||||
accessLevel: result.list.access_level,
|
||||
createdAt: result.list.created_at,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the list was created successfully' },
|
||||
message: { type: 'string', description: 'Response message' },
|
||||
list: { type: 'json', description: 'Created mailing list details' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { GetDomainParams, GetDomainResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunGetDomainTool: ToolConfig<GetDomainParams, GetDomainResult> = {
|
||||
id: 'mailgun_get_domain',
|
||||
name: 'Mailgun Get Domain',
|
||||
description: 'Get details of a specific domain',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Domain name to retrieve details for (e.g., mg.example.com)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => `https://api.mailgun.net/v3/domains/${params.domain}`,
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<GetDomainResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to get domain')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
domain: {
|
||||
name: result.domain.name,
|
||||
smtpLogin: result.domain.smtp_login,
|
||||
smtpPassword: result.domain.smtp_password,
|
||||
spamAction: result.domain.spam_action,
|
||||
state: result.domain.state,
|
||||
createdAt: result.domain.created_at,
|
||||
type: result.domain.type,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the request was successful' },
|
||||
domain: { type: 'json', description: 'Domain details' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { GetMailingListParams, GetMailingListResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunGetMailingListTool: ToolConfig<GetMailingListParams, GetMailingListResult> = {
|
||||
id: 'mailgun_get_mailing_list',
|
||||
name: 'Mailgun Get Mailing List',
|
||||
description: 'Get details of a mailing list',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
address: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Mailing list address to retrieve (e.g., newsletter@mg.example.com)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => `https://api.mailgun.net/v3/lists/${params.address}`,
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<GetMailingListResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to get mailing list')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
list: {
|
||||
address: result.list.address,
|
||||
name: result.list.name,
|
||||
description: result.list.description,
|
||||
accessLevel: result.list.access_level,
|
||||
membersCount: result.list.members_count,
|
||||
createdAt: result.list.created_at,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the request was successful' },
|
||||
list: { type: 'json', description: 'Mailing list details' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import type { GetMessageParams, GetMessageResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunGetMessageTool: ToolConfig<GetMessageParams, GetMessageResult> = {
|
||||
id: 'mailgun_get_message',
|
||||
name: 'Mailgun Get Message',
|
||||
description: 'Retrieve a stored message by its key',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun domain for retrieving messages (e.g., mg.example.com)',
|
||||
},
|
||||
messageKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Message storage key',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
`https://api.mailgun.net/v3/domains/${params.domain}/messages/${params.messageKey}`,
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<GetMessageResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to get message')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
recipients: result.recipients,
|
||||
from: result.from,
|
||||
subject: result.subject,
|
||||
bodyPlain: result['body-plain'],
|
||||
strippedText: result['stripped-text'],
|
||||
strippedSignature: result['stripped-signature'],
|
||||
bodyHtml: result['body-html'],
|
||||
strippedHtml: result['stripped-html'],
|
||||
attachmentCount: result['attachment-count'],
|
||||
timestamp: result.timestamp,
|
||||
messageHeaders: result['message-headers'],
|
||||
contentIdMap: result['content-id-map'],
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the request was successful' },
|
||||
recipients: { type: 'string', description: 'Message recipients' },
|
||||
from: { type: 'string', description: 'Sender email' },
|
||||
subject: { type: 'string', description: 'Message subject' },
|
||||
bodyPlain: { type: 'string', description: 'Plain text body' },
|
||||
strippedText: { type: 'string', description: 'Stripped text' },
|
||||
strippedSignature: { type: 'string', description: 'Stripped signature' },
|
||||
bodyHtml: { type: 'string', description: 'HTML body' },
|
||||
strippedHtml: { type: 'string', description: 'Stripped HTML' },
|
||||
attachmentCount: { type: 'number', description: 'Number of attachments' },
|
||||
timestamp: { type: 'number', description: 'Message timestamp' },
|
||||
messageHeaders: { type: 'json', description: 'Message headers' },
|
||||
contentIdMap: { type: 'json', description: 'Content ID map' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Message Operations
|
||||
|
||||
export { mailgunAddListMemberTool } from './add_list_member'
|
||||
export { mailgunCreateMailingListTool } from './create_mailing_list'
|
||||
export { mailgunGetDomainTool } from './get_domain'
|
||||
export { mailgunGetMailingListTool } from './get_mailing_list'
|
||||
export { mailgunGetMessageTool } from './get_message'
|
||||
export { mailgunListDomainsTool } from './list_domains'
|
||||
export { mailgunListMessagesTool } from './list_messages'
|
||||
export { mailgunSendMessageTool } from './send_message'
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { ListDomainsParams, ListDomainsResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunListDomainsTool: ToolConfig<ListDomainsParams, ListDomainsResult> = {
|
||||
id: 'mailgun_list_domains',
|
||||
name: 'Mailgun List Domains',
|
||||
description: 'List all domains for your Mailgun account',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => 'https://api.mailgun.net/v3/domains',
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<ListDomainsResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to list domains')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
totalCount: result.total_count,
|
||||
items: result.items || [],
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the request was successful' },
|
||||
totalCount: { type: 'number', description: 'Total number of domains' },
|
||||
items: { type: 'json', description: 'Array of domain objects' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { ListMessagesParams, ListMessagesResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunListMessagesTool: ToolConfig<ListMessagesParams, ListMessagesResult> = {
|
||||
id: 'mailgun_list_messages',
|
||||
name: 'Mailgun List Messages',
|
||||
description: 'List events (logs) for messages sent through Mailgun',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun domain for listing events (e.g., mg.example.com)',
|
||||
},
|
||||
event: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Filter by event type (accepted, delivered, failed, opened, clicked, etc.)',
|
||||
},
|
||||
limit: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Maximum number of events to return (default: 100)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const baseUrl = `https://api.mailgun.net/v3/${params.domain}/events`
|
||||
const queryParams = new URLSearchParams()
|
||||
|
||||
if (params.event) {
|
||||
queryParams.append('event', params.event)
|
||||
}
|
||||
if (params.limit) {
|
||||
queryParams.append('limit', params.limit.toString())
|
||||
}
|
||||
|
||||
const query = queryParams.toString()
|
||||
return query ? `${baseUrl}?${query}` : baseUrl
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<ListMessagesResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to list messages')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
items: result.items || [],
|
||||
paging: result.paging || {},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the request was successful' },
|
||||
items: { type: 'json', description: 'Array of event items' },
|
||||
paging: { type: 'json', description: 'Paging information' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import type { SendMessageParams, SendMessageResult } from '@/tools/mailgun/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const mailgunSendMessageTool: ToolConfig<SendMessageParams, SendMessageResult> = {
|
||||
id: 'mailgun_send_message',
|
||||
name: 'Mailgun Send Message',
|
||||
description: 'Send an email using Mailgun API',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun API key',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Mailgun sending domain (e.g., mg.example.com)',
|
||||
},
|
||||
from: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Sender email address (e.g., sender@example.com or "Name <sender@example.com>")',
|
||||
},
|
||||
to: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Recipient email address (e.g., user@example.com). Use comma-separated values for multiple recipients',
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Email subject line',
|
||||
},
|
||||
text: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Plain text body of the email',
|
||||
},
|
||||
html: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'HTML body of the email (e.g., "<h1>Hello</h1><p>Message content</p>")',
|
||||
},
|
||||
cc: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'CC recipient email address (e.g., cc@example.com). Use comma-separated values for multiple recipients',
|
||||
},
|
||||
bcc: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'BCC recipient email address (e.g., bcc@example.com). Use comma-separated values for multiple recipients',
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Tags for the email (comma-separated)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => `https://api.mailgun.net/v3/${params.domain}/messages`,
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Basic ${Buffer.from(`api:${params.apiKey}`).toString('base64')}`,
|
||||
}),
|
||||
body: (params) => {
|
||||
const formData = new FormData()
|
||||
formData.append('from', params.from)
|
||||
formData.append('to', params.to)
|
||||
formData.append('subject', params.subject)
|
||||
|
||||
if (params.text) {
|
||||
formData.append('text', params.text)
|
||||
}
|
||||
if (params.html) {
|
||||
formData.append('html', params.html)
|
||||
}
|
||||
if (params.cc) {
|
||||
formData.append('cc', params.cc)
|
||||
}
|
||||
if (params.bcc) {
|
||||
formData.append('bcc', params.bcc)
|
||||
}
|
||||
if (params.tags) {
|
||||
const tagArray = params.tags.split(',').map((t) => t.trim())
|
||||
tagArray.forEach((tag) => formData.append('o:tag', tag))
|
||||
}
|
||||
|
||||
return { body: formData }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response, params): Promise<SendMessageResult> => {
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.message || 'Failed to send message')
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
success: true,
|
||||
id: result.id,
|
||||
message: result.message || 'Queued. Thank you.',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the message was sent successfully' },
|
||||
id: { type: 'string', description: 'Message ID' },
|
||||
message: { type: 'string', description: 'Response message from Mailgun' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
interface MailgunMessageHeaders {
|
||||
[key: string]: string | string[]
|
||||
}
|
||||
|
||||
interface MailgunMessageItem {
|
||||
timestamp: number
|
||||
event: string
|
||||
recipient: string
|
||||
sender?: string
|
||||
subject?: string
|
||||
deliveryStatus?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface MailgunDomainItem {
|
||||
name: string
|
||||
state: string
|
||||
type: string
|
||||
created_at?: string
|
||||
smtp_login?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface MailgunPaging {
|
||||
first?: string
|
||||
next?: string
|
||||
previous?: string
|
||||
last?: string
|
||||
}
|
||||
|
||||
interface MailgunMailingListMember {
|
||||
address: string
|
||||
name?: string
|
||||
subscribed: boolean
|
||||
vars?: Record<string, string | number | boolean | null>
|
||||
}
|
||||
|
||||
// Send Message
|
||||
export interface SendMessageParams {
|
||||
apiKey: string
|
||||
domain: string
|
||||
from: string
|
||||
to: string
|
||||
subject: string
|
||||
text?: string
|
||||
html?: string
|
||||
cc?: string
|
||||
bcc?: string
|
||||
tags?: string
|
||||
}
|
||||
|
||||
export interface SendMessageResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
id: string
|
||||
message: string
|
||||
}
|
||||
}
|
||||
|
||||
// Get Message
|
||||
export interface GetMessageParams {
|
||||
apiKey: string
|
||||
domain: string
|
||||
messageKey: string
|
||||
}
|
||||
|
||||
export interface GetMessageResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
recipients: string
|
||||
from: string
|
||||
subject: string
|
||||
bodyPlain: string
|
||||
strippedText: string
|
||||
strippedSignature: string
|
||||
bodyHtml: string
|
||||
strippedHtml: string
|
||||
attachmentCount: number
|
||||
timestamp: number
|
||||
messageHeaders: MailgunMessageHeaders
|
||||
contentIdMap: Record<string, string>
|
||||
}
|
||||
}
|
||||
|
||||
// List Messages (Events)
|
||||
export interface ListMessagesParams {
|
||||
apiKey: string
|
||||
domain: string
|
||||
event?: string
|
||||
limit?: number
|
||||
}
|
||||
|
||||
export interface ListMessagesResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
items: MailgunMessageItem[]
|
||||
paging: MailgunPaging
|
||||
}
|
||||
}
|
||||
|
||||
// Create Mailing List
|
||||
export interface CreateMailingListParams {
|
||||
apiKey: string
|
||||
address: string
|
||||
name?: string
|
||||
description?: string
|
||||
accessLevel?: 'readonly' | 'members' | 'everyone'
|
||||
}
|
||||
|
||||
export interface CreateMailingListResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
message: string
|
||||
list: {
|
||||
address: string
|
||||
name: string
|
||||
description: string
|
||||
accessLevel: string
|
||||
createdAt: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Mailing List
|
||||
export interface GetMailingListParams {
|
||||
apiKey: string
|
||||
address: string
|
||||
}
|
||||
|
||||
export interface GetMailingListResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
list: {
|
||||
address: string
|
||||
name: string
|
||||
description: string
|
||||
accessLevel: string
|
||||
membersCount: number
|
||||
createdAt: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add List Member
|
||||
export interface AddListMemberParams {
|
||||
apiKey: string
|
||||
listAddress: string
|
||||
address: string
|
||||
name?: string
|
||||
vars?: string
|
||||
subscribed?: boolean
|
||||
}
|
||||
|
||||
export interface AddListMemberResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
message: string
|
||||
member: {
|
||||
address: string
|
||||
name: string
|
||||
subscribed: boolean
|
||||
vars: Record<string, string | number | boolean | null>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List Domains
|
||||
export interface ListDomainsParams {
|
||||
apiKey: string
|
||||
}
|
||||
|
||||
export interface ListDomainsResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
totalCount: number
|
||||
items: MailgunDomainItem[]
|
||||
}
|
||||
}
|
||||
|
||||
// Get Domain
|
||||
export interface GetDomainParams {
|
||||
apiKey: string
|
||||
domain: string
|
||||
}
|
||||
|
||||
export interface GetDomainResult extends ToolResponse {
|
||||
output: {
|
||||
success: boolean
|
||||
domain: {
|
||||
name: string
|
||||
smtpLogin: string
|
||||
smtpPassword: string
|
||||
spamAction: string
|
||||
state: string
|
||||
createdAt: string
|
||||
type: string
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user