wechen-agent-editor-v1 1.0.7 → 1.1.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.
- package/README.md +170 -209
- package/dist/WechenAgentEditor.d.ts +29 -2
- package/dist/WechenAgentEditor.d.ts.map +1 -1
- package/dist/backendWorkflowJson.d.ts +57 -0
- package/dist/backendWorkflowJson.d.ts.map +1 -0
- package/dist/config/componentLibraryConfig.d.ts +9 -0
- package/dist/config/componentLibraryConfig.d.ts.map +1 -1
- package/dist/config/flowHandleTypes.d.ts +27 -0
- package/dist/config/flowHandleTypes.d.ts.map +1 -0
- package/dist/flow/deleteGuard.d.ts +11 -0
- package/dist/flow/deleteGuard.d.ts.map +1 -0
- package/dist/flow/dropNodes.d.ts +3 -2
- package/dist/flow/dropNodes.d.ts.map +1 -1
- package/dist/flow/flowJsonUtils.d.ts +1 -0
- package/dist/flow/flowJsonUtils.d.ts.map +1 -1
- package/dist/flow/initialFlow.d.ts.map +1 -1
- package/dist/flow/nodeChangeSyncAttachSides.d.ts +15 -0
- package/dist/flow/nodeChangeSyncAttachSides.d.ts.map +1 -0
- package/dist/flow/nodes/CardNode.d.ts.map +1 -1
- package/dist/flow/nodes/DeclaredHandles.d.ts +5 -0
- package/dist/flow/nodes/DeclaredHandles.d.ts.map +1 -0
- package/dist/flow/nodes/MainAgentNode.d.ts.map +1 -1
- package/dist/flow/nodes/PillNode.d.ts.map +1 -1
- package/dist/flow/nodes/ZoneHandles.d.ts +10 -0
- package/dist/flow/nodes/ZoneHandles.d.ts.map +1 -0
- package/dist/flow/swapFlowEdgeEndpoints.d.ts +11 -0
- package/dist/flow/swapFlowEdgeEndpoints.d.ts.map +1 -0
- package/dist/flow/wechenAgentEdgeTypes.d.ts +16 -2
- package/dist/flow/wechenAgentEdgeTypes.d.ts.map +1 -1
- package/dist/flow/zoneConnectionAttach.d.ts +30 -0
- package/dist/flow/zoneConnectionAttach.d.ts.map +1 -0
- package/dist/flow/zoneConnectionIds.d.ts +13 -0
- package/dist/flow/zoneConnectionIds.d.ts.map +1 -0
- package/dist/flow/zoneConnectionValidation.d.ts +8 -0
- package/dist/flow/zoneConnectionValidation.d.ts.map +1 -0
- package/dist/flow/zoneHandleLayout.d.ts +48 -0
- package/dist/flow/zoneHandleLayout.d.ts.map +1 -0
- package/dist/flowTypes.d.ts +25 -3
- package/dist/flowTypes.d.ts.map +1 -1
- package/dist/hostEditorConfig.d.ts +53 -0
- package/dist/hostEditorConfig.d.ts.map +1 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5930 -4968
- package/dist/index.js.map +1 -1
- package/dist/panels/EdgeConfigPanel.d.ts +3 -1
- package/dist/panels/EdgeConfigPanel.d.ts.map +1 -1
- package/dist/panels/NodeConfigPanel.d.ts +5 -2
- package/dist/panels/NodeConfigPanel.d.ts.map +1 -1
- package/dist/panels/RightConfigPanel.d.ts +3 -1
- package/dist/panels/RightConfigPanel.d.ts.map +1 -1
- package/dist/wechenAgentConfigPanel.d.ts +10 -2
- package/dist/wechenAgentConfigPanel.d.ts.map +1 -1
- package/package.json +10 -4
- package/dist/flow/WechenAgentEdgeFlowStyles.d.ts +0 -6
- package/dist/flow/WechenAgentEdgeFlowStyles.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,298 +1,259 @@
|
|
|
1
1
|
# wechen-agent-editor-v1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
面向宿主应用的 **Agent 流程编排编辑器** React 组件:左侧可拖入的组件库、中间 **@xyflow/react** 画布、右侧基于 **antd** 与 **Monaco** 的配置区。图上的 **节点** 表示功能模块,**边** 表示执行顺序;持久化的 `flow` 可由你的运行时或执行引擎消费。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**包名**:以 `package.json` 的 `name` 为准(`wechen-agent-editor-v1`)。安装与 `import` 均使用该名称。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
> **BREAKING(peer 依赖)**:自 **1.0.3** 起,`react`、`react-dom`、`antd`、`monaco-editor`、`@monaco-editor/react` 为 **`peerDependencies`**(由宿主安装)。自 **1.0.7** 起,**`@xyflow/react` 为本包 `dependencies` 且列入 `bundledDependencies`**:发布 tarball 内会附带 **`node_modules/@xyflow/react`**,宿主 **根目录 `package.json` 可不写** `@xyflow/react` 也能解析 **`dist/index.js` 中的 import**(利于 Umi MFSU 等场景)。若宿主**另有**直接使用 **`@xyflow/react`** 的页面,请用 **`npm ls`** 与 **`resolve.alias`** 避免 **双份 xyflow 运行时**。请见下文「依赖(安装)」与「排查」。
|
|
9
|
-
> **BREAKING(Monaco)**:需在宿主入口配置 **Monaco worker**(见下文)。
|
|
10
|
-
> **BREAKING(initialFlow)**:未传 `initialFlow` 时为 **空画布**(无内置示例节点)。若依赖旧版「零配置即出现示例图」,请显式传入 `initialFlow={cloneWechenAgentFlow(defaultInitialFlow)}`(需同时 import `cloneWechenAgentFlow` 与 `defaultInitialFlow`)。
|
|
7
|
+
## 快速开始
|
|
11
8
|
|
|
9
|
+
### 60 秒最小集成(L0)
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
只需 **`onSave`** 与 antd **`ConfigProvider`**,并保证父容器有高度(例如 `height: 100%` 链或 `100vh`)。未传 **`initialFlow`** 时为**空画布**(与编辑器默认一致)。
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
- **npm 7+** 安装本包时,一般会 **自动安装缺失的 peer**;仍建议在宿主 `package.json` 中 **显式列出** 上述依赖及版本,便于与业务线对齐并避免重复副本。
|
|
22
|
-
- 版本范围以 **`peerDependencies`** 为准;建议 **React 18+**、**`antd` 5+**;**`@xyflow/react`** 版本随本包 **`dependencies` / `bundledDependencies`** 锁定(与 **`npm pack` 内容**一致)。
|
|
23
|
-
|
|
24
|
-
### 宿主 `npm install wechen-agent-editor-v1` 报 `ERESOLVE`
|
|
25
|
-
|
|
26
|
-
npm 7+ 会对 **整棵依赖树**做严格 peer 校验;安装 **`wechen-agent-editor-v1`** 往往只是 **触发一次完整解析**,冲突可能来自 **宿主里早已存在的包**,**不一定与本包 `peerDependencies` 声明矛盾**。
|
|
27
|
-
|
|
28
|
-
**与本 issue 一致的两类典型冲突**(看 `npm install` 日志里 **While resolving …** 指向谁):
|
|
29
|
-
|
|
30
|
-
| 类型 | 常见表现 | 建议先做的排查 |
|
|
31
|
-
|------|----------|----------------|
|
|
32
|
-
| **`@ant-design/pro-chat` ↔ `antd-style`** | 例如 pro-chat 声明 **`antd-style@^3`**,宿主已用 **`antd-style@^4`** | 在 [npm @ant-design/pro-chat](https://www.npmjs.com/package/@ant-design/pro-chat?activeTab=versions) 查各版本 **peerDependencies**;宿主执行 **`npm ls @ant-design/pro-chat antd-style`** |
|
|
33
|
-
| **`@ahooksjs/use-request`(经 `ahooks` / `@umijs/plugins`)↔ React 18** | peer 仍写 **`react@^16 \|\| ^17`** 等 | **`npm why @ahooksjs/use-request`**;**`npm ls ahooks react`**;按 Umi / ahooks 官方说明 **升级 ahooks 或相关插件** |
|
|
34
|
-
|
|
35
|
-
**「临时 unblock」与「根治」**(勿与下文「多份 React」混淆——那是 **安装成功后运行时** 的问题):
|
|
36
|
-
|
|
37
|
-
| 阶段 | 做法 | 说明 |
|
|
38
|
-
|------|------|------|
|
|
39
|
-
| **临时** | `npm install wechen-agent-editor-v1@<version> --legacy-peer-deps`,或宿主根目录 **`.npmrc`**:`legacy-peer-deps=true` | 仅放宽 **peer 解析**,**不替代**你在 `package.json` 里对本包要求的 **`react` / `antd` / `monaco-editor` / …** 的显式声明;上线前请在宿主跑 **`npm run build`**(或 `max build`)并记录技术债 |
|
|
40
|
-
| **根治** | **升级** `@ant-design/pro-chat` 等到与 **`antd-style@4`** 兼容的组合;或 **升级 ahooks / Umi 链** 与 React 18 一致;必要时再用 **`overrides`**(见下折叠示例) | 对齐后应 **去掉** `legacy-peer-deps`,避免长期掩盖不兼容 |
|
|
41
|
-
|
|
42
|
-
**与「排查:第一次从组件库拖入正常…」的区别**:本节解决 **`npm install` 失败(ERESOLVE)**;该小节解决 **装得上但画布异常**(多为 **多份 `react`**、**样式未进包**,或 **宿主另引 `@xyflow/react` 与本包内置副本冲突**)。
|
|
43
|
-
|
|
44
|
-
<details>
|
|
45
|
-
<summary><strong>可选:<code>package.json</code> <code>overrides</code> 示例(npm)</strong> — 仅作参考,须按宿主实际包名与版本调整;优先升级上游</summary>
|
|
46
|
-
|
|
47
|
-
`overrides` 会 **强制子依赖解析版本**,可能掩盖真实不兼容;合并前请在 **关键页面 + CI build** 验证。
|
|
13
|
+
```tsx
|
|
14
|
+
import { ConfigProvider } from "antd";
|
|
15
|
+
import { WechenAgentEditor } from "wechen-agent-editor-v1";
|
|
16
|
+
// 若生产构建后缺少 Flow 全局样式,再增加:import "wechen-agent-editor-v1/style.css";
|
|
48
17
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
export function AgentPage() {
|
|
19
|
+
return (
|
|
20
|
+
<ConfigProvider>
|
|
21
|
+
<div style={{ height: "100vh" }}>
|
|
22
|
+
<WechenAgentEditor onSave={(s) => console.log("flow", s.flow)} />
|
|
23
|
+
</div>
|
|
24
|
+
</ConfigProvider>
|
|
25
|
+
);
|
|
54
26
|
}
|
|
55
27
|
```
|
|
56
28
|
|
|
57
|
-
|
|
29
|
+
### 常用配置一条对象(L1)
|
|
58
30
|
|
|
59
|
-
|
|
31
|
+
标题、初始流、只读、以及在**默认组件库**上按条目打补丁,可用 **`buildWechenAgentEditorProps`** 一次展开为 `WechenAgentEditor` 的 props(类型见包内导出)。
|
|
60
32
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
33
|
+
```tsx
|
|
34
|
+
import { ConfigProvider } from "antd";
|
|
35
|
+
import {
|
|
36
|
+
WechenAgentEditor,
|
|
37
|
+
buildWechenAgentEditorProps,
|
|
38
|
+
cloneWechenAgentFlow,
|
|
39
|
+
COMPONENT_LIBRARY_GROUP_APP,
|
|
40
|
+
defaultInitialFlow,
|
|
41
|
+
} from "wechen-agent-editor-v1";
|
|
64
42
|
|
|
65
|
-
|
|
43
|
+
const editorProps = buildWechenAgentEditorProps({
|
|
44
|
+
title: "我的流程",
|
|
45
|
+
initialFlow: cloneWechenAgentFlow(defaultInitialFlow),
|
|
46
|
+
readOnly: false,
|
|
47
|
+
library: {
|
|
48
|
+
preset: "default",
|
|
49
|
+
itemPatches: [
|
|
50
|
+
{ groupKey: COMPONENT_LIBRARY_GROUP_APP, itemKey: "alert", patch: { subtitle: "自定义副标题" } },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
onSave: (s) => console.log("flow", s.flow),
|
|
54
|
+
});
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
export function AgentPage() {
|
|
57
|
+
return (
|
|
58
|
+
<ConfigProvider>
|
|
59
|
+
<div style={{ height: "100vh" }}>
|
|
60
|
+
<WechenAgentEditor {...editorProps} />
|
|
61
|
+
</div>
|
|
62
|
+
</ConfigProvider>
|
|
63
|
+
);
|
|
71
64
|
}
|
|
72
65
|
```
|
|
73
66
|
|
|
74
|
-
|
|
67
|
+
**高级扩展**(自定义画布节点、右侧配置面板、组件库列表映射、顶栏按钮等)仍使用完整 **`WechenAgentEditorProps`**;说明见下文「行为与扩展(摘要)」与 **`src/index.ts`** 导出。
|
|
75
68
|
|
|
76
|
-
|
|
69
|
+
### 后端工作流 JSON(存库 / 执行 / 回显)
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
- **对照**:暂时 **`mfsu: false`** 做问题隔离。
|
|
71
|
+
编辑器内部持久化形态为 **`WechenAgentFlowJson`**(React Flow 的 `nodes` / `edges` + 业务 `data`)。若后端希望 **扁平 DTO**(`flowId`、`flowName`、`nodes[].type` + `config`、`edges[].source/target` 等),请使用:
|
|
80
72
|
|
|
81
|
-
|
|
73
|
+
- **`exportBackendWorkflowJson(snapshot | flow, meta)`** → **`WechenBackendWorkflowJson`**(根字段 **`schemaVersion`** 当前为 **`"1"`**,与业务字段 **`version`** 区分)
|
|
74
|
+
- **`importBackendWorkflowToFlow(dto)`** → **`WechenAgentFlowJson`**,再作为 **`initialFlow`** 或 **`ref.replaceFlow`** 回显
|
|
82
75
|
|
|
83
|
-
|
|
76
|
+
**有损字段**:导出会去掉 RF 运行期字段与部分边样式;导入会按边 `id` 重新分配 `sourceHandle`/`targetHandle`。详见类型 **`WechenBackendWorkflowJson`** 的 JSDoc。
|
|
84
77
|
|
|
85
|
-
|
|
78
|
+
```tsx
|
|
79
|
+
import {
|
|
80
|
+
WechenAgentEditor,
|
|
81
|
+
exportBackendWorkflowJson,
|
|
82
|
+
importBackendWorkflowToFlow,
|
|
83
|
+
} from "wechen-agent-editor-v1";
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
<WechenAgentEditor
|
|
86
|
+
onSave={(s) => {
|
|
87
|
+
const dto = exportBackendWorkflowJson(s, {
|
|
88
|
+
flowId: "agent_flow_001",
|
|
89
|
+
workflowVersion: "1.0",
|
|
90
|
+
});
|
|
91
|
+
void fetch("/api/flows", {
|
|
92
|
+
method: "POST",
|
|
93
|
+
body: JSON.stringify(dto),
|
|
94
|
+
headers: { "Content-Type": "application/json" },
|
|
95
|
+
});
|
|
96
|
+
}}
|
|
97
|
+
/>;
|
|
98
|
+
|
|
99
|
+
// 回显:从接口取 dto 后
|
|
100
|
+
const flow = importBackendWorkflowToFlow(dtoFromApi);
|
|
101
|
+
// <WechenAgentEditor initialFlow={flow} />
|
|
102
|
+
```
|
|
92
103
|
|
|
93
|
-
|
|
104
|
+
本仓库 **playground** 提供对照:`npm run dev:minimal` 为最小页;默认 `npm run dev` 为带场景 JSON 与工具栏的完整演示(见 `playground/README.md`)。
|
|
94
105
|
|
|
95
|
-
|
|
106
|
+
---
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
defaultInitialFlow,
|
|
102
|
-
type WechenAgentEditorRef,
|
|
103
|
-
type WechenAgentSnapshot,
|
|
104
|
-
} from "wechen-agent-editor-v1";
|
|
108
|
+
## 安装
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm install wechen-agent-editor-v1
|
|
105
112
|
```
|
|
106
113
|
|
|
107
|
-
|
|
114
|
+
### Peer 依赖(须由宿主安装)
|
|
108
115
|
|
|
109
|
-
|
|
110
|
-
|------|-----------|
|
|
111
|
-
| 组件 | `WechenAgentEditor` |
|
|
112
|
-
| Ref / 快照 / Flow | `WechenAgentEditorRef`, `WechenAgentSnapshot`, `WechenAgentFlowJson` |
|
|
113
|
-
| 顶栏自定义 | `WechenAgentHeaderActionsRenderContext`(与 `renderHeaderActions` 搭配) |
|
|
114
|
-
| 右侧配置扩展 | `WechenAgentRenderConfigPanelFn`、`WechenAgentConfigPanelContext` 等 |
|
|
115
|
-
| 组件库 | `getDefaultComponentLibraryGroups`、`COMPONENT_LIBRARY_GROUP_MAIN`、动态 `appendComponentToLibrary` … |
|
|
116
|
-
| Flow 工具 | `cloneWechenAgentFlow`、`parseWechenAgentFlowJson`、`mergeNodeData`、`emptyInitialFlow` … |
|
|
117
|
-
| 拖放协议 | `WECHEN_AGENT_FLOW_DRAG_MIME`、`encodePaletteDragPayload` … |
|
|
116
|
+
`react`、`react-dom`、`antd`(建议 5+)、`monaco-editor`、`@monaco-editor/react`。请在 `package.json` 中显式声明并与业务栈版本对齐。
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
**`@xyflow/react`** 已作为本包的 **`dependencies`** 且列入 **`bundledDependencies`**,会安装到 `node_modules/wechen-agent-editor-v1/node_modules/@xyflow/react`,与 `dist/index.js` 中的引用配套。仅嵌入本编辑器时,宿主根目录 **不必**再单独安装 `@xyflow/react`。若项目中 **另有**直接使用 `@xyflow/react` 的代码,请用 `npm ls @xyflow/react` 与打包器的 `resolve`/别名保证 **单实例**,避免两套 Flow 运行时。
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
- **Ant Design**:antd 5 为 **CSS-in-JS**,随组件在运行时注入;请使用 **`ConfigProvider`** 包裹(与官方用法一致),并避免 **重复多份 `antd`** 导致样式异常。
|
|
120
|
+
### 安装失败(`ERESOLVE`)
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
npm 7+ 会校验整棵依赖树的 peer。冲突常来自宿主已有包,未必与本包声明矛盾。优先:**升级**冲突链上的上游(如 Pro 组件、ahooks、Umi 插件)使 peer 与 React 18 一致。临时可 **`npm install wechen-agent-editor-v1 --legacy-peer-deps`** 或在宿主 `.npmrc` 使用 `legacy-peer-deps=true`(上线前务必用 `npm run build` 验证,并计划去掉该放宽)。
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
2. **官方文档**:[Monaco Editor](https://github.com/microsoft/monaco-editor) 与 [@monaco-editor/react](https://github.com/suren-atoyan/monaco-react) 中的 Vite / Webpack 说明。
|
|
124
|
+
### Umi / MFSU
|
|
128
125
|
|
|
129
|
-
|
|
126
|
+
一般可直接使用。若遇预编译或模块解析异常,可在配置里将 **`wechen-agent-editor-v1`**、**`monaco-editor`**、**`@monaco-editor/react`** 加入 **`mfsu.exclude`**(见 [Umi MFSU](https://umijs.org/docs/api/config#mfsu)),删除 `.umi` 后重启;或用 **`mfsu: false`** 做对比排查。
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
import { ConfigProvider } from "antd";
|
|
133
|
-
import {
|
|
134
|
-
WechenAgentEditor,
|
|
135
|
-
type WechenAgentSnapshot,
|
|
136
|
-
} from "wechen-agent-editor-v1";
|
|
128
|
+
**依赖示例**(版本请按团队锁定,须满足本包 `peerDependencies`):
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/* 持久化 s.nodes / s.edges */
|
|
145
|
-
}}
|
|
146
|
-
onTestRun={(s) => {
|
|
147
|
-
/* 触发试运行 */
|
|
148
|
-
}}
|
|
149
|
-
/>
|
|
150
|
-
</ConfigProvider>
|
|
151
|
-
);
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"dependencies": {
|
|
133
|
+
"@monaco-editor/react": "^4.6.0",
|
|
134
|
+
"wechen-agent-editor-v1": "^1.1.0"
|
|
135
|
+
}
|
|
152
136
|
}
|
|
153
137
|
```
|
|
154
138
|
|
|
155
|
-
|
|
139
|
+
---
|
|
156
140
|
|
|
157
|
-
|
|
141
|
+
## 使用
|
|
158
142
|
|
|
159
|
-
|
|
143
|
+
### 入口与样式
|
|
160
144
|
|
|
161
|
-
|
|
145
|
+
```ts
|
|
146
|
+
import { WechenAgentEditor, type WechenAgentSnapshot } from "wechen-agent-editor-v1";
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
发布产物中 **`dist/index.js`** 会包含对 **`./style.css`** 的引用,正常情况下图样式会随主入口进入打包结果。若生产环境仍看不到 Flow 全局样式,可增加:
|
|
162
150
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
- **何时才用 `patch` 里的 `data` 键**:仅当你的业务模型里 **`node.data` 下确有名 `data` 的嵌套对象** 时,才使用 `patchNode({ data: { ... } })`;否则该写法更新的是 **`node.data.data.*`**,容易与「把整个业务 payload 放进 `data` 键」的误解混淆。
|
|
151
|
+
```ts
|
|
152
|
+
import "wechen-agent-editor-v1/style.css";
|
|
153
|
+
```
|
|
167
154
|
|
|
168
|
-
|
|
155
|
+
antd 5 为 CSS-in-JS,请用 **`ConfigProvider`** 包裹应用(与官方用法一致)。
|
|
169
156
|
|
|
170
|
-
|
|
171
|
-
- **边**:`patchEdge` 将 **`Partial<Edge>` 浅合并到边对象顶层**(如 `animated`、`label`),与节点 `data` 不是同一套模型。
|
|
157
|
+
### 嵌入尺寸、`readOnly` 与 `readingMode`
|
|
172
158
|
|
|
173
|
-
|
|
159
|
+
根组件默认 **`height` / `width` 为 `100%`**,可通过 **`className` / `style`** 透传;可选 **`minHeight`**。请保证父级链路上有**明确高度**(如 flex 子项 `flex:1` + `minHeight:0`、固定 `height` 等),否则中间画布可能无法撑满。
|
|
174
160
|
|
|
175
|
-
|
|
161
|
+
- **`readOnly`**:禁止对图的增删改(拖入、连线、删除键、拖动节点等),仍可使用平移/缩放查看。**`readOnly`** 与 **`readingMode`** 会出现在 **`renderConfigPanel` / `renderNodeConfig`** 的入参中,便于对表单设 **`disabled`**。
|
|
162
|
+
- **`readingMode`**:**仅展示中间流程画布**(隐藏顶栏与左右栏),并**禁用选中**与一切改图,适合文档内嵌、大屏预览等纯展示场景(隐含只读)。
|
|
176
163
|
|
|
177
|
-
|
|
178
|
-
- **`editorRef`**:与 `<WechenAgentEditor ref={...} />` 为 **同一 ref 对象**(推荐使用对象 `useRef`),可在自定义工具条中调用 **`getSnapshot`**、`patchNodeData`、`fitView` 等任意 ref API。挂载完成前 **`current` 可能为 `null`**,请在点击回调或 `useEffect` 内使用。
|
|
164
|
+
### 删除守卫(`onBeforeRemoveNode` / `onBeforeRemoveEdge`)
|
|
179
165
|
|
|
180
|
-
|
|
166
|
+
在可编辑模式下,可通过回调 **按节点/边粒度** 决定是否允许删除。同步返回 **`false`** 时取消该次删除(**Backspace** 与 **`ref.removeNode` / `ref.removeEdge`** 均生效)。**`readOnly` / `readingMode`** 下不调用回调。删除节点时 **级联移除** 的关联边 **不会** 逐条触发 `onBeforeRemoveEdge`。
|
|
181
167
|
|
|
182
168
|
```tsx
|
|
183
|
-
import { Button, Space } from "antd";
|
|
184
|
-
import type { WechenAgentHeaderActionsRenderContext } from "wechen-agent-editor-v1";
|
|
185
|
-
|
|
186
169
|
<WechenAgentEditor
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)}
|
|
170
|
+
onBeforeRemoveNode={(node) => {
|
|
171
|
+
// 例:禁止删除入口节点,或 data.deletable === false 的节点
|
|
172
|
+
if (node.id === "start_node") return false;
|
|
173
|
+
if (node.data?.deletable === false) return false;
|
|
174
|
+
return true;
|
|
175
|
+
}}
|
|
176
|
+
onBeforeRemoveEdge={(edge) => edge.data?.locked !== true}
|
|
195
177
|
/>
|
|
196
178
|
```
|
|
197
179
|
|
|
198
|
-
|
|
180
|
+
L1 工厂同样支持:`buildWechenAgentEditorProps({ onBeforeRemoveNode: ... })`。
|
|
199
181
|
|
|
200
|
-
|
|
182
|
+
### 四边感应区连线(默认)
|
|
201
183
|
|
|
202
|
-
|
|
203
|
-
npm install
|
|
204
|
-
npm install --prefix playground
|
|
205
|
-
npm run dev
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
浏览器打开终端提示的地址(默认 `http://localhost:5173`)。
|
|
184
|
+
内置 **`pill` / `card` / `mainAgent`** 在未使用 **`renderFlowNode`**、且未启用下文 **legacy `flowHandles`** 时,采用 **上 / 右 / 下 / 左** 周界窄条(**四条始终挂载**,无上/下连线锚点时仍保留空条带便于发现):**输入池 = 左 ∪ 上**(`target`)、**输出池 = 右 ∪ 下**(`source`);边稳定排序后 **前半入左、后半入上**,出边 **前半出右、后半出下**;**`in-new-{nodeId}`** 默认在 **左侧**,**`out-new-{nodeId}`** 在 **右侧**;角区留白避免相邻带重叠命中。透明 **`Handle`**、无固定圆点桩 UI。新边 **`sourceHandle` / `targetHandle`** 仍为 **`out-${edgeId}`** / **`in-${edgeId}`**;**`normalizeWechenAgentFlowJson`** 归一化旧桩 id,并将遗留 **`data.wechenFlowDirection: 'reverse'`** 归一为 **交换 `source`/`target`** 后清除该键。新建连线会写入 **`edge.data.wechenSourceAttachSide` / `wechenTargetAttachSide`**(默认 **右→左**),用于稳定落回感应带;亦可手写 **`top`/`bottom`** 等偏好。**`ConnectionMode.Strict`**、**`isValidConnection`**(禁自环)。默认边 **平滑阶梯 + 终点箭头**(箭头在 **target** 端)。
|
|
209
185
|
|
|
210
|
-
|
|
186
|
+
周界四向感应的 **完整方案说明(交互、角区、数据字段、代码映射)** 见仓库 **`openspec/changes/node-perimeter-sensing-scheme/design.md`**。
|
|
211
187
|
|
|
212
|
-
|
|
188
|
+
### 组件库 legacy 接线桩(`flowHandles`,可选)
|
|
213
189
|
|
|
214
|
-
|
|
190
|
+
**已弃用优先**:编排默认以 **四边感应区** 为准。**`libraryGroups`** 中每项仍可设置 **`flowHandles`** 以兼容旧版「声明桩位」:`FlowHandleSpec[]` 或 **`mode: 'even'`** 自动均分。拖入后写入 **`data.flowHandles`**;**`card` / `mainAgent`** 在 **`flowHandles` 展开非空** 时仍走声明桩渲染。**`renderFlowNode`** 自定义整节点时由宿主自行决定接线方式。类型见 **`expandFlowHandlesConfig`**、**`findComponentLibraryItem`** 等导出。
|
|
215
191
|
|
|
216
|
-
|
|
217
|
-
2. **构建**:`npm run build` 成功,生成 `dist/index.js` 与 `dist/index.d.ts`。
|
|
218
|
-
3. **打包内容**:`npm run pack:check`(即 `npm pack --dry-run`)确认仅包含 `package.json` **`files`** 声明的内容(当前为 **`dist`** 与 **`LICENSE`**),无意外把 `playground` 或源码打进包。
|
|
219
|
-
4. **测试**(建议):`npm test`(Vitest,见 `src/**/*.test.ts`)。
|
|
220
|
-
5. **版本号**:在 `package.json` 提升 **`version`**(语义化:**`MAJOR`** 不兼容 API、**`MINOR`** 向后兼容功能、**`PATCH`** 修订)。若需预览版可使用 **0.x** 或预发布标签(如 `-beta`),并在变更说明中写明。若团队维护变更说明,可同步更新 **CHANGELOG**(本仓库未强制附带该文件)。
|
|
192
|
+
### Monaco Worker
|
|
221
193
|
|
|
222
|
-
|
|
194
|
+
必须在**首次渲染编辑器之前**完成 Monaco worker 引导,否则代码编辑区无法初始化。可参考本仓库 **`playground/src/monacoBootstrap.ts`** 与 **`playground/src/main.tsx`**,并按 [Monaco](https://github.com/microsoft/monaco-editor) / [@monaco-editor/react](https://github.com/suren-atoyan/monaco-react) 文档适配 Vite 或 Webpack。
|
|
223
195
|
|
|
224
|
-
|
|
225
|
-
npm install
|
|
226
|
-
npm run build
|
|
227
|
-
npm test
|
|
228
|
-
npm run pack:check
|
|
229
|
-
```
|
|
196
|
+
### 与快速开始一致的最小页(可选 `title`)
|
|
230
197
|
|
|
231
|
-
|
|
198
|
+
与上文 **L0** 相同;若需要顶栏文案可传 **`title`**。未传 **`initialFlow`** 时为**空画布**。需要内置示例图时,从本包导入 **`defaultInitialFlow`**、**`cloneWechenAgentFlow`** 并传入 `initialFlow={cloneWechenAgentFlow(defaultInitialFlow)}`。
|
|
232
199
|
|
|
233
|
-
|
|
200
|
+
### 行为与扩展(摘要)
|
|
234
201
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
202
|
+
- **连线**:从节点的 source Handle 拖到 target Handle;选中边可在右侧调整动画与**执行方向**等。**执行方向**与 **`source` → `target`** 一致:箭头在 **目标** 端;选「反向」会 **交换源与目标**(及 handle),不再依赖仅反转 dash 的持久化字段。历史 **`edge.data.wechenFlowDirection: 'reverse'`** 在 **`normalizeWechenAgentFlowJson` / `cloneWechenAgentFlow` / `parseWechenAgentFlowJson`** 中 **幂等归一** 为交换端点并清除该键。宿主也可调用 **`swapWechenFlowEdgeEndpoints(edge)`** 得到与内置面板一致的 **`patchEdge`** 补丁。
|
|
203
|
+
- **数据合并**:节点 `data` 的更新遵循导出的 **`mergeNodeData`**(对象深度合并,数组在补丁中出现时整段替换)。`patchNode` / ref 的 **`patchNodeData`** 将补丁合并进 `node.data`;**`patchEdge`** 为边的顶层浅合并。
|
|
204
|
+
- **自定义右侧面板**:可选 **`renderConfigPanel`**(节点与连线统一入口)或 **`renderNodeConfig`**;同时存在时以 `renderConfigPanel` 为准(返回 `undefined` 时回退内置)。
|
|
205
|
+
- **顶栏按钮**:可选 **`renderHeaderActions`**,入参含与默认行为一致的 **`save`** / **`testRun`** 及 **`editorRef`**。
|
|
238
206
|
|
|
239
|
-
|
|
207
|
+
完整类型与符号列表以 **`src/index.ts`** 的导出为准。
|
|
240
208
|
|
|
241
|
-
###
|
|
209
|
+
### 集成自检
|
|
242
210
|
|
|
243
|
-
|
|
211
|
+
在宿主项目根目录建议逐项确认:
|
|
244
212
|
|
|
245
|
-
|
|
246
|
-
|
|
213
|
+
| 检查项 | 说明 |
|
|
214
|
+
|--------|------|
|
|
215
|
+
| Peer 依赖 | **`npm ls react`**、**`npm ls @xyflow/react`**(若宿主另有 Flow 代码)无意外多版本 |
|
|
216
|
+
| 构建 | **`npm run build`**(或 Umi `max build`)通过 |
|
|
217
|
+
| Monaco | 已在首屏前完成 **worker 引导**(见上文「Monaco Worker」) |
|
|
218
|
+
| 空画布 | **未传 `initialFlow`** 时中间画布无预置节点;业务示例需 **`cloneWechenAgentFlow(defaultInitialFlow)`** 或 `ref.replaceFlow(...)` 显式注入 |
|
|
219
|
+
| 烟测 | 拖入节点、四向连线、`readOnly` / `readingMode`、保存或 `getSnapshot` 取流 |
|
|
247
220
|
|
|
248
|
-
|
|
221
|
+
---
|
|
249
222
|
|
|
250
|
-
|
|
223
|
+
## 本地开发(本仓库)
|
|
251
224
|
|
|
252
225
|
```bash
|
|
253
|
-
npm
|
|
254
|
-
npm
|
|
226
|
+
npm install
|
|
227
|
+
npm install --prefix playground
|
|
228
|
+
npm run dev # 完整 playground(场景 JSON + 工具栏)
|
|
229
|
+
npm run dev:minimal # 仅最小宿主集成(对照 README「快速开始」)
|
|
255
230
|
```
|
|
256
231
|
|
|
257
|
-
|
|
232
|
+
浏览器地址以终端输出为准(默认 `http://localhost:5173`)。
|
|
258
233
|
|
|
259
|
-
|
|
234
|
+
---
|
|
260
235
|
|
|
261
|
-
|
|
262
|
-
npm publish --access public --registry https://registry.npmjs.org/
|
|
263
|
-
# 或(项目脚本,已含上述 registry)
|
|
264
|
-
npm run release
|
|
265
|
-
```
|
|
236
|
+
## 维护者:发版
|
|
266
237
|
|
|
267
|
-
|
|
238
|
+
### 1.1.0(相对 npm 线上 **1.0.8**)
|
|
268
239
|
|
|
269
|
-
|
|
270
|
-
npm run registry:show # 查看当前默认 registry
|
|
271
|
-
npm run registry:npmjs # 手动切到 npm 官方(仅改默认 registry,可选)
|
|
272
|
-
npm run registry:npmmirror # 切回 npmmirror(装依赖常用)
|
|
273
|
-
npm run release:cn # 发布到官方(脚本内已固定 registry)→ 成功后再切回 npmmirror
|
|
274
|
-
```
|
|
240
|
+
**新增(向后兼容)**
|
|
275
241
|
|
|
276
|
-
|
|
242
|
+
- **`onBeforeRemoveNode` / `onBeforeRemoveEdge`**:删除前宿主守卫,按节点/边粒度允许或拒绝删除(键盘与 `ref.removeNode` / `ref.removeEdge` 均生效)
|
|
243
|
+
- **`buildWechenAgentEditorProps`**(L1 宿主聚合配置)及 **`exportBackendWorkflowJson` / `importBackendWorkflowToFlow`**(后端 DTO 转换)等已在仓库合入、文档化的能力
|
|
277
244
|
|
|
278
|
-
|
|
279
|
-
npm view wechen-agent-editor-v1 version
|
|
280
|
-
```
|
|
245
|
+
### 发版清单
|
|
281
246
|
|
|
282
|
-
|
|
247
|
+
1. 确认 `package.json` **`version`** 已 bump(当前 **1.1.0**)。
|
|
248
|
+
2. 执行 **`npm install`**(同步 lock)→ **`npm run release:prep`**(`test` + `build` + `pack:check` + playground build),或分步执行。
|
|
249
|
+
3. **`npm whoami`** 确认已登录 **registry.npmjs.org**;scoped 包首次发布需 **`--access public`**(`publishConfig` 已配置)。
|
|
250
|
+
4. 执行 **`npm run release`**(或 `npm publish`),发后验证:
|
|
283
251
|
|
|
284
252
|
```bash
|
|
285
|
-
npm
|
|
253
|
+
npm view wechen-agent-editor-v1 version
|
|
254
|
+
npm pack --dry-run # 确认 tarball 仅含 dist、LICENSE
|
|
286
255
|
```
|
|
287
256
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
发版前建议将 `package.json` 中 **`repository` / `bugs` / `homepage`** 里的占位地址(如 `your-org/wechen-agent`)替换为 **真实 Git 仓库** URL,便于 npm 页面展示与问题反馈。**占位未替换时** npm 项目页上的「仓库」链接不可用,建议在 **对外公开发布前** 完成替换。
|
|
291
|
-
|
|
292
|
-
## 技术说明
|
|
257
|
+
5. 在空目录烟测:`npm install wechen-agent-editor-v1@1.1.0`,`import { WechenAgentEditor } from "wechen-agent-editor-v1"`。
|
|
293
258
|
|
|
294
|
-
|
|
295
|
-
- **`sideEffects`**:`package.json` 声明 **`./dist/index.js`** 与 **`./dist/style.css`**,避免宿主误摇树掉 **入口 JS 对同目录 CSS 的 `import`**,导致 **生产包样式丢失**。
|
|
296
|
-
- 组件库条目拖入画布时,使用 MIME `application/reactflow` 与载荷前缀 `scope:"wechen-agent"`;宿主可 import `WECHEN_AGENT_FLOW_DRAG_MIME` 与编解码函数以对齐自定义侧栏。
|
|
297
|
-
- 顶栏 **保存** / **测试运行** 通过 `onSave`、`onTestRun` 传出 `WechenAgentSnapshot`:`flow` 为与 `initialFlow` 同形的 **完整对象**(推荐);`flowJson` 为兼容用字符串。
|
|
298
|
-
- 画布 **Controls** 使用 `showInteractive={false}` 时隐藏「锁定交互」开关,**缩放 / 适应视图** 仍可用。
|
|
259
|
+
发版前可将 `repository` / `bugs` / `homepage` 中的占位 URL 换成真实仓库地址。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { ComponentLibraryGroup, WechenAgentComponentLibraryList } from './config/componentLibraryConfig';
|
|
3
|
-
import { WechenAgentEditorRef, WechenAgentFlowJson, WechenAgentHeaderActionsRenderContext, WechenAgentSnapshot } from './flowTypes';
|
|
3
|
+
import { WechenAgentEditorRef, WechenAgentFlowJson, WechenAgentHeaderActionsRenderContext, WechenAgentSnapshot, WechenBeforeRemoveEdgeFn, WechenBeforeRemoveNodeFn } from './flowTypes';
|
|
4
4
|
import { WechenAgentRenderFlowNodeFn } from './WechenAgentEditorContext';
|
|
5
5
|
import { WechenAgentRenderNodeConfigFn } from './panels/NodeConfigPanel';
|
|
6
6
|
import { WechenAgentRenderConfigPanelFn } from './wechenAgentConfigPanel';
|
|
@@ -46,6 +46,33 @@ export interface WechenAgentEditorProps {
|
|
|
46
46
|
onSave?: (snapshot: WechenAgentSnapshot) => void;
|
|
47
47
|
/** 测试运行:收到与 `onSave` 同形的 `WechenAgentSnapshot`;具体执行由宿主实现(可为试运行 / 调试) */
|
|
48
48
|
onTestRun?: (snapshot: WechenAgentSnapshot) => void;
|
|
49
|
+
/**
|
|
50
|
+
* 删除节点前回调;同步返回 **`false`** 时取消该次删除(键盘 Backspace 与 `ref.removeNode` 均生效)。
|
|
51
|
+
* 删除节点时 **级联移除** 的关联边 **不会** 逐条触发 `onBeforeRemoveEdge`。
|
|
52
|
+
* `readOnly` / `readingMode` 下 **不调用** 本回调。
|
|
53
|
+
*/
|
|
54
|
+
onBeforeRemoveNode?: WechenBeforeRemoveNodeFn;
|
|
55
|
+
/**
|
|
56
|
+
* 删除边前回调;同步返回 **`false`** 时取消该次删除(键盘与 `ref.removeEdge` 均生效)。
|
|
57
|
+
* `readOnly` / `readingMode` 下 **不调用** 本回调。
|
|
58
|
+
*/
|
|
59
|
+
onBeforeRemoveEdge?: WechenBeforeRemoveEdgeFn;
|
|
60
|
+
/**
|
|
61
|
+
* 为真时禁止对图的增删改(拖入、连线、删除键、拖动节点等);仍允许平移/缩放。
|
|
62
|
+
* 标志会传入 `renderConfigPanel` / `renderNodeConfig` 便于禁用表单。
|
|
63
|
+
*/
|
|
64
|
+
readOnly?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 为真时仅渲染中间画布(隐藏顶栏与左右栏),并禁用选中与一切改图;用于纯流程展示。
|
|
67
|
+
* 隐含只读语义,且 `readOnly`/`readingMode` 会一并传入回调 context。
|
|
68
|
+
*/
|
|
69
|
+
readingMode?: boolean;
|
|
70
|
+
/** 根布局可选最小高度;不传则不设置,便于由父容器 `height:100%` 填满 */
|
|
71
|
+
minHeight?: number | string;
|
|
72
|
+
/** 透传根 `Layout` 的 `className` */
|
|
73
|
+
className?: string;
|
|
74
|
+
/** 透传根 `Layout` 的 `style`(在默认宽高之后合并,便于覆盖) */
|
|
75
|
+
style?: CSSProperties;
|
|
49
76
|
}
|
|
50
77
|
export declare const WechenAgentEditor: import('react').ForwardRefExoticComponent<WechenAgentEditorProps & import('react').RefAttributes<WechenAgentEditorRef>>;
|
|
51
78
|
//# sourceMappingURL=WechenAgentEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WechenAgentEditor.d.ts","sourceRoot":"","sources":["../src/WechenAgentEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WechenAgentEditor.d.ts","sourceRoot":"","sources":["../src/WechenAgentEditor.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAa,SAAS,EAAa,MAAM,OAAO,CAAC;AAe5E,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAChC,MAAM,iCAAiC,CAAC;AA0BzC,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,qCAAqC,EACrC,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAU/E,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,yDAAyD;IACzD,aAAa,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACxC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CACxB,IAAI,EAAE,+BAA+B,KAClC,+BAA+B,CAAC;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,2BAA2B,CAAC;IAC7C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,qCAAqC,KAAK,SAAS,CAAC;IAChF,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjD,wEAAwE;IACxE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACpD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;IAC9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAmkBD,eAAO,MAAM,iBAAiB,yHAyE7B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WechenAgentFlowJson, WechenAgentSnapshot } from './flowTypes';
|
|
2
|
+
/**
|
|
3
|
+
* 本包定义的「后端工作流 DTO」schema 版本;导入时 **必须** 一致,否则抛错(便于后端演进分支)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const WECHEN_BACKEND_WORKFLOW_SCHEMA_VERSION = "1";
|
|
6
|
+
/** 后端节点类型(与常见低代码「节点 + config」形态对齐;可扩展)。 */
|
|
7
|
+
export type WechenBackendWorkflowNodeType = "start" | "agent" | "task" | "condition" | "api" | "script";
|
|
8
|
+
export interface WechenBackendWorkflowNode {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: WechenBackendWorkflowNodeType;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
/** 执行侧参数;由导出映射写入,导入时再映射回 `node.data` */
|
|
15
|
+
config: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface WechenBackendWorkflowEdge {
|
|
18
|
+
source: string;
|
|
19
|
+
target: string;
|
|
20
|
+
/** 未给出时导出为 `"default"` */
|
|
21
|
+
condition?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 建议持久化 / POST 给后端的 JSON 形状(与内部 `WechenAgentFlowJson` 解耦)。
|
|
25
|
+
*
|
|
26
|
+
* **有损说明(导出)**:不携带 React Flow 运行期字段(`measured` 等)、不携带完整 `style` / 自定义 `node.style`;
|
|
27
|
+
* `edge` 上除 `source`/`target`/`id`/`animated`/`label` 外的部分字段可能丢失,详见 README。
|
|
28
|
+
*
|
|
29
|
+
* **有损说明(导入)**:新建边的 `sourceHandle`/`targetHandle` 按边 `id` 规范化;`animated`/`style` 等默认简化。
|
|
30
|
+
*/
|
|
31
|
+
export interface WechenBackendWorkflowJson {
|
|
32
|
+
schemaVersion: string;
|
|
33
|
+
flowId: string;
|
|
34
|
+
flowName: string;
|
|
35
|
+
/** 业务上的流程定义版本(如 `"1.0"`),与 `schemaVersion` 不同 */
|
|
36
|
+
version?: string;
|
|
37
|
+
createTime?: string;
|
|
38
|
+
nodes: WechenBackendWorkflowNode[];
|
|
39
|
+
edges: WechenBackendWorkflowEdge[];
|
|
40
|
+
}
|
|
41
|
+
export interface BackendWorkflowExportMeta {
|
|
42
|
+
flowId: string;
|
|
43
|
+
flowName?: string;
|
|
44
|
+
workflowVersion?: string;
|
|
45
|
+
createTime?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 将编辑器当前快照(或 `WechenAgentFlowJson`)导出为后端 DTO。
|
|
49
|
+
*/
|
|
50
|
+
export declare function exportBackendWorkflowJson(input: WechenAgentSnapshot | WechenAgentFlowJson, meta: BackendWorkflowExportMeta): WechenBackendWorkflowJson;
|
|
51
|
+
/**
|
|
52
|
+
* 将后端 DTO 还原为 `WechenAgentFlowJson`,用于 `initialFlow` / `replaceFlow`。
|
|
53
|
+
*/
|
|
54
|
+
export declare function importBackendWorkflowToFlow(dto: WechenBackendWorkflowJson): WechenAgentFlowJson;
|
|
55
|
+
/** 运行时轻量校验(不替代 JSON Schema 服务端校验)。 */
|
|
56
|
+
export declare function isWechenBackendWorkflowJson(value: unknown): value is WechenBackendWorkflowJson;
|
|
57
|
+
//# sourceMappingURL=backendWorkflowJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backendWorkflowJson.d.ts","sourceRoot":"","sources":["../src/backendWorkflowJson.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAI/G;;GAEG;AACH,eAAO,MAAM,sCAAsC,MAAM,CAAC;AAE1D,2CAA2C;AAC3C,MAAM,MAAM,6BAA6B,GACrC,OAAO,GACP,OAAO,GACP,MAAM,GACN,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAEb,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,6BAA6B,CAAC;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,yBAAyB,EAAE,CAAC;IACnC,KAAK,EAAE,yBAAyB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA4HD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,EAChD,IAAI,EAAE,yBAAyB,GAC9B,yBAAyB,CAY3B;AAiDD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,yBAAyB,GAAG,mBAAmB,CAgB/F;AAED,sCAAsC;AACtC,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,yBAAyB,CAyC9F"}
|