@huanban/rulego-editor-vue 1.3.17 → 1.4.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 (49) hide show
  1. package/README.md +306 -10
  2. package/dist/components/AIAssistant.vue.d.ts +6 -7
  3. package/dist/components/ComponentSidebar.vue.d.ts +16 -1
  4. package/dist/components/ContextMenu.vue.d.ts +21 -2
  5. package/dist/components/CopilotChat.vue.d.ts +68 -43
  6. package/dist/components/DataViewDialog.vue.d.ts +0 -1
  7. package/dist/components/DebugPanel.vue.d.ts +5 -3
  8. package/dist/components/DynamicForm.vue.d.ts +18 -77
  9. package/dist/components/EdgePropertyDrawer.vue.d.ts +0 -1
  10. package/dist/components/EditorConnectionStatus.vue.d.ts +45 -0
  11. package/dist/components/EditorEdgeHoverTools.vue.d.ts +50 -0
  12. package/dist/components/EditorIcon.d.ts +29 -0
  13. package/dist/components/EditorNodeHoverTools.vue.d.ts +58 -0
  14. package/dist/components/EditorPanelDock.vue.d.ts +65 -0
  15. package/dist/components/EditorStatusBar.vue.d.ts +68 -0
  16. package/dist/components/EditorToolbar.vue.d.ts +2 -1
  17. package/dist/components/ImportExportDialog.vue.d.ts +1 -2
  18. package/dist/components/LogViewer.vue.d.ts +29 -52
  19. package/dist/components/MiniMap.vue.d.ts +1 -2
  20. package/dist/components/NodePropertyDrawer.vue.d.ts +19 -30
  21. package/dist/components/ProblemsPanel.vue.d.ts +55 -0
  22. package/dist/components/RuleChainSettings.vue.d.ts +0 -1
  23. package/dist/components/RuleGoEditor.d.ts +122 -17
  24. package/dist/components/RuleMaintenancePanel.vue.d.ts +0 -1
  25. package/dist/components/SearchPanel.vue.d.ts +0 -1
  26. package/dist/components/SearchableSelect.vue.d.ts +6 -7
  27. package/dist/components/ToolSchemaEditor.vue.d.ts +0 -1
  28. package/dist/components/ValidationPanel.vue.d.ts +0 -1
  29. package/dist/components/WorkflowExplorer.vue.d.ts +108 -0
  30. package/dist/components/WorkflowInfoPanel.vue.d.ts +6 -25
  31. package/dist/components/WorkflowList.vue.d.ts +36 -34
  32. package/dist/components/WorkspaceTabs.vue.d.ts +52 -0
  33. package/dist/components/properties/AgentOrchestrationProperties.vue.d.ts +2 -1
  34. package/dist/composables/useClipboard.d.ts +2 -39
  35. package/dist/composables/useEditorCore.d.ts +0 -66
  36. package/dist/composables/useEditorI18n.d.ts +0 -35
  37. package/dist/composables/useEditorInstance.d.ts +17 -0
  38. package/dist/composables/useEditorPanels.d.ts +24 -0
  39. package/dist/composables/useEditorShell.d.ts +36 -0
  40. package/dist/composables/useEditorTheme.d.ts +0 -32
  41. package/dist/composables/useEditorWorkspace.d.ts +26 -0
  42. package/dist/composables/useKeyboardShortcuts.d.ts +4 -1
  43. package/dist/i18n.d.ts +6 -4
  44. package/dist/index.cjs +19 -0
  45. package/dist/index.d.ts +45 -42
  46. package/dist/index.esm.js +8043 -4432
  47. package/dist/style.css +1 -1
  48. package/package.json +14 -9
  49. package/dist/index.cjs.js +0 -16
package/README.md CHANGED
@@ -8,10 +8,12 @@
8
8
  ## ✨ 特性
9
9
 
10
10
  - **开箱即用** — 提供 `<RuleGoEditor />` 组件,一行代码嵌入编辑器
11
- - **Vue 3 Composables** — `useEditorCore`、`useEditorTheme`、`useEditorI18n`
12
- - **事件监听** — 支持 `@node-click`、`@ready`、`@change` 等 Vue 事件;保存接管通过 `options.onSave`
11
+ - **Vue 3 Composables** — `useEditorCore`、`useEditorWorkspace`、`useEditorDock`、`useEditorPanels`、`useServerStatus`、`useConnectionStatus`、`useEditorTheme`、`useEditorI18n`
12
+ - **事件监听** — 支持 `@node-click`、`@ready`、`@change` 等 Vue 事件;保存观察使用 `@save`,保存接管通过 `options.saveMode + saveHandler`
13
13
  - **完整内置 UI** — 工具栏、侧边栏、属性抽屉、设置、AI 助理、运行调试由 core 统一提供
14
+ - **大列表性能** — 组件侧栏对超大分类使用固定行高虚拟窗口,搜索和拖拽行为保持不变
14
15
  - **独立管理组件** — `WorkflowList` / `WorkflowInfoPanel` 可组合出列表、详情和编辑器联动页面
16
+ - **独立 AI 对话组件** — `CopilotChat` 可单独引用,支持流式响应、停止、思考过程和宿主持久化
15
17
  - **响应式状态** — 所有状态自动转为 Vue `ref`,模板中直接使用
16
18
  - **TypeScript** — 完整类型定义
17
19
  - **兼容 Vue 3.2+** — 支持 Composition API
@@ -19,12 +21,12 @@
19
21
  ## 📦 安装
20
22
 
21
23
  ```bash
22
- npm install @huanban/rulego-editor-vue @huanban/rulego-editor-core
23
-
24
- # 可选:安装内置 UI 组件
25
- npm install @huanban/rulego-editor-ui
24
+ npm install @huanban/rulego-editor-vue
26
25
  ```
27
26
 
27
+ `@huanban/rulego-editor-core` 和 `@huanban/rulego-editor-ui` 是 Vue 包的正式运行依赖,
28
+ 包管理器会自动安装。只有直接使用它们的独立 API 时才需要在宿主清单中显式声明。
29
+
28
30
  ## 🚀 快速开始
29
31
 
30
32
  ### 方式一:使用 `<RuleGoEditor />` 组件
@@ -64,6 +66,31 @@ const onChange = () => console.log('画布已变更')
64
66
  </script>
65
67
  ```
66
68
 
69
+ ### 独立 `CopilotChat`
70
+
71
+ `CopilotChat` 不依赖 `<RuleGoEditor />`,可以放在宿主自己的右侧 AI 面板或业务页面中。
72
+ 默认只保留内存会话;需要刷新恢复时显式传入宿主管理的 `persistence`:
73
+
74
+ ```vue
75
+ <CopilotChat
76
+ rule-chain-id="orders"
77
+ :api-base="apiBase"
78
+ model="gpt-5.4-mini"
79
+ :fetch-headers="() => ({ Authorization: `Bearer ${token}` })"
80
+ :persistence="{
81
+ adapter: {
82
+ getItem: key => localStorage.getItem(key),
83
+ setItem: (key, value) => localStorage.setItem(key, value),
84
+ removeItem: key => localStorage.removeItem(key),
85
+ },
86
+ namespace: { host: 'orders-app', editorInstance: 'customer-copilot', version: 'v1' },
87
+ }"
88
+ />
89
+ ```
90
+
91
+ 持久化 key 按 `host/editorInstance/version/chainId/component` 隔离;不传
92
+ `persistence` 时组件仍调用宿主提供的真实 OpenAI 兼容接口,但刷新后不恢复历史。
93
+
67
94
  ### 方式二:使用 `useEditorCore` Composable
68
95
 
69
96
  ```vue
@@ -93,6 +120,7 @@ watch(isReady, (ready) => {
93
120
  | `data` | `RuleChainData \| null` | 规则链数据 |
94
121
  | `components` | `RawComponentData` | 组件列表,可不传;有 `options.apiBase` 时会自动请求 `/components` |
95
122
  | `options` | `Partial<HuanbanRulegoEditorOptions>` | 透传 core 配置,如 `apiBase/fetchHeaders/onSettingsSubmit/onLoginClick` |
123
+ | `enableConnectionStatus` | `boolean` | 开启真实规则链节点、endpoint 和共享节点连接状态轮询,默认关闭 |
96
124
  | `height` | `string \| number` | 编辑器高度,默认 `100%` |
97
125
  | `width` | `string \| number` | 编辑器宽度,默认 `100%` |
98
126
  | `theme` | `string` | 主题名称 |
@@ -109,7 +137,94 @@ watch(isReady, (ready) => {
109
137
  | `@ready` | — | 编辑器就绪时触发 |
110
138
  | `@change` | — | 画布数据变化 |
111
139
  | `@edge-click` | `EdgeData` | 连线点击 |
112
- | `@deploy` | `chainId, action` | 部署/下线/重载;部署对应 `start`,下线对应 `stop` |
140
+ | `@deploy` | `chainId, action` | 部署/下线;后端动作严格对应 `start/stop` |
141
+ | `@restart` | `chainId` | 重启;与 `operate` 分离,内置流程读取服务端 DSL 后原样保存 |
142
+ | `@connection-status-change` | `ConnectionStatusState` | 当前 Core 节点/共享节点连接状态变化,不增加轮询 |
143
+
144
+ 在 `options.showRestartButton=true` 时显示重启入口。重启会重建节点实例,内存会话、
145
+ 计数器、定时器等瞬态状态会重置,端点连接可能短暂重连。宿主使用 `options.onRestart`
146
+ 接管时也必须执行 `GET /rules/:id` 后原样 `POST /rules/:id`,不得调用 `operate/reload`。
147
+ `options.showReloadButton` 只作为弃用兼容别名保留。
148
+
149
+ `enableConnectionStatus` 默认关闭。开启后,编辑器实例按当前规则链串行请求
150
+ `GET {apiBase}/rules/:id/status`,共享节点管理面板打开期间按引用请求
151
+ `GET {apiBase}/shared-node-statuses`。Vue 适配层不会额外创建轮询器;可通过组件 ref 暴露的
152
+ 方法控制同一个 standalone 实例:
153
+
154
+ ```ts
155
+ editorRef.value?.refreshConnectionStatuses()
156
+ const release = editorRef.value?.acquireSharedConnectionStatuses()
157
+ // 关闭共享节点管理面板时释放本次引用。
158
+ release?.()
159
+ ```
160
+
161
+ 宿主需要在自定义 UI 中响应式展示状态时,主组件直接监听变更事件:
162
+
163
+ ```vue
164
+ <RuleGoEditor
165
+ ref="editorRef"
166
+ :enable-connection-status="true"
167
+ @connection-status-change="connectionState = $event"
168
+ />
169
+ ```
170
+
171
+ 自定义组合层已经持有 `ConnectionStatusStore` 时,可使用
172
+ `useConnectionStatus({ connectionStatus: hostStore })` 订阅同一个 store。composable 不创建请求;
173
+ 未传 store 时只返回空状态。
174
+
175
+ 状态接口返回 `401/403` 时会暂停对应轮询并交给宿主认证流程,`404/501` 表示后端未提供能力
176
+ 并停止探测,网络错误只标记状态可能已过期,不会伪造在线状态。连接状态是运行时展示数据,
177
+ 不会写入 LogicFlow history、节点复制结果、DSL 导出或保存 payload。
178
+
179
+ ### 命令式加载与工作区 Tab
180
+
181
+ 组件 `ref` 暴露的命令式 API 会复用当前 `HuanbanRulegoEditor`,不会因为加载或切换
182
+ Tab 重建 LogicFlow:
183
+
184
+ ```vue
185
+ <script setup lang="ts">
186
+ import { ref } from 'vue'
187
+ import {
188
+ RuleGoEditor,
189
+ type RuleGoEditorRef,
190
+ } from '@huanban/rulego-editor-vue'
191
+
192
+ const editorRef = ref<RuleGoEditorRef | null>(null)
193
+
194
+ function loadRemote(remoteChain: any) {
195
+ // 新远程数据或导入数据:建立新的已保存基线。
196
+ editorRef.value?.loadData(remoteChain)
197
+ }
198
+
199
+ function restoreDraft(tabDraft: any) {
200
+ // 恢复当前 Tab 草稿:保留 savedData、dirty 标记和 JSON diff。
201
+ editorRef.value?.loadData(tabDraft, { preserveWorkspaceTab: true })
202
+ }
203
+
204
+ function activateTab(tabId: string) {
205
+ // Tab 不存在时返回 false。
206
+ return editorRef.value?.activateWorkspaceTab(tabId) ?? false
207
+ }
208
+ </script>
209
+
210
+ <template>
211
+ <RuleGoEditor ref="editorRef" :options="editorOptions" :data="ruleChainData" />
212
+ </template>
213
+ ```
214
+
215
+ `preserveWorkspaceTab` 只用于恢复当前已有 Tab 的草稿。首次加载、新建远程规则链或
216
+ 导入 clean 快照时不要开启。确实需要同时打开同一 `chainId` 的多个工作副本时,显式
217
+ 传 `{ allowDuplicateWorkspaceTab: true }`。
218
+
219
+ 自定义工作台隐藏内置工具栏时,可以直接打开组件管理的指定页签:
220
+
221
+ ```ts
222
+ editorRef.value?.openComponentManager('shared')
223
+ ```
224
+
225
+ 页签类型为 `ComponentManageDialogTab`,可选 `installed` / `market` / `dsl` /
226
+ `shared`。设置 `options.onComponentManage` 接管弹窗时,`component-manage` 事件和宿主回调都会
227
+ 收到同一个初始页签;未接管时使用 Core 内置管理器,不会在 Vue 层创建第二套请求或状态轮询。
113
228
 
114
229
  ### 保存协议
115
230
 
@@ -122,12 +237,14 @@ GET {apiBase}/rules/:id
122
237
 
123
238
  第二次 `GET` 用于回读校验,只有后端返回的数据与当前画布一致时才会显示已保存。
124
239
 
125
- 只有宿主确实要完全接管保存时才在 `options` 中传 `onSave`。接管后必须返回明确结果:
240
+ 只有宿主确实要完全接管保存时才在 `options` 中设置 `saveMode: 'host'` 并传
241
+ `saveHandler`。执行器必须返回明确结果:
126
242
 
127
243
  ```ts
128
244
  const editorOptions = computed(() => ({
129
245
  apiBase: apiBase.value,
130
- onSave: async (data: any) => {
246
+ saveMode: 'host' as const,
247
+ saveHandler: async (data: any) => {
131
248
  const id = data?.ruleChain?.id
132
249
  const response = await fetch(`${apiBase.value}/rules/${encodeURIComponent(id)}`, {
133
250
  method: 'POST',
@@ -139,12 +256,52 @@ const editorOptions = computed(() => ({
139
256
  }))
140
257
  ```
141
258
 
142
- 单纯监听 `@save` 不再短路内置保存。只想打印日志或观察画布变化时,请使用 `@change`、`@node-click` 或浏览器调试日志。
259
+ 单纯监听 `@save` 只观察保存请求,不会短路内置保存。不要在 `@save` 中再次 POST,
260
+ 否则会和内置保存重复。旧版 `options.onSave` 仍兼容宿主执行器,但新接入应使用明确的
261
+ `saveMode + saveHandler` 合同。
143
262
 
144
263
  ### `<WorkflowList />` 管理列表
145
264
 
146
265
  `WorkflowList` 是独立管理组件,不是编辑器。它负责查询、搜索、创建、部署/下线、复制、删除和选择规则链;进入画布编辑需要通过 `:on-design` 切换到 `<RuleGoEditor />`。
147
266
 
267
+ 工作流列表的内置请求层支持宿主管理的认证和服务状态:
268
+
269
+ ```vue
270
+ <WorkflowList
271
+ :api-base="apiBase"
272
+ :api-options="{
273
+ headers: () => ({ Authorization: `Bearer ${readToken()}` }),
274
+ credentials: 'include',
275
+ onAuthRequired: ({ status }) => host.openLogin({ reason: status }),
276
+ serverStatus,
277
+ }"
278
+ :on-error="showRequestError"
279
+ />
280
+ ```
281
+
282
+ 默认兼容浏览器 `token`/`access_token`;纯 Cookie 接入设置
283
+ `includeStoredToken: false`。HTTP 401 表示凭据缺失或失效,宿主应打开登录流程并清理失效凭据;
284
+ HTTP 403 表示凭据有效但权限不足,保留当前凭据并显示权限提示;网络失败和超时会通过
285
+ `:on-error` 暴露为离线或请求失败,不能被当成空列表。Vue 只会替换列表请求层,不会因为认证配置变化重建编辑器画布。
286
+
287
+ ### 结构性配置与重建边界
288
+
289
+ `lfOptions`、`lfPlugins` 和 `persistence` 在编辑器实例创建时绑定,属于结构性配置。
290
+ 它们不会被普通 prop 更新热替换;`updateOptions()` 返回的 `structuralKeys` 会明确列出这类变更。
291
+ 宿主应先保存或处理 dirty 状态,再改变 Vue 的原生 `key`,让组件完整销毁并重建:
292
+
293
+ ```vue
294
+ <RuleGoEditor
295
+ :key="`${editorInstanceId}:${structuralConfigVersion}`"
296
+ :options="{ lfOptions, lfPlugins, persistence }"
297
+ :data="chainData"
298
+ />
299
+ ```
300
+
301
+ 不要用每次 render 都新建的对象内容作为 `key`,否则会造成画布闪屏、焦点丢失和未保存数据风险。
302
+ 普通 API、主题、语言、显示开关和回调仍走热更新,不应为了这些选项重建画布。React 和 standalone
303
+ 使用同一边界契约。
304
+
148
305
  ```vue
149
306
  <template>
150
307
  <section class="workspace">
@@ -184,6 +341,7 @@ async function openEditor(id: string) {
184
341
  | `autoOpenAfterCreate` | 传了 `onDesign` 时默认开启;新建成功后自动进入编辑器 |
185
342
  | `onDesign` | 双击卡片或点击菜单“设计”时触发,宿主在这里打开编辑器 |
186
343
  | `onInfo` | 单击卡片或点击菜单“信息”时触发,宿主在这里联动详情 |
344
+ | `onViewLogs` | 点击“日志”时触发,参数为 `(chainId, workflow?)`;第二个参数是当前列表接口返回的真实工作流对象 |
187
345
 
188
346
  默认新建弹窗包含 ID、名称、主链/子链、初始状态、调试模式、分类、描述。ID 自动生成,也可手动输入;为兼容后台路由,ID 不能包含 `/`、`\` 或 `.`。
189
347
 
@@ -239,6 +397,144 @@ const editorOptions = computed(() => ({
239
397
  | `save` | `() => void` | 触发保存 |
240
398
  | `on` | `(event, handler) => void` | 监听事件 |
241
399
 
400
+ ### 工作区、Dock 和服务状态 Composables
401
+
402
+ 需要自己搭建工作台时,使用这些 composable。它们只负责 Vue 响应式桥接,Tab、dirty
403
+ 草稿、关闭确认、尺寸限制和 401/1006 状态都由 `editor-core` 统一管理。
404
+
405
+ ```ts
406
+ import {
407
+ useEditorWorkspace,
408
+ useEditorDock,
409
+ useServerStatus,
410
+ useConnectionStatus,
411
+ } from '@huanban/rulego-editor-vue'
412
+
413
+ const { tabs, activeTab, openTab, closeTab } = useEditorWorkspace()
414
+ const { state: dockState, setDockWidth } = useEditorDock()
415
+ const { state: serverState, recordHttpStatus, recordWebSocketStatus } = useServerStatus({
416
+ baseUrl: 'http://127.0.0.1:19806',
417
+ })
418
+ // 已持有主编辑器的 Core store 时使用;这里只订阅,不创建轮询。
419
+ const { state: connectionState } = useConnectionStatus({ connectionStatus: hostConnectionStatus })
420
+ ```
421
+
422
+ ### 独立工作区 Tab
423
+
424
+ 需要自己组合多规则链工作台时,可以使用 `WorkspaceTabs`。它只负责渲染
425
+ `EditorWorkspace` 状态,保存、关闭确认和后端请求仍由宿主处理:
426
+
427
+ ```vue
428
+ <script setup lang="ts">
429
+ import { WorkspaceTabs, useEditorWorkspace } from '@huanban/rulego-editor-vue'
430
+ import '@huanban/rulego-editor-vue/style.css'
431
+
432
+ const workspace = useEditorWorkspace()
433
+ </script>
434
+
435
+ <template>
436
+ <WorkspaceTabs
437
+ :tabs="workspace.tabs.value"
438
+ :active-tab-id="workspace.activeTab.value?.id"
439
+ @activate="workspace.activateTab"
440
+ @close="workspace.closeTab"
441
+ @add="() => workspace.openTab({ title: '新规则链' })"
442
+ @edit-info="openRuleChainInfo"
443
+ :on-tab-action="(tabId, action) => {
444
+ if (action === 'rename') openRuleChainInfo(tabId)
445
+ if (action === 'run-history') openRunHistory(tabId)
446
+ if (action === 'debug') openDebugPanel(tabId)
447
+ if (action === 'toggle-disabled') toggleChainDisabled(tabId)
448
+ }"
449
+ />
450
+ </template>
451
+ ```
452
+
453
+ Tab 组件会显示主链/子链、加载状态、未保存标记和溢出选择菜单,不会重新创建
454
+ 画布,也不会绕过宿主的保存和权限策略。组件同时发出 `tab-action` 事件,稳定动作
455
+ ID 为 `rename`、`toggle-disabled`、`run-history`、`debug`;动作对应的真实保存、
456
+ `start`/`stop` 请求、登录和错误反馈仍由宿主处理。
457
+
458
+ `serverState.value.api` 与 `serverState.value.ws` 独立更新。收到 401/403 时展示登录
459
+ 入口,收到 WS 1006 时展示实时连接断开和重连入口,不会把两种问题混成同一个状态。
460
+
461
+ ### 独立状态栏与连接状态
462
+
463
+ 需要自己组合编辑器外壳时,可以复用 `EditorStatusBar` 和
464
+ `EditorConnectionStatus`。组件只消费宿主传入的 LogicFlow/Core 状态,不自行请求、
465
+ 重连或登录;服务端动作由宿主回调接管:
466
+
467
+ ```vue
468
+ <EditorConnectionStatus
469
+ :state="serverState"
470
+ :on-login="openLogin"
471
+ :on-retry="checkConnection"
472
+ />
473
+ <EditorStatusBar
474
+ :lf="editorRef?.lf"
475
+ :problem-count="problems.length"
476
+ :on-open-diagnostics="openDiagnostics"
477
+ @open-diagnostics="openDiagnostics"
478
+ />
479
+ ```
480
+
481
+ `EditorConnectionStatus` 分别显示 API 与 WS 状态,`EditorStatusBar` 提供缩放、节点
482
+ 数、边数、选中数和诊断入口。未传 `on-login`/`on-retry` 时,Vue 组件会发出对应事件,
483
+ 方便宿主接入自己的认证和重试流程。
484
+
485
+ ### 独立 Dock 面板
486
+
487
+ `EditorPanelDock` 只渲染 `EditorPanelRegistry` / `EditorDockStore` 的状态,支持左侧
488
+ 堆叠、右侧/底部/AI Tab、关闭和拖动尺寸;面板内容通过命名 slot 提供:
489
+
490
+ ```vue
491
+ <EditorPanelDock
492
+ dock="right"
493
+ :dock-state="dockState"
494
+ :panel-state="panelsState"
495
+ @activate-panel="panels.activatePanel"
496
+ @close-panel="panels.closePanel"
497
+ @toggle-dock="(_, visible) => dock.setDockVisibility('right', visible)"
498
+ :on-resize="(id, size) => dock.setDockWidth(id, size)"
499
+ >
500
+ <template #panel-info><InfoPanel /></template>
501
+ <template #panel-node-config><NodeConfigPanel /></template>
502
+ </EditorPanelDock>
503
+ ```
504
+
505
+ 组件不自行保存、请求或创建面板状态;Vue 宿主可以继续使用自己的设置、AI、登录和
506
+ 客服测试页面,而不会把场景模块混入编辑器包。
507
+
508
+ ### 节点与连线悬浮工具
509
+
510
+ `EditorNodeHoverTools` 和 `EditorEdgeHoverTools` 接收宿主计算的目标 ID 与画布坐标,
511
+ 负责统一渲染编辑、复制、执行、插入和删除按钮,并通过回调或 `action` 事件转发:
512
+
513
+ ```vue
514
+ <EditorNodeHoverTools
515
+ :target-id="selectedNode.id"
516
+ :x="toolbarPosition.x"
517
+ :y="toolbarPosition.y"
518
+ :on-edit="openNodeEditor"
519
+ :on-delete="confirmDeleteNode"
520
+ :on-run-from="openRunPanel"
521
+ />
522
+ <EditorEdgeHoverTools
523
+ :target-id="selectedEdge.id"
524
+ :x="edgePosition.x"
525
+ :y="edgePosition.y"
526
+ :on-insert-node="insertNodeOnEdge"
527
+ :on-delete="confirmDeleteEdge"
528
+ />
529
+ ```
530
+
531
+ 删除动作只通知宿主,不直接修改画布;二次确认、权限和保存仍由 Core/宿主处理。所有
532
+ 按钮都带有 `title` 与 `aria-label`,`flip-down` 可用于靠近画布顶部的工具条。
533
+
534
+ `EditorEdgeHoverTools` 的 `onInsertNode` 参数是连线 ID。宿主应调用主编辑器的
535
+ `openNodePicker({ edgeId, excludeInputNodes: true })`,由 Core 统一完成
536
+ `source -> new -> target` 替换和失败回滚,不能把该 ID 当作节点 ID 直接追加边。
537
+
242
538
  ## 🔗 相关包
243
539
 
244
540
  - [`@huanban/rulego-editor-core`](https://www.npmjs.com/package/@huanban/rulego-editor-core) — 核心引擎 (必需)
@@ -1,5 +1,5 @@
1
1
  import type { AIAssistantOpenOptions, HuanbanRulegoEditor } from '@huanban/rulego-editor-core';
2
- type __VLS_Props = {
2
+ export interface AIAssistantProps {
3
3
  editor?: HuanbanRulegoEditor | null;
4
4
  options?: AIAssistantOpenOptions;
5
5
  iconOnly?: boolean;
@@ -7,8 +7,8 @@ type __VLS_Props = {
7
7
  className?: string;
8
8
  customStyle?: Record<string, string | number>;
9
9
  disabled?: boolean;
10
- };
11
- declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
10
+ }
11
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<AIAssistantProps>, {
12
12
  editor: null;
13
13
  options: () => {};
14
14
  iconOnly: boolean;
@@ -18,7 +18,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
18
18
  disabled: boolean;
19
19
  }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
20
  open: () => void;
21
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
21
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<AIAssistantProps>, {
22
22
  editor: null;
23
23
  options: () => {};
24
24
  iconOnly: boolean;
@@ -29,12 +29,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
29
29
  }>>> & Readonly<{
30
30
  onOpen?: (() => any) | undefined;
31
31
  }>, {
32
+ disabled: boolean;
33
+ editor: HuanbanRulegoEditor | null;
32
34
  options: AIAssistantOpenOptions;
33
35
  className: string;
34
36
  customStyle: Record<string, string | number>;
35
37
  label: string;
36
- disabled: boolean;
37
- editor: HuanbanRulegoEditor | null;
38
38
  iconOnly: boolean;
39
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
40
  declare const _default: typeof __VLS_export;
@@ -57,4 +57,3 @@ type __VLS_PrettifyLocal<T> = (T extends any ? {
57
57
  } : {
58
58
  [K in keyof T as K]: T[K];
59
59
  }) & {};
60
- //# sourceMappingURL=AIAssistant.vue.d.ts.map
@@ -11,11 +11,16 @@ export interface ComponentField {
11
11
  export interface RuleGoComponent {
12
12
  type: string;
13
13
  category: string;
14
+ categoryPath?: string;
15
+ subgroup?: string;
16
+ categorySubgroups?: Array<Record<string, unknown>>;
14
17
  label?: string;
15
18
  desc?: string;
16
19
  fields?: ComponentField[];
17
20
  icon?: string;
18
21
  background?: string;
22
+ order?: number;
23
+ disabled?: boolean;
19
24
  notInput?: boolean;
20
25
  notOutput?: boolean;
21
26
  [key: string]: unknown;
@@ -23,18 +28,29 @@ export interface RuleGoComponent {
23
28
  export interface ComponentSidebarProps {
24
29
  components: RuleGoComponent[];
25
30
  onDragStart?: (component: RuleGoComponent) => void;
31
+ recentComponentTypes?: string[];
26
32
  collapsed?: boolean;
27
33
  searchPlaceholder?: string;
28
34
  locale?: string;
29
35
  messages?: LocaleMessages;
30
36
  t?: EditorTranslate;
31
37
  theme?: string;
38
+ virtualization?: {
39
+ enabled?: boolean;
40
+ threshold?: number;
41
+ itemHeight?: number;
42
+ viewportHeight?: number;
43
+ overscan?: number;
44
+ };
32
45
  }
33
46
  declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ComponentSidebarProps>, {
34
47
  collapsed: boolean;
48
+ recentComponentTypes: () => never[];
35
49
  }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ComponentSidebarProps>, {
36
50
  collapsed: boolean;
51
+ recentComponentTypes: () => never[];
37
52
  }>>> & Readonly<{}>, {
53
+ recentComponentTypes: string[];
38
54
  collapsed: boolean;
39
55
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
56
  declare const _default: typeof __VLS_export;
@@ -57,4 +73,3 @@ type __VLS_PrettifyLocal<T> = (T extends any ? {
57
73
  } : {
58
74
  [K in keyof T as K]: T[K];
59
75
  }) & {};
60
- //# sourceMappingURL=ComponentSidebar.vue.d.ts.map
@@ -31,6 +31,7 @@ export declare function getNodeContextMenuItems(handlers: {
31
31
  onDuplicate?: () => void;
32
32
  onRunFromNode?: () => void;
33
33
  onRunSingleNode?: () => void;
34
+ nodeType?: unknown;
34
35
  }, i18n?: ContextMenuI18nOptions): ContextMenuItem[];
35
36
  export declare function getEdgeContextMenuItems(handlers: {
36
37
  onEditProperties?: () => void;
@@ -44,7 +45,16 @@ export declare function getCanvasContextMenuItems(handlers: {
44
45
  }, i18n?: ContextMenuI18nOptions): ContextMenuItem[];
45
46
  declare const _default: typeof __VLS_export;
46
47
  export default _default;
47
- declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<ContextMenuProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<ContextMenuProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
48
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ContextMenuProps>, {
49
+ targetType: string;
50
+ targetId: string;
51
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ContextMenuProps>, {
52
+ targetType: string;
53
+ targetId: string;
54
+ }>>> & Readonly<{}>, {
55
+ targetId: string;
56
+ targetType: ContextMenuTarget;
57
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
48
58
  type __VLS_TypePropsToOption<T> = {
49
59
  [K in keyof T]-?: {} extends Pick<T, K> ? {
50
60
  type: import('vue').PropType<Required<T>[K]>;
@@ -53,4 +63,13 @@ type __VLS_TypePropsToOption<T> = {
53
63
  required: true;
54
64
  };
55
65
  };
56
- //# sourceMappingURL=ContextMenu.vue.d.ts.map
66
+ type __VLS_WithDefaults<P, D> = {
67
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
68
+ default: D[K];
69
+ }> : P[K];
70
+ };
71
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
72
+ [K in keyof T]: T[K];
73
+ } : {
74
+ [K in keyof T as K]: T[K];
75
+ }) & {};
@@ -1,47 +1,72 @@
1
- import type { PropType } from 'vue';
2
- import type { LocaleMessages } from '@huanban/rulego-editor-core';
1
+ import type { CopilotChatMessage, CopilotChatToolCall, EditorChatHistoryMode, EditorPersistenceAdapter, EditorPersistenceNamespace, LocaleMessages } from '@huanban/rulego-editor-core';
3
2
  import type { EditorTranslate } from '../i18n';
4
- declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
- /** 绑定对话的规则链 ID,用于上下文隔离 */
6
- ruleChainId: {
7
- type: PropType<string>;
8
- required: true;
9
- };
10
- locale: {
11
- type: StringConstructor;
12
- default: undefined;
13
- };
14
- messages: {
15
- type: PropType<LocaleMessages>;
16
- default: undefined;
17
- };
18
- t: {
19
- type: PropType<EditorTranslate>;
20
- default: undefined;
21
- };
22
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
23
- /** 绑定对话的规则链 ID,用于上下文隔离 */
24
- ruleChainId: {
25
- type: PropType<string>;
26
- required: true;
27
- };
28
- locale: {
29
- type: StringConstructor;
30
- default: undefined;
31
- };
32
- messages: {
33
- type: PropType<LocaleMessages>;
34
- default: undefined;
35
- };
36
- t: {
37
- type: PropType<EditorTranslate>;
38
- default: undefined;
39
- };
40
- }>> & Readonly<{}>, {
41
- locale: string;
42
- t: EditorTranslate;
43
- messages: LocaleMessages;
3
+ export interface CopilotChatViewMessage extends CopilotChatMessage {
4
+ id: string;
5
+ status?: 'sending' | 'complete' | 'error';
6
+ reasoning?: string;
7
+ toolCalls?: CopilotChatToolCall[];
8
+ }
9
+ export interface CopilotChatPersistence {
10
+ adapter: EditorPersistenceAdapter;
11
+ namespace: EditorPersistenceNamespace;
12
+ mode?: EditorChatHistoryMode;
13
+ }
14
+ export interface CopilotChatProps {
15
+ ruleChainId: string;
16
+ apiBase?: string;
17
+ endpoint?: string;
18
+ conversationContextKey?: string;
19
+ model?: string;
20
+ stream?: boolean;
21
+ fetchHeaders?: Record<string, string> | (() => Record<string, string>);
22
+ customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
23
+ initialMessages?: CopilotChatMessage[];
24
+ persistence?: CopilotChatPersistence;
25
+ onMessagesChange?: (messages: CopilotChatViewMessage[]) => void;
26
+ locale?: string;
27
+ messages?: LocaleMessages;
28
+ t?: EditorTranslate;
29
+ placeholder?: string;
30
+ className?: string;
31
+ style?: Record<string, string | number>;
32
+ disabled?: boolean;
33
+ }
34
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<CopilotChatProps>, {
35
+ stream: boolean;
36
+ initialMessages: () => never[];
37
+ disabled: boolean;
38
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
39
+ "messages-change": (messages: CopilotChatViewMessage[]) => void;
40
+ error: (error: Error) => void;
41
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<CopilotChatProps>, {
42
+ stream: boolean;
43
+ initialMessages: () => never[];
44
+ disabled: boolean;
45
+ }>>> & Readonly<{
46
+ onError?: ((error: Error) => any) | undefined;
47
+ "onMessages-change"?: ((messages: CopilotChatViewMessage[]) => any) | undefined;
48
+ }>, {
49
+ disabled: boolean;
50
+ stream: boolean;
51
+ initialMessages: CopilotChatMessage[];
44
52
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
45
53
  declare const _default: typeof __VLS_export;
46
54
  export default _default;
47
- //# sourceMappingURL=CopilotChat.vue.d.ts.map
55
+ type __VLS_TypePropsToOption<T> = {
56
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
57
+ type: import('vue').PropType<Required<T>[K]>;
58
+ } : {
59
+ type: import('vue').PropType<T[K]>;
60
+ required: true;
61
+ };
62
+ };
63
+ type __VLS_WithDefaults<P, D> = {
64
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
65
+ default: D[K];
66
+ }> : P[K];
67
+ };
68
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
69
+ [K in keyof T]: T[K];
70
+ } : {
71
+ [K in keyof T as K]: T[K];
72
+ }) & {};
@@ -44,4 +44,3 @@ type __VLS_PrettifyLocal<T> = (T extends any ? {
44
44
  } : {
45
45
  [K in keyof T as K]: T[K];
46
46
  }) & {};
47
- //# sourceMappingURL=DataViewDialog.vue.d.ts.map