mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor: Simplify agent request store (#15743)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useRunWorkflow } from '@/composables/useRunWorkflow';
|
||||
import { FROM_AI_PARAMETERS_MODAL_KEY, AI_MCP_TOOL_NODE_TYPE } from '@/constants';
|
||||
import { useAgentRequestStore } from '@n8n/stores/useAgentRequestStore';
|
||||
import { useAgentRequestStore, type IAgentRequest } from '@n8n/stores/useAgentRequestStore';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { createEventBus } from '@n8n/utils/event-bus';
|
||||
import {
|
||||
@@ -166,11 +166,8 @@ watch(
|
||||
const inputQuery = inputOverrides?.query as IDataObject;
|
||||
const initialValue = inputQuery?.[value.key]
|
||||
? inputQuery[value.key]
|
||||
: (agentRequestStore.getAgentRequest(
|
||||
workflowsStore.workflowId,
|
||||
newNode.id,
|
||||
'query.' + value.key,
|
||||
) ?? mapTypes[type]?.defaultValue);
|
||||
: (agentRequestStore.getQueryValue(workflowsStore.workflowId, newNode.id, value.key) ??
|
||||
mapTypes[type]?.defaultValue);
|
||||
|
||||
result.push({
|
||||
name: 'query.' + value.key,
|
||||
@@ -189,7 +186,7 @@ watch(
|
||||
}
|
||||
const queryValue =
|
||||
inputQuery ??
|
||||
agentRequestStore.getAgentRequest(workflowsStore.workflowId, newNode.id, 'query') ??
|
||||
agentRequestStore.getQueryValue(workflowsStore.workflowId, newNode.id, 'query') ??
|
||||
'';
|
||||
|
||||
result.push({
|
||||
@@ -216,7 +213,24 @@ const onExecute = async () => {
|
||||
const inputValues = inputs.value?.getValues() ?? {};
|
||||
|
||||
agentRequestStore.clearAgentRequests(workflowsStore.workflowId, node.value.id);
|
||||
agentRequestStore.addAgentRequests(workflowsStore.workflowId, node.value.id, inputValues);
|
||||
|
||||
// Structure the input values as IAgentRequest
|
||||
const agentRequest: IAgentRequest = {
|
||||
query: {},
|
||||
toolName: inputValues.toolName as string,
|
||||
};
|
||||
|
||||
// Move all query.* fields to query object
|
||||
Object.entries(inputValues).forEach(([key, value]) => {
|
||||
if (key === 'query') {
|
||||
agentRequest.query = value as string;
|
||||
} else if (key.startsWith('query.') && 'string' !== typeof agentRequest.query) {
|
||||
const queryKey = key.replace('query.', '');
|
||||
agentRequest.query[queryKey] = value;
|
||||
}
|
||||
});
|
||||
|
||||
agentRequestStore.setAgentRequestForNode(workflowsStore.workflowId, node.value.id, agentRequest);
|
||||
|
||||
const telemetryPayload = {
|
||||
node_type: node.value.type,
|
||||
|
||||
Reference in New Issue
Block a user