mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { BlockConfig } from './types'
|
|
|
|
// Import blocks
|
|
import { AgentBlock } from './blocks/agent'
|
|
import { ApiBlock } from './blocks/api'
|
|
import { FunctionBlock } from './blocks/function'
|
|
import { CrewAIVisionBlock } from './blocks/crewai'
|
|
import { FirecrawlScrapeBlock } from './blocks/firecrawl'
|
|
import { JinaBlock } from './blocks/jina'
|
|
import { TranslateBlock } from './blocks/translate'
|
|
import { SlackMessageBlock } from './blocks/slack'
|
|
import { GitHubBlock } from './blocks/github'
|
|
import { ConditionBlock } from './blocks/condition'
|
|
import { SerperBlock } from './blocks/serper'
|
|
|
|
// Export blocks for ease of use
|
|
export {
|
|
AgentBlock,
|
|
ApiBlock,
|
|
FunctionBlock,
|
|
CrewAIVisionBlock,
|
|
FirecrawlScrapeBlock,
|
|
JinaBlock,
|
|
TranslateBlock,
|
|
SlackMessageBlock,
|
|
GitHubBlock,
|
|
ConditionBlock,
|
|
SerperBlock
|
|
}
|
|
|
|
// Registry of all block configurations
|
|
const blocks: Record<string, BlockConfig> = {
|
|
agent: AgentBlock,
|
|
api: ApiBlock,
|
|
function: FunctionBlock,
|
|
crewai_vision: CrewAIVisionBlock,
|
|
firecrawl_scrape: FirecrawlScrapeBlock,
|
|
jina_reader: JinaBlock,
|
|
translate: TranslateBlock,
|
|
slack_message: SlackMessageBlock,
|
|
github_repo_info: GitHubBlock,
|
|
condition: ConditionBlock,
|
|
serper_search: SerperBlock
|
|
}
|
|
|
|
// Build a reverse mapping of tools to block types
|
|
const toolToBlockType = Object.entries(blocks).reduce((acc, [blockType, config]) => {
|
|
config.tools.access.forEach(toolId => {
|
|
acc[toolId] = blockType
|
|
})
|
|
return acc
|
|
}, {} as Record<string, string>)
|
|
|
|
// Helper functions
|
|
export const getBlock = (type: string): BlockConfig | undefined =>
|
|
blocks[type]
|
|
|
|
export const getBlocksByCategory = (category: 'blocks' | 'tools'): BlockConfig[] =>
|
|
Object.values(blocks).filter(block => block.toolbar.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) |