mirror of
https://github.com/simstudioai/sim.git
synced 2026-10-29 18:47:25 +08:00
Made reliable type passdown from executor to console
This commit is contained in:
@@ -15,18 +15,6 @@ jest.mock('@/components/icons', () => ({
|
||||
// Mock blocks
|
||||
jest.mock('@/blocks', () => ({
|
||||
getBlock: jest.fn(),
|
||||
getBlockTypeForTool: jest.fn((toolId: string) => {
|
||||
switch (toolId) {
|
||||
case 'openai.chat':
|
||||
return 'agent'
|
||||
case 'http.request':
|
||||
return 'api'
|
||||
case 'test-tool':
|
||||
return 'agent'
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
describe('Serializer', () => {
|
||||
@@ -372,8 +360,10 @@ describe('Serializer', () => {
|
||||
title: 'Agent Block',
|
||||
description: 'Use any LLM',
|
||||
category: 'basic',
|
||||
color: '#7F2FFF'
|
||||
}
|
||||
color: '#7F2FFF',
|
||||
type: 'agent'
|
||||
},
|
||||
enabled: true
|
||||
}
|
||||
],
|
||||
connections: []
|
||||
|
||||
+5
-4
@@ -1,7 +1,7 @@
|
||||
import { BlockState, SubBlockState } from '@/stores/workflow/types'
|
||||
import { Edge } from 'reactflow'
|
||||
import { SerializedBlock, SerializedConnection, SerializedWorkflow } from './types'
|
||||
import { getBlock, getBlockTypeForTool } from '@/blocks'
|
||||
import { getBlock } from '@/blocks'
|
||||
|
||||
export class Serializer {
|
||||
serializeWorkflow(blocks: Record<string, BlockState>, edges: Edge[]): SerializedWorkflow {
|
||||
@@ -52,7 +52,8 @@ export class Serializer {
|
||||
title: block.name,
|
||||
description: blockConfig.toolbar.description,
|
||||
category: blockConfig.toolbar.category,
|
||||
color: blockConfig.toolbar.bgColor
|
||||
color: blockConfig.toolbar.bgColor,
|
||||
type: block.type
|
||||
},
|
||||
enabled: block.enabled
|
||||
}
|
||||
@@ -108,9 +109,9 @@ export class Serializer {
|
||||
}
|
||||
|
||||
private deserializeBlock(serializedBlock: SerializedBlock): BlockState {
|
||||
const blockType = getBlockTypeForTool(serializedBlock.config.tool)
|
||||
const blockType = serializedBlock.metadata?.type
|
||||
if (!blockType) {
|
||||
throw new Error(`Invalid tool ID: ${serializedBlock.config.tool}`)
|
||||
throw new Error(`Invalid block type: ${serializedBlock.metadata?.type}`)
|
||||
}
|
||||
|
||||
const blockConfig = getBlock(blockType)
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface SerializedBlock {
|
||||
category?: string
|
||||
icon?: string
|
||||
color?: string
|
||||
type: string
|
||||
}
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user