@aheart-ui/ai 0.0.0-stage → 1.1.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 (205) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/es/actions/index.d.ts +2 -0
  4. package/es/actions/index.js +5 -0
  5. package/es/actions/style.css +36 -0
  6. package/es/actions.vue.d.ts +34 -0
  7. package/es/actions.vue.js +27 -0
  8. package/es/actions.vue2.js +4 -0
  9. package/es/agent/index.d.ts +5 -0
  10. package/es/agent/index.js +12 -0
  11. package/es/agent/style.css +308 -0
  12. package/es/agent-execution.vue.d.ts +106 -0
  13. package/es/agent-execution.vue.js +441 -0
  14. package/es/agent-execution.vue2.js +4 -0
  15. package/es/agent-workbench/index.d.ts +2 -0
  16. package/es/agent-workbench/index.js +5 -0
  17. package/es/agent-workbench/style.css +1332 -0
  18. package/es/agent-workbench.vue.d.ts +186 -0
  19. package/es/agent-workbench.vue.js +537 -0
  20. package/es/agent-workbench.vue2.js +4 -0
  21. package/es/attachments/index.d.ts +2 -0
  22. package/es/attachments/index.js +5 -0
  23. package/es/attachments/style.css +62 -0
  24. package/es/attachments.vue.d.ts +39 -0
  25. package/es/attachments.vue.js +39 -0
  26. package/es/attachments.vue2.js +4 -0
  27. package/es/bubble/index.d.ts +2 -0
  28. package/es/bubble/index.js +5 -0
  29. package/es/bubble/style.css +241 -0
  30. package/es/bubble.vue.d.ts +27 -0
  31. package/es/bubble.vue.js +82 -0
  32. package/es/bubble.vue2.js +4 -0
  33. package/es/chat/index.d.ts +11 -0
  34. package/es/chat/index.js +23 -0
  35. package/es/chat/style.css +595 -0
  36. package/es/chat-panel/index.d.ts +3 -0
  37. package/es/chat-panel/index.js +8 -0
  38. package/es/chat-panel/style.css +595 -0
  39. package/es/chat-panel.vue.d.ts +108 -0
  40. package/es/chat-panel.vue.js +330 -0
  41. package/es/chat-panel.vue2.js +4 -0
  42. package/es/conversations/index.d.ts +2 -0
  43. package/es/conversations/index.js +5 -0
  44. package/es/conversations/style.css +48 -0
  45. package/es/conversations.vue.d.ts +39 -0
  46. package/es/conversations.vue.js +29 -0
  47. package/es/conversations.vue2.js +4 -0
  48. package/es/form/index.d.ts +3 -0
  49. package/es/form/index.js +9 -0
  50. package/es/form/style.css +242 -0
  51. package/es/form-field.vue.d.ts +28 -0
  52. package/es/form-field.vue.js +176 -0
  53. package/es/form-field.vue2.js +4 -0
  54. package/es/form-schema.d.ts +73 -0
  55. package/es/form-schema.js +105 -0
  56. package/es/form.vue.d.ts +81 -0
  57. package/es/form.vue.js +376 -0
  58. package/es/form.vue2.js +4 -0
  59. package/es/index.d.ts +20 -0
  60. package/es/index.js +42 -0
  61. package/es/package.json +3 -0
  62. package/es/process/index.d.ts +2 -0
  63. package/es/process/index.js +5 -0
  64. package/es/process/style.css +77 -0
  65. package/es/process.vue.d.ts +30 -0
  66. package/es/process.vue.js +29 -0
  67. package/es/process.vue2.js +4 -0
  68. package/es/prompts/index.d.ts +2 -0
  69. package/es/prompts/index.js +5 -0
  70. package/es/prompts/style.css +76 -0
  71. package/es/prompts.vue.d.ts +39 -0
  72. package/es/prompts.vue.js +33 -0
  73. package/es/prompts.vue2.js +4 -0
  74. package/es/safe-markdown.d.ts +3 -0
  75. package/es/safe-markdown.js +23 -0
  76. package/es/sender/index.d.ts +2 -0
  77. package/es/sender/index.js +5 -0
  78. package/es/sender/style.css +88 -0
  79. package/es/sender.vue.d.ts +52 -0
  80. package/es/sender.vue.js +46 -0
  81. package/es/sender.vue2.js +4 -0
  82. package/es/sources/index.d.ts +2 -0
  83. package/es/sources/index.js +5 -0
  84. package/es/sources/style.css +54 -0
  85. package/es/sources.vue.d.ts +30 -0
  86. package/es/sources.vue.js +34 -0
  87. package/es/sources.vue2.js +4 -0
  88. package/es/stream-reducer.d.ts +35 -0
  89. package/es/stream-reducer.js +85 -0
  90. package/es/style.css +1586 -0
  91. package/es/thought-chain/index.d.ts +2 -0
  92. package/es/thought-chain/index.js +5 -0
  93. package/es/thought-chain/style.css +77 -0
  94. package/es/thought-chain.vue.d.ts +30 -0
  95. package/es/thought-chain.vue.js +15 -0
  96. package/es/thought-chain.vue2.js +4 -0
  97. package/es/types.d.ts +203 -0
  98. package/es/welcome/index.d.ts +2 -0
  99. package/es/welcome/index.js +5 -0
  100. package/es/welcome/style.css +33 -0
  101. package/es/welcome.vue.d.ts +41 -0
  102. package/es/welcome.vue.js +27 -0
  103. package/es/welcome.vue2.js +4 -0
  104. package/lib/actions/index.d.ts +2 -0
  105. package/lib/actions/index.js +1 -0
  106. package/lib/actions/style.css +36 -0
  107. package/lib/actions.vue.d.ts +34 -0
  108. package/lib/actions.vue.js +1 -0
  109. package/lib/actions.vue2.js +1 -0
  110. package/lib/agent/index.d.ts +5 -0
  111. package/lib/agent/index.js +1 -0
  112. package/lib/agent/style.css +308 -0
  113. package/lib/agent-execution.vue.d.ts +106 -0
  114. package/lib/agent-execution.vue.js +1 -0
  115. package/lib/agent-execution.vue2.js +1 -0
  116. package/lib/agent-workbench/index.d.ts +2 -0
  117. package/lib/agent-workbench/index.js +1 -0
  118. package/lib/agent-workbench/style.css +1332 -0
  119. package/lib/agent-workbench.vue.d.ts +186 -0
  120. package/lib/agent-workbench.vue.js +1 -0
  121. package/lib/agent-workbench.vue2.js +1 -0
  122. package/lib/attachments/index.d.ts +2 -0
  123. package/lib/attachments/index.js +1 -0
  124. package/lib/attachments/style.css +62 -0
  125. package/lib/attachments.vue.d.ts +39 -0
  126. package/lib/attachments.vue.js +1 -0
  127. package/lib/attachments.vue2.js +1 -0
  128. package/lib/bubble/index.d.ts +2 -0
  129. package/lib/bubble/index.js +1 -0
  130. package/lib/bubble/style.css +241 -0
  131. package/lib/bubble.vue.d.ts +27 -0
  132. package/lib/bubble.vue.js +1 -0
  133. package/lib/bubble.vue2.js +1 -0
  134. package/lib/chat/index.d.ts +11 -0
  135. package/lib/chat/index.js +1 -0
  136. package/lib/chat/style.css +595 -0
  137. package/lib/chat-panel/index.d.ts +3 -0
  138. package/lib/chat-panel/index.js +1 -0
  139. package/lib/chat-panel/style.css +595 -0
  140. package/lib/chat-panel.vue.d.ts +108 -0
  141. package/lib/chat-panel.vue.js +1 -0
  142. package/lib/chat-panel.vue2.js +1 -0
  143. package/lib/conversations/index.d.ts +2 -0
  144. package/lib/conversations/index.js +1 -0
  145. package/lib/conversations/style.css +48 -0
  146. package/lib/conversations.vue.d.ts +39 -0
  147. package/lib/conversations.vue.js +1 -0
  148. package/lib/conversations.vue2.js +1 -0
  149. package/lib/form/index.d.ts +3 -0
  150. package/lib/form/index.js +1 -0
  151. package/lib/form/style.css +242 -0
  152. package/lib/form-field.vue.d.ts +28 -0
  153. package/lib/form-field.vue.js +1 -0
  154. package/lib/form-field.vue2.js +1 -0
  155. package/lib/form-schema.d.ts +73 -0
  156. package/lib/form-schema.js +1 -0
  157. package/lib/form.vue.d.ts +81 -0
  158. package/lib/form.vue.js +1 -0
  159. package/lib/form.vue2.js +1 -0
  160. package/lib/index.d.ts +20 -0
  161. package/lib/index.js +1 -0
  162. package/lib/package.json +3 -0
  163. package/lib/process/index.d.ts +2 -0
  164. package/lib/process/index.js +1 -0
  165. package/lib/process/style.css +77 -0
  166. package/lib/process.vue.d.ts +30 -0
  167. package/lib/process.vue.js +1 -0
  168. package/lib/process.vue2.js +1 -0
  169. package/lib/prompts/index.d.ts +2 -0
  170. package/lib/prompts/index.js +1 -0
  171. package/lib/prompts/style.css +76 -0
  172. package/lib/prompts.vue.d.ts +39 -0
  173. package/lib/prompts.vue.js +1 -0
  174. package/lib/prompts.vue2.js +1 -0
  175. package/lib/safe-markdown.d.ts +3 -0
  176. package/lib/safe-markdown.js +2 -0
  177. package/lib/sender/index.d.ts +2 -0
  178. package/lib/sender/index.js +1 -0
  179. package/lib/sender/style.css +88 -0
  180. package/lib/sender.vue.d.ts +52 -0
  181. package/lib/sender.vue.js +1 -0
  182. package/lib/sender.vue2.js +1 -0
  183. package/lib/sources/index.d.ts +2 -0
  184. package/lib/sources/index.js +1 -0
  185. package/lib/sources/style.css +54 -0
  186. package/lib/sources.vue.d.ts +30 -0
  187. package/lib/sources.vue.js +1 -0
  188. package/lib/sources.vue2.js +1 -0
  189. package/lib/stream-reducer.d.ts +35 -0
  190. package/lib/stream-reducer.js +1 -0
  191. package/lib/style.css +1586 -0
  192. package/lib/thought-chain/index.d.ts +2 -0
  193. package/lib/thought-chain/index.js +1 -0
  194. package/lib/thought-chain/style.css +77 -0
  195. package/lib/thought-chain.vue.d.ts +30 -0
  196. package/lib/thought-chain.vue.js +1 -0
  197. package/lib/thought-chain.vue2.js +1 -0
  198. package/lib/types.d.ts +203 -0
  199. package/lib/welcome/index.d.ts +2 -0
  200. package/lib/welcome/index.js +1 -0
  201. package/lib/welcome/style.css +33 -0
  202. package/lib/welcome.vue.d.ts +41 -0
  203. package/lib/welcome.vue.js +1 -0
  204. package/lib/welcome.vue2.js +1 -0
  205. package/package.json +172 -3
@@ -0,0 +1,330 @@
1
+ import { defineComponent as he, getCurrentInstance as ke, ref as k, onBeforeUpdate as Ce, computed as X, watch as Y, onBeforeUnmount as _e, openBlock as g, createElementBlock as C, createBlock as oe, createCommentVNode as E, createElementVNode as U, Fragment as xe, renderList as $e, withCtx as we, createVNode as z, toDisplayString as Ie } from "vue";
2
+ import Ae from "./attachments.vue.js";
3
+ import Se from "./bubble.vue.js";
4
+ import Re from "./conversations.vue.js";
5
+ import Ve from "./prompts.vue.js";
6
+ import Ee from "./sender.vue.js";
7
+ import Be from "./welcome.vue.js";
8
+ import { createAIStreamReducer as De } from "./stream-reducer.js";
9
+ const Me = {
10
+ class: "aheart-ai-chat-panel",
11
+ "aria-label": "AI 对话"
12
+ }, Ue = { class: "aheart-ai-chat-panel__surface" }, Pe = {
13
+ key: 0,
14
+ class: "aheart-ai-chat-panel__messages",
15
+ role: "log",
16
+ "aria-live": "polite",
17
+ "aria-relevant": "additions text"
18
+ }, Ne = {
19
+ class: "aheart-ai-chat-panel__message-actions",
20
+ "aria-label": "消息操作"
21
+ }, Te = ["aria-label", "onClick"], je = ["disabled", "onClick"], Fe = ["disabled", "onClick"], Oe = ["disabled", "onClick"], Ke = {
22
+ key: 1,
23
+ class: "aheart-ai-chat-panel__empty"
24
+ }, Le = { class: "aheart-ai-chat-panel__composer" }, ze = {
25
+ key: 0,
26
+ class: "aheart-ai-chat-panel__stream-reconnecting",
27
+ role: "status",
28
+ "aria-live": "polite"
29
+ }, Ge = {
30
+ key: 1,
31
+ class: "aheart-ai-chat-panel__editing",
32
+ role: "status"
33
+ }, He = {
34
+ class: "aheart-ai-visually-hidden",
35
+ role: "status",
36
+ "aria-live": "polite"
37
+ }, tt = /* @__PURE__ */ he({
38
+ name: "AAIChatPanel",
39
+ __name: "chat-panel",
40
+ props: {
41
+ messages: { default: () => [] },
42
+ defaultMessages: { default: () => [] },
43
+ transport: {},
44
+ conversationId: { default: void 0 },
45
+ conversations: { default: () => [] },
46
+ activeConversation: { default: void 0 },
47
+ prompts: { default: () => [] },
48
+ attachments: { default: () => [] },
49
+ welcomeTitle: { default: "你好,我能为你做些什么?" },
50
+ welcomeDescription: { default: "描述目标、补充上下文,或从建议任务开始。" },
51
+ disabled: { type: Boolean, default: !1 },
52
+ maxReconnectAttempts: { default: 1 }
53
+ },
54
+ emits: ["update:messages", "update:activeConversation", "update:attachments", "send", "stop", "retry", "regenerate", "edit", "copy", "error", "stream-status", "stream-reject"],
55
+ setup(m, { emit: re }) {
56
+ const i = m, n = re, _ = ke(), Z = (e) => Object.prototype.hasOwnProperty.call((_ == null ? void 0 : _.vnode.props) ?? {}, e), q = k(Z("messages"));
57
+ Ce(() => {
58
+ q.value = Z("messages");
59
+ });
60
+ const f = () => q.value, G = k([...i.defaultMessages]), l = k(f() ? [...i.messages] : [...G.value]), S = k(""), u = k(!1), y = k(), R = k(), B = k(), P = k(""), x = k("idle");
61
+ let p = 0, ne = 0;
62
+ const w = X(() => f() ? i.messages : G.value), H = X(() => i.conversationId ?? i.activeConversation), le = X(() => {
63
+ if (x.value === "reconnecting") return "";
64
+ if (!f() && u.value && P.value) return `AI 回复:${P.value}`;
65
+ const e = [...w.value].reverse().find((a) => a.role === "assistant");
66
+ return e ? e.status === "streaming" ? "正在生成" : e.status === "stopped" ? "已停止生成" : e.status === "error" ? "生成失败" : e.status === "complete" ? "已完成生成" : "" : "";
67
+ }), $ = (e) => {
68
+ e === "idle" && u.value && (x.value === "streaming" || x.value === "reconnecting") || x.value !== e && (x.value = e, n("stream-status", e));
69
+ };
70
+ Y(
71
+ () => i.messages,
72
+ (e) => {
73
+ f() && !u.value && (l.value = [...e]);
74
+ },
75
+ { deep: !0 }
76
+ );
77
+ const T = (e) => `${e}-${Date.now()}-${ne++}`, D = (e) => {
78
+ l.value = e, f() || (G.value = e), n("update:messages", e);
79
+ }, j = (e, a) => {
80
+ D(l.value.map((t) => t.id === e ? { ...t, ...a } : t));
81
+ }, ie = (e, a, t) => e == null ? void 0 : e.map((s) => s.status === "pending" || s.status === "running" ? { ...s, status: a, ...t && !s.detail ? { detail: t } : {} } : s), M = (e, a, t) => {
82
+ const s = l.value.find((d) => d.id === e);
83
+ if (!s) return;
84
+ const o = a === "complete" ? "complete" : a === "stopped" ? "stopped" : "error";
85
+ j(e, {
86
+ status: a,
87
+ ...t ? { error: t } : {},
88
+ process: ie(s.process, o, t)
89
+ }), a === "complete" ? $("completed") : a === "stopped" ? $("cancelled") : a === "error" && $("error");
90
+ }, ce = (e, a) => {
91
+ const t = l.value.find((s) => s.id === e);
92
+ if (!t) return !1;
93
+ if (a.type === "text-delta")
94
+ f() || (P.value = a.delta), j(e, { content: `${t.content}${a.delta}` });
95
+ else if (a.type === "process") {
96
+ const s = [...(t.process ?? []).filter((o) => o.id !== a.item.id), a.item];
97
+ j(e, { process: s });
98
+ } else if (a.type === "sources")
99
+ j(e, { sources: a.sources });
100
+ else {
101
+ if (a.type === "done")
102
+ return M(e, "complete"), !0;
103
+ if (a.type === "cancelled")
104
+ return M(e, "stopped"), !0;
105
+ if (a.type === "error")
106
+ return M(e, "error", a.error), n("error", a.error), !0;
107
+ }
108
+ return !1;
109
+ }, J = async (e, a = {}) => {
110
+ var te, ae, se;
111
+ const t = {
112
+ id: T("assistant"),
113
+ role: "assistant",
114
+ content: "",
115
+ status: "streaming"
116
+ }, s = ((ae = (te = _ == null ? void 0 : _.proxy) == null ? void 0 : te.$el) == null ? void 0 : ae.ownerDocument) ?? (typeof document < "u" ? document : void 0), o = new (((se = s == null ? void 0 : s.defaultView) == null ? void 0 : se.AbortController) ?? AbortController)(), d = ++p, r = i.transport, N = r && "version" in r && r.version === "2", F = T("request");
117
+ u.value = !0, $("streaming"), y.value = o, R.value = t.id, P.value = "", N && f() ? l.value = [...e, t] : D([...e, t]), N && f() && n("update:messages", [...e, t]);
118
+ try {
119
+ if (N) {
120
+ const b = {
121
+ version: "2",
122
+ requestId: F,
123
+ messageId: t.id,
124
+ idempotencyKey: T("idempotency"),
125
+ conversationId: H.value,
126
+ messages: e,
127
+ ...a.action && { action: a.action },
128
+ ...a.messageId && { targetMessageId: a.messageId }
129
+ }, c = De({ requestId: F, messageId: t.id, maxReconnectAttempts: i.maxReconnectAttempts });
130
+ let V = r.send(b, o.signal), O = 0, K = !1, L = !1;
131
+ for (; !K; )
132
+ try {
133
+ for await (const h of V) {
134
+ if (d !== p || o.signal.aborted) break;
135
+ const v = c.dispatch(h);
136
+ if (v.diagnostic.kind === "protocol-error") {
137
+ const Q = c.failRecovery(`协议错误:${v.diagnostic.reason ?? "invalid envelope"}`, !1);
138
+ n("stream-reject", v.diagnostic.reason ?? "协议错误"), $(Q.status), n("error", Q.message.error ?? "协议错误");
139
+ const ye = { ...t, ...Q.message };
140
+ l.value = [...e, ye], f() ? n("update:messages", l.value) : D(l.value), L = !0, K = !0;
141
+ break;
142
+ }
143
+ $(v.status), (v.status === "completed" || v.status === "cancelled" || v.status === "error") && (K = !0);
144
+ const be = { ...t, ...v.message };
145
+ if (l.value = [...e, be], f() ? n("update:messages", l.value) : D(l.value), !f() && h.type === "text-delta" && v.diagnostic.kind === "accepted" && (P.value = h.delta), v.status === "completed" || v.status === "cancelled" || v.status === "error") {
146
+ K = !0;
147
+ break;
148
+ }
149
+ if (v.recoveryRequired) break;
150
+ }
151
+ if (d !== p || o.signal.aborted) break;
152
+ const I = c.getState();
153
+ if (I.status === "completed" || I.status === "cancelled" || I.status === "error") break;
154
+ if (L || !("resume" in r) || !r.resume || O >= Math.max(0, Number.isSafeInteger(i.maxReconnectAttempts) ? i.maxReconnectAttempts : 1)) {
155
+ let h = r.resume ? c.recover({ reason: L ? "protocol" : "eof" }) : c.failRecovery("连接中断,请重试");
156
+ h.status === "reconnecting" && L && (h = c.failRecovery("协议错误", !1)), $(h.status);
157
+ const v = { ...t, ...h.message };
158
+ l.value = [...e, v], f() ? n("update:messages", l.value) : D(l.value);
159
+ break;
160
+ }
161
+ O += 1;
162
+ const A = c.recover({ reason: "eof" });
163
+ $(A.status), V = r.resume({ ...b, resume: c.getState().cursor }, o.signal);
164
+ } catch {
165
+ if (d !== p || o.signal.aborted) break;
166
+ let A = r.resume ? c.recover({ reason: "transport" }) : c.failRecovery("连接中断,请重试", !0);
167
+ if ($(A.status), A.status === "error") {
168
+ const h = { ...t, ...A.message };
169
+ l.value = [...e, h], f() ? n("update:messages", l.value) : D(l.value);
170
+ }
171
+ if (!("resume" in r) || !r.resume || A.status === "error" || O >= (i.maxReconnectAttempts ?? 1)) break;
172
+ O += 1, V = r.resume({ ...b, resume: c.getState().cursor }, o.signal);
173
+ }
174
+ if (d === p && !o.signal.aborted) {
175
+ const I = c.getState(), A = { ...t, ...I.message };
176
+ l.value = [...e, A], I.status === "error" && n("error", I.message.error ?? "生成失败");
177
+ }
178
+ } else {
179
+ const b = r;
180
+ for await (const V of b.send({ conversationId: H.value, messages: e, ...a.action && { action: a.action }, ...a.messageId && { messageId: a.messageId } }, o.signal))
181
+ if (d !== p || o.signal.aborted || ce(t.id, V)) break;
182
+ const c = l.value.find((V) => V.id === t.id);
183
+ (c == null ? void 0 : c.status) === "streaming" && d === p && M(t.id, "complete");
184
+ }
185
+ } catch (b) {
186
+ const c = String(b instanceof Error ? b.message : b);
187
+ if (o.signal.aborted || d !== p)
188
+ return;
189
+ M(t.id, "error", c), n("error", c);
190
+ } finally {
191
+ y.value === o && (u.value = !1, x.value = w.value.some((b) => b.status === "streaming") ? "streaming" : "idle", y.value = void 0, R.value = void 0, l.value = [...w.value]);
192
+ }
193
+ }, W = async (e) => {
194
+ const a = (e ?? S.value).trim();
195
+ if (!a || u.value || i.disabled) return;
196
+ if (B.value) {
197
+ const o = B.value, d = [...w.value], r = d.findIndex((F) => F.id === o.id);
198
+ if (r < 0) return;
199
+ const N = { ...o, content: a, status: "complete" };
200
+ S.value = "", B.value = void 0, n("edit", o, a), await J([...d.slice(0, r), N], { action: "edit", messageId: o.id });
201
+ return;
202
+ }
203
+ const t = {
204
+ id: T("user"),
205
+ role: "user",
206
+ content: a,
207
+ status: "complete",
208
+ ...i.attachments.length && { attachments: [...i.attachments] }
209
+ }, s = [...w.value, t];
210
+ S.value = "", n("send", a), i.attachments.length && n("update:attachments", []), await J(s);
211
+ }, ee = async (e, a) => {
212
+ if (u.value || i.disabled) return;
213
+ const t = [...w.value], s = t.findIndex((r) => r.id === e.id);
214
+ if (s < 1) return;
215
+ const o = t.slice(0, s);
216
+ [...o].reverse().find((r) => r.role === "user") && (n(a === "retry" ? "retry" : "regenerate", e), await J(o, { action: a, messageId: e.id }));
217
+ }, ue = (e) => ee(e, "retry"), de = (e) => ee(e, "regenerate"), ve = (e) => {
218
+ u.value || i.disabled || (B.value = e, S.value = e.content);
219
+ }, me = () => {
220
+ B.value = void 0, S.value = "";
221
+ }, fe = (e) => {
222
+ var t, s, o, d, r;
223
+ const a = (o = (s = (t = _ == null ? void 0 : _.proxy) == null ? void 0 : t.$el) == null ? void 0 : s.ownerDocument) == null ? void 0 : o.defaultView;
224
+ (r = (d = a == null ? void 0 : a.navigator) == null ? void 0 : d.clipboard) == null || r.writeText(e.content), n("copy", e);
225
+ }, pe = (e) => {
226
+ n("update:attachments", i.attachments.filter((a) => a.id !== e.id));
227
+ }, ge = () => {
228
+ p += 1;
229
+ const e = y.value;
230
+ R.value && M(R.value, "stopped"), e == null || e.abort(), y.value = void 0, R.value = void 0, u.value = !1, n("stop");
231
+ };
232
+ return Y(H, (e, a) => {
233
+ var t;
234
+ e !== a && (p += 1, (t = y.value) == null || t.abort(), y.value = void 0, R.value = void 0, u.value = !1, x.value = "idle");
235
+ }), Y(() => i.transport, (e, a) => {
236
+ var t;
237
+ e !== a && (p += 1, (t = y.value) == null || t.abort(), y.value = void 0, R.value = void 0, u.value = !1, x.value = "idle");
238
+ }), _e(() => {
239
+ var e;
240
+ p += 1, (e = y.value) == null || e.abort();
241
+ }), (e, a) => (g(), C("section", Me, [
242
+ m.conversations.length ? (g(), oe(Re, {
243
+ key: 0,
244
+ "model-value": m.activeConversation,
245
+ conversations: m.conversations,
246
+ "onUpdate:modelValue": a[0] || (a[0] = (t) => n("update:activeConversation", t))
247
+ }, null, 8, ["model-value", "conversations"])) : E("", !0),
248
+ U("div", Ue, [
249
+ w.value.length ? (g(), C("div", Pe, [
250
+ (g(!0), C(xe, null, $e(w.value, (t) => (g(), oe(Se, {
251
+ key: t.id,
252
+ "data-message-id": t.id,
253
+ message: t
254
+ }, {
255
+ actions: we(() => [
256
+ U("div", Ne, [
257
+ t.content ? (g(), C("button", {
258
+ key: 0,
259
+ type: "button",
260
+ "data-action": "copy",
261
+ "aria-label": `复制${t.role === "user" ? "问题" : "回答"}`,
262
+ onClick: (s) => fe(t)
263
+ }, " 复制 ", 8, Te)) : E("", !0),
264
+ t.role === "user" ? (g(), C("button", {
265
+ key: 1,
266
+ type: "button",
267
+ "data-action": "edit",
268
+ disabled: m.disabled || u.value,
269
+ onClick: (s) => ve(t)
270
+ }, " 编辑 ", 8, je)) : E("", !0),
271
+ t.role === "assistant" && (t.status === "error" || t.status === "stopped") && t.retryable !== !1 ? (g(), C("button", {
272
+ key: 2,
273
+ type: "button",
274
+ "data-action": "retry",
275
+ disabled: m.disabled || u.value,
276
+ onClick: (s) => ue(t)
277
+ }, " 重试 ", 8, Fe)) : E("", !0),
278
+ t.role === "assistant" && t.status === "complete" ? (g(), C("button", {
279
+ key: 3,
280
+ type: "button",
281
+ "data-action": "regenerate",
282
+ disabled: m.disabled || u.value,
283
+ onClick: (s) => de(t)
284
+ }, " 重新生成 ", 8, Oe)) : E("", !0)
285
+ ])
286
+ ]),
287
+ _: 2
288
+ }, 1032, ["data-message-id", "message"]))), 128))
289
+ ])) : (g(), C("div", Ke, [
290
+ z(Be, {
291
+ title: m.welcomeTitle,
292
+ description: m.welcomeDescription
293
+ }, null, 8, ["title", "description"]),
294
+ z(Ve, {
295
+ prompts: m.prompts,
296
+ disabled: m.disabled || u.value,
297
+ onSelect: a[1] || (a[1] = (t) => W(t.label))
298
+ }, null, 8, ["prompts", "disabled"])
299
+ ])),
300
+ U("div", Le, [
301
+ x.value === "reconnecting" ? (g(), C("p", ze, "正在恢复连接")) : E("", !0),
302
+ B.value ? (g(), C("div", Ge, [
303
+ a[3] || (a[3] = U("span", null, "正在编辑已发送的问题", -1)),
304
+ U("button", {
305
+ type: "button",
306
+ onClick: me
307
+ }, "取消编辑")
308
+ ])) : E("", !0),
309
+ z(Ae, {
310
+ items: m.attachments,
311
+ removable: "",
312
+ onRemove: pe
313
+ }, null, 8, ["items"]),
314
+ z(Ee, {
315
+ modelValue: S.value,
316
+ "onUpdate:modelValue": a[2] || (a[2] = (t) => S.value = t),
317
+ disabled: m.disabled,
318
+ loading: u.value,
319
+ onSubmit: W,
320
+ onStop: ge
321
+ }, null, 8, ["modelValue", "disabled", "loading"])
322
+ ])
323
+ ]),
324
+ U("p", He, Ie(le.value), 1)
325
+ ]));
326
+ }
327
+ });
328
+ export {
329
+ tt as default
330
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./chat-panel.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,2 @@
1
+ export { default as AIConversations, default } from '../conversations.vue';
2
+ export type * from '../types';
@@ -0,0 +1,5 @@
1
+ import { default as o, default as t } from "../conversations.vue.js";
2
+ export {
3
+ o as AIConversations,
4
+ t as default
5
+ };
@@ -0,0 +1,48 @@
1
+ :root {
2
+ --aheart-ai-cyan: #0e7490;
3
+ --aheart-ai-cyan-strong: #0e7490;
4
+ --aheart-ai-brand-strong: #0958d9;
5
+ --aheart-ai-cyan-soft: #ecfeff;
6
+ --aheart-ai-line: #e4e7ec;
7
+ --aheart-ai-surface: #ffffff;
8
+ --aheart-ai-surface-subtle: #f8fafc;
9
+ --aheart-ai-text: #182230;
10
+ --aheart-ai-text-secondary: #667085;
11
+ }
12
+
13
+ .aheart-ai-conversations {
14
+ display: grid;
15
+ gap: 8px;
16
+ }
17
+
18
+ .aheart-ai-conversations button {
19
+ min-block-size: 36px;
20
+ padding: 7px 9px;
21
+ border: 1px solid transparent;
22
+ border-radius: 5px;
23
+ background: transparent;
24
+ color: var(--aheart-ai-text-secondary);
25
+ font: inherit;
26
+ text-align: left;
27
+ cursor: pointer;
28
+ }
29
+
30
+ .aheart-ai-conversations button:hover,
31
+ .aheart-ai-conversations button:focus-visible {
32
+ background: #f2f4f7;
33
+ color: var(--aheart-ai-text);
34
+ outline: none;
35
+ }
36
+
37
+ .aheart-ai-conversations button.is-active {
38
+ border-color: #b2ddff;
39
+ background: #eff8ff;
40
+ color: #175cd3;
41
+ }
42
+
43
+ @media (pointer: coarse) {
44
+ .aheart-ai-conversations button {
45
+ min-block-size: 44px;
46
+ min-inline-size: 44px;
47
+ }
48
+ }
@@ -0,0 +1,39 @@
1
+ import type { AIConversation } from './types';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ modelValue?: string | undefined;
4
+ conversations?: AIConversation[] | undefined;
5
+ }>, {
6
+ modelValue: undefined;
7
+ conversations: () => never[];
8
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:modelValue": (key: string) => void;
10
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
11
+ modelValue?: string | undefined;
12
+ conversations?: AIConversation[] | undefined;
13
+ }>, {
14
+ modelValue: undefined;
15
+ conversations: () => never[];
16
+ }>>> & Readonly<{
17
+ "onUpdate:modelValue"?: ((key: string) => any) | undefined;
18
+ }>, {
19
+ modelValue: string;
20
+ conversations: AIConversation[];
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ export default _default;
23
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
24
+ type __VLS_TypePropsToRuntimeProps<T> = {
25
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
26
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
27
+ } : {
28
+ type: import('vue').PropType<T[K]>;
29
+ required: true;
30
+ };
31
+ };
32
+ type __VLS_WithDefaults<P, D> = {
33
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
34
+ default: D[K];
35
+ }> : P[K];
36
+ };
37
+ type __VLS_Prettify<T> = {
38
+ [K in keyof T]: T[K];
39
+ } & {};
@@ -0,0 +1,29 @@
1
+ import { defineComponent as s, openBlock as t, createElementBlock as l, Fragment as i, renderList as r, normalizeClass as d, toDisplayString as u } from "vue";
2
+ const c = {
3
+ class: "aheart-ai-conversations",
4
+ "aria-label": "会话列表"
5
+ }, m = ["disabled", "aria-current", "onClick"], f = /* @__PURE__ */ s({
6
+ name: "AAIConversations",
7
+ __name: "conversations",
8
+ props: {
9
+ modelValue: { default: void 0 },
10
+ conversations: { default: () => [] }
11
+ },
12
+ emits: ["update:modelValue"],
13
+ setup(a, { emit: n }) {
14
+ const o = n;
15
+ return (k, p) => (t(), l("nav", c, [
16
+ (t(!0), l(i, null, r(a.conversations, (e) => (t(), l("button", {
17
+ key: e.key,
18
+ type: "button",
19
+ class: d({ "is-active": e.key === a.modelValue }),
20
+ disabled: e.disabled,
21
+ "aria-current": e.key === a.modelValue ? "page" : void 0,
22
+ onClick: (b) => o("update:modelValue", e.key)
23
+ }, u(e.label), 11, m))), 128))
24
+ ]));
25
+ }
26
+ });
27
+ export {
28
+ f as default
29
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./conversations.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,3 @@
1
+ export { default as AIForm, default } from '../form.vue';
2
+ export type * from '../types';
3
+ export * from '../form-schema';
@@ -0,0 +1,9 @@
1
+ import { default as e, default as o } from "../form.vue.js";
2
+ import { AI_FORM_CONDITION_OPERATORS as O, AI_FORM_FIELD_TYPES as _, validateAIFormSchema as m } from "../form-schema.js";
3
+ export {
4
+ e as AIForm,
5
+ O as AI_FORM_CONDITION_OPERATORS,
6
+ _ as AI_FORM_FIELD_TYPES,
7
+ o as default,
8
+ m as validateAIFormSchema
9
+ };