Files
simstudioai--sim/apps/sim/tools/agentphone/create_number.ts
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

107 lines
3.0 KiB
TypeScript

import type {
AgentPhoneCreateNumberParams,
AgentPhoneCreateNumberResult,
} from '@/tools/agentphone/types'
import type { ToolConfig } from '@/tools/types'
export const agentphoneCreateNumberTool: ToolConfig<
AgentPhoneCreateNumberParams,
AgentPhoneCreateNumberResult
> = {
id: 'agentphone_create_number',
name: 'Create Phone Number',
description: 'Provision a new SMS- and voice-enabled phone number',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'AgentPhone API key',
},
country: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Two-letter country code (e.g. US, CA). Defaults to US.',
},
areaCode: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Preferred area code (US/CA only, e.g. "415"). Best-effort — may be ignored if unavailable.',
},
agentId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optionally attach the number to an agent immediately',
},
},
request: {
url: 'https://api.agentphone.to/v1/numbers',
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.country) body.country = params.country
if (params.areaCode) body.areaCode = params.areaCode
if (params.agentId) body.agentId = params.agentId
return body
},
},
transformResponse: async (response): Promise<AgentPhoneCreateNumberResult> => {
const data = await response.json()
if (!response.ok) {
return {
success: false,
error: data?.detail?.[0]?.msg ?? data?.message ?? 'Failed to create phone number',
output: {
id: '',
phoneNumber: '',
country: '',
status: '',
type: '',
agentId: null,
createdAt: '',
},
}
}
return {
success: true,
output: {
id: data.id ?? '',
phoneNumber: data.phoneNumber ?? '',
country: data.country ?? '',
status: data.status ?? '',
type: data.type ?? '',
agentId: data.agentId ?? null,
createdAt: data.createdAt ?? '',
},
}
},
outputs: {
id: { type: 'string', description: 'Unique phone number ID' },
phoneNumber: { type: 'string', description: 'Provisioned phone number in E.164 format' },
country: { type: 'string', description: 'Two-letter country code' },
status: { type: 'string', description: 'Number status (e.g. active)' },
type: { type: 'string', description: 'Number type (e.g. sms)', optional: true },
agentId: {
type: 'string',
description: 'Agent the number is attached to',
optional: true,
},
createdAt: { type: 'string', description: 'ISO 8601 timestamp when the number was created' },
},
}