@donglegeyu/company-ui 1.2.44 → 1.2.46

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.
@@ -130,6 +130,26 @@ var AiSessionEngine = class {
130
130
  this.update(tabKey, { messages });
131
131
  break;
132
132
  }
133
+ case "tool": {
134
+ if (isPlaceholder) {
135
+ const calls = [...last.toolCalls ?? []];
136
+ const view = {
137
+ callId: event.callId,
138
+ name: event.name,
139
+ status: event.status,
140
+ ...event.args !== void 0 ? { args: event.args } : {},
141
+ ...event.result !== void 0 ? { result: event.result } : {}
142
+ };
143
+ const index = calls.findIndex((call) => call.callId === event.callId);
144
+ if (index >= 0)
145
+ calls[index] = { ...calls[index], ...view };
146
+ else
147
+ calls.push(view);
148
+ messages[messages.length - 1] = { ...last, toolCalls: calls };
149
+ }
150
+ this.update(tabKey, { messages });
151
+ break;
152
+ }
133
153
  case "done": {
134
154
  this.update(tabKey, { messages, streaming: false });
135
155
  break;
@@ -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";
@@ -74,6 +74,21 @@ export interface AiSuggestion {
74
74
  /** 补丁数据:确认后传给 actions.backfill */
75
75
  patch: FormPatch;
76
76
  }
77
+ /** 工具调用状态 */
78
+ export type AiToolCallStatus = "pending" | "running" | "succeeded" | "failed" | "skipped";
79
+ /** 工具调用视图(tool 帧按 callId 归并后的展示结构;面板受控渲染) */
80
+ export interface AiToolCallView {
81
+ /** 调用唯一标识(同一 callId 的后续帧覆盖状态与结果) */
82
+ callId: string;
83
+ /** 工具名 */
84
+ name: string;
85
+ /** 入参(自由结构;面板仅做只读摘要展示,完整入参不进面板) */
86
+ args?: Record<string, unknown>;
87
+ /** 调用状态 */
88
+ status: AiToolCallStatus;
89
+ /** 结果摘要(单行简述;完整结果不进面板) */
90
+ result?: string;
91
+ }
77
92
  /** 面板消息 */
78
93
  export interface AiMessage {
79
94
  id: string;
@@ -84,6 +99,8 @@ export interface AiMessage {
84
99
  suggestion?: AiSuggestion;
85
100
  /** 建议是否已确认回填(已确认后芯片置为已完成态) */
86
101
  applied?: boolean;
102
+ /** 本轮工具调用(tool 帧按 callId 归并;仅 assistant 消息) */
103
+ toolCalls?: AiToolCallView[];
87
104
  createdAt: number;
88
105
  }
89
106
  /** 草稿快照(backfill 前自动压栈,rollback 出栈恢复) */
@@ -112,6 +129,18 @@ export type AiStreamEvent = {
112
129
  patch: FormPatch;
113
130
  title?: string;
114
131
  items?: string[];
132
+ } | {
133
+ type: "tool";
134
+ /** 调用唯一标识(同一 callId 多帧归并为一次调用,后帧覆盖状态与结果) */
135
+ callId: string;
136
+ /** 工具名 */
137
+ name: string;
138
+ /** 入参(自由结构) */
139
+ args?: Record<string, unknown>;
140
+ /** 调用状态 */
141
+ status: AiToolCallStatus;
142
+ /** 结果摘要 */
143
+ result?: string;
115
144
  } | {
116
145
  type: "done";
117
146
  } | {
@@ -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,36 @@ 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 isStreamingTail = streaming && message.role === "assistant" && !message.content && !message.suggestion;
268
+ const messageToolCalls = (toolCalls == null ? void 0 : toolCalls.length) ? void 0 : message.toolCalls;
269
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
270
+ "div",
271
+ {
272
+ className: `company-ai-assistant__msg company-ai-assistant__msg--${message.role}`,
273
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__bubble", children: [
274
+ isStreamingTail ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "company-ai-assistant__typing", "aria-label": "正在输入", children: [
275
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
276
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {}),
277
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", {})
278
+ ] }) : message.content,
279
+ messageToolCalls && messageToolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolCallChain, { toolCalls: messageToolCalls }),
280
+ message.suggestion && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ SuggestionCard,
282
+ {
283
+ suggestion: message.suggestion,
284
+ applied: message.applied,
285
+ onConfirm: onBackfill
286
+ }
287
+ )
288
+ ] })
289
+ },
290
+ message.id
291
+ );
292
+ })
293
+ ] }),
232
294
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__footer", children: [
233
295
  showActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-ai-assistant__actions", children: [
234
296
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -216,6 +216,73 @@
216
216
  font-size: var(--caa-font-size);
217
217
  }
218
218
 
219
+ // ===== 工具调用(思维链折叠区,置于消息列表顶部) =====
220
+ &__tools {
221
+ margin: 0 16px 0 4px;
222
+ font-size: var(--caa-font-size-xs);
223
+ }
224
+
225
+ &__tool-title {
226
+ display: inline-flex;
227
+ align-items: center;
228
+ gap: 8px;
229
+ min-width: 0;
230
+ }
231
+
232
+ // 状态文案色:全部消费 token 派生的 CSS 变量,无硬编码色值
233
+ &__tool-status {
234
+ font-size: 12px;
235
+ line-height: 18px;
236
+
237
+ &--pending {
238
+ color: var(--caa-text-tertiary);
239
+ }
240
+
241
+ &--running {
242
+ color: var(--caa-primary);
243
+ }
244
+
245
+ &--succeeded {
246
+ color: var(--caa-success);
247
+ }
248
+
249
+ &--failed {
250
+ color: var(--caa-error);
251
+ }
252
+
253
+ &--skipped {
254
+ color: var(--caa-warning);
255
+ }
256
+ }
257
+
258
+ &__tool-detail {
259
+ display: flex;
260
+ flex-direction: column;
261
+ gap: 4px;
262
+ min-width: 0;
263
+ }
264
+
265
+ &__tool-result {
266
+ color: var(--caa-text-secondary);
267
+ line-height: 18px;
268
+ word-break: break-word;
269
+ }
270
+
271
+ &__tool-args {
272
+ margin: 0;
273
+ padding: 8px;
274
+ max-height: 160px;
275
+ overflow-y: auto;
276
+ background: var(--caa-bubble-bg);
277
+ border-radius: var(--caa-radius-sm);
278
+ color: var(--caa-text-secondary);
279
+ font-size: 12px;
280
+ line-height: 18px;
281
+ white-space: pre-wrap;
282
+ word-break: break-all;
283
+ box-sizing: border-box;
284
+ }
285
+
219
286
  // ===== 动作芯片(footer 顶部芯片行,与输入卡、免责声明共处同一容器) =====
220
287
  &__actions {
221
288
  flex-shrink: 0;
@@ -150,6 +150,34 @@ export var AiSessionEngine = /*#__PURE__*/function () {
150
150
  });
151
151
  break;
152
152
  }
153
+ case "tool":
154
+ {
155
+ // 工具帧按 callId 归并到占位助手消息:状态与结果以后帧为准,缺省字段不覆盖已捕获值
156
+ if (isPlaceholder) {
157
+ var _last$toolCalls;
158
+ var calls = _toConsumableArray((_last$toolCalls = last.toolCalls) !== null && _last$toolCalls !== void 0 ? _last$toolCalls : []);
159
+ var view = _objectSpread(_objectSpread({
160
+ callId: event.callId,
161
+ name: event.name,
162
+ status: event.status
163
+ }, event.args !== undefined ? {
164
+ args: event.args
165
+ } : {}), event.result !== undefined ? {
166
+ result: event.result
167
+ } : {});
168
+ var index = calls.findIndex(function (call) {
169
+ return call.callId === event.callId;
170
+ });
171
+ if (index >= 0) calls[index] = _objectSpread(_objectSpread({}, calls[index]), view);else calls.push(view);
172
+ messages[messages.length - 1] = _objectSpread(_objectSpread({}, last), {}, {
173
+ toolCalls: calls
174
+ });
175
+ }
176
+ _this2.update(tabKey, {
177
+ messages: messages
178
+ });
179
+ break;
180
+ }
153
181
  case "done":
154
182
  {
155
183
  _this2.update(tabKey, {
@@ -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";
@@ -74,6 +74,21 @@ export interface AiSuggestion {
74
74
  /** 补丁数据:确认后传给 actions.backfill */
75
75
  patch: FormPatch;
76
76
  }
77
+ /** 工具调用状态 */
78
+ export type AiToolCallStatus = "pending" | "running" | "succeeded" | "failed" | "skipped";
79
+ /** 工具调用视图(tool 帧按 callId 归并后的展示结构;面板受控渲染) */
80
+ export interface AiToolCallView {
81
+ /** 调用唯一标识(同一 callId 的后续帧覆盖状态与结果) */
82
+ callId: string;
83
+ /** 工具名 */
84
+ name: string;
85
+ /** 入参(自由结构;面板仅做只读摘要展示,完整入参不进面板) */
86
+ args?: Record<string, unknown>;
87
+ /** 调用状态 */
88
+ status: AiToolCallStatus;
89
+ /** 结果摘要(单行简述;完整结果不进面板) */
90
+ result?: string;
91
+ }
77
92
  /** 面板消息 */
78
93
  export interface AiMessage {
79
94
  id: string;
@@ -84,6 +99,8 @@ export interface AiMessage {
84
99
  suggestion?: AiSuggestion;
85
100
  /** 建议是否已确认回填(已确认后芯片置为已完成态) */
86
101
  applied?: boolean;
102
+ /** 本轮工具调用(tool 帧按 callId 归并;仅 assistant 消息) */
103
+ toolCalls?: AiToolCallView[];
87
104
  createdAt: number;
88
105
  }
89
106
  /** 草稿快照(backfill 前自动压栈,rollback 出栈恢复) */
@@ -112,6 +129,18 @@ export type AiStreamEvent = {
112
129
  patch: FormPatch;
113
130
  title?: string;
114
131
  items?: string[];
132
+ } | {
133
+ type: "tool";
134
+ /** 调用唯一标识(同一 callId 多帧归并为一次调用,后帧覆盖状态与结果) */
135
+ callId: string;
136
+ /** 工具名 */
137
+ name: string;
138
+ /** 入参(自由结构) */
139
+ args?: Record<string, unknown>;
140
+ /** 调用状态 */
141
+ status: AiToolCallStatus;
142
+ /** 结果摘要 */
143
+ result?: string;
115
144
  } | {
116
145
  type: "done";
117
146
  } | {
@@ -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 关闭清除) */
@@ -13,7 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
13
13
  import { useEffect, useMemo, useRef, useState } from "react";
14
14
  import { ConfigProvider, theme } from "antd";
15
15
  import SvgIcon from "../SvgIcon";
16
- import { CompanySender, CompanySuggestion } from "../../basic-components";
16
+ import { CompanySender, CompanySuggestion, CompanyThoughtChain } from "../../basic-components";
17
17
  import { companyTheme } from "../../theme";
18
18
  import "./index.scss";
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -70,6 +70,68 @@ function ActionChip(_ref2) {
70
70
  });
71
71
  }
72
72
 
73
+ /** 工具调用状态文案 */
74
+ var TOOL_STATUS_TEXT = {
75
+ pending: "等待中",
76
+ running: "执行中",
77
+ succeeded: "已完成",
78
+ failed: "失败",
79
+ skipped: "已跳过"
80
+ };
81
+
82
+ /** AiToolCallStatus → ThoughtChain 节点状态(pending 无状态图标) */
83
+ function toChainStatus(status) {
84
+ switch (status) {
85
+ case "running":
86
+ return "loading";
87
+ case "succeeded":
88
+ return "success";
89
+ case "failed":
90
+ return "error";
91
+ case "skipped":
92
+ return "abort";
93
+ default:
94
+ return undefined;
95
+ }
96
+ }
97
+
98
+ /** 工具调用折叠思维链(每个调用一个可折叠节点,标题带状态色文案) */
99
+ function ToolCallChain(_ref3) {
100
+ var toolCalls = _ref3.toolCalls;
101
+ var items = toolCalls.map(function (call) {
102
+ var chainStatus = toChainStatus(call.status);
103
+ return _objectSpread(_objectSpread({
104
+ key: call.callId,
105
+ title: /*#__PURE__*/_jsxs("span", {
106
+ className: "company-ai-assistant__tool-title",
107
+ children: [call.name, /*#__PURE__*/_jsx("span", {
108
+ className: "company-ai-assistant__tool-status company-ai-assistant__tool-status--".concat(call.status),
109
+ children: TOOL_STATUS_TEXT[call.status]
110
+ })]
111
+ }),
112
+ content: /*#__PURE__*/_jsxs("div", {
113
+ className: "company-ai-assistant__tool-detail",
114
+ children: [call.result && /*#__PURE__*/_jsx("div", {
115
+ className: "company-ai-assistant__tool-result",
116
+ children: call.result
117
+ }), call.args !== undefined && /*#__PURE__*/_jsx("pre", {
118
+ className: "company-ai-assistant__tool-args",
119
+ children: JSON.stringify(call.args, null, 2)
120
+ })]
121
+ })
122
+ }, chainStatus ? {
123
+ status: chainStatus
124
+ } : {}), {}, {
125
+ collapsible: true
126
+ });
127
+ });
128
+ return /*#__PURE__*/_jsx(CompanyThoughtChain, {
129
+ className: "company-ai-assistant__tools",
130
+ items: items,
131
+ defaultExpandedKeys: []
132
+ });
133
+ }
134
+
73
135
  /**
74
136
  * AI 智能助手面板(纯展示组件)。
75
137
  *
@@ -84,31 +146,32 @@ export default function CompanyAiAssistant(props) {
84
146
  children: /*#__PURE__*/_jsx(AssistantPanel, _objectSpread({}, props))
85
147
  });
86
148
  }
87
- function AssistantPanel(_ref3) {
88
- var messages = _ref3.messages,
89
- _ref3$streaming = _ref3.streaming,
90
- streaming = _ref3$streaming === void 0 ? false : _ref3$streaming,
91
- _ref3$pinned = _ref3.pinned,
92
- pinned = _ref3$pinned === void 0 ? false : _ref3$pinned,
93
- _ref3$showActions = _ref3.showActions,
94
- showActions = _ref3$showActions === void 0 ? false : _ref3$showActions,
95
- _ref3$canRollback = _ref3.canRollback,
96
- canRollback = _ref3$canRollback === void 0 ? false : _ref3$canRollback,
97
- _ref3$canValidate = _ref3.canValidate,
98
- canValidate = _ref3$canValidate === void 0 ? true : _ref3$canValidate,
99
- reference = _ref3.reference,
100
- referenceTabs = _ref3.referenceTabs,
101
- onSend = _ref3.onSend,
102
- onReferenceChange = _ref3.onReferenceChange,
103
- onPinToggle = _ref3.onPinToggle,
104
- onClose = _ref3.onClose,
105
- onBackfill = _ref3.onBackfill,
106
- onRollback = _ref3.onRollback,
107
- onValidate = _ref3.onValidate,
108
- _ref3$placeholder = _ref3.placeholder,
109
- placeholder = _ref3$placeholder === void 0 ? "请输入" : _ref3$placeholder,
110
- className = _ref3.className,
111
- style = _ref3.style;
149
+ function AssistantPanel(_ref4) {
150
+ var messages = _ref4.messages,
151
+ _ref4$streaming = _ref4.streaming,
152
+ streaming = _ref4$streaming === void 0 ? false : _ref4$streaming,
153
+ _ref4$pinned = _ref4.pinned,
154
+ pinned = _ref4$pinned === void 0 ? false : _ref4$pinned,
155
+ _ref4$showActions = _ref4.showActions,
156
+ showActions = _ref4$showActions === void 0 ? false : _ref4$showActions,
157
+ _ref4$canRollback = _ref4.canRollback,
158
+ canRollback = _ref4$canRollback === void 0 ? false : _ref4$canRollback,
159
+ _ref4$canValidate = _ref4.canValidate,
160
+ canValidate = _ref4$canValidate === void 0 ? true : _ref4$canValidate,
161
+ reference = _ref4.reference,
162
+ referenceTabs = _ref4.referenceTabs,
163
+ toolCalls = _ref4.toolCalls,
164
+ onSend = _ref4.onSend,
165
+ onReferenceChange = _ref4.onReferenceChange,
166
+ onPinToggle = _ref4.onPinToggle,
167
+ onClose = _ref4.onClose,
168
+ onBackfill = _ref4.onBackfill,
169
+ onRollback = _ref4.onRollback,
170
+ onValidate = _ref4.onValidate,
171
+ _ref4$placeholder = _ref4.placeholder,
172
+ placeholder = _ref4$placeholder === void 0 ? "请输入" : _ref4$placeholder,
173
+ className = _ref4.className,
174
+ style = _ref4.style;
112
175
  var _theme$useToken = theme.useToken(),
113
176
  token = _theme$useToken.token;
114
177
  var _useState = useState(""),
@@ -166,11 +229,11 @@ function AssistantPanel(_ref3) {
166
229
  return undefined;
167
230
  }, [messages]);
168
231
 
169
- // 消息更新自动滚动到底部
232
+ // 消息/工具调用更新自动滚动到底部
170
233
  useEffect(function () {
171
234
  var list = listRef.current;
172
235
  if (list) list.scrollTop = list.scrollHeight;
173
- }, [messages, streaming]);
236
+ }, [messages, streaming, toolCalls]);
174
237
 
175
238
  // Sender 提交回调:拦截空白与流式接收中的提交,发送后清空输入
176
239
  var handleSubmit = function handleSubmit(text) {
@@ -201,6 +264,9 @@ function AssistantPanel(_ref3) {
201
264
  "--caa-primary": token.colorPrimary,
202
265
  "--caa-primary-bg": token.colorPrimaryBg,
203
266
  "--caa-on-primary": token.colorTextLightSolid,
267
+ "--caa-success": token.colorSuccess,
268
+ "--caa-error": token.colorError,
269
+ "--caa-warning": token.colorWarning,
204
270
  "--caa-radius": "".concat(token.borderRadius, "px"),
205
271
  "--caa-radius-sm": "".concat(token.borderRadiusSM, "px"),
206
272
  "--caa-radius-lg": "".concat(token.borderRadiusLG, "px"),
@@ -233,11 +299,15 @@ function AssistantPanel(_ref3) {
233
299
  onClick: handleIconClick(onClose)
234
300
  })]
235
301
  })]
236
- }), /*#__PURE__*/_jsx("div", {
302
+ }), /*#__PURE__*/_jsxs("div", {
237
303
  ref: listRef,
238
304
  className: "company-ai-assistant__messages",
239
- children: messages.map(function (message) {
305
+ children: [toolCalls && toolCalls.length > 0 && /*#__PURE__*/_jsx(ToolCallChain, {
306
+ toolCalls: toolCalls
307
+ }), messages.map(function (message) {
240
308
  var isStreamingTail = streaming && message.role === "assistant" && !message.content && !message.suggestion;
309
+ // 工具状态:顶层受控 toolCalls 优先,缺省时回落渲染该条消息自带的 toolCalls(引擎归并结果)
310
+ var messageToolCalls = toolCalls !== null && toolCalls !== void 0 && toolCalls.length ? undefined : message.toolCalls;
241
311
  return /*#__PURE__*/_jsx("div", {
242
312
  className: "company-ai-assistant__msg company-ai-assistant__msg--".concat(message.role),
243
313
  children: /*#__PURE__*/_jsxs("div", {
@@ -246,14 +316,16 @@ function AssistantPanel(_ref3) {
246
316
  className: "company-ai-assistant__typing",
247
317
  "aria-label": "\u6B63\u5728\u8F93\u5165",
248
318
  children: [/*#__PURE__*/_jsx("i", {}), /*#__PURE__*/_jsx("i", {}), /*#__PURE__*/_jsx("i", {})]
249
- }) : message.content, message.suggestion && /*#__PURE__*/_jsx(SuggestionCard, {
319
+ }) : message.content, messageToolCalls && messageToolCalls.length > 0 && /*#__PURE__*/_jsx(ToolCallChain, {
320
+ toolCalls: messageToolCalls
321
+ }), message.suggestion && /*#__PURE__*/_jsx(SuggestionCard, {
250
322
  suggestion: message.suggestion,
251
323
  applied: message.applied,
252
324
  onConfirm: onBackfill
253
325
  })]
254
326
  })
255
327
  }, message.id);
256
- })
328
+ })]
257
329
  }), /*#__PURE__*/_jsxs("div", {
258
330
  className: "company-ai-assistant__footer",
259
331
  children: [showActions && /*#__PURE__*/_jsxs("div", {
@@ -285,9 +357,9 @@ function AssistantPanel(_ref3) {
285
357
  onOpenChange: setSuggestOpen,
286
358
  onSelect: handleSelectReference,
287
359
  block: true,
288
- children: function children(_ref4) {
289
- var onTrigger = _ref4.onTrigger,
290
- _onKeyDown = _ref4.onKeyDown;
360
+ children: function children(_ref5) {
361
+ var onTrigger = _ref5.onTrigger,
362
+ _onKeyDown = _ref5.onKeyDown;
291
363
  return /*#__PURE__*/_jsxs("div", {
292
364
  className: "company-ai-assistant__input-area",
293
365
  children: [suggestEnabled && /*#__PURE__*/_jsx("div", {
@@ -216,6 +216,73 @@
216
216
  font-size: var(--caa-font-size);
217
217
  }
218
218
 
219
+ // ===== 工具调用(思维链折叠区,置于消息列表顶部) =====
220
+ &__tools {
221
+ margin: 0 16px 0 4px;
222
+ font-size: var(--caa-font-size-xs);
223
+ }
224
+
225
+ &__tool-title {
226
+ display: inline-flex;
227
+ align-items: center;
228
+ gap: 8px;
229
+ min-width: 0;
230
+ }
231
+
232
+ // 状态文案色:全部消费 token 派生的 CSS 变量,无硬编码色值
233
+ &__tool-status {
234
+ font-size: 12px;
235
+ line-height: 18px;
236
+
237
+ &--pending {
238
+ color: var(--caa-text-tertiary);
239
+ }
240
+
241
+ &--running {
242
+ color: var(--caa-primary);
243
+ }
244
+
245
+ &--succeeded {
246
+ color: var(--caa-success);
247
+ }
248
+
249
+ &--failed {
250
+ color: var(--caa-error);
251
+ }
252
+
253
+ &--skipped {
254
+ color: var(--caa-warning);
255
+ }
256
+ }
257
+
258
+ &__tool-detail {
259
+ display: flex;
260
+ flex-direction: column;
261
+ gap: 4px;
262
+ min-width: 0;
263
+ }
264
+
265
+ &__tool-result {
266
+ color: var(--caa-text-secondary);
267
+ line-height: 18px;
268
+ word-break: break-word;
269
+ }
270
+
271
+ &__tool-args {
272
+ margin: 0;
273
+ padding: 8px;
274
+ max-height: 160px;
275
+ overflow-y: auto;
276
+ background: var(--caa-bubble-bg);
277
+ border-radius: var(--caa-radius-sm);
278
+ color: var(--caa-text-secondary);
279
+ font-size: 12px;
280
+ line-height: 18px;
281
+ white-space: pre-wrap;
282
+ word-break: break-all;
283
+ box-sizing: border-box;
284
+ }
285
+
219
286
  // ===== 动作芯片(footer 顶部芯片行,与输入卡、免责声明共处同一容器) =====
220
287
  &__actions {
221
288
  flex-shrink: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donglegeyu/company-ui",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",
@@ -32,7 +32,10 @@
32
32
  "test:run": "vitest run",
33
33
  "test:coverage": "vitest run --coverage",
34
34
  "prepare": "husky",
35
- "prepublishOnly": "bash scripts/check-clean.sh && npm run build",
35
+ "prepack": "node scripts/gen-llms.mjs",
36
+ "prepublishOnly": "node scripts/prepublish-guard.mjs && npm run build && npm run verify:skill-examples",
37
+ "postpublish": "node scripts/postpublish.mjs",
38
+ "release:patch": "npm version patch && npm publish",
36
39
  "verify:skill-examples": "node scripts/verify-skill-examples.mjs"
37
40
  },
38
41
  "keywords": [