mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-26 02:07:28 +08:00
@@ -239,10 +239,10 @@ export const getSystemToolsWithInstalled = async ({
|
||||
};
|
||||
|
||||
export const getSystemToolByIdAndVersionId = async (
|
||||
pluginId: string,
|
||||
toolId: string,
|
||||
versionId?: string
|
||||
): Promise<ChildAppType> => {
|
||||
const tool = await getSystemToolById(pluginId);
|
||||
const tool = await getSystemToolById(toolId);
|
||||
|
||||
// App type system tool
|
||||
if (tool.associatedPluginId) {
|
||||
@@ -333,10 +333,6 @@ export const getSystemToolByIdAndVersionId = async (
|
||||
|
||||
/*
|
||||
Format plugin to workflow preview node data
|
||||
Persion workflow/plugin: objectId
|
||||
Persion mcptoolset: objectId
|
||||
Persion mcp tool: mcp-parentId/name
|
||||
System tool/toolset: system-toolId
|
||||
*/
|
||||
export async function getChildAppPreviewNode({
|
||||
appId,
|
||||
@@ -350,8 +346,7 @@ export async function getChildAppPreviewNode({
|
||||
const { source, pluginId } = splitCombineToolId(appId);
|
||||
|
||||
const app: ChildAppType = await (async () => {
|
||||
// 1. App
|
||||
// 2. MCP ToolSets
|
||||
// App / Mcp toolset / Http toolset
|
||||
if (source === AppToolSourceEnum.personal) {
|
||||
const item = await MongoApp.findById(pluginId).lean();
|
||||
if (!item) return Promise.reject(PluginErrEnum.unExist);
|
||||
@@ -367,17 +362,18 @@ export async function getChildAppPreviewNode({
|
||||
})
|
||||
: true;
|
||||
|
||||
if (item.type === AppTypeEnum.mcpToolSet) {
|
||||
// Adapt
|
||||
if (item.type === AppTypeEnum.mcpToolSet && !version.nodes[0].toolConfig) {
|
||||
const children = await getMCPChildren(item);
|
||||
version.nodes[0].toolConfig = {
|
||||
mcpToolSet: {
|
||||
toolId: pluginId,
|
||||
toolList: children,
|
||||
url: '',
|
||||
headerSecret: {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
id: String(item._id),
|
||||
teamId: String(item.teamId),
|
||||
@@ -430,11 +426,12 @@ export async function getChildAppPreviewNode({
|
||||
getMCPToolRuntimeNode({
|
||||
nodeId: getNanoid(6),
|
||||
toolSetId: item._id,
|
||||
toolsetName: item.name,
|
||||
avatar: item.avatar,
|
||||
tool: {
|
||||
description: tool.description,
|
||||
inputSchema: tool.inputSchema,
|
||||
name: `${item.name}/${tool.name}`
|
||||
name: tool.name
|
||||
}
|
||||
})
|
||||
],
|
||||
@@ -469,11 +466,12 @@ export async function getChildAppPreviewNode({
|
||||
getHTTPToolRuntimeNode({
|
||||
nodeId: getNanoid(6),
|
||||
toolSetId: item._id,
|
||||
toolsetName: item.name,
|
||||
tool: {
|
||||
description: tool.description,
|
||||
inputSchema: tool.inputSchema,
|
||||
outputSchema: tool.outputSchema,
|
||||
name: `${item.name}/${tool.name}`
|
||||
name: tool.name
|
||||
},
|
||||
avatar: item.avatar
|
||||
})
|
||||
@@ -484,10 +482,9 @@ export async function getChildAppPreviewNode({
|
||||
isLatestVersion: true
|
||||
};
|
||||
}
|
||||
// 1. System Tools
|
||||
// 2. System Plugins configured in Pro (has associatedPluginId)
|
||||
// System Tools/ Commercial system tools
|
||||
else {
|
||||
return getSystemToolByIdAndVersionId(pluginId, versionId);
|
||||
return getSystemToolByIdAndVersionId(appId, versionId);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -504,7 +501,7 @@ export async function getChildAppPreviewNode({
|
||||
if (source === AppToolSourceEnum.systemTool) {
|
||||
// system Tool or Toolsets
|
||||
const children = app.isFolder
|
||||
? (await getSystemTools()).filter((item) => item.parentId === pluginId)
|
||||
? (await getSystemTools()).filter((item) => item.parentId === app.id)
|
||||
: [];
|
||||
|
||||
return {
|
||||
@@ -619,74 +616,6 @@ export async function getChildAppPreviewNode({
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
Get runtime plugin data
|
||||
System plugin: plugin id
|
||||
Personal plugin: Version id
|
||||
*/
|
||||
export async function getChildAppRuntimeById({
|
||||
id,
|
||||
versionId,
|
||||
lang = 'en'
|
||||
}: {
|
||||
id: string;
|
||||
versionId?: string;
|
||||
lang?: localeType;
|
||||
}): Promise<AppToolRuntimeType> {
|
||||
const app = await (async () => {
|
||||
const { source, pluginId } = splitCombineToolId(id);
|
||||
|
||||
if (source === AppToolSourceEnum.personal) {
|
||||
const item = await MongoApp.findById(pluginId).lean();
|
||||
if (!item) return Promise.reject(PluginErrEnum.unExist);
|
||||
|
||||
const version = await getAppVersionById({
|
||||
appId: pluginId,
|
||||
versionId,
|
||||
app: item
|
||||
});
|
||||
|
||||
return {
|
||||
id: String(item._id),
|
||||
teamId: String(item.teamId),
|
||||
tmbId: String(item.tmbId),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
showStatus: true,
|
||||
workflow: {
|
||||
nodes: version.nodes,
|
||||
edges: version.edges,
|
||||
chatConfig: version.chatConfig
|
||||
},
|
||||
templateType: FlowNodeTemplateTypeEnum.teamApp,
|
||||
|
||||
originCost: 0,
|
||||
currentCost: 0,
|
||||
systemKeyCost: 0,
|
||||
hasTokenFee: false,
|
||||
pluginOrder: 0
|
||||
};
|
||||
} else {
|
||||
return getSystemToolByIdAndVersionId(pluginId, versionId);
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
id: app.id,
|
||||
teamId: app.teamId,
|
||||
tmbId: app.tmbId,
|
||||
name: parseI18nString(app.name, lang),
|
||||
avatar: app.avatar || '',
|
||||
showStatus: true,
|
||||
currentCost: app.currentCost,
|
||||
systemKeyCost: app.systemKeyCost,
|
||||
nodes: app.workflow.nodes,
|
||||
edges: app.workflow.edges,
|
||||
hasTokenFee: app.hasTokenFee
|
||||
};
|
||||
}
|
||||
|
||||
/* FastsGPT-tool api: */
|
||||
export const refreshSystemTools = async (): Promise<AppToolTemplateItemType[]> => {
|
||||
const workflowToolFormat = (item: SystemPluginToolCollectionType): AppToolTemplateItemType => {
|
||||
@@ -784,10 +713,10 @@ export const refreshSystemTools = async (): Promise<AppToolTemplateItemType[]> =
|
||||
return concatTools;
|
||||
};
|
||||
|
||||
export const getSystemToolById = async (id: string): Promise<AppToolTemplateItemType> => {
|
||||
const { pluginId } = splitCombineToolId(id);
|
||||
// toolId: systemTool-id, commercial-id
|
||||
export const getSystemToolById = async (toolId: string): Promise<AppToolTemplateItemType> => {
|
||||
const tools = await getSystemTools();
|
||||
const tool = tools.find((item) => item.id === pluginId);
|
||||
const tool = tools.find((item) => item.id === toolId);
|
||||
if (tool) {
|
||||
return cloneDeep(tool);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,12 @@ export const computedAppToolUsage = async ({
|
||||
const { source } = splitCombineToolId(plugin.id);
|
||||
const childrenUsages = childrenUsage.reduce((sum, item) => sum + (item.totalPoints || 0), 0);
|
||||
|
||||
if (source !== AppToolSourceEnum.personal) {
|
||||
const set = new Set([
|
||||
AppToolSourceEnum.commercial,
|
||||
AppToolSourceEnum.community,
|
||||
AppToolSourceEnum.systemTool
|
||||
]);
|
||||
if (set.has(source)) {
|
||||
if (error) return 0;
|
||||
|
||||
const pluginCurrentCost = plugin.currentCost ?? 0;
|
||||
|
||||
@@ -82,7 +82,7 @@ export async function rewriteAppWorkflowToDetail({
|
||||
/* Add node(App Type) versionlabel and latest sign ==== */
|
||||
await Promise.all(
|
||||
nodes.map(async (node) => {
|
||||
// Tool node(简易模式/工作流)
|
||||
// Tool node
|
||||
if (node.pluginId) {
|
||||
const result = await loadToolNode({ id: node.pluginId, versionId: node.version });
|
||||
if (result.success) {
|
||||
|
||||
@@ -7,6 +7,7 @@ export const collectionName = 'system_plugin_tools';
|
||||
|
||||
const SystemToolSchema = new Schema({
|
||||
pluginId: {
|
||||
// commercial-id
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
|
||||
@@ -20,6 +20,7 @@ import { getAppVersionById } from '../../../../../../app/version/controller';
|
||||
import { MCPClient } from '../../../../../../app/mcp';
|
||||
import { runHTTPTool } from '../../../../../../app/http';
|
||||
import { getS3ChatSource } from '../../../../../../../common/s3/sources/chat';
|
||||
import { parseToolId } from '../../../../child/runTool';
|
||||
|
||||
type SystemInputConfigType = {
|
||||
type: SystemToolSecretInputTypeEnum;
|
||||
@@ -175,8 +176,7 @@ export const dispatchTool = async ({
|
||||
]
|
||||
};
|
||||
} else if (toolConfig?.mcpTool?.toolId) {
|
||||
const { pluginId } = splitCombineToolId(toolConfig.mcpTool.toolId);
|
||||
const [parentId, toolSetName, toolName] = pluginId.split('/');
|
||||
const { parentId, toolName } = parseToolId(toolConfig.mcpTool.toolId);
|
||||
const tool = await getAppVersionById({
|
||||
appId: parentId,
|
||||
versionId: version
|
||||
@@ -203,8 +203,7 @@ export const dispatchTool = async ({
|
||||
usages: []
|
||||
};
|
||||
} else if (toolConfig?.httpTool?.toolId) {
|
||||
const { pluginId } = splitCombineToolId(toolConfig.httpTool.toolId);
|
||||
const [parentId, toolSetName, toolName] = pluginId.split('/');
|
||||
const { parentId, toolName } = parseToolId(toolConfig.httpTool.toolId);
|
||||
if (!parentId || !toolName) {
|
||||
return Promise.reject(`Invalid HTTP tool id: ${toolConfig.httpTool.toolId}`);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import type { SubAppInitType } from '../type';
|
||||
import { getToolConfigStatus } from '@fastgpt/global/core/app/formEdit/utils';
|
||||
import { getLogger, LogCategories } from '../../../../../../../common/logger';
|
||||
|
||||
export const agentSkillToToolRuntime = async ({
|
||||
export const getAgentRuntimeTools = async ({
|
||||
tools,
|
||||
tmbId,
|
||||
lang
|
||||
@@ -195,18 +195,15 @@ export const agentSkillToToolRuntime = async ({
|
||||
if (!app) return [];
|
||||
const toolList = await getMCPChildren(app);
|
||||
|
||||
const toolSetId = mcpToolsetVal.toolId ?? toolNode.pluginId;
|
||||
const toolSetId = mcpToolsetVal.toolId || toolNode.pluginId;
|
||||
const children = toolList.map((tool, index) => {
|
||||
const newToolNode = getMCPToolRuntimeNode({
|
||||
toolSetId,
|
||||
toolsetName: toolNode.name,
|
||||
nodeId: `${toolSetId}${index}`,
|
||||
avatar: toolNode.avatar,
|
||||
tool: {
|
||||
...tool,
|
||||
name: `${toolNode.name}/${tool.name}`
|
||||
}
|
||||
tool
|
||||
});
|
||||
|
||||
return newToolNode;
|
||||
});
|
||||
|
||||
@@ -232,15 +229,12 @@ export const agentSkillToToolRuntime = async ({
|
||||
} else if (httpToolsetVal) {
|
||||
const children = httpToolsetVal.toolList.map((tool: HttpToolConfigType, index) => {
|
||||
const newToolNode = getHTTPToolRuntimeNode({
|
||||
tool: {
|
||||
...tool,
|
||||
name: `${toolNode.name}/${tool.name}`
|
||||
},
|
||||
tool,
|
||||
nodeId: `${pluginId}${index}`,
|
||||
avatar: toolNode.avatar,
|
||||
toolSetId: pluginId
|
||||
toolSetId: pluginId,
|
||||
toolsetName: toolNode.name
|
||||
});
|
||||
|
||||
return newToolNode;
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { localeType } from '@fastgpt/global/common/i18n/type';
|
||||
import type { SkillToolType } from '@fastgpt/global/core/ai/skill/type';
|
||||
import type { ChatCompletionTool } from '@fastgpt/global/core/ai/type';
|
||||
import type { SubAppRuntimeType } from './type';
|
||||
import { agentSkillToToolRuntime } from './sub/tool/utils';
|
||||
import { getAgentRuntimeTools } from './sub/tool/utils';
|
||||
import { readFileTool } from './sub/file/utils';
|
||||
import { PlanAgentTool } from './sub/plan/constants';
|
||||
import { datasetSearchTool } from './sub/dataset/utils';
|
||||
@@ -43,7 +43,7 @@ export const getSubapps = async ({
|
||||
}
|
||||
|
||||
/* System tool */
|
||||
const formatTools = await agentSkillToToolRuntime({
|
||||
const formatTools = await getAgentRuntimeTools({
|
||||
tools,
|
||||
tmbId,
|
||||
lang
|
||||
|
||||
@@ -19,7 +19,6 @@ import { getSystemToolById } from '../../../app/tool/controller';
|
||||
import { textAdaptGptResponse } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { pushTrack } from '../../../../common/middle/tracks/utils';
|
||||
import { getNodeErrResponse } from '../utils';
|
||||
import { splitCombineToolId } from '@fastgpt/global/core/app/tool/utils';
|
||||
import { getAppVersionById } from '../../../../core/app/version/controller';
|
||||
import { runHTTPTool } from '../../../app/http';
|
||||
import { getS3ChatSource } from '../../../../common/s3/sources/chat';
|
||||
@@ -207,8 +206,7 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
};
|
||||
} else if (toolConfig?.mcpTool?.toolId) {
|
||||
// pluginId: toolSetAppId/toolsetName/toolName
|
||||
const { pluginId } = splitCombineToolId(toolConfig.mcpTool.toolId);
|
||||
const [parentId, toolSetName, toolName] = pluginId.split('/');
|
||||
const { parentId, toolName } = parseToolId(toolConfig.mcpTool.toolId);
|
||||
const tool = await getAppVersionById({
|
||||
appId: parentId,
|
||||
versionId: version
|
||||
@@ -241,8 +239,7 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
[DispatchNodeResponseKeyEnum.toolResponses]: result
|
||||
};
|
||||
} else if (toolConfig?.httpTool?.toolId) {
|
||||
const { pluginId } = splitCombineToolId(toolConfig.httpTool.toolId);
|
||||
const [parentId, toolSetName, toolName] = pluginId.split('/');
|
||||
const { parentId, toolName } = parseToolId(toolConfig.httpTool.toolId);
|
||||
const toolset = await getAppVersionById({
|
||||
appId: parentId,
|
||||
versionId: version
|
||||
@@ -347,3 +344,16 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const parseToolId = (id: string) => {
|
||||
const formatId = id.split('-').slice(1).join('-');
|
||||
const [parentId, toolsetNameOrToolName, legacyToolName] = formatId.split('/');
|
||||
|
||||
if (legacyToolName) {
|
||||
// 旧版格式: source-appId/toolsetName/toolName
|
||||
return { parentId, toolName: legacyToolName };
|
||||
}
|
||||
|
||||
// 新版格式: source-appId/toolName
|
||||
return { parentId, toolName: toolsetNameOrToolName };
|
||||
};
|
||||
|
||||
@@ -14,18 +14,22 @@ import {
|
||||
storeNodes2RuntimeNodes
|
||||
} from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { authPluginByTmbId } from '../../../../support/permission/app/auth';
|
||||
import { authWorkflowToolByTmbId } from '../../../../support/permission/app/auth';
|
||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { computedAppToolUsage } from '../../../app/tool/runtime/utils';
|
||||
import { filterSystemVariables, getNodeErrResponse } from '../utils';
|
||||
import { serverGetWorkflowToolRunUserQuery } from '../../../app/tool/workflowTool/utils';
|
||||
import type { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { getChildAppRuntimeById } from '../../../app/tool/controller';
|
||||
import {
|
||||
type NodeInputKeyEnum,
|
||||
type NodeOutputKeyEnum
|
||||
} from '@fastgpt/global/core/workflow/constants';
|
||||
import { runWorkflow } from '../index';
|
||||
import { getUserChatInfo } from '../../../../support/user/team/utils';
|
||||
import { dispatchRunTool } from '../child/runTool';
|
||||
import type { AppToolRuntimeType } from '@fastgpt/global/core/app/tool/type';
|
||||
import { anyValueDecrypt } from '../../../../common/secret/utils';
|
||||
import { getAppVersionById } from '../../../app/version/controller';
|
||||
import { parseI18nString } from '@fastgpt/global/common/i18n/utils';
|
||||
|
||||
type RunPluginProps = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.forbidStream]?: boolean;
|
||||
@@ -51,7 +55,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
return getNodeErrResponse({ error: 'pluginId can not find' });
|
||||
}
|
||||
|
||||
let plugin: AppToolRuntimeType | undefined;
|
||||
let workflowTool: AppToolRuntimeType | undefined;
|
||||
|
||||
try {
|
||||
// Adapt <= 4.10 system tool
|
||||
@@ -70,33 +74,55 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
});
|
||||
}
|
||||
|
||||
if (source !== AppToolSourceEnum.commercial && source !== AppToolSourceEnum.personal) {
|
||||
return getNodeErrResponse({ error: 'pluginId can not find' });
|
||||
}
|
||||
|
||||
/*
|
||||
1. Team app
|
||||
2. Admin selected system tool
|
||||
*/
|
||||
const { files } = chatValue2RuntimePrompt(query);
|
||||
|
||||
// auth plugin
|
||||
const pluginData = await authPluginByTmbId({
|
||||
appId: pluginId,
|
||||
// auth workflowTool
|
||||
const toolData = await authWorkflowToolByTmbId({
|
||||
appId: formatPluginId,
|
||||
tmbId: runningAppInfo.tmbId,
|
||||
per: ReadPermissionVal
|
||||
});
|
||||
|
||||
plugin = await getChildAppRuntimeById({ id: pluginId, versionId: version });
|
||||
const toolVersion = await getAppVersionById({
|
||||
appId: toolData._id,
|
||||
versionId: version,
|
||||
app: toolData
|
||||
});
|
||||
|
||||
workflowTool = {
|
||||
id: String(toolData._id),
|
||||
teamId: toolData.teamId,
|
||||
tmbId: toolData.tmbId,
|
||||
name: parseI18nString(toolData.name, props.lang),
|
||||
avatar: toolData.avatar || '',
|
||||
showStatus: true,
|
||||
currentCost: 0,
|
||||
systemKeyCost: 0,
|
||||
nodes: toolVersion.nodes,
|
||||
edges: toolVersion.edges,
|
||||
hasTokenFee: false
|
||||
};
|
||||
|
||||
const outputFilterMap =
|
||||
plugin.nodes
|
||||
workflowTool.nodes
|
||||
.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput)
|
||||
?.inputs.reduce<Record<string, boolean>>((acc, cur) => {
|
||||
acc[cur.key] = cur.isToolOutput === false ? false : true;
|
||||
return acc;
|
||||
}, {}) ?? {};
|
||||
const runtimeNodes = storeNodes2RuntimeNodes(
|
||||
plugin.nodes,
|
||||
getWorkflowEntryNodeIds(plugin.nodes)
|
||||
workflowTool.nodes,
|
||||
getWorkflowEntryNodeIds(workflowTool.nodes)
|
||||
).map((node) => {
|
||||
// Update plugin input value
|
||||
// Update workflowTool input value
|
||||
if (node.flowNodeType === FlowNodeTypeEnum.pluginInput) {
|
||||
return {
|
||||
...node,
|
||||
@@ -129,7 +155,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
const { externalProvider } = await getUserChatInfo(runningAppInfo.tmbId);
|
||||
const runtimeVariables = {
|
||||
...filterSystemVariables(props.variables),
|
||||
appId: String(plugin.id),
|
||||
appId: String(workflowTool.id),
|
||||
...(externalProvider ? externalProvider.externalWorkflowVariables : {})
|
||||
};
|
||||
const {
|
||||
@@ -150,27 +176,27 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
}
|
||||
: {}),
|
||||
runningAppInfo: {
|
||||
id: String(plugin.id),
|
||||
name: plugin.name,
|
||||
id: String(workflowTool.id),
|
||||
name: workflowTool.name,
|
||||
// 如果系统插件有 teamId 和 tmbId,则使用系统插件的 teamId 和 tmbId(管理员指定了插件作为系统插件)
|
||||
teamId: plugin.teamId || runningAppInfo.teamId,
|
||||
tmbId: plugin.tmbId || runningAppInfo.tmbId,
|
||||
teamId: workflowTool.teamId || runningAppInfo.teamId,
|
||||
tmbId: workflowTool.tmbId || runningAppInfo.tmbId,
|
||||
isChildApp: true
|
||||
},
|
||||
variables: runtimeVariables,
|
||||
query: serverGetWorkflowToolRunUserQuery({
|
||||
pluginInputs: getWorkflowToolInputsFromStoreNodes(plugin.nodes),
|
||||
pluginInputs: getWorkflowToolInputsFromStoreNodes(workflowTool.nodes),
|
||||
variables: runtimeVariables,
|
||||
files
|
||||
}).value,
|
||||
chatConfig: {},
|
||||
runtimeNodes,
|
||||
runtimeEdges: storeEdges2RuntimeEdges(plugin.edges)
|
||||
runtimeEdges: storeEdges2RuntimeEdges(workflowTool.edges)
|
||||
});
|
||||
const output = flowResponses.find((item) => item.moduleType === FlowNodeTypeEnum.pluginOutput);
|
||||
|
||||
const usagePoints = await computedAppToolUsage({
|
||||
plugin,
|
||||
plugin: workflowTool,
|
||||
childrenUsage: flowUsages,
|
||||
error: !!output?.pluginOutput?.error
|
||||
});
|
||||
@@ -182,20 +208,17 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
// responseData, // debug
|
||||
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
moduleLogo: plugin.avatar,
|
||||
moduleLogo: workflowTool.avatar,
|
||||
totalPoints: usagePoints,
|
||||
toolInput: data,
|
||||
pluginOutput: output?.pluginOutput,
|
||||
pluginDetail: pluginData?.permission?.hasWritePer // Not system plugin
|
||||
? flowResponses.filter((item) => {
|
||||
const filterArr = [FlowNodeTypeEnum.pluginOutput];
|
||||
return !filterArr.includes(item.moduleType as any);
|
||||
})
|
||||
pluginDetail: toolData?.permission?.hasWritePer // Not system workflowTool
|
||||
? flowResponses
|
||||
: undefined
|
||||
},
|
||||
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [
|
||||
{
|
||||
moduleName: plugin.name,
|
||||
moduleName: workflowTool.name,
|
||||
totalPoints: usagePoints
|
||||
}
|
||||
],
|
||||
@@ -212,7 +235,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
||||
} catch (error) {
|
||||
return getNodeErrResponse({
|
||||
error,
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: { moduleLogo: plugin?.avatar }
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: { moduleLogo: workflowTool?.avatar }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -332,34 +332,29 @@ export const rewriteRuntimeWorkFlow = async ({
|
||||
if (!app) continue;
|
||||
const toolList = await getMCPChildren(app);
|
||||
|
||||
// mcpToolsetVal.toolId-旧版 MCP
|
||||
const toolSetId = mcpToolsetVal.toolId ?? toolSetNode.pluginId;
|
||||
// mcpToolsetVal.toolId: 旧版 MCP
|
||||
const toolSetId = mcpToolsetVal.toolId || toolSetNode.pluginId;
|
||||
|
||||
toolList.forEach((tool, index) => {
|
||||
const newToolNode = getMCPToolRuntimeNode({
|
||||
nodeId: `${toolSetNode.nodeId}${index}`,
|
||||
toolSetId,
|
||||
toolsetName: toolSetNode.name,
|
||||
avatar: toolSetNode.avatar,
|
||||
tool: {
|
||||
...tool,
|
||||
name: `${toolSetNode.name}/${tool.name}`
|
||||
}
|
||||
tool
|
||||
});
|
||||
|
||||
nodes.push(newToolNode);
|
||||
pushEdges(newToolNode.nodeId);
|
||||
});
|
||||
} else if (httpToolsetVal) {
|
||||
httpToolsetVal.toolList.forEach((tool: HttpToolConfigType, index: number) => {
|
||||
const newToolNode = getHTTPToolRuntimeNode({
|
||||
tool: {
|
||||
...tool,
|
||||
name: `${toolSetNode.name}/${tool.name}`
|
||||
},
|
||||
tool,
|
||||
nodeId: `${toolSetNode.nodeId}${index}`,
|
||||
avatar: toolSetNode.avatar,
|
||||
toolSetId: toolSetNode.pluginId!
|
||||
toolSetId: toolSetNode.pluginId!,
|
||||
toolsetName: toolSetNode.name
|
||||
});
|
||||
|
||||
nodes.push(newToolNode);
|
||||
pushEdges(newToolNode.nodeId);
|
||||
});
|
||||
|
||||
@@ -15,12 +15,11 @@ import { type PermissionValueType } from '@fastgpt/global/support/permission/typ
|
||||
import { AppFolderTypeList, AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type';
|
||||
import { type AuthModeType, type AuthResponseType } from '../type';
|
||||
import { splitCombineToolId } from '@fastgpt/global/core/app/tool/utils';
|
||||
import { AppReadChatLogPerVal } from '@fastgpt/global/support/permission/app/constant';
|
||||
import { parseHeaderCert } from '../auth/common';
|
||||
import { sumPer } from '@fastgpt/global/support/permission/utils';
|
||||
|
||||
export const authPluginByTmbId = async ({
|
||||
export const authWorkflowToolByTmbId = async ({
|
||||
tmbId,
|
||||
appId,
|
||||
per
|
||||
@@ -29,16 +28,12 @@ export const authPluginByTmbId = async ({
|
||||
appId: string;
|
||||
per: PermissionValueType;
|
||||
}) => {
|
||||
const { authAppId } = splitCombineToolId(appId);
|
||||
if (authAppId) {
|
||||
const { app } = await authAppByTmbId({
|
||||
appId: authAppId,
|
||||
tmbId,
|
||||
per
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
const { app } = await authAppByTmbId({
|
||||
appId,
|
||||
tmbId,
|
||||
per
|
||||
});
|
||||
return app;
|
||||
};
|
||||
|
||||
export const authAppByTmbId = async ({
|
||||
|
||||
Reference in New Issue
Block a user