mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat: AI Workflow Builder backend (no-changelog) (#14837)
This commit is contained in:
22
packages/@n8n/ai-workflow-builder/src/workflow-state.ts
Normal file
22
packages/@n8n/ai-workflow-builder/src/workflow-state.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
import { Annotation, END } from '@langchain/langgraph';
|
||||
|
||||
import type { SimpleWorkflow } from './types';
|
||||
|
||||
export const WorkflowState = Annotation.Root({
|
||||
messages: Annotation<BaseMessage[]>({
|
||||
reducer: (x, y) => x.concat(y),
|
||||
}),
|
||||
// The original prompt from the user.
|
||||
prompt: Annotation<string>({ reducer: (x, y) => y ?? x ?? '' }),
|
||||
// The list of logically derived workflow steps.
|
||||
steps: Annotation<string[]>({ reducer: (x, y) => y ?? x ?? [] }),
|
||||
// The list of candidate or selected n8n node names.
|
||||
nodes: Annotation<string[]>({ reducer: (x, y) => y ?? x ?? [] }),
|
||||
// The JSON representation of the workflow being built.
|
||||
workflowJSON: Annotation<SimpleWorkflow>({
|
||||
reducer: (x, y) => y ?? x ?? { nodes: [], connections: {} },
|
||||
}),
|
||||
// The next phase to be executed in the workflow graph.
|
||||
next: Annotation<string>({ reducer: (x, y) => y ?? x ?? END, default: () => END }),
|
||||
});
|
||||
Reference in New Issue
Block a user