Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Development

add-enrichment

Add a code-defined table enrichment (registry entry) under `apps/sim/enrichments/` backed by an ordered provider cascade, ensuring every provider tool it calls has hosted-key support. Use when adding a per-row table enrichment that fills cells via existing Sim tools.

simstudioai · AI review on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add simstudioai/sim --skill add-enrichment

About this skill


name: add-enrichment description: Add a code-defined table enrichment (registry entry) under apps/sim/enrichments/ backed by an ordered provider cascade, ensuring every provider tool it calls has hosted-key support. Use when adding a per-row table enrichment that fills cells via existing Sim tools. argument-hint:

Adding a Table Enrichment

Enrichments are code-defined entries in apps/sim/enrichments/ that run directly per table row (no workflow). Each enrichment declares inputs, outputs, and an ordered list of providers; the cascade runner tries providers in order and the first non-empty result fills the cell. Each provider calls one existing Sim tool via executeTool, which injects the workspace's BYOK key or a hosted key and bills usage automatically.

Because enrichments run on Sim's hosted keys by default, every provider tool you reference must have hosted-key support — otherwise it can only run when the workspace brings its own key. This command makes that check a required step.

Overview

StepWhatWhere
1Pick the data-source tool(s) for each outputtools/{service}/ + tools/registry.ts
2Verify each tool has hosting; if not, run /add-hosted-keytools/{service}/{action}.ts
3Write the enrichment definitionenrichments/{name}/{name}.ts + index.ts
4Register itenrichments/registry.ts
5Verifytsc / biome / manual run

Architecture (what you're plugging into)

  • enrichments/types.ts — EnrichmentConfig { id, name, description, icon, inputs, outputs, providers } and EnrichmentProvider { id, label, toolId, buildParams, projectFailure, mapOutput } — toolProvider fills projectFailure with the standard HTTP projection; override it only for a provider whose failure shape is nonstandard (see enrichments/provider-failures/). Providers are plain data (no @/tools import) so the catalog stays client-safe.
  • enrichments/providers.ts — toolProvider(...) (typed passthrough) plus shared input helpers: str(v), normalizeDomain(v), firstNonEmpty(arr), splitName(fullName), and projectEnrichmentProviderFailure.
  • enrichments/run.ts — the server-only cascade runner. Calls executeTool(provider.toolId, { ...params, _context: { workspaceId, userId } }), accumulates hosted-key cost, returns the first non-empty mapped result. You do not edit this — it works for any registry entry.
  • enrichments/registry.ts — ENRICHMENT_REGISTRY / ALL_ENRICHMENTS / getEnrichment. Register new entries here.

Outputs automatically become table columns; billing, the catalog/sidebar UI, the column meta-header icon, and per-row execution all work with no extra wiring.

Step 1: Pick the data-source tool(s)

For each output the enrichment produces, decide which existing tool provides it. Look up the service's API and the tool in apps/sim/tools/{service}/ (e.g. hunter_email_finder, pdl_person_enrich, pdl_company_enrich). Confirm:

  • The tool id is registered in apps/sim/tools/registry.ts.
  • Its params accept what you can derive from table columns (read the tool's params).
  • Its outputs / transformResponse actually expose the field you need (read the real output shape — don't assume).

Order providers cheapest / most-likely-to-hit first; the cascade stops at the first non-empty result. Apollo / LinkedIn are not hosted-safe (ToS) — don't use them.

Step 2: Verify hosted-key support — chain to /add-hosted-key if missing

This is the required gate. For every tool a provider calls, open apps/sim/tools/{service}/{action}.ts and check for a hosting block:

hosting: {
  envKeyPrefix: 'SERVICE_API_KEY',
  apiKeyParam: 'apiKey',
  byokProviderId: 'service',
  pricing: { /* ... */ },
  rateLimit: { /* ... */ },
}
  • If hosting is present — good. Note the envKeyPrefix; the deployment needs {PREFIX}_COUNT + {PREFIX}_1..N env vars set for the hosted key to actually resolve at runtime (ops concern, not code). If those env vars aren't set in the target environment, the provider will only run with a workspace BYOK key.
  • If hosting is absent — the tool can't use a Sim-provided key, so the enrichment would silently produce blank cells on hosted Sim. Stop and run /add-hosted-key <service> to add hosted-key support to that tool first, then come back. Do this for every provider tool that lacks it.

Why it matters: the cascade runner only bills (and only reads output.cost.total) when executeTool injected a hosted key, which requires the tool's hosting config. No hosting → no hosted key → the enrichment depends entirely on per-workspace BYOK.

Step 3: Write the enrichment definition

Create apps/sim/enrichments/{name}/{name}.ts and a barrel index.ts. Mirror the entries registered in enrichments/registry.ts.

import { SomeIcon } from '@sim/emcn/icons'
import { filterUndefined } from '@sim/utils/object'
import { normalizeDomain, splitName, str, toolProvider } from '@/enrichments/providers'
import type { EnrichmentConfig } from '@/enrichments/types'

export const myEnrichment: EnrichmentConfig = {
  id: 'my-enrichment',
  name: 'My Enrichment',
  description: 'One concise sentence describing what it finds.',
  icon: SomeIcon,
  inputs: [
    // Person enrichments take a single canonical `fullName` (Clay-style);
    // split it with splitName() for tools that need first/last.
    { id: 'fullName', name: 'Full name', type: 'string', required: true },
    { id: 'companyDomain', name: 'Company domain', type: 'string' },
  ],
  outputs: [{ id: 'value', name: 'value', type: 'string' }],
  providers: [
    toolProvider({
      id: 'provider-a',
      label: 'Provider A',
      toolId: 'service_action', // must have `hosting` (Step 2)
      buildParams: (inputs) => {
        // Return null when there aren't enough inputs → cascade skips this provider.
Read the complete source ↗