@huanban/rulego-editor-core 1.1.1 → 1.1.2

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 (68) hide show
  1. package/LICENSE +190 -0
  2. package/dist/api/AIManager.d.ts +12 -0
  3. package/dist/api/ApiProvider.d.ts +83 -0
  4. package/dist/api/DebugSocketClient.d.ts +39 -0
  5. package/dist/api/RuleChainAPI.d.ts +5 -1
  6. package/dist/api/StreamParser.d.ts +13 -0
  7. package/dist/api/index.d.ts +5 -1
  8. package/dist/api/response-utils.d.ts +28 -0
  9. package/dist/api/types.d.ts +67 -0
  10. package/dist/core/AutoLayout.d.ts +1 -1
  11. package/dist/core/ComponentRegistry.d.ts +11 -1
  12. package/dist/core/EditorCore.d.ts +23 -1
  13. package/dist/core/I18nManager.d.ts +18 -0
  14. package/dist/core/Optimizations.d.ts +16 -0
  15. package/dist/core/RuleChainChatManager.d.ts +53 -0
  16. package/dist/core/component-payload.d.ts +12 -0
  17. package/dist/core/index.d.ts +4 -2
  18. package/dist/core/runtime-limits.d.ts +35 -0
  19. package/dist/defaults/components.d.ts +4 -23
  20. package/dist/defaults/official-component-fallbacks.d.ts +12 -0
  21. package/dist/extensions/ClipboardExtension.d.ts +28 -0
  22. package/dist/extensions/KeyboardExtension.d.ts +18 -0
  23. package/dist/extensions/MenuExtension.d.ts +29 -0
  24. package/dist/iconRegistry.d.ts +2 -2
  25. package/dist/index.cjs.js +5739 -922
  26. package/dist/index.d.ts +11 -6
  27. package/dist/index.esm.js +74892 -43118
  28. package/dist/index.umd.js +5739 -922
  29. package/dist/models/BaseNodeModel.d.ts +38 -0
  30. package/dist/models/index.d.ts +2 -0
  31. package/dist/nodes/AgentOrchestrationNode.d.ts +41 -0
  32. package/dist/nodes/GroupNode.d.ts +50 -0
  33. package/dist/nodes/HeadlessHtmlNode.d.ts +20 -0
  34. package/dist/nodes/SwitchNode.d.ts +27 -0
  35. package/dist/nodes/UnknownNodeModel.d.ts +24 -0
  36. package/dist/standalone/HuanbanRulegoEditor.d.ts +122 -12
  37. package/dist/standalone/ai-providers.d.ts +7 -0
  38. package/dist/standalone/auth-fetch.d.ts +6 -1
  39. package/dist/standalone/code-editor.d.ts +40 -4
  40. package/dist/standalone/custom-nodes.d.ts +4 -1
  41. package/dist/standalone/editor-context-menu.d.ts +3 -2
  42. package/dist/standalone/editor-debug-ws.d.ts +26 -6
  43. package/dist/standalone/editor-delete.d.ts +4 -0
  44. package/dist/standalone/editor-dialogs.d.ts +27 -4
  45. package/dist/standalone/editor-events.d.ts +2 -1
  46. package/dist/standalone/editor-property-drawers.d.ts +30 -2
  47. package/dist/standalone/editor-route-settings.d.ts +49 -0
  48. package/dist/standalone/editor-sidebar.d.ts +11 -0
  49. package/dist/standalone/editor-toast.d.ts +2 -0
  50. package/dist/standalone/editor-toolbar.d.ts +13 -1
  51. package/dist/standalone/group-node.d.ts +9 -1
  52. package/dist/standalone/index.d.ts +4 -2
  53. package/dist/standalone/layout-scheduler.d.ts +16 -0
  54. package/dist/standalone/lifecycle.d.ts +15 -0
  55. package/dist/standalone/models-dev-catalog.d.ts +53 -0
  56. package/dist/standalone/node-definitions.d.ts +25 -7
  57. package/dist/standalone/official-node-view-patches.d.ts +15 -0
  58. package/dist/standalone/security-utils.d.ts +45 -0
  59. package/dist/test/setup-dom.d.ts +3 -0
  60. package/dist/types/component.d.ts +10 -1
  61. package/dist/types/editor.d.ts +48 -2
  62. package/dist/types/events.d.ts +14 -0
  63. package/dist/types/rule-chain.d.ts +1 -1
  64. package/dist/utils/GraphUtils.d.ts +24 -0
  65. package/dist/utils/index.d.ts +1 -0
  66. package/dist/utils/relation-utils.d.ts +13 -0
  67. package/dist/utils/textUtils.d.ts +13 -0
  68. package/package.json +15 -13
@@ -22,6 +22,8 @@ export interface EditorContext {
22
22
  core: any;
23
23
  /** 编辑器配置选项 */
24
24
  opts: any;
25
+ /** 编辑器根容器 */
26
+ rootEl?: HTMLElement;
25
27
  /** 组件列表 */
26
28
  components: any[];
27
29
  /** 侧边栏展开的分组集合 */
@@ -43,12 +45,33 @@ export interface EditorContext {
43
45
  /** 关闭 Modal */
44
46
  _closeModal(): void;
45
47
  }
48
+ export interface RunPanelOptions {
49
+ fromNodeId?: string;
50
+ onlyThisNode?: boolean;
51
+ initialMode?: 'form' | 'chat';
52
+ initialTab?: 'response' | 'resp_headers' | 'debug' | 'history' | 'integration';
53
+ section?: string;
54
+ }
55
+ export type SettingsDialogTab = 'user' | 'setting' | 'ai' | 'skills';
56
+ export interface SettingsDialogOptions {
57
+ /** Keep the current drawer mounted while settings opens, avoiding canvas reflow flicker. */
58
+ preserveDrawer?: boolean;
59
+ /** Open settings as fullscreen. Defaults to a large dialog. */
60
+ fullscreen?: boolean;
61
+ }
62
+ export declare function normalizeComponentMarketItems(raw: unknown): any[];
63
+ export declare function normalizeComponentsListItems(raw: unknown): any[];
46
64
  /**
47
- * 显示规则链选择器弹窗支持搜索和分页
48
- * 数据来源: opts.ruleItems (初始传入) 或远程 API
65
+ * 显示规则链选择器左侧抽屉支持主链/子链 Tab、搜索、分页、远程 API。
66
+ * 数据来源优先级: apiBase / rulesApi 真实后端 → opts.ruleItems 本地兜底。
49
67
  * @param ctx - 编辑器上下文
50
68
  */
51
69
  export declare function showRuleChainSelector(ctx: EditorContext): void;
70
+ /**
71
+ * 显示设置弹窗 — 对齐官方 SettingDialog 的账号设置、系统设置、AI 助手、全局技能入口。
72
+ * 若宿主提供 onSettingsClick,则保持组件化 slot 能力,由宿主完全接管。
73
+ */
74
+ export declare function showSettingsDialog(ctx: EditorContext, initialTab?: SettingsDialogTab, options?: SettingsDialogOptions): void;
52
75
  /**
53
76
  * 显示导出 DSL 弹窗
54
77
  * 支持 下载 JSON 数据 + 下载画布 PNG 截图
@@ -57,12 +80,12 @@ export declare function showRuleChainSelector(ctx: EditorContext): void;
57
80
  */
58
81
  export declare function showExportDialog(ctx: EditorContext): void;
59
82
  /**
60
- * 显示运行面板 Drawer
83
+ * 显示运行面板
61
84
  * 可发送消息到规则链并查看响应
62
85
  * slot: onRunClick 可劫持
63
86
  * @param ctx - 编辑器上下文
64
87
  */
65
- export declare function showRunPanel(ctx: EditorContext): void;
88
+ export declare function showRunPanel(ctx: EditorContext, options?: RunPanelOptions): void;
66
89
  /**
67
90
  * 显示组件管理弹窗
68
91
  * 已安装列表 + 组件市场(搜索/安装)
@@ -8,6 +8,7 @@
8
8
  *
9
9
  * @param editor - HuanbanRulegoEditor 实例引用
10
10
  */
11
+ export { showEditorToast } from './editor-toast';
11
12
  /**
12
13
  * 桥接 LogicFlow 画布事件到 EditorCore + 外部回调
13
14
  *
@@ -24,5 +25,5 @@
24
25
  *
25
26
  * @param editor - 编辑器实例 (需要含 lf / core / opts 等属性)
26
27
  */
27
- export declare function bridgeEvents(editor: any): void;
28
+ export declare function bridgeEvents(editor: any): () => void;
28
29
  //# sourceMappingURL=editor-events.d.ts.map
@@ -52,7 +52,33 @@ export declare function renderDebugTerminal(ctx: PropertyDrawerContext, wrapper:
52
52
  * @param wrapper - drawer 外层 DOM
53
53
  * @param msg - 显示的提示文本
54
54
  */
55
- export declare function renderDebugEmpty(ctx: PropertyDrawerContext, wrapper: HTMLElement, msg: string): void;
55
+ export declare function renderDebugEmpty(_ctx: PropertyDrawerContext, wrapper: HTMLElement, msg: string): void;
56
+ interface DebugLogPage {
57
+ items: any[];
58
+ total: number;
59
+ page: number;
60
+ size: number;
61
+ }
62
+ interface DebugTerminalFilters {
63
+ showIn: boolean;
64
+ showOut: boolean;
65
+ }
66
+ export declare function normalizeDebugLogPage(raw: unknown, fallbackPage?: number, fallbackSize?: number): DebugLogPage;
67
+ export declare function normalizeDebugLogItems(raw: unknown): any[];
68
+ export declare function filterDebugLogTerminalItems(items: any[], filters: DebugTerminalFilters): any[];
69
+ export interface NodeRelationSummaryRow {
70
+ label: string;
71
+ value: string;
72
+ }
73
+ export interface NodeRelationSummarySection {
74
+ title: string;
75
+ rows: NodeRelationSummaryRow[];
76
+ }
77
+ /**
78
+ * 构建节点详情页的关系/匹配协议摘要。画布渲染保持官方 GroupNode 简洁样式,
79
+ * 复杂协议字段集中在 Drawer 中呈现,避免导出协议值和 UI 标签混淆。
80
+ */
81
+ export declare function buildNodeRelationSummary(model: any, nodeView: any, ctx?: PropertyDrawerContext): NodeRelationSummarySection[];
56
82
  /**
57
83
  * 显示节点属性编辑 Drawer — 照搬原版 NodePropertyDrawer.vue + NodePropertyForm.vue
58
84
  * 包含三个 Tab: 详情、调试日志、帮助
@@ -73,6 +99,8 @@ export declare function showNodePropertyDrawer(ctx: PropertyDrawerContext, model
73
99
  * @param sourceNodeView - 源节点的组件定义 (含 relationTypes)
74
100
  * @param fromAdd - 是否从新增触发
75
101
  * @param usedRelationTypes - 已被同源节点其他边占用的 relationTypes (用于禁用下拉选项)
102
+ * @param sourceNodeModel - 源节点 RuleGo model,用于动态提取 cases/router 关系
76
103
  */
77
- export declare function showEdgePropertyDrawer(ctx: PropertyDrawerContext, edgeModel: any, sourceNodeView: any, fromAdd: boolean, usedRelationTypes?: string[]): void;
104
+ export declare function showEdgePropertyDrawer(ctx: PropertyDrawerContext, edgeModel: any, sourceNodeView: any, fromAdd: boolean, usedRelationTypes?: string[], sourceNodeModel?: any): void;
105
+ export {};
78
106
  //# sourceMappingURL=editor-property-drawers.d.ts.map
@@ -23,6 +23,55 @@
23
23
  * @see DataAdapter.ts 数据适配器负责 routers/processors 的持久化
24
24
  */
25
25
  import type { PropertyDrawerContext } from './editor-property-drawers';
26
+ /**
27
+ * 路由条目的数据结构
28
+ * 对应线上 RuleEndpointConfig.routers[] 中每一项
29
+ */
30
+ export interface RouterItem {
31
+ /** 唯一标识 */
32
+ id?: string;
33
+ /** 来源配置: path 为触发路径/主题/cron 等 */
34
+ from?: {
35
+ path?: string;
36
+ processors?: string[];
37
+ [key: string]: unknown;
38
+ };
39
+ /** 目标配置: path 为目标规则链, wait 为是否等待结果 */
40
+ to?: {
41
+ path?: string;
42
+ processors?: string[];
43
+ wait?: boolean;
44
+ [key: string]: unknown;
45
+ };
46
+ /** 附加参数: [0]=HTTP方法/MCP描述, [1]=MCP inputSchema 等 */
47
+ params?: string[];
48
+ }
49
+ export interface RouteTableRenderOptions {
50
+ nodeType: string;
51
+ pathLabel: string;
52
+ hideFromProcessors: boolean;
53
+ hideToProcessors: boolean;
54
+ supportsWait: boolean;
55
+ isMcp: boolean;
56
+ isUniquePath?: boolean;
57
+ labels: {
58
+ preProcessor: string;
59
+ postProcessor: string;
60
+ wait: string;
61
+ toolDesc: string;
62
+ operate: string;
63
+ edit: string;
64
+ delete: string;
65
+ empty: string;
66
+ yes: string;
67
+ no: string;
68
+ };
69
+ }
70
+ export declare function routePathPreviewPrefix(nodeType: string, params?: string[]): string;
71
+ export declare function isReservedHuanbanWsPath(path: string): boolean;
72
+ export declare function normalizeRouterItemForEndpoint(nodeType: string, routerItem: RouterItem): RouterItem;
73
+ export declare function renderRouteTableHeader(row: Element, options: RouteTableRenderOptions): void;
74
+ export declare function renderRouteTableBody(tbody: Element, routers: RouterItem[], options: RouteTableRenderOptions, startIndex?: number): void;
26
75
  /**
27
76
  * 将路由设置内容渲染到指定的 Tab 容器中
28
77
  *
@@ -9,6 +9,15 @@
9
9
  *
10
10
  * @param editor - HuanbanRulegoEditor 实例引用
11
11
  */
12
+ import type { ComponentDefinition } from '../types/component';
13
+ export interface DragNodeData {
14
+ type: string;
15
+ text: string;
16
+ properties: {
17
+ model: Record<string, unknown>;
18
+ view: ComponentDefinition;
19
+ };
20
+ }
12
21
  /**
13
22
  * 渲染侧边栏组件列表
14
23
  * 按 category 分组展示,支持搜索过滤、折叠/展开
@@ -16,4 +25,6 @@
16
25
  * @param editor - 编辑器实例 (需要含 sidebarGroupsEl / searchInputEl / components / expandedGroups / lf / rootEl 等)
17
26
  */
18
27
  export declare function renderSidebar(editor: any): void;
28
+ export declare function buildDragNodeData(comp: ComponentDefinition & Record<string, any>, label?: string, allComponents?: Array<ComponentDefinition & Record<string, any>>): DragNodeData;
29
+ export declare function inferNodeType(comp: ComponentDefinition & Record<string, any>): string;
19
30
  //# sourceMappingURL=editor-sidebar.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function showEditorToast(editor: any, message: string, type?: 'error' | 'info'): void;
2
+ //# sourceMappingURL=editor-toast.d.ts.map
@@ -14,6 +14,12 @@
14
14
  *
15
15
  * @param editor - HuanbanRulegoEditor 实例引用
16
16
  */
17
+ type ExternalOperationResult = void | boolean | {
18
+ success?: boolean;
19
+ msg?: string;
20
+ message?: string;
21
+ };
22
+ export declare function isExternalOperationSuccess(result: ExternalOperationResult): boolean;
17
23
  /**
18
24
  * 工具栏按钮点击事件处理
19
25
  * 根据 data-action 分发到对应的处理函数
@@ -22,6 +28,11 @@
22
28
  * @param e - 原始点击事件
23
29
  */
24
30
  export declare function handleToolbarClick(editor: any, e: Event): void;
31
+ export declare function updateToolbarHistoryState(editor: any, state?: {
32
+ undoAble?: boolean;
33
+ redoAble?: boolean;
34
+ }): void;
35
+ export declare function bindFullscreenState(editor: any): () => void;
25
36
  /**
26
37
  * 切换语言(中英文互切)并刷新工具栏 + 侧边栏文本
27
38
  * 不销毁重建 UI,仅精准更新 DOM 内的按钮文字
@@ -62,7 +73,7 @@ export declare function applyTheme(editor: any, themeId: string): void;
62
73
  *
63
74
  * @param editor - 编辑器实例
64
75
  */
65
- export declare function toggleThemeMenu(editor: any): void;
76
+ export declare function toggleThemeMenu(editor: any, target?: Element | null): void;
66
77
  /**
67
78
  * 关闭主题下拉菜单
68
79
  *
@@ -86,4 +97,5 @@ export declare function refreshThemeDropdown(editor: any): void;
86
97
  * @returns 清理函数 (用于 destroy 时移除监听)
87
98
  */
88
99
  export declare function setupKeyboardShortcuts(editor: any): () => void;
100
+ export {};
89
101
  //# sourceMappingURL=editor-toolbar.d.ts.map
@@ -37,6 +37,13 @@ import LogicFlow from '@logicflow/core';
37
37
  * 这些组件在画布上会展示为可包含子节点的容器
38
38
  */
39
39
  export declare const GROUP_NODE_TYPES: string[];
40
+ type GroupNodeTranslator = (key: 'onlyRightAnchorOut' | 'notToInput' | 'onlyLeftAnchorIn', fallback: string) => string;
41
+ export declare function isGroupAppendAllowed(nodeData: {
42
+ type?: string;
43
+ } | null | undefined): boolean;
44
+ export declare function fillGroupNodeFields(lf: any, groupLfId: string): void;
45
+ export declare function setupGroupEventListeners(lf: any): void;
46
+ export declare function restoreParentGroup(lf: any): void;
40
47
  /**
41
48
  * 注册 group-node 自定义图元到 LogicFlow 实例
42
49
  *
@@ -49,5 +56,6 @@ export declare const GROUP_NODE_TYPES: string[];
49
56
  *
50
57
  * @param lf - LogicFlow 画布实例
51
58
  */
52
- export declare function registerGroupNode(lf: LogicFlow): void;
59
+ export declare function registerGroupNode(lf: LogicFlow, translate?: GroupNodeTranslator): void;
60
+ export {};
53
61
  //# sourceMappingURL=group-node.d.ts.map
@@ -2,8 +2,10 @@
2
2
  * @file standalone/index.ts
3
3
  * @description HuanbanRulegoEditor 入口的 barrel 导出
4
4
  */
5
- export { HuanbanRulegoEditor } from './HuanbanRulegoEditor';
6
- export type { HuanbanRulegoEditorOptions } from './HuanbanRulegoEditor';
5
+ export { HuanbanRulegoEditor, applyComponentsRuntimePayloadOptions, normalizeComponentsPayload, normalizeComponentsRawPayload, } from './HuanbanRulegoEditor';
6
+ export type { AIAssistantOpenOptions, HuanbanRulegoEditorOptions } from './HuanbanRulegoEditor';
7
7
  /** 调试日志工具 — 可通过 setDebug(true) 开启编辑器内部调试日志 */
8
8
  export { debugLog, setDebug, isDebug } from './logger';
9
+ export { escapeHtml, escapeAttr, setSafeText, safeUrl, safeImageUrl, safeCssColor, sanitizeRichHtml, sanitizeDescription, redactSensitive, formatJsonBounded, parseJsonBounded, } from './security-utils';
10
+ export type { RichHtmlPolicy, RedactOptions, FormatJsonBoundedOptions, ParseJsonBoundedOptions, } from './security-utils';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ type ResizeTarget = {
2
+ resize?: (...args: any[]) => void;
3
+ };
4
+ export interface ScheduleEditorResizeOptions {
5
+ delayMs?: number;
6
+ args?: any[];
7
+ }
8
+ /**
9
+ * Coalesces LogicFlow resize calls into one animation-frame pass plus an optional
10
+ * delayed pass for CSS transitions. This prevents drawer/settings toggles from
11
+ * issuing several resize calls in the same layout frame.
12
+ */
13
+ export declare function scheduleEditorResize(target: ResizeTarget | null | undefined, options?: ScheduleEditorResizeOptions): void;
14
+ export declare function cancelScheduledEditorResize(target: ResizeTarget | null | undefined): void;
15
+ export {};
16
+ //# sourceMappingURL=layout-scheduler.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file standalone/lifecycle.ts
3
+ * @description Small cleanup registry for standalone DOM and runtime resources.
4
+ */
5
+ export type Cleanup = () => void;
6
+ export declare class CleanupBag {
7
+ private cleanups;
8
+ add(cleanup: Cleanup | null | undefined | void): void;
9
+ listen(target: EventTarget | null | undefined, type: string, handler: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
10
+ timeout(id: ReturnType<typeof setTimeout> | null | undefined): void;
11
+ interval(id: ReturnType<typeof setInterval> | null | undefined): void;
12
+ frame(id: number | null | undefined): void;
13
+ dispose(): void;
14
+ }
15
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1,53 @@
1
+ import type { AiProviderOption } from '../types/editor';
2
+ export declare const MODELS_DEV_API_URL = "https://models.dev/api.json";
3
+ export declare const MODELS_DEV_CACHE_KEY = "huanban.rulego-editor.models-dev.catalog.v1";
4
+ export declare const MODELS_DEV_CACHE_TTL_MS: number;
5
+ export declare const MODELS_DEV_MAX_PROVIDERS = 260;
6
+ export declare const MODELS_DEV_MAX_MODELS_PER_PROVIDER = 800;
7
+ export interface ModelsDevCatalogModel {
8
+ id: string;
9
+ name: string;
10
+ description?: string;
11
+ family?: string;
12
+ status?: string;
13
+ reasoning?: boolean;
14
+ toolCall?: boolean;
15
+ attachment?: boolean;
16
+ inputModalities?: string[];
17
+ outputModalities?: string[];
18
+ contextLimit?: number;
19
+ outputLimit?: number;
20
+ inputCost?: number;
21
+ outputCost?: number;
22
+ cacheReadCost?: number;
23
+ cacheWriteCost?: number;
24
+ lastUpdated?: string;
25
+ releaseDate?: string;
26
+ }
27
+ export interface ModelsDevCatalogProvider {
28
+ id: string;
29
+ name: string;
30
+ api: string;
31
+ doc?: string;
32
+ env?: string[];
33
+ models: ModelsDevCatalogModel[];
34
+ }
35
+ export interface ModelsDevCatalog {
36
+ fetchedAt: number;
37
+ providers: ModelsDevCatalogProvider[];
38
+ }
39
+ export interface ModelsDevLoadResult {
40
+ catalog: ModelsDevCatalog | null;
41
+ source: 'memory' | 'cache' | 'network' | 'unavailable';
42
+ error?: string;
43
+ }
44
+ export declare function normalizeModelsDevCatalog(raw: unknown, fetchedAt?: number): ModelsDevCatalog;
45
+ export declare function modelsDevProvidersToAiProviders(catalog: ModelsDevCatalog | null): AiProviderOption[];
46
+ export declare function mergeAiProvidersWithModelsDev(baseProviders: AiProviderOption[], catalog: ModelsDevCatalog | null): AiProviderOption[];
47
+ export declare function loadModelsDevProviderCatalog(options?: {
48
+ force?: boolean;
49
+ fetcher?: typeof fetch;
50
+ maxAgeMs?: number;
51
+ }): Promise<ModelsDevLoadResult>;
52
+ export declare function clearModelsDevCatalogMemoryForTest(): void;
53
+ //# sourceMappingURL=models-dev-catalog.d.ts.map
@@ -18,11 +18,15 @@
18
18
  * import { CATEGORY_CONFIG, getCategoryKey, getCategoryConfig, adapterComponentsLocal } from './node-definitions'
19
19
  * import { DEFAULT_NODE_VIEWS } from './node-views-data' // 需要数据时直接引入
20
20
  */
21
+ import { type AiProviderOption } from './ai-providers';
21
22
  export { DEFAULT_NODE_VIEWS } from './node-views-data';
22
- /** 分类颜色映射(label 通过 i18n 动态获取) */
23
- export declare const CATEGORY_CONFIG: Record<string, {
23
+ interface CategoryConfig {
24
24
  bg: string;
25
- }>;
25
+ label?: string;
26
+ nodeType?: string;
27
+ }
28
+ /** 分类颜色映射(label 通过 i18n 动态获取) */
29
+ export declare const CATEGORY_CONFIG: Record<string, CategoryConfig>;
26
30
  /**
27
31
  * 分类在侧边栏 / 管理列表中的显示顺序
28
32
  * 不在此列表中的分类会排到末尾(按字母序)
@@ -48,14 +52,25 @@ export declare const CATEGORY_PATH_MAP: Record<string, string>;
48
52
  * @returns 标准化的分类键
49
53
  */
50
54
  export declare function getCategoryKey(rawCat: string): string;
55
+ export declare function resolveRuntimeCategoryKey(component: any, isEndpoint?: boolean): string;
51
56
  /**
52
57
  * 获取分类配置 (未知分类用默认色 #86B4E5FF)
53
58
  * @param cat - 分类键
54
59
  * @returns 分类配置对象 { bg: 颜色 }
55
60
  */
56
- export declare function getCategoryConfig(cat: string): {
57
- bg: string;
58
- };
61
+ export declare function getCategoryConfig(cat: string): CategoryConfig;
62
+ export declare function adapterRelationTypeLabel(relationTypes: any, translate?: (value: string) => string): any;
63
+ export declare function adapterEndpointDefaults(component: any, isEndpoint?: boolean): void;
64
+ export declare function ensureStartNodeComponent(components: any[], label?: string): void;
65
+ export interface RuntimeComponentAdapterOptions {
66
+ builtins?: any;
67
+ aiProviders?: AiProviderOption[];
68
+ translateRelationType?: (value: string) => string;
69
+ translateCategory?: (categoryKey: string) => string;
70
+ inferNodeType?: (component: any) => string;
71
+ defaultBackground?: string;
72
+ }
73
+ export declare function adapterRuntimeComponent(component: any, options?: RuntimeComponentAdapterOptions): string;
59
74
  /**
60
75
  * 组件国际化适配器
61
76
  * 将 fallback 翻译数据应用到组件对象上。
@@ -70,5 +85,8 @@ export declare function getCategoryConfig(cat: string): {
70
85
  * @param customViews - 可选,外部传入的自定义本地化定义,优先于默认值
71
86
  * 调用方可传入自己的翻译字典来覆盖内置默认值
72
87
  */
73
- export declare function adapterComponentsLocal(component: any, customViews?: Record<string, any>): void;
88
+ export declare function adapterComponentsLocal(component: any, customViews?: Record<string, any>, translateRelationType?: (value: string) => string): void;
89
+ export declare function injectProviderField(component: any, providers?: AiProviderOption[]): void;
90
+ export declare function adapterBuiltins(component: any, builtins: any, categoryName?: string): void;
91
+ export declare function adapterRules(component: any): void;
74
92
  //# sourceMappingURL=node-definitions.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file official-node-view-patches.ts
3
+ * @description 官方 RuleGo editor zh i18n 节点渲染协议补丁。
4
+ *
5
+ * 生成来源:
6
+ * - 参考项目代码/rulego-editor-20260627/src/components/i18n/zh/index.js
7
+ * - 参考项目代码/rulego-editor-20260627/src/components/i18n/zh/endpoint.js
8
+ * - 参考项目代码/rulego-editor-20260627/src/components/i18n/zh/extend.js
9
+ * - 参考项目代码/rulego-editor-20260627/src/components/i18n/zh/ai.js
10
+ *
11
+ * 注意: 原官方 loadData 函数被归一化为 component.source,用于 standalone 渲染器
12
+ * 在运行时从当前画布或规则链列表补齐 options。
13
+ */
14
+ export declare const OFFICIAL_NODE_VIEW_PATCHES: Record<string, any>;
15
+ //# sourceMappingURL=official-node-view-patches.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file standalone/security-utils.ts
3
+ * @description Browser-side safety helpers for text, URLs, bounded JSON, and redaction.
4
+ */
5
+ export type RichHtmlPolicy = {
6
+ allowRichDescription?: boolean;
7
+ allowedLinkOrigins?: string[];
8
+ maxRichHtmlChars?: number;
9
+ };
10
+ export type RedactOptions = {
11
+ maxDepth?: number;
12
+ maxString?: number;
13
+ maxArray?: number;
14
+ sensitiveKeys?: RegExp[];
15
+ };
16
+ export type FormatJsonBoundedOptions = RedactOptions & {
17
+ maxChars?: number;
18
+ redact?: boolean;
19
+ space?: number;
20
+ };
21
+ export type ParseJsonBoundedOptions = {
22
+ maxBytes?: number;
23
+ label?: string;
24
+ };
25
+ export declare function escapeHtml(value: unknown): string;
26
+ export declare function escapeAttr(value: unknown): string;
27
+ export declare function setSafeText(el: Element | null | undefined, value: unknown): void;
28
+ export declare function safeUrl(value: unknown, opts?: {
29
+ allowRelative?: boolean;
30
+ allowedProtocols?: string[];
31
+ allowedOrigins?: string[];
32
+ base?: string;
33
+ }): string | null;
34
+ export declare function safeImageUrl(value: unknown, opts?: {
35
+ allowDataImage?: boolean;
36
+ allowedOrigins?: string[];
37
+ builtInResolver?: (value: string) => string | null;
38
+ }): string | null;
39
+ export declare function safeCssColor(value: unknown, fallback?: string): string;
40
+ export declare function sanitizeDescription(value: unknown, policy?: RichHtmlPolicy): string;
41
+ export declare function sanitizeRichHtml(value: unknown, policy?: RichHtmlPolicy): string;
42
+ export declare function redactSensitive<T>(value: T, opts?: RedactOptions): T;
43
+ export declare function formatJsonBounded(value: unknown, opts?: FormatJsonBoundedOptions): string;
44
+ export declare function parseJsonBounded<T = unknown>(raw: string, opts?: ParseJsonBoundedOptions): T;
45
+ //# sourceMappingURL=security-utils.d.ts.map
@@ -0,0 +1,3 @@
1
+ declare function createEmptyDomRect(): DOMRect;
2
+ declare function createEmptyDomRectList(): DOMRectList;
3
+ //# sourceMappingURL=setup-dom.d.ts.map
@@ -107,7 +107,16 @@ export interface ComponentGroup {
107
107
  * 从后端 API 返回的原始组件数据
108
108
  * 可能需要经过 adapterComponents 转换后才能使用
109
109
  */
110
- export type RawComponentData = ComponentDefinition[];
110
+ export interface RawComponentPayloadSections {
111
+ endpoints?: ComponentDefinition[];
112
+ nodes?: ComponentDefinition[];
113
+ components?: ComponentDefinition[];
114
+ builtins?: Record<string, unknown>;
115
+ skillPath?: string;
116
+ data?: unknown;
117
+ [key: string]: unknown;
118
+ }
119
+ export type RawComponentData = ComponentDefinition[] | RawComponentPayloadSections;
111
120
  /**
112
121
  * 组件注册表选项
113
122
  */
@@ -73,6 +73,40 @@ export interface GridConfig {
73
73
  color: string;
74
74
  };
75
75
  }
76
+ /**
77
+ * AI 供应商预设选项
78
+ * 与官方 RuleGo editorOptions.aiProviders / aiEmbeddingProviders 协议保持兼容。
79
+ */
80
+ export interface AiProviderOption {
81
+ /** 供应商 ID */
82
+ id?: string;
83
+ /** 兼容 select value 写法 */
84
+ value?: string;
85
+ /** 展示名称 */
86
+ label?: string;
87
+ /** 兼容 name 写法 */
88
+ name?: string;
89
+ /** OpenAI 兼容 API 地址 */
90
+ url?: string;
91
+ /** 默认模型 */
92
+ defaultModel?: string;
93
+ /** 模型下拉选项 */
94
+ models?: Array<string | {
95
+ label?: string;
96
+ value?: string;
97
+ [key: string]: unknown;
98
+ }>;
99
+ /** 数据来源,如 builtin、models.dev 或宿主自定义 */
100
+ source?: string;
101
+ /** 文档地址 */
102
+ doc?: string;
103
+ /** 推荐环境变量名 */
104
+ env?: string[];
105
+ /** 供应商模型数量,用于大目录检索展示 */
106
+ modelCount?: number;
107
+ /** 保留宿主扩展字段 */
108
+ [key: string]: unknown;
109
+ }
76
110
  /**
77
111
  * 编辑器初始化选项
78
112
  * 创建编辑器实例时传入,合并默认值后使用
@@ -94,8 +128,20 @@ export interface EditorOptions {
94
128
  startX?: number;
95
129
  /** 起始节点的 Y 坐标 (默认: 280) */
96
130
  startY?: number;
97
- /** 预加载的组件列表 (如果提供则不从 API 加载) */
98
- components?: ComponentDefinition[];
131
+ /** 预加载的组件列表,支持数组或官方 /api/v1/components 分段返回 */
132
+ components?: RawComponentData;
133
+ /** AI 供应商预设;对齐官方 editorOptions.aiProviders */
134
+ aiProviders?: AiProviderOption[];
135
+ /** 是否显示工具栏按钮文字,默认 false;设为 true 时显示图标 + 文字 */
136
+ showToolbarButtonLabels?: boolean;
137
+ /** 工具栏是否只显示图标,默认 true;显式 false 时可显示文字 */
138
+ toolbarIconOnly?: boolean;
139
+ /** 运行面板 AI 对话发送到 /rules/{chainId}/v1/chat/completions 的模型名 */
140
+ runChatModel?: string;
141
+ /** 兼容旧集成命名;未设置 runChatModel 时作为运行面板 AI 对话默认模型 */
142
+ defaultChatModel?: string;
143
+ /** Embedding AI 供应商预设;对齐官方 window.rulegoAiEmbeddingProviders 扩展 */
144
+ aiEmbeddingProviders?: AiProviderOption[];
99
145
  /** 组件列表格式转换函数 */
100
146
  adapterComponents?: (data: RawComponentData) => ComponentGroup[];
101
147
  /** 初始规则链数据 (如果提供则直接渲染) */
@@ -126,6 +126,18 @@ export interface EditorEventMap {
126
126
  id: string;
127
127
  properties: Record<string, unknown>;
128
128
  };
129
+ /** Headless HTML 节点挂载,用于 Vue/React Portal 渲染 */
130
+ 'node:html-mount': {
131
+ id: string;
132
+ type: string;
133
+ data: unknown;
134
+ model: unknown;
135
+ el: HTMLElement;
136
+ };
137
+ /** Headless HTML 节点卸载 */
138
+ 'node:html-unmount': {
139
+ id: string;
140
+ };
129
141
  /** 边被点击 */
130
142
  'edge:click': EdgeEventPayload;
131
143
  /** 边被双击 (触发编辑) */
@@ -189,6 +201,8 @@ export interface EditorEventMap {
189
201
  'history:change': HistoryChangePayload;
190
202
  /** 验证完成 */
191
203
  'validation:complete': ValidationPayload;
204
+ /** 调试日志写入 */
205
+ 'debug:log': unknown;
192
206
  }
193
207
  /**
194
208
  * 事件名称联合类型
@@ -5,7 +5,7 @@
5
5
  * 对应 RuleGo 后端的 JSON 数据结构,用于前后端数据交互。
6
6
  * 包含规则链元信息、节点定义、连接定义等完整类型。
7
7
  *
8
- * @see https://rulego.cc/pages/a2a7a9/ RuleGo 官方文档
8
+ * 数据结构需与当前后端 JSON 协议保持一致。
9
9
  */
10
10
  /**
11
11
  * 节点在画布上的布局信息
@@ -0,0 +1,24 @@
1
+ export interface GraphData {
2
+ nodes: any[];
3
+ edges: any[];
4
+ }
5
+ export declare class GraphUtils {
6
+ /**
7
+ * 洗白并重新分配图数据中的 ID,避免复制粘贴时与现有图产生 ID 冲突
8
+ * @param data 要处理的图数据(剪贴板中读取的原始数据)
9
+ * @param counters 引用计数器
10
+ * @returns 洗白后的安全图数据
11
+ */
12
+ static sanitizeGraphData(data: GraphData, counters: {
13
+ nodeCount: number;
14
+ edgeCount: number;
15
+ }): GraphData;
16
+ /**
17
+ * 刷新整个画布节点的全局计数器
18
+ */
19
+ static refreshCounters(data: GraphData, counters: {
20
+ nodeCount: number;
21
+ edgeCount: number;
22
+ }): void;
23
+ }
24
+ //# sourceMappingURL=GraphUtils.d.ts.map
@@ -3,4 +3,5 @@
3
3
  * @description 工具函数统一导出入口
4
4
  */
5
5
  export { getNodeByID, getEdgeBySourceNodeIdAndTargetNodeId, getNodeSeq, getBytesLength, generateUUID, adapterComponents, toComponentMap, defaultIdGenerator, } from './helpers';
6
+ export { GraphUtils, type GraphData } from './GraphUtils';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ export interface RelationOption {
2
+ label: string;
3
+ value: string;
4
+ }
5
+ export declare function normalizeRelationOptions(relationTypes: unknown): RelationOption[];
6
+ export declare function getSwitchCaseRelationOptions(nodeModel: any): RelationOption[];
7
+ export declare function getMsgTypeSwitchRelationOptions(nodeModel: any): RelationOption[];
8
+ export declare function getEndpointRouterRelationOptions(nodeModel: any): RelationOption[];
9
+ export declare function getRelationOptionsForNode(nodeView: any, nodeModel: any): RelationOption[];
10
+ export declare function resolveRelationLabel(value: unknown, nodeView?: any, nodeModel?: any): string;
11
+ export declare function parseRelationValues(value: unknown, splitToken?: string, relationOptions?: RelationOption[]): string[];
12
+ export declare function parseNodeIds(value: unknown): string[];
13
+ //# sourceMappingURL=relation-utils.d.ts.map