@yiyi_zhang/reactflow-ui 1.1.0 → 1.2.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 (51) hide show
  1. package/dist/AiWorkflowIDE.d.ts +21 -0
  2. package/dist/WorkflowIDE.d.ts +21 -0
  3. package/dist/actions/fromDefinitions.d.ts +70 -0
  4. package/dist/actions/registry.d.ts +1 -0
  5. package/dist/actions/types.d.ts +26 -0
  6. package/dist/ai.d.ts +9 -0
  7. package/dist/components/AiNative/AiCommandCenter.d.ts +4 -0
  8. package/dist/components/business/ActionPickerModal.d.ts +25 -0
  9. package/dist/components/business/DataPillInput.d.ts +2 -0
  10. package/dist/components/business/DecisionBranchCard.d.ts +2 -0
  11. package/dist/components/business/ForkJoinCard.d.ts +2 -0
  12. package/dist/components/business/LibraryVersionBadge.d.ts +29 -0
  13. package/dist/components/business/LoopDoWhileCard.d.ts +2 -0
  14. package/dist/components/business/NestedControlStep.d.ts +22 -0
  15. package/dist/components/business/StepFlowEditor.d.ts +9 -0
  16. package/dist/components/business/StepListEditor.d.ts +29 -0
  17. package/dist/index.d.ts +7 -1
  18. package/dist/library/catalog.d.ts +93 -0
  19. package/dist/library/conductorProvider.d.ts +41 -0
  20. package/dist/library/diff.d.ts +62 -0
  21. package/dist/library/index.d.ts +16 -0
  22. package/dist/library/level.d.ts +6 -0
  23. package/dist/library/naming.d.ts +28 -0
  24. package/dist/library/projections.d.ts +53 -0
  25. package/dist/library/types.d.ts +58 -0
  26. package/dist/library/useLibraryCatalog.d.ts +9 -0
  27. package/dist/library/version.d.ts +17 -0
  28. package/dist/library/versionStatus.d.ts +44 -0
  29. package/dist/product-launch.html +3 -3
  30. package/dist/reactflow-ui-ai.es.js +14322 -8462
  31. package/dist/reactflow-ui.css +1 -1
  32. package/dist/reactflow-ui.es.js +9405 -8280
  33. package/dist/reactflow-ui.umd.js +28 -25
  34. package/dist/sample-workflows/library-capabilities-demo.json +66 -0
  35. package/dist/services/ai/agentRunner.d.ts +11 -0
  36. package/dist/services/ai/schemaRegistry.d.ts +7 -1
  37. package/dist/services/ai/systemPrompt.d.ts +11 -0
  38. package/dist/services/ai/toolExecutor.d.ts +12 -0
  39. package/dist/services/ai/workflowSynthesizer.d.ts +28 -3
  40. package/dist/stepmodel/compile.d.ts +6 -0
  41. package/dist/stepmodel/decompile.d.ts +5 -0
  42. package/dist/stepmodel/factory.d.ts +8 -0
  43. package/dist/stepmodel/types.d.ts +3 -0
  44. package/dist/store/ideStoresContext.d.ts +3 -0
  45. package/dist/store/workflowStore.d.ts +1 -0
  46. package/dist/types/conductor.d.ts +13 -8
  47. package/dist/types/workflow.d.ts +9 -0
  48. package/dist/types/workflowLibrary.d.ts +2 -0
  49. package/dist/utils/taskTypeMeta.d.ts +3 -3
  50. package/package.json +1 -1
  51. package/dist/components/AiNative/BusinessCanvas.d.ts +0 -15
@@ -10,6 +10,7 @@ import type { WorkflowDef, WorkflowInstance } from './types/conductor';
10
10
  import type { AiConfig } from './services/ai/protocolAdapter';
11
11
  import type { AiMetrics } from './store/aiStore';
12
12
  import type { WorkflowLibraryItem } from './types/workflowLibrary';
13
+ import type { LibraryProvider } from './library/types';
13
14
  import type { ExecutionActions, ThemeMode, ThemeColor, LayoutDirection, ViewMode, WorkflowExecutionInput } from './types/workflow';
14
15
  import type { CustomTool } from './services/ai/toolRegistry';
15
16
  import type { CustomValidationRule } from './services/ai/ruleEngine';
@@ -42,6 +43,26 @@ export interface AiWorkflowIDEProps {
42
43
  * ```
43
44
  */
44
45
  workflowLibrary?: WorkflowLibraryItem[];
46
+ /**
47
+ * 流程库数据源(LibraryProvider)。提供后,库内流程 / 任务定义经规范化后同时投影为
48
+ * AI 目录(`workflowLibrary`)、任务 Schema(`taskSchemas`)与检索工具的数据来源;
49
+ * 同名条目 Provider 优先于静态 prop,静态 prop 仍可单独使用。
50
+ *
51
+ * `libraryProvider` 引用变化时重新加载,组件卸载时中止进行中的请求。
52
+ * AI 新建的 SUB_WORKFLOW 会固定为目录当前最新版本,已有版本号不会被自动改变。
53
+ *
54
+ * ```tsx
55
+ * const provider = createConductorLibraryProvider({ baseUrl, headers });
56
+ * <AiWorkflowIDE libraryProvider={provider} />
57
+ * ```
58
+ */
59
+ libraryProvider?: LibraryProvider;
60
+ /**
61
+ * 流程库目录注入系统提示词的条数上限,默认 50(按层级 L3 -> L1 截断)。
62
+ * 超出部分会提示 AI 改用 `search_workflow_library` 检索。
63
+ * 提供 `libraryProvider` 时,任务 Schema 段落同样受此上限约束。
64
+ */
65
+ promptCatalogLimit?: number;
45
66
  /**
46
67
  * AI 模型配置(集成方提供)。
47
68
  *
@@ -2,6 +2,8 @@ import { ThemeMode, ThemeColor, LayoutDirection, ValidationResults, ExecutionAct
2
2
  import { WorkflowDef, WorkflowInstance } from './types/conductor';
3
3
  import { AIServiceConfig } from './services/aiService';
4
4
  import { ActionDefinition } from './actions/types';
5
+ import type { WorkflowLevel } from './types/workflowLibrary';
6
+ import type { LibraryProvider } from './library/types';
5
7
  import './styles/tokens.css';
6
8
  import './styles/executionStyles.css';
7
9
  /**
@@ -105,6 +107,25 @@ export interface WorkflowIDEProps {
105
107
  * 宿主可传入自定义业务动作(如私有云/特定系统连接器)。
106
108
  */
107
109
  actions?: ActionDefinition[];
110
+ /**
111
+ * 流程库数据源(LibraryProvider)。提供后,库内流程 / 任务定义会生成业务动作并注册到本实例的动作库:
112
+ * 流程库能力编译为 `SUB_WORKFLOW`,步骤在首次引用时固定为目录当前最新版本,
113
+ * 库发布新版本后步骤不会自动跟随,徽标提示「有新版本」,由用户确认差异后手动升级。
114
+ *
115
+ * 同名动作 Provider 优先于 `actions`;不传时 `actions` 的行为完全不变。
116
+ * `libraryProvider` 引用变化时重新加载,组件卸载时中止进行中的请求。
117
+ *
118
+ * ```tsx
119
+ * const provider = createConductorLibraryProvider({ baseUrl, headers });
120
+ * <WorkflowIDE uiMode="business" libraryProvider={provider} />
121
+ * ```
122
+ */
123
+ libraryProvider?: LibraryProvider;
124
+ /**
125
+ * 当前正在编辑的工作流层级(L1 / L2 / L3)。
126
+ * 提供时,动作选择器隐藏违反分层调用规则的流程库动作(L1 不显示 L2/L3,L2 不显示 L3);未提供则不过滤。
127
+ */
128
+ currentWorkflowLevel?: WorkflowLevel;
108
129
  /**
109
130
  * 组件容器高度。
110
131
  * @default '100%'
@@ -0,0 +1,70 @@
1
+ import type { SchemaDef, WorkflowDef } from '../types/conductor';
2
+ import type { ActionCategory, ActionDefinition, ActionField, ActionOutputField } from './types';
3
+ import type { WorkflowLevel } from '../types/workflowLibrary';
4
+ /**
5
+ * 从 Conductor OSS 标准定义(WorkflowDef / 已注册 TaskDef)生成业务动作。
6
+ *
7
+ * 设计原则:
8
+ * - 库本身不发请求:定义数据由接入方从治理层取得(权限过滤也在治理层完成)。
9
+ * - 标准结构给不了的信息(中文名、分类、图标、风险等级、特殊控件、层级、标签)
10
+ * 通过可选的 ActionExtension 补充;缺省时按合理默认值降级,保证任何定义都能出现在动作库里。
11
+ */
12
+ /** 治理层/接入方提供的补充字段(均可选,按名称一一对应) */
13
+ export interface ActionExtension {
14
+ /** 业务展示名(缺省使用定义名称) */
15
+ label?: string;
16
+ description?: string;
17
+ category?: ActionCategory;
18
+ icon?: string;
19
+ riskLevel?: 'safe' | 'sensitive';
20
+ connector?: string;
21
+ level?: WorkflowLevel;
22
+ /** 业务域展示名 */
23
+ domain?: string;
24
+ tags?: string[];
25
+ /** 为 true 时不进入动作库(例如用户无权限、已下线) */
26
+ hidden?: boolean;
27
+ /** 按入参 key 覆盖表单字段属性(中文标签、控件类型、下拉选项等) */
28
+ fieldOverrides?: Record<string, Partial<ActionField>>;
29
+ /** 按出参 key 覆盖出参说明(中文标签、示例值) */
30
+ outputOverrides?: Record<string, Partial<ActionOutputField>>;
31
+ }
32
+ /** Conductor `/metadata/taskdefs` 返回的已注册任务定义(只列本模块用到的标准字段) */
33
+ export interface RegisteredTaskDef {
34
+ name: string;
35
+ description?: string;
36
+ /** 仅文档用途,不强制 */
37
+ inputKeys?: string[];
38
+ outputKeys?: string[];
39
+ inputTemplate?: Record<string, any>;
40
+ inputSchema?: SchemaDef;
41
+ outputSchema?: SchemaDef;
42
+ ownerEmail?: string;
43
+ }
44
+ /**
45
+ * 将 JSON Schema 的 properties 转为表单字段;没有 schema 时退化为仅有 key 列表
46
+ * (Conductor 的 inputKeys / inputParameters 只有名称),类型一律按文本处理。
47
+ */
48
+ export declare function buildFields(schema: SchemaDef | undefined, fallbackKeys: string[], inputTemplate?: Record<string, any>): ActionField[];
49
+ /** 出参:优先 outputSchema;其次 outputKeys / outputParameters 的 key(后者是输出模板,其 key 即对外接口) */
50
+ export declare function buildOutputs(schema: SchemaDef | undefined, fallbackKeys: string[], outputTemplate?: Record<string, any>): ActionOutputField[];
51
+ /**
52
+ * 把流程库中的一个工作流定义生成为动作:业务用户只面对入参表单与出参,
53
+ * 编译为 SUB_WORKFLOW 引用。版本由步骤上的 libraryRef 决定(首次引用时固定)。
54
+ * 被 extension.hidden 标记时返回 null。
55
+ */
56
+ export declare function buildActionFromWorkflowDef(def: WorkflowDef, ext?: ActionExtension): ActionDefinition | null;
57
+ /** 已注册任务定义生成原子动作,编译为同名 SIMPLE 任务。 */
58
+ export declare function buildActionFromTaskDef(def: RegisteredTaskDef, ext?: ActionExtension): ActionDefinition | null;
59
+ export interface LibraryWorkflowEntry {
60
+ workflowDef: WorkflowDef;
61
+ extension?: ActionExtension;
62
+ }
63
+ export interface RegisteredTaskEntry {
64
+ taskDef: RegisteredTaskDef;
65
+ extension?: ActionExtension;
66
+ }
67
+ /** 批量生成流程库动作(自动跳过 hidden) */
68
+ export declare function buildActionsFromLibrary(entries: LibraryWorkflowEntry[]): ActionDefinition[];
69
+ /** 批量生成原子任务动作(自动跳过 hidden) */
70
+ export declare function buildActionsFromTaskDefs(entries: RegisteredTaskEntry[]): ActionDefinition[];
@@ -5,6 +5,7 @@ export declare class ActionRegistry {
5
5
  constructor(initialActions?: ActionDefinition[]);
6
6
  register(action: ActionDefinition): void;
7
7
  registerAll(actions: ActionDefinition[]): void;
8
+ unregister(id: string): void;
8
9
  getAction(id: string): ActionDefinition | undefined;
9
10
  getAllActions(): ActionDefinition[];
10
11
  getActionsByCategory(category?: ActionCategory): ActionDefinition[];
@@ -1,4 +1,5 @@
1
1
  import type { TaskDef } from '../types/conductor';
2
+ import type { WorkflowLevel } from '../types/workflowLibrary';
2
3
  export type ActionCategory = 'compute' | 'storage' | 'network' | 'monitor' | 'notify' | 'logic' | 'human' | 'custom';
3
4
  export type ActionFieldType = 'text' | 'textarea' | 'number' | 'select' | 'boolean' | 'account' | 'cron-friendly';
4
5
  export interface ActionFieldOption {
@@ -28,6 +29,16 @@ export interface CompileCtx {
28
29
  taskReferenceName: string;
29
30
  stepIndex: number;
30
31
  workflowName?: string;
32
+ /**
33
+ * 该步骤引用流程库能力时记录的 {名称, 版本}。
34
+ * 版本在首次引用时固定,库升级后不会自动跟随;version 缺省表示沿用原定义(不显式指定版本)。
35
+ */
36
+ libraryRef?: LibraryRef;
37
+ }
38
+ /** 步骤对流程库能力(SUB_WORKFLOW)的引用记录 */
39
+ export interface LibraryRef {
40
+ name: string;
41
+ version?: number;
31
42
  }
32
43
  export interface ActionDefinition {
33
44
  id: string;
@@ -36,6 +47,21 @@ export interface ActionDefinition {
36
47
  icon: string;
37
48
  description: string;
38
49
  connector?: string;
50
+ /** 动作来源:task = 原子任务(默认),workflow = 流程库能力(以 SUB_WORKFLOW 引用) */
51
+ kind?: 'task' | 'workflow';
52
+ /** kind = workflow 时:库中该能力的当前最新版本,用于提示“有新版本可升级” */
53
+ workflowRef?: {
54
+ name: string;
55
+ version: number;
56
+ };
57
+ /** 流程库层级 L1 / L2 / L3(调用方向规则见 workflowLibrary) */
58
+ level?: WorkflowLevel;
59
+ /** 业务域展示名(流程库动作);动作选择器据此分组,缺省归入「其他」 */
60
+ domain?: string;
61
+ /** 已下线 / 不建议新引用:动作选择器隐藏,但已引用的步骤照常显示与编译 */
62
+ deprecated?: boolean;
63
+ tags?: string[];
64
+ ownerEmail?: string;
39
65
  riskLevel: 'safe' | 'sensitive';
40
66
  fields: ActionField[];
41
67
  outputs: ActionOutputField[];
package/dist/ai.d.ts CHANGED
@@ -21,6 +21,15 @@ export type { CustomTool } from './services/ai/toolRegistry';
21
21
  export type { CustomValidationRule } from './services/ai/ruleEngine';
22
22
  export type { TaskSchema } from './services/ai/schemaRegistry';
23
23
  export type { WorkflowLevel, WorkflowLibraryItem, WorkflowLibraryDetail } from './types/workflowLibrary';
24
+ export type { LibraryProvider, LibraryExtension, LibraryWorkflowRecord, LibraryTaskRecord, LibraryListResult, LibrarySearchOptions, LibraryLoadStatus, } from './library/types';
25
+ export { LibraryCatalog } from './library/catalog';
26
+ export type { LibraryEntry, LibraryCatalogSnapshot, LibraryCatalogOptions } from './library/catalog';
27
+ export { toActions, toTaskSchemas, toLibraryItems } from './library/projections';
28
+ export { parseWorkflowName, validateWorkflowName } from './library/naming';
29
+ export type { ParsedWorkflowName, WorkflowNameType } from './library/naming';
30
+ export { createConductorLibraryProvider } from './library/conductorProvider';
31
+ export type { ConductorLibraryProviderOptions } from './library/conductorProvider';
32
+ export { DEFAULT_PROMPT_CATALOG_LIMIT } from './services/ai/systemPrompt';
24
33
  export type { AiEvent, AiEventType } from './types/aiEvents';
25
34
  export type { DiffSummary, PartialAcceptSelection, PatchOp } from './services/ai/toolExecutor';
26
35
  export { applyPartialProposal, describeDiff, computeDiff } from './services/ai/toolExecutor';
@@ -12,6 +12,10 @@ import type { AiEvent } from '../../types/aiEvents';
12
12
  interface AiCommandCenterProps {
13
13
  systemPrompt?: string;
14
14
  systemPromptExtra?: string;
15
+ /** 流程库目录注入提示词的条数上限(缺省 50) */
16
+ promptCatalogLimit?: number;
17
+ /** 任务 Schema 注入提示词的条数上限(缺省不限制) */
18
+ promptSchemaLimit?: number;
15
19
  showConfigButton?: boolean;
16
20
  onShowConfig: () => void;
17
21
  executionActions?: ExecutionActions;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { ActionRegistry } from '../../actions/registry';
3
+ import type { ActionDefinition } from '../../actions/types';
4
+ import type { WorkflowLevel } from '../../types/workflowLibrary';
5
+ import type { LibraryCatalog } from '../../library/catalog';
6
+ export interface ActionPickerModalProps {
7
+ registry: ActionRegistry;
8
+ /** 展示用的步骤序号(从 1 开始) */
9
+ stepNumber: number;
10
+ onClose: () => void;
11
+ onSelect: (action: ActionDefinition) => void;
12
+ /**
13
+ * 当前正在编辑的工作流层级。提供时隐藏违反分层调用规则的流程库动作
14
+ * (L1 不显示 L2/L3,L2 不显示 L3);未提供则不按层级过滤。
15
+ */
16
+ currentWorkflowLevel?: WorkflowLevel;
17
+ /** 流程库目录:用于显示「加载中 / 加载失败,点击重试」状态 */
18
+ libraryCatalog?: LibraryCatalog;
19
+ }
20
+ /**
21
+ * 业务动作选择弹窗:分类筛选 + 关键字搜索。
22
+ * 筛选状态与过滤计算都放在弹窗内部:仅在弹窗打开时才会随输入重新计算,
23
+ * 不再拖累编辑器每次渲染(动作库可能有成百上千项)。
24
+ */
25
+ export declare const ActionPickerModal: React.FC<ActionPickerModalProps>;
@@ -10,5 +10,7 @@ export interface DataPillInputProps {
10
10
  registry?: ActionRegistry;
11
11
  workflowInputParams?: any[];
12
12
  disabled?: boolean;
13
+ /** 初始即展开「插入数据」选择面板(例如下拉字段刚切换为动态取值时) */
14
+ defaultShowPicker?: boolean;
13
15
  }
14
16
  export declare const DataPillInput: React.FC<DataPillInputProps>;
@@ -9,5 +9,7 @@ export interface DecisionBranchCardProps {
9
9
  disabled?: boolean;
10
10
  onChange: (updated: BusinessStep) => void;
11
11
  onOpenInsertModal: (callback: (action: ActionDefinition) => void) => void;
12
+ /** 嵌套深度:顶层卡片为 0,其内部子控制流依次 +1 */
13
+ depth?: number;
12
14
  }
13
15
  export declare const DecisionBranchCard: React.FC<DecisionBranchCardProps>;
@@ -9,5 +9,7 @@ export interface ForkJoinCardProps {
9
9
  disabled?: boolean;
10
10
  onChange: (updated: BusinessStep) => void;
11
11
  onOpenInsertModal: (callback: (action: ActionDefinition) => void) => void;
12
+ /** 嵌套深度:顶层卡片为 0,其内部子控制流依次 +1 */
13
+ depth?: number;
12
14
  }
13
15
  export declare const ForkJoinCard: React.FC<ForkJoinCardProps>;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import type { BusinessStep } from '../../stepmodel/types';
3
+ import type { ActionDefinition } from '../../actions/types';
4
+ import type { LibraryCatalog } from '../../library/catalog';
5
+ import { type WorkflowVersionDiff } from '../../library/diff';
6
+ export interface LibraryVersionBadgeProps {
7
+ step: BusinessStep;
8
+ action?: ActionDefinition;
9
+ disabled?: boolean;
10
+ /**
11
+ * 流程库目录。提供后:
12
+ * - 升级前取旧、新两个版本的定义,展示入参 / 出参差异再确认
13
+ * - 固定版本在库中不存在 / 已下线时显示「⚠ 版本不可用」
14
+ * 未提供时沿用旧行为(只按动作上记录的最新版本提示升级)。
15
+ */
16
+ catalog?: LibraryCatalog;
17
+ /** 其它步骤中引用了本步骤哪些出参 key(用于差异里的「下游引用将失效」提示) */
18
+ getReferencedOutputs?: () => Iterable<string>;
19
+ /** 用户确认升级后回调:库中最新版本号,以及(能取到两个版本定义时的)升级差异 */
20
+ onUpgrade: (latestVersion: number, diff?: WorkflowVersionDiff) => void;
21
+ }
22
+ /**
23
+ * 流程库能力的版本标记:
24
+ * - 显示步骤引用时固定的版本(库升级后不会自动跟随)
25
+ * - 库中有更新版本时,提示并允许用户在看过升级差异后手动升级
26
+ * - 固定版本不可用(不存在 / 已下线)时给出警示,保持原样编译,不自动改版本
27
+ * - 目录加载失败时不显示新版本提示,不影响编辑与编译
28
+ */
29
+ export declare const LibraryVersionBadge: React.FC<LibraryVersionBadgeProps>;
@@ -9,5 +9,7 @@ export interface LoopDoWhileCardProps {
9
9
  disabled?: boolean;
10
10
  onChange: (updated: BusinessStep) => void;
11
11
  onOpenInsertModal: (callback: (action: ActionDefinition) => void) => void;
12
+ /** 嵌套深度:顶层卡片为 0,其内部子控制流依次 +1 */
13
+ depth?: number;
12
14
  }
13
15
  export declare const LoopDoWhileCard: React.FC<LoopDoWhileCardProps>;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { BusinessStep } from '../../stepmodel/types';
3
+ import { ActionRegistry } from '../../actions/registry';
4
+ import type { ActionDefinition } from '../../actions/types';
5
+ export interface NestedControlStepProps {
6
+ step: BusinessStep;
7
+ index: number;
8
+ /** 当前嵌套层级(顶层卡片内的第一层子控制流为 1),用于缩进与视觉区分 */
9
+ depth?: number;
10
+ upstreamSteps: BusinessStep[];
11
+ registry?: ActionRegistry;
12
+ disabled?: boolean;
13
+ onChange: (updated: BusinessStep) => void;
14
+ onDelete: () => void;
15
+ onOpenInsertModal: (callback: (action: ActionDefinition) => void) => void;
16
+ }
17
+ /**
18
+ * 分支 / 并行泳道 / 循环体内部的"子控制流"渲染器。
19
+ * 通过它,DecisionBranchCard / ForkJoinCard / LoopDoWhileCard 可以互相递归嵌套,
20
+ * 支持例如「分支 A 内再包含一个分支」「泳道内再有并行或循环」等任意层级。
21
+ */
22
+ export declare const NestedControlStep: React.FC<NestedControlStepProps>;
@@ -1,11 +1,20 @@
1
1
  import React from 'react';
2
2
  import type { WorkflowDef, WorkflowInstance } from '../../types/conductor';
3
+ import type { BusinessStep } from '../../stepmodel/types';
3
4
  import { ActionRegistry } from '../../actions/registry';
5
+ import type { LibraryCatalog } from '../../library/catalog';
6
+ import type { WorkflowLevel } from '../../types/workflowLibrary';
4
7
  export interface StepFlowEditorProps {
5
8
  workflowDef: WorkflowDef | null;
6
9
  onChange: (def: WorkflowDef) => void;
7
10
  registry?: ActionRegistry;
8
11
  readOnly?: boolean;
9
12
  workflowExecution?: WorkflowInstance;
13
+ /** 流程库目录(由 WorkflowIDE 按 libraryProvider 创建):用于动作选择器状态与版本徽标 */
14
+ libraryCatalog?: LibraryCatalog;
15
+ /** 当前正在编辑的工作流层级:提供时选择器隐藏违反分层调用规则的流程库动作 */
16
+ currentWorkflowLevel?: WorkflowLevel;
17
+ /** 提供时,步骤头部显示「🤖」按钮,点击请 AI 介绍该步骤(AI IDE 中使用) */
18
+ onAskAi?: (step: BusinessStep) => void;
10
19
  }
11
20
  export declare const StepFlowEditor: React.FC<StepFlowEditorProps>;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import type { BusinessStep } from '../../stepmodel/types';
3
+ import { ActionRegistry } from '../../actions/registry';
4
+ import type { ActionDefinition } from '../../actions/types';
5
+ export interface StepListEditorProps {
6
+ steps: BusinessStep[];
7
+ onStepsChange: (next: BusinessStep[]) => void;
8
+ /** 本列表之前的所有上游步骤(用于参数胶囊联想);列表内前序步骤会自动追加 */
9
+ upstreamSteps: BusinessStep[];
10
+ registry?: ActionRegistry;
11
+ disabled?: boolean;
12
+ /** 本列表所在容器的嵌套深度(顶层容器为 0) */
13
+ depth: number;
14
+ onOpenInsertModal: (callback: (action: ActionDefinition) => void) => void;
15
+ /** regular:分支 / 循环体内的宽松行;compact:并行泳道内的窄列行 */
16
+ variant?: 'regular' | 'compact';
17
+ /** 行背景色调;展开区域使用相反色调,保持层次 */
18
+ rowTone?: 'primary' | 'secondary';
19
+ /** 序号徽标前缀,如「轮内 」 */
20
+ indexPrefix?: string;
21
+ /** 序号徽标是否使用强调色(默认为中性底色) */
22
+ accentIndexBadge?: boolean;
23
+ }
24
+ /**
25
+ * 分支 / 并行泳道 / 循环体共用的"子步骤列表":
26
+ * - 普通动作渲染为可展开的表单行
27
+ * - 控制流步骤(分支 / 并行 / 循环)交给 NestedControlStep 递归渲染,因此可任意层级嵌套
28
+ */
29
+ export declare const StepListEditor: React.FC<StepListEditorProps>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { WorkflowIDE } from './WorkflowIDE';
2
2
  export type { WorkflowIDEProps, WorkflowIDERef } from './WorkflowIDE';
3
- export type { WorkflowDef, TaskDef, WorkflowInputParam, WorkflowInstance } from './types/conductor';
3
+ export type { WorkflowDef, TaskDef, WorkflowInputParam, WorkflowInstance, SchemaDef } from './types/conductor';
4
4
  export { parseWorkflowInputParams } from './types/conductor';
5
5
  export type { AIServiceConfig } from './services/aiService';
6
6
  export type { ExecutionActions, RestartOptions, ViewMode, RunState, WorkflowExecutionInput } from './types/workflow';
@@ -12,6 +12,9 @@ export * from './actions/types';
12
12
  export { ActionRegistry, defaultActionRegistry } from './actions/registry';
13
13
  export { BUILTIN_ECS_ACTIONS } from './actions/builtin/ecs';
14
14
  export { BUILTIN_COMMON_ACTIONS } from './actions/builtin/common';
15
+ export { buildActionFromWorkflowDef, buildActionFromTaskDef, buildActionsFromLibrary, buildActionsFromTaskDefs, } from './actions/fromDefinitions';
16
+ export type { ActionExtension, RegisteredTaskDef, LibraryWorkflowEntry, RegisteredTaskEntry, } from './actions/fromDefinitions';
17
+ export { createStepFromAction } from './stepmodel/factory';
15
18
  export * from './stepmodel/types';
16
19
  export { compileStepToTaskDef, compileStepModelToWorkflowDef, } from './stepmodel/compile';
17
20
  export { decompileTaskDefToStep, decompileWorkflowDefToStepModel, } from './stepmodel/decompile';
@@ -37,3 +40,6 @@ export { FriendlyErrorCard } from './components/business/FriendlyErrorCard';
37
40
  export type { FriendlyErrorCardProps } from './components/business/FriendlyErrorCard';
38
41
  export { RunStoryTimeline } from './components/business/RunStoryTimeline';
39
42
  export type { RunStoryTimelineProps } from './components/business/RunStoryTimeline';
43
+ export * from './library';
44
+ export type { WorkflowLevel, WorkflowLibraryItem } from './types/workflowLibrary';
45
+ export type { TaskSchema } from './services/ai/schemaRegistry';
@@ -0,0 +1,93 @@
1
+ import type { WorkflowLevel, WorkflowLibraryItem } from '../types/workflowLibrary';
2
+ import type { TaskSchema } from '../services/ai/schemaRegistry';
3
+ import type { LibraryLoadStatus, LibraryProvider, LibrarySearchOptions, LibraryTaskRecord, LibraryWorkflowRecord } from './types';
4
+ /** 规范化后的目录条目(每个 name 只有一个最新版本) */
5
+ export interface LibraryEntry {
6
+ name: string;
7
+ /** 统一为整数 */
8
+ version: number;
9
+ versionLabel?: string;
10
+ description?: string;
11
+ level?: WorkflowLevel;
12
+ /** 业务域展示名:优先取 extension.domain,缺省时从流程名称解析 */
13
+ domain?: string;
14
+ tags: string[];
15
+ deprecated: boolean;
16
+ record: LibraryWorkflowRecord;
17
+ /** 条目来源:Provider 提供,或静态 prop(workflowLibrary)。同名时 Provider 优先 */
18
+ source: 'provider' | 'static';
19
+ }
20
+ /** 目录状态快照(引用在每次变化时更新,供 useSyncExternalStore 使用) */
21
+ export interface LibraryCatalogSnapshot {
22
+ status: LibraryLoadStatus;
23
+ error?: Error;
24
+ /** 每次数据 / 状态变化递增,便于作为 useMemo 依赖 */
25
+ revision: number;
26
+ }
27
+ export interface LibraryCatalogOptions {
28
+ /** 兼容旧 `workflowLibrary` prop 的静态条目 */
29
+ staticItems?: WorkflowLibraryItem[];
30
+ /** 兼容旧 `taskSchemas` prop 的静态 Schema */
31
+ staticTaskSchemas?: TaskSchema[];
32
+ }
33
+ /** 把一条记录规范化为目录条目 */
34
+ export declare function entryFromRecord(record: LibraryWorkflowRecord, source: LibraryEntry['source'], onLossy?: (name: string, label: string) => void): LibraryEntry;
35
+ /**
36
+ * 流程库目录:把 Provider 与静态 prop 规范化成一份数据。
37
+ * 每个实例独立(不是全局单例);通过 subscribe / getSnapshot 接入 React。
38
+ */
39
+ export declare class LibraryCatalog {
40
+ private provider?;
41
+ private staticItems;
42
+ private staticSchemas;
43
+ private providerEntries;
44
+ private providerTasks;
45
+ private merged;
46
+ private versionCache;
47
+ private warned;
48
+ private listeners;
49
+ /** 每次 load / setProvider 递增,用于丢弃过期的异步结果 */
50
+ private generation;
51
+ private controller;
52
+ private snapshot;
53
+ constructor(provider?: LibraryProvider, options?: LibraryCatalogOptions);
54
+ /** 更换数据源:丢弃旧数据与缓存,状态回到 idle(需再调用 load) */
55
+ setProvider(provider?: LibraryProvider): void;
56
+ /** 更新静态条目 / Schema(对应旧 prop 变化) */
57
+ setStatic(options: LibraryCatalogOptions): void;
58
+ hasProvider(): boolean;
59
+ /** Provider 是否支持服务端检索 */
60
+ hasServerSearch(): boolean;
61
+ /**
62
+ * 拉取目录:同名多版本去重取最大 version。
63
+ * 同一时刻只保留最新一次加载:新的 load / reload / setProvider / abort 会取消上一次(abort 其请求并丢弃其结果);
64
+ * 传入的 signal 被 abort 时同样取消。网络错误记为 error 状态,不抛出。
65
+ */
66
+ load(signal?: AbortSignal): Promise<void>;
67
+ /** 重新加载(供 UI「点击重试」使用) */
68
+ reload(): Promise<void>;
69
+ /** 取消进行中的加载(组件卸载时调用);已加载的数据保留 */
70
+ abort(): void;
71
+ latest(name: string): LibraryEntry | undefined;
72
+ entries(): LibraryEntry[];
73
+ /** Provider 提供的原子任务定义 */
74
+ tasks(): LibraryTaskRecord[];
75
+ /** 静态 Schema(Provider 未覆盖的部分由 projections 合并) */
76
+ staticTaskSchemas(): TaskSchema[];
77
+ /**
78
+ * 取指定版本的完整定义(历史版本按需获取并缓存)。
79
+ * 找不到返回 null;网络错误向上抛出,由调用方决定如何提示。
80
+ */
81
+ getVersion(name: string, version: number, signal?: AbortSignal): Promise<LibraryWorkflowRecord | null>;
82
+ /**
83
+ * 服务端检索。Provider 未实现 search 时返回 null,调用方应退回本地匹配。
84
+ * 结果不并入目录(只是一次查询的命中)。
85
+ */
86
+ search(query: string, opts?: LibrarySearchOptions, signal?: AbortSignal): Promise<LibraryEntry[] | null>;
87
+ getSnapshot: () => LibraryCatalogSnapshot;
88
+ subscribe: (listener: () => void) => (() => void);
89
+ private warnLossy;
90
+ /** Provider 条目优先,静态条目补充同名之外的部分 */
91
+ private rebuild;
92
+ private setState;
93
+ }
@@ -0,0 +1,41 @@
1
+ import type { WorkflowDef } from '../types/conductor';
2
+ import type { RegisteredTaskDef } from '../actions/fromDefinitions';
3
+ import type { LibraryExtension, LibraryProvider } from './types';
4
+ export interface ConductorLibraryProviderOptions {
5
+ /** Conductor API 根地址,如 `https://conductor.example.com/api`(尾部斜杠可有可无) */
6
+ baseUrl: string;
7
+ /**
8
+ * 认证头等,由宿主在每次请求前注入(组件库不保存任何凭据)。
9
+ * 可返回 Promise,便于异步刷新 token。
10
+ */
11
+ headers?: () => Record<string, string> | Promise<Record<string, string>>;
12
+ /** 自定义 fetch(测试 / 网关封装);缺省使用全局 fetch */
13
+ fetch?: typeof fetch;
14
+ /** 是否同时拉取已注册的原子任务定义(`/metadata/taskdefs`),默认 false */
15
+ includeTaskDefs?: boolean;
16
+ /** 只暴露「流程库」内的工作流(如按名前缀 / ownerEmail);对列表与单个获取都生效 */
17
+ filter?: (def: WorkflowDef) => boolean;
18
+ /** 补充字段(层级、分类、图标、是否下线等)的来源由宿主决定 */
19
+ resolveExtension?: (def: WorkflowDef) => LibraryExtension | undefined;
20
+ /** 原子任务的补充字段来源(仅 includeTaskDefs 时使用) */
21
+ resolveTaskExtension?: (def: RegisteredTaskDef) => LibraryExtension | undefined;
22
+ /**
23
+ * 网关路径不同可覆盖(相对 baseUrl)。
24
+ * `workflow` 为单个工作流的路径:含 `{name}` 时按模板替换,否则在其后追加 `/{name}`。
25
+ */
26
+ paths?: {
27
+ workflows?: string;
28
+ workflow?: string;
29
+ taskDefs?: string;
30
+ };
31
+ }
32
+ /**
33
+ * Conductor OSS 默认的流程库数据源:
34
+ * - `GET {baseUrl}/metadata/workflow` 列出工作流(同名多版本时客户端取最大 version)
35
+ * - `GET {baseUrl}/metadata/workflow/{name}?version={v}` 取指定版本,404 返回 null
36
+ * - `GET {baseUrl}/metadata/taskdefs` 已注册任务(includeTaskDefs 时)
37
+ *
38
+ * 不内置 `search`(Conductor OSS 元数据接口没有检索能力);需要服务端检索请自行实现 LibraryProvider。
39
+ * 网络错误 / 非 404 的 HTTP 错误会抛出,由目录层捕获为 `error` 状态。
40
+ */
41
+ export declare function createConductorLibraryProvider(options: ConductorLibraryProviderOptions): LibraryProvider;
@@ -0,0 +1,62 @@
1
+ import type { WorkflowDef } from '../types/conductor';
2
+ import type { ActionField } from '../actions/types';
3
+ /**
4
+ * 流程库能力升级差异(纯函数):对比旧、新两个版本的入参 / 出参,
5
+ * 让用户在确认升级前看清「哪些已填内容会受影响」。
6
+ */
7
+ export interface InputChange {
8
+ key: string;
9
+ /** 旧版本的类型描述,如「数字,必填」「可选值 a|b」 */
10
+ from: string;
11
+ /** 新版本的类型描述 */
12
+ to: string;
13
+ /** 该入参是否已填写过值(类型变化后已填值可能不再有效) */
14
+ valueFilled: boolean;
15
+ }
16
+ export interface WorkflowVersionDiff {
17
+ /** 新增入参(field.required 标出必填) */
18
+ addedInputs: ActionField[];
19
+ /** 删除的入参 */
20
+ removedInputs: ActionField[];
21
+ /** 类型 / 枚举 / 必填变化 */
22
+ changedInputs: InputChange[];
23
+ addedOutputs: string[];
24
+ removedOutputs: string[];
25
+ /** removedInputs 中已填值的 key:升级后这些值将丢失 */
26
+ lostValueKeys: string[];
27
+ /** removedOutputs 中被其它步骤引用的 key:升级后下游引用将失效 */
28
+ brokenOutputRefs: string[];
29
+ }
30
+ export interface DiffOptions {
31
+ /** 其它步骤中引用了本步骤哪些出参 key(见 collectReferencedOutputKeys);缺省视为没有引用 */
32
+ referencedOutputs?: Iterable<string>;
33
+ }
34
+ /**
35
+ * @param oldDef 步骤当前固定版本的定义
36
+ * @param newDef 目录最新版本的定义
37
+ * @param filledValues 步骤上已填写的入参值
38
+ */
39
+ export declare function diffWorkflowVersions(oldDef: WorkflowDef, newDef: WorkflowDef, filledValues?: Record<string, unknown>, options?: DiffOptions): WorkflowVersionDiff;
40
+ /** 没有任何入参 / 出参变化 */
41
+ export declare function isDiffEmpty(diff: WorkflowVersionDiff): boolean;
42
+ /**
43
+ * 在若干结构(其它步骤的入参值等)中查找对 `${ref.output.<key>...}` 的引用,返回被引用的出参 key。
44
+ * 用于判断升级删除某个出参后,下游引用是否会失效。
45
+ */
46
+ export declare function collectReferencedOutputKeys(taskReferenceName: string, parts: unknown[]): Set<string>;
47
+ export interface DiffSummary {
48
+ /** 会影响已填内容的条目(置顶显示) */
49
+ impacts: string[];
50
+ /** 其它变化 */
51
+ changes: string[];
52
+ }
53
+ /** 把差异整理为面向用户的文字条目:会影响已填内容的置顶 */
54
+ export declare function summarizeDiff(diff: WorkflowVersionDiff): DiffSummary;
55
+ /** 升级确认框文案(含升级差异)。无差异时提示「入参出参未变化」。 */
56
+ export declare function buildUpgradeConfirmMessage(name: string, pinned: number | undefined, latest: number, diff: WorkflowVersionDiff): string;
57
+ /**
58
+ * 升级后调整步骤已填的入参值:
59
+ * - 删除的入参:移除其值(与差异中「值将丢失」一致)
60
+ * - 新增且有默认值的入参:补上默认值(用户已填的不覆盖)
61
+ */
62
+ export declare function applyUpgradeToValues(values: Record<string, any>, diff: WorkflowVersionDiff): Record<string, any>;
@@ -0,0 +1,16 @@
1
+ export * from './types';
2
+ export { normalizeVersion } from './version';
3
+ export type { NormalizedVersion } from './version';
4
+ export { canCallLevel } from './level';
5
+ export { parseWorkflowName, validateWorkflowName, WORKFLOW_NAME_TYPES } from './naming';
6
+ export type { ParsedWorkflowName, WorkflowNameType } from './naming';
7
+ export { LibraryCatalog, entryFromRecord } from './catalog';
8
+ export type { LibraryEntry, LibraryCatalogSnapshot, LibraryCatalogOptions } from './catalog';
9
+ export { toActions, toActionExtension, toTaskSchemas, toLibraryItems, entriesToLibraryItems, filterPickableActions, libraryDomainOf, collectLibraryDomains, OTHER_DOMAIN, schemaToTypeStrings, } from './projections';
10
+ export { useLibraryCatalogSnapshot, useLibraryCatalogLoader } from './useLibraryCatalog';
11
+ export { createConductorLibraryProvider } from './conductorProvider';
12
+ export type { ConductorLibraryProviderOptions } from './conductorProvider';
13
+ export { diffWorkflowVersions, isDiffEmpty, summarizeDiff, buildUpgradeConfirmMessage, applyUpgradeToValues, collectReferencedOutputKeys, } from './diff';
14
+ export type { WorkflowVersionDiff, InputChange, DiffOptions, DiffSummary } from './diff';
15
+ export { resolveLibraryBadgeState, describeUnavailable } from './versionStatus';
16
+ export type { LibraryBadgeState, LibraryBadgeInputs } from './versionStatus';
@@ -0,0 +1,6 @@
1
+ import type { WorkflowLevel } from '../types/workflowLibrary';
2
+ /**
3
+ * 分层调用规则:高层可调用低层及同层,禁止反向跨层。
4
+ * L3 -> L3/L2/L1;L2 -> L2/L1;L1 -> L1。任一方层级未知时视为允许(不做限制)。
5
+ */
6
+ export declare function canCallLevel(caller: WorkflowLevel | undefined, callee: WorkflowLevel | undefined): boolean;