@yiyi_zhang/reactflow-ui 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +140 -101
  2. package/dist/AiWorkflowIDE.d.ts +219 -0
  3. package/dist/WorkflowIDE.d.ts +4 -4
  4. package/dist/ai.d.ts +34 -0
  5. package/dist/components/AICopilot/ParameterSuggester.d.ts +9 -0
  6. package/dist/components/AiNative/AgentTimeline.d.ts +23 -0
  7. package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
  8. package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
  9. package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
  10. package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
  11. package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
  12. package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
  13. package/dist/components/AiNative/InlineCanvasCopilot.d.ts +7 -0
  14. package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
  15. package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
  16. package/dist/components/AiNative/PlanCard.d.ts +15 -0
  17. package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
  18. package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
  19. package/dist/components/AiNative/RepairCard.d.ts +17 -0
  20. package/dist/components/AiNative/ReviewBar.d.ts +21 -0
  21. package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
  22. package/dist/components/BrandLogo.d.ts +13 -0
  23. package/dist/components/Controls/ModeSlider.d.ts +2 -0
  24. package/dist/components/ExecutionWaterfallPanel.d.ts +3 -0
  25. package/dist/components/SandboxConfigModal.d.ts +7 -0
  26. package/dist/components/StructuredJsonViewer.d.ts +11 -0
  27. package/dist/components/nodes/NodeLayout.d.ts +3 -1
  28. package/dist/components/nodes/NodeWrapper.d.ts +2 -1
  29. package/dist/hooks/useNodeExecution.d.ts +5 -2
  30. package/dist/hooks/useNodeLayout.d.ts +1 -1
  31. package/dist/index.d.ts +5 -1
  32. package/dist/logo.svg +37 -0
  33. package/dist/product-launch.html +1400 -0
  34. package/dist/reactflow-ui-ai.es.js +21433 -0
  35. package/dist/reactflow-ui.css +1 -1
  36. package/dist/reactflow-ui.es.js +12482 -8252
  37. package/dist/reactflow-ui.umd.js +38 -20
  38. package/dist/services/ai/agentRunner.d.ts +55 -0
  39. package/dist/services/ai/contextEngine.d.ts +83 -0
  40. package/dist/services/ai/draftPersistence.d.ts +23 -0
  41. package/dist/services/ai/errorMessages.d.ts +16 -0
  42. package/dist/services/ai/intentClassifier.d.ts +17 -0
  43. package/dist/services/ai/protocolAdapter.d.ts +114 -0
  44. package/dist/services/ai/ruleEngine.d.ts +57 -0
  45. package/dist/services/ai/schemaRegistry.d.ts +51 -0
  46. package/dist/services/ai/systemPrompt.d.ts +30 -0
  47. package/dist/services/ai/toolDefs.d.ts +9 -0
  48. package/dist/services/ai/toolExecutor.d.ts +96 -0
  49. package/dist/services/ai/toolRegistry.d.ts +38 -0
  50. package/dist/services/ai/transport.d.ts +58 -0
  51. package/dist/services/ai/workflowSynthesizer.d.ts +118 -0
  52. package/dist/services/aiService.d.ts +7 -5
  53. package/dist/services/wlsp/workflowLsp.d.ts +101 -0
  54. package/dist/store/aiStore.d.ts +230 -0
  55. package/dist/store/ideStoresContext.d.ts +39 -0
  56. package/dist/store/libraryStore.d.ts +25 -0
  57. package/dist/types/aiEvents.d.ts +40 -0
  58. package/dist/types/conductor.d.ts +6 -1
  59. package/dist/types/workflow.d.ts +43 -0
  60. package/dist/types/workflowLibrary.d.ts +27 -0
  61. package/dist/utils/localSandboxEngine.d.ts +49 -0
  62. package/dist/utils/nodeMeta.d.ts +6 -0
  63. package/dist/utils/proposalPreview.d.ts +19 -0
  64. package/dist/utils/taskTypeMeta.d.ts +18 -0
  65. package/dist/utils/workflowToMermaid.d.ts +7 -0
  66. package/package.json +19 -6
package/README.md CHANGED
@@ -1,155 +1,194 @@
1
- # Conductor Workflow IDE (ReactFlow UI)
2
-
3
- 基于 React 19、ReactFlow 和 Vite 构建的企业级 [Netflix Conductor](https://conductor-oss.org/) 工作流可视化设计器。
4
-
5
- ## ✨ 核心特性
6
-
7
- ### 🎨 可视化建模
8
- - **从零创建**:无需预先提供 JSON,通过空状态引导面板新建空白工作流,配合中心 **[+]** 引导按钮快速开始建模
9
- - **完整任务类型**:支持 HTTP、SIMPLE、INLINE/LAMBDA、SWITCH、FORK_JOIN、DO_WHILE、SUB_WORKFLOW、SET_VARIABLE、TERMINATE 等全量 Conductor 任务类型
10
- - **极简视图**:移除冗余的 START/END 虚拟节点,工作流图更加聚焦业务逻辑
11
- - **智能布局**:自动 Dagre 布局(TB/LR),超大流程自动触发蛇形布局,编辑/只读模式行为一致
12
-
13
- ### 🔀 复杂结构编辑
14
- - **SWITCH 分支管理**:在节点上直接添加、重命名、删除分支,全部通过页面内 Modal,无浏览器原生弹框
15
- - **DO_WHILE 循环体**:循环任务以容器方式展示,支持在循环体内任意位置插入任务(含首位)
16
- - **FORK_JOIN 并行分支**:支持动态分支添加和管理
17
-
18
- ### ✏️ 编辑体验
19
- - **全屏代码编辑器**:点击任意表达式/脚本/JSON 字段右上角 **⛶** 按钮,展开全屏编辑器,支持 Ctrl+S 保存、Esc 取消,底部状态栏显示行数和字符数
20
- - **任务引用名实时编辑**:引用名输入框支持流畅输入,失焦/回车后提交,避免逐字符刷新
21
- - **撤销/重做**:完整的编辑历史,支持 Ctrl+Z / Ctrl+Shift+Z
22
- - **智能剪贴板**:任务复制粘贴
23
-
24
- ### 👁️ 视图模式
25
- - **Business 模式**:仅展示核心业务节点,控制/数据节点折叠为边标签
26
- - **Standard 模式**:业务 + 控制流节点(默认)
27
- - **Developer 模式**:显示全部节点,含数据转换等辅助节点,节点上展示表达式预览
28
-
29
- ### 🚀 运行态监控
30
- - 节点根据执行状态(Scheduled / In Progress / Completed / Failed / Timed Out / Skipped)实时变色
31
- - 已完成路径连线高亮,进行中路径动态动画,编辑/只读模式使用静态实线
32
- - 点击节点展示执行详情面板(输入/输出/耗时/重试次数)
33
- - **运行态操作**:暂停、继续、终止、重试、重启(支持选择定义版本)、从指定任务重跑、跳过任务
34
- - `allowOperations` 全局权限开关,快速控制操作按钮是否可用
35
-
36
- ### 🤖 AI Copilot(智能辅助)
37
- - 自然语言描述生成完整工作流,支持对话式迭代修改
38
- - 差异卡片(Diff Card)预览变更内容,一键应用/撤销
39
- - **✨ AI 参数填充(v0.4.0 新增)**:节点编辑面板一键调用 AI 生成完整 `inputParameters`,基于任务类型、上游任务列表和工作流入参自动推断,diff 预览后一键应用
40
-
41
- ### 🔬 执行验证闭环(v0.4.0 新增)
42
- - **执行验证面板**:在 edit 模式下点击"▶ 执行验证"按钮,填写工作流入参(表单/JSON 双模式),一键触发真实 Conductor 执行
43
- - **自动切换 run 模式**:执行触发后 IDE 自动切换到运行态,通过指数退避轮询实时更新执行状态
44
- - **结构化入参声明**:`WorkflowSettingsPanel` 支持可视化编辑入参名称、类型、是否必填、描述和示例值
45
-
46
- ### 📊 执行结果分析(v0.4.0 新增)
47
- - **执行概览面板**:run 模式下点击"📊 分析",展示总任务数/成功率/失败数/总耗时概览卡片
48
- - **步骤时序表**:按 `startTime` 排序显示所有任务的执行状态、耗时和重试次数,点击行可高亮对应节点
49
- - **智能故障诊断**:自动识别 10+ 种常见 Conductor 错误模式(JSONPath 失败、HTTP 错误码、超时、认证、脚本异常等),在诊断卡片中给出可操作的修复建议
50
- - **"去修复"跳转**:点击诊断卡片的"去修复"按钮,一键切换到 edit 模式并选中问题任务
51
-
52
- ### 🏢 企业级能力
53
- - TypeScript 全量类型定义(WorkflowDef、TaskDef、WorkflowInputParam、ExecutionActions…)
54
- - 命令式 API(`ref`)支持程序化创建、保存、导出
55
- - 强类型 Ref API:`getWorkflowDef()`、`save()`、`createBlankWorkflow()`
1
+ # Conductor Workflow IDE (`@yiyi_zhang/reactflow-ui` v1.0.0)
2
+
3
+ 基于 **React 19、ReactFlow 与 Zustand** 构建的下一代企业级 [Netflix Conductor](https://conductor-oss.org/) 工作流可视化设计器与 AI 原生编排 IDE。
4
+
5
+ 提供两个可独立按需集成的核心组件入口:
6
+ - **`WorkflowIDE`**(主入口 `@yiyi_zhang/reactflow-ui`)— 面向专业编排与研发人员的完整可视化 IDE
7
+ - **`AiWorkflowIDE`**(子路径 `@yiyi_zhang/reactflow-ui/ai`)— 对话优先、AI 驱动,支持多轮 Agentic 编排、子工作流库复用与混合交互
8
+
9
+ ---
10
+
11
+ ## 🌟 v1.0.0 四大核心支柱架构 (Next-Gen Architecture)
12
+
13
+ ### 🧬 支柱一:确定性工作流语言服务 (W-LSP) 与数据血缘图谱
14
+ - **0ms 确定性 JSONPath 补全**:在节点配置面板输入 `${` 时,W-LSP 引擎实时遍历当前节点的所有**合法上游祖先节点**,融合五类数据源(运行态真实 Output、人工 Mock Output、`TaskSchema` 注册表、节点配置自省、类型默认字段)弹出零延迟自动补全,并附带 `⚡ 实时值预览`。
15
+ - **Portal 视口自适应锚定**:补全浮层挂载至 `document.body` 并自动感知视口边界翻转,彻底解决侧边抽屉滚动截断问题。
16
+ - **🔗 数据流血缘图谱 (Data Lineage Graph)**:一键开启画布级蓝色虚线动画边,直观展示跨节点 `${taskRef.output.xxx}` 的参数引用依赖与字段流向。
17
+ - **跨节点安全重构 (Refactor Rename)**:修改任意节点的 `taskReferenceName` 时,自动扫描并重写全图所有下游节点的 `${oldRef.output...}` 表达式,杜绝断链。
18
+
19
+ ### ⚡ 支柱二:浏览器本地沙箱试跑 (0ms Dry-Run) 与时间旅行调试器
20
+ - **无需后端的确定性沙箱引擎 (`localSandboxEngine`)**:支持 `SIMPLE`、`HTTP`、`INLINE`(安全沙箱求值)、`SWITCH`(真实计算 `caseValueParam` / `expression` 路由)、`FORK_JOIN`(并发波次耗时推演)、`DO_WHILE`(多轮循环迭代生成 `__1`、`__2`、`__3`)、`SET_VARIABLE`、`TERMINATE` 等全量控制流。
21
+ - **🧪 人工模拟数据配置台 (`SandboxConfigModal`)**:
22
+ - **Tab 1 — 全局入参 (`workflow.input`)**:自动提取工作流声明入参与全图 `${workflow.input.xxx}` 隐式引用,一键生成可编辑 JSON 模板。
23
+ - **Tab 2 — 节点 Mock、故障注入与分支路由**:按节点自定义 Mock Output JSON、模拟耗时 (`durationMs`)、为 `SWITCH` 强制指定命中分支,或注入 `FAILED` / `TIMED_OUT` 异常以验证高可用容错链路。
24
+ - **📊 并发甘特瀑布流与时间旅行回放 (`ExecutionWaterfallPanel`)**:
25
+ - 底部可展开并发执行甘特图,直观呈现并行分支耗时瓶颈。
26
+ - 拖动**时间旅行滑块 (`Time-Travel Scrubber`)** 或点击 `▶ 0.5x / 1x / 2x` 回放,画布节点与连线按毫秒级时间戳实时还原任意历史时刻的执行状态。
27
+ - **🔄 循环迭代切片器 (`LoopIterationPill`) & 结构化 JSON 树 (`StructuredJsonViewer`)**:
28
+ - `DO_WHILE` 节点内嵌 `[1] [2] [3]` 迭代切换胶囊,点击即可切换对应轮次的子任务快照。
29
+ - 运行态详情面板支持字段搜索高亮、折叠展开与**一键复制 JSONPath (`${taskRef.output.xxx}`)**。
30
+
31
+ ### 🤖 支柱三:画布原生 AI Co-Pilot (`Cmd+K`) 与 Shadow Graph 视觉 Diff
32
+ - **画布内联微调指令栏 (`InlineCanvasCopilot`)**:选中任意节点或直接在画布按下 `Cmd+K` / `Ctrl+K`,原位唤起毛玻璃 AI 指令浮层,支持局部新增下游节点、包裹重试循环、插入条件分支与自动补全参数。
33
+ - **👻 Shadow Graph 架构级 Diff 预览**:AI 生成或修改工作流提案时,画布直接渲染虚拟变更预览图(`+新增` 翠绿高亮、`~修改` 琥珀高亮、`-移除` 绯红虚线),支持顶部胶囊栏一键采纳或按节点部分采纳 (`Partial Accept`)。
34
+ - **零外部运行时依赖的轻量级流程图渲染**:内置基于 Dagre 的原生 SVG 流程图渲染引擎,无需体积庞大的外部 Mermaid 运行时即可在对话流中极速渲染架构图。
35
+
36
+ ### 🎛️ 支柱四:双向实时代码同步、语义级缩放 (Semantic LOD) 与统一工作台
37
+ - **双向实时分屏 JSON 编辑器 (`JsonPreviewPanel`)**:底部 Dock 栏点击 **`{ } JSON`** 即可展开左画布 + 右代码的双栏分屏视图,修改 JSON 经过 300ms 防抖与结构校验后实时驱动画布重绘,画布拖拽/增删节点亦实时同步至代码。
38
+ - **三级语义缩放 (Semantic Zoom LOD)**:
39
+ - **宏观鸟瞰 (`zoom < 0.55`)**:自动收起次要技术文本,渲染高对比度色块胶囊,百节点大图依然丝滑。
40
+ - **标准编排 (`0.55 <= zoom <= 1.15`)**:展示节点标题、类型徽章、引用名与运行耗时。
41
+ - **微距透视 (`zoom > 1.15`)**:节点卡片内直接透视展示核心入参摘要(如 `GET/POST URL`、`SWITCH` 路由表达式等),免去频繁开关抽屉。
42
+ - **统一毛玻璃胶囊工具栏 (`ActionBar`)**:将视图层级分段滑块(**📋 业务 / 🔧 标准 / 💻 全开发**)、**🔗 数据血缘**、**⌘K AI微调**、**↺/↻ 历史栈**、**🩺 诊断**、**⚙️ 配置**、**⚡ 沙箱试运行 | 🧪** 统一收纳于右上角流式 Dock。
56
43
 
57
44
  ---
58
45
 
59
46
  ## 📦 安装
60
47
 
61
48
  ```bash
62
- npm install reactflow-ui reactflow react react-dom
49
+ npm install @yiyi_zhang/reactflow-ui reactflow react react-dom
63
50
  ```
64
51
 
52
+ > **环境要求**:`react >= 18.0.0`(完全兼容 React 18 与 React 19),`reactflow >= 11.11.0`。
53
+
54
+ ---
55
+
65
56
  ## 🚀 快速开始
66
57
 
58
+ ### 1. `WorkflowIDE`(面向专业编排与研发人员)
59
+
67
60
  ```tsx
68
61
  import { useRef } from 'react';
69
- import { WorkflowIDE, WorkflowIDERef } from 'reactflow-ui';
70
- import 'reactflow-ui/style.css';
62
+ import { WorkflowIDE, WorkflowIDERef } from '@yiyi_zhang/reactflow-ui';
63
+ import '@yiyi_zhang/reactflow-ui/style.css';
71
64
 
72
- function App() {
65
+ export default function App() {
73
66
  const ideRef = useRef<WorkflowIDERef>(null);
74
67
 
75
68
  return (
76
- <div style={{ height: '100vh' }}>
77
- <button onClick={() => ideRef.current?.createBlankWorkflow('my_flow')}>新建</button>
69
+ <div style={{ height: '100vh', width: '100%' }}>
78
70
  <WorkflowIDE
79
71
  ref={ideRef}
80
72
  theme="dark"
81
73
  themeColor="blue"
82
- onSave={(workflow) => console.log('保存:', workflow)}
83
- onRequestImport={() => { /* 打开文件选择器 */ }}
74
+ onSave={(workflow) => console.log('保存工作流:', workflow)}
75
+ onWorkflowChange={(workflow) => console.log('变更回调:', workflow)}
84
76
  />
85
77
  </div>
86
78
  );
87
79
  }
88
80
  ```
89
81
 
90
- 不传 `workflowDef` 时画布显示引导面板,支持空白创建、AI 生成或导入 JSON。
82
+ ### 2. `AiWorkflowIDE`(面向业务与架构人员,AI 原生双栏编排)
91
83
 
92
- 详细集成步骤和 API 参考:**[集成指南 →](./INTEGRATION.md)**
84
+ 从独立子路径 `@yiyi_zhang/reactflow-ui/ai` 导入:
93
85
 
94
- ---
86
+ ```tsx
87
+ import { AiWorkflowIDE } from '@yiyi_zhang/reactflow-ui/ai';
88
+ import '@yiyi_zhang/reactflow-ui/style.css';
95
89
 
96
- ## 🛠️ 开发指南
90
+ export default function AiApp() {
91
+ return (
92
+ <div style={{ height: '100vh', width: '100%' }}>
93
+ <AiWorkflowIDE
94
+ aiConfig={{
95
+ // 生产环境推荐使用后端代理模式,避免暴露模型 API Key
96
+ transport: { mode: 'endpoint', endpoint: '/api/ai/workflow-agent' },
97
+ }}
98
+ draftPersist={{ key: 'my-workflow-ide-draft' }}
99
+ onSave={(def) => console.log('保存:', def)}
100
+ />
101
+ </div>
102
+ );
103
+ }
104
+ ```
97
105
 
98
- ### 环境要求
99
- - Node.js >= 18.0.0
100
- - npm 或 yarn
106
+ ### 3. 编程式调用 W-LSP 与本地沙箱引擎 (v1.0.0 新增)
101
107
 
102
- ### 本地开发
108
+ ```tsx
109
+ import {
110
+ executeLocalSandboxDryRun,
111
+ buildDataFlowGraph,
112
+ getCompletionItems,
113
+ } from '@yiyi_zhang/reactflow-ui';
114
+
115
+ // 1. 0ms 浏览器本地确定性沙箱试跑(支持自定义入参与故障注入)
116
+ const { instance } = executeLocalSandboxDryRun(workflowDef, {
117
+ workflowInput: { orderId: 'ORD-2026', vipLevel: 3 },
118
+ taskOverrides: {
119
+ charge_card: { status: 'FAILED', errorMessage: '模拟支付网关 502 超时' },
120
+ },
121
+ });
122
+
123
+ // 2. 构建工作流全局数据血缘图谱
124
+ const lineageGraph = buildDataFlowGraph(workflowDef);
125
+ ```
103
126
 
104
- ```bash
105
- # 克隆仓库
106
- git clone https://github.com/yiyisf/reactflow-ui.git
107
- cd reactflow-ui
127
+ ---
128
+
129
+ ## 🛠️ 本地开发与验证
108
130
 
131
+ ```bash
109
132
  # 安装依赖
110
133
  npm install
111
134
 
112
- # 启动开发服务器(含演示应用)
135
+ # 启动本地开发调试环境(含完整演示工作台)
113
136
  npm run dev
114
- # 访问 http://localhost:5173
115
- ```
116
137
 
117
- ### 构建
138
+ # 运行单元测试(Vitest)
139
+ npm test
118
140
 
119
- ```bash
141
+ # 代码规范检查
142
+ npm run lint
143
+
144
+ # 构建 NPM 发布产物(dist/)
120
145
  npm run build
121
- # 产物生成在 dist/ 目录
122
146
  ```
123
147
 
124
- ### 项目结构
148
+ ---
149
+
150
+ ## 📁 项目结构
125
151
 
126
152
  ```
127
153
  src/
128
- ├── components/ # UI 核心组件(设计器、属性面板、节点…)
129
- │ ├── nodes/ # 各类型节点组件(TaskNode、DecisionNode、LoopNode…)
130
- │ ├── AICopilot/ # AI 助手面板
131
- │ ├── Controls/ # 工具栏、模式切换器
132
- │ ├── WorkflowRunPanel.tsx # P4.2: 执行验证入参面板
133
- │ └── ExecutionSummaryPanel.tsx # P4.3: 执行结果分析面板
134
- ├── store/ # Zustand 状态管理(workflowStore)
135
- ├── parser/ # Conductor JSON ↔ ReactFlow 节点/边转换
136
- ├── layout/ # Dagre 自动布局(含蛇形布局)
137
- ├── types/ # TypeScript 类型定义
138
- ├── styles/ # CSS 变量和执行状态样式
139
- ├── utils/ # 校验器、executionAnalyzer(P4.3 诊断引擎)
140
- └── demo/ # 演示应用(开发调试用)
154
+ ├── index.ts # 主入口:WorkflowIDE + W-LSP + 沙箱引擎导出
155
+ ├── ai.ts # AI 入口(/ai 子路径):AiWorkflowIDE + Agent 工具链导出
156
+ ├── WorkflowIDE.tsx # 专业编排组件外壳
157
+ ├── AiWorkflowIDE.tsx # AI 原生编排组件外壳
158
+ ├── components/
159
+ │ ├── WorkflowDesigner.tsx # 核心画布(集成血缘连线、Shadow Graph、时间旅行)
160
+ │ ├── TaskDetailPanel.tsx # 节点属性抽屉(集成 W-LSP 补全与重构提示)
161
+ │ ├── ExecutionTaskPanel.tsx # 运行态详情抽屉(集成 StructuredJsonViewer)
162
+ │ ├── SandboxConfigModal.tsx # 🧪 沙箱人工模拟数据与故障注入配置台
163
+ │ ├── ExecutionWaterfallPanel.tsx # 📊 并发甘特瀑布流与时间旅行回放面板
164
+ │ ├── JsonPreviewPanel.tsx # { } 双向实时分屏 JSON 编辑器
165
+ │ ├── StructuredJsonViewer.tsx # 树形 JSON 检索与一键复制 JSONPath 组件
166
+ │ ├── nodes/ # 节点渲染层(含 Semantic LOD 三级语义缩放与 Loop 切片器)
167
+ │ ├── Controls/ # 统一毛玻璃胶囊工具栏 ActionBar、ModeSlider、ControlHub
168
+ │ ├── AICopilot/ # W-LSP ParameterSuggester 补全浮层与对话面板
169
+ │ └── AiNative/ # AiCommandCenter、InlineCanvasCopilot (Cmd+K)、MermaidBlock
170
+ ├── services/
171
+ │ ├── wlsp/workflowLsp.ts # W-LSP 工作流语言服务(祖先推导、Schema 推断、血缘、重构)
172
+ │ └── ai/ # 多模型协议适配、Agent 循环、工具注册表、规则引擎
173
+ ├── utils/
174
+ │ ├── localSandboxEngine.ts # 浏览器本地确定性沙箱执行引擎
175
+ │ ├── validator.ts # 静态拓扑与引用校验器
176
+ │ └── executionAnalyzer.ts # 运行态智能故障诊断引擎
177
+ ├── store/ # Zustand 状态管理(workflowStore、aiStore、libraryStore)
178
+ ├── parser/ # Conductor DSL ↔ ReactFlow 节点/边双向解析器
179
+ └── layout/ # Dagre 自动布局与超大流程蛇形布局引擎
141
180
  ```
142
181
 
143
182
  ---
144
183
 
145
- ## 📚 文档资源
184
+ ## 📚 文档导航
146
185
 
147
- - [集成指南 (Integration Guide)](./INTEGRATION.md)
148
- - [最佳实践 (Best Practices)](./docs/best-practices.md)
149
- - [路线图 (Roadmap)](./ROADMAP.md)
150
- - [v0.4.0 发布计划](./docs/v0.4.0-release-plan.md)
186
+ - **[🚀 v1.0.0 产品发布宣传首页 (Product Launch Showcase)](./docs/product-launch-v1.0.0.html)** — 100% 单文件零依赖 HTML,含首屏 Before/After 耗时对比、一行命令极速体验、可拖动双滑块团队 ROI 收益计算器与交互式沙箱演练
187
+ - **[集成指南 (INTEGRATION.md)](./INTEGRATION.md)** — Props 详解、运行态接入、AI 代理配置、W-LSP 与沙箱 API
188
+ - **[版本更新日志 (CHANGELOG.md)](./CHANGELOG.md)** — `v1.0.0` 及历次版本完整变更记录
189
+ - **[发展路线图 (ROADMAP.md)](./ROADMAP.md)** — 演进里程碑与未来规划
190
+ - **[最佳实践 (docs/best-practices.md)](./docs/best-practices.md)** — 常见业务拓扑建模规范
151
191
 
152
192
  ## 📄 许可证
153
193
 
154
194
  MIT
155
-
@@ -0,0 +1,219 @@
1
+ /**
2
+ * AiWorkflowIDE — AI-First workflow designer (component-ready)
3
+ *
4
+ * 设计目标:可被任何前端项目直接引用,仅需传入 aiConfig 即可使用。
5
+ *
6
+ * 布局:左侧 AI 对话面板(可收起) + 右侧画布 + ReviewBar
7
+ * 与 WorkflowIDE 共享底层 workflowStore 和组件基础设施。
8
+ */
9
+ import type { WorkflowDef, WorkflowInstance } from './types/conductor';
10
+ import type { AiConfig } from './services/ai/protocolAdapter';
11
+ import type { AiMetrics } from './store/aiStore';
12
+ import type { WorkflowLibraryItem } from './types/workflowLibrary';
13
+ import type { ExecutionActions, ThemeMode, ThemeColor, LayoutDirection, ViewMode, WorkflowExecutionInput } from './types/workflow';
14
+ import type { CustomTool } from './services/ai/toolRegistry';
15
+ import type { CustomValidationRule } from './services/ai/ruleEngine';
16
+ import type { TaskSchema } from './services/ai/schemaRegistry';
17
+ import type { AiEvent } from './types/aiEvents';
18
+ import type { IdeDraft } from './services/ai/draftPersistence';
19
+ import './styles/tokens.css';
20
+ import './styles/executionStyles.css';
21
+ import './components/AiNative/AiNative.css';
22
+ export interface AiWorkflowIDEProps {
23
+ /** 初始工作流定义(编辑态) */
24
+ workflowDef?: WorkflowDef;
25
+ /** 运行态执行实例数据(完整 Conductor Workflow 实例,或裸的任务实例数组) */
26
+ workflowExecution?: WorkflowExecutionInput;
27
+ /**
28
+ * L1/L2/L3 子工作流库元数据列表(集成方提供)。
29
+ *
30
+ * AI 会优先从库中识别可复用的子工作流,而非从零生成。
31
+ * 遵循分层调用规范:L3→L2/L1,L2→L1,L1同层,禁止反向跨层调用。
32
+ *
33
+ * ```tsx
34
+ * <AiWorkflowIDE
35
+ * workflowLibrary={[
36
+ * { workflowName: 'create_vm', workflowLevel: 'L1', version: '1.0',
37
+ * description: '创建虚机实例', tags: ['云服务器', '计算'] },
38
+ * { workflowName: 'cloud_server_apply', workflowLevel: 'L2', version: '2.1',
39
+ * description: '云服务器申请完整流程', tags: ['申请'] },
40
+ * ]}
41
+ * />
42
+ * ```
43
+ */
44
+ workflowLibrary?: WorkflowLibraryItem[];
45
+ /**
46
+ * AI 模型配置(集成方提供)。
47
+ *
48
+ * 最简用法:仅传 apiKey,其余使用默认值(OpenAI gpt-4o)。
49
+ * ```tsx
50
+ * <AiWorkflowIDE aiConfig={{ apiKey: 'sk-xxx' }} />
51
+ * ```
52
+ *
53
+ * 使用 Anthropic:
54
+ * ```tsx
55
+ * <AiWorkflowIDE aiConfig={{ provider: 'anthropic', apiKey: 'sk-ant-xxx', model: 'claude-sonnet-4-6' }} />
56
+ * ```
57
+ *
58
+ * 当此 prop 提供有效 apiKey 时,组件内建的 AI 配置按钮将自动隐藏,
59
+ * 由集成方完全掌控 AI 配置。
60
+ */
61
+ aiConfig?: Partial<AiConfig>;
62
+ /**
63
+ * 完全替换内置基础提示词(高级定制)。
64
+ * 工作流上下文仍会自动注入,无需手动处理。
65
+ *
66
+ * 可从 'reactflow-ui' 导入 BASE_SYSTEM_PROMPT 在此基础上修改:
67
+ * ```tsx
68
+ * import { BASE_SYSTEM_PROMPT } from 'reactflow-ui';
69
+ * <AiWorkflowIDE systemPrompt={BASE_SYSTEM_PROMPT + '\n\n额外规则...'} />
70
+ * ```
71
+ */
72
+ systemPrompt?: string;
73
+ /**
74
+ * 追加到内置提示词之后的补充内容(轻量定制)。
75
+ * 适合注入公司规范、业务背景等上下文,无需理解内置提示词结构。
76
+ */
77
+ systemPromptExtra?: string;
78
+ theme?: ThemeMode;
79
+ themeColor?: ThemeColor;
80
+ layoutDirection?: LayoutDirection;
81
+ /** 初始视图模式。默认 'business'(节点类型标签使用中文业务词汇)。 */
82
+ viewMode?: ViewMode;
83
+ /** 组件高度,默认 '100vh' */
84
+ height?: string | number;
85
+ /**
86
+ * Custom tools the AI can call alongside built-in tools (Tool Registry v1).
87
+ *
88
+ * Each tool must provide an OpenAI-compatible function definition and an
89
+ * async `execute` function. The return value is sent back to the model as
90
+ * the tool result.
91
+ *
92
+ * ```tsx
93
+ * <AiWorkflowIDE
94
+ * customTools={[{
95
+ * definition: { type: 'function', function: { name: 'query_cmdb',
96
+ * description: '查询 CMDB 资源', parameters: { ... } } },
97
+ * execute: async (args) => JSON.stringify(await fetchCmdb(args)),
98
+ * }]}
99
+ * />
100
+ * ```
101
+ */
102
+ customTools?: CustomTool[];
103
+ /**
104
+ * Custom validation rules applied after built-in Conductor validation (Rules Engine v1).
105
+ *
106
+ * Rule `description` strings are injected into the AI system prompt so
107
+ * generated workflows satisfy these constraints from the start.
108
+ *
109
+ * ```tsx
110
+ * <AiWorkflowIDE
111
+ * validationRules={[{
112
+ * id: 'require-owner-email',
113
+ * level: 'error',
114
+ * description: '所有工作流必须设置 ownerEmail(格式:xxx@company.com)',
115
+ * validate: (def) =>
116
+ * def.ownerEmail ? [] : [{ type: 'GLOBAL', ref: '', message: 'ownerEmail 不能为空' }],
117
+ * }]}
118
+ * />
119
+ * ```
120
+ */
121
+ validationRules?: CustomValidationRule[];
122
+ /**
123
+ * Task input/output schemas (Schema Registry v1).
124
+ *
125
+ * Registered schemas are injected into the AI system prompt so the model
126
+ * generates correct inputParameters references for known task types.
127
+ *
128
+ * ```tsx
129
+ * <AiWorkflowIDE
130
+ * taskSchemas={[{
131
+ * taskName: 'send_notification',
132
+ * taskType: 'SIMPLE',
133
+ * description: '发送通知',
134
+ * inputSchema: { userId: 'string', message: 'string' },
135
+ * outputSchema: { messageId: 'string', status: 'sent|failed' },
136
+ * }]}
137
+ * />
138
+ * ```
139
+ */
140
+ taskSchemas?: TaskSchema[];
141
+ onSave?: (def: WorkflowDef) => void;
142
+ onWorkflowChange?: (def: WorkflowDef) => void;
143
+ onRequestImport?: () => void;
144
+ executionActions?: ExecutionActions;
145
+ /**
146
+ * 触发执行当前工作流。若提供此回调,AI 对话中将出现"执行工作流"快捷操作。
147
+ *
148
+ * 签名与 `WorkflowIDE` 的 `onTriggerExecution` 完全一致——同一个后端适配器可同时用于两个组件。
149
+ */
150
+ onTriggerExecution?: (workflowName: string, version: number, input: Record<string, any>) => Promise<{
151
+ workflowId: string;
152
+ }>;
153
+ /**
154
+ * 轮询执行状态,由 workflowId 查询。需与 onTriggerExecution 一起提供。
155
+ * 返回 `null` 表示暂未获取到结果(继续轮询),返回 `WorkflowInstance` 则视为当前/终态数据。
156
+ *
157
+ * 签名与 `WorkflowIDE` 的 `onPollExecution` 完全一致。
158
+ */
159
+ onPollExecution?: (workflowId: string) => Promise<WorkflowInstance | null>;
160
+ /** AI 操作指标回调(accept/reject 次数等) */
161
+ onAiMetrics?: (metrics: AiMetrics) => void;
162
+ /**
163
+ * AI 生命周期事件回调(审计日志 v1)。
164
+ *
165
+ * 接收提案创建/接受/拒绝、计划创建/执行、修复提案/执行、工具调用、撤销等所有 AI 操作事件。
166
+ *
167
+ * ```tsx
168
+ * <AiWorkflowIDE
169
+ * onAiEvent={(e) => console.log(e.type, e.timestamp, e.diff)}
170
+ * />
171
+ * ```
172
+ */
173
+ onAiEvent?: (event: AiEvent) => void;
174
+ /**
175
+ * AI 操作权限配置。
176
+ *
177
+ * - `canEdit`(默认 true):false 时 AI 只能读取,不能修改工作流
178
+ * - `canRepair`(默认 true):false 时运行态修复功能不可用
179
+ * - `restrictionMessage`:权限受限时显示的提示文字
180
+ *
181
+ * ```tsx
182
+ * <AiWorkflowIDE aiPermissions={{ canEdit: false, restrictionMessage: '只读演示模式' }} />
183
+ * ```
184
+ */
185
+ aiPermissions?: {
186
+ canEdit?: boolean;
187
+ canRepair?: boolean;
188
+ restrictionMessage?: string;
189
+ };
190
+ /**
191
+ * 开启 localStorage 草稿自动保存(workflowDef + 对话 + 待确认提案)。
192
+ * 默认 `false`(不写宿主页面的 localStorage)。挂载时若检测到草稿会自动恢复现场,
193
+ * 并展示可放弃恢复的横幅。**仅在未传入 `workflowDef` 时生效**——显式加载指定工作流
194
+ * 的场景视为明确意图,不应被本地草稿覆盖。
195
+ *
196
+ * ```tsx
197
+ * <AiWorkflowIDE draftPersist={{ key: 'my-app-ai-workflow-draft' }} />
198
+ * ```
199
+ */
200
+ draftPersist?: {
201
+ key: string;
202
+ } | false;
203
+ /**
204
+ * 草稿变化时的回调(与 `draftPersist` 独立,二者可同时使用)。
205
+ * 集成方可用它把草稿存到自己的后端,而非(或除了)localStorage。
206
+ */
207
+ onDraftChange?: (draft: IdeDraft) => void;
208
+ }
209
+ export interface AiWorkflowIDERef {
210
+ /** 获取当前工作流定义 */
211
+ getWorkflowDef: () => WorkflowDef | null;
212
+ /** 程序化设置工作流 */
213
+ setWorkflow: (def: WorkflowDef) => void;
214
+ /** 新建空白工作流 */
215
+ createBlankWorkflow: (name?: string) => void;
216
+ /** 获取 AI 使用指标 */
217
+ getAiMetrics: () => AiMetrics;
218
+ }
219
+ export declare const AiWorkflowIDE: import("react").ForwardRefExoticComponent<AiWorkflowIDEProps & import("react").RefAttributes<AiWorkflowIDERef>>;
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { ThemeMode, ThemeColor, LayoutDirection, ValidationResults, ExecutionActions, ViewMode } from './types/workflow';
1
+ import { ThemeMode, ThemeColor, LayoutDirection, ValidationResults, ExecutionActions, ViewMode, WorkflowExecutionInput } from './types/workflow';
3
2
  import { WorkflowDef, WorkflowInstance } from './types/conductor';
4
3
  import { AIServiceConfig } from './services/aiService';
5
4
  import './styles/tokens.css';
@@ -60,7 +59,8 @@ export interface WorkflowIDEProps {
60
59
  * 运行态数据 (WorkflowInstance)。
61
60
  * 当传入此属性时,IDE 会自动切换到 **Run Mode**,展示任务执行状态、连线路径高亮等。
62
61
  */
63
- workflowExecution?: any;
62
+ /** 运行态执行实例数据(完整 Conductor Workflow 实例,或裸的任务实例数组) */
63
+ workflowExecution?: WorkflowExecutionInput;
64
64
  /**
65
65
  * 点击保存按钮时的回调函数。
66
66
  * @param def 最新的工作流定义对象
@@ -131,4 +131,4 @@ export interface WorkflowIDEProps {
131
131
  * />
132
132
  * ```
133
133
  */
134
- export declare const WorkflowIDE: React.ForwardRefExoticComponent<WorkflowIDEProps & React.RefAttributes<WorkflowIDERef>>;
134
+ export declare const WorkflowIDE: import("react").ForwardRefExoticComponent<WorkflowIDEProps & import("react").RefAttributes<WorkflowIDERef>>;
package/dist/ai.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * AI 入口 — AiWorkflowIDE 及其配套类型/工具的公开导出。
3
+ *
4
+ * 集成方引入方式:
5
+ * ```tsx
6
+ * import { AiWorkflowIDE } from '@yiyi_zhang/reactflow-ui/ai';
7
+ * import '@yiyi_zhang/reactflow-ui/style.css';
8
+ * ```
9
+ *
10
+ * 拆分为独立入口的原因:只使用 WorkflowIDE(主入口 `.`)的集成方不需要
11
+ * 承担 AI 协议适配、工具执行、Mermaid 渲染等代码体积。
12
+ */
13
+ export { AiWorkflowIDE } from './AiWorkflowIDE';
14
+ export type { AiWorkflowIDEProps, AiWorkflowIDERef } from './AiWorkflowIDE';
15
+ export type { AiConfig, Message, ToolDef, StreamEvent, TestConnectionResult } from './services/ai/protocolAdapter';
16
+ export { PROVIDER_DEFAULTS, testConnection } from './services/ai/protocolAdapter';
17
+ export { BASE_SYSTEM_PROMPT, buildSystemPrompt } from './services/ai/systemPrompt';
18
+ export type { AiTransport, AgentRequest } from './services/ai/transport';
19
+ export type { IdeDraft } from './services/ai/draftPersistence';
20
+ export type { CustomTool } from './services/ai/toolRegistry';
21
+ export type { CustomValidationRule } from './services/ai/ruleEngine';
22
+ export type { TaskSchema } from './services/ai/schemaRegistry';
23
+ export type { WorkflowLevel, WorkflowLibraryItem, WorkflowLibraryDetail } from './types/workflowLibrary';
24
+ export type { AiEvent, AiEventType } from './types/aiEvents';
25
+ export type { DiffSummary, PartialAcceptSelection, PatchOp } from './services/ai/toolExecutor';
26
+ export { applyPartialProposal, describeDiff, computeDiff } from './services/ai/toolExecutor';
27
+ export type { AiMetrics } from './store/aiStore';
28
+ export type { WorkflowDef, TaskDef, WorkflowInputParam, WorkflowInstance } from './types/conductor';
29
+ export { parseWorkflowInputParams } from './types/conductor';
30
+ export type { ExecutionActions, ThemeMode, ThemeColor, LayoutDirection, ViewMode, TaskExecutionData, WorkflowExecutionInput } from './types/workflow';
31
+ export { getCompletionItems, buildDataFlowGraph, refactorTaskReferenceName, getUpstreamAncestors, inferTaskOutputSchema, } from './services/wlsp/workflowLsp';
32
+ export type { WlspCompletionItem, DataFlowGraph, DataFlowEdge, InferredField, UpstreamTaskInfo, } from './services/wlsp/workflowLsp';
33
+ export { executeLocalSandboxDryRun, buildDefaultWorkflowMockInput, generateDefaultTaskOutputPreview, } from './utils/localSandboxEngine';
34
+ export type { SandboxDryRunOptions, TaskMockOverride, } from './utils/localSandboxEngine';
@@ -1,16 +1,25 @@
1
1
  import React from 'react';
2
2
  import './ParameterSuggester.css';
3
+ import { WlspCompletionItem, ValueType } from '../../services/wlsp/workflowLsp';
3
4
  export interface Suggestion {
4
5
  label: string;
5
6
  value: string;
6
7
  description: string;
8
+ category?: 'upstream' | 'workflow_input' | 'variable' | 'system' | 'ai';
9
+ valueType?: ValueType;
10
+ sourceLabel?: string;
11
+ sampleValue?: string;
12
+ isConditional?: boolean;
7
13
  }
8
14
  interface ParameterSuggesterProps {
9
15
  isOpen: boolean;
10
16
  onClose: () => void;
11
17
  onSelect: (value: string) => void;
12
18
  suggestions: Suggestion[];
19
+ wlspItems?: WlspCompletionItem[];
13
20
  anchorRect?: DOMRect;
21
+ onRequestAiHint?: () => void;
22
+ aiLoading?: boolean;
14
23
  }
15
24
  declare const ParameterSuggester: React.FC<ParameterSuggesterProps>;
16
25
  export default ParameterSuggester;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * AgentTimeline — visible work-in-progress log for the current agent turn (M2.2 + PI Durable 4-Phase Stepper)
3
+ *
4
+ * Replaces the single toolStatus line with:
5
+ * 1. A 4-Phase Synthesis Progress Bar ("① 蓝图定义 → ② 拓扑编排 → ③ 参数与数据流 → ④ 整体校验") when progressive synthesis is active
6
+ * 2. A growing list of completed steps ("✓ 已搜索工作流库", "✓ 阶段 2/4:已编排 5 个任务拓扑骨架")
7
+ * 3. The current in-flight step as a spinner row
8
+ */
9
+ import React from 'react';
10
+ import type { TimelineEntry } from '../../store/aiStore';
11
+ import type { SynthesisPhase } from '../../services/ai/workflowSynthesizer';
12
+ import type { WorkflowDef } from '../../types/conductor';
13
+ interface AgentTimelineProps {
14
+ entries: TimelineEntry[];
15
+ /** Current in-flight step label, or '' when nothing is actively running */
16
+ activeLabel: string;
17
+ /** Optional current 4-phase synthesis stage */
18
+ synthesisPhase?: SynthesisPhase;
19
+ /** Optional in-progress working draft */
20
+ workingDraft?: WorkflowDef | null;
21
+ }
22
+ declare const AgentTimeline: React.FC<AgentTimelineProps>;
23
+ export default AgentTimeline;