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

170 lines
5.6 KiB
TypeScript

import { prospeoHosting } from '@/tools/prospeo/hosting'
import {
extractProspeoError,
type ProspeoEnrichPersonParams,
type ProspeoEnrichPersonResponse,
} from '@/tools/prospeo/types'
import type { ToolConfig } from '@/tools/types'
export const enrichPersonTool: ToolConfig<ProspeoEnrichPersonParams, ProspeoEnrichPersonResponse> =
{
id: 'prospeo_enrich_person',
name: 'Prospeo Enrich Person',
description: 'Enrich a person with complete B2B profile data, email address and mobile.',
version: '1.0.0',
hosting: prospeoHosting<ProspeoEnrichPersonParams>((_params, output) => {
// No charge on a no-match or a repeat enrichment.
if (output.free_enrichment === true) return 0
const person = output.person as Record<string, unknown> | null
if (!person) return 0
// 10 credits when a mobile is revealed, otherwise 1 for the person match.
const mobile = person.mobile as { revealed?: boolean } | undefined
return mobile?.revealed ? 10 : 1
}),
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Prospeo API key',
},
first_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'First name of the person',
},
last_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Last name of the person',
},
full_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Full name of the person (alternative to first_name + last_name)',
},
linkedin_url: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: "Person's public LinkedIn URL",
},
email: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Work email of the person',
},
company_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Company name',
},
company_website: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Company website',
},
company_linkedin_url: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: "Company's public LinkedIn URL",
},
person_id: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Prospeo person_id from a previous Search Person response',
},
only_verified_email: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Only return records with a verified email',
},
enrich_mobile: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Reveal mobile number (10 credits per match; email included)',
},
only_verified_mobile: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Only return records that have a mobile (implies enrich_mobile)',
},
},
request: {
url: 'https://api.prospeo.io/enrich-person',
method: 'POST',
headers: (params) => ({
'X-KEY': params.apiKey,
'Content-Type': 'application/json',
}),
body: (params) => {
const data: Record<string, unknown> = {}
if (params.first_name) data.first_name = params.first_name
if (params.last_name) data.last_name = params.last_name
if (params.full_name) data.full_name = params.full_name
if (params.linkedin_url) data.linkedin_url = params.linkedin_url
if (params.email) data.email = params.email
if (params.company_name) data.company_name = params.company_name
if (params.company_website) data.company_website = params.company_website
if (params.company_linkedin_url) data.company_linkedin_url = params.company_linkedin_url
if (params.person_id) data.person_id = params.person_id
const body: Record<string, unknown> = { data }
if (params.only_verified_email !== undefined)
body.only_verified_email = params.only_verified_email
if (params.enrich_mobile !== undefined) body.enrich_mobile = params.enrich_mobile
if (params.only_verified_mobile !== undefined)
body.only_verified_mobile = params.only_verified_mobile
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
throw new Error(await extractProspeoError(response))
}
const data = await response.json()
return {
success: true,
output: {
free_enrichment: data.free_enrichment ?? false,
person: data.person ?? null,
company: data.company ?? null,
},
}
},
outputs: {
free_enrichment: {
type: 'boolean',
description: 'True if this enrichment was free (already enriched in the past)',
},
person: {
type: 'json',
description:
'The matched person object including person_id, name, linkedin_url, current_job_title, job_history, mobile, email, location, and skills',
optional: true,
},
company: {
type: 'json',
description:
'The current company of the matched person including name, website, domain, industry, employee_count, location, social URLs, funding, and technology',
optional: true,
},
},
}