chore: plugin in sandbox auto set to true

This commit is contained in:
Joel
2026-02-06 17:21:10 +08:00
parent c61129590d
commit 81715426d2
6 changed files with 31 additions and 11 deletions

View File

@ -159,7 +159,7 @@ const SkillEditor = ({
<ToolBlockReplacementBlock />
<FileReferenceReplacementBlock />
{editable && <FilePickerBlock />}
{editable && <ToolPickerBlock scope={toolPickerScope} />}
{editable && <ToolPickerBlock scope={toolPickerScope} enableAutoDefault />}
</>
<OnChangePlugin onChange={handleEditorChange} />
{editable && autoFocus && <EditorAutoFocusPlugin onAutoFocus={onAutoFocus} />}

View File

@ -60,7 +60,7 @@ const normalizeProviderIcon = (icon?: ToolWithProvider['icon']) => {
type ToolConfigField = {
id: string
value: unknown
auto: boolean
auto?: boolean
}
type ToolConfigMetadata = {
@ -87,6 +87,9 @@ const getVarKindType = (type: FormTypeEnum | string) => {
return VarKindType.constant
}
const canUseAutoByType = (type: string) =>
![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum)
const normalizeCredentialId = (credentialId?: string) => {
if (!credentialId || credentialId === '__workspace_default__')
return undefined
@ -230,7 +233,9 @@ const ToolBlockComponent = ({
const field = fieldsById.get(schema.variable)
if (!field)
return
const isAuto = Boolean(field.auto)
const isAuto = field.auto === undefined
? canUseAutoByType(schema.type)
: Boolean(field.auto)
if (isAuto) {
nextValue[schema.variable] = { auto: 1, value: null }
return

View File

@ -47,7 +47,7 @@ type ToolGroupBlockComponentProps = {
type ToolConfigField = {
id: string
value: unknown
auto: boolean
auto?: boolean
}
type ToolConfigMetadata = {
@ -223,6 +223,9 @@ const ToolGroupBlockComponent = ({
return VarKindType.constant
}
const canUseAutoByType = (type: string) =>
![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum)
const normalizeCredentialId = (credentialId?: string) => {
if (!credentialId || credentialId === '__workspace_default__')
return undefined
@ -266,7 +269,9 @@ const ToolGroupBlockComponent = ({
const field = fieldsById.get(schema.variable)
if (!field)
return
const isAuto = Boolean(field.auto)
const isAuto = field.auto === undefined
? canUseAutoByType(schema.type)
: Boolean(field.auto)
if (isAuto) {
nextValue[schema.variable] = { auto: 1, value: null }
return

View File

@ -15,6 +15,7 @@ import ReactDOM from 'react-dom'
import { v4 as uuid } from 'uuid'
import { useBasicTypeaheadTriggerMatch } from '@/app/components/base/prompt-editor/hooks'
import { $splitNodeContainingQuery } from '@/app/components/base/prompt-editor/utils'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import ToolPicker from '@/app/components/workflow/block-selector/tool-picker'
import { START_TAB_ID } from '@/app/components/workflow/skill/constants'
@ -31,9 +32,10 @@ class ToolPickerMenuOption extends MenuOption {
type ToolPickerBlockProps = {
scope?: string
enableAutoDefault?: boolean
}
const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => {
const ToolPickerBlock = ({ scope = 'all', enableAutoDefault = false }: ToolPickerBlockProps) => {
const [editor] = useLexicalComposerContext()
const checkForTriggerMatch = useBasicTypeaheadTriggerMatch('@', {
minLength: 0,
@ -44,6 +46,11 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => {
const isUsingExternalMetadata = Boolean(toolBlockContext?.onMetadataChange)
const [queryString, setQueryString] = useState('')
const canUseAutoByType = useCallback(
(type: string) => ![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum),
[],
)
const options = useMemo(() => [new ToolPickerMenuOption()], [])
const getMatchFromSelection = useCallback(() => {
@ -70,7 +77,7 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => {
const fields = schemas.map(schema => ({
id: schema.variable,
value: schema.default ?? null,
auto: schema.form === 'llm',
auto: enableAutoDefault ? canUseAutoByType(schema.type) : schema.form === 'llm',
}))
nextTools[configId] = {
type: tool.provider_type,
@ -81,7 +88,7 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => {
...metadata,
tools: nextTools,
}
}, [])
}, [canUseAutoByType, enableAutoDefault])
const insertTools = useCallback((tools: ToolDefaultValue[]) => {
const toolEntries = tools.map(tool => ({

View File

@ -93,6 +93,8 @@ const ToolSettingsSection = ({
const showSettingsSection = currentToolSettings.length > 0
const showParamsSection = currentToolParams.length > 0
const canUseAutoByType = (type: string) =>
![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum)
const getVarKindType = (type: FormTypeEnum | string) => {
if (type === FormTypeEnum.file || type === FormTypeEnum.files)
return VarKindType.variable
@ -107,8 +109,9 @@ const ToolSettingsSection = ({
schemas.forEach((schema) => {
const currentValue = nextValue[schema.variable]
if (!currentValue) {
const canUseAuto = canUseAutoByType(schema.type)
nextValue[schema.variable] = {
auto: 0,
auto: canUseAuto ? 1 : 0,
value: {
type: getVarKindType(schema.type),
value: schema.default ?? null,
@ -117,7 +120,7 @@ const ToolSettingsSection = ({
return
}
if (currentValue.auto === undefined)
currentValue.auto = 0
currentValue.auto = canUseAutoByType(schema.type) ? 1 : 0
if (currentValue.value === undefined) {
currentValue.value = {
type: getVarKindType(schema.type),