feat: Add sub-graph component for workflow

This commit is contained in:
zhsama
2026-01-12 14:56:53 +08:00
parent f925266c1b
commit cab7cd37b8
21 changed files with 1046 additions and 19 deletions

View File

@ -0,0 +1,49 @@
import type { CreateSubGraphSlice, SubGraphSliceShape } from '../types'
const initialState: Omit<SubGraphSliceShape, 'setSubGraphContext' | 'setSubGraphNodes' | 'setSubGraphEdges' | 'setSelectedOutputVar' | 'setWhenOutputNone' | 'setDefaultValue' | 'setShowDebugPanel' | 'setIsRunning' | 'setParentAvailableVars' | 'resetSubGraph'> = {
parentToolNodeId: '',
parameterKey: '',
sourceAgentNodeId: '',
sourceVariable: [],
subGraphNodes: [],
subGraphEdges: [],
selectedOutputVar: [],
whenOutputNone: 'skip',
defaultValue: '',
showDebugPanel: false,
isRunning: false,
parentAvailableVars: [],
}
export const createSubGraphSlice: CreateSubGraphSlice = set => ({
...initialState,
setSubGraphContext: context => set(() => ({
parentToolNodeId: context.parentToolNodeId,
parameterKey: context.parameterKey,
sourceAgentNodeId: context.sourceAgentNodeId,
sourceVariable: context.sourceVariable,
})),
setSubGraphNodes: nodes => set(() => ({ subGraphNodes: nodes })),
setSubGraphEdges: edges => set(() => ({ subGraphEdges: edges })),
setSelectedOutputVar: selector => set(() => ({ selectedOutputVar: selector })),
setWhenOutputNone: option => set(() => ({ whenOutputNone: option })),
setDefaultValue: value => set(() => ({ defaultValue: value })),
setShowDebugPanel: show => set(() => ({ showDebugPanel: show })),
setIsRunning: running => set(() => ({ isRunning: running })),
setParentAvailableVars: vars => set(() => ({ parentAvailableVars: vars })),
resetSubGraph: () => set(() => ({ ...initialState })),
})