From 736ec55f8686670959116e5346c4b79aaedbf0a5 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 5 Aug 2025 18:31:18 +0800 Subject: [PATCH] feat: hitl block --- .../components/base/prompt-editor/index.tsx | 18 ++++++++++++++++++ web/app/components/base/prompt-editor/types.ts | 4 ++++ web/config/index.ts | 3 +++ 3 files changed, 25 insertions(+) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 6ad832b595..9feace996c 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -39,6 +39,11 @@ import { WorkflowVariableBlockNode, WorkflowVariableBlockReplacementBlock, } from './plugins/workflow-variable-block' +import { + HITLInputBlock, + HITLInputBlockReplacementBlock, + HITLInputNode, +} from './plugins/hitl-input-block' import VariableBlock from './plugins/variable-block' import VariableValueBlock from './plugins/variable-value-block' import { VariableValueBlockNode } from './plugins/variable-value-block/node' @@ -49,6 +54,7 @@ import { textToEditorState } from './utils' import type { ContextBlockType, ExternalToolBlockType, + HITLInputBlockType, HistoryBlockType, QueryBlockType, VariableBlockType, @@ -80,6 +86,7 @@ export type PromptEditorProps = { variableBlock?: VariableBlockType externalToolBlock?: ExternalToolBlockType workflowVariableBlock?: WorkflowVariableBlockType + hitlInputBlock?: HITLInputBlockType isSupportFileVar?: boolean } @@ -102,6 +109,7 @@ const PromptEditor: FC = ({ variableBlock, externalToolBlock, workflowVariableBlock, + hitlInputBlock, isSupportFileVar, }) => { const { eventEmitter } = useEventEmitterContextContext() @@ -119,6 +127,7 @@ const PromptEditor: FC = ({ QueryBlockNode, WorkflowVariableBlockNode, VariableValueBlockNode, + HITLInputNode, ], editorState: textToEditorState(value || ''), onError: (error: Error) => { @@ -230,6 +239,15 @@ const PromptEditor: FC = ({ ) } + { + // TODO: test hitlInputBlock?.show + ( + <> + + + + ) + } diff --git a/web/app/components/base/prompt-editor/types.ts b/web/app/components/base/prompt-editor/types.ts index e82ec1da16..db182e4a51 100644 --- a/web/app/components/base/prompt-editor/types.ts +++ b/web/app/components/base/prompt-editor/types.ts @@ -70,6 +70,10 @@ export type WorkflowVariableBlockType = { getVarType?: GetVarType } +export type HITLInputBlockType = { + show?: boolean +} + export type MenuTextMatch = { leadOffset: number matchingString: string diff --git a/web/config/index.ts b/web/config/index.ts index 667723aaaf..ca9bdc7db4 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -255,6 +255,9 @@ export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#) export const resetReg = () => VAR_REGEX.lastIndex = 0 +export const HITL_INPUT_REG = /\{\{#$output\.([a-zA-Z_]\w{0,29}){1,10}#\}\}/gi +export const resetHITLInputReg = () => HITL_INPUT_REG.lastIndex = 0 + export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true' export const GITHUB_ACCESS_TOKEN = process.env.NEXT_PUBLIC_GITHUB_ACCESS_TOKEN || ''