Skip to content

Commit 75c6582

Browse files
authored
feat(build): added turbopack in dev & fixed circular dependency (#328)
* fix(tools): fixed x tool * feat(build): added turbopack in dev & fixed circular dependency * add turbopack config * fixed failing test bc of circular import
1 parent 4be568e commit 75c6582

13 files changed

Lines changed: 13094 additions & 11338 deletions

.github/CONTRIBUTING.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,22 +313,20 @@ In addition, you will need to update the registries:
313313
```
314314
315315
4. **Register Your Block:**
316-
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.
316+
Add your block to the blocks registry (`/sim/blocks/registry.ts`):
317317
318-
```typescript:/sim/blocks/index.ts
318+
```typescript:/sim/blocks/registry.ts
319319
import { PineconeBlock } from './blocks/pinecone'
320-
321-
export const blocks = [
320+
321+
// Registry of all available blocks
322+
export const registry: Record<string, BlockConfig> = {
322323
// ... existing blocks
323-
PineconeBlock,
324-
]
325-
326-
export const blocksByType: Record<string, BlockConfig> = {
327-
// ... existing blocks by type
328324
pinecone: PineconeBlock,
329325
}
330326
```
331327
328+
The block will be automatically available to the application through the registry.
329+
332330
5. **Test Your Block:**
333331
Ensure that the block displays correctly in the UI and that its functionality works as expected.
334332

sim/blocks/blocks/agent.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AgentIcon } from '@/components/icons'
22
import { createLogger } from '@/lib/logs/console-logger'
33
import { isHosted } from '@/lib/environment'
44
import { useOllamaStore } from '@/stores/ollama/store'
5-
import { getAllBlocks } from '@/blocks'
65
import { MODELS_TEMP_RANGE_0_1, MODELS_TEMP_RANGE_0_2 } from '@/providers/model-capabilities'
76
import { getAllModelProviders, getBaseModelProviders } from '@/providers/utils'
87
import { ToolResponse } from '@/tools/types'
@@ -31,9 +30,15 @@ interface AgentResponse extends ToolResponse {
3130

3231
// Helper function to get the tool ID from a block type
3332
const getToolIdFromBlock = (blockType: string): string | undefined => {
34-
const blocks = getAllBlocks()
35-
const block = blocks.find((b) => b.type === blockType)
36-
return block?.tools?.access?.[0]
33+
try {
34+
const { getAllBlocks } = require('@/blocks/registry')
35+
const blocks = getAllBlocks()
36+
const block = blocks.find((b: { type: string; tools?: { access?: string[] } }) => b.type === blockType)
37+
return block?.tools?.access?.[0]
38+
} catch (error) {
39+
logger.error('Error getting tool ID from block', { error })
40+
return undefined
41+
}
3742
}
3843

3944
export const AgentBlock: BlockConfig<AgentResponse> = {

sim/blocks/index.ts

Lines changed: 15 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,19 @@
1-
// Import blocks
2-
import { AgentBlock } from './blocks/agent'
3-
import { AirtableBlock } from './blocks/airtable'
4-
import { ApiBlock } from './blocks/api'
5-
import { BrowserUseBlock } from './blocks/browser_use'
6-
// import { AutoblocksBlock } from './blocks/autoblocks'
7-
import { ConditionBlock } from './blocks/condition'
8-
import { ConfluenceBlock } from './blocks/confluence'
9-
import { GoogleDocsBlock } from './blocks/google_docs'
10-
import { GoogleDriveBlock } from './blocks/drive'
11-
import { ElevenLabsBlock } from './blocks/elevenlabs'
12-
import { EvaluatorBlock } from './blocks/evaluator'
13-
import { ExaBlock } from './blocks/exa'
14-
import { FileBlock } from './blocks/file'
15-
import { FirecrawlBlock } from './blocks/firecrawl'
16-
import { FunctionBlock } from './blocks/function'
17-
import { GitHubBlock } from './blocks/github'
18-
import { GmailBlock } from './blocks/gmail'
19-
import { GoogleSearchBlock } from './blocks/google'
20-
// import { GuestyBlock } from './blocks/guesty'
21-
import { ImageGeneratorBlock } from './blocks/image_generator'
22-
import { JinaBlock } from './blocks/jina'
23-
import { LinkupBlock } from './blocks/linkup'
24-
import { MistralParseBlock } from './blocks/mistral_parse'
25-
import { JiraBlock } from './blocks/jira'
26-
import { NotionBlock } from './blocks/notion'
27-
import { OpenAIBlock } from './blocks/openai'
28-
import { PerplexityBlock } from './blocks/perplexity'
29-
import { PineconeBlock } from './blocks/pinecone'
30-
import { RedditBlock } from './blocks/reddit'
31-
import { RouterBlock } from './blocks/router'
32-
import { SerperBlock } from './blocks/serper'
33-
import { GoogleSheetsBlock } from './blocks/google_sheets'
34-
import { SlackBlock } from './blocks/slack'
35-
import { StagehandBlock } from './blocks/stagehand'
36-
import { StagehandAgentBlock } from './blocks/stagehand_agent'
37-
import { StarterBlock } from './blocks/starter'
38-
import { SupabaseBlock } from './blocks/supabase'
39-
import { TavilyBlock } from './blocks/tavily'
40-
import { ThinkingBlock } from './blocks/thinking'
41-
import { TranslateBlock } from './blocks/translate'
42-
import { TwilioSMSBlock } from './blocks/twilio'
43-
import { TypeformBlock } from './blocks/typeform'
44-
import { VisionBlock } from './blocks/vision'
45-
import { WhatsAppBlock } from './blocks/whatsapp'
46-
import { XBlock } from './blocks/x'
47-
import { YouTubeBlock } from './blocks/youtube'
48-
import { BlockConfig } from './types'
49-
import { Mem0Block } from './blocks/mem0'
50-
import { S3Block } from './blocks/s3'
51-
import { TelegramBlock } from './blocks/telegram'
52-
import { ClayBlock } from './blocks/clay'
1+
import {
2+
registry,
3+
getAllBlocks,
4+
getBlock,
5+
getBlocksByCategory,
6+
getAllBlockTypes,
7+
isValidBlockType
8+
} from './registry'
539

54-
// Export blocks for ease of use
5510
export {
56-
AgentBlock,
57-
AirtableBlock,
58-
ApiBlock,
59-
BrowserUseBlock,
60-
// AutoblocksBlock,
61-
ElevenLabsBlock,
62-
Mem0Block,
63-
MistralParseBlock,
64-
FunctionBlock,
65-
VisionBlock,
66-
FirecrawlBlock,
67-
// GuestyBlock,
68-
FileBlock,
69-
GoogleSearchBlock,
70-
JinaBlock,
71-
LinkupBlock,
72-
JiraBlock,
73-
TranslateBlock,
74-
SlackBlock,
75-
GitHubBlock,
76-
ConditionBlock,
77-
SerperBlock,
78-
TavilyBlock,
79-
RouterBlock,
80-
EvaluatorBlock,
81-
YouTubeBlock,
82-
NotionBlock,
83-
GmailBlock,
84-
SupabaseBlock,
85-
XBlock,
86-
StarterBlock,
87-
PineconeBlock,
88-
OpenAIBlock,
89-
ExaBlock,
90-
RedditBlock,
91-
GoogleDriveBlock,
92-
GoogleDocsBlock,
93-
WhatsAppBlock,
94-
GoogleSheetsBlock,
95-
PerplexityBlock,
96-
ConfluenceBlock,
97-
TwilioSMSBlock,
98-
ImageGeneratorBlock,
99-
TypeformBlock,
100-
ThinkingBlock,
101-
StagehandBlock,
102-
StagehandAgentBlock,
103-
S3Block,
104-
TelegramBlock,
105-
ClayBlock,
11+
registry,
12+
getBlock,
13+
getBlocksByCategory,
14+
getAllBlockTypes,
15+
isValidBlockType,
16+
getAllBlocks
10617
}
10718

108-
// Registry of all block configurations, alphabetically sorted
109-
const blocks: Record<string, BlockConfig> = {
110-
agent: AgentBlock,
111-
airtable: AirtableBlock,
112-
api: ApiBlock,
113-
browser_use: BrowserUseBlock,
114-
// autoblocks: AutoblocksBlock,
115-
condition: ConditionBlock,
116-
confluence: ConfluenceBlock,
117-
elevenlabs: ElevenLabsBlock,
118-
evaluator: EvaluatorBlock,
119-
exa: ExaBlock,
120-
firecrawl: FirecrawlBlock,
121-
file: FileBlock,
122-
function: FunctionBlock,
123-
github: GitHubBlock,
124-
gmail: GmailBlock,
125-
google_docs: GoogleDocsBlock,
126-
google_drive: GoogleDriveBlock,
127-
google_search: GoogleSearchBlock,
128-
google_sheets: GoogleSheetsBlock,
129-
// guesty: GuestyBlock,
130-
image_generator: ImageGeneratorBlock,
131-
jina: JinaBlock,
132-
linkup: LinkupBlock,
133-
jira: JiraBlock,
134-
mem0: Mem0Block,
135-
mistral_parse: MistralParseBlock,
136-
notion: NotionBlock,
137-
openai: OpenAIBlock,
138-
perplexity: PerplexityBlock,
139-
pinecone: PineconeBlock,
140-
reddit: RedditBlock,
141-
router: RouterBlock,
142-
s3: S3Block,
143-
serper: SerperBlock,
144-
stagehand: StagehandBlock,
145-
stagehand_agent: StagehandAgentBlock,
146-
slack: SlackBlock,
147-
starter: StarterBlock,
148-
supabase: SupabaseBlock,
149-
tavily: TavilyBlock,
150-
thinking: ThinkingBlock,
151-
translate: TranslateBlock,
152-
twilio_sms: TwilioSMSBlock,
153-
typeform: TypeformBlock,
154-
vision: VisionBlock,
155-
whatsapp: WhatsAppBlock,
156-
x: XBlock,
157-
youtube: YouTubeBlock,
158-
telegram: TelegramBlock,
159-
clay: ClayBlock,
160-
}
161-
162-
// Helper functions
163-
export const getBlock = (type: string): BlockConfig | undefined => blocks[type]
164-
165-
export const getBlocksByCategory = (category: 'blocks' | 'tools'): BlockConfig[] =>
166-
Object.values(blocks).filter((block) => block.category === category)
167-
168-
export const getAllBlockTypes = (): string[] => Object.keys(blocks)
169-
170-
export const isValidBlockType = (type: string): type is string => type in blocks
171-
172-
export const getAllBlocks = (): BlockConfig[] => Object.values(blocks)
19+
export type { BlockConfig } from './types'

sim/blocks/registry.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/**
2+
* Blocks Registry
3+
*
4+
*/
5+
6+
import { BlockConfig } from './types'
7+
8+
// Import all blocks directly here
9+
import { AgentBlock } from './blocks/agent'
10+
import { AirtableBlock } from './blocks/airtable'
11+
import { ApiBlock } from './blocks/api'
12+
// import { AutoblocksBlock } from './blocks/autoblocks'
13+
import { BrowserUseBlock } from './blocks/browser_use'
14+
import { ClayBlock } from './blocks/clay'
15+
import { ConditionBlock } from './blocks/condition'
16+
import { ConfluenceBlock } from './blocks/confluence'
17+
import { GoogleDocsBlock } from './blocks/google_docs'
18+
import { GoogleDriveBlock } from './blocks/drive'
19+
import { ElevenLabsBlock } from './blocks/elevenlabs'
20+
import { EvaluatorBlock } from './blocks/evaluator'
21+
import { ExaBlock } from './blocks/exa'
22+
import { FileBlock } from './blocks/file'
23+
import { FirecrawlBlock } from './blocks/firecrawl'
24+
import { FunctionBlock } from './blocks/function'
25+
import { GitHubBlock } from './blocks/github'
26+
import { GmailBlock } from './blocks/gmail'
27+
import { GoogleSearchBlock } from './blocks/google'
28+
// import { GuestyBlock } from './blocks/guesty'
29+
import { ImageGeneratorBlock } from './blocks/image_generator'
30+
import { JinaBlock } from './blocks/jina'
31+
import { LinkupBlock } from './blocks/linkup'
32+
import { MistralParseBlock } from './blocks/mistral_parse'
33+
import { JiraBlock } from './blocks/jira'
34+
import { NotionBlock } from './blocks/notion'
35+
import { OpenAIBlock } from './blocks/openai'
36+
import { PerplexityBlock } from './blocks/perplexity'
37+
import { PineconeBlock } from './blocks/pinecone'
38+
import { RedditBlock } from './blocks/reddit'
39+
import { RouterBlock } from './blocks/router'
40+
import { SerperBlock } from './blocks/serper'
41+
import { GoogleSheetsBlock } from './blocks/google_sheets'
42+
import { SlackBlock } from './blocks/slack'
43+
import { StagehandBlock } from './blocks/stagehand'
44+
import { StagehandAgentBlock } from './blocks/stagehand_agent'
45+
import { StarterBlock } from './blocks/starter'
46+
import { SupabaseBlock } from './blocks/supabase'
47+
import { TavilyBlock } from './blocks/tavily'
48+
import { ThinkingBlock } from './blocks/thinking'
49+
import { TranslateBlock } from './blocks/translate'
50+
import { TwilioSMSBlock } from './blocks/twilio'
51+
import { TypeformBlock } from './blocks/typeform'
52+
import { VisionBlock } from './blocks/vision'
53+
import { WhatsAppBlock } from './blocks/whatsapp'
54+
import { XBlock } from './blocks/x'
55+
import { YouTubeBlock } from './blocks/youtube'
56+
import { Mem0Block } from './blocks/mem0'
57+
import { S3Block } from './blocks/s3'
58+
import { TelegramBlock } from './blocks/telegram'
59+
60+
// Registry of all available blocks, alphabetically sorted
61+
export const registry: Record<string, BlockConfig> = {
62+
agent: AgentBlock,
63+
airtable: AirtableBlock,
64+
api: ApiBlock,
65+
// autoblocks: AutoblocksBlock,
66+
browser_use: BrowserUseBlock,
67+
clay: ClayBlock,
68+
condition: ConditionBlock,
69+
confluence: ConfluenceBlock,
70+
elevenlabs: ElevenLabsBlock,
71+
evaluator: EvaluatorBlock,
72+
exa: ExaBlock,
73+
firecrawl: FirecrawlBlock,
74+
file: FileBlock,
75+
function: FunctionBlock,
76+
github: GitHubBlock,
77+
gmail: GmailBlock,
78+
google_docs: GoogleDocsBlock,
79+
google_drive: GoogleDriveBlock,
80+
google_search: GoogleSearchBlock,
81+
google_sheets: GoogleSheetsBlock,
82+
// guesty: GuestyBlock,
83+
image_generator: ImageGeneratorBlock,
84+
jina: JinaBlock,
85+
linkup: LinkupBlock,
86+
jira: JiraBlock,
87+
mem0: Mem0Block,
88+
mistral_parse: MistralParseBlock,
89+
notion: NotionBlock,
90+
openai: OpenAIBlock,
91+
perplexity: PerplexityBlock,
92+
pinecone: PineconeBlock,
93+
reddit: RedditBlock,
94+
router: RouterBlock,
95+
s3: S3Block,
96+
serper: SerperBlock,
97+
stagehand: StagehandBlock,
98+
stagehand_agent: StagehandAgentBlock,
99+
slack: SlackBlock,
100+
starter: StarterBlock,
101+
supabase: SupabaseBlock,
102+
tavily: TavilyBlock,
103+
thinking: ThinkingBlock,
104+
translate: TranslateBlock,
105+
twilio_sms: TwilioSMSBlock,
106+
typeform: TypeformBlock,
107+
vision: VisionBlock,
108+
whatsapp: WhatsAppBlock,
109+
x: XBlock,
110+
youtube: YouTubeBlock,
111+
telegram: TelegramBlock
112+
}
113+
114+
// Helper functions to access the registry
115+
export const getBlock = (type: string): BlockConfig | undefined => registry[type]
116+
117+
export const getBlocksByCategory = (category: 'blocks' | 'tools'): BlockConfig[] =>
118+
Object.values(registry).filter((block) => block.category === category)
119+
120+
export const getAllBlockTypes = (): string[] => Object.keys(registry)
121+
122+
export const isValidBlockType = (type: string): type is string => type in registry
123+
124+
export const getAllBlocks = (): BlockConfig[] => Object.values(registry)

0 commit comments

Comments
 (0)