@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) JustSoSu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @done-coding/forge-kit-agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 3 AI 对话与智能体 UI 组件库。
4
+
5
+ 文档:https://done-coding.github.io/done-coding-showcase/docs/
6
+
7
+ 本包目录与安装身份已统一为 `forge-kit-agent`;当前manifest已同版0.100.0-dev.1,组件API保持,改名拟随统一 `0.100.0-alpha.0` 发行。kits/plugins 独立消费,不进入 forge 聚合。
8
+
9
+ 注入键保持历史 namespace,包名改动不改变既有 bridge 配对。
10
+
11
+ ## 本机同版候选(id5nov)
12
+
13
+ 12公开包现已统一为 `0.100.0-dev.1`,内部依赖保持 `workspace:*` 并在真实pack中转换为精确同版。候选仅用于/tmp可丢弃宿主;没有发布到registry,正式消费项目不写dev字面版本。组件API不因起版改变,迁移见 [发布前身份调整](migrations/v0.100.0-dev.1.md)。第一方许可为 MIT,署名 `Copyright (c) JustSoSu`,完整正文见本包 LICENSE。
14
+
15
+ <!-- repo-map:start -->
16
+
17
+ ## 目录导航(自动维护,勿手改段内 — 由项目初始化脚本重跑刷新)
18
+
19
+ - `demo-src/` — 本地调试宿主(不入发布物)
20
+ - `__tests__/` — 单元测试
21
+ - `demos/` — 按目录名分组的源码或资源
22
+ - `host/` — 按目录名分组的源码或资源
23
+ - `mock/` — 按目录名分组的源码或资源
24
+ - `type-tests/` — 按目录名分组的源码或资源
25
+ - `docs/` — 文档
26
+ - `e2e/` — 浏览器测试
27
+ - `migrations/` — 版本迁移说明
28
+ - `recording/` — 录制脚本
29
+ - `src/` — 源码
30
+ - `bridge/` — 跨包桥接(provide/inject 通道)
31
+ - `components/` — 组件
32
+ - `bubble/` — 消息气泡
33
+ - `docs/` — 文档
34
+ - `config/` — 配置
35
+ - `dialogue/` — 对话
36
+ - `json-trigger/` — 结构化输出触发器
37
+ - `operation/` — 操作组件
38
+ - `sender/` — 输入器
39
+ - `hooks/` — 组合式函数
40
+ - `docs/` — 文档
41
+ - `inject/` — 注入键定义
42
+ - `types/` — 类型定义
43
+ - `utils/` — 工具函数
44
+
45
+ > 用途:供协作者/AI 按图定位,免遍历目录树。结构变更后重跑初始化刷新。
46
+ > (模块根的本段展开该模块**内部**结构;深层大目录 ≥8 项或继续分叉则嵌套列出,叶子小目录不展。)
47
+
48
+ <!-- repo-map:end -->
49
+
50
+ ## 自动验证与消费边界(tc7f1a)
51
+
52
+ 声明构建保留 `vue-element-plus-x` 的公开模块引用,避免将其改写为包内 `node_modules` 相对路径;Vue 推导的 MentionSender 类型使用上游公开 `types/MentionSender` 子路径。代码块 hook 的返回类型从上游公开 `XMarkdown` props 提取,不要求消费者解析上游未导出的内部路径。运行行为不变,bundler 类型检查由真实 tgz ATTW 闸门验证。
53
+
54
+ 仓根 `pnpm verify` 检查受影响包,`pnpm verify --all` 检查全量;`pnpm test:consumer` 用十二个真实 tgz 建仓外宿主;`pnpm verify:release` 绑定当前 HEAD 与工作树生成发行戳。任何失败均非零退出,未通过不得发布。本包 prepublishOnly 校验发行戳,不执行发布。exports 的 types 条件优先于运行时条件。ESM 产物的 lodash 子路径使用 `.js` 扩展名;不改变组件 API。消费配置和已知失败见 `scripts/forge-testing.md`,既有工程验证说明保留于 `migrations/v1.0.0-dev.2.md`(历史文件);当前候选为 `0.100.0-dev.1`,不发行。
@@ -0,0 +1,10 @@
1
+ const _export_sfc = (sfc, props) => {
2
+ const target = sfc.__vccOpts || sfc;
3
+ for (const [key, val] of props) {
4
+ target[key] = val;
5
+ }
6
+ return target;
7
+ };
8
+ export {
9
+ _export_sfc as default
10
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiBubbleContent.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiBubbleContent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1773fd29"]]);
5
+ export {
6
+ AiBubbleContent as default
7
+ };
@@ -0,0 +1,209 @@
1
+ import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, normalizeClass, createBlock, mergeProps, withCtx, Fragment, renderList, unref, renderSlot, createVNode, createCommentVNode, toDisplayString, createTextVNode } from "vue";
2
+ import { ElText } from "element-plus";
3
+ import { AiChatRoleEnum, aiIsDataPart } from "../../types/index.mjs";
4
+ import _sfc_main$2 from "./AiContentSplit.vue.mjs";
5
+ import AiPartRenderer from "./AiPartRenderer.vue.mjs";
6
+ import { XMarkdown } from "vue-element-plus-x";
7
+ import _sfc_main$1 from "./AiTypewriter.vue.mjs";
8
+ const _hoisted_1 = { class: "ai-bubble-content" };
9
+ const _hoisted_2 = {
10
+ key: 1,
11
+ class: "ai-bubble-user-text"
12
+ };
13
+ const _sfc_main = /* @__PURE__ */ defineComponent({
14
+ __name: "AiBubbleContent",
15
+ props: {
16
+ item: {},
17
+ codeXSlot: {},
18
+ typingMsgUuid: {},
19
+ allowHtml: { type: Boolean, default: true }
20
+ },
21
+ emits: ["typingFinished"],
22
+ setup(__props, { emit: __emit }) {
23
+ const props = __props;
24
+ const emits = __emit;
25
+ const isAi = computed(() => props.item.role === AiChatRoleEnum.AI);
26
+ const timeline = computed(() => {
27
+ const { parts, partOffsets, showThink, content = "" } = props.item;
28
+ if (!(parts == null ? void 0 : parts.length) || showThink) {
29
+ return null;
30
+ }
31
+ if (!partOffsets || partOffsets.length !== parts.length) {
32
+ return null;
33
+ }
34
+ const entries = [];
35
+ let cursor = 0;
36
+ parts.forEach((part, index) => {
37
+ const offset = Math.min(
38
+ Math.max(partOffsets[index] ?? 0, cursor),
39
+ content.length
40
+ );
41
+ if (offset > cursor) {
42
+ entries.push({ kind: "text", start: cursor, end: offset });
43
+ cursor = offset;
44
+ }
45
+ entries.push({ kind: "part", part, index, offset });
46
+ });
47
+ if (cursor < content.length) {
48
+ entries.push({ kind: "text", start: cursor, end: content.length });
49
+ }
50
+ return entries;
51
+ });
52
+ const typingConfig = computed(() => {
53
+ const { item } = props;
54
+ const { typing = true } = item;
55
+ const { disabled, step, interval, suffix } = typing ? {
56
+ disabled: props.item.uuid !== props.typingMsgUuid
57
+ } : {
58
+ disabled: true
59
+ };
60
+ return {
61
+ disabled,
62
+ step,
63
+ interval,
64
+ suffix
65
+ };
66
+ });
67
+ const customAttrs = {
68
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- 1:1 迁入源既有 dead 参数,REQ-2 禁删,见 review-notes 二
69
+ think: (...args) => {
70
+ const style = {
71
+ wordBreak: "break-all"
72
+ };
73
+ return {
74
+ node: "div",
75
+ style
76
+ };
77
+ }
78
+ };
79
+ const markdownPublicProps = computed(() => {
80
+ return {
81
+ allowHtml: props.allowHtml,
82
+ codeXSlot: props.codeXSlot,
83
+ customAttrs
84
+ };
85
+ });
86
+ const handlerTypeFinished = (uuid) => {
87
+ emits("typingFinished", uuid);
88
+ };
89
+ return (_ctx, _cache) => {
90
+ return openBlock(), createElementBlock("div", _hoisted_1, [
91
+ createElementVNode("div", {
92
+ class: normalizeClass([
93
+ isAi.value ? "ai-rail" : "ai-bubble-user",
94
+ { "ai-rail_streaming": isAi.value && !__props.item.isFinished }
95
+ ])
96
+ }, [
97
+ isAi.value && timeline.value ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
98
+ key: 0,
99
+ item: __props.item
100
+ }, typingConfig.value, {
101
+ onFinished: _cache[0] || (_cache[0] = ($event) => handlerTypeFinished(__props.item.uuid))
102
+ }), {
103
+ default: withCtx(({ textShow }) => [
104
+ (openBlock(true), createElementBlock(Fragment, null, renderList(timeline.value, (entry) => {
105
+ return openBlock(), createElementBlock(Fragment, {
106
+ key: entry.kind === "text" ? `t-${entry.start}` : `p-${entry.index}`
107
+ }, [
108
+ entry.kind === "text" && entry.start < textShow.length ? (openBlock(), createBlock(unref(XMarkdown), mergeProps({
109
+ key: 0,
110
+ markdown: textShow.slice(entry.start, entry.end)
111
+ }, { ref_for: true }, markdownPublicProps.value), null, 16, ["markdown"])) : entry.kind === "part" && textShow.length >= entry.offset ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
112
+ unref(aiIsDataPart)(entry.part) ? renderSlot(_ctx.$slots, "part", {
113
+ key: 0,
114
+ part: entry.part,
115
+ item: __props.item
116
+ }, () => [
117
+ createVNode(AiPartRenderer, {
118
+ part: entry.part,
119
+ item: __props.item
120
+ }, null, 8, ["part", "item"])
121
+ ], true) : entry.part.type === "tool-call" ? renderSlot(_ctx.$slots, "tool", {
122
+ key: 1,
123
+ part: entry.part,
124
+ item: __props.item
125
+ }, () => [
126
+ createVNode(AiPartRenderer, {
127
+ part: entry.part,
128
+ item: __props.item
129
+ }, null, 8, ["part", "item"])
130
+ ], true) : (openBlock(), createBlock(AiPartRenderer, {
131
+ key: 2,
132
+ part: entry.part,
133
+ item: __props.item
134
+ }, null, 8, ["part", "item"]))
135
+ ], 64)) : createCommentVNode("", true)
136
+ ], 64);
137
+ }), 128))
138
+ ]),
139
+ _: 3
140
+ }, 16, ["item"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
141
+ isAi.value && __props.item.content ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
142
+ key: 0,
143
+ item: __props.item
144
+ }, typingConfig.value, {
145
+ onFinished: _cache[1] || (_cache[1] = ($event) => handlerTypeFinished(__props.item.uuid))
146
+ }), {
147
+ default: withCtx(({ textShow }) => [
148
+ __props.item.showThink ? (openBlock(), createBlock(_sfc_main$2, {
149
+ key: 0,
150
+ item: __props.item,
151
+ textShow
152
+ }, {
153
+ default: withCtx(({ text }) => [
154
+ createVNode(unref(XMarkdown), mergeProps({ markdown: text }, markdownPublicProps.value), null, 16, ["markdown"])
155
+ ]),
156
+ _: 1
157
+ }, 8, ["item", "textShow"])) : (openBlock(), createBlock(unref(XMarkdown), mergeProps({
158
+ key: 1,
159
+ markdown: textShow
160
+ }, markdownPublicProps.value), null, 16, ["markdown"]))
161
+ ]),
162
+ _: 1
163
+ }, 16, ["item"])) : !isAi.value && __props.item.content ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.item.content), 1)) : createCommentVNode("", true),
164
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.item.parts ?? [], (part, index) => {
165
+ return openBlock(), createElementBlock(Fragment, { key: index }, [
166
+ unref(aiIsDataPart)(part) ? renderSlot(_ctx.$slots, "part", {
167
+ key: 0,
168
+ part,
169
+ item: __props.item
170
+ }, () => [
171
+ createVNode(AiPartRenderer, {
172
+ part,
173
+ item: __props.item
174
+ }, null, 8, ["part", "item"])
175
+ ], true) : part.type === "tool-call" ? renderSlot(_ctx.$slots, "tool", {
176
+ key: 1,
177
+ part,
178
+ item: __props.item
179
+ }, () => [
180
+ createVNode(AiPartRenderer, {
181
+ part,
182
+ item: __props.item
183
+ }, null, 8, ["part", "item"])
184
+ ], true) : (openBlock(), createBlock(AiPartRenderer, {
185
+ key: 2,
186
+ part,
187
+ item: __props.item
188
+ }, null, 8, ["part", "item"]))
189
+ ], 64);
190
+ }), 128))
191
+ ], 64))
192
+ ], 2),
193
+ __props.item.errorMsg ? (openBlock(), createBlock(unref(ElText), {
194
+ key: 0,
195
+ type: "danger",
196
+ class: "ai-gradient-error"
197
+ }, {
198
+ default: withCtx(() => [
199
+ createTextVNode(toDisplayString(__props.item.errorMsg), 1)
200
+ ]),
201
+ _: 1
202
+ })) : createCommentVNode("", true)
203
+ ]);
204
+ };
205
+ }
206
+ });
207
+ export {
208
+ _sfc_main as default
209
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiBubbleFooter.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiBubbleFooter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5d96910f"]]);
5
+ export {
6
+ AiBubbleFooter as default
7
+ };
@@ -0,0 +1,91 @@
1
+ import { defineComponent, computed, ref, onBeforeUnmount, openBlock, createElementBlock, createBlock, unref, withCtx, createTextVNode, createCommentVNode, normalizeClass, createVNode, createElementVNode } from "vue";
2
+ import { ElText, ElTooltip, ElIcon } from "element-plus";
3
+ import { Check, CopyDocument } from "@element-plus/icons-vue";
4
+ import { AiChatRoleEnum } from "../../types/index.mjs";
5
+ const _hoisted_1 = { class: "ai-bubble-footer" };
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ __name: "AiBubbleFooter",
8
+ props: {
9
+ item: {}
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ const isAi = computed(() => props.item.role === AiChatRoleEnum.AI);
14
+ const copied = ref(false);
15
+ const timer = ref();
16
+ const clearTimer = () => {
17
+ if (timer.value) {
18
+ clearTimeout(timer.value);
19
+ timer.value = void 0;
20
+ }
21
+ };
22
+ const copy = async () => {
23
+ if (copied.value) {
24
+ return;
25
+ }
26
+ try {
27
+ await navigator.clipboard.writeText(props.item.content || "");
28
+ } catch {
29
+ return;
30
+ }
31
+ copied.value = true;
32
+ clearTimer();
33
+ timer.value = setTimeout(() => {
34
+ copied.value = false;
35
+ }, 2e3);
36
+ };
37
+ onBeforeUnmount(clearTimer);
38
+ return (_ctx, _cache) => {
39
+ return openBlock(), createElementBlock("div", _hoisted_1, [
40
+ __props.item.isAborted ? (openBlock(), createBlock(unref(ElText), {
41
+ key: 0,
42
+ type: "danger",
43
+ class: "ai-gradient-error"
44
+ }, {
45
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
46
+ createTextVNode("被中止", -1)
47
+ ])]),
48
+ _: 1
49
+ })) : __props.item.errorMsg ? (openBlock(), createBlock(unref(ElText), {
50
+ key: 1,
51
+ type: "danger",
52
+ class: "ai-gradient-error"
53
+ }, {
54
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
55
+ createTextVNode("出错了", -1)
56
+ ])]),
57
+ _: 1
58
+ })) : createCommentVNode("", true),
59
+ __props.item.content ? (openBlock(), createElementBlock("div", {
60
+ key: 2,
61
+ class: normalizeClass(["ai-bubble-actions", { "ai-bubble-actions_divided": isAi.value }])
62
+ }, [
63
+ createVNode(unref(ElTooltip), {
64
+ content: copied.value ? "已复制" : "复制",
65
+ placement: "top"
66
+ }, {
67
+ default: withCtx(() => [
68
+ createElementVNode("button", {
69
+ class: "ai-bubble-action-btn",
70
+ type: "button",
71
+ "aria-label": "复制消息",
72
+ onClick: copy
73
+ }, [
74
+ createVNode(unref(ElIcon), null, {
75
+ default: withCtx(() => [
76
+ copied.value ? (openBlock(), createBlock(unref(Check), { key: 0 })) : (openBlock(), createBlock(unref(CopyDocument), { key: 1 }))
77
+ ]),
78
+ _: 1
79
+ })
80
+ ])
81
+ ]),
82
+ _: 1
83
+ }, 8, ["content"])
84
+ ], 2)) : createCommentVNode("", true)
85
+ ]);
86
+ };
87
+ }
88
+ });
89
+ export {
90
+ _sfc_main as default
91
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiCodeHeaderControl.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiCodeHeaderControl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-71c8d3b2"]]);
5
+ export {
6
+ AiCodeHeaderControl as default
7
+ };
@@ -0,0 +1,97 @@
1
+ import { defineComponent, ref, onBeforeUnmount, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, createBlock, normalizeClass } from "vue";
2
+ import { ElTooltip, ElIcon } from "element-plus";
3
+ import { Check, CopyDocument, ArrowDown } from "@element-plus/icons-vue";
4
+ const _hoisted_1 = { class: "ai-code-control" };
5
+ const _hoisted_2 = ["aria-label"];
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ __name: "AiCodeHeaderControl",
8
+ props: {
9
+ codeBlock: {}
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ const readLibExpand = () => {
14
+ const ie = props.codeBlock.isExpand;
15
+ if (ie && typeof ie === "object" && "value" in ie) {
16
+ return !!ie.value;
17
+ }
18
+ return ie === void 0 ? true : !!ie;
19
+ };
20
+ const expanded = ref(readLibExpand());
21
+ const copied = ref(false);
22
+ const timer = ref();
23
+ const clearTimer = () => {
24
+ if (timer.value) {
25
+ clearTimeout(timer.value);
26
+ timer.value = void 0;
27
+ }
28
+ };
29
+ const copy = () => {
30
+ if (copied.value) {
31
+ return;
32
+ }
33
+ props.codeBlock.copyCode(props.codeBlock.raw.content || "");
34
+ copied.value = true;
35
+ clearTimer();
36
+ timer.value = setTimeout(() => {
37
+ copied.value = false;
38
+ }, 2e3);
39
+ };
40
+ const toggle = (e) => {
41
+ const ret = props.codeBlock.toggleExpand(e);
42
+ expanded.value = typeof (ret == null ? void 0 : ret.isExpand) === "boolean" ? ret.isExpand : !expanded.value;
43
+ };
44
+ onBeforeUnmount(clearTimer);
45
+ return (_ctx, _cache) => {
46
+ return openBlock(), createElementBlock("div", _hoisted_1, [
47
+ createVNode(unref(ElTooltip), {
48
+ content: copied.value ? "已复制" : "复制代码",
49
+ placement: "top"
50
+ }, {
51
+ default: withCtx(() => [
52
+ createElementVNode("button", {
53
+ class: "ai-code-control-btn",
54
+ type: "button",
55
+ "aria-label": "复制代码",
56
+ onClick: copy
57
+ }, [
58
+ createVNode(unref(ElIcon), null, {
59
+ default: withCtx(() => [
60
+ copied.value ? (openBlock(), createBlock(unref(Check), { key: 0 })) : (openBlock(), createBlock(unref(CopyDocument), { key: 1 }))
61
+ ]),
62
+ _: 1
63
+ })
64
+ ])
65
+ ]),
66
+ _: 1
67
+ }, 8, ["content"]),
68
+ createVNode(unref(ElTooltip), {
69
+ content: expanded.value ? "折叠" : "展开",
70
+ placement: "top"
71
+ }, {
72
+ default: withCtx(() => [
73
+ createElementVNode("button", {
74
+ class: "ai-code-control-btn",
75
+ type: "button",
76
+ "aria-label": expanded.value ? "折叠代码" : "展开代码",
77
+ onClick: toggle
78
+ }, [
79
+ createVNode(unref(ElIcon), {
80
+ class: normalizeClass(["ai-code-control-arrow", { "ai-code-control-arrow_collapsed": !expanded.value }])
81
+ }, {
82
+ default: withCtx(() => [
83
+ createVNode(unref(ArrowDown))
84
+ ]),
85
+ _: 1
86
+ }, 8, ["class"])
87
+ ], 8, _hoisted_2)
88
+ ]),
89
+ _: 1
90
+ }, 8, ["content"])
91
+ ]);
92
+ };
93
+ }
94
+ });
95
+ export {
96
+ _sfc_main as default
97
+ };
@@ -0,0 +1,70 @@
1
+ import { defineComponent, computed, openBlock, createElementBlock, Fragment, renderList, createBlock, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
2
+ import AiThinkBox from "./AiThinkBox.vue.mjs";
3
+ const _hoisted_1 = { class: "ai-content-split" };
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "AiContentSplit",
6
+ props: {
7
+ textShow: {},
8
+ splitMark: { default: "</think>" },
9
+ item: {}
10
+ },
11
+ setup(__props) {
12
+ const props = __props;
13
+ const content = computed(() => props.textShow);
14
+ const splitContent = (content2, splitMark) => {
15
+ const openMark = splitMark.replace("</", "<");
16
+ if (!content2.includes(openMark)) {
17
+ return [{ text: content2, thinkProcess: false }];
18
+ }
19
+ const list = content2.split(splitMark).map((item) => item);
20
+ const maxIndex = list.length - 1;
21
+ return list.map((item, index) => {
22
+ if (index >= 1 && maxIndex === index) {
23
+ return {
24
+ text: item,
25
+ thinkProcess: false
26
+ };
27
+ } else {
28
+ return {
29
+ text: `${item}${splitMark}`,
30
+ thinkProcess: true
31
+ };
32
+ }
33
+ });
34
+ };
35
+ const contentList = computed(
36
+ () => splitContent(content.value, props.splitMark)
37
+ );
38
+ const isThinking = computed(() => {
39
+ return props.item.isFinished ? false : contentList.value.length < 2;
40
+ });
41
+ return (_ctx, _cache) => {
42
+ return openBlock(), createElementBlock("div", _hoisted_1, [
43
+ (openBlock(true), createElementBlock(Fragment, null, renderList(contentList.value, ({ text, thinkProcess }, index) => {
44
+ return openBlock(), createElementBlock(Fragment, { key: index }, [
45
+ thinkProcess ? (openBlock(), createBlock(AiThinkBox, {
46
+ key: 0,
47
+ isThinking: isThinking.value,
48
+ item: __props.item
49
+ }, {
50
+ default: withCtx(() => [
51
+ renderSlot(_ctx.$slots, "default", { text }, () => [
52
+ createTextVNode(toDisplayString(text), 1)
53
+ ])
54
+ ]),
55
+ _: 2
56
+ }, 1032, ["isThinking", "item"])) : renderSlot(_ctx.$slots, "default", {
57
+ key: 1,
58
+ text
59
+ }, () => [
60
+ createTextVNode(toDisplayString(text), 1)
61
+ ])
62
+ ], 64);
63
+ }), 128))
64
+ ]);
65
+ };
66
+ }
67
+ });
68
+ export {
69
+ _sfc_main as default
70
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./AiContentSplit.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./AiPartRenderer.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const AiPartRenderer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ab33ef47"]]);
5
+ export {
6
+ AiPartRenderer as default
7
+ };