Files
simstudioai--sim/apps/sim/tools/sixtyfour/enrich_lead.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

106 lines
3.0 KiB
TypeScript

import type {
SixtyfourEnrichLeadParams,
SixtyfourEnrichLeadResponse,
} from '@/tools/sixtyfour/types'
import type { ToolConfig } from '@/tools/types'
export const sixtyfourEnrichLeadTool: ToolConfig<
SixtyfourEnrichLeadParams,
SixtyfourEnrichLeadResponse
> = {
id: 'sixtyfour_enrich_lead',
name: 'Sixtyfour Enrich Lead',
description:
'Enrich lead information with contact details, social profiles, and company data using Sixtyfour AI.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Sixtyfour API key',
},
leadInfo: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Lead information as JSON object with key-value pairs (e.g. name, company, title, linkedin)',
},
struct: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Fields to collect as JSON object. Keys are field names, values are descriptions (e.g. {"email": "The individual\'s email address", "phone": "Phone number"})',
},
researchPlan: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optional research plan to guide enrichment strategy',
},
},
request: {
url: 'https://api.sixtyfour.ai/enrich-lead',
method: 'POST',
headers: (params) => ({
'Content-Type': 'application/json',
'x-api-key': params.apiKey,
}),
body: (params) => {
let leadInfo: unknown
try {
leadInfo =
typeof params.leadInfo === 'string' ? JSON.parse(params.leadInfo) : params.leadInfo
} catch {
throw new Error('leadInfo must be valid JSON')
}
let struct: unknown
try {
struct = typeof params.struct === 'string' ? JSON.parse(params.struct) : params.struct
} catch {
throw new Error('struct must be valid JSON')
}
return {
lead_info: leadInfo,
struct,
...(params.researchPlan && { research_plan: params.researchPlan }),
}
},
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || data.message || data.detail || `API error: ${response.status}`)
}
return {
success: true,
output: {
notes: data.notes ?? null,
structuredData: data.structured_data ?? {},
references: data.references ?? {},
confidenceScore: data.confidence_score ?? null,
},
}
},
outputs: {
notes: { type: 'string', description: 'Research notes about the lead', optional: true },
structuredData: {
type: 'json',
description: 'Enriched lead data matching the requested struct fields',
},
references: { type: 'json', description: 'Source URLs and descriptions used for enrichment' },
confidenceScore: {
type: 'number',
description: 'Quality score for the returned data (0-10)',
optional: true,
},
},
}