dify/web/app/components/workflow/nodes/agent-v2/default.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

42 lines
997 B
TypeScript

import type { TFunction } from 'i18next'
import type { NodeDefault } from '../../types'
import type { AgentV2NodeType } from './types'
import { BlockEnum } from '../../types'
import { genNodeMetaData } from '../../utils'
import { hasValidAgentBinding } from './types'
const metaData = genNodeMetaData({
sort: 3,
type: BlockEnum.AgentV2,
helpLinkUri: 'agent',
})
const nodeDefault: NodeDefault<AgentV2NodeType> = {
metaData,
defaultValue: {
agent_binding: {
binding_type: 'inline_agent',
},
agent_node_kind: 'dify_agent',
version: '2',
},
checkValid(payload, t: TFunction<'workflow'>) {
if (!hasValidAgentBinding(payload)) {
return {
isValid: false,
errorMessage: t(($) => $['errorMsg.fieldRequired'], {
ns: 'workflow',
field: t(($) => $['nodes.agent.roster.label'], { ns: 'workflow' }),
}),
}
}
return {
isValid: true,
errorMessage: '',
}
},
}
export default nodeDefault