@done-coding/forge-kit-agent 0.0.0-stage → 0.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -2
  3. package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  4. package/es/components/bubble/AiBubbleContent.vue.mjs +7 -0
  5. package/es/components/bubble/AiBubbleContent.vue2.mjs +209 -0
  6. package/es/components/bubble/AiBubbleFooter.vue.mjs +7 -0
  7. package/es/components/bubble/AiBubbleFooter.vue2.mjs +91 -0
  8. package/es/components/bubble/AiCodeHeaderControl.vue.mjs +7 -0
  9. package/es/components/bubble/AiCodeHeaderControl.vue2.mjs +97 -0
  10. package/es/components/bubble/AiContentSplit.vue.mjs +70 -0
  11. package/es/components/bubble/AiContentSplit.vue2.mjs +4 -0
  12. package/es/components/bubble/AiPartRenderer.vue.mjs +7 -0
  13. package/es/components/bubble/AiPartRenderer.vue2.mjs +184 -0
  14. package/es/components/bubble/AiThinkBox.vue.mjs +7 -0
  15. package/es/components/bubble/AiThinkBox.vue2.mjs +155 -0
  16. package/es/components/bubble/AiTypewriter.vue.mjs +81 -0
  17. package/es/components/bubble/AiTypewriter.vue2.mjs +4 -0
  18. package/es/components/config/AiConfigProvider.vue.mjs +31 -0
  19. package/es/components/config/AiConfigProvider.vue2.mjs +4 -0
  20. package/es/components/dialogue/AiDialogue.vue.mjs +7 -0
  21. package/es/components/dialogue/AiDialogue.vue2.mjs +242 -0
  22. package/es/components/dialogue/AiDialogueGroup.vue.mjs +7 -0
  23. package/es/components/dialogue/AiDialogueGroup.vue2.mjs +133 -0
  24. package/es/components/dialogue/AiDialogueWrap.vue.mjs +7 -0
  25. package/es/components/dialogue/AiDialogueWrap.vue2.mjs +73 -0
  26. package/es/components/dialogue/AiMessageList.vue.mjs +7 -0
  27. package/es/components/dialogue/AiMessageList.vue2.mjs +111 -0
  28. package/es/components/json-trigger/LlmJsonTrigger.vue.mjs +7 -0
  29. package/es/components/json-trigger/LlmJsonTrigger.vue2.mjs +130 -0
  30. package/es/components/operation/AiOperationBar.vue.mjs +7 -0
  31. package/es/components/operation/AiOperationBar.vue2.mjs +174 -0
  32. package/es/components/operation/AiOperationBtns.vue.mjs +7 -0
  33. package/es/components/operation/AiOperationBtns.vue2.mjs +140 -0
  34. package/es/components/sender/AiSender.vue.mjs +7 -0
  35. package/es/components/sender/AiSender.vue2.mjs +74 -0
  36. package/es/components/sender/AiSenderHeader.vue.mjs +7 -0
  37. package/es/components/sender/AiSenderHeader.vue2.mjs +78 -0
  38. package/es/hooks/CodeXSlot.mjs +20 -0
  39. package/es/hooks/SessionExpose.mjs +81 -0
  40. package/es/hooks/agent-tools.mjs +95 -0
  41. package/es/hooks/agent.mjs +143 -0
  42. package/es/hooks/bubble-list.mjs +64 -0
  43. package/es/hooks/expose.mjs +133 -0
  44. package/es/hooks/fix-bubble-list-bug.mjs +65 -0
  45. package/es/hooks/sender-history.mjs +28 -0
  46. package/es/hooks/sender.mjs +197 -0
  47. package/es/hooks/session-list.mjs +154 -0
  48. package/es/hooks/sse.mjs +401 -0
  49. package/es/hooks/storage.mjs +217 -0
  50. package/es/hooks/theme.mjs +253 -0
  51. package/es/hooks/use-density.mjs +100 -0
  52. package/es/hooks/use-empty-state-center.mjs +40 -0
  53. package/es/hooks/use-keyboard-inset.mjs +87 -0
  54. package/es/index.mjs +68 -0
  55. package/es/style.css +836 -0
  56. package/es/types/index.mjs +54 -0
  57. package/es/utils/index.mjs +34 -0
  58. package/es/utils/json-from-llm.mjs +26 -0
  59. package/es/utils/request-llm.mjs +60 -0
  60. package/package.json +83 -4
  61. package/types/bridge/config-hook.d.ts +21 -0
  62. package/types/bridge/index.d.ts +69 -0
  63. package/types/bridge/plugin.d.ts +39 -0
  64. package/types/bridge/state.d.ts +26 -0
  65. package/types/bridge/storage.d.ts +10 -0
  66. package/types/components/bubble/AiBubbleContent.vue.d.ts +57 -0
  67. package/types/components/bubble/AiBubbleFooter.vue.d.ts +6 -0
  68. package/types/components/bubble/AiCodeHeaderControl.vue.d.ts +7 -0
  69. package/types/components/bubble/AiContentSplit.vue.d.ts +36 -0
  70. package/types/components/bubble/AiPartRenderer.vue.d.ts +9 -0
  71. package/types/components/bubble/AiThinkBox.vue.d.ts +31 -0
  72. package/types/components/bubble/AiTypewriter.vue.d.ts +28 -0
  73. package/types/components/config/AiConfigProvider.vue.d.ts +28 -0
  74. package/types/components/dialogue/AiDialogue.vue.d.ts +546 -0
  75. package/types/components/dialogue/AiDialogueGroup.vue.d.ts +49 -0
  76. package/types/components/dialogue/AiDialogueWrap.vue.d.ts +38 -0
  77. package/types/components/dialogue/AiMessageList.vue.d.ts +65 -0
  78. package/types/components/json-trigger/LlmJsonTrigger.vue.d.ts +43 -0
  79. package/types/components/json-trigger/types.d.ts +12 -0
  80. package/types/components/operation/AiOperationBar.vue.d.ts +36 -0
  81. package/types/components/operation/AiOperationBtns.vue.d.ts +27 -0
  82. package/types/components/sender/AiSender.vue.d.ts +38 -0
  83. package/types/components/sender/AiSenderHeader.vue.d.ts +28 -0
  84. package/types/hooks/CodeXSlot.d.ts +7 -0
  85. package/types/hooks/SessionExpose.d.ts +20 -0
  86. package/types/hooks/agent-tools.d.ts +67 -0
  87. package/types/hooks/agent.d.ts +43 -0
  88. package/types/hooks/bubble-list.d.ts +22 -0
  89. package/types/hooks/expose.d.ts +111 -0
  90. package/types/hooks/fix-bubble-list-bug.d.ts +8 -0
  91. package/types/hooks/sender-history.d.ts +41 -0
  92. package/types/hooks/sender.d.ts +101 -0
  93. package/types/hooks/session-list.d.ts +36 -0
  94. package/types/hooks/sse.d.ts +239 -0
  95. package/types/hooks/storage.d.ts +70 -0
  96. package/types/hooks/theme.d.ts +37 -0
  97. package/types/hooks/use-density.d.ts +66 -0
  98. package/types/hooks/use-empty-state-center.d.ts +23 -0
  99. package/types/hooks/use-keyboard-inset.d.ts +37 -0
  100. package/types/index.d.ts +26 -0
  101. package/types/inject/key.d.ts +20 -0
  102. package/types/types/index.d.ts +612 -0
  103. package/types/utils/index.d.ts +29 -0
  104. package/types/utils/json-from-llm.d.ts +35 -0
  105. package/types/utils/request-llm.d.ts +44 -0
@@ -0,0 +1,242 @@
1
+ import { defineComponent, useCssVars, unref, useModel, computed, ref, onMounted, onDeactivated, onBeforeUnmount, openBlock, createElementBlock, createElementVNode, normalizeClass, createVNode, withCtx, createSlots, renderSlot, normalizeProps, guardReactiveProps, isRef, createBlock, createCommentVNode, createTextVNode, toDisplayString, mergeModels, reactive } from "vue";
2
+ import { BubbleList, MentionSender } from "vue-element-plus-x";
3
+ import { useSenderScoped } from "../../hooks/sender.mjs";
4
+ import { createNewSessionInfo } from "../../hooks/session-list.mjs";
5
+ import { useBubbleListScoped } from "../../hooks/bubble-list.mjs";
6
+ import { useCodeXSlot } from "../../hooks/CodeXSlot.mjs";
7
+ import { useSessionExpose } from "../../hooks/SessionExpose.mjs";
8
+ import { createAiDb } from "../../hooks/storage.mjs";
9
+ import { getCssWithUnit } from "../../utils/index.mjs";
10
+ import AiBubbleContent from "../bubble/AiBubbleContent.vue.mjs";
11
+ import AiBubbleFooter from "../bubble/AiBubbleFooter.vue.mjs";
12
+ import AiSenderHeader from "../sender/AiSenderHeader.vue.mjs";
13
+ import { useEmptyStateCenter } from "../../hooks/use-empty-state-center.mjs";
14
+ import { ElText } from "element-plus";
15
+ const _hoisted_1 = {
16
+ class: "ai-dialogue"
17
+ };
18
+ const _hoisted_2 = {
19
+ key: 0,
20
+ class: "ai-dialogue-title"
21
+ };
22
+ const _sfc_main = /* @__PURE__ */ defineComponent({
23
+ __name: "AiDialogue",
24
+ props: /* @__PURE__ */ mergeModels({
25
+ db: {},
26
+ dbNamespace: {},
27
+ sseUrl: {},
28
+ sseConverter: {},
29
+ sseHeaders: {},
30
+ sseBody: {},
31
+ sseMessagesSerializer: {},
32
+ historyLimit: {},
33
+ tools: {},
34
+ onToolCall: {},
35
+ maxSteps: {},
36
+ userName: {},
37
+ swiftAsk: {},
38
+ greeting: {},
39
+ showTitle: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ showThink: {
44
+ type: Boolean,
45
+ default: false
46
+ },
47
+ bubbleMaxWidth: {
48
+ default: "100%"
49
+ },
50
+ showAvatar: {
51
+ type: Boolean
52
+ },
53
+ titleHeight: {
54
+ default: "43px"
55
+ },
56
+ logoUrl: {}
57
+ }, {
58
+ "sessionInfo": {
59
+ default: () => reactive(createNewSessionInfo())
60
+ },
61
+ "sessionInfoModifiers": {}
62
+ }),
63
+ emits: /* @__PURE__ */ mergeModels(["sessionEnable"], ["update:sessionInfo"]),
64
+ setup(__props, {
65
+ emit: __emit
66
+ }) {
67
+ useCssVars((_ctx) => ({
68
+ "v24b11b8b": titleHeightPx.value,
69
+ "fe3d968e": unref(emptyCenterOffset),
70
+ "v02fd7481": bubbleAvatarDisplay.value,
71
+ "d7d6d72c": _ctx.bubbleMaxWidth
72
+ }));
73
+ const props = __props;
74
+ const emits = __emit;
75
+ const sessionInfo = useModel(__props, "sessionInfo");
76
+ const {
77
+ list,
78
+ addBubble,
79
+ updateMessage,
80
+ loadMore
81
+ } = useBubbleListScoped({
82
+ db: props.db || createAiDb(props.userName, props.dbNamespace),
83
+ sessionInfo,
84
+ addSessionToList: (data) => emits("sessionEnable", data),
85
+ updateSession: (data) => {
86
+ sessionInfo.value = {
87
+ ...sessionInfo.value,
88
+ ...data
89
+ };
90
+ }
91
+ });
92
+ const isNewSession = computed(() => !sessionInfo.value.msgCount);
93
+ const senderHeaderRef = ref(null);
94
+ const {
95
+ offsetPx: emptyCenterOffset
96
+ } = useEmptyStateCenter(() => {
97
+ var _a;
98
+ return (_a = senderHeaderRef.value) == null ? void 0 : _a.$el;
99
+ }, isNewSession);
100
+ const bubbleAvatarDisplay = computed(() => props.showAvatar ? void 0 : "none");
101
+ const titleHeightPx = computed(() => props.showTitle ? getCssWithUnit(props.titleHeight) : "0px");
102
+ const {
103
+ senderValue,
104
+ placeholder,
105
+ autoSizeOptions,
106
+ submitBtnDisabled,
107
+ typingMsgCtrl,
108
+ fixBugCls,
109
+ noScrollAnimation,
110
+ historyRenderScrollShield,
111
+ setTypingMsgCtrl,
112
+ handleSubmit,
113
+ handleCancel,
114
+ isResponding
115
+ } = useSenderScoped({
116
+ getSseUrl: () => props.sseUrl,
117
+ converter: props.sseConverter,
118
+ addBubble,
119
+ // 以下四项走 getter:每轮发送时求值,消费方可在运行期改(直值会在 setup 期定格)
120
+ // 多轮上下文来源——发送时在 addBubble 之前取快照
121
+ getBubbleList: () => list.value,
122
+ getHeaders: () => props.sseHeaders,
123
+ getBody: () => props.sseBody,
124
+ getHistoryLimit: () => props.historyLimit,
125
+ getTools: () => props.tools,
126
+ getOnToolCall: () => props.onToolCall,
127
+ getMaxSteps: () => props.maxSteps,
128
+ getMessagesSerializer: () => props.sseMessagesSerializer,
129
+ getShowThink: () => props.showThink,
130
+ changeMessage: (data) => {
131
+ return updateMessage(data);
132
+ }
133
+ });
134
+ const {
135
+ senderExpose,
136
+ bubbleListExpose
137
+ } = useSessionExpose({
138
+ senderValue,
139
+ isResponding,
140
+ sessionInfo,
141
+ handleCancel,
142
+ handleSubmit
143
+ });
144
+ const {
145
+ codeXSlot
146
+ } = useCodeXSlot();
147
+ const assertType = (list2) => {
148
+ return list2;
149
+ };
150
+ const handleTypingFinished = (uuid) => {
151
+ var _a;
152
+ if (uuid && uuid === ((_a = typingMsgCtrl.value) == null ? void 0 : _a.uuid)) {
153
+ setTypingMsgCtrl();
154
+ }
155
+ };
156
+ onMounted(() => {
157
+ var _a;
158
+ (_a = senderExpose.value) == null ? void 0 : _a.openHeader();
159
+ loadMore().finally(historyRenderScrollShield);
160
+ });
161
+ onDeactivated(() => {
162
+ });
163
+ onBeforeUnmount(() => {
164
+ handleCancel();
165
+ });
166
+ return (_ctx, _cache) => {
167
+ return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", {
168
+ class: normalizeClass(["ai-dialogue-shim", {
169
+ [`ai-dialogue-shim_noScrollAnimation ${unref(fixBugCls)}`]: unref(noScrollAnimation)
170
+ }])
171
+ }, [createVNode(unref(BubbleList), {
172
+ ref_key: "bubbleListExpose",
173
+ ref: bubbleListExpose,
174
+ list: assertType(unref(list)),
175
+ "max-height": "100%"
176
+ }, {
177
+ content: withCtx(({
178
+ item
179
+ }) => {
180
+ var _a;
181
+ return [createVNode(AiBubbleContent, {
182
+ item,
183
+ "code-x-slot": unref(codeXSlot),
184
+ "typing-msg-uuid": (_a = unref(typingMsgCtrl)) == null ? void 0 : _a.uuid,
185
+ onTypingFinished: handleTypingFinished
186
+ }, createSlots({
187
+ _: 2
188
+ }, [_ctx.$slots.part ? {
189
+ name: "part",
190
+ fn: withCtx((scope) => [renderSlot(_ctx.$slots, "part", normalizeProps(guardReactiveProps(scope)), void 0, true)]),
191
+ key: "0"
192
+ } : void 0, _ctx.$slots.tool ? {
193
+ name: "tool",
194
+ fn: withCtx((scope) => [renderSlot(_ctx.$slots, "tool", normalizeProps(guardReactiveProps(scope)), void 0, true)]),
195
+ key: "1"
196
+ } : void 0]), 1032, ["item", "code-x-slot", "typing-msg-uuid"])];
197
+ }),
198
+ footer: withCtx(({
199
+ item
200
+ }) => [createVNode(AiBubbleFooter, {
201
+ item
202
+ }, null, 8, ["item"])]),
203
+ _: 3
204
+ }, 8, ["list"]), createVNode(unref(MentionSender), {
205
+ ref_key: "senderExpose",
206
+ ref: senderExpose,
207
+ modelValue: unref(senderValue),
208
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(senderValue) ? senderValue.value = $event : null),
209
+ class: normalizeClass(["ai-dialogue-sender", {
210
+ [`ai-dialogue-sender_newSession`]: isNewSession.value
211
+ }]),
212
+ loading: unref(isResponding),
213
+ "auto-size": unref(autoSizeOptions),
214
+ "submit-btn-disabled": unref(submitBtnDisabled),
215
+ placeholder: unref(placeholder),
216
+ variant: "updown",
217
+ onSubmit: unref(handleSubmit),
218
+ onCancel: unref(handleCancel)
219
+ }, {
220
+ header: withCtx(() => [isNewSession.value ? (openBlock(), createBlock(AiSenderHeader, {
221
+ key: 0,
222
+ ref_key: "senderHeaderRef",
223
+ ref: senderHeaderRef,
224
+ class: "ai-dialogue-sender-header",
225
+ greeting: __props.greeting,
226
+ "swift-ask": __props.swiftAsk,
227
+ "logo-url": __props.logoUrl
228
+ }, null, 8, ["greeting", "swift-ask", "logo-url"])) : createCommentVNode("", true)]),
229
+ _: 1
230
+ }, 8, ["modelValue", "class", "loading", "auto-size", "submit-btn-disabled", "placeholder", "onSubmit", "onCancel"])], 2), __props.showTitle ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(unref(ElText), {
231
+ "line-clamp": 1,
232
+ class: "ai-dialogue-title-text"
233
+ }, {
234
+ default: withCtx(() => [createTextVNode(toDisplayString(sessionInfo.value.label), 1)]),
235
+ _: 1
236
+ })])) : createCommentVNode("", true)]);
237
+ };
238
+ }
239
+ });
240
+ export {
241
+ _sfc_main as default
242
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiDialogueGroup.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiDialogueGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8dff57f8"]]);
5
+ export {
6
+ AiDialogueGroup as default
7
+ };
@@ -0,0 +1,133 @@
1
+ import { defineComponent, useModel, computed, onMounted, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, mergeProps, unref, isRef, Fragment, renderList, createBlock, createSlots, withCtx, renderSlot, mergeModels } from "vue";
2
+ import AiOperationBar from "../operation/AiOperationBar.vue.mjs";
3
+ import AiDialogue from "./AiDialogue.vue.mjs";
4
+ import { createAiDb } from "../../hooks/storage.mjs";
5
+ import { useSessionListScoped } from "../../hooks/session-list.mjs";
6
+ const _hoisted_1 = { class: "ai-dialogue-group-main" };
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ __name: "AiDialogueGroup",
9
+ props: /* @__PURE__ */ mergeModels({
10
+ operationBarProps: {},
11
+ db: {},
12
+ dbNamespace: {},
13
+ sseUrl: {},
14
+ sseConverter: {},
15
+ sseHeaders: {},
16
+ sseBody: {},
17
+ sseMessagesSerializer: {},
18
+ historyLimit: {},
19
+ tools: {},
20
+ onToolCall: {},
21
+ maxSteps: {},
22
+ userName: {},
23
+ swiftAsk: {},
24
+ greeting: {},
25
+ showTitle: { type: Boolean, default: true },
26
+ showThink: { type: Boolean, default: false },
27
+ bubbleMaxWidth: {},
28
+ showAvatar: { type: Boolean },
29
+ titleHeight: {},
30
+ logoUrl: {}
31
+ }, {
32
+ "isCollapsed": { type: Boolean, ...{
33
+ default: true
34
+ } },
35
+ "isCollapsedModifiers": {}
36
+ }),
37
+ emits: ["update:isCollapsed"],
38
+ setup(__props) {
39
+ const props = __props;
40
+ const isCollapsed = useModel(__props, "isCollapsed");
41
+ const {
42
+ activeSessionId,
43
+ sessionList,
44
+ renderSessionList,
45
+ unshiftSession,
46
+ changeSession,
47
+ loadMore,
48
+ isLoadMoreFinished,
49
+ isLoadMoreLoading
50
+ /* eslint-disable vue/no-setup-props-destructure -- 1:1 迁入源既有写法,props 仅取初值传入 composable,REQ-2 禁改响应性,见 review-notes 二 */
51
+ } = useSessionListScoped(
52
+ props.db || createAiDb(props.userName, props.dbNamespace)
53
+ );
54
+ const operationBarPropsAdjust = computed(() => {
55
+ return {
56
+ position: "right",
57
+ ...props.operationBarProps || {}
58
+ };
59
+ });
60
+ const operationBarPosition = computed(
61
+ () => operationBarPropsAdjust.value.position
62
+ );
63
+ const handleSessionListLoadMore = () => {
64
+ if (isLoadMoreFinished.value) {
65
+ return;
66
+ }
67
+ loadMore();
68
+ };
69
+ onMounted(() => {
70
+ loadMore();
71
+ });
72
+ return (_ctx, _cache) => {
73
+ return openBlock(), createElementBlock("div", {
74
+ class: normalizeClass(["ai-dialogue-group", {
75
+ [`ai-dialogue-group_side_${operationBarPosition.value}`]: true
76
+ }])
77
+ }, [
78
+ createElementVNode("div", {
79
+ class: normalizeClass(["ai-dialogue-group-operation-bar", {
80
+ [`ai-dialogue-group-operation-bar_${operationBarPosition.value}`]: true
81
+ }])
82
+ }, [
83
+ createVNode(AiOperationBar, mergeProps({
84
+ "is-collapsed": isCollapsed.value,
85
+ "onUpdate:isCollapsed": _cache[0] || (_cache[0] = ($event) => isCollapsed.value = $event),
86
+ "active-session-id": unref(activeSessionId),
87
+ "onUpdate:activeSessionId": _cache[1] || (_cache[1] = ($event) => isRef(activeSessionId) ? activeSessionId.value = $event : null),
88
+ list: unref(sessionList),
89
+ "logo-url": __props.logoUrl
90
+ }, operationBarPropsAdjust.value, {
91
+ sessionListLoadMoreLoading: unref(isLoadMoreLoading),
92
+ onSessionListLodeMore: handleSessionListLoadMore
93
+ }), null, 16, ["is-collapsed", "active-session-id", "list", "logo-url", "sessionListLoadMoreLoading"])
94
+ ], 2),
95
+ createElementVNode("div", _hoisted_1, [
96
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(renderSessionList), (sessionInfo) => {
97
+ return openBlock(), createElementBlock("div", {
98
+ key: sessionInfo.id,
99
+ class: normalizeClass(["ai-dialogue-group-main-item", {
100
+ [`ai-dialogue-group-main-item_active`]: sessionInfo.id === unref(activeSessionId)
101
+ }])
102
+ }, [
103
+ (openBlock(), createBlock(AiDialogue, mergeProps({ ref_for: true }, props, {
104
+ key: sessionInfo.id,
105
+ "session-info": sessionInfo,
106
+ "onUpdate:sessionInfo": unref(changeSession),
107
+ onSessionEnable: _cache[2] || (_cache[2] = ($event) => unref(unshiftSession)($event))
108
+ }), createSlots({ _: 2 }, [
109
+ _ctx.$slots.part ? {
110
+ name: "part",
111
+ fn: withCtx((scope) => [
112
+ renderSlot(_ctx.$slots, "part", mergeProps({ ref_for: true }, scope), void 0, true)
113
+ ]),
114
+ key: "0"
115
+ } : void 0,
116
+ _ctx.$slots.tool ? {
117
+ name: "tool",
118
+ fn: withCtx((scope) => [
119
+ renderSlot(_ctx.$slots, "tool", mergeProps({ ref_for: true }, scope), void 0, true)
120
+ ]),
121
+ key: "1"
122
+ } : void 0
123
+ ]), 1040, ["session-info", "onUpdate:sessionInfo"]))
124
+ ], 2);
125
+ }), 128))
126
+ ])
127
+ ], 2);
128
+ };
129
+ }
130
+ });
131
+ export {
132
+ _sfc_main as default
133
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiDialogueWrap.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiDialogueWrap = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-30b981e0"]]);
5
+ export {
6
+ AiDialogueWrap as default
7
+ };
@@ -0,0 +1,73 @@
1
+ import { defineComponent, useModel, ref, toRef, computed, openBlock, createBlock, Teleport, createElementVNode, normalizeStyle, renderSlot, createVNode, unref, withCtx, mergeModels } from "vue";
2
+ import { ElIcon } from "element-plus";
3
+ import { ArrowRight, ArrowLeft } from "@element-plus/icons-vue";
4
+ import { useAiExposeInject } from "../../hooks/expose.mjs";
5
+ import { useAgentUiDensity } from "../../hooks/use-density.mjs";
6
+ import { useKeyboardInset } from "../../hooks/use-keyboard-inset.mjs";
7
+ const _hoisted_1 = { class: "ai-dialogue-panel" };
8
+ const _hoisted_2 = ["aria-label", "title"];
9
+ const _sfc_main = /* @__PURE__ */ defineComponent({
10
+ __name: "AiDialogueWrap",
11
+ props: /* @__PURE__ */ mergeModels({
12
+ density: { default: "auto" }
13
+ }, {
14
+ "show": { type: Boolean },
15
+ "showModifiers": {}
16
+ }),
17
+ emits: ["update:show"],
18
+ setup(__props) {
19
+ const props = __props;
20
+ const isShow = useModel(__props, "show");
21
+ const wrapRef = ref(null);
22
+ const densityMode = toRef(props, "density");
23
+ useAgentUiDensity(wrapRef, { mode: densityMode });
24
+ useKeyboardInset(wrapRef, { mode: densityMode });
25
+ const { aiExpose } = useAiExposeInject();
26
+ const toggleLabel = computed(
27
+ () => isShow.value ? "收起AI面板" : "打开AI面板"
28
+ );
29
+ const style = computed(() => {
30
+ return {
31
+ transform: `translateX(${isShow.value ? "0" : "100%"})`
32
+ };
33
+ });
34
+ const handleToggle = (nextStatus) => {
35
+ var _a, _b;
36
+ isShow.value = nextStatus;
37
+ if (nextStatus) {
38
+ (_b = (_a = aiExpose == null ? void 0 : aiExpose.value) == null ? void 0 : _a.sender) == null ? void 0 : _b.focus();
39
+ }
40
+ };
41
+ return (_ctx, _cache) => {
42
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
43
+ createElementVNode("div", {
44
+ ref_key: "wrapRef",
45
+ ref: wrapRef,
46
+ class: "ai-dialogue-wrap",
47
+ style: normalizeStyle(style.value)
48
+ }, [
49
+ createElementVNode("div", _hoisted_1, [
50
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
51
+ ]),
52
+ createElementVNode("button", {
53
+ class: "ai-dialogue-toggle",
54
+ type: "button",
55
+ "aria-label": toggleLabel.value,
56
+ title: toggleLabel.value,
57
+ onClick: _cache[0] || (_cache[0] = ($event) => handleToggle(!isShow.value))
58
+ }, [
59
+ createVNode(unref(ElIcon), { size: 18 }, {
60
+ default: withCtx(() => [
61
+ isShow.value ? (openBlock(), createBlock(unref(ArrowRight), { key: 0 })) : (openBlock(), createBlock(unref(ArrowLeft), { key: 1 }))
62
+ ]),
63
+ _: 1
64
+ })
65
+ ], 8, _hoisted_2)
66
+ ], 4)
67
+ ]);
68
+ };
69
+ }
70
+ });
71
+ export {
72
+ _sfc_main as default
73
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiMessageList.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiMessageList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b534d381"]]);
5
+ export {
6
+ AiMessageList as default
7
+ };
@@ -0,0 +1,111 @@
1
+ import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createElementBlock, Fragment, renderList, renderSlot, createVNode } from "vue";
2
+ import { BubbleList } from "vue-element-plus-x";
3
+ import { normalizeParts, aiIsDataPart, AiChatRoleEnum } from "../../types/index.mjs";
4
+ import { useCodeXSlot } from "../../hooks/CodeXSlot.mjs";
5
+ import AiBubbleContent from "../bubble/AiBubbleContent.vue.mjs";
6
+ import AiPartRenderer from "../bubble/AiPartRenderer.vue.mjs";
7
+ const _hoisted_1 = {
8
+ key: 1,
9
+ class: "ai-message-list-empty"
10
+ };
11
+ const _sfc_main = /* @__PURE__ */ defineComponent({
12
+ __name: "AiMessageList",
13
+ props: {
14
+ messages: {},
15
+ allowHtml: { type: Boolean, default: true },
16
+ bubbleMaxWidth: { default: "100%" }
17
+ },
18
+ setup(__props) {
19
+ const props = __props;
20
+ const { codeXSlot } = useCodeXSlot();
21
+ const msgItem = (item) => item;
22
+ const roleToEnum = (role) => role === "assistant" ? AiChatRoleEnum.AI : AiChatRoleEnum.USER;
23
+ const toBubbleItem = (message) => {
24
+ const role = roleToEnum(message.role);
25
+ return {
26
+ // —— BubbleProps(vue-element-plus-x) ——
27
+ placement: message.role === "assistant" ? "start" : "end",
28
+ typing: false,
29
+ content: "",
30
+ maxWidth: props.bubbleMaxWidth,
31
+ // —— XBubbleListItemProps 扩展必填字段(稳定默认) ——
32
+ uuid: message.id,
33
+ sessionId: "",
34
+ role,
35
+ createdAt: 0,
36
+ updatedAt: 0,
37
+ errorMsg: "",
38
+ isAborted: false,
39
+ isFinished: true,
40
+ thinkTime: 0,
41
+ talkGoalLabel: "",
42
+ talkGoalValue: "",
43
+ showThink: false,
44
+ // —— 内部携带 ——
45
+ __message: message
46
+ };
47
+ };
48
+ const bubbleList = computed(
49
+ () => props.messages.map(toBubbleItem)
50
+ );
51
+ const textItemFor = (item, part, index) => {
52
+ return {
53
+ ...item,
54
+ uuid: `${item.uuid}-${index}`,
55
+ content: part.text
56
+ };
57
+ };
58
+ const isDataPart = aiIsDataPart;
59
+ return (_ctx, _cache) => {
60
+ return bubbleList.value.length ? (openBlock(), createBlock(unref(BubbleList), {
61
+ key: 0,
62
+ list: bubbleList.value,
63
+ "max-height": "100%",
64
+ class: "ai-message-list"
65
+ }, {
66
+ content: withCtx(({ item }) => [
67
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(normalizeParts)(msgItem(item).__message), (part, index) => {
68
+ return openBlock(), createElementBlock(Fragment, {
69
+ key: `${msgItem(item).uuid}-${index}`
70
+ }, [
71
+ part.type === "text" ? (openBlock(), createBlock(AiBubbleContent, {
72
+ key: 0,
73
+ item: textItemFor(msgItem(item), part, index),
74
+ "code-x-slot": unref(codeXSlot),
75
+ "allow-html": __props.allowHtml
76
+ }, null, 8, ["item", "code-x-slot", "allow-html"])) : unref(isDataPart)(part) ? renderSlot(_ctx.$slots, "part", {
77
+ key: 1,
78
+ part,
79
+ message: msgItem(item).__message
80
+ }, () => [
81
+ createVNode(AiPartRenderer, {
82
+ part,
83
+ item: msgItem(item)
84
+ }, null, 8, ["part", "item"])
85
+ ], true) : part.type === "tool-call" ? renderSlot(_ctx.$slots, "tool", {
86
+ key: 2,
87
+ part,
88
+ message: msgItem(item).__message
89
+ }, () => [
90
+ createVNode(AiPartRenderer, {
91
+ part,
92
+ item: msgItem(item)
93
+ }, null, 8, ["part", "item"])
94
+ ], true) : (openBlock(), createBlock(AiPartRenderer, {
95
+ key: 3,
96
+ part,
97
+ item: msgItem(item)
98
+ }, null, 8, ["part", "item"]))
99
+ ], 64);
100
+ }), 128))
101
+ ]),
102
+ _: 3
103
+ }, 8, ["list"])) : (openBlock(), createElementBlock("div", _hoisted_1, [
104
+ renderSlot(_ctx.$slots, "empty", {}, void 0, true)
105
+ ]));
106
+ };
107
+ }
108
+ });
109
+ export {
110
+ _sfc_main as default
111
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./LlmJsonTrigger.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const LlmJsonTrigger = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8ecdbef5"]]);
5
+ export {
6
+ LlmJsonTrigger as default
7
+ };