Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,20 @@ In addition, you will need to update the registries:
```

4. **Register Your Block:**
Import and add your block to the blocks registry (`/sim/blocks/index.ts`) in the appropriate index file so it appears in the workflow builder.
Add your block to the blocks registry (`/sim/blocks/registry.ts`):

```typescript:/sim/blocks/index.ts
```typescript:/sim/blocks/registry.ts
import { PineconeBlock } from './blocks/pinecone'

export const blocks = [

// Registry of all available blocks
export const registry: Record<string, BlockConfig> = {
// ... existing blocks
PineconeBlock,
]

export const blocksByType: Record<string, BlockConfig> = {
// ... existing blocks by type
pinecone: PineconeBlock,
}
```

The block will be automatically available to the application through the registry.

5. **Test Your Block:**
Ensure that the block displays correctly in the UI and that its functionality works as expected.

Expand Down
13 changes: 9 additions & 4 deletions sim/blocks/blocks/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { AgentIcon } from '@/components/icons'
import { createLogger } from '@/lib/logs/console-logger'
import { isHosted } from '@/lib/environment'
import { useOllamaStore } from '@/stores/ollama/store'
import { getAllBlocks } from '@/blocks'
import { MODELS_TEMP_RANGE_0_1, MODELS_TEMP_RANGE_0_2 } from '@/providers/model-capabilities'
import { getAllModelProviders, getBaseModelProviders } from '@/providers/utils'
import { ToolResponse } from '@/tools/types'
Expand Down Expand Up @@ -31,9 +30,15 @@ interface AgentResponse extends ToolResponse {

// Helper function to get the tool ID from a block type
const getToolIdFromBlock = (blockType: string): string | undefined => {
const blocks = getAllBlocks()
const block = blocks.find((b) => b.type === blockType)
return block?.tools?.access?.[0]
try {
const { getAllBlocks } = require('@/blocks/registry')
const blocks = getAllBlocks()
const block = blocks.find((b: { type: string; tools?: { access?: string[] } }) => b.type === blockType)
return block?.tools?.access?.[0]
} catch (error) {
logger.error('Error getting tool ID from block', { error })
return undefined
}
}

export const AgentBlock: BlockConfig<AgentResponse> = {
Expand Down
183 changes: 15 additions & 168 deletions sim/blocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,172 +1,19 @@
// Import blocks
import { AgentBlock } from './blocks/agent'
import { AirtableBlock } from './blocks/airtable'
import { ApiBlock } from './blocks/api'
import { BrowserUseBlock } from './blocks/browser_use'
// import { AutoblocksBlock } from './blocks/autoblocks'
import { ConditionBlock } from './blocks/condition'
import { ConfluenceBlock } from './blocks/confluence'
import { GoogleDocsBlock } from './blocks/google_docs'
import { GoogleDriveBlock } from './blocks/drive'
import { ElevenLabsBlock } from './blocks/elevenlabs'
import { EvaluatorBlock } from './blocks/evaluator'
import { ExaBlock } from './blocks/exa'
import { FileBlock } from './blocks/file'
import { FirecrawlBlock } from './blocks/firecrawl'
import { FunctionBlock } from './blocks/function'
import { GitHubBlock } from './blocks/github'
import { GmailBlock } from './blocks/gmail'
import { GoogleSearchBlock } from './blocks/google'
// import { GuestyBlock } from './blocks/guesty'
import { ImageGeneratorBlock } from './blocks/image_generator'
import { JinaBlock } from './blocks/jina'
import { LinkupBlock } from './blocks/linkup'
import { MistralParseBlock } from './blocks/mistral_parse'
import { JiraBlock } from './blocks/jira'
import { NotionBlock } from './blocks/notion'
import { OpenAIBlock } from './blocks/openai'
import { PerplexityBlock } from './blocks/perplexity'
import { PineconeBlock } from './blocks/pinecone'
import { RedditBlock } from './blocks/reddit'
import { RouterBlock } from './blocks/router'
import { SerperBlock } from './blocks/serper'
import { GoogleSheetsBlock } from './blocks/google_sheets'
import { SlackBlock } from './blocks/slack'
import { StagehandBlock } from './blocks/stagehand'
import { StagehandAgentBlock } from './blocks/stagehand_agent'
import { StarterBlock } from './blocks/starter'
import { SupabaseBlock } from './blocks/supabase'
import { TavilyBlock } from './blocks/tavily'
import { ThinkingBlock } from './blocks/thinking'
import { TranslateBlock } from './blocks/translate'
import { TwilioSMSBlock } from './blocks/twilio'
import { TypeformBlock } from './blocks/typeform'
import { VisionBlock } from './blocks/vision'
import { WhatsAppBlock } from './blocks/whatsapp'
import { XBlock } from './blocks/x'
import { YouTubeBlock } from './blocks/youtube'
import { BlockConfig } from './types'
import { Mem0Block } from './blocks/mem0'
import { S3Block } from './blocks/s3'
import { TelegramBlock } from './blocks/telegram'
import { ClayBlock } from './blocks/clay'
import {
registry,
getAllBlocks,
getBlock,
getBlocksByCategory,
getAllBlockTypes,
isValidBlockType
} from './registry'

// Export blocks for ease of use
export {
AgentBlock,
AirtableBlock,
ApiBlock,
BrowserUseBlock,
// AutoblocksBlock,
ElevenLabsBlock,
Mem0Block,
MistralParseBlock,
FunctionBlock,
VisionBlock,
FirecrawlBlock,
// GuestyBlock,
FileBlock,
GoogleSearchBlock,
JinaBlock,
LinkupBlock,
JiraBlock,
TranslateBlock,
SlackBlock,
GitHubBlock,
ConditionBlock,
SerperBlock,
TavilyBlock,
RouterBlock,
EvaluatorBlock,
YouTubeBlock,
NotionBlock,
GmailBlock,
SupabaseBlock,
XBlock,
StarterBlock,
PineconeBlock,
OpenAIBlock,
ExaBlock,
RedditBlock,
GoogleDriveBlock,
GoogleDocsBlock,
WhatsAppBlock,
GoogleSheetsBlock,
PerplexityBlock,
ConfluenceBlock,
TwilioSMSBlock,
ImageGeneratorBlock,
TypeformBlock,
ThinkingBlock,
StagehandBlock,
StagehandAgentBlock,
S3Block,
TelegramBlock,
ClayBlock,
registry,
getBlock,
getBlocksByCategory,
getAllBlockTypes,
isValidBlockType,
getAllBlocks
}

// Registry of all block configurations, alphabetically sorted
const blocks: Record<string, BlockConfig> = {
agent: AgentBlock,
airtable: AirtableBlock,
api: ApiBlock,
browser_use: BrowserUseBlock,
// autoblocks: AutoblocksBlock,
condition: ConditionBlock,
confluence: ConfluenceBlock,
elevenlabs: ElevenLabsBlock,
evaluator: EvaluatorBlock,
exa: ExaBlock,
firecrawl: FirecrawlBlock,
file: FileBlock,
function: FunctionBlock,
github: GitHubBlock,
gmail: GmailBlock,
google_docs: GoogleDocsBlock,
google_drive: GoogleDriveBlock,
google_search: GoogleSearchBlock,
google_sheets: GoogleSheetsBlock,
// guesty: GuestyBlock,
image_generator: ImageGeneratorBlock,
jina: JinaBlock,
linkup: LinkupBlock,
jira: JiraBlock,
mem0: Mem0Block,
mistral_parse: MistralParseBlock,
notion: NotionBlock,
openai: OpenAIBlock,
perplexity: PerplexityBlock,
pinecone: PineconeBlock,
reddit: RedditBlock,
router: RouterBlock,
s3: S3Block,
serper: SerperBlock,
stagehand: StagehandBlock,
stagehand_agent: StagehandAgentBlock,
slack: SlackBlock,
starter: StarterBlock,
supabase: SupabaseBlock,
tavily: TavilyBlock,
thinking: ThinkingBlock,
translate: TranslateBlock,
twilio_sms: TwilioSMSBlock,
typeform: TypeformBlock,
vision: VisionBlock,
whatsapp: WhatsAppBlock,
x: XBlock,
youtube: YouTubeBlock,
telegram: TelegramBlock,
clay: ClayBlock,
}

// Helper functions
export const getBlock = (type: string): BlockConfig | undefined => blocks[type]

export const getBlocksByCategory = (category: 'blocks' | 'tools'): BlockConfig[] =>
Object.values(blocks).filter((block) => block.category === category)

export const getAllBlockTypes = (): string[] => Object.keys(blocks)

export const isValidBlockType = (type: string): type is string => type in blocks

export const getAllBlocks = (): BlockConfig[] => Object.values(blocks)
export type { BlockConfig } from './types'
124 changes: 124 additions & 0 deletions sim/blocks/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**
* Blocks Registry
*
*/

import { BlockConfig } from './types'

// Import all blocks directly here
import { AgentBlock } from './blocks/agent'
import { AirtableBlock } from './blocks/airtable'
import { ApiBlock } from './blocks/api'
// import { AutoblocksBlock } from './blocks/autoblocks'
import { BrowserUseBlock } from './blocks/browser_use'
import { ClayBlock } from './blocks/clay'
import { ConditionBlock } from './blocks/condition'
import { ConfluenceBlock } from './blocks/confluence'
import { GoogleDocsBlock } from './blocks/google_docs'
import { GoogleDriveBlock } from './blocks/drive'
import { ElevenLabsBlock } from './blocks/elevenlabs'
import { EvaluatorBlock } from './blocks/evaluator'
import { ExaBlock } from './blocks/exa'
import { FileBlock } from './blocks/file'
import { FirecrawlBlock } from './blocks/firecrawl'
import { FunctionBlock } from './blocks/function'
import { GitHubBlock } from './blocks/github'
import { GmailBlock } from './blocks/gmail'
import { GoogleSearchBlock } from './blocks/google'
// import { GuestyBlock } from './blocks/guesty'
import { ImageGeneratorBlock } from './blocks/image_generator'
import { JinaBlock } from './blocks/jina'
import { LinkupBlock } from './blocks/linkup'
import { MistralParseBlock } from './blocks/mistral_parse'
import { JiraBlock } from './blocks/jira'
import { NotionBlock } from './blocks/notion'
import { OpenAIBlock } from './blocks/openai'
import { PerplexityBlock } from './blocks/perplexity'
import { PineconeBlock } from './blocks/pinecone'
import { RedditBlock } from './blocks/reddit'
import { RouterBlock } from './blocks/router'
import { SerperBlock } from './blocks/serper'
import { GoogleSheetsBlock } from './blocks/google_sheets'
import { SlackBlock } from './blocks/slack'
import { StagehandBlock } from './blocks/stagehand'
import { StagehandAgentBlock } from './blocks/stagehand_agent'
import { StarterBlock } from './blocks/starter'
import { SupabaseBlock } from './blocks/supabase'
import { TavilyBlock } from './blocks/tavily'
import { ThinkingBlock } from './blocks/thinking'
import { TranslateBlock } from './blocks/translate'
import { TwilioSMSBlock } from './blocks/twilio'
import { TypeformBlock } from './blocks/typeform'
import { VisionBlock } from './blocks/vision'
import { WhatsAppBlock } from './blocks/whatsapp'
import { XBlock } from './blocks/x'
import { YouTubeBlock } from './blocks/youtube'
import { Mem0Block } from './blocks/mem0'
import { S3Block } from './blocks/s3'
import { TelegramBlock } from './blocks/telegram'

// Registry of all available blocks, alphabetically sorted
export const registry: Record<string, BlockConfig> = {
agent: AgentBlock,
airtable: AirtableBlock,
api: ApiBlock,
// autoblocks: AutoblocksBlock,
browser_use: BrowserUseBlock,
clay: ClayBlock,
condition: ConditionBlock,
confluence: ConfluenceBlock,
elevenlabs: ElevenLabsBlock,
evaluator: EvaluatorBlock,
exa: ExaBlock,
firecrawl: FirecrawlBlock,
file: FileBlock,
function: FunctionBlock,
github: GitHubBlock,
gmail: GmailBlock,
google_docs: GoogleDocsBlock,
google_drive: GoogleDriveBlock,
google_search: GoogleSearchBlock,
google_sheets: GoogleSheetsBlock,
// guesty: GuestyBlock,
image_generator: ImageGeneratorBlock,
jina: JinaBlock,
linkup: LinkupBlock,
jira: JiraBlock,
mem0: Mem0Block,
mistral_parse: MistralParseBlock,
notion: NotionBlock,
openai: OpenAIBlock,
perplexity: PerplexityBlock,
pinecone: PineconeBlock,
reddit: RedditBlock,
router: RouterBlock,
s3: S3Block,
serper: SerperBlock,
stagehand: StagehandBlock,
stagehand_agent: StagehandAgentBlock,
slack: SlackBlock,
starter: StarterBlock,
supabase: SupabaseBlock,
tavily: TavilyBlock,
thinking: ThinkingBlock,
translate: TranslateBlock,
twilio_sms: TwilioSMSBlock,
typeform: TypeformBlock,
vision: VisionBlock,
whatsapp: WhatsAppBlock,
x: XBlock,
youtube: YouTubeBlock,
telegram: TelegramBlock
}

// Helper functions to access the registry
export const getBlock = (type: string): BlockConfig | undefined => registry[type]

export const getBlocksByCategory = (category: 'blocks' | 'tools'): BlockConfig[] =>
Object.values(registry).filter((block) => block.category === category)

export const getAllBlockTypes = (): string[] => Object.keys(registry)

export const isValidBlockType = (type: string): type is string => type in registry

export const getAllBlocks = (): BlockConfig[] => Object.values(registry)
Loading