From b8d4f60782757145066f09c19afa5f69a4828f8c Mon Sep 17 00:00:00 2001 From: twwu Date: Thu, 25 Dec 2025 15:51:19 +0800 Subject: [PATCH] feat: add HumanInput block support with output variable handling and integration --- web/app/components/workflow/constants.ts | 1 + .../workflow/hooks/use-workflow-variables.ts | 2 +- .../nodes/_base/components/variable/utils.ts | 13 +++++++++++++ .../workflow/nodes/human-input/default.ts | 19 +++++++++++++++++-- .../workflow/nodes/human-input/types.ts | 2 -- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.ts index 4d95db7fcf..76ad86b6b7 100644 --- a/web/app/components/workflow/constants.ts +++ b/web/app/components/workflow/constants.ts @@ -128,6 +128,7 @@ export const SUPPORT_OUTPUT_VARS_NODE = [ BlockEnum.ListFilter, BlockEnum.Agent, BlockEnum.DataSource, + BlockEnum.HumanInput, ] export const AGENT_OUTPUT_STRUCT: Var[] = [ diff --git a/web/app/components/workflow/hooks/use-workflow-variables.ts b/web/app/components/workflow/hooks/use-workflow-variables.ts index d6a5b8bdd1..8a975d80ec 100644 --- a/web/app/components/workflow/hooks/use-workflow-variables.ts +++ b/web/app/components/workflow/hooks/use-workflow-variables.ts @@ -116,7 +116,7 @@ export const useWorkflowVariables = () => { schemaTypeDefinitions, preferSchemaType, }) - }, [workflowStore, getVarType, schemaTypeDefinitions, buildInTools, customTools, workflowTools, mcpTools]) + }, [workflowStore, schemaTypeDefinitions, buildInTools, customTools, workflowTools, mcpTools]) return { getNodeAvailableVars, diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index a7dc04e571..634c29798f 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -15,6 +15,7 @@ import type { QuestionClassifierNodeType } from '../../../question-classifier/ty import type { TemplateTransformNodeType } from '../../../template-transform/types' import type { ToolNodeType } from '../../../tool/types' import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types' +import type { HumanInputNodeType } from '@/app/components/workflow/nodes/human-input/types' import type { CaseItem, Condition } from '@/app/components/workflow/nodes/if-else/types' import type { Field as StructField } from '@/app/components/workflow/nodes/llm/types' import type { StartNodeType } from '@/app/components/workflow/nodes/start/types' @@ -49,6 +50,7 @@ import { TOOL_OUTPUT_STRUCT, } from '@/app/components/workflow/constants' import DataSourceNodeDefault from '@/app/components/workflow/nodes/data-source/default' +import HumanInputNodeDefault from '@/app/components/workflow/nodes/human-input/default' import ToolNodeDefault from '@/app/components/workflow/nodes/tool/default' import PluginTriggerNodeDefault from '@/app/components/workflow/nodes/trigger-plugin/default' import { @@ -630,6 +632,17 @@ const formatItem = ( break } + case BlockEnum.HumanInput: { + const outputSchema = HumanInputNodeDefault.getOutputVars?.( + data as HumanInputNodeType, + allPluginInfoList, + [], + { schemaTypeDefinitions }, + ) || [] + res.vars = outputSchema + break + } + case 'env': { res.vars = data.envList.map((env: EnvironmentVariable) => { return { diff --git a/web/app/components/workflow/nodes/human-input/default.ts b/web/app/components/workflow/nodes/human-input/default.ts index bcd272ad13..ed98aa5816 100644 --- a/web/app/components/workflow/nodes/human-input/default.ts +++ b/web/app/components/workflow/nodes/human-input/default.ts @@ -1,7 +1,7 @@ -import type { NodeDefault } from '../../types' +import type { NodeDefault, Var } from '../../types' import type { HumanInputNodeType } from './types' import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types' -import { BlockEnum } from '@/app/components/workflow/types' +import { BlockEnum, VarType } from '@/app/components/workflow/types' // import { DeliveryMethodType, UserActionButtonType } from './types' import { genNodeMetaData } from '@/app/components/workflow/utils' @@ -13,11 +13,22 @@ const metaData = genNodeMetaData({ type: BlockEnum.HumanInput, }) +const buildOutputVars = (variables: string[]): Var[] => { + return variables.map((variable) => { + return { + variable, + type: VarType.string, + } + }) +} + const nodeDefault: NodeDefault = { metaData, defaultValue: { delivery_methods: [], user_actions: [], + form_content: '', + inputs: [], timeout: 3, timeout_unit: 'day', }, @@ -46,6 +57,10 @@ const nodeDefault: NodeDefault = { errorMessage: errorMessages, } }, + getOutputVars(payload, _allPluginInfoList, _ragVars) { + const variables = payload.inputs.map(input => input.output_variable_name) + return buildOutputVars(variables) + }, } export default nodeDefault diff --git a/web/app/components/workflow/nodes/human-input/types.ts b/web/app/components/workflow/nodes/human-input/types.ts index 30191e6504..0c7029f071 100644 --- a/web/app/components/workflow/nodes/human-input/types.ts +++ b/web/app/components/workflow/nodes/human-input/types.ts @@ -2,7 +2,6 @@ import type { CommonNodeType, InputVarType, ValueSelector, - Variable, } from '@/app/components/workflow/types' export type HumanInputNodeType = CommonNodeType & { @@ -12,7 +11,6 @@ export type HumanInputNodeType = CommonNodeType & { user_actions: UserAction[] timeout: number timeout_unit: 'hour' | 'day' - outputs: Variable[] } export enum DeliveryMethodType {