@donglegeyu/company-ui 1.2.45 → 1.2.47

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 (47) hide show
  1. package/dist/cjs/ai-assistant/AiSessionEngine.d.ts +3 -0
  2. package/dist/cjs/ai-assistant/AiSessionEngine.js +33 -0
  3. package/dist/cjs/ai-assistant/MockAiTransport.d.ts +4 -1
  4. package/dist/cjs/ai-assistant/MockAiTransport.js +14 -2
  5. package/dist/cjs/ai-assistant/index.d.ts +1 -1
  6. package/dist/cjs/ai-assistant/types.d.ts +41 -0
  7. package/dist/cjs/basic-components/CompanyChart/Chart.d.ts +20 -0
  8. package/dist/cjs/basic-components/CompanyChart/Chart.js +93 -0
  9. package/dist/cjs/basic-components/CompanyChart/index.d.ts +3 -0
  10. package/dist/cjs/basic-components/CompanyChart/index.js +27 -0
  11. package/dist/cjs/basic-components/CompanyChart/presets.d.ts +102 -0
  12. package/dist/cjs/basic-components/CompanyChart/presets.js +147 -0
  13. package/dist/cjs/basic-components/CompanyChart/theme.d.ts +9 -0
  14. package/dist/cjs/basic-components/CompanyChart/theme.js +45 -0
  15. package/dist/cjs/basic-components/CompanyChart/utils.d.ts +6 -0
  16. package/dist/cjs/basic-components/CompanyChart/utils.js +39 -0
  17. package/dist/cjs/basic-components/index.d.ts +2 -0
  18. package/dist/cjs/basic-components/index.js +5 -1
  19. package/dist/cjs/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  20. package/dist/cjs/shared-components/CompanyAiAssistant/index.js +99 -26
  21. package/dist/cjs/shared-components/CompanyAiAssistant/index.scss +79 -0
  22. package/dist/cjs/sidebar-config.d.ts +2 -0
  23. package/dist/cjs/sidebar-config.js +23 -0
  24. package/dist/es/ai-assistant/AiSessionEngine.d.ts +3 -0
  25. package/dist/es/ai-assistant/AiSessionEngine.js +56 -1
  26. package/dist/es/ai-assistant/MockAiTransport.d.ts +4 -1
  27. package/dist/es/ai-assistant/MockAiTransport.js +11 -2
  28. package/dist/es/ai-assistant/index.d.ts +1 -1
  29. package/dist/es/ai-assistant/types.d.ts +41 -0
  30. package/dist/es/basic-components/CompanyChart/Chart.d.ts +20 -0
  31. package/dist/es/basic-components/CompanyChart/Chart.js +91 -0
  32. package/dist/es/basic-components/CompanyChart/index.d.ts +3 -0
  33. package/dist/es/basic-components/CompanyChart/index.js +3 -0
  34. package/dist/es/basic-components/CompanyChart/presets.d.ts +102 -0
  35. package/dist/es/basic-components/CompanyChart/presets.js +229 -0
  36. package/dist/es/basic-components/CompanyChart/theme.d.ts +9 -0
  37. package/dist/es/basic-components/CompanyChart/theme.js +36 -0
  38. package/dist/es/basic-components/CompanyChart/utils.d.ts +6 -0
  39. package/dist/es/basic-components/CompanyChart/utils.js +26 -0
  40. package/dist/es/basic-components/index.d.ts +2 -0
  41. package/dist/es/basic-components/index.js +3 -1
  42. package/dist/es/shared-components/CompanyAiAssistant/index.d.ts +3 -1
  43. package/dist/es/shared-components/CompanyAiAssistant/index.js +121 -37
  44. package/dist/es/shared-components/CompanyAiAssistant/index.scss +79 -0
  45. package/dist/es/sidebar-config.d.ts +2 -0
  46. package/dist/es/sidebar-config.js +30 -0
  47. package/package.json +3 -2
@@ -0,0 +1,45 @@
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/basic-components/CompanyChart/theme.ts
20
+ var theme_exports = {};
21
+ __export(theme_exports, {
22
+ CHART_COLOR_10: () => CHART_COLOR_10,
23
+ CHART_COLOR_20: () => CHART_COLOR_20,
24
+ companyChartTheme: () => companyChartTheme
25
+ });
26
+ module.exports = __toCommonJS(theme_exports);
27
+ var import_paletteMapping = require("../../theme/paletteMapping");
28
+ var uniqueChartColors = [...new Set(import_paletteMapping.CHART_SEQUENCE.map((s) => s.color))];
29
+ var CHART_COLOR_10 = uniqueChartColors;
30
+ var CHART_COLOR_20 = import_paletteMapping.PALETTES.filter(
31
+ (p) => uniqueChartColors.includes(p.colors[5])
32
+ ).flatMap((p) => [p.colors[5], p.colors[3]]);
33
+ var companyChartTheme = {
34
+ type: "classic",
35
+ /** 单系列默认色(G2 Light 主题 colorDefault 为蓝色 #1783FF,必须覆盖为品牌橙) */
36
+ color: CHART_COLOR_10[0],
37
+ category10: CHART_COLOR_10,
38
+ category20: CHART_COLOR_20
39
+ };
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ CHART_COLOR_10,
43
+ CHART_COLOR_20,
44
+ companyChartTheme
45
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 深度合并:source 覆盖 target。
3
+ * - 数组整体替换(不做下标合并)
4
+ * - source 中为 undefined 的键不覆盖
5
+ */
6
+ export declare function deepMerge<T>(target: T, source: unknown): T;
@@ -0,0 +1,39 @@
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/basic-components/CompanyChart/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ deepMerge: () => deepMerge
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ var isPlainObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
26
+ function deepMerge(target, source) {
27
+ if (!isPlainObject(source) || !isPlainObject(target)) {
28
+ return source === void 0 ? target : source;
29
+ }
30
+ const result = { ...target };
31
+ for (const key of Object.keys(source)) {
32
+ result[key] = deepMerge(result[key], source[key]);
33
+ }
34
+ return result;
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ deepMerge
39
+ });
@@ -13,6 +13,7 @@ export * from "./CompanyBubble";
13
13
  export * from "./CompanyButton";
14
14
  export * from "./CompanyCalendar";
15
15
  export * from "./CompanyCard";
16
+ export * from "./CompanyChart";
16
17
  export * from "./CompanyCarousel";
17
18
  export * from "./CompanyCascader";
18
19
  export * from "./CompanyCheckbox";
@@ -85,3 +86,4 @@ export * from "./CompanyTypography";
85
86
  export * from "./CompanyUpload";
86
87
  export * from "./CompanyWatermark";
87
88
  export * from "./CompanyWelcome";
89
+ export * from "./CompanyXProvider";
@@ -31,6 +31,7 @@ __reExport(basic_components_exports, require("./CompanyBubble"), module.exports)
31
31
  __reExport(basic_components_exports, require("./CompanyButton"), module.exports);
32
32
  __reExport(basic_components_exports, require("./CompanyCalendar"), module.exports);
33
33
  __reExport(basic_components_exports, require("./CompanyCard"), module.exports);
34
+ __reExport(basic_components_exports, require("./CompanyChart"), module.exports);
34
35
  __reExport(basic_components_exports, require("./CompanyCarousel"), module.exports);
35
36
  __reExport(basic_components_exports, require("./CompanyCascader"), module.exports);
36
37
  __reExport(basic_components_exports, require("./CompanyCheckbox"), module.exports);
@@ -103,6 +104,7 @@ __reExport(basic_components_exports, require("./CompanyTypography"), module.expo
103
104
  __reExport(basic_components_exports, require("./CompanyUpload"), module.exports);
104
105
  __reExport(basic_components_exports, require("./CompanyWatermark"), module.exports);
105
106
  __reExport(basic_components_exports, require("./CompanyWelcome"), module.exports);
107
+ __reExport(basic_components_exports, require("./CompanyXProvider"), module.exports);
106
108
  // Annotate the CommonJS export names for ESM import in node:
107
109
  0 && (module.exports = {
108
110
  ...require("./CompanyActions"),
@@ -120,6 +122,7 @@ __reExport(basic_components_exports, require("./CompanyWelcome"), module.exports
120
122
  ...require("./CompanyButton"),
121
123
  ...require("./CompanyCalendar"),
122
124
  ...require("./CompanyCard"),
125
+ ...require("./CompanyChart"),
123
126
  ...require("./CompanyCarousel"),
124
127
  ...require("./CompanyCascader"),
125
128
  ...require("./CompanyCheckbox"),
@@ -191,5 +194,6 @@ __reExport(basic_components_exports, require("./CompanyWelcome"), module.exports
191
194
  ...require("./CompanyTypography"),
192
195
  ...require("./CompanyUpload"),
193
196
  ...require("./CompanyWatermark"),
194
- ...require("./CompanyWelcome")
197
+ ...require("./CompanyWelcome"),
198
+ ...require("./CompanyXProvider")
195
199
  });
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties } from "react";
2
- import type { AiMessage, AiReference, AiReferenceTab, AiSuggestion } from "../../ai-assistant/types";
2
+ import type { AiMessage, AiReference, AiReferenceTab, AiSuggestion, AiToolCallView } from "../../ai-assistant/types";
3
3
  import "./index.scss";
4
4
  export interface CompanyAiAssistantProps {
5
5
  /** 消息列表(含流式累积中的消息) */
@@ -18,6 +18,8 @@ export interface CompanyAiAssistantProps {
18
18
  reference?: AiReference | null;
19
19
  /** @ 引用可选的页签列表(缺省禁用 @ 触发与引用条) */
20
20
  referenceTabs?: AiReferenceTab[];
21
+ /** 工具调用列表(受控;引擎归并的 toolCalls 或业务侧自管数据,非空时展示折叠思维链) */
22
+ toolCalls?: AiToolCallView[];
21
23
  /** 发送消息 */
22
24
  onSend?: (text: string) => void;
23
25
  /** 引用变更(@ 选择设置、tag 关闭清除) */
@@ -81,6 +81,59 @@ function ActionChip({
81
81
  }
82
82
  );
83
83
  }
84
+ var TOOL_STATUS_TEXT = {
85
+ pending: "等待中",
86
+ running: "执行中",
87
+ succeeded: "已完成",
88
+ failed: "失败",
89
+ skipped: "已跳过"
90
+ };
91
+ function toChainStatus(status) {
92
+ switch (status) {
93
+ case "running":
94
+ return "loading";
95
+ case "succeeded":
96
+ return "success";
97
+ case "failed":
98
+ return "error";
99
+ case "skipped":
100
+ return "abort";
101
+ default:
102
+ return void 0;
103
+ }
104
+ }
105
+ function ToolCallChain({ toolCalls }) {
106
+ const items = toolCalls.map((call) => {
107
+ const chainStatus = toChainStatus(call.status);
108
+ return {
109
+ key: call.callId,
110
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "company-ai-assistant__tool-title", children: [
111
+ call.name,
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
113
+ "span",
114
+ {
115
+ className: `company-ai-assistant__tool-status company-ai-assistant__tool-status--${call.status}`,
116
+ children: TOOL_STATUS_TEXT[call.status]
117
+ }
118
+ )
119
+ ] }),
120
+ content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__tool-detail", children: [
121
+ call.result && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "company-ai-assistant__tool-result", children: call.result }),
122
+ call.args !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "company-ai-assistant__tool-args", children: JSON.stringify(call.args, null, 2) })
123
+ ] }),
124
+ ...chainStatus ? { status: chainStatus } : {},
125
+ collapsible: true
126
+ };
127
+ });
128
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
+ import_basic_components.CompanyThoughtChain,
130
+ {
131
+ className: "company-ai-assistant__tools",
132
+ items,
133
+ defaultExpandedKeys: []
134
+ }
135
+ );
136
+ }
84
137
  function CompanyAiAssistant(props) {
85
138
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AssistantPanel, { ...props }) });
86
139
  }
@@ -93,6 +146,7 @@ function AssistantPanel({
93
146
  canValidate = true,
94
147
  reference,
95
148
  referenceTabs,
149
+ toolCalls,
96
150
  onSend,
97
151
  onReferenceChange,
98
152
  onPinToggle,
@@ -143,7 +197,7 @@ function AssistantPanel({
143
197
  const list = listRef.current;
144
198
  if (list)
145
199
  list.scrollTop = list.scrollHeight;
146
- }, [messages, streaming]);
200
+ }, [messages, streaming, toolCalls]);
147
201
  const handleSubmit = (text) => {
148
202
  const trimmed = text.trim();
149
203
  if (!trimmed || streaming)
@@ -169,6 +223,9 @@ function AssistantPanel({
169
223
  "--caa-primary": token.colorPrimary,
170
224
  "--caa-primary-bg": token.colorPrimaryBg,
171
225
  "--caa-on-primary": token.colorTextLightSolid,
226
+ "--caa-success": token.colorSuccess,
227
+ "--caa-error": token.colorError,
228
+ "--caa-warning": token.colorWarning,
172
229
  "--caa-radius": `${token.borderRadius}px`,
173
230
  "--caa-radius-sm": `${token.borderRadiusSM}px`,
174
231
  "--caa-radius-lg": `${token.borderRadiusLG}px`,
@@ -204,31 +261,47 @@ function AssistantPanel({
204
261
  )
205
262
  ] })
206
263
  ] }),
207
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: listRef, className: "company-ai-assistant__messages", children: messages.map((message) => {
208
- const isStreamingTail = streaming && message.role === "assistant" && !message.content && !message.suggestion;
209
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
- "div",
211
- {
212
- className: `company-ai-assistant__msg company-ai-assistant__msg--${message.role}`,
213
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__bubble", children: [
214
- isStreamingTail ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "company-ai-assistant__typing", "aria-label": "正在输入", children: [
215
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
216
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
217
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {})
218
- ] }) : message.content,
219
- message.suggestion && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
- SuggestionCard,
221
- {
222
- suggestion: message.suggestion,
223
- applied: message.applied,
224
- onConfirm: onBackfill
225
- }
226
- )
227
- ] })
228
- },
229
- message.id
230
- );
231
- }) }),
264
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: listRef, className: "company-ai-assistant__messages", children: [
265
+ toolCalls && toolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallChain, { toolCalls }),
266
+ messages.map((message) => {
267
+ const isThinking = streaming && message.role === "assistant" && !message.content;
268
+ const isStreamingTail = isThinking && !message.reasoning && !message.suggestion;
269
+ const messageToolCalls = (toolCalls == null ? void 0 : toolCalls.length) ? void 0 : message.toolCalls;
270
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
271
+ "div",
272
+ {
273
+ className: `company-ai-assistant__msg company-ai-assistant__msg--${message.role}`,
274
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__bubble", children: [
275
+ message.reasoning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ import_basic_components.CompanyThink,
277
+ {
278
+ className: "company-ai-assistant__think",
279
+ title: isThinking ? "思考中" : "已完成思考",
280
+ loading: isThinking,
281
+ defaultExpanded: isThinking,
282
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "company-ai-assistant__think-body", children: message.reasoning })
283
+ }
284
+ ),
285
+ isStreamingTail ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "company-ai-assistant__typing", "aria-label": "正在输入", children: [
286
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
288
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {})
289
+ ] }) : message.content,
290
+ messageToolCalls && messageToolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallChain, { toolCalls: messageToolCalls }),
291
+ message.suggestion && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
292
+ SuggestionCard,
293
+ {
294
+ suggestion: message.suggestion,
295
+ applied: message.applied,
296
+ onConfirm: onBackfill
297
+ }
298
+ )
299
+ ] })
300
+ },
301
+ message.id
302
+ );
303
+ })
304
+ ] }),
232
305
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__footer", children: [
233
306
  showActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__actions", children: [
234
307
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -122,6 +122,18 @@
122
122
  word-break: break-word;
123
123
  }
124
124
 
125
+ // 思考过程区块(CompanyThink):与正文留出间距,正文为浅灰小字
126
+ &__think {
127
+ margin-bottom: 8px;
128
+ }
129
+
130
+ &__think-body {
131
+ font-size: 12px;
132
+ line-height: 20px;
133
+ color: rgba(0, 0, 0, 0.65);
134
+ white-space: pre-wrap;
135
+ }
136
+
125
137
  // 输入中动画(三个渐现圆点)
126
138
  &__typing {
127
139
  display: inline-flex;
@@ -216,6 +228,73 @@
216
228
  font-size: var(--caa-font-size);
217
229
  }
218
230
 
231
+ // ===== 工具调用(思维链折叠区,置于消息列表顶部) =====
232
+ &__tools {
233
+ margin: 0 16px 0 4px;
234
+ font-size: var(--caa-font-size-xs);
235
+ }
236
+
237
+ &__tool-title {
238
+ display: inline-flex;
239
+ align-items: center;
240
+ gap: 8px;
241
+ min-width: 0;
242
+ }
243
+
244
+ // 状态文案色:全部消费 token 派生的 CSS 变量,无硬编码色值
245
+ &__tool-status {
246
+ font-size: 12px;
247
+ line-height: 18px;
248
+
249
+ &--pending {
250
+ color: var(--caa-text-tertiary);
251
+ }
252
+
253
+ &--running {
254
+ color: var(--caa-primary);
255
+ }
256
+
257
+ &--succeeded {
258
+ color: var(--caa-success);
259
+ }
260
+
261
+ &--failed {
262
+ color: var(--caa-error);
263
+ }
264
+
265
+ &--skipped {
266
+ color: var(--caa-warning);
267
+ }
268
+ }
269
+
270
+ &__tool-detail {
271
+ display: flex;
272
+ flex-direction: column;
273
+ gap: 4px;
274
+ min-width: 0;
275
+ }
276
+
277
+ &__tool-result {
278
+ color: var(--caa-text-secondary);
279
+ line-height: 18px;
280
+ word-break: break-word;
281
+ }
282
+
283
+ &__tool-args {
284
+ margin: 0;
285
+ padding: 8px;
286
+ max-height: 160px;
287
+ overflow-y: auto;
288
+ background: var(--caa-bubble-bg);
289
+ border-radius: var(--caa-radius-sm);
290
+ color: var(--caa-text-secondary);
291
+ font-size: 12px;
292
+ line-height: 18px;
293
+ white-space: pre-wrap;
294
+ word-break: break-all;
295
+ box-sizing: border-box;
296
+ }
297
+
219
298
  // ===== 动作芯片(footer 顶部芯片行,与输入卡、免责声明共处同一容器) =====
220
299
  &__actions {
221
300
  flex-shrink: 0;
@@ -7,4 +7,6 @@ export interface SidebarGroup {
7
7
  children: SidebarItem[];
8
8
  }
9
9
  export declare const COMPONENT_GROUPS: SidebarGroup[];
10
+ /** 图表组件(独立 tab):AntV G2 5.0 图表组件,侧边栏单独成组 */
11
+ export declare const CHART_GROUPS: SidebarGroup[];
10
12
  export declare const TEMPLATE_GROUPS: SidebarGroup[];
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/sidebar-config.ts
20
20
  var sidebar_config_exports = {};
21
21
  __export(sidebar_config_exports, {
22
+ CHART_GROUPS: () => CHART_GROUPS,
22
23
  COMPONENT_GROUPS: () => COMPONENT_GROUPS,
23
24
  TEMPLATE_GROUPS: () => TEMPLATE_GROUPS
24
25
  });
@@ -153,6 +154,27 @@ var COMPONENT_GROUPS = [
153
154
  ]
154
155
  }
155
156
  ];
157
+ var CHART_GROUPS = [
158
+ {
159
+ title: "图表",
160
+ children: [
161
+ { title: "图表 Chart", link: "/antd-components/charts/companychart" },
162
+ { title: "折线图 LineChart", link: "/antd-components/charts/companylinechart" },
163
+ { title: "面积图 AreaChart", link: "/antd-components/charts/companyareachart" },
164
+ { title: "柱形图 BarChart", link: "/antd-components/charts/companybarchart" },
165
+ {
166
+ title: "分组柱形图 GroupedBarChart",
167
+ link: "/antd-components/charts/companygroupedbarchart"
168
+ },
169
+ {
170
+ title: "堆叠柱形图 StackedBarChart",
171
+ link: "/antd-components/charts/companystackedbarchart"
172
+ },
173
+ { title: "饼图 PieChart", link: "/antd-components/charts/companypiechart" },
174
+ { title: "环形图 DonutChart", link: "/antd-components/charts/companydonutchart" }
175
+ ]
176
+ }
177
+ ];
156
178
  var TEMPLATE_GROUPS = [
157
179
  {
158
180
  title: "页面级模板",
@@ -213,6 +235,7 @@ var TEMPLATE_GROUPS = [
213
235
  ];
214
236
  // Annotate the CommonJS export names for ESM import in node:
215
237
  0 && (module.exports = {
238
+ CHART_GROUPS,
216
239
  COMPONENT_GROUPS,
217
240
  TEMPLATE_GROUPS
218
241
  });
@@ -7,6 +7,8 @@ export interface AiSessionEngineOptions {
7
7
  getCapability: (tabKey: string) => AiPageCapability | undefined;
8
8
  /** 版本栈深度,默认 10(超出丢弃最旧) */
9
9
  maxSnapshots?: number;
10
+ /** 随请求发送的对话历史上限条数,默认 20(不含本轮消息) */
11
+ maxHistory?: number;
10
12
  }
11
13
  /**
12
14
  * 会话引擎:SSE 流式接收、消息历史、草稿版本栈。
@@ -21,6 +23,7 @@ export declare class AiSessionEngine {
21
23
  private readonly transport;
22
24
  private readonly getCapability;
23
25
  private readonly maxSnapshots;
26
+ private readonly maxHistory;
24
27
  constructor(options: AiSessionEngineOptions);
25
28
  /** 订阅会话表变更(订阅时立即回调一次当前快照) */
26
29
  subscribe(listener: (sessions: Record<string, AiSession>) => void): () => void;
@@ -52,16 +52,18 @@ function safeClone(data) {
52
52
  */
53
53
  export var AiSessionEngine = /*#__PURE__*/function () {
54
54
  function AiSessionEngine(options) {
55
- var _options$maxSnapshots;
55
+ var _options$maxSnapshots, _options$maxHistory;
56
56
  _classCallCheck(this, AiSessionEngine);
57
57
  _defineProperty(this, "sessions", new Map());
58
58
  _defineProperty(this, "listeners", new Set());
59
59
  _defineProperty(this, "transport", void 0);
60
60
  _defineProperty(this, "getCapability", void 0);
61
61
  _defineProperty(this, "maxSnapshots", void 0);
62
+ _defineProperty(this, "maxHistory", void 0);
62
63
  this.transport = options.transport;
63
64
  this.getCapability = options.getCapability;
64
65
  this.maxSnapshots = (_options$maxSnapshots = options.maxSnapshots) !== null && _options$maxSnapshots !== void 0 ? _options$maxSnapshots : 10;
66
+ this.maxHistory = (_options$maxHistory = options.maxHistory) !== null && _options$maxHistory !== void 0 ? _options$maxHistory : 20;
65
67
  }
66
68
 
67
69
  /** 订阅会话表变更(订阅时立即回调一次当前快照) */
@@ -109,6 +111,16 @@ export var AiSessionEngine = /*#__PURE__*/function () {
109
111
  } catch (_unused3) {
110
112
  context = undefined;
111
113
  }
114
+
115
+ // 本轮消息之前的对话历史:过滤空内容(流式占位/中断残留),按 maxHistory 截断最近条目
116
+ var history = session.messages.filter(function (item) {
117
+ return item.content.trim().length > 0;
118
+ }).slice(-this.maxHistory).map(function (item) {
119
+ return {
120
+ role: item.role,
121
+ content: item.content
122
+ };
123
+ });
112
124
  this.update(tabKey, {
113
125
  messages: [].concat(_toConsumableArray(session.messages), [createMessage("user", trimmed), createMessage("assistant", "")]),
114
126
  streaming: true
@@ -132,6 +144,20 @@ export var AiSessionEngine = /*#__PURE__*/function () {
132
144
  });
133
145
  break;
134
146
  }
147
+ case "thinking":
148
+ {
149
+ // 思考帧累积到 reasoning,与正文 content 分离渲染
150
+ if (isPlaceholder) {
151
+ var _last$reasoning;
152
+ messages[messages.length - 1] = _objectSpread(_objectSpread({}, last), {}, {
153
+ reasoning: ((_last$reasoning = last.reasoning) !== null && _last$reasoning !== void 0 ? _last$reasoning : "") + event.text
154
+ });
155
+ }
156
+ _this2.update(tabKey, {
157
+ messages: messages
158
+ });
159
+ break;
160
+ }
135
161
  case "action":
136
162
  {
137
163
  if (isPlaceholder) {
@@ -150,6 +176,34 @@ export var AiSessionEngine = /*#__PURE__*/function () {
150
176
  });
151
177
  break;
152
178
  }
179
+ case "tool":
180
+ {
181
+ // 工具帧按 callId 归并到占位助手消息:状态与结果以后帧为准,缺省字段不覆盖已捕获值
182
+ if (isPlaceholder) {
183
+ var _last$toolCalls;
184
+ var calls = _toConsumableArray((_last$toolCalls = last.toolCalls) !== null && _last$toolCalls !== void 0 ? _last$toolCalls : []);
185
+ var view = _objectSpread(_objectSpread({
186
+ callId: event.callId,
187
+ name: event.name,
188
+ status: event.status
189
+ }, event.args !== undefined ? {
190
+ args: event.args
191
+ } : {}), event.result !== undefined ? {
192
+ result: event.result
193
+ } : {});
194
+ var index = calls.findIndex(function (call) {
195
+ return call.callId === event.callId;
196
+ });
197
+ if (index >= 0) calls[index] = _objectSpread(_objectSpread({}, calls[index]), view);else calls.push(view);
198
+ messages[messages.length - 1] = _objectSpread(_objectSpread({}, last), {}, {
199
+ toolCalls: calls
200
+ });
201
+ }
202
+ _this2.update(tabKey, {
203
+ messages: messages
204
+ });
205
+ break;
206
+ }
153
207
  case "done":
154
208
  {
155
209
  _this2.update(tabKey, {
@@ -185,6 +239,7 @@ export var AiSessionEngine = /*#__PURE__*/function () {
185
239
  // 无页面契约时为系统级交互,后端按 system 场景路由通用问答
186
240
  scene: (_capability$scene = capability === null || capability === void 0 ? void 0 : capability.scene) !== null && _capability$scene !== void 0 ? _capability$scene : "system",
187
241
  context: context,
242
+ history: history,
188
243
  message: trimmed,
189
244
  onEvent: handleEvent
190
245
  });
@@ -1,9 +1,11 @@
1
- import type { AiContext, AiStreamEvent, AiTransport } from "./types";
1
+ import type { AiContext, AiHistoryMessage, AiStreamEvent, AiTransport } from "./types";
2
2
  export interface MockAiTransportOptions {
3
3
  /** 自定义应答脚本:返回流式帧序列;缺省使用内置通用问答脚本 */
4
4
  respond?: (params: {
5
5
  scene: string;
6
6
  context?: AiContext;
7
+ /** 近 N 轮对话历史(不含本轮 message) */
8
+ history?: AiHistoryMessage[];
7
9
  message: string;
8
10
  }) => AiStreamEvent[];
9
11
  /** 每帧间隔(ms),默认 120 */
@@ -20,6 +22,7 @@ export declare class MockAiTransport implements AiTransport {
20
22
  send(params: {
21
23
  scene: string;
22
24
  context?: AiContext;
25
+ history?: AiHistoryMessage[];
23
26
  message: string;
24
27
  onEvent: (event: AiStreamEvent) => void;
25
28
  }): void;
@@ -5,11 +5,18 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- /** 内置通用问答脚本:页面未注册能力契约时的兜底回复 */
8
+ /** 内置通用问答脚本:页面未注册能力契约时的兜底回复(含思考过程演示) */
9
9
  function defaultRespond(params) {
10
- var _params$context;
10
+ var _params$context, _params$history$lengt, _params$history;
11
11
  var title = (_params$context = params.context) === null || _params$context === void 0 ? void 0 : _params$context.sceneTitle;
12
+ var historyCount = (_params$history$lengt = (_params$history = params.history) === null || _params$history === void 0 ? void 0 : _params$history.length) !== null && _params$history$lengt !== void 0 ? _params$history$lengt : 0;
12
13
  return [{
14
+ type: "thinking",
15
+ text: "先理解用户诉求,结合当前页面上下文判断意图。"
16
+ }, {
17
+ type: "thinking",
18
+ text: historyCount > 0 ? "\u7ED3\u5408\u6B64\u524D ".concat(historyCount, " \u8F6E\u5BF9\u8BDD\u5386\u53F2\u4E0E\u9875\u9762\u4FE1\u606F\uFF0C\u7EC4\u7EC7\u672C\u6B21\u56DE\u7B54\u3002") : "本轮暂无对话历史,基于页面上下文组织回答。"
19
+ }, {
13
20
  type: "delta",
14
21
  text: title ? "\u6536\u5230\uFF0C\u5F53\u524D\u4E3A[".concat(title, "]\u3002") : "收到。"
15
22
  }, {
@@ -44,10 +51,12 @@ export var MockAiTransport = /*#__PURE__*/function () {
44
51
  var events = (_this$options$respond = (_this$options$respond2 = (_this$options = this.options).respond) === null || _this$options$respond2 === void 0 ? void 0 : _this$options$respond2.call(_this$options, {
45
52
  scene: params.scene,
46
53
  context: params.context,
54
+ history: params.history,
47
55
  message: params.message
48
56
  })) !== null && _this$options$respond !== void 0 ? _this$options$respond : defaultRespond({
49
57
  scene: params.scene,
50
58
  context: params.context,
59
+ history: params.history,
51
60
  message: params.message
52
61
  });
53
62
  var index = 0;
@@ -1,6 +1,6 @@
1
1
  export * from "./AiActionGuard";
2
2
  export * from "./aiDraft";
3
- export type { AiContext, AiMessage, AiMessageRole, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
3
+ export type { AiContext, AiMessage, AiMessageRole, AiPageActions, AiPageCapability, AiReference, AiReferenceTab, AiSession, AiSnapshot, AiStreamEvent, AiSuggestion, AiToolCallStatus, AiToolCallView, AiTransport, AiValidateIssue, AiValidateReport, FormPatch, } from "./types";
4
4
  export { AiSessionEngine } from "./AiSessionEngine";
5
5
  export type { AiSessionEngineOptions } from "./AiSessionEngine";
6
6
  export { MockAiTransport } from "./MockAiTransport";