Files
simstudioai--sim/apps/sim/tools/peopledatalabs/school_clean.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

105 lines
3.0 KiB
TypeScript

import type { PdlCleanSchoolParams, PdlCleanSchoolResponse } from '@/tools/peopledatalabs/types'
import {
PDL_SCHOOL_OUTPUT_PROPERTIES,
PEOPLEDATALABS_API_KEY_PREFIX,
} from '@/tools/peopledatalabs/types'
import { projectSchool } from '@/tools/peopledatalabs/utils'
import type { ToolConfig } from '@/tools/types'
export const cleanSchoolTool: ToolConfig<PdlCleanSchoolParams, PdlCleanSchoolResponse> = {
id: 'pdl_clean_school',
name: 'PDL School Cleaner',
description:
'Normalize a school string into a canonical school record. Provide at least one of name, website, or profile (LinkedIn URL).',
version: '1.0.0',
hosting: {
envKeyPrefix: PEOPLEDATALABS_API_KEY_PREFIX,
apiKeyParam: 'apiKey',
byokProviderId: 'peopledatalabs',
// Cleaner APIs are free on PDL (rate-limited only) — no credits consumed.
pricing: { type: 'per_request', cost: 0 },
rateLimit: {
mode: 'per_request',
requestsPerMinute: 60,
},
},
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'People Data Labs API key',
},
name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Raw school name to normalize',
},
website: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'School website',
},
profile: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'LinkedIn school URL',
},
},
request: {
url: () => 'https://api.peopledatalabs.com/v5/school/clean',
method: 'POST',
headers: (params) => ({
'X-Api-Key': params.apiKey,
'Content-Type': 'application/json',
Accept: 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.name) body.name = params.name
if (params.website) body.website = params.website
if (params.profile) body.profile = params.profile
return body
},
},
transformResponse: async (response: Response) => {
const data = (await response.json()) as Record<string, unknown>
const status = (data.status as number) ?? response.status
if (status === 404) {
return { success: true, output: { matched: false, school: null } }
}
if (!response.ok) {
const error = (data.error as { message?: string })?.message
throw new Error(error || `People Data Labs error: ${response.status}`)
}
const hasFields = data.name || data.website || data.id
return {
success: true,
output: {
matched: Boolean(hasFields),
school: hasFields ? projectSchool(data) : null,
},
}
},
outputs: {
matched: { type: 'boolean', description: 'Whether the input was matched to a known school' },
school: {
type: 'object',
description: 'Canonical school record',
optional: true,
properties: PDL_SCHOOL_OUTPUT_PROPERTIES,
},
},
}