@yiyi_zhang/reactflow-ui 0.3.0 → 0.5.0-beta.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 (110) hide show
  1. package/README.md +61 -22
  2. package/dist/AiWorkflowIDE.d.ts +217 -0
  3. package/dist/WorkflowIDE.d.ts +22 -3
  4. package/dist/ai-BJwQZcGK.js +15168 -0
  5. package/dist/ai.d.ts +30 -0
  6. package/dist/arc-BUGZGgtu.js +83 -0
  7. package/dist/architectureDiagram-3BPJPVTR-ZcgvTwSO.js +4692 -0
  8. package/dist/blockDiagram-GPEHLZMM-DtVtOBbH.js +2418 -0
  9. package/dist/c4Diagram-AAUBKEIU-tBS5Rcvm.js +1577 -0
  10. package/dist/channel-CURI9jmI.js +5 -0
  11. package/dist/chunk-2J33WTMH-D7gashNz.js +19 -0
  12. package/dist/chunk-4BX2VUAB-DE3VjyiZ.js +8 -0
  13. package/dist/chunk-55IACEB6-GYZ_m2MY.js +8 -0
  14. package/dist/chunk-727SXJPM-D4WVyvOg.js +1528 -0
  15. package/dist/chunk-AQP2D5EJ-Os2Uwqya.js +1387 -0
  16. package/dist/chunk-FMBD7UC4-B3CSVzS4.js +19 -0
  17. package/dist/chunk-ND2GUHAM-CNj_s1aK.js +68 -0
  18. package/dist/chunk-QZHKN3VN-DoV8iUKo.js +15 -0
  19. package/dist/classDiagram-4FO5ZUOK-Dr9C18x4.js +16 -0
  20. package/dist/classDiagram-v2-Q7XG4LA2-Dr9C18x4.js +16 -0
  21. package/dist/components/AiNative/AgentTimeline.d.ts +18 -0
  22. package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
  23. package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
  24. package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
  25. package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
  26. package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
  27. package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
  28. package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
  29. package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
  30. package/dist/components/AiNative/PlanCard.d.ts +15 -0
  31. package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
  32. package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
  33. package/dist/components/AiNative/RepairCard.d.ts +17 -0
  34. package/dist/components/AiNative/ReviewBar.d.ts +21 -0
  35. package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
  36. package/dist/components/Controls/ModeSlider.d.ts +2 -0
  37. package/dist/components/ExecutionSummaryPanel.d.ts +4 -0
  38. package/dist/components/WorkflowRunPanel.d.ts +12 -0
  39. package/dist/components/nodes/NodeWrapper.d.ts +2 -1
  40. package/dist/cose-bilkent-S5V4N54A-CgQlI-io.js +2609 -0
  41. package/dist/cytoscape.esm-kVAWcYoG.js +18755 -0
  42. package/dist/dagre-BM42HDAG-CFMIuOmS.js +445 -0
  43. package/dist/defaultLocale-BgPVtth8.js +171 -0
  44. package/dist/diagram-2AECGRRQ-C5jZp2YX.js +217 -0
  45. package/dist/diagram-5GNKFQAL-DRUVcHpp.js +123 -0
  46. package/dist/diagram-KO2AKTUF-BOl4aaej.js +461 -0
  47. package/dist/diagram-LMA3HP47-ZeckPR2Q.js +142 -0
  48. package/dist/diagram-OG6HWLK6-qUWeLfa-.js +528 -0
  49. package/dist/erDiagram-TEJ5UH35-Bw_CWS13.js +899 -0
  50. package/dist/flowDiagram-I6XJVG4X-D3xEvQA-.js +1628 -0
  51. package/dist/ganttDiagram-6RSMTGT7-D8GvenY3.js +2707 -0
  52. package/dist/gitGraphDiagram-PVQCEYII-BWrN_HOm.js +815 -0
  53. package/dist/graph-BRoPeNF3.js +1545 -0
  54. package/dist/hooks/useNodeExecution.d.ts +1 -1
  55. package/dist/hooks/useNodeLayout.d.ts +1 -1
  56. package/dist/index.d.ts +3 -2
  57. package/dist/infoDiagram-5YYISTIA-Da8FG5tB.js +24 -0
  58. package/dist/init-DjUOC4st.js +16 -0
  59. package/dist/ishikawaDiagram-YF4QCWOH-Bg2_mKEc.js +621 -0
  60. package/dist/journeyDiagram-JHISSGLW-sFIxGfua.js +834 -0
  61. package/dist/kanban-definition-UN3LZRKU-CGmopzHd.js +724 -0
  62. package/dist/katex-DoRnZ_sp.js +11682 -0
  63. package/dist/layout-D9EpM4Fg.js +1728 -0
  64. package/dist/linear-BA49eco4.js +259 -0
  65. package/dist/mermaid.core-XSpZEAKP.js +16137 -0
  66. package/dist/mindmap-definition-RKZ34NQL-Bqf76QGB.js +827 -0
  67. package/dist/ordinal-B6-f3MAq.js +61 -0
  68. package/dist/pieDiagram-4H26LBE5-hHiP8HzL.js +163 -0
  69. package/dist/quadrantDiagram-W4KKPZXB-DSccwH8B.js +1024 -0
  70. package/dist/reactflow-ui-ai.es.js +12 -0
  71. package/dist/reactflow-ui.css +1 -1
  72. package/dist/reactflow-ui.es.js +8198 -7039
  73. package/dist/reactflow-ui.umd.js +52 -17
  74. package/dist/requirementDiagram-4Y6WPE33-DIpyoYZ_.js +882 -0
  75. package/dist/sankeyDiagram-5OEKKPKP-DsaPqq8D.js +847 -0
  76. package/dist/sequenceDiagram-3UESZ5HK-BNg7orie.js +2891 -0
  77. package/dist/services/ai/agentRunner.d.ts +51 -0
  78. package/dist/services/ai/contextEngine.d.ts +83 -0
  79. package/dist/services/ai/draftPersistence.d.ts +22 -0
  80. package/dist/services/ai/errorMessages.d.ts +16 -0
  81. package/dist/services/ai/intentClassifier.d.ts +17 -0
  82. package/dist/services/ai/protocolAdapter.d.ts +114 -0
  83. package/dist/services/ai/ruleEngine.d.ts +57 -0
  84. package/dist/services/ai/schemaRegistry.d.ts +51 -0
  85. package/dist/services/ai/systemPrompt.d.ts +30 -0
  86. package/dist/services/ai/toolDefs.d.ts +9 -0
  87. package/dist/services/ai/toolExecutor.d.ts +83 -0
  88. package/dist/services/ai/toolRegistry.d.ts +38 -0
  89. package/dist/services/ai/transport.d.ts +58 -0
  90. package/dist/services/aiService.d.ts +27 -5
  91. package/dist/stateDiagram-AJRCARHV-Rv1mSmnJ.js +263 -0
  92. package/dist/stateDiagram-v2-BHNVJYJU-BME16k02.js +16 -0
  93. package/dist/store/aiStore.d.ts +199 -0
  94. package/dist/store/ideStoresContext.d.ts +39 -0
  95. package/dist/store/libraryStore.d.ts +25 -0
  96. package/dist/timeline-definition-PNZ67QCA-CmmzdVk-.js +1055 -0
  97. package/dist/types/aiEvents.d.ts +38 -0
  98. package/dist/types/conductor.d.ts +23 -2
  99. package/dist/types/workflow.d.ts +36 -0
  100. package/dist/types/workflowLibrary.d.ts +27 -0
  101. package/dist/utils/executionAnalyzer.d.ts +32 -0
  102. package/dist/utils/nodeMeta.d.ts +6 -0
  103. package/dist/utils/proposalPreview.d.ts +19 -0
  104. package/dist/utils/taskTypeMeta.d.ts +18 -0
  105. package/dist/utils/workflowToMermaid.d.ts +7 -0
  106. package/dist/vennDiagram-CIIHVFJN-BQt00w9Q.js +1557 -0
  107. package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
  108. package/dist/wardleyDiagram-YWT4CUSO-LZpiODGN.js +675 -0
  109. package/dist/xychartDiagram-2RQKCTM6-BpJlv_mc.js +1342 -0
  110. package/package.json +14 -4
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  基于 React 19、ReactFlow 和 Vite 构建的企业级 [Netflix Conductor](https://conductor-oss.org/) 工作流可视化设计器。
4
4
 
5
+ 提供两个可独立集成的核心组件:
6
+ - **`WorkflowIDE`**(主入口)— 面向专业编排人员的完整可视化设计器
7
+ - **`AiWorkflowIDE`**(`/ai` 子路径)— 对话优先、AI 驱动,面向非技术业务用户
8
+
5
9
  ## ✨ 核心特性
6
10
 
7
11
  ### 🎨 可视化建模
@@ -34,19 +38,23 @@
34
38
  - `allowOperations` 全局权限开关,快速控制操作按钮是否可用
35
39
 
36
40
  ### 🤖 AI Copilot(智能辅助)
37
- - **仅在编辑模式可用**,避免干扰只读/运行态场景
38
41
  - 自然语言描述生成完整工作流,支持对话式迭代修改
39
42
  - 差异卡片(Diff Card)预览变更内容,一键应用/撤销
40
- - 参数智能提示:节点属性面板中基于上下文推荐 JSONPath 表达式
43
+ - **✨ AI 参数填充(v0.4.0 新增)**:节点编辑面板一键调用 AI 生成完整 `inputParameters`,基于任务类型、上游任务列表和工作流入参自动推断,diff 预览后一键应用
44
+
45
+ ### 🔬 执行验证闭环(v0.4.0 新增)
46
+ - **执行验证面板**:在 edit 模式下点击"▶ 执行验证"按钮,填写工作流入参(表单/JSON 双模式),一键触发真实 Conductor 执行
47
+ - **自动切换 run 模式**:执行触发后 IDE 自动切换到运行态,通过指数退避轮询实时更新执行状态
48
+ - **结构化入参声明**:`WorkflowSettingsPanel` 支持可视化编辑入参名称、类型、是否必填、描述和示例值
41
49
 
42
- ### 🎯 视觉体验
43
- - 深色/浅色主题 + 品牌主色调(科技蓝/活力橙)
44
- - 节点边框和阴影经过调校,深色模式下更清晰可辨
45
- - 切换工作流时自动执行 Fit View,无需手动缩放定位
46
- - 校验错误徽章(❗⚠️)仅在编辑模式显示,不干扰只读查看
50
+ ### 📊 执行结果分析(v0.4.0 新增)
51
+ - **执行概览面板**:run 模式下点击"📊 分析",展示总任务数/成功率/失败数/总耗时概览卡片
52
+ - **步骤时序表**:按 `startTime` 排序显示所有任务的执行状态、耗时和重试次数,点击行可高亮对应节点
53
+ - **智能故障诊断**:自动识别 10+ 种常见 Conductor 错误模式(JSONPath 失败、HTTP 错误码、超时、认证、脚本异常等),在诊断卡片中给出可操作的修复建议
54
+ - **"去修复"跳转**:点击诊断卡片的"去修复"按钮,一键切换到 edit 模式并选中问题任务
47
55
 
48
56
  ### 🏢 企业级能力
49
- - TypeScript 全量类型定义(WorkflowDef、TaskDef、ExecutionActions…)
57
+ - TypeScript 全量类型定义(WorkflowDef、TaskDef、WorkflowInputParam、ExecutionActions…)
50
58
  - 命令式 API(`ref`)支持程序化创建、保存、导出
51
59
  - 强类型 Ref API:`getWorkflowDef()`、`save()`、`createBlankWorkflow()`
52
60
 
@@ -55,15 +63,17 @@
55
63
  ## 📦 安装
56
64
 
57
65
  ```bash
58
- npm install reactflow-ui reactflow react react-dom
66
+ npm install @yiyi_zhang/reactflow-ui reactflow react react-dom
59
67
  ```
60
68
 
61
69
  ## 🚀 快速开始
62
70
 
71
+ ### WorkflowIDE(专业编排人员)
72
+
63
73
  ```tsx
64
74
  import { useRef } from 'react';
65
- import { WorkflowIDE, WorkflowIDERef } from 'reactflow-ui';
66
- import 'reactflow-ui/style.css';
75
+ import { WorkflowIDE, WorkflowIDERef } from '@yiyi_zhang/reactflow-ui';
76
+ import '@yiyi_zhang/reactflow-ui/style.css';
67
77
 
68
78
  function App() {
69
79
  const ideRef = useRef<WorkflowIDERef>(null);
@@ -85,6 +95,25 @@ function App() {
85
95
 
86
96
  不传 `workflowDef` 时画布显示引导面板,支持空白创建、AI 生成或导入 JSON。
87
97
 
98
+ ### AiWorkflowIDE(业务用户,AI 驱动)
99
+
100
+ 从独立子路径导入,避免主入口承担 AI 协议/工具执行等代码体积:
101
+
102
+ ```tsx
103
+ import { AiWorkflowIDE } from '@yiyi_zhang/reactflow-ui/ai';
104
+ import '@yiyi_zhang/reactflow-ui/style.css';
105
+
106
+ function App() {
107
+ return (
108
+ <div style={{ height: '100vh' }}>
109
+ <AiWorkflowIDE aiConfig={{ apiKey: 'your-key' }} onSave={(def) => console.log('保存:', def)} />
110
+ </div>
111
+ );
112
+ }
113
+ ```
114
+
115
+ > ⚠️ 生产环境请勿将真实模型密钥直接下发到前端,详见 [集成指南](./INTEGRATION.md) 中 AiWorkflowIDE 章节的安全提示。
116
+
88
117
  详细集成步骤和 API 参考:**[集成指南 →](./INTEGRATION.md)**
89
118
 
90
119
  ---
@@ -121,17 +150,25 @@ npm run build
121
150
 
122
151
  ```
123
152
  src/
124
- ├── components/ # UI 核心组件(设计器、属性面板、节点…)
125
- │ ├── nodes/ # 各类型节点组件(TaskNode、DecisionNode、LoopNode…)
126
- │ ├── AICopilot/ # AI 助手面板
127
- │ └── Controls/ # 工具栏、模式切换器
128
- ├── store/ # Zustand 状态管理(workflowStore)
129
- ├── parser/ # Conductor JSON ↔ ReactFlow 节点/边转换
130
- ├── layout/ # Dagre 自动布局(含蛇形布局)
131
- ├── types/ # TypeScript 类型定义
132
- ├── styles/ # CSS 变量和执行状态样式
133
- ├── utils/ # 校验器、工作流生成工具
134
- └── demo/ # 演示应用(开发调试用)
153
+ ├── index.ts # 主入口:WorkflowIDE + 共享类型
154
+ ├── ai.ts # AI 入口(/ai 子路径):AiWorkflowIDE + AI 配套类型
155
+ ├── WorkflowIDE.tsx # 专业编排组件外壳
156
+ ├── AiWorkflowIDE.tsx # AI 驱动组件外壳
157
+ ├── components/ # UI 核心组件(设计器、属性面板、节点…)
158
+ │ ├── nodes/ # 各类型节点组件(TaskNode、DecisionNode、LoopNode…)
159
+ │ ├── AICopilot/ # WorkflowIDE 内置 AI 助手面板
160
+ │ ├── AiNative/ # AiWorkflowIDE 对话/画布/审查等组件
161
+ │ ├── Controls/ # 工具栏、模式切换器
162
+ │ ├── WorkflowRunPanel.tsx # P4.2: 执行验证入参面板
163
+ │ └── ExecutionSummaryPanel.tsx # P4.3: 执行结果分析面板
164
+ ├── services/ai/ # AI 协议适配、工具执行、system prompt 构建
165
+ ├── store/ # Zustand 状态管理(workflowStore、aiStore、libraryStore)
166
+ ├── parser/ # Conductor JSON ↔ ReactFlow 节点/边转换
167
+ ├── layout/ # Dagre 自动布局(含蛇形布局)
168
+ ├── types/ # TypeScript 类型定义
169
+ ├── styles/ # CSS 变量和执行状态样式
170
+ ├── utils/ # 校验器、executionAnalyzer(P4.3 诊断引擎)
171
+ └── demo/ # 演示应用(开发调试用)
135
172
  ```
136
173
 
137
174
  ---
@@ -141,7 +178,9 @@ src/
141
178
  - [集成指南 (Integration Guide)](./INTEGRATION.md)
142
179
  - [最佳实践 (Best Practices)](./docs/best-practices.md)
143
180
  - [路线图 (Roadmap)](./ROADMAP.md)
181
+ - [v0.4.0 发布计划](./docs/v0.4.0-release-plan.md)
144
182
 
145
183
  ## 📄 许可证
146
184
 
147
185
  MIT
186
+
@@ -0,0 +1,217 @@
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 './components/AiNative/AiNative.css';
20
+ export interface AiWorkflowIDEProps {
21
+ /** 初始工作流定义(编辑态) */
22
+ workflowDef?: WorkflowDef;
23
+ /** 运行态执行实例数据(完整 Conductor Workflow 实例,或裸的任务实例数组) */
24
+ workflowExecution?: WorkflowExecutionInput;
25
+ /**
26
+ * L1/L2/L3 子工作流库元数据列表(集成方提供)。
27
+ *
28
+ * AI 会优先从库中识别可复用的子工作流,而非从零生成。
29
+ * 遵循分层调用规范:L3→L2/L1,L2→L1,L1同层,禁止反向跨层调用。
30
+ *
31
+ * ```tsx
32
+ * <AiWorkflowIDE
33
+ * workflowLibrary={[
34
+ * { workflowName: 'create_vm', workflowLevel: 'L1', version: '1.0',
35
+ * description: '创建虚机实例', tags: ['云服务器', '计算'] },
36
+ * { workflowName: 'cloud_server_apply', workflowLevel: 'L2', version: '2.1',
37
+ * description: '云服务器申请完整流程', tags: ['申请'] },
38
+ * ]}
39
+ * />
40
+ * ```
41
+ */
42
+ workflowLibrary?: WorkflowLibraryItem[];
43
+ /**
44
+ * AI 模型配置(集成方提供)。
45
+ *
46
+ * 最简用法:仅传 apiKey,其余使用默认值(OpenAI gpt-4o)。
47
+ * ```tsx
48
+ * <AiWorkflowIDE aiConfig={{ apiKey: 'sk-xxx' }} />
49
+ * ```
50
+ *
51
+ * 使用 Anthropic:
52
+ * ```tsx
53
+ * <AiWorkflowIDE aiConfig={{ provider: 'anthropic', apiKey: 'sk-ant-xxx', model: 'claude-sonnet-4-6' }} />
54
+ * ```
55
+ *
56
+ * 当此 prop 提供有效 apiKey 时,组件内建的 AI 配置按钮将自动隐藏,
57
+ * 由集成方完全掌控 AI 配置。
58
+ */
59
+ aiConfig?: Partial<AiConfig>;
60
+ /**
61
+ * 完全替换内置基础提示词(高级定制)。
62
+ * 工作流上下文仍会自动注入,无需手动处理。
63
+ *
64
+ * 可从 'reactflow-ui' 导入 BASE_SYSTEM_PROMPT 在此基础上修改:
65
+ * ```tsx
66
+ * import { BASE_SYSTEM_PROMPT } from 'reactflow-ui';
67
+ * <AiWorkflowIDE systemPrompt={BASE_SYSTEM_PROMPT + '\n\n额外规则...'} />
68
+ * ```
69
+ */
70
+ systemPrompt?: string;
71
+ /**
72
+ * 追加到内置提示词之后的补充内容(轻量定制)。
73
+ * 适合注入公司规范、业务背景等上下文,无需理解内置提示词结构。
74
+ */
75
+ systemPromptExtra?: string;
76
+ theme?: ThemeMode;
77
+ themeColor?: ThemeColor;
78
+ layoutDirection?: LayoutDirection;
79
+ /** 初始视图模式。默认 'business'(节点类型标签使用中文业务词汇)。 */
80
+ viewMode?: ViewMode;
81
+ /** 组件高度,默认 '100vh' */
82
+ height?: string | number;
83
+ /**
84
+ * Custom tools the AI can call alongside built-in tools (Tool Registry v1).
85
+ *
86
+ * Each tool must provide an OpenAI-compatible function definition and an
87
+ * async `execute` function. The return value is sent back to the model as
88
+ * the tool result.
89
+ *
90
+ * ```tsx
91
+ * <AiWorkflowIDE
92
+ * customTools={[{
93
+ * definition: { type: 'function', function: { name: 'query_cmdb',
94
+ * description: '查询 CMDB 资源', parameters: { ... } } },
95
+ * execute: async (args) => JSON.stringify(await fetchCmdb(args)),
96
+ * }]}
97
+ * />
98
+ * ```
99
+ */
100
+ customTools?: CustomTool[];
101
+ /**
102
+ * Custom validation rules applied after built-in Conductor validation (Rules Engine v1).
103
+ *
104
+ * Rule `description` strings are injected into the AI system prompt so
105
+ * generated workflows satisfy these constraints from the start.
106
+ *
107
+ * ```tsx
108
+ * <AiWorkflowIDE
109
+ * validationRules={[{
110
+ * id: 'require-owner-email',
111
+ * level: 'error',
112
+ * description: '所有工作流必须设置 ownerEmail(格式:xxx@company.com)',
113
+ * validate: (def) =>
114
+ * def.ownerEmail ? [] : [{ type: 'GLOBAL', ref: '', message: 'ownerEmail 不能为空' }],
115
+ * }]}
116
+ * />
117
+ * ```
118
+ */
119
+ validationRules?: CustomValidationRule[];
120
+ /**
121
+ * Task input/output schemas (Schema Registry v1).
122
+ *
123
+ * Registered schemas are injected into the AI system prompt so the model
124
+ * generates correct inputParameters references for known task types.
125
+ *
126
+ * ```tsx
127
+ * <AiWorkflowIDE
128
+ * taskSchemas={[{
129
+ * taskName: 'send_notification',
130
+ * taskType: 'SIMPLE',
131
+ * description: '发送通知',
132
+ * inputSchema: { userId: 'string', message: 'string' },
133
+ * outputSchema: { messageId: 'string', status: 'sent|failed' },
134
+ * }]}
135
+ * />
136
+ * ```
137
+ */
138
+ taskSchemas?: TaskSchema[];
139
+ onSave?: (def: WorkflowDef) => void;
140
+ onWorkflowChange?: (def: WorkflowDef) => void;
141
+ onRequestImport?: () => void;
142
+ executionActions?: ExecutionActions;
143
+ /**
144
+ * 触发执行当前工作流。若提供此回调,AI 对话中将出现"执行工作流"快捷操作。
145
+ *
146
+ * 签名与 `WorkflowIDE` 的 `onTriggerExecution` 完全一致——同一个后端适配器可同时用于两个组件。
147
+ */
148
+ onTriggerExecution?: (workflowName: string, version: number, input: Record<string, any>) => Promise<{
149
+ workflowId: string;
150
+ }>;
151
+ /**
152
+ * 轮询执行状态,由 workflowId 查询。需与 onTriggerExecution 一起提供。
153
+ * 返回 `null` 表示暂未获取到结果(继续轮询),返回 `WorkflowInstance` 则视为当前/终态数据。
154
+ *
155
+ * 签名与 `WorkflowIDE` 的 `onPollExecution` 完全一致。
156
+ */
157
+ onPollExecution?: (workflowId: string) => Promise<WorkflowInstance | null>;
158
+ /** AI 操作指标回调(accept/reject 次数等) */
159
+ onAiMetrics?: (metrics: AiMetrics) => void;
160
+ /**
161
+ * AI 生命周期事件回调(审计日志 v1)。
162
+ *
163
+ * 接收提案创建/接受/拒绝、计划创建/执行、修复提案/执行、工具调用、撤销等所有 AI 操作事件。
164
+ *
165
+ * ```tsx
166
+ * <AiWorkflowIDE
167
+ * onAiEvent={(e) => console.log(e.type, e.timestamp, e.diff)}
168
+ * />
169
+ * ```
170
+ */
171
+ onAiEvent?: (event: AiEvent) => void;
172
+ /**
173
+ * AI 操作权限配置。
174
+ *
175
+ * - `canEdit`(默认 true):false 时 AI 只能读取,不能修改工作流
176
+ * - `canRepair`(默认 true):false 时运行态修复功能不可用
177
+ * - `restrictionMessage`:权限受限时显示的提示文字
178
+ *
179
+ * ```tsx
180
+ * <AiWorkflowIDE aiPermissions={{ canEdit: false, restrictionMessage: '只读演示模式' }} />
181
+ * ```
182
+ */
183
+ aiPermissions?: {
184
+ canEdit?: boolean;
185
+ canRepair?: boolean;
186
+ restrictionMessage?: string;
187
+ };
188
+ /**
189
+ * 开启 localStorage 草稿自动保存(workflowDef + 对话 + 待确认提案)。
190
+ * 默认 `false`(不写宿主页面的 localStorage)。挂载时若检测到草稿会自动恢复现场,
191
+ * 并展示可放弃恢复的横幅。**仅在未传入 `workflowDef` 时生效**——显式加载指定工作流
192
+ * 的场景视为明确意图,不应被本地草稿覆盖。
193
+ *
194
+ * ```tsx
195
+ * <AiWorkflowIDE draftPersist={{ key: 'my-app-ai-workflow-draft' }} />
196
+ * ```
197
+ */
198
+ draftPersist?: {
199
+ key: string;
200
+ } | false;
201
+ /**
202
+ * 草稿变化时的回调(与 `draftPersist` 独立,二者可同时使用)。
203
+ * 集成方可用它把草稿存到自己的后端,而非(或除了)localStorage。
204
+ */
205
+ onDraftChange?: (draft: IdeDraft) => void;
206
+ }
207
+ export interface AiWorkflowIDERef {
208
+ /** 获取当前工作流定义 */
209
+ getWorkflowDef: () => WorkflowDef | null;
210
+ /** 程序化设置工作流 */
211
+ setWorkflow: (def: WorkflowDef) => void;
212
+ /** 新建空白工作流 */
213
+ createBlankWorkflow: (name?: string) => void;
214
+ /** 获取 AI 使用指标 */
215
+ getAiMetrics: () => AiMetrics;
216
+ }
217
+ export declare const AiWorkflowIDE: import("react").ForwardRefExoticComponent<AiWorkflowIDEProps & import("react").RefAttributes<AiWorkflowIDERef>>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { ThemeMode, ThemeColor, LayoutDirection, ValidationResults, ExecutionActions, ViewMode } from './types/workflow';
3
- import { WorkflowDef } from './types/conductor';
2
+ import { ThemeMode, ThemeColor, LayoutDirection, ValidationResults, ExecutionActions, ViewMode, WorkflowExecutionInput } from './types/workflow';
3
+ import { WorkflowDef, WorkflowInstance } from './types/conductor';
4
4
  import { AIServiceConfig } from './services/aiService';
5
5
  import './styles/tokens.css';
6
6
  import './styles/executionStyles.css';
@@ -60,7 +60,8 @@ export interface WorkflowIDEProps {
60
60
  * 运行态数据 (WorkflowInstance)。
61
61
  * 当传入此属性时,IDE 会自动切换到 **Run Mode**,展示任务执行状态、连线路径高亮等。
62
62
  */
63
- workflowExecution?: any;
63
+ /** 运行态执行实例数据(完整 Conductor Workflow 实例,或裸的任务实例数组) */
64
+ workflowExecution?: WorkflowExecutionInput;
64
65
  /**
65
66
  * 点击保存按钮时的回调函数。
66
67
  * @param def 最新的工作流定义对象
@@ -97,6 +98,24 @@ export interface WorkflowIDEProps {
97
98
  * @default '100%'
98
99
  */
99
100
  height?: string | number;
101
+ /**
102
+ * P4.2: 触发工作流执行。用户在执行验证面板中点击"发起执行"时调用。
103
+ * 返回 workflowId 后 IDE 自动切换至 run 模式并开始轮询。
104
+ */
105
+ onTriggerExecution?: (workflowName: string, version: number, input: Record<string, any>) => Promise<{
106
+ workflowId: string;
107
+ }>;
108
+ /**
109
+ * P4.2: 轮询执行状态。IDE 在执行触发后按指数退避间隔调用。
110
+ * 返回 null 表示暂未获取到结果,返回 WorkflowInstance 则加载执行数据。
111
+ * 返回终态(COMPLETED/FAILED/TIMED_OUT/TERMINATED)后停止轮询。
112
+ */
113
+ onPollExecution?: (workflowId: string) => Promise<WorkflowInstance | null>;
114
+ /**
115
+ * P4.2: 初始轮询间隔(毫秒),内部使用指数退避,最大退避至 15000ms。
116
+ * @default 3000
117
+ */
118
+ executionPollInterval?: number;
100
119
  }
101
120
  /**
102
121
  * Conductor Workflow IDE 主组件。