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
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/agent.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { AgentBlock } from './agent'
import { AgentBlock } from '@/blocks/blocks/agent'

vi.mock('@/blocks', () => ({
getAllBlocks: vi.fn(() => [
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/agent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AgentIcon } from '@/components/icons'
import { isHosted } from '@/lib/environment'
import { createLogger } from '@/lib/logs/console-logger'
import type { BlockConfig } from '@/blocks/types'
import {
getAllModelProviders,
getBaseModelProviders,
Expand All @@ -13,7 +14,6 @@ import {
} from '@/providers/utils'
import { useOllamaStore } from '@/stores/ollama/store'
import type { ToolResponse } from '@/tools/types'
import type { BlockConfig } from '../types'

const logger = createLogger('AgentBlock')

Expand Down
17 changes: 2 additions & 15 deletions apps/sim/blocks/blocks/airtable.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import { AirtableIcon } from '@/components/icons'
import type {
AirtableCreateResponse,
AirtableGetResponse,
AirtableListResponse,
AirtableUpdateMultipleResponse,
AirtableUpdateResponse,
} from '@/tools/airtable/types'
import type { BlockConfig } from '../types'

type AirtableResponse =
| AirtableListResponse
| AirtableGetResponse
| AirtableCreateResponse
| AirtableUpdateResponse
| AirtableUpdateMultipleResponse
import type { BlockConfig } from '@/blocks/types'
import type { AirtableResponse } from '@/tools/airtable/types'

export const AirtableBlock: BlockConfig<AirtableResponse> = {
type: 'airtable',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import type { RequestResponse } from '@/tools/http/types'
import type { BlockConfig } from '../types'

export const ApiBlock: BlockConfig<RequestResponse> = {
type: 'api',
Expand Down
13 changes: 2 additions & 11 deletions apps/sim/blocks/blocks/browser_use.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { BrowserUseIcon } from '@/components/icons'
import type { ToolResponse } from '@/tools/types'
import type { BlockConfig } from '../types'

interface BrowserUseResponse extends ToolResponse {
output: {
id: string
success: boolean
output: any
steps: any[]
}
}
import type { BlockConfig } from '@/blocks/types'
import type { BrowserUseResponse } from '@/tools/browser_use/types'

export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
type: 'browser_use',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/clay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClayIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import type { ClayPopulateResponse } from '@/tools/clay/types'
import type { BlockConfig } from '../types'

export const ClayBlock: BlockConfig<ClayPopulateResponse> = {
type: 'clay',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/condition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConditionalIcon } from '@/components/icons'
import type { BlockConfig } from '../types'
import type { BlockConfig } from '@/blocks/types'

interface ConditionBlockOutput {
success: boolean
Expand Down
31 changes: 24 additions & 7 deletions apps/sim/blocks/blocks/confluence.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ConfluenceIcon } from '@/components/icons'
import type { ConfluenceRetrieveResponse, ConfluenceUpdateResponse } from '@/tools/confluence/types'
import type { BlockConfig } from '../types'

type ConfluenceResponse = ConfluenceRetrieveResponse | ConfluenceUpdateResponse
import type { BlockConfig } from '@/blocks/types'
import type { ConfluenceResponse } from '@/tools/confluence/types'

export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
type: 'confluence',
Expand Down Expand Up @@ -48,7 +46,7 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
],
placeholder: 'Select Confluence account',
},
// Use file-selector component for page selection
// Page selector (basic mode)
{
id: 'pageId',
title: 'Select Page',
Expand All @@ -57,6 +55,16 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
provider: 'confluence',
serviceId: 'confluence',
placeholder: 'Select Confluence page',
mode: 'basic',
},
// Manual page ID input (advanced mode)
{
id: 'manualPageId',
title: 'Page ID',
type: 'short-input',
layout: 'full',
placeholder: 'Enter Confluence page ID',
mode: 'advanced',
},
// Update page fields
{
Expand Down Expand Up @@ -90,10 +98,18 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
}
},
params: (params) => {
const { credential, ...rest } = params
const { credential, pageId, manualPageId, ...rest } = params

// Use the selected page ID or the manually entered one
const effectivePageId = (pageId || manualPageId || '').trim()

if (!effectivePageId) {
throw new Error('Page ID is required. Please select a page or enter a page ID manually.')
}

return {
accessToken: credential,
pageId: effectivePageId,
...rest,
}
},
Expand All @@ -103,7 +119,8 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
operation: { type: 'string', required: true },
domain: { type: 'string', required: true },
credential: { type: 'string', required: true },
pageId: { type: 'string', required: true },
pageId: { type: 'string', required: false },
manualPageId: { type: 'string', required: false },
// Update operation inputs
title: { type: 'string', required: false },
content: { type: 'string', required: false },
Expand Down
72 changes: 66 additions & 6 deletions apps/sim/blocks/blocks/discord.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DiscordIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import type { DiscordResponse } from '@/tools/discord/types'
import type { BlockConfig } from '../types'

export const DiscordBlock: BlockConfig<DiscordResponse> = {
type: 'discord',
Expand Down Expand Up @@ -32,6 +32,7 @@ export const DiscordBlock: BlockConfig<DiscordResponse> = {
placeholder: 'Enter Discord bot token',
password: true,
},
// Server selector (basic mode)
{
id: 'serverId',
title: 'Server',
Expand All @@ -40,11 +41,26 @@ export const DiscordBlock: BlockConfig<DiscordResponse> = {
provider: 'discord',
serviceId: 'discord',
placeholder: 'Select Discord server',
mode: 'basic',
condition: {
field: 'operation',
value: ['discord_send_message', 'discord_get_messages', 'discord_get_server'],
},
},
// Manual server ID input (advanced mode)
{
id: 'manualServerId',
title: 'Server ID',
type: 'short-input',
layout: 'full',
placeholder: 'Enter Discord server ID',
mode: 'advanced',
condition: {
field: 'operation',
value: ['discord_send_message', 'discord_get_messages', 'discord_get_server'],
},
},
// Channel selector (basic mode)
{
id: 'channelId',
title: 'Channel',
Expand All @@ -53,6 +69,17 @@ export const DiscordBlock: BlockConfig<DiscordResponse> = {
provider: 'discord',
serviceId: 'discord',
placeholder: 'Select Discord channel',
mode: 'basic',
condition: { field: 'operation', value: ['discord_send_message', 'discord_get_messages'] },
},
// Manual channel ID input (advanced mode)
{
id: 'manualChannelId',
title: 'Channel ID',
type: 'short-input',
layout: 'full',
placeholder: 'Enter Discord channel ID',
mode: 'advanced',
condition: { field: 'operation', value: ['discord_send_message', 'discord_get_messages'] },
},
{
Expand Down Expand Up @@ -108,25 +135,56 @@ export const DiscordBlock: BlockConfig<DiscordResponse> = {
if (!params.botToken) throw new Error('Bot token required for this operation')
commonParams.botToken = params.botToken

// Handle server ID (selector or manual)
const effectiveServerId = (params.serverId || params.manualServerId || '').trim()

// Handle channel ID (selector or manual)
const effectiveChannelId = (params.channelId || params.manualChannelId || '').trim()

switch (params.operation) {
case 'discord_send_message':
if (!effectiveServerId) {
throw new Error(
'Server ID is required. Please select a server or enter a server ID manually.'
)
}
if (!effectiveChannelId) {
throw new Error(
'Channel ID is required. Please select a channel or enter a channel ID manually.'
)
}
return {
...commonParams,
serverId: params.serverId,
channelId: params.channelId,
serverId: effectiveServerId,
channelId: effectiveChannelId,
content: params.content,
}
case 'discord_get_messages':
if (!effectiveServerId) {
throw new Error(
'Server ID is required. Please select a server or enter a server ID manually.'
)
}
if (!effectiveChannelId) {
throw new Error(
'Channel ID is required. Please select a channel or enter a channel ID manually.'
)
}
return {
...commonParams,
serverId: params.serverId,
channelId: params.channelId,
serverId: effectiveServerId,
channelId: effectiveChannelId,
limit: params.limit ? Math.min(Math.max(1, Number(params.limit)), 100) : 10,
}
case 'discord_get_server':
if (!effectiveServerId) {
throw new Error(
'Server ID is required. Please select a server or enter a server ID manually.'
)
}
return {
...commonParams,
serverId: params.serverId,
serverId: effectiveServerId,
}
case 'discord_get_user':
return {
Expand All @@ -143,7 +201,9 @@ export const DiscordBlock: BlockConfig<DiscordResponse> = {
operation: { type: 'string', required: true },
botToken: { type: 'string', required: true },
serverId: { type: 'string', required: false },
manualServerId: { type: 'string', required: false },
channelId: { type: 'string', required: false },
manualChannelId: { type: 'string', required: false },
content: { type: 'string', required: false },
limit: { type: 'number', required: false },
userId: { type: 'string', required: false },
Expand Down
10 changes: 2 additions & 8 deletions apps/sim/blocks/blocks/elevenlabs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { ElevenLabsIcon } from '@/components/icons'
import type { ToolResponse } from '@/tools/types'
import type { BlockConfig } from '../types'

interface ElevenLabsBlockResponse extends ToolResponse {
output: {
audioUrl: string
}
}
import type { BlockConfig } from '@/blocks/types'
import type { ElevenLabsBlockResponse } from '@/tools/elevenlabs/types'

export const ElevenLabsBlock: BlockConfig<ElevenLabsBlockResponse> = {
type: 'elevenlabs',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ChartBarIcon } from '@/components/icons'
import { isHosted } from '@/lib/environment'
import { createLogger } from '@/lib/logs/console-logger'
import type { BlockConfig, ParamType } from '@/blocks/types'
import type { ProviderId } from '@/providers/types'
import { getAllModelProviders, getBaseModelProviders, getHostedModels } from '@/providers/utils'
import { useOllamaStore } from '@/stores/ollama/store'
import type { ToolResponse } from '@/tools/types'
import type { BlockConfig, ParamType } from '../types'

const logger = createLogger('EvaluatorBlock')

Expand Down
15 changes: 2 additions & 13 deletions apps/sim/blocks/blocks/exa.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { ExaAIIcon } from '@/components/icons'
import type {
ExaAnswerResponse,
ExaFindSimilarLinksResponse,
ExaGetContentsResponse,
ExaSearchResponse,
} from '@/tools/exa/types'
import type { BlockConfig } from '../types'

type ExaResponse =
| ExaSearchResponse
| ExaGetContentsResponse
| ExaFindSimilarLinksResponse
| ExaAnswerResponse
import type { BlockConfig } from '@/blocks/types'
import type { ExaResponse } from '@/tools/exa/types'

export const ExaBlock: BlockConfig<ExaResponse> = {
type: 'exa',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/file.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DocumentIcon } from '@/components/icons'
import { isProd } from '@/lib/environment'
import { createLogger } from '@/lib/logs/console-logger'
import type { BlockConfig, SubBlockConfig, SubBlockLayout, SubBlockType } from '@/blocks/types'
import type { FileParserOutput } from '@/tools/file/types'
import type { BlockConfig, SubBlockConfig, SubBlockLayout, SubBlockType } from '../types'

const logger = createLogger('FileBlock')

Expand Down
6 changes: 2 additions & 4 deletions apps/sim/blocks/blocks/firecrawl.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FirecrawlIcon } from '@/components/icons'
import type { ScrapeResponse, SearchResponse } from '@/tools/firecrawl/types'
import type { BlockConfig } from '../types'

type FirecrawlResponse = ScrapeResponse | SearchResponse
import type { BlockConfig } from '@/blocks/types'
import type { FirecrawlResponse } from '@/tools/firecrawl/types'

export const FirecrawlBlock: BlockConfig<FirecrawlResponse> = {
type: 'firecrawl',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/function.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CodeIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import type { CodeExecutionOutput } from '@/tools/function/types'
import type { BlockConfig } from '../types'

export const FunctionBlock: BlockConfig<CodeExecutionOutput> = {
type: 'function',
Expand Down
15 changes: 2 additions & 13 deletions apps/sim/blocks/blocks/github.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { GithubIcon } from '@/components/icons'
import type {
CreateCommentResponse,
LatestCommitResponse,
PullRequestResponse,
RepoInfoResponse,
} from '@/tools/github/types'
import type { BlockConfig } from '../types'

type GitHubResponse =
| PullRequestResponse
| CreateCommentResponse
| LatestCommitResponse
| RepoInfoResponse
import type { BlockConfig } from '@/blocks/types'
import type { GitHubResponse } from '@/tools/github/types'

export const GitHubBlock: BlockConfig<GitHubResponse> = {
type: 'github',
Expand Down
Loading