dify/web/app/components/workflow/nodes/command/default.ts
Harry 1c7c475c43 feat: add Command node support
- Introduced Command node type in workflow with associated UI components and translations.
- Enhanced SandboxLayer to manage sandbox attachment for Command nodes during execution.
- Updated various components and constants to integrate Command node functionality across the workflow.
2026-01-06 19:30:38 +08:00

36 lines
1005 B
TypeScript

import type { NodeDefault } from '../../types'
import type { CommandNodeType } from './types'
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
const i18nPrefix = 'errorMsg'
const metaData = genNodeMetaData({
classification: BlockClassificationEnum.Utilities,
sort: 2,
type: BlockEnum.Command,
})
const nodeDefault: NodeDefault<CommandNodeType> = {
metaData,
defaultValue: {
working_directory: '',
command: '',
},
checkValid(payload: CommandNodeType, t: any) {
let errorMessages = ''
const { command } = payload
if (!errorMessages && !command)
errorMessages = t(`${i18nPrefix}.fieldRequired`, { ns: 'workflow', field: t(`${i18nPrefix}.fields.command`, { ns: 'workflow' }) })
return {
isValid: !errorMessages,
errorMessage: errorMessages,
}
},
}
export default nodeDefault