Skip to content

Commit f25505a

Browse files
committed
merge conflict resolution
1 parent 34bdb4f commit f25505a

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it, vi } from 'vitest'
5+
import { createBlockFromParams } from './builders'
6+
7+
const agentBlockConfig = {
8+
type: 'agent',
9+
name: 'Agent',
10+
outputs: {
11+
content: { type: 'string', description: 'Default content output' },
12+
},
13+
subBlocks: [{ id: 'responseFormat', type: 'response-format' }],
14+
}
15+
16+
vi.mock('@/blocks/registry', () => ({
17+
getAllBlocks: () => [agentBlockConfig],
18+
getBlock: (type: string) => (type === 'agent' ? agentBlockConfig : undefined),
19+
}))
20+
21+
describe('createBlockFromParams', () => {
22+
it('derives agent outputs from responseFormat when outputs are not provided', () => {
23+
const block = createBlockFromParams('b-agent', {
24+
type: 'agent',
25+
name: 'Agent',
26+
inputs: {
27+
responseFormat: {
28+
type: 'object',
29+
properties: {
30+
answer: {
31+
type: 'string',
32+
description: 'Structured answer text',
33+
},
34+
},
35+
required: ['answer'],
36+
},
37+
},
38+
triggerMode: false,
39+
})
40+
41+
expect(block.outputs.answer).toBeDefined()
42+
expect(block.outputs.answer.type).toBe('string')
43+
})
44+
})

apps/sim/lib/copilot/tools/server/workflow/edit-workflow/builders.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import crypto from 'crypto'
22
import { createLogger } from '@sim/logger'
33
import type { PermissionGroupConfig } from '@/lib/permission-groups/types'
4-
import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
4+
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
55
import { buildCanonicalIndex, isCanonicalPair } from '@/lib/workflows/subblocks/visibility'
66
import { getAllBlocks } from '@/blocks/registry'
77
import type { BlockConfig } from '@/blocks/types'
@@ -54,7 +54,10 @@ export function createBlockFromParams(
5454
subBlocks[key] = { id: key, type: 'short-input', value: value }
5555
})
5656
}
57-
outputs = getBlockOutputs(params.type, subBlocks, triggerMode)
57+
outputs = getEffectiveBlockOutputs(params.type, subBlocks, {
58+
triggerMode,
59+
preferToolOutputs: !triggerMode,
60+
})
5861
} else {
5962
outputs = {}
6063
}

apps/sim/lib/workflows/defaults.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
1+
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
22
import { getBlock } from '@/blocks'
33
import type { BlockConfig, SubBlockConfig } from '@/blocks/types'
44
import type { BlockState, SubBlockState, WorkflowState } from '@/stores/workflows/workflow/types'
@@ -85,7 +85,10 @@ function buildStartBlockState(
8585
subBlockValues[config.id] = initialValue ?? null
8686
})
8787

88-
const outputs = getBlockOutputs(blockConfig.type, subBlocks)
88+
const outputs = getEffectiveBlockOutputs(blockConfig.type, subBlocks, {
89+
triggerMode: false,
90+
preferToolOutputs: true,
91+
})
8992

9093
const blockState: BlockState = {
9194
id: blockId,

apps/sim/stores/workflows/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Edge } from 'reactflow'
22
import { v4 as uuidv4 } from 'uuid'
33
import { DEFAULT_DUPLICATE_OFFSET } from '@/lib/workflows/autolayout/constants'
4-
import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
4+
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
55
import { mergeSubblockStateWithValues } from '@/lib/workflows/subblocks'
66
import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
77
import { getBlock } from '@/blocks'
@@ -188,7 +188,10 @@ export function prepareBlockState(options: PrepareBlockStateOptions): BlockState
188188
})
189189
}
190190

191-
const outputs = getBlockOutputs(type, subBlocks, triggerMode)
191+
const outputs = getEffectiveBlockOutputs(type, subBlocks, {
192+
triggerMode,
193+
preferToolOutputs: !triggerMode,
194+
})
192195

193196
return {
194197
id,

0 commit comments

Comments
 (0)