chore: import upstream snapshot with attribution
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) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
@@ -0,0 +1,69 @@
import type { TwilioGetRecordingOutput, TwilioGetRecordingParams } from '@/tools/twilio_voice/types'
import type { ToolConfig } from '@/tools/types'
export const getRecordingTool: ToolConfig<TwilioGetRecordingParams, TwilioGetRecordingOutput> = {
id: 'twilio_voice_get_recording',
name: 'Twilio Voice Get Recording',
description: 'Retrieve call recording information and transcription (if enabled via TwiML).',
version: '1.0.0',
params: {
recordingSid: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Recording SID to retrieve (e.g., RExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)',
},
accountSid: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Account SID',
},
authToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Auth Token',
},
},
request: {
url: '/api/tools/twilio/get-recording',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
accountSid: params.accountSid,
authToken: params.authToken,
recordingSid: params.recordingSid,
}),
},
outputs: {
success: { type: 'boolean', description: 'Whether the recording was successfully retrieved' },
recordingSid: { type: 'string', description: 'Unique identifier for the recording' },
callSid: { type: 'string', description: 'Call SID this recording belongs to' },
duration: { type: 'number', description: 'Duration of the recording in seconds' },
status: { type: 'string', description: 'Recording status (completed, processing, etc.)' },
channels: { type: 'number', description: 'Number of channels (1 for mono, 2 for dual)' },
source: { type: 'string', description: 'How the recording was created' },
mediaUrl: { type: 'string', description: 'URL to download the recording media file' },
file: { type: 'file', description: 'Downloaded recording media file' },
price: { type: 'string', description: 'Cost of the recording' },
priceUnit: { type: 'string', description: 'Currency of the price' },
uri: { type: 'string', description: 'Relative URI of the recording resource' },
transcriptionText: {
type: 'string',
description: 'Transcribed text from the recording (if available)',
},
transcriptionStatus: {
type: 'string',
description: 'Transcription status (completed, in-progress, failed)',
},
transcriptionPrice: { type: 'string', description: 'Cost of the transcription' },
transcriptionPriceUnit: { type: 'string', description: 'Currency of the transcription price' },
error: { type: 'string', description: 'Error message if retrieval failed' },
},
}
+5
View File
@@ -0,0 +1,5 @@
import { getRecordingTool } from '@/tools/twilio_voice/get_recording'
import { listCallsTool } from '@/tools/twilio_voice/list_calls'
import { makeCallTool } from '@/tools/twilio_voice/make_call'
export { getRecordingTool, listCallsTool, makeCallTool }
+183
View File
@@ -0,0 +1,183 @@
import { createLogger } from '@sim/logger'
import type { TwilioListCallsOutput, TwilioListCallsParams } from '@/tools/twilio_voice/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('TwilioVoiceListCallsTool')
export const listCallsTool: ToolConfig<TwilioListCallsParams, TwilioListCallsOutput> = {
id: 'twilio_voice_list_calls',
name: 'Twilio Voice List Calls',
description: 'Retrieve a list of calls made to and from an account.',
version: '1.0.0',
params: {
accountSid: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Account SID',
},
authToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Auth Token',
},
to: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by calls to this phone number in E.164 format (e.g., +14155551234)',
},
from: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by calls from this phone number in E.164 format (e.g., +14155559876)',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Filter by call status (e.g., queued, ringing, in-progress, completed, busy, failed, no-answer, canceled)',
},
startTimeAfter: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Filter calls that started on or after this date (YYYY-MM-DD)',
},
startTimeBefore: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Filter calls that started on or before this date (YYYY-MM-DD)',
},
pageSize: {
type: 'number',
required: false,
visibility: 'user-only',
description: 'Number of records to return (max 1000, default 50)',
},
},
request: {
url: (params) => {
if (!params.accountSid) {
throw new Error('Twilio Account SID is required')
}
if (!params.accountSid.startsWith('AC')) {
throw new Error(
`Invalid Account SID format. Account SID must start with "AC" (you provided: ${params.accountSid.substring(0, 2)}...)`
)
}
const baseUrl = `https://api.twilio.com/2010-04-01/Accounts/${params.accountSid}/Calls.json`
const queryParams = new URLSearchParams()
if (params.to) queryParams.append('To', params.to)
if (params.from) queryParams.append('From', params.from)
if (params.status) queryParams.append('Status', params.status)
if (params.startTimeAfter) queryParams.append('StartTime>', params.startTimeAfter)
if (params.startTimeBefore) queryParams.append('StartTime<', params.startTimeBefore)
if (params.pageSize) queryParams.append('PageSize', Number(params.pageSize).toString())
const queryString = queryParams.toString()
return queryString ? `${baseUrl}?${queryString}` : baseUrl
},
method: 'GET',
headers: (params) => {
if (!params.accountSid || !params.authToken) {
throw new Error('Twilio credentials are required')
}
const authToken = Buffer.from(`${params.accountSid}:${params.authToken}`).toString('base64')
return {
Authorization: `Basic ${authToken}`,
}
},
},
transformResponse: async (response, params) => {
const data = await response.json()
logger.info('Twilio List Calls Response:', { total: data.calls?.length || 0 })
if (data.error_code) {
return {
success: false,
output: {
success: false,
calls: [],
error: data.message || data.error_message || 'Failed to retrieve calls',
},
error: data.message || data.error_message || 'Failed to retrieve calls',
}
}
const authToken = Buffer.from(`${params?.accountSid}:${params?.authToken}`).toString('base64')
const calls = await Promise.all(
(data.calls || []).map(async (call: any) => {
let recordingSids: string[] = []
if (call.subresource_uris?.recordings) {
try {
const recordingsUrl = `https://api.twilio.com${call.subresource_uris.recordings}`
const recordingsResponse = await fetch(recordingsUrl, {
method: 'GET',
headers: { Authorization: `Basic ${authToken}` },
})
if (recordingsResponse.ok) {
const recordingsData = await recordingsResponse.json()
recordingSids = (recordingsData.recordings || []).map((rec: any) => rec.sid)
}
} catch (error) {
logger.warn(`Failed to fetch recordings for call ${call.sid}:`, error)
}
}
return {
callSid: call.sid,
from: call.from,
to: call.to,
status: call.status,
direction: call.direction,
duration: call.duration ? Number.parseInt(call.duration, 10) : null,
price: call.price,
priceUnit: call.price_unit,
startTime: call.start_time,
endTime: call.end_time,
dateCreated: call.date_created,
recordingSids,
}
})
)
logger.info('Transformed calls with recordings:', {
totalCalls: calls.length,
callsWithRecordings: calls.filter((c) => c.recordingSids.length > 0).length,
})
return {
success: true,
output: {
success: true,
calls,
total: calls.length,
page: data.page,
pageSize: data.page_size,
},
error: undefined,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the calls were successfully retrieved' },
calls: { type: 'array', description: 'Array of call objects' },
total: { type: 'number', description: 'Total number of calls returned' },
page: { type: 'number', description: 'Current page number' },
pageSize: { type: 'number', description: 'Number of calls per page' },
error: { type: 'string', description: 'Error message if retrieval failed' },
},
}
+220
View File
@@ -0,0 +1,220 @@
import { createLogger } from '@sim/logger'
import { convertSquareBracketsToTwiML } from '@/lib/webhooks/utils'
import type { TwilioCallOutput, TwilioMakeCallParams } from '@/tools/twilio_voice/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('TwilioVoiceMakeCallTool')
export const makeCallTool: ToolConfig<TwilioMakeCallParams, TwilioCallOutput> = {
id: 'twilio_voice_make_call',
name: 'Twilio Voice Make Call',
description: 'Make an outbound phone call using Twilio Voice API.',
version: '1.0.0',
params: {
to: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Phone number to call in E.164 format (e.g., +14155551234)',
},
from: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Your Twilio phone number to call from in E.164 format (e.g., +14155559876)',
},
url: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Webhook URL that returns TwiML instructions for the call (e.g., https://example.com/twiml)',
},
twiml: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'TwiML instructions to execute. Use square brackets instead of angle brackets (e.g., [Response][Say]Hello[/Say][/Response])',
},
statusCallback: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Webhook URL for call status updates',
},
statusCallbackMethod: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'HTTP method for status callback (GET or POST)',
},
accountSid: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Account SID',
},
authToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Twilio Auth Token',
},
record: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Whether to record the call',
},
recordingStatusCallback: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Webhook URL for recording status updates',
},
timeout: {
type: 'number',
required: false,
visibility: 'user-only',
description: 'Time to wait for answer before giving up (seconds, default: 60)',
},
machineDetection: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Answering machine detection: Enable or DetectMessageEnd',
},
},
request: {
url: (params) => {
if (!params.accountSid) {
throw new Error('Twilio Account SID is required')
}
if (!params.accountSid.startsWith('AC')) {
throw new Error(
`Invalid Account SID format. Account SID must start with "AC" (you provided: ${params.accountSid.substring(0, 2)}...)`
)
}
return `https://api.twilio.com/2010-04-01/Accounts/${params.accountSid}/Calls.json`
},
method: 'POST',
headers: (params) => {
if (!params.accountSid || !params.authToken) {
throw new Error('Twilio credentials are required')
}
const authToken = Buffer.from(`${params.accountSid}:${params.authToken}`).toString('base64')
return {
Authorization: `Basic ${authToken}`,
'Content-Type': 'application/x-www-form-urlencoded',
}
},
body: ((params) => {
if (!params.to) {
throw new Error('Destination phone number (to) is required')
}
if (!params.from) {
throw new Error('Source phone number (from) is required')
}
if (!params.url && !params.twiml) {
throw new Error('Either URL or TwiML is required to execute the call')
}
logger.info('Make call params:', {
to: params.to,
from: params.from,
record: params.record,
recordType: typeof params.record,
})
const formData = new URLSearchParams()
formData.append('To', params.to)
formData.append('From', params.from)
if (params.url) {
formData.append('Url', params.url)
} else if (params.twiml) {
const convertedTwiml = convertSquareBracketsToTwiML(params.twiml) || params.twiml
formData.append('Twiml', convertedTwiml)
}
if (params.statusCallback) {
formData.append('StatusCallback', params.statusCallback)
}
if (params.statusCallbackMethod) {
formData.append('StatusCallbackMethod', params.statusCallbackMethod)
}
if (params.record === true) {
logger.info('Enabling call recording')
formData.append('Record', 'true')
}
if (params.recordingStatusCallback) {
formData.append('RecordingStatusCallback', params.recordingStatusCallback)
}
if (params.timeout) {
formData.append('Timeout', Number(params.timeout).toString())
}
if (params.machineDetection) {
formData.append('MachineDetection', params.machineDetection)
}
const bodyString = formData.toString()
logger.info('Final Twilio request body:', bodyString)
return bodyString as any
}) as (params: TwilioMakeCallParams) => Record<string, any>,
},
transformResponse: async (response) => {
const data = await response.json()
logger.info('Twilio Make Call Response:', data)
if (data.error_code || data.status === 'failed') {
return {
success: false,
output: {
success: false,
error: data.message || data.error_message || 'Call failed',
},
error: data.message || data.error_message || 'Call failed',
}
}
return {
success: true,
output: {
success: true,
callSid: data.sid,
status: data.status,
direction: data.direction,
from: data.from,
to: data.to,
duration: data.duration,
price: data.price,
priceUnit: data.price_unit,
},
error: undefined,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the call was successfully initiated' },
callSid: { type: 'string', description: 'Unique identifier for the call' },
status: {
type: 'string',
description: 'Call status (queued, ringing, in-progress, completed, etc.)',
},
direction: { type: 'string', description: 'Call direction (outbound-api)' },
from: { type: 'string', description: 'Phone number the call is from' },
to: { type: 'string', description: 'Phone number the call is to' },
duration: { type: 'number', description: 'Call duration in seconds' },
price: { type: 'string', description: 'Cost of the call' },
priceUnit: { type: 'string', description: 'Currency of the price' },
error: { type: 'string', description: 'Error message if call failed' },
},
}
+98
View File
@@ -0,0 +1,98 @@
import type { ToolFileData, ToolResponse } from '@/tools/types'
export interface TwilioMakeCallParams {
to: string
from: string
url?: string
twiml?: string
statusCallback?: string
statusCallbackMethod?: 'GET' | 'POST'
statusCallbackEvent?: string[]
accountSid: string
authToken: string
record?: boolean
recordingStatusCallback?: string
recordingStatusCallbackMethod?: 'GET' | 'POST'
timeout?: number
machineDetection?: 'Enable' | 'DetectMessageEnd'
asyncAmd?: boolean
asyncAmdStatusCallback?: string
}
export interface TwilioCallOutput extends ToolResponse {
output: {
success: boolean
callSid?: string
status?: string
direction?: string
from?: string
to?: string
duration?: number
price?: string
priceUnit?: string
error?: string
}
}
export interface TwilioGetRecordingParams {
recordingSid: string
accountSid: string
authToken: string
}
export interface TwilioGetRecordingOutput extends ToolResponse {
output: {
success: boolean
recordingSid?: string
callSid?: string
duration?: number
status?: string
channels?: number
source?: string
mediaUrl?: string
file?: ToolFileData
price?: string
priceUnit?: string
uri?: string
transcriptionText?: string
transcriptionStatus?: string
transcriptionPrice?: string
transcriptionPriceUnit?: string
error?: string
}
}
export interface TwilioListCallsParams {
accountSid: string
authToken: string
to?: string
from?: string
status?: string
startTimeAfter?: string
startTimeBefore?: string
pageSize?: number
}
export interface TwilioListCallsOutput extends ToolResponse {
output: {
success: boolean
calls?: Array<{
callSid: string
from: string
to: string
status: string
direction: string
duration: number | null
price: string | null
priceUnit: string
startTime: string
endTime: string | null
dateCreated: string
recordingSids: string[]
}>
total?: number
page?: number
pageSize?: number
error?: string
}
}