Skip to content

Commit 65b1ca1

Browse files
authored
feat(context-dev): add Context.dev to hosted key rotation pool (#5576)
Wires all 22 context_dev tools into the same hosted-key mechanism as Exa: CONTEXT_DEV_API_KEY_COUNT/1..N rotation, BYOK provider registration, and hideWhenHosted on the block's API key field. Cost is read directly from each response's reported credits_consumed rather than estimated per endpoint.
1 parent 5de66db commit 65b1ca1

29 files changed

Lines changed: 177 additions & 0 deletions

apps/sim/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ API_ENCRYPTION_KEY=your_api_encryption_key # Use `openssl rand -hex 32` to gener
7777
# PEOPLEDATALABS_API_KEY_COUNT=2 # Number of People Data Labs keys for hosted PDL blocks
7878
# PEOPLEDATALABS_API_KEY_1= # People Data Labs API key #1
7979
# PEOPLEDATALABS_API_KEY_2= # People Data Labs API key #2
80+
# CONTEXT_DEV_API_KEY_COUNT=2 # Number of Context.dev keys for hosted Context.dev blocks
81+
# CONTEXT_DEV_API_KEY_1= # Context.dev API key #1
82+
# CONTEXT_DEV_API_KEY_2= # Context.dev API key #2
8083

8184
# File Storage (Optional - defaults to local disk; use S3 or Azure Blob for production)
8285
# AWS_REGION=us-east-1 # Required with S3_BUCKET_NAME to enable S3. Use "auto" for Cloudflare R2

apps/sim/app/workspace/[workspaceId]/settings/components/byok/byok.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
AnthropicIcon,
77
BasetenIcon,
88
BrandfetchIcon,
9+
ContextDevIcon,
910
DatagmaIcon,
1011
DropcontactIcon,
1112
EnrowIcon,
@@ -124,6 +125,13 @@ const PROVIDERS: (BYOKManagerProvider & { id: BYOKProviderId })[] = [
124125
description: 'AI-powered search and research',
125126
placeholder: 'Enter your Exa API key',
126127
},
128+
{
129+
id: 'context_dev',
130+
name: 'Context.dev',
131+
icon: ContextDevIcon,
132+
description: 'Web scraping, crawling, search, and brand intelligence',
133+
placeholder: 'Enter your Context.dev API key',
134+
},
127135
{
128136
id: 'serper',
129137
name: 'Serper',
@@ -291,6 +299,7 @@ const PROVIDER_SECTIONS: BYOKProviderSection[] = [
291299
ids: [
292300
'firecrawl',
293301
'exa',
302+
'context_dev',
294303
'serper',
295304
'linkup',
296305
'parallel_ai',

apps/sim/blocks/blocks/context_dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ Do not include any explanations, markdown formatting, or other text outside the
540540
placeholder: 'Enter your Context.dev API key',
541541
password: true,
542542
required: true,
543+
hideWhenHosted: true,
543544
},
544545
],
545546
tools: {

apps/sim/lib/api/contracts/byok-keys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const byokProviderIdSchema = z.enum([
1414
'falai',
1515
'firecrawl',
1616
'exa',
17+
'context_dev',
1718
'serper',
1819
'linkup',
1920
'perplexity',

apps/sim/tools/context_dev/classify_naics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type {
23
ContextDevClassifyNaicsParams,
34
ContextDevClassifyNaicsResponse,
@@ -22,6 +23,8 @@ export const contextDevClassifyNaicsTool: ToolConfig<
2223
description: 'Classify a brand into NAICS industry codes from its domain or company name.',
2324
version: '1.0.0',
2425

26+
hosting: contextDevHosting<ContextDevClassifyNaicsParams>(),
27+
2528
params: {
2629
input: {
2730
type: 'string',

apps/sim/tools/context_dev/classify_sic.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type {
23
ContextDevClassifySicParams,
34
ContextDevClassifySicResponse,
@@ -22,6 +23,8 @@ export const contextDevClassifySicTool: ToolConfig<
2223
description: 'Classify a brand into SIC industry codes from its domain or company name.',
2324
version: '1.0.0',
2425

26+
hosting: contextDevHosting<ContextDevClassifySicParams>(),
27+
2528
params: {
2629
input: {
2730
type: 'string',

apps/sim/tools/context_dev/crawl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type { ContextDevCrawlParams, ContextDevCrawlResponse } from '@/tools/context_dev/types'
23
import { CRAWL_RESULT_OUTPUT_PROPERTIES } from '@/tools/context_dev/types'
34
import {
@@ -15,6 +16,8 @@ export const contextDevCrawlTool: ToolConfig<ContextDevCrawlParams, ContextDevCr
1516
description: 'Crawl an entire website and return each discovered page as clean markdown.',
1617
version: '1.0.0',
1718

19+
hosting: contextDevHosting<ContextDevCrawlParams>(),
20+
1821
params: {
1922
url: {
2023
type: 'string',

apps/sim/tools/context_dev/extract.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type { ContextDevExtractParams, ContextDevExtractResponse } from '@/tools/context_dev/types'
23
import {
34
CONTEXT_DEV_BASE_URL,
@@ -15,6 +16,8 @@ export const contextDevExtractTool: ToolConfig<ContextDevExtractParams, ContextD
1516
description: 'Crawl a website and extract structured data matching a provided JSON schema.',
1617
version: '1.0.0',
1718

19+
hosting: contextDevHosting<ContextDevExtractParams>(),
20+
1821
params: {
1922
url: {
2023
type: 'string',

apps/sim/tools/context_dev/extract_product.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type {
23
ContextDevExtractProductParams,
34
ContextDevExtractProductResponse,
@@ -21,6 +22,8 @@ export const contextDevExtractProductTool: ToolConfig<
2122
description: 'Detect and extract structured product details from a single product page URL.',
2223
version: '1.0.0',
2324

25+
hosting: contextDevHosting<ContextDevExtractProductParams>(),
26+
2427
params: {
2528
url: {
2629
type: 'string',

apps/sim/tools/context_dev/extract_products.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { contextDevHosting } from '@/tools/context_dev/hosting'
12
import type {
23
ContextDevExtractProductsParams,
34
ContextDevExtractProductsResponse,
@@ -21,6 +22,8 @@ export const contextDevExtractProductsTool: ToolConfig<
2122
description: "Extract the product catalog from a brand's website by domain (beta).",
2223
version: '1.0.0',
2324

25+
hosting: contextDevHosting<ContextDevExtractProductsParams>(),
26+
2427
params: {
2528
domain: {
2629
type: 'string',

0 commit comments

Comments
 (0)