@donglegeyu/company-ui 1.2.42 → 1.2.44
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/dist/cjs/ai-assistant/AiActionGuard/AiActionConfirmModal.d.ts +10 -0
- package/dist/cjs/ai-assistant/AiActionGuard/AiActionConfirmModal.js +87 -0
- package/dist/cjs/ai-assistant/AiActionGuard/AiActionGuard.d.ts +11 -0
- package/dist/cjs/ai-assistant/AiActionGuard/AiActionGuard.js +467 -0
- package/dist/cjs/ai-assistant/AiActionGuard/index.d.ts +5 -0
- package/dist/cjs/ai-assistant/AiActionGuard/index.js +51 -0
- package/dist/cjs/ai-assistant/AiActionGuard/policy.d.ts +23 -0
- package/dist/cjs/ai-assistant/AiActionGuard/policy.js +146 -0
- package/dist/cjs/ai-assistant/AiActionGuard/types.d.ts +130 -0
- package/dist/cjs/ai-assistant/AiActionGuard/types.js +17 -0
- package/dist/cjs/ai-assistant/AiAssistantProvider.d.ts +59 -0
- package/dist/cjs/ai-assistant/AiAssistantProvider.js +181 -0
- package/dist/cjs/ai-assistant/AiSessionEngine.d.ts +52 -0
- package/dist/cjs/ai-assistant/AiSessionEngine.js +335 -0
- package/dist/cjs/ai-assistant/MockAiTransport.d.ts +28 -0
- package/dist/cjs/ai-assistant/MockAiTransport.js +74 -0
- package/dist/cjs/ai-assistant/aiDraft.d.ts +60 -0
- package/dist/cjs/ai-assistant/aiDraft.js +17 -0
- package/dist/cjs/ai-assistant/index.d.ts +9 -0
- package/dist/cjs/ai-assistant/index.js +42 -0
- package/dist/cjs/ai-assistant/types.d.ts +133 -0
- package/dist/cjs/ai-assistant/types.js +17 -0
- package/dist/cjs/basic-components/CompanyActions/index.d.ts +9 -0
- package/dist/cjs/basic-components/CompanyActions/index.js +53 -0
- package/dist/cjs/basic-components/CompanyAttachments/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyAttachments/index.js +36 -0
- package/dist/cjs/basic-components/CompanyBubble/index.d.ts +8 -0
- package/dist/cjs/basic-components/CompanyBubble/index.js +49 -0
- package/dist/cjs/basic-components/CompanyCodeHighlighter/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyCodeHighlighter/index.js +36 -0
- package/dist/cjs/basic-components/CompanyConversations/index.d.ts +6 -0
- package/dist/cjs/basic-components/CompanyConversations/index.js +41 -0
- package/dist/cjs/basic-components/CompanyFileCard/index.d.ts +6 -0
- package/dist/cjs/basic-components/CompanyFileCard/index.js +41 -0
- package/dist/cjs/basic-components/CompanyFolder/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyFolder/index.js +36 -0
- package/dist/cjs/basic-components/CompanyMermaid/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyMermaid/index.js +36 -0
- package/dist/cjs/basic-components/CompanyPrompts/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyPrompts/index.js +36 -0
- package/dist/cjs/basic-components/CompanySender/index.d.ts +7 -0
- package/dist/cjs/basic-components/CompanySender/index.js +45 -0
- package/dist/cjs/basic-components/CompanySources/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanySources/index.js +36 -0
- package/dist/cjs/basic-components/CompanySuggestion/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanySuggestion/index.js +36 -0
- package/dist/cjs/basic-components/CompanyThink/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyThink/index.js +36 -0
- package/dist/cjs/basic-components/CompanyThoughtChain/index.d.ts +6 -0
- package/dist/cjs/basic-components/CompanyThoughtChain/index.js +41 -0
- package/dist/cjs/basic-components/CompanyWelcome/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyWelcome/index.js +36 -0
- package/dist/cjs/basic-components/CompanyXProvider/index.d.ts +4 -0
- package/dist/cjs/basic-components/CompanyXProvider/index.js +36 -0
- package/dist/cjs/basic-components/index.d.ts +15 -0
- package/dist/cjs/basic-components/index.js +31 -1
- package/dist/cjs/global.css +3 -3
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/shared-components/BaseInfoForm/index.d.ts +7 -2
- package/dist/cjs/shared-components/BaseInfoForm/index.js +146 -47
- package/dist/cjs/shared-components/CompanyAiAssistant/index.d.ts +48 -0
- package/dist/cjs/shared-components/CompanyAiAssistant/index.js +319 -0
- package/dist/cjs/shared-components/CompanyAiAssistant/index.scss +373 -0
- package/dist/cjs/shared-components/IconExplorer/index.js +31 -16
- package/dist/cjs/shared-components/PageTitle/index.d.ts +7 -3
- package/dist/cjs/shared-components/PageTitle/index.js +8 -2
- package/dist/cjs/shared-components/PageTitle/index.scss +10 -0
- package/dist/cjs/shared-components/SvgIcon/icon-manifest.js +12 -1
- package/dist/cjs/shared-components/SvgIcon/icon-meta.json +32 -2
- package/dist/cjs/shared-components/SvgIcon/icons.js +191 -2
- package/dist/cjs/shared-components/SvgIcon/index.d.ts +3 -1
- package/dist/cjs/shared-components/SvgIcon/index.js +3 -0
- package/dist/cjs/shared-components/index.d.ts +2 -0
- package/dist/cjs/shared-components/index.js +3 -0
- package/dist/cjs/sidebar-config.js +39 -0
- package/dist/cjs/template-components/AdminLayoutTemplate/index.d.ts +12 -1
- package/dist/cjs/template-components/AdminLayoutTemplate/index.js +361 -53
- package/dist/cjs/template-components/AdminLayoutTemplate/index.scss +128 -0
- package/dist/cjs/template-components/AiAssistantDock/index.d.ts +24 -0
- package/dist/cjs/template-components/AiAssistantDock/index.js +132 -0
- package/dist/cjs/template-components/AiAssistantDock/index.scss +59 -0
- package/dist/cjs/template-components/DrawerDetailTemplate/index.d.ts +42 -0
- package/dist/cjs/template-components/DrawerDetailTemplate/index.js +120 -0
- package/dist/cjs/template-components/DrawerDetailTemplate/index.scss +56 -0
- package/dist/cjs/template-components/DrawerFormTemplate/index.d.ts +35 -0
- package/dist/cjs/template-components/DrawerFormTemplate/index.js +132 -0
- package/dist/cjs/template-components/DrawerFormTemplate/index.scss +3 -0
- package/dist/cjs/template-components/FilterForm/index.d.ts +6 -1
- package/dist/cjs/template-components/FilterForm/index.js +175 -54
- package/dist/cjs/template-components/FormPageTemplate/index.d.ts +10 -1
- package/dist/cjs/template-components/FormPageTemplate/index.js +109 -1
- package/dist/cjs/template-components/SmartListTemplate/index.d.ts +6 -1
- package/dist/cjs/template-components/SmartListTemplate/index.js +6 -2
- package/dist/cjs/template-components/StatisticsListPage/index.d.ts +1 -1
- package/dist/cjs/template-components/StatisticsListPage/index.js +54 -3
- package/dist/cjs/template-components/StatisticsListPage/index.scss +14 -3
- package/dist/cjs/template-components/index.d.ts +6 -0
- package/dist/cjs/template-components/index.js +9 -0
- package/dist/cjs/theme/BasicPalette.d.ts +12 -0
- package/dist/cjs/theme/BasicPalette.js +176 -0
- package/dist/cjs/theme/BasicPalette.less +273 -0
- package/dist/cjs/theme/GlobalTheme.d.ts +85 -34
- package/dist/cjs/theme/GlobalTheme.js +69 -62
- package/dist/cjs/theme/PaletteTool.d.ts +3 -0
- package/dist/cjs/theme/PaletteTool.js +68 -0
- package/dist/cjs/theme/PaletteTool.less +75 -0
- package/dist/cjs/theme/ThemeEditor.d.ts +4 -0
- package/dist/cjs/theme/ThemeEditor.js +434 -0
- package/dist/cjs/theme/ThemeEditor.less +393 -0
- package/dist/cjs/theme/ThemeOverrides.d.ts +3 -0
- package/dist/cjs/theme/ThemeOverrides.js +211 -0
- package/dist/cjs/theme/ThemePalette.d.ts +38 -4
- package/dist/cjs/theme/ThemePalette.js +84 -142
- package/dist/cjs/theme/ThemePalette.less +64 -110
- package/dist/cjs/theme/editorNav.d.ts +25 -0
- package/dist/cjs/theme/editorNav.js +80 -0
- package/dist/cjs/theme/paletteMapping.d.ts +73 -0
- package/dist/cjs/theme/paletteMapping.js +147 -0
- package/dist/es/ai-assistant/AiActionGuard/AiActionConfirmModal.d.ts +10 -0
- package/dist/es/ai-assistant/AiActionGuard/AiActionConfirmModal.js +58 -0
- package/dist/es/ai-assistant/AiActionGuard/AiActionGuard.d.ts +11 -0
- package/dist/es/ai-assistant/AiActionGuard/AiActionGuard.js +676 -0
- package/dist/es/ai-assistant/AiActionGuard/index.d.ts +5 -0
- package/dist/es/ai-assistant/AiActionGuard/index.js +4 -0
- package/dist/es/ai-assistant/AiActionGuard/policy.d.ts +23 -0
- package/dist/es/ai-assistant/AiActionGuard/policy.js +97 -0
- package/dist/es/ai-assistant/AiActionGuard/types.d.ts +130 -0
- package/dist/es/ai-assistant/AiActionGuard/types.js +1 -0
- package/dist/es/ai-assistant/AiAssistantProvider.d.ts +59 -0
- package/dist/es/ai-assistant/AiAssistantProvider.js +222 -0
- package/dist/es/ai-assistant/AiSessionEngine.d.ts +52 -0
- package/dist/es/ai-assistant/AiSessionEngine.js +406 -0
- package/dist/es/ai-assistant/MockAiTransport.d.ts +28 -0
- package/dist/es/ai-assistant/MockAiTransport.js +81 -0
- package/dist/es/ai-assistant/aiDraft.d.ts +60 -0
- package/dist/es/ai-assistant/aiDraft.js +1 -0
- package/dist/es/ai-assistant/index.d.ts +9 -0
- package/dist/es/ai-assistant/index.js +11 -0
- package/dist/es/ai-assistant/types.d.ts +133 -0
- package/dist/es/ai-assistant/types.js +1 -0
- package/dist/es/basic-components/CompanyActions/index.d.ts +9 -0
- package/dist/es/basic-components/CompanyActions/index.js +46 -0
- package/dist/es/basic-components/CompanyAttachments/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyAttachments/index.js +17 -0
- package/dist/es/basic-components/CompanyBubble/index.d.ts +8 -0
- package/dist/es/basic-components/CompanyBubble/index.js +39 -0
- package/dist/es/basic-components/CompanyCodeHighlighter/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyCodeHighlighter/index.js +17 -0
- package/dist/es/basic-components/CompanyConversations/index.d.ts +6 -0
- package/dist/es/basic-components/CompanyConversations/index.js +25 -0
- package/dist/es/basic-components/CompanyFileCard/index.d.ts +6 -0
- package/dist/es/basic-components/CompanyFileCard/index.js +25 -0
- package/dist/es/basic-components/CompanyFolder/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyFolder/index.js +17 -0
- package/dist/es/basic-components/CompanyMermaid/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyMermaid/index.js +17 -0
- package/dist/es/basic-components/CompanyPrompts/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyPrompts/index.js +17 -0
- package/dist/es/basic-components/CompanySender/index.d.ts +7 -0
- package/dist/es/basic-components/CompanySender/index.js +32 -0
- package/dist/es/basic-components/CompanySources/index.d.ts +4 -0
- package/dist/es/basic-components/CompanySources/index.js +17 -0
- package/dist/es/basic-components/CompanySuggestion/index.d.ts +4 -0
- package/dist/es/basic-components/CompanySuggestion/index.js +17 -0
- package/dist/es/basic-components/CompanyThink/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyThink/index.js +17 -0
- package/dist/es/basic-components/CompanyThoughtChain/index.d.ts +6 -0
- package/dist/es/basic-components/CompanyThoughtChain/index.js +25 -0
- package/dist/es/basic-components/CompanyWelcome/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyWelcome/index.js +17 -0
- package/dist/es/basic-components/CompanyXProvider/index.d.ts +4 -0
- package/dist/es/basic-components/CompanyXProvider/index.js +17 -0
- package/dist/es/basic-components/index.d.ts +15 -0
- package/dist/es/basic-components/index.js +16 -1
- package/dist/es/global.css +3 -3
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +2 -0
- package/dist/es/shared-components/BaseInfoForm/index.d.ts +7 -2
- package/dist/es/shared-components/BaseInfoForm/index.js +128 -24
- package/dist/es/shared-components/CompanyAiAssistant/index.d.ts +48 -0
- package/dist/es/shared-components/CompanyAiAssistant/index.js +346 -0
- package/dist/es/shared-components/CompanyAiAssistant/index.scss +373 -0
- package/dist/es/shared-components/IconExplorer/index.js +35 -23
- package/dist/es/shared-components/PageTitle/index.d.ts +7 -3
- package/dist/es/shared-components/PageTitle/index.js +6 -6
- package/dist/es/shared-components/PageTitle/index.scss +10 -0
- package/dist/es/shared-components/SvgIcon/icon-manifest.js +27 -0
- package/dist/es/shared-components/SvgIcon/icon-meta.json +32 -2
- package/dist/es/shared-components/SvgIcon/icons.js +147 -2
- package/dist/es/shared-components/SvgIcon/index.d.ts +3 -1
- package/dist/es/shared-components/SvgIcon/index.js +3 -0
- package/dist/es/shared-components/index.d.ts +2 -0
- package/dist/es/shared-components/index.js +1 -0
- package/dist/es/sidebar-config.js +66 -0
- package/dist/es/template-components/AdminLayoutTemplate/index.d.ts +12 -1
- package/dist/es/template-components/AdminLayoutTemplate/index.js +490 -95
- package/dist/es/template-components/AdminLayoutTemplate/index.scss +128 -0
- package/dist/es/template-components/AiAssistantDock/index.d.ts +24 -0
- package/dist/es/template-components/AiAssistantDock/index.js +177 -0
- package/dist/es/template-components/AiAssistantDock/index.scss +59 -0
- package/dist/es/template-components/DrawerDetailTemplate/index.d.ts +42 -0
- package/dist/es/template-components/DrawerDetailTemplate/index.js +112 -0
- package/dist/es/template-components/DrawerDetailTemplate/index.scss +56 -0
- package/dist/es/template-components/DrawerFormTemplate/index.d.ts +35 -0
- package/dist/es/template-components/DrawerFormTemplate/index.js +149 -0
- package/dist/es/template-components/DrawerFormTemplate/index.scss +3 -0
- package/dist/es/template-components/FilterForm/index.d.ts +6 -1
- package/dist/es/template-components/FilterForm/index.js +165 -7
- package/dist/es/template-components/FormPageTemplate/index.d.ts +10 -1
- package/dist/es/template-components/FormPageTemplate/index.js +103 -2
- package/dist/es/template-components/SmartListTemplate/index.d.ts +6 -1
- package/dist/es/template-components/SmartListTemplate/index.js +6 -2
- package/dist/es/template-components/StatisticsListPage/index.d.ts +1 -1
- package/dist/es/template-components/StatisticsListPage/index.js +70 -3
- package/dist/es/template-components/StatisticsListPage/index.scss +14 -3
- package/dist/es/template-components/index.d.ts +6 -0
- package/dist/es/template-components/index.js +4 -1
- package/dist/es/theme/BasicPalette.d.ts +12 -0
- package/dist/es/theme/BasicPalette.js +273 -0
- package/dist/es/theme/BasicPalette.less +273 -0
- package/dist/es/theme/GlobalTheme.d.ts +85 -34
- package/dist/es/theme/GlobalTheme.js +75 -61
- package/dist/es/theme/PaletteTool.d.ts +3 -0
- package/dist/es/theme/PaletteTool.js +93 -0
- package/dist/es/theme/PaletteTool.less +75 -0
- package/dist/es/theme/ThemeEditor.d.ts +4 -0
- package/dist/es/theme/ThemeEditor.js +641 -0
- package/dist/es/theme/ThemeEditor.less +393 -0
- package/dist/es/theme/ThemeOverrides.d.ts +3 -0
- package/dist/es/theme/ThemeOverrides.js +277 -0
- package/dist/es/theme/ThemePalette.d.ts +38 -4
- package/dist/es/theme/ThemePalette.js +154 -241
- package/dist/es/theme/ThemePalette.less +64 -110
- package/dist/es/theme/editorNav.d.ts +25 -0
- package/dist/es/theme/editorNav.js +96 -0
- package/dist/es/theme/paletteMapping.d.ts +73 -0
- package/dist/es/theme/paletteMapping.js +150 -0
- package/package.json +3 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { AiActionConfirmModalProps } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* AI 动作确认弹层:基于 CompanyModal。
|
|
5
|
+
*
|
|
6
|
+
* - 标题 / 内容 / 确认取消文案均可配(缺省取 request 上的文案)
|
|
7
|
+
* - 键盘可操作(antd Modal 内置 Esc 关闭与 Tab 焦点循环),关闭后焦点回到触发点
|
|
8
|
+
* - 遮罩不关闭,必须显式确认或取消,避免误触放行
|
|
9
|
+
*/
|
|
10
|
+
export declare function AiActionConfirmModal({ open, request, title, content, okText, cancelText, onOk, onCancel, className, style, }: AiActionConfirmModalProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ai-assistant/AiActionGuard/AiActionConfirmModal.tsx
|
|
20
|
+
var AiActionConfirmModal_exports = {};
|
|
21
|
+
__export(AiActionConfirmModal_exports, {
|
|
22
|
+
AiActionConfirmModal: () => AiActionConfirmModal
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(AiActionConfirmModal_exports);
|
|
25
|
+
var import_antd = require("antd");
|
|
26
|
+
var import_CompanyModal = require("../../basic-components/CompanyModal");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
function AiActionConfirmModal({
|
|
29
|
+
open,
|
|
30
|
+
request,
|
|
31
|
+
title,
|
|
32
|
+
content,
|
|
33
|
+
okText,
|
|
34
|
+
cancelText,
|
|
35
|
+
onOk,
|
|
36
|
+
onCancel,
|
|
37
|
+
className,
|
|
38
|
+
style
|
|
39
|
+
}) {
|
|
40
|
+
const { token } = import_antd.theme.useToken();
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
42
|
+
import_CompanyModal.CompanyModal,
|
|
43
|
+
{
|
|
44
|
+
open,
|
|
45
|
+
centered: true,
|
|
46
|
+
maskClosable: false,
|
|
47
|
+
destroyOnHidden: true,
|
|
48
|
+
focusTriggerAfterClose: true,
|
|
49
|
+
title: title ?? (request == null ? void 0 : request.title) ?? "确认执行 AI 动作?",
|
|
50
|
+
okText: okText ?? (request == null ? void 0 : request.okText) ?? "确认",
|
|
51
|
+
cancelText: cancelText ?? (request == null ? void 0 : request.cancelText) ?? "取消",
|
|
52
|
+
onOk,
|
|
53
|
+
onCancel,
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorText, lineHeight: token.lineHeight }, children: content ?? (request == null ? void 0 : request.content) ?? "该动作需经你确认后才会继续。" }),
|
|
58
|
+
request ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
style: {
|
|
62
|
+
marginTop: token.marginSM,
|
|
63
|
+
padding: `${token.paddingXS}px ${token.paddingSM}px`,
|
|
64
|
+
borderRadius: token.borderRadius,
|
|
65
|
+
background: token.colorFillTertiary,
|
|
66
|
+
color: token.colorTextSecondary,
|
|
67
|
+
fontSize: token.fontSizeSM,
|
|
68
|
+
lineHeight: token.lineHeightSM
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
"动作:",
|
|
72
|
+
request.label,
|
|
73
|
+
"(",
|
|
74
|
+
request.action,
|
|
75
|
+
") · 数据域:",
|
|
76
|
+
request.domain
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
) : null
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
AiActionConfirmModal
|
|
87
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { AiActionGuardProps, UseAiActionValue } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* AI 动作执行闸门(上下文 Provider):
|
|
5
|
+
*
|
|
6
|
+
* 策略判定 → 用户确认 → 实时权限 → 写类幂等 → 调用方执行 → 审计。
|
|
7
|
+
* 组件不发起任何业务请求,执行逻辑由调用方通过 run 的第三个参数注入。
|
|
8
|
+
*/
|
|
9
|
+
export declare function AiActionGuard({ policy, domain, checkPermission, onAudit, onConfirm, userId, sessionId, confirmText, children, }: AiActionGuardProps): import("react").JSX.Element;
|
|
10
|
+
/** 读取动作闸门能力(需在 AiActionGuard 内使用) */
|
|
11
|
+
export declare function useAiAction(): UseAiActionValue;
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ai-assistant/AiActionGuard/AiActionGuard.tsx
|
|
20
|
+
var AiActionGuard_exports = {};
|
|
21
|
+
__export(AiActionGuard_exports, {
|
|
22
|
+
AiActionGuard: () => AiActionGuard,
|
|
23
|
+
useAiAction: () => useAiAction
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(AiActionGuard_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_AiActionConfirmModal = require("./AiActionConfirmModal");
|
|
28
|
+
var import_policy = require("./policy");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
var AiActionContext = (0, import_react.createContext)(void 0);
|
|
31
|
+
var sessionSeed = 0;
|
|
32
|
+
function createSessionId() {
|
|
33
|
+
sessionSeed += 1;
|
|
34
|
+
return `ai-action-${Date.now().toString(36)}-${sessionSeed}`;
|
|
35
|
+
}
|
|
36
|
+
function AiActionGuard({
|
|
37
|
+
policy,
|
|
38
|
+
domain,
|
|
39
|
+
checkPermission,
|
|
40
|
+
onAudit,
|
|
41
|
+
onConfirm,
|
|
42
|
+
userId,
|
|
43
|
+
sessionId,
|
|
44
|
+
confirmText,
|
|
45
|
+
children
|
|
46
|
+
}) {
|
|
47
|
+
const policyRef = (0, import_react.useRef)(policy);
|
|
48
|
+
policyRef.current = policy;
|
|
49
|
+
const domainRef = (0, import_react.useRef)(domain);
|
|
50
|
+
domainRef.current = domain;
|
|
51
|
+
const checkPermissionRef = (0, import_react.useRef)(checkPermission);
|
|
52
|
+
checkPermissionRef.current = checkPermission;
|
|
53
|
+
const onAuditRef = (0, import_react.useRef)(onAudit);
|
|
54
|
+
onAuditRef.current = onAudit;
|
|
55
|
+
const onConfirmRef = (0, import_react.useRef)(onConfirm);
|
|
56
|
+
onConfirmRef.current = onConfirm;
|
|
57
|
+
const userIdRef = (0, import_react.useRef)(userId);
|
|
58
|
+
userIdRef.current = userId;
|
|
59
|
+
const confirmTextRef = (0, import_react.useRef)(confirmText);
|
|
60
|
+
confirmTextRef.current = confirmText;
|
|
61
|
+
const [generatedSessionId] = (0, import_react.useState)(createSessionId);
|
|
62
|
+
const sessionIdRef = (0, import_react.useRef)(sessionId ?? generatedSessionId);
|
|
63
|
+
sessionIdRef.current = sessionId ?? generatedSessionId;
|
|
64
|
+
const navigateCountRef = (0, import_react.useRef)(0);
|
|
65
|
+
const usedKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
66
|
+
const undoRegistryRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
67
|
+
const undoSeedRef = (0, import_react.useRef)(0);
|
|
68
|
+
const [activeConfirm, setActiveConfirm] = (0, import_react.useState)(null);
|
|
69
|
+
const activeConfirmRef = (0, import_react.useRef)(null);
|
|
70
|
+
const confirmQueueRef = (0, import_react.useRef)([]);
|
|
71
|
+
(0, import_react.useEffect)(() => {
|
|
72
|
+
return () => {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = activeConfirmRef.current) == null ? void 0 : _a.resolve(false);
|
|
75
|
+
activeConfirmRef.current = null;
|
|
76
|
+
confirmQueueRef.current.forEach((entry) => entry.resolve(false));
|
|
77
|
+
confirmQueueRef.current = [];
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
const enqueueConfirm = (0, import_react.useCallback)((request) => {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
const entry = { request, resolve };
|
|
83
|
+
if (activeConfirmRef.current) {
|
|
84
|
+
confirmQueueRef.current.push(entry);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
activeConfirmRef.current = entry;
|
|
88
|
+
setActiveConfirm(entry);
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
91
|
+
const settleConfirm = (0, import_react.useCallback)((approved) => {
|
|
92
|
+
const current = activeConfirmRef.current;
|
|
93
|
+
activeConfirmRef.current = null;
|
|
94
|
+
current == null ? void 0 : current.resolve(approved);
|
|
95
|
+
const next = confirmQueueRef.current.shift() ?? null;
|
|
96
|
+
activeConfirmRef.current = next;
|
|
97
|
+
setActiveConfirm(next);
|
|
98
|
+
}, []);
|
|
99
|
+
const requestConfirmation = (0, import_react.useCallback)(
|
|
100
|
+
async (request) => {
|
|
101
|
+
const handler = onConfirmRef.current;
|
|
102
|
+
if (!handler) {
|
|
103
|
+
return { approved: await enqueueConfirm(request) };
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return { approved: Boolean(await handler(request)) };
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error("AiActionGuard onConfirm 回调异常:", error);
|
|
109
|
+
return { approved: false, exception: error };
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[enqueueConfirm]
|
|
113
|
+
);
|
|
114
|
+
const runPermissionCheck = (0, import_react.useCallback)(
|
|
115
|
+
async (action, params) => {
|
|
116
|
+
try {
|
|
117
|
+
const allowed = await checkPermissionRef.current(action, params);
|
|
118
|
+
return { allowed: Boolean(allowed) };
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("AiActionGuard checkPermission 异常,已按拒绝处理:", error);
|
|
121
|
+
return { allowed: false, error };
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
[]
|
|
125
|
+
);
|
|
126
|
+
const emitAudit = (0, import_react.useCallback)(
|
|
127
|
+
(action, params, result, undoHandle) => {
|
|
128
|
+
const handler = onAuditRef.current;
|
|
129
|
+
if (!handler)
|
|
130
|
+
return;
|
|
131
|
+
const event = {
|
|
132
|
+
action,
|
|
133
|
+
params,
|
|
134
|
+
domain: domainRef.current,
|
|
135
|
+
result,
|
|
136
|
+
userId: userIdRef.current,
|
|
137
|
+
sessionId: sessionIdRef.current,
|
|
138
|
+
timestamp: Date.now(),
|
|
139
|
+
undoHandle
|
|
140
|
+
};
|
|
141
|
+
try {
|
|
142
|
+
handler(event);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error("AiActionGuard onAudit 回调异常:", error);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
[]
|
|
148
|
+
);
|
|
149
|
+
const registerUndo = (0, import_react.useCallback)(
|
|
150
|
+
(action, undo2) => {
|
|
151
|
+
undoSeedRef.current += 1;
|
|
152
|
+
const id = `undo-${Date.now().toString(36)}-${undoSeedRef.current}`;
|
|
153
|
+
undoRegistryRef.current.set(id, undo2);
|
|
154
|
+
return { id, action, label: import_policy.AI_ACTION_LABELS[action] };
|
|
155
|
+
},
|
|
156
|
+
[]
|
|
157
|
+
);
|
|
158
|
+
const canRun = (0, import_react.useCallback)(
|
|
159
|
+
async (action, params = {}) => {
|
|
160
|
+
if (!(0, import_policy.isKnownAiAction)(action)) {
|
|
161
|
+
return {
|
|
162
|
+
ok: false,
|
|
163
|
+
decision: "deny",
|
|
164
|
+
reason: "denied",
|
|
165
|
+
message: `未登记的动作:${action}`
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const decision = (0, import_policy.resolveAiActionDecision)(
|
|
169
|
+
policyRef.current,
|
|
170
|
+
action,
|
|
171
|
+
params,
|
|
172
|
+
navigateCountRef.current
|
|
173
|
+
);
|
|
174
|
+
if (decision === "deny") {
|
|
175
|
+
return {
|
|
176
|
+
ok: false,
|
|
177
|
+
decision,
|
|
178
|
+
reason: "denied",
|
|
179
|
+
message: `策略拒绝执行「${import_policy.AI_ACTION_LABELS[action]}」`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const permission = await runPermissionCheck(action, params);
|
|
183
|
+
if (permission.error) {
|
|
184
|
+
return {
|
|
185
|
+
ok: false,
|
|
186
|
+
decision,
|
|
187
|
+
reason: "error",
|
|
188
|
+
message: "权限校验异常,已按拒绝处理"
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (!permission.allowed) {
|
|
192
|
+
return {
|
|
193
|
+
ok: false,
|
|
194
|
+
decision,
|
|
195
|
+
reason: "forbidden",
|
|
196
|
+
message: "当前用户无权限执行该动作"
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if ((0, import_policy.requiresIdempotencyKey)(action, params)) {
|
|
200
|
+
if (!params.idempotencyKey) {
|
|
201
|
+
return {
|
|
202
|
+
ok: false,
|
|
203
|
+
decision,
|
|
204
|
+
reason: "denied",
|
|
205
|
+
message: "写类动作缺少幂等键 idempotencyKey"
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (usedKeysRef.current.has(params.idempotencyKey)) {
|
|
209
|
+
return {
|
|
210
|
+
ok: false,
|
|
211
|
+
decision,
|
|
212
|
+
reason: "denied",
|
|
213
|
+
message: "幂等键已执行,跳过重复执行"
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return { ok: true, decision };
|
|
218
|
+
},
|
|
219
|
+
[runPermissionCheck]
|
|
220
|
+
);
|
|
221
|
+
const run = (0, import_react.useCallback)(
|
|
222
|
+
async (action, params = {}, execute) => {
|
|
223
|
+
if (!(0, import_policy.isKnownAiAction)(action)) {
|
|
224
|
+
emitAudit(action, params, "denied");
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
action,
|
|
228
|
+
decision: "deny",
|
|
229
|
+
reason: "denied",
|
|
230
|
+
message: `未登记的动作:${action}`
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
const decision = (0, import_policy.resolveAiActionDecision)(
|
|
234
|
+
policyRef.current,
|
|
235
|
+
action,
|
|
236
|
+
params,
|
|
237
|
+
navigateCountRef.current
|
|
238
|
+
);
|
|
239
|
+
if (decision === "deny") {
|
|
240
|
+
emitAudit(action, params, "denied");
|
|
241
|
+
return {
|
|
242
|
+
ok: false,
|
|
243
|
+
action,
|
|
244
|
+
decision,
|
|
245
|
+
reason: "denied",
|
|
246
|
+
message: `策略拒绝执行「${import_policy.AI_ACTION_LABELS[action]}」`
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (decision === "confirm") {
|
|
250
|
+
const request = (0, import_policy.createAiActionConfirmRequest)(
|
|
251
|
+
action,
|
|
252
|
+
params,
|
|
253
|
+
domainRef.current,
|
|
254
|
+
confirmTextRef.current
|
|
255
|
+
);
|
|
256
|
+
const confirmation = await requestConfirmation(request);
|
|
257
|
+
if (confirmation.exception) {
|
|
258
|
+
emitAudit(action, params, "error");
|
|
259
|
+
return {
|
|
260
|
+
ok: false,
|
|
261
|
+
action,
|
|
262
|
+
decision,
|
|
263
|
+
reason: "error",
|
|
264
|
+
message: "确认流程异常,已按取消处理"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (!confirmation.approved) {
|
|
268
|
+
emitAudit(action, params, "cancelled");
|
|
269
|
+
return {
|
|
270
|
+
ok: false,
|
|
271
|
+
action,
|
|
272
|
+
decision,
|
|
273
|
+
reason: "cancelled",
|
|
274
|
+
message: "用户取消了该动作"
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const permission = await runPermissionCheck(action, params);
|
|
279
|
+
if (permission.error) {
|
|
280
|
+
emitAudit(action, params, "error");
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
action,
|
|
284
|
+
decision,
|
|
285
|
+
reason: "error",
|
|
286
|
+
message: "权限校验异常,已按拒绝处理"
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (!permission.allowed) {
|
|
290
|
+
emitAudit(action, params, "denied");
|
|
291
|
+
return {
|
|
292
|
+
ok: false,
|
|
293
|
+
action,
|
|
294
|
+
decision,
|
|
295
|
+
reason: "forbidden",
|
|
296
|
+
message: "当前用户无权限执行该动作"
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const needIdempotency = (0, import_policy.requiresIdempotencyKey)(action, params);
|
|
300
|
+
const idempotencyKey = needIdempotency ? params.idempotencyKey : void 0;
|
|
301
|
+
if (needIdempotency) {
|
|
302
|
+
if (!idempotencyKey) {
|
|
303
|
+
emitAudit(action, params, "denied");
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
action,
|
|
307
|
+
decision,
|
|
308
|
+
reason: "denied",
|
|
309
|
+
message: "写类动作缺少幂等键 idempotencyKey"
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
if (usedKeysRef.current.has(idempotencyKey)) {
|
|
313
|
+
emitAudit(action, params, "denied");
|
|
314
|
+
return {
|
|
315
|
+
ok: false,
|
|
316
|
+
action,
|
|
317
|
+
decision,
|
|
318
|
+
reason: "denied",
|
|
319
|
+
message: "幂等键已执行,跳过重复执行"
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
usedKeysRef.current.add(idempotencyKey);
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
let data;
|
|
326
|
+
let undoHandle;
|
|
327
|
+
if (execute) {
|
|
328
|
+
const output = await execute(params);
|
|
329
|
+
data = output == null ? void 0 : output.data;
|
|
330
|
+
if (output == null ? void 0 : output.undo) {
|
|
331
|
+
undoHandle = registerUndo(action, output.undo);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (action === "navigate") {
|
|
335
|
+
navigateCountRef.current += 1;
|
|
336
|
+
}
|
|
337
|
+
emitAudit(action, params, "ok", undoHandle);
|
|
338
|
+
return { ok: true, action, decision, data, undoHandle };
|
|
339
|
+
} catch (error) {
|
|
340
|
+
const message = error instanceof Error ? error.message : "动作执行失败";
|
|
341
|
+
console.error("AiActionGuard 动作执行异常:", error);
|
|
342
|
+
emitAudit(action, params, "error");
|
|
343
|
+
return { ok: false, action, decision, reason: "error", message };
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
[emitAudit, registerUndo, requestConfirmation, runPermissionCheck]
|
|
347
|
+
);
|
|
348
|
+
const undo = (0, import_react.useCallback)(
|
|
349
|
+
async (handle) => {
|
|
350
|
+
const undoParams = { handleId: handle.id, targetAction: handle.action };
|
|
351
|
+
const decision = (0, import_policy.resolveAiActionDecision)(
|
|
352
|
+
policyRef.current,
|
|
353
|
+
"undo",
|
|
354
|
+
undoParams,
|
|
355
|
+
navigateCountRef.current
|
|
356
|
+
);
|
|
357
|
+
if (decision === "deny") {
|
|
358
|
+
emitAudit("undo", undoParams, "denied", handle);
|
|
359
|
+
return {
|
|
360
|
+
ok: false,
|
|
361
|
+
action: "undo",
|
|
362
|
+
decision,
|
|
363
|
+
reason: "denied",
|
|
364
|
+
message: "策略拒绝执行「撤销」"
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (decision === "confirm") {
|
|
368
|
+
const request = (0, import_policy.createAiActionConfirmRequest)(
|
|
369
|
+
"undo",
|
|
370
|
+
undoParams,
|
|
371
|
+
domainRef.current,
|
|
372
|
+
confirmTextRef.current
|
|
373
|
+
);
|
|
374
|
+
const confirmation = await requestConfirmation(request);
|
|
375
|
+
if (confirmation.exception) {
|
|
376
|
+
emitAudit("undo", undoParams, "error", handle);
|
|
377
|
+
return {
|
|
378
|
+
ok: false,
|
|
379
|
+
action: "undo",
|
|
380
|
+
decision,
|
|
381
|
+
reason: "error",
|
|
382
|
+
message: "确认流程异常,已按取消处理"
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (!confirmation.approved) {
|
|
386
|
+
emitAudit("undo", undoParams, "cancelled", handle);
|
|
387
|
+
return {
|
|
388
|
+
ok: false,
|
|
389
|
+
action: "undo",
|
|
390
|
+
decision,
|
|
391
|
+
reason: "cancelled",
|
|
392
|
+
message: "用户取消了撤销"
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const permission = await runPermissionCheck("undo", undoParams);
|
|
397
|
+
if (permission.error) {
|
|
398
|
+
emitAudit("undo", undoParams, "error", handle);
|
|
399
|
+
return {
|
|
400
|
+
ok: false,
|
|
401
|
+
action: "undo",
|
|
402
|
+
decision,
|
|
403
|
+
reason: "error",
|
|
404
|
+
message: "权限校验异常,已按拒绝处理"
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
if (!permission.allowed) {
|
|
408
|
+
emitAudit("undo", undoParams, "denied", handle);
|
|
409
|
+
return {
|
|
410
|
+
ok: false,
|
|
411
|
+
action: "undo",
|
|
412
|
+
decision,
|
|
413
|
+
reason: "forbidden",
|
|
414
|
+
message: "当前用户无权限执行撤销"
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
const undoFn = undoRegistryRef.current.get(handle.id);
|
|
418
|
+
if (!undoFn) {
|
|
419
|
+
emitAudit("undo", undoParams, "denied", handle);
|
|
420
|
+
return {
|
|
421
|
+
ok: false,
|
|
422
|
+
action: "undo",
|
|
423
|
+
decision,
|
|
424
|
+
reason: "denied",
|
|
425
|
+
message: "撤销句柄已失效"
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
await undoFn();
|
|
430
|
+
undoRegistryRef.current.delete(handle.id);
|
|
431
|
+
emitAudit("undo", undoParams, "ok", handle);
|
|
432
|
+
return { ok: true, action: "undo", decision };
|
|
433
|
+
} catch (error) {
|
|
434
|
+
const message = error instanceof Error ? error.message : "撤销执行失败";
|
|
435
|
+
console.error("AiActionGuard 撤销异常:", error);
|
|
436
|
+
emitAudit("undo", undoParams, "error", handle);
|
|
437
|
+
return { ok: false, action: "undo", decision, reason: "error", message };
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
[emitAudit, requestConfirmation, runPermissionCheck]
|
|
441
|
+
);
|
|
442
|
+
const api = (0, import_react.useMemo)(() => ({ canRun, run, undo }), [canRun, run, undo]);
|
|
443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AiActionContext.Provider, { value: api, children: [
|
|
444
|
+
children,
|
|
445
|
+
onConfirm ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
446
|
+
import_AiActionConfirmModal.AiActionConfirmModal,
|
|
447
|
+
{
|
|
448
|
+
open: Boolean(activeConfirm),
|
|
449
|
+
request: activeConfirm == null ? void 0 : activeConfirm.request,
|
|
450
|
+
onOk: () => settleConfirm(true),
|
|
451
|
+
onCancel: () => settleConfirm(false)
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
] });
|
|
455
|
+
}
|
|
456
|
+
function useAiAction() {
|
|
457
|
+
const context = (0, import_react.useContext)(AiActionContext);
|
|
458
|
+
if (!context) {
|
|
459
|
+
throw new Error("useAiAction 必须在 AiActionGuard 内使用");
|
|
460
|
+
}
|
|
461
|
+
return context;
|
|
462
|
+
}
|
|
463
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
464
|
+
0 && (module.exports = {
|
|
465
|
+
AiActionGuard,
|
|
466
|
+
useAiAction
|
|
467
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AiActionGuard, useAiAction } from "./AiActionGuard";
|
|
2
|
+
export { AiActionConfirmModal } from "./AiActionConfirmModal";
|
|
3
|
+
export type { AiActionConfirmModalProps } from "./types";
|
|
4
|
+
export { AI_ACTION_LABELS, AI_ACTION_TYPES, DEFAULT_AI_ACTION_POLICY, WRITE_ACTION_TYPES, createAiActionConfirmRequest, isKnownAiAction, requiresIdempotencyKey, resolveAiActionDecision, } from "./policy";
|
|
5
|
+
export type { AiActionAuditEvent, AiActionAuditResult, AiActionCanRunResult, AiActionConfirmRequest, AiActionConfirmText, AiActionDecision, AiActionExecutionResult, AiActionExecutor, AiActionFailure, AiActionGuardProps, AiActionParams, AiActionPolicy, AiActionReason, AiActionResult, AiActionSuccess, AiActionType, AiUndoHandle, UseAiActionValue, } from "./types";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ai-assistant/AiActionGuard/index.ts
|
|
20
|
+
var AiActionGuard_exports = {};
|
|
21
|
+
__export(AiActionGuard_exports, {
|
|
22
|
+
AI_ACTION_LABELS: () => import_policy.AI_ACTION_LABELS,
|
|
23
|
+
AI_ACTION_TYPES: () => import_policy.AI_ACTION_TYPES,
|
|
24
|
+
AiActionConfirmModal: () => import_AiActionConfirmModal.AiActionConfirmModal,
|
|
25
|
+
AiActionGuard: () => import_AiActionGuard.AiActionGuard,
|
|
26
|
+
DEFAULT_AI_ACTION_POLICY: () => import_policy.DEFAULT_AI_ACTION_POLICY,
|
|
27
|
+
WRITE_ACTION_TYPES: () => import_policy.WRITE_ACTION_TYPES,
|
|
28
|
+
createAiActionConfirmRequest: () => import_policy.createAiActionConfirmRequest,
|
|
29
|
+
isKnownAiAction: () => import_policy.isKnownAiAction,
|
|
30
|
+
requiresIdempotencyKey: () => import_policy.requiresIdempotencyKey,
|
|
31
|
+
resolveAiActionDecision: () => import_policy.resolveAiActionDecision,
|
|
32
|
+
useAiAction: () => import_AiActionGuard.useAiAction
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(AiActionGuard_exports);
|
|
35
|
+
var import_AiActionGuard = require("./AiActionGuard");
|
|
36
|
+
var import_AiActionConfirmModal = require("./AiActionConfirmModal");
|
|
37
|
+
var import_policy = require("./policy");
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
AI_ACTION_LABELS,
|
|
41
|
+
AI_ACTION_TYPES,
|
|
42
|
+
AiActionConfirmModal,
|
|
43
|
+
AiActionGuard,
|
|
44
|
+
DEFAULT_AI_ACTION_POLICY,
|
|
45
|
+
WRITE_ACTION_TYPES,
|
|
46
|
+
createAiActionConfirmRequest,
|
|
47
|
+
isKnownAiAction,
|
|
48
|
+
requiresIdempotencyKey,
|
|
49
|
+
resolveAiActionDecision,
|
|
50
|
+
useAiAction
|
|
51
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AiActionConfirmRequest, AiActionConfirmText, AiActionDecision, AiActionParams, AiActionPolicy, AiActionType } from "./types";
|
|
2
|
+
/** 动作白名单(未知动作一律 deny) */
|
|
3
|
+
export declare const AI_ACTION_TYPES: readonly AiActionType[];
|
|
4
|
+
/** 写类动作:需幂等键;其中 create-draft 仅在 persist=true(落库)时按写类处理 */
|
|
5
|
+
export declare const WRITE_ACTION_TYPES: readonly AiActionType[];
|
|
6
|
+
/** 默认策略(可被 AiActionGuard.policy 覆盖) */
|
|
7
|
+
export declare const DEFAULT_AI_ACTION_POLICY: Readonly<Record<AiActionType, AiActionDecision>>;
|
|
8
|
+
/** 动作中文名(确认弹层与审计展示用) */
|
|
9
|
+
export declare const AI_ACTION_LABELS: Readonly<Record<AiActionType, string>>;
|
|
10
|
+
/** 运行时白名单判定(防 JS 侧传入未登记动作) */
|
|
11
|
+
export declare function isKnownAiAction(action: string): action is AiActionType;
|
|
12
|
+
/** 该动作在本次参数下是否属于「写」并要求幂等键 */
|
|
13
|
+
export declare function requiresIdempotencyKey(action: AiActionType, params: AiActionParams): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 解析本次动作决策:
|
|
16
|
+
* - 显式 policy 覆盖优先(不再叠加默认动态规则)
|
|
17
|
+
* - 默认策略下,同一会话内第 2 次及以上 navigate 需确认
|
|
18
|
+
* - 默认策略下,rollback 且调用方声明存在未保存修改时需确认
|
|
19
|
+
* - 未登记动作 deny
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveAiActionDecision(policy: AiActionPolicy | undefined, action: AiActionType, params: AiActionParams, navigateCount: number): AiActionDecision;
|
|
22
|
+
/** 构造确认请求(内置弹层与宿主自定义 UI 共用) */
|
|
23
|
+
export declare function createAiActionConfirmRequest(action: AiActionType, params: AiActionParams, domain: string, confirmText?: AiActionConfirmText): AiActionConfirmRequest;
|