d25d482dc2
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
102 lines
2.8 KiB
TypeScript
102 lines
2.8 KiB
TypeScript
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' },
|
|
},
|
|
}
|