@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,81 @@
1
+ import { type AIFormAsyncValidator } from './form-schema';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ modelValue?: Record<string, unknown> | undefined;
4
+ schema: unknown;
5
+ disabled?: boolean | undefined;
6
+ submitting?: boolean | undefined;
7
+ submitText?: string | undefined;
8
+ submitError?: string | undefined;
9
+ validators?: Record<string, AIFormAsyncValidator> | undefined;
10
+ }>, {
11
+ modelValue: () => {};
12
+ disabled: boolean;
13
+ submitting: boolean;
14
+ submitText: string;
15
+ submitError: undefined;
16
+ validators: () => {};
17
+ }>>, {
18
+ validate: () => Promise<any>;
19
+ resetFields: () => void;
20
+ clearValidate: (names?: string[] | undefined) => void;
21
+ setFieldsErrors: (fields: {
22
+ name: string;
23
+ errors: string[];
24
+ }[]) => void;
25
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
26
+ submit: (value: Record<string, unknown>) => void;
27
+ "update:modelValue": (value: Record<string, unknown>) => void;
28
+ "schema-error": (errors: string[]) => void;
29
+ "validation-error": (errors: {
30
+ key: string;
31
+ message: string;
32
+ }[]) => void;
33
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
34
+ modelValue?: Record<string, unknown> | undefined;
35
+ schema: unknown;
36
+ disabled?: boolean | undefined;
37
+ submitting?: boolean | undefined;
38
+ submitText?: string | undefined;
39
+ submitError?: string | undefined;
40
+ validators?: Record<string, AIFormAsyncValidator> | undefined;
41
+ }>, {
42
+ modelValue: () => {};
43
+ disabled: boolean;
44
+ submitting: boolean;
45
+ submitText: string;
46
+ submitError: undefined;
47
+ validators: () => {};
48
+ }>>> & Readonly<{
49
+ onSubmit?: ((value: Record<string, unknown>) => any) | undefined;
50
+ "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
51
+ "onSchema-error"?: ((errors: string[]) => any) | undefined;
52
+ "onValidation-error"?: ((errors: {
53
+ key: string;
54
+ message: string;
55
+ }[]) => any) | undefined;
56
+ }>, {
57
+ disabled: boolean;
58
+ modelValue: Record<string, unknown>;
59
+ submitting: boolean;
60
+ submitText: string;
61
+ submitError: string;
62
+ validators: Record<string, AIFormAsyncValidator>;
63
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
+ export default _default;
65
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
66
+ type __VLS_TypePropsToRuntimeProps<T> = {
67
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
68
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
69
+ } : {
70
+ type: import('vue').PropType<T[K]>;
71
+ required: true;
72
+ };
73
+ };
74
+ type __VLS_WithDefaults<P, D> = {
75
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
76
+ default: D[K];
77
+ }> : P[K];
78
+ };
79
+ type __VLS_Prettify<T> = {
80
+ [K in keyof T]: T[K];
81
+ } & {};
package/es/form.vue.js ADDED
@@ -0,0 +1,376 @@
1
+ import { defineComponent as Ae, computed as R, reactive as D, ref as q, onMounted as Fe, watch as k, toRaw as J, onBeforeUnmount as Ve, openBlock as c, createBlock as Q, unref as X, withCtx as W, createElementBlock as d, toDisplayString as v, createCommentVNode as V, createElementVNode as j, Fragment as K, renderList as I, resolveDynamicComponent as je, createVNode as ne, createTextVNode as we, nextTick as le } from "vue";
2
+ import { Form as Ee, FormItem as $e, Button as Se } from "aheart-ui";
3
+ import Re from "./form-field.vue.js";
4
+ import { validateAIFormSchema as qe } from "./form-schema.js";
5
+ const Ce = {
6
+ key: 0,
7
+ class: "aheart-ai-form__header"
8
+ }, xe = { key: 0 }, Me = { key: 1 }, Ne = {
9
+ key: 1,
10
+ class: "aheart-ai-form__error-summary",
11
+ role: "alert",
12
+ tabindex: "-1"
13
+ }, Te = ["onClick"], Pe = { key: 0 }, Ue = { key: 0 }, Be = {
14
+ key: 2,
15
+ class: "aheart-ai-form__submit-error",
16
+ role: "alert"
17
+ }, De = { class: "aheart-ai-form__footer" }, We = {
18
+ key: 1,
19
+ class: "aheart-ai-form__error",
20
+ role: "alert"
21
+ }, Qe = /* @__PURE__ */ Ae({
22
+ name: "AAIForm",
23
+ __name: "form",
24
+ props: {
25
+ modelValue: { default: () => ({}) },
26
+ schema: {},
27
+ disabled: { type: Boolean, default: !1 },
28
+ submitting: { type: Boolean, default: !1 },
29
+ submitText: { default: "提交" },
30
+ submitError: { default: void 0 },
31
+ validators: { default: () => ({}) }
32
+ },
33
+ emits: ["update:modelValue", "submit", "schema-error", "validation-error"],
34
+ setup(p, { expose: ie, emit: ce }) {
35
+ const u = p, w = ce, i = R(() => {
36
+ const e = qe(u.schema);
37
+ if (!e.valid || !e.schema) return e;
38
+ const t = e.schema.fields.flatMap((r) => (r.rules ?? []).filter((a) => a.kind === "async" && !(Object.prototype.hasOwnProperty.call(u.validators, a.validator) && typeof u.validators[a.validator] == "function")).map((a) => `fields.${r.key}.rules.${a.validator} validator 不存在`));
39
+ return t.length ? { valid: !1, errors: [...e.errors, ...t] } : e;
40
+ }), h = R(() => u.modelValue), b = R(
41
+ () => {
42
+ var e;
43
+ return (((e = i.value.schema) == null ? void 0 : e.fields) ?? []).reduce(
44
+ (t, r) => {
45
+ const a = Object.prototype.hasOwnProperty.call(h.value, r.key);
46
+ return !a && P.has(r.key) || (t[r.key] = a ? h.value[r.key] : r.defaultValue), t;
47
+ },
48
+ { ...h.value }
49
+ );
50
+ }
51
+ ), l = D({}), N = D({}), T = /* @__PURE__ */ new Map(), L = D({}), z = /* @__PURE__ */ new Map(), _ = q(), m = /* @__PURE__ */ new Map(), Z = () => {
52
+ for (const e of m.values()) e.abort();
53
+ m.clear();
54
+ }, G = q({}), P = D(/* @__PURE__ */ new Set()), g = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), ue = q(!1);
55
+ Fe(() => {
56
+ ue.value = !0;
57
+ });
58
+ const ee = q(!1), de = q(0), $ = q(!1);
59
+ k(
60
+ i,
61
+ (e) => {
62
+ e.valid || w("schema-error", e.errors);
63
+ },
64
+ { immediate: !0 }
65
+ ), k(b, (e) => {
66
+ Object.keys(G.value).length || (G.value = M(e));
67
+ }, { immediate: !0, deep: !0 }), k(
68
+ b,
69
+ (e, t) => {
70
+ Object.keys(N).forEach((r) => {
71
+ Object.prototype.hasOwnProperty.call(e, r) || delete N[r];
72
+ }), Object.entries(e).forEach(([r, a]) => {
73
+ const s = T.get(r);
74
+ T.has(r) ? F(a, s) && (T.delete(r), delete l[r]) : t && !F(a, t[r]) && delete l[r], N[r] = M(a);
75
+ });
76
+ },
77
+ { immediate: !0, deep: !0 }
78
+ ), k(h, (e) => {
79
+ for (const t of [...g]) {
80
+ const r = O.get(t), a = A.get(t), s = J(e);
81
+ if (s !== r) {
82
+ if (s !== r && !F(s, a)) {
83
+ g.delete(t), E.delete(t), O.delete(t), A.delete(t);
84
+ continue;
85
+ }
86
+ Object.prototype.hasOwnProperty.call(e, t) ? (g.delete(t), E.delete(t), O.delete(t), A.delete(t)) : (P.add(t), g.delete(t), E.delete(t), O.delete(t), A.delete(t));
87
+ }
88
+ }
89
+ }, { deep: !0 });
90
+ const H = (e) => {
91
+ if (!e) return !0;
92
+ const t = b.value[e.field];
93
+ return e.operator === "equals" ? t === e.value : e.operator === "not-equals" ? t !== e.value : e.operator === "includes" ? Array.isArray(t) ? t.includes(e.value) : String(t ?? "").includes(String(e.value ?? "")) : e.operator === "not-includes" ? Array.isArray(t) ? !t.includes(e.value) : !String(t ?? "").includes(String(e.value ?? "")) : e.operator === "is-empty" ? S(t) : !S(t);
94
+ }, C = R(
95
+ () => {
96
+ var e;
97
+ return ((e = i.value.schema) == null ? void 0 : e.fields.filter((t) => H(t.visibleWhen))) ?? [];
98
+ }
99
+ );
100
+ k(b, (e, t) => {
101
+ var n;
102
+ const r = t ?? {}, a = { ...h.value };
103
+ let s = !1;
104
+ for (const o of ((n = i.value.schema) == null ? void 0 : n.fields) ?? []) {
105
+ const f = te(o.visibleWhen, r), y = te(o.visibleWhen, e);
106
+ y && g.has(o.key) && !P.has(o.key) && (g.delete(o.key), E.delete(o.key), O.delete(o.key), A.delete(o.key)), f && !y && o.preserve === !1 && (delete a[o.key], g.add(o.key), E.set(o.key, Object.prototype.hasOwnProperty.call(h.value, o.key)), O.set(o.key, J(h.value)), A.set(o.key, J(a)), s = !0);
107
+ }
108
+ s && w("update:modelValue", a);
109
+ }, { deep: !0 }), k(b, (e, t) => {
110
+ var a, s;
111
+ const r = t ?? {};
112
+ for (const n of ((a = i.value.schema) == null ? void 0 : a.fields) ?? []) {
113
+ const o = oe(n);
114
+ (!F(e[n.key], r[n.key]) || o.some((y) => !F(e[y], r[y]))) && ((s = m.get(n.key)) == null || s.abort(), m.delete(n.key));
115
+ }
116
+ }, { deep: !0 }), k(() => u.schema, () => {
117
+ for (const e of m.values()) e.abort();
118
+ m.clear();
119
+ });
120
+ const te = (e, t) => {
121
+ if (!e) return !0;
122
+ const r = t[e.field];
123
+ return e.operator === "equals" ? r === e.value : e.operator === "not-equals" ? r !== e.value : e.operator === "is-empty" ? S(r) : e.operator === "is-not-empty" ? !S(r) : e.operator === "includes" ? Array.isArray(r) ? r.includes(e.value) : String(r ?? "").includes(String(e.value ?? "")) : Array.isArray(r) ? !r.includes(e.value) : !String(r ?? "").includes(String(e.value ?? ""));
124
+ }, x = (e) => u.disabled || u.submitting || !!(e.disabledWhen && H(e.disabledWhen)), me = R(() => {
125
+ const e = i.value.schema;
126
+ if (!e) return [];
127
+ const t = (e.groups ?? []).map((a) => ({
128
+ key: a.key,
129
+ group: a,
130
+ fields: C.value.filter((s) => s.group === a.key)
131
+ })).filter((a) => a.fields.length > 0), r = C.value.filter((a) => !a.group);
132
+ return r.length && t.push({ key: "__ungrouped", fields: r }), t;
133
+ }), Y = R(
134
+ () => C.value.filter((e) => l[e.key]).map((e) => ({ key: e.key, message: l[e.key] }))
135
+ );
136
+ k([b, C], () => {
137
+ var t;
138
+ const e = ((t = i.value.schema) == null ? void 0 : t.fields) ?? [];
139
+ Object.keys(l).forEach((r) => {
140
+ const a = e.find((s) => s.key === r);
141
+ (!a || !H(a.visibleWhen) || x(a)) && delete l[r];
142
+ });
143
+ });
144
+ function S(e) {
145
+ return e == null || e === "" || e === !1 || Array.isArray(e) && (e.length === 0 || e.every((t) => t == null || t === ""));
146
+ }
147
+ function F(e, t) {
148
+ if (Object.is(e, t)) return !0;
149
+ if (Array.isArray(e) || Array.isArray(t))
150
+ return Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((r, a) => F(r, t[a]));
151
+ if (e && t && typeof e == "object" && typeof t == "object") {
152
+ const r = e, a = t, s = Object.keys(r), n = Object.keys(a);
153
+ return s.length === n.length && s.every((o) => Object.prototype.hasOwnProperty.call(a, o) && F(r[o], a[o]));
154
+ }
155
+ return !1;
156
+ }
157
+ function M(e) {
158
+ return Array.isArray(e) ? e.map((t) => M(t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(Object.entries(e).map(([t, r]) => [t, M(r)])) : e;
159
+ }
160
+ const fe = (e, t) => e.type === "date-range" || e.type === "time-range" ? !Array.isArray(t) || t.length !== 2 || t.some((r) => r == null || r === "") : S(t), ye = (e) => {
161
+ const t = b.value[e.key];
162
+ if (t !== void 0) return t;
163
+ if (e.type === "checkbox" || e.type === "upload") return [];
164
+ if (!(e.type === "date-range" || e.type === "time-range"))
165
+ return "";
166
+ }, pe = (e) => `${e.key}-${L[e.key] ?? 0}`, he = (e, t) => {
167
+ t && typeof t.focus == "function" ? z.set(e, t) : z.delete(e);
168
+ }, re = (e) => {
169
+ var t;
170
+ return (t = z.get(e)) == null ? void 0 : t.focus();
171
+ }, be = async (e, t) => {
172
+ T.set(e, t), w("update:modelValue", { ...h.value, [e]: t }), await le(), h.value[e] !== t && (L[e] = (L[e] ?? 0) + 1);
173
+ }, ve = (e) => {
174
+ if (x(e)) return [];
175
+ const t = [];
176
+ if (e.required && !x(e)) {
177
+ const r = `${e.label}为必填项`;
178
+ t.push({ required: !0, message: r }, { message: r, validator: (a, s) => fe(e, s) ? r : void 0 });
179
+ }
180
+ for (const r of e.rules ?? []) t.push(ge(e, r));
181
+ return t;
182
+ }, ae = (e) => {
183
+ if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
184
+ const [t, r, a] = e.split("-").map(Number), s = new Date(Date.UTC(t, r - 1, a));
185
+ return s.getUTCFullYear() === t && s.getUTCMonth() === r - 1 && s.getUTCDate() === a;
186
+ }, se = (e) => typeof e == "string" && /^\d{2}:\d{2}:\d{2}$/.test(e) && e.split(":").map(Number).every((t, r) => r === 0 ? t < 24 : t < 60), ge = (e, t) => ({
187
+ ...t.kind === "format" && t.format === "email" ? { type: "email" } : {},
188
+ ...t.kind === "range" && t.min !== void 0 ? { min: t.min } : {},
189
+ ...t.kind === "range" && t.max !== void 0 ? { max: t.max } : {},
190
+ message: t.message ?? `${e.label}校验失败`,
191
+ validator: (r, a) => {
192
+ if (!e.required && S(a)) return;
193
+ if (t.kind === "range") {
194
+ const o = t.valueType === "number" ? typeof a == "number" && Number.isFinite(a) ? a : void 0 : typeof a == "string" || Array.isArray(a) ? a.length : void 0;
195
+ return o === void 0 || t.min !== void 0 && o < t.min || t.max !== void 0 && o > t.max ? t.message ?? `${e.label}范围不合法` : void 0;
196
+ }
197
+ if (t.kind === "format")
198
+ return typeof a != "string" ? t.message ?? `${e.label}格式不合法` : (t.format === "email" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a) : t.format === "url" ? (() => {
199
+ try {
200
+ const f = new URL(a);
201
+ return f.protocol === "http:" || f.protocol === "https:";
202
+ } catch {
203
+ return !1;
204
+ }
205
+ })() : t.format === "date" ? /^\d{4}-\d{2}-\d{2}$/.test(a) && ae(a) : se(a)) ? void 0 : t.message ?? `${e.label}格式不合法`;
206
+ if (t.kind === "compare") {
207
+ const o = b.value[t.field];
208
+ if (!(typeof a == typeof o && (typeof a == "number" ? Number.isFinite(a) && Number.isFinite(o) : !0))) return t.message ?? `${e.label}与${t.field}类型不匹配`;
209
+ if (["greater-than", "greater-than-or-equal", "less-than", "less-than-or-equal"].includes(t.operator)) {
210
+ const U = (B) => typeof B == "number" && Number.isFinite(B) ? "number" : ae(B) ? "date" : se(B) ? "time" : void 0;
211
+ if (!U(a) || !U(o) || U(a) !== U(o)) return t.message ?? `${e.label}有序比较不合法`;
212
+ }
213
+ return (t.operator === "equals" ? a === o : t.operator === "not-equals" ? a !== o : t.operator === "greater-than" ? a > o : t.operator === "greater-than-or-equal" ? a >= o : t.operator === "less-than" ? a < o : a <= o) ? void 0 : t.message ?? `${e.label}比较不成立`;
214
+ }
215
+ const s = m.get(e.key) ?? new AbortController();
216
+ m.set(e.key, s);
217
+ const n = Object.prototype.hasOwnProperty.call(u.validators, t.validator) && typeof u.validators[t.validator] == "function" ? u.validators[t.validator] : void 0;
218
+ if (!n) return `${e.label}校验器不存在`;
219
+ try {
220
+ const o = n(a, { values: b.value, field: e, signal: s.signal }), f = (y) => {
221
+ if (!s.signal.aborted) {
222
+ if (y === !1) return t.message ?? `${e.label}校验失败`;
223
+ if (typeof y == "string") return y;
224
+ }
225
+ };
226
+ return o && typeof o.then == "function" ? o.then(f) : f(o);
227
+ } catch (o) {
228
+ return s.signal.aborted ? void 0 : o instanceof Error ? o.message : t.message ?? `${e.label}校验失败`;
229
+ }
230
+ }
231
+ }), ke = () => {
232
+ var e, t;
233
+ u.disabled || u.submitting || ($.value = !1, Z(), (t = (e = _.value) == null ? void 0 : e.clearValidate) == null || t.call(e), Object.keys(l).forEach((r) => delete l[r]), ee.value = !1);
234
+ }, oe = (e) => Array.from(/* @__PURE__ */ new Set([...e.dependencies ?? [], ...(e.rules ?? []).filter((t) => t.kind === "compare").map((t) => t.field)])), _e = (e) => {
235
+ if ($.value) {
236
+ $.value = !1;
237
+ return;
238
+ }
239
+ u.disabled || u.submitting || ee.value || w("submit", { ...e });
240
+ }, Oe = (e) => {
241
+ if ($.value) {
242
+ $.value = !1;
243
+ return;
244
+ }
245
+ if (u.disabled || u.submitting) return;
246
+ const t = e.errorFields.map((r) => {
247
+ var o;
248
+ const a = typeof r.name == "string" ? r.name : String(r.name[0]), s = (o = i.value.schema) == null ? void 0 : o.fields.find((f) => f.key === a), n = r.errors[0] || `${(s == null ? void 0 : s.label) ?? a}为必填项`;
249
+ return { key: a, message: n };
250
+ }).filter((r) => C.value.some((a) => a.key === r.key) && !x(i.value.schema.fields.find((a) => a.key === r.key)));
251
+ t.forEach((r) => {
252
+ l[r.key] = r.message;
253
+ }), t.length && (w("validation-error", t), le(() => re(t[0].key)));
254
+ };
255
+ return ie({ validate: () => {
256
+ var e, t;
257
+ return Z(), Promise.resolve(((t = (e = _.value) == null ? void 0 : e.validate) == null ? void 0 : t.call(e)) ?? { errorFields: [] }).then((r) => {
258
+ var a;
259
+ Object.keys(l).forEach((s) => delete l[s]);
260
+ for (const s of r.errorFields ?? []) {
261
+ const n = typeof s.name == "string" ? s.name : String(s.name[0]);
262
+ (a = s.errors) != null && a[0] && (l[n] = s.errors[0]);
263
+ }
264
+ return r;
265
+ });
266
+ }, resetFields: () => {
267
+ var t, r, a, s, n;
268
+ for (const o of m.values()) o.abort();
269
+ m.clear(), P.clear(), g.clear(), E.clear(), O.clear(), A.clear(), de.value += 1, $.value = !0, Object.keys(l).forEach((o) => delete l[o]);
270
+ const e = (((t = i.value.schema) == null ? void 0 : t.fields) ?? []).map((o) => ({ name: o.key, errors: [] }));
271
+ (a = (r = _.value) == null ? void 0 : r.clearValidate) == null || a.call(r), (n = (s = _.value) == null ? void 0 : s.setFieldsErrors) == null || n.call(s, e), Object.keys(l).forEach((o) => delete l[o]), w("update:modelValue", M(G.value));
272
+ }, clearValidate: (e) => {
273
+ var t, r;
274
+ e ? e.forEach((a) => delete l[a]) : Object.keys(l).forEach((a) => delete l[a]), (r = (t = _.value) == null ? void 0 : t.clearValidate) == null || r.call(t, e);
275
+ }, setFieldsErrors: (e) => {
276
+ var t, r;
277
+ e.forEach((a) => {
278
+ a.errors[0] ? l[a.name] = a.errors[0] : delete l[a.name];
279
+ }), (r = (t = _.value) == null ? void 0 : t.setFieldsErrors) == null || r.call(t, e);
280
+ } }), Ve(() => {
281
+ for (const e of m.values()) e.abort();
282
+ }), (e, t) => i.value.valid && i.value.schema ? (c(), Q(X(Ee), {
283
+ key: 0,
284
+ ref_key: "formElement",
285
+ ref: _,
286
+ class: "aheart-ai-form",
287
+ model: N,
288
+ disabled: p.disabled || p.submitting,
289
+ "required-mark": !1,
290
+ layout: "vertical",
291
+ "aria-busy": p.submitting ? "true" : "false",
292
+ onSubmit: ke,
293
+ onFinish: _e,
294
+ onFinishFailed: Oe
295
+ }, {
296
+ default: W(() => [
297
+ i.value.schema.title || i.value.schema.description ? (c(), d("header", Ce, [
298
+ i.value.schema.title ? (c(), d("h2", xe, v(i.value.schema.title), 1)) : V("", !0),
299
+ i.value.schema.description ? (c(), d("p", Me, v(i.value.schema.description), 1)) : V("", !0)
300
+ ])) : V("", !0),
301
+ Y.value.length ? (c(), d("div", Ne, [
302
+ j("strong", null, "请解决 " + v(Y.value.length) + " 个校验问题", 1),
303
+ j("ul", null, [
304
+ (c(!0), d(K, null, I(Y.value, (r) => (c(), d("li", {
305
+ key: r.key
306
+ }, [
307
+ j("button", {
308
+ type: "button",
309
+ onClick: (a) => re(r.key)
310
+ }, v(r.message), 9, Te)
311
+ ]))), 128))
312
+ ])
313
+ ])) : V("", !0),
314
+ (c(!0), d(K, null, I(me.value, (r) => {
315
+ var a;
316
+ return c(), Q(je(r.group ? "fieldset" : "section"), {
317
+ key: r.key,
318
+ class: "aheart-ai-form__group",
319
+ "data-group-key": (a = r.group) == null ? void 0 : a.key
320
+ }, {
321
+ default: W(() => [
322
+ r.group ? (c(), d("legend", Pe, [
323
+ j("span", null, v(r.group.title), 1),
324
+ r.group.description ? (c(), d("small", Ue, v(r.group.description), 1)) : V("", !0)
325
+ ])) : V("", !0),
326
+ (c(!0), d(K, null, I(r.fields, (s) => (c(), Q(X($e), {
327
+ key: pe(s),
328
+ name: s.key,
329
+ rules: ve(s),
330
+ dependencies: oe(s),
331
+ "no-style": ""
332
+ }, {
333
+ default: W(() => [
334
+ ne(Re, {
335
+ ref_for: !0,
336
+ ref: (n) => he(s.key, n),
337
+ field: s,
338
+ value: ye(s),
339
+ disabled: x(s),
340
+ error: l[s.key],
341
+ onUpdate: (n) => be(s.key, n)
342
+ }, null, 8, ["field", "value", "disabled", "error", "onUpdate"])
343
+ ]),
344
+ _: 2
345
+ }, 1032, ["name", "rules", "dependencies"]))), 128))
346
+ ]),
347
+ _: 2
348
+ }, 1032, ["data-group-key"]);
349
+ }), 128)),
350
+ p.submitError ? (c(), d("p", Be, v(p.submitError), 1)) : V("", !0),
351
+ j("footer", De, [
352
+ ne(X(Se), {
353
+ "html-type": "submit",
354
+ type: "primary",
355
+ loading: p.submitting,
356
+ disabled: p.disabled
357
+ }, {
358
+ default: W(() => [
359
+ we(v(p.submitText), 1)
360
+ ]),
361
+ _: 1
362
+ }, 8, ["loading", "disabled"])
363
+ ])
364
+ ]),
365
+ _: 1
366
+ }, 8, ["model", "disabled", "aria-busy"])) : (c(), d("div", We, [
367
+ t[0] || (t[0] = j("strong", null, "表单配置无效", -1)),
368
+ j("ul", null, [
369
+ (c(!0), d(K, null, I(i.value.errors, (r) => (c(), d("li", { key: r }, v(r), 1))), 128))
370
+ ])
371
+ ]));
372
+ }
373
+ });
374
+ export {
375
+ Qe as default
376
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./form.vue.js";
2
+ export {
3
+ f as default
4
+ };
package/es/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import AIChatPanel from './chat-panel.vue';
2
+ import AIActions from './actions.vue';
3
+ import AIAttachments from './attachments.vue';
4
+ import AIBubble from './bubble.vue';
5
+ import AIConversations from './conversations.vue';
6
+ import AIProcess from './process.vue';
7
+ import AIPrompts from './prompts.vue';
8
+ import AISender from './sender.vue';
9
+ import AISources from './sources.vue';
10
+ import AIThoughtChain from './thought-chain.vue';
11
+ import AIWelcome from './welcome.vue';
12
+ import AIForm from './form.vue';
13
+ import AIAgentWorkbench from './agent-workbench.vue';
14
+ export { AIActions, AIAgentWorkbench, AIAttachments, AIBubble, AIChatPanel, AIConversations, AIForm, AIProcess, AIPrompts, AISender, AISources, AIThoughtChain, AIWelcome };
15
+ export * from './types';
16
+ export * from './form-schema';
17
+ export * from './stream-reducer';
18
+ declare const AheartAI: Plugin;
19
+ export default AheartAI;
20
+ import type { Plugin } from 'vue';
package/es/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import m from "./chat-panel.vue.js";
2
+ import n from "./actions.vue.js";
3
+ import t from "./attachments.vue.js";
4
+ import e from "./bubble.vue.js";
5
+ import r from "./conversations.vue.js";
6
+ import A from "./process.vue.js";
7
+ import s from "./prompts.vue.js";
8
+ import c from "./sender.vue.js";
9
+ import a from "./sources.vue.js";
10
+ import i from "./thought-chain.vue.js";
11
+ import I from "./welcome.vue.js";
12
+ import _ from "./form.vue.js";
13
+ import f from "./agent-workbench.vue.js";
14
+ /* empty css */
15
+ import { AI_FORM_CONDITION_OPERATORS as W, AI_FORM_FIELD_TYPES as x, validateAIFormSchema as k } from "./form-schema.js";
16
+ import { createAIStreamReducer as D, reduceAIStreamEvent as M } from "./stream-reducer.js";
17
+ const g = {
18
+ install(o) {
19
+ o.component("AAIActions", n), o.component("AAIAgentWorkbench", f), o.component("AAIAttachments", t), o.component("AAIBubble", e), o.component("AAIChatPanel", m), o.component("AAIConversations", r), o.component("AAIForm", _), o.component("AAIProcess", A), o.component("AAIPrompts", s), o.component("AAISender", c), o.component("AAISources", a), o.component("AAIThoughtChain", i), o.component("AAIWelcome", I);
20
+ }
21
+ };
22
+ export {
23
+ n as AIActions,
24
+ f as AIAgentWorkbench,
25
+ t as AIAttachments,
26
+ e as AIBubble,
27
+ m as AIChatPanel,
28
+ r as AIConversations,
29
+ _ as AIForm,
30
+ A as AIProcess,
31
+ s as AIPrompts,
32
+ c as AISender,
33
+ a as AISources,
34
+ i as AIThoughtChain,
35
+ I as AIWelcome,
36
+ W as AI_FORM_CONDITION_OPERATORS,
37
+ x as AI_FORM_FIELD_TYPES,
38
+ D as createAIStreamReducer,
39
+ g as default,
40
+ M as reduceAIStreamEvent,
41
+ k as validateAIFormSchema
42
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,2 @@
1
+ export { default as AIProcess, default } from '../process.vue';
2
+ export type * from '../types';
@@ -0,0 +1,5 @@
1
+ import { default as f, default as o } from "../process.vue.js";
2
+ export {
3
+ f as AIProcess,
4
+ o as default
5
+ };
@@ -0,0 +1,77 @@
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-process h3 {
14
+ margin: 0;
15
+ }
16
+
17
+ .aheart-ai-process small {
18
+ display: block;
19
+ color: var(--aheart-ai-text-secondary);
20
+ font-size: 12px;
21
+ }
22
+
23
+ .aheart-ai-process {
24
+ display: grid;
25
+ gap: 8px;
26
+ }
27
+
28
+ .aheart-ai-process ol {
29
+ margin: 0;
30
+ padding: 0;
31
+ list-style: none;
32
+ }
33
+
34
+ .aheart-ai-process h3 {
35
+ font-size: 12px;
36
+ color: var(--aheart-ai-text-secondary);
37
+ }
38
+
39
+ .aheart-ai-process ol {
40
+ display: grid;
41
+ gap: 6px;
42
+ }
43
+
44
+ .aheart-ai-process li {
45
+ position: relative;
46
+ display: grid;
47
+ gap: 2px;
48
+ padding-inline-start: 16px;
49
+ }
50
+
51
+ .aheart-ai-process li::before {
52
+ content: "";
53
+ position: absolute;
54
+ inset-block-start: 7px;
55
+ inset-inline-start: 2px;
56
+ inline-size: 6px;
57
+ block-size: 6px;
58
+ border-radius: 50%;
59
+ background: #98a2b3;
60
+ }
61
+
62
+ .aheart-ai-process li.is-running::before {
63
+ background: var(--aheart-ai-cyan);
64
+ box-shadow: 0 0 0 3px #cffafe;
65
+ }
66
+
67
+ .aheart-ai-process li.is-complete::before {
68
+ background: #12b76a;
69
+ }
70
+
71
+ .aheart-ai-process li.is-stopped::before {
72
+ background: #98a2b3;
73
+ }
74
+
75
+ .aheart-ai-process li.is-error {
76
+ color: var(--aheart-color-danger, #d92d20);
77
+ }
@@ -0,0 +1,30 @@
1
+ import type { AIProcessItem } from './types';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ items?: AIProcessItem[] | undefined;
4
+ }>, {
5
+ items: () => never[];
6
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
7
+ items?: AIProcessItem[] | undefined;
8
+ }>, {
9
+ items: () => never[];
10
+ }>>> & Readonly<{}>, {
11
+ items: AIProcessItem[];
12
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ export default _default;
14
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
+ type __VLS_TypePropsToRuntimeProps<T> = {
16
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
17
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
18
+ } : {
19
+ type: import('vue').PropType<T[K]>;
20
+ required: true;
21
+ };
22
+ };
23
+ type __VLS_WithDefaults<P, D> = {
24
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
25
+ default: D[K];
26
+ }> : P[K];
27
+ };
28
+ type __VLS_Prettify<T> = {
29
+ [K in keyof T]: T[K];
30
+ } & {};