Agent Skills › simstudioai/sim › add-enrichment

add-enrichment

GitHub

指导如何为 Sim 平台添加代码定义的行级表格数据增强功能。涵盖选择数据源工具、验证托管密钥支持、编写和注册增强定义,以及确保调用工具具备 hosted-key 能力以自动计费。

.agents/skills/add-enrichment/SKILL.md simstudioai/sim

触发场景

需要向表格行添加通过现有工具填充的数据字段 创建新的表格列增强逻辑 配置支持托管密钥的数据提供商

安装

npx skills add simstudioai/sim --skill add-enrichment -g -y
更多选项

非标准路径

npx skills add https://github.com/simstudioai/sim/tree/main/.agents/skills/add-enrichment -g -y

不安装直接使用

npx skills use simstudioai/sim@add-enrichment

指定 Agent (Claude Code)

npx skills add simstudioai/sim --skill add-enrichment -a claude-code -g -y

安装 repo 全部 skill

npx skills add simstudioai/sim --all -g -y

预览 repo 内 skill

npx skills add simstudioai/sim --list

SKILL.md

Frontmatter
{
    "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": "<enrichment-name>"
}

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

Step What Where
1 Pick the data-source tool(s) for each output tools/{service}/ + tools/registry.ts
2 Verify each tool has hosting; if not, run /add-hosted-key tools/{service}/{action}.ts
3 Write the enrichment definition enrichments/{id}/{id}.ts + index.ts
4 Register it enrichments/registry.ts
5 Verify tsc / 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, isVerified? } — 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, and per-row execution 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 by accuracy first, then price per hit. Order decides which answer wins when two providers would disagree, so a cheaper but less accurate provider ahead of a better one trades quality for cost; reorder for price only with benchmark evidence. Among similarly accurate providers, put the ones that bill on a miss or charge a high price per hit after the cheaper, free-on-miss ones (check each vendor's billing docs and the tool's hosting.pricing); never move a more accurate provider behind a less accurate one to save cost. The cascade stops at the first non-empty, verified result. Apollo and LinkedIn APIs are not hosted-safe (ToS) — never call them as providers.

Prefer a vendor's own verified-only option (e.g. Prospeo only_verified_email) when it turns an unverified result into a free miss. Otherwise, when a provider can return an unconfirmed hit (a catch-all guess, a risky status), declare isVerified(output): an unconfirmed hit is held while later providers look for a confirmed one, and fills the cell only if none does. isVerified: false marks a provider that never confirms its hits (a database record); it runs only while nothing is held.

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/{id}/{id}.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.
        const name = splitName(inputs.fullName)
        const domain = normalizeDomain(inputs.companyDomain)
        if (!name || !domain) return null
        return { domain, first_name: name.firstName, last_name: name.lastName }
      },
      mapOutput: (output) => {
        // Return { [outputId]: value } on a hit, or null to fall through.
        const value = str(output.value)
        return value ? { value } : null
      },
    }),
    // ...additional fallback providers, in priority order.
  ],
}
// apps/sim/enrichments/{id}/index.ts
export { myEnrichment } from './my-enrichment'

Rules:

  • Keep the file client-safe: import only @sim/emcn/icons, @sim/utils/*, @/enrichments/providers, @/enrichments/provider-failures/*, and the types. Never import @/tools here — the runner does the tool call.
  • buildParams returns null when inputs are insufficient (provider skipped). mapOutput returns null/empty for a miss (falls through). Use filterUndefined when assembling optional tool params; coerce numbers explicitly (don't pass '' to number outputs).
  • Output ids are the keys mapOutput returns; output names are the default column names (the user can rename them in the config).

Step 4: Register it

In apps/sim/enrichments/registry.ts, import and add the entry (catalog order is registration order):

import { myEnrichment } from '@/enrichments/{id}'

export const ENRICHMENT_REGISTRY: EnrichmentRegistry = {
  // ...existing
  [myEnrichment.id]: myEnrichment,
}

Step 5: Verify

  1. bun run type-check (from apps/sim) and bunx biome check on the changed files.
  2. In a table → + New column → Enrichments → pick the new enrichment, map its inputs to columns, name the output column(s), Save. Confirm it appears in the catalog with its icon/description.
  3. With hosted keys (or a workspace BYOK key) configured for each provider's service, run a row and confirm the cell fills; the dev-server log shows Enrichment hit { provider }. A row whose providers all miss completes blank; a row where every provider errored shows an error cell.

Checklist

  • Each output mapped to a real tool field (verified against the tool's params/outputs)
  • Every provider tool has a hosting block — ran /add-hosted-key for any that didn't
  • Providers ordered accuracy-first, then price per hit (billing on a miss checked against vendor docs); Apollo/LinkedIn not used
  • Providers that can return an unconfirmed hit declare isVerified
  • Enrichment file is client-safe (no @/tools import); uses toolProvider + shared helpers
  • buildParams returns null on insufficient inputs; mapOutput returns null on a miss
  • Registered in enrichments/registry.ts
  • tsc + biome clean; created and ran the column end-to-end

版本历史

  • c6cef5f 当前 2026-10-20 02:37

    优化了提供商瀑布流顺序以降低成本并提高准确性;修复了账单逻辑;增加了故障时的错误状态处理,防止静默生成空行。

  • 6dfb467 2026-09-23 06:35
  • ceda457 2026-08-20 15:28

同 Skill 集合

.agents/skills/add-block-preview/SKILL.md
.agents/skills/add-block/SKILL.md
.agents/skills/add-column-type/SKILL.md
.agents/skills/add-connector/SKILL.md
.agents/skills/add-feature-flag/SKILL.md
.agents/skills/add-hosted-key/SKILL.md
.agents/skills/add-integration/SKILL.md
.agents/skills/add-managed-cli/SKILL.md
.agents/skills/add-model/SKILL.md
.agents/skills/add-permission-group-item/SKILL.md
.agents/skills/add-selector/SKILL.md
.agents/skills/add-settings-page/SKILL.md
.agents/skills/add-tools/SKILL.md
.agents/skills/add-trigger/SKILL.md
.agents/skills/babysit/SKILL.md
.agents/skills/cleanup/SKILL.md
.agents/skills/council/SKILL.md
.agents/skills/db-migrate/SKILL.md
.agents/skills/design-taste-frontend/SKILL.md
.agents/skills/emcn-design-review/SKILL.md
.agents/skills/emil-design-eng/SKILL.md
.agents/skills/make-interfaces-feel-better/SKILL.md
.agents/skills/memory-load-check/SKILL.md
.agents/skills/react-query-best-practices/SKILL.md
.agents/skills/ship/SKILL.md
.agents/skills/test-audit/SKILL.md
.agents/skills/tool-registry-boundary/SKILL.md
.agents/skills/v2-api-conventions/SKILL.md
.agents/skills/validate-connector/SKILL.md
.agents/skills/validate-integration/SKILL.md
.agents/skills/validate-model/SKILL.md
.agents/skills/validate-permission-group-item/SKILL.md
.agents/skills/validate-selector/SKILL.md
.agents/skills/validate-trigger/SKILL.md
.agents/skills/you-might-not-need-a-callback/SKILL.md
.agents/skills/you-might-not-need-a-comment/SKILL.md
.agents/skills/you-might-not-need-a-memo/SKILL.md
.agents/skills/you-might-not-need-an-effect/SKILL.md
.agents/skills/you-might-not-need-state/SKILL.md
.agents/skills/you-might-not-need-url-state/SKILL.md
.claude/skills/add-settings-page/SKILL.md
helm/sim/.claude/skills/sim-helm/SKILL.md
.agents/skills/migrate-application-operation/SKILL.md

元信息

文件数
0
版本
c6cef5f
Hash
204b48ee
收录时间
2026-08-20 15:28

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-21 16:27
浙ICP备14020137号-1