@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
package/lib/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/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./chat-panel.vue.js"),_=require("./actions.vue.js"),r=require("./attachments.vue.js"),n=require("./bubble.vue.js"),o=require("./conversations.vue.js"),c=require("./process.vue.js"),s=require("./prompts.vue.js"),a=require("./sender.vue.js"),A=require("./sources.vue.js"),l=require("./thought-chain.vue.js"),i=require("./welcome.vue.js"),I=require("./form.vue.js"),d=require("./agent-workbench.vue.js");;/* empty css */const t=require("./form-schema.js"),m=require("./stream-reducer.js"),v={install(e){e.component("AAIActions",_.default),e.component("AAIAgentWorkbench",d.default),e.component("AAIAttachments",r.default),e.component("AAIBubble",n.default),e.component("AAIChatPanel",u.default),e.component("AAIConversations",o.default),e.component("AAIForm",I.default),e.component("AAIProcess",c.default),e.component("AAIPrompts",s.default),e.component("AAISender",a.default),e.component("AAISources",A.default),e.component("AAIThoughtChain",l.default),e.component("AAIWelcome",i.default)}};exports.AIChatPanel=u.default;exports.AIActions=_.default;exports.AIAttachments=r.default;exports.AIBubble=n.default;exports.AIConversations=o.default;exports.AIProcess=c.default;exports.AIPrompts=s.default;exports.AISender=a.default;exports.AISources=A.default;exports.AIThoughtChain=l.default;exports.AIWelcome=i.default;exports.AIForm=I.default;exports.AIAgentWorkbench=d.default;exports.AI_FORM_CONDITION_OPERATORS=t.AI_FORM_CONDITION_OPERATORS;exports.AI_FORM_FIELD_TYPES=t.AI_FORM_FIELD_TYPES;exports.validateAIFormSchema=t.validateAIFormSchema;exports.createAIStreamReducer=m.createAIStreamReducer;exports.reduceAIStreamEvent=m.reduceAIStreamEvent;exports.default=v;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,2 @@
1
+ export { default as AIProcess, default } from '../process.vue';
2
+ export type * from '../types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../process.vue.js");exports.AIProcess=e.default;exports.default=e.default;
@@ -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
+ } & {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o={key:0,class:"aheart-ai-process","aria-label":"执行进度"},r={key:0},s=e.defineComponent({name:"AAIProcess",__name:"process",props:{items:{default:()=>[]}},setup(l){return(a,n)=>l.items.length?(e.openBlock(),e.createElementBlock("section",o,[n[0]||(n[0]=e.createElementVNode("h3",null,"执行进度",-1)),e.createElementVNode("ol",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.items,t=>(e.openBlock(),e.createElementBlock("li",{key:t.id,class:e.normalizeClass(`is-${t.status}`)},[e.createElementVNode("span",null,e.toDisplayString(t.label),1),t.detail?(e.openBlock(),e.createElementBlock("small",r,e.toDisplayString(t.detail),1)):e.createCommentVNode("",!0)],2))),128))])])):e.createCommentVNode("",!0)}});exports.default=s;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./process.vue.js");exports.default=e.default;
@@ -0,0 +1,2 @@
1
+ export { default as AIPrompts, default } from '../prompts.vue';
2
+ export type * from '../types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../prompts.vue.js");exports.AIPrompts=e.default;exports.default=e.default;
@@ -0,0 +1,76 @@
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-prompts {
14
+ display: grid;
15
+ grid-template-columns: repeat(2, minmax(0, 1fr));
16
+ gap: 8px;
17
+ margin: 0;
18
+ padding: 0;
19
+ list-style: none;
20
+ }
21
+
22
+ .aheart-ai-prompts li {
23
+ margin: 0;
24
+ padding: 0;
25
+ min-inline-size: 0;
26
+ list-style: none !important;
27
+ }
28
+
29
+ .aheart-ai-prompts li::marker {
30
+ content: "";
31
+ }
32
+
33
+ .aheart-ai-prompts button {
34
+ display: grid;
35
+ gap: 4px;
36
+ min-block-size: 64px;
37
+ inline-size: 100%;
38
+ padding: 11px 12px;
39
+ border: 1px solid #d0d5dd;
40
+ border-radius: 6px;
41
+ background: rgba(255, 255, 255, 0.96);
42
+ color: var(--aheart-ai-text);
43
+ font: inherit;
44
+ text-align: left;
45
+ cursor: pointer;
46
+ transition: transform 120ms ease-out, border-color 120ms ease-out, background-color 120ms ease-out;
47
+ }
48
+
49
+ .aheart-ai-prompts button:hover,
50
+ .aheart-ai-prompts button:focus-visible {
51
+ transform: translateY(-2px);
52
+ border-color: #69b1ff;
53
+ background: #f0f7ff;
54
+ outline: none;
55
+ }
56
+
57
+ .aheart-ai-prompts span {
58
+ display: block;
59
+ color: var(--aheart-ai-text-secondary);
60
+ font-size: 12px;
61
+ }
62
+
63
+ @media (max-width: 760px) {
64
+
65
+ .aheart-ai-prompts {
66
+ grid-template-columns: minmax(0, 1fr);
67
+ }
68
+ }
69
+
70
+ @media (prefers-reduced-motion: reduce) {
71
+
72
+ .aheart-ai-prompts button:hover,
73
+ .aheart-ai-prompts button:focus-visible {
74
+ transform: none;
75
+ }
76
+ }
@@ -0,0 +1,39 @@
1
+ import type { AIPrompt } from './types';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ prompts?: AIPrompt[] | undefined;
4
+ disabled?: boolean | undefined;
5
+ }>, {
6
+ prompts: () => never[];
7
+ disabled: boolean;
8
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ select: (prompt: AIPrompt) => void;
10
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
11
+ prompts?: AIPrompt[] | undefined;
12
+ disabled?: boolean | undefined;
13
+ }>, {
14
+ prompts: () => never[];
15
+ disabled: boolean;
16
+ }>>> & Readonly<{
17
+ onSelect?: ((prompt: AIPrompt) => any) | undefined;
18
+ }>, {
19
+ disabled: boolean;
20
+ prompts: AIPrompt[];
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 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s={class:"aheart-ai-prompts","aria-label":"建议任务"},a=["disabled","onClick"],c={key:0},r=e.defineComponent({name:"AAIPrompts",__name:"prompts",props:{prompts:{default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["select"],setup(l,{emit:n}){const o=n;return(i,d)=>(e.openBlock(),e.createElementBlock("ul",s,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.prompts,t=>(e.openBlock(),e.createElementBlock("li",{key:t.key},[e.createElementVNode("button",{type:"button",disabled:l.disabled,onClick:u=>o("select",t)},[e.createElementVNode("strong",null,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",c,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)],8,a)]))),128))]))}});exports.default=r;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./prompts.vue.js");exports.default=e.default;
@@ -0,0 +1,3 @@
1
+ import { type VNodeChild } from 'vue';
2
+ export declare const getSafeUrl: (value?: string) => string | undefined;
3
+ export declare const renderSafeMarkdown: (value: string) => VNodeChild[];
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),c=t=>t&&/^(https?:|mailto:)/i.test(t)?t:void 0,h=/(\*\*([^*]+)\*\*|\*([^*]+)\*|\[([^\]]+)\]\(([^)]+)\))/g,l=t=>{const n=[];let r=0;for(const e of t.matchAll(h)){const o=e.index??0;if(o>r&&n.push(t.slice(r,o)),e[2])n.push(s.h("strong",e[2]));else if(e[3])n.push(s.h("em",e[3]));else{const i=c(e[5]);n.push(i?s.h("a",{href:i,target:"_blank",rel:"noreferrer"},e[4]):e[4])}r=o+e[0].length}return r<t.length&&n.push(t.slice(r)),n},f=t=>t.split(`
2
+ `).flatMap((r,e)=>e===0?l(r):[s.h("br"),...l(r)]);exports.getSafeUrl=c;exports.renderSafeMarkdown=f;
@@ -0,0 +1,2 @@
1
+ export { default as AISender, default } from '../sender.vue';
2
+ export type * from '../types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../sender.vue.js");exports.AISender=e.default;exports.default=e.default;
@@ -0,0 +1,88 @@
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-sender {
14
+ display: grid;
15
+ grid-template-columns: minmax(0, 1fr) auto;
16
+ align-items: end;
17
+ gap: 8px;
18
+ padding: 6px;
19
+ border: 1px solid #b9c2cf;
20
+ border-radius: 7px;
21
+ background: #fff;
22
+ box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
23
+ transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
24
+ }
25
+
26
+ .aheart-ai-sender:focus-within {
27
+ border-color: var(--aheart-color-primary, #1677ff);
28
+ box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
29
+ }
30
+
31
+ .aheart-ai-sender textarea {
32
+ inline-size: 100%;
33
+ min-block-size: 56px;
34
+ max-block-size: 160px;
35
+ resize: vertical;
36
+ padding: 8px;
37
+ border: 0;
38
+ background: transparent;
39
+ color: var(--aheart-ai-text);
40
+ font: inherit;
41
+ line-height: 1.55;
42
+ outline: none;
43
+ }
44
+
45
+ .aheart-ai-sender button {
46
+ min-inline-size: 72px;
47
+ min-block-size: 36px;
48
+ padding: 7px 14px;
49
+ border: 1px solid var(--aheart-color-primary, #1677ff);
50
+ border-radius: 5px;
51
+ background: var(--aheart-color-primary, #1677ff);
52
+ color: #fff;
53
+ font: 500 14px/1 inherit;
54
+ cursor: pointer;
55
+ transition: background-color 120ms ease-out, border-color 120ms ease-out;
56
+ }
57
+
58
+ .aheart-ai-sender button:hover:not(:disabled),
59
+ .aheart-ai-sender button:focus-visible {
60
+ border-color: #0958d9;
61
+ background: #0958d9;
62
+ outline: none;
63
+ }
64
+
65
+ .aheart-ai-sender button:disabled {
66
+ border-color: #d0d5dd;
67
+ background: #eaecf0;
68
+ color: #98a2b3;
69
+ cursor: not-allowed;
70
+ }
71
+
72
+ @media (max-width: 760px) {
73
+
74
+ .aheart-ai-sender {
75
+ grid-template-columns: minmax(0, 1fr);
76
+ }
77
+
78
+ .aheart-ai-sender button {
79
+ inline-size: 100%;
80
+ }
81
+ }
82
+
83
+ @media (pointer: coarse) {
84
+ .aheart-ai-sender button {
85
+ min-block-size: 44px;
86
+ min-inline-size: 44px;
87
+ }
88
+ }
@@ -0,0 +1,52 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
+ modelValue?: string | undefined;
3
+ placeholder?: string | undefined;
4
+ disabled?: boolean | undefined;
5
+ loading?: boolean | undefined;
6
+ }>, {
7
+ modelValue: string;
8
+ placeholder: string;
9
+ disabled: boolean;
10
+ loading: boolean;
11
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ submit: (content: string) => void;
13
+ stop: () => void;
14
+ "update:modelValue": (value: string) => void;
15
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
16
+ modelValue?: string | undefined;
17
+ placeholder?: string | undefined;
18
+ disabled?: boolean | undefined;
19
+ loading?: boolean | undefined;
20
+ }>, {
21
+ modelValue: string;
22
+ placeholder: string;
23
+ disabled: boolean;
24
+ loading: boolean;
25
+ }>>> & Readonly<{
26
+ onSubmit?: ((content: string) => any) | undefined;
27
+ onStop?: (() => any) | undefined;
28
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
29
+ }>, {
30
+ disabled: boolean;
31
+ loading: boolean;
32
+ placeholder: string;
33
+ modelValue: string;
34
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
35
+ export default _default;
36
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
37
+ type __VLS_TypePropsToRuntimeProps<T> = {
38
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
39
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
40
+ } : {
41
+ type: import('vue').PropType<T[K]>;
42
+ required: true;
43
+ };
44
+ };
45
+ type __VLS_WithDefaults<P, D> = {
46
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
47
+ default: D[K];
48
+ }> : P[K];
49
+ };
50
+ type __VLS_Prettify<T> = {
51
+ [K in keyof T]: T[K];
52
+ } & {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=["value","placeholder","disabled","onKeydown"],r=["disabled"],m=e.defineComponent({name:"AAISender",__name:"sender",props:{modelValue:{default:""},placeholder:{default:"输入消息"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["update:modelValue","submit","stop"],setup(t,{emit:u}){const a=t,o=u,n=()=>{const d=a.modelValue.trim();d&&!a.disabled&&!a.loading&&o("submit",d)};return(d,l)=>(e.openBlock(),e.createElementBlock("form",{class:"aheart-ai-sender",onSubmit:e.withModifiers(n,["prevent"])},[e.createElementVNode("textarea",{value:t.modelValue,"aria-label":"消息内容",placeholder:t.placeholder,disabled:t.disabled||t.loading,onInput:l[0]||(l[0]=i=>o("update:modelValue",i.target.value)),onKeydown:e.withKeys(e.withModifiers(n,["exact","prevent"]),["enter"])},null,40,s),t.loading?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button","aria-label":"停止生成",onClick:l[1]||(l[1]=i=>o("stop"))},"停止")):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit","aria-label":"发送消息",disabled:t.disabled||!t.modelValue.trim(),onClick:e.withModifiers(n,["prevent"])},"发送",8,r))],32))}});exports.default=m;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./sender.vue.js");exports.default=e.default;
@@ -0,0 +1,2 @@
1
+ export { default as AISources, default } from '../sources.vue';
2
+ export type * from '../types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../sources.vue.js");exports.AISources=e.default;exports.default=e.default;
@@ -0,0 +1,54 @@
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-sources h3,
14
+ .aheart-ai-sources p {
15
+ margin: 0;
16
+ }
17
+
18
+ .aheart-ai-sources {
19
+ display: grid;
20
+ gap: 8px;
21
+ }
22
+
23
+ .aheart-ai-sources ul {
24
+ margin: 0;
25
+ padding: 0;
26
+ list-style: none;
27
+ }
28
+
29
+ .aheart-ai-sources li {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+ gap: 8px;
34
+ min-block-size: 34px;
35
+ padding: 6px 8px;
36
+ border: 1px solid var(--aheart-ai-line);
37
+ border-radius: 5px;
38
+ background: var(--aheart-ai-surface-subtle);
39
+ font-size: 12px;
40
+ }
41
+
42
+ .aheart-ai-sources {
43
+ padding-block-start: 8px;
44
+ border-block-start: 1px solid var(--aheart-ai-line);
45
+ }
46
+
47
+ .aheart-ai-sources a {
48
+ color: var(--aheart-ai-brand-strong);
49
+ }
50
+
51
+ .aheart-ai-sources h3 {
52
+ font-size: 12px;
53
+ color: var(--aheart-ai-text-secondary);
54
+ }
@@ -0,0 +1,30 @@
1
+ import type { AISource } from './types';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ sources?: AISource[] | undefined;
4
+ }>, {
5
+ sources: () => never[];
6
+ }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
7
+ sources?: AISource[] | undefined;
8
+ }>, {
9
+ sources: () => never[];
10
+ }>>> & Readonly<{}>, {
11
+ sources: AISource[];
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
+ } & {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("./safe-markdown.js"),o={key:0,class:"aheart-ai-sources","aria-label":"参考来源"},a=["href"],c={key:1},s={key:2},i=e.defineComponent({name:"AAISources",__name:"sources",props:{sources:{default:()=>[]}},setup(r){return(u,n)=>r.sources.length?(e.openBlock(),e.createElementBlock("section",o,[n[0]||(n[0]=e.createElementVNode("h3",null,"参考来源",-1)),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.sources,t=>(e.openBlock(),e.createElementBlock("li",{key:t.id},[e.unref(l.getSafeUrl)(t.url)?(e.openBlock(),e.createElementBlock("a",{key:0,href:e.unref(l.getSafeUrl)(t.url),target:"_blank",rel:"noreferrer"},e.toDisplayString(t.title),9,a)):(e.openBlock(),e.createElementBlock("span",c,e.toDisplayString(t.title),1)),t.description?(e.openBlock(),e.createElementBlock("p",s,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)]))),128))])])):e.createCommentVNode("",!0)}});exports.default=i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./sources.vue.js");exports.default=e.default;
@@ -0,0 +1,35 @@
1
+ import type { AIMessage, AIStreamEventV2 } from './types';
2
+ export type AIStreamDiagnosticKind = 'accepted' | 'duplicate' | 'buffered' | 'stale' | 'gap' | 'protocol-error' | 'terminal-no-op';
3
+ export interface AIStreamReducerState {
4
+ requestId: string;
5
+ messageId: string;
6
+ cursor: {
7
+ afterSequence: number;
8
+ revision: number;
9
+ };
10
+ message: AIMessage;
11
+ status: 'idle' | 'streaming' | 'reconnecting' | 'completed' | 'cancelled' | 'error';
12
+ recoveryRequired: boolean;
13
+ diagnostic: {
14
+ kind: AIStreamDiagnosticKind;
15
+ sequence?: number;
16
+ reason?: string;
17
+ };
18
+ }
19
+ export interface AIStreamReducerOptions {
20
+ requestId: string;
21
+ messageId: string;
22
+ maxReconnectAttempts?: number;
23
+ initialMessage?: AIMessage;
24
+ }
25
+ export interface AIStreamReducer {
26
+ dispatch(event: AIStreamEventV2): AIStreamReducerState;
27
+ reduce(event: AIStreamEventV2): AIStreamReducerState;
28
+ recover(options?: {
29
+ reason?: string;
30
+ }): AIStreamReducerState;
31
+ failRecovery(reason?: string, retryable?: boolean): AIStreamReducerState;
32
+ getState(): AIStreamReducerState;
33
+ }
34
+ export declare const createAIStreamReducer: (options: AIStreamReducerOptions) => AIStreamReducer;
35
+ export declare const reduceAIStreamEvent: (state: AIStreamReducer, event: AIStreamEventV2) => AIStreamReducerState;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=s=>typeof s=="number"&&Number.isSafeInteger(s),l=s=>Array.isArray(s)?s.map(l):s&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,c])=>[o,l(c)])):s,f=s=>s===void 0?"undefined":s===null||typeof s!="object"?JSON.stringify(s):Array.isArray(s)?`[${s.map(f).join(",")}]`:`{${Object.keys(s).sort().map(o=>`${JSON.stringify(o)}:${f(s[o])}`).join(",")}}`,M=s=>{if(!s||typeof s!="object")return;const o=s;if(typeof o.id!="string"||typeof o.name!="string"||typeof o.summary!="string")return;const c={id:o.id,name:o.name,summary:o.summary};for(const r of["inputStatus","inputSummary","resultStatus","resultSummary","error"])typeof o[r]=="string"&&(c[r]=o[r]);return c},R=(s,o)=>{if(!s||typeof s!="object")return;const c=s;if(c.id!==o||c.role!=="assistant"||typeof c.content!="string")return;const r={id:o,role:"assistant",content:c.content};if((c.status==="streaming"||c.status==="complete")&&(r.status=c.status),typeof c.error=="string"&&(r.error=c.error),Array.isArray(c.process)&&(r.process=l(c.process)),Array.isArray(c.sources)&&(r.sources=l(c.sources)),c.toolCall!==void 0){const i=M(c.toolCall);i&&(r.toolCall=i)}return r},O=s=>{const o=S(s.maxReconnectAttempts)?Math.max(0,s.maxReconnectAttempts):1,c=s.initialMessage??{id:s.messageId,role:"assistant",content:"",status:"streaming"};let r={requestId:s.requestId,messageId:s.messageId,cursor:{afterSequence:0,revision:0},message:l(c),status:"idle",recoveryRequired:!1,diagnostic:{kind:"accepted"}};const i=new Map,p=new Map;let b=0;const g=new Map,t=(e,a,n)=>(r={...r,diagnostic:{kind:e,...a===void 0?{}:{sequence:a},...n?{reason:n}:{}}},l(r)),m=(e,a)=>{for(p.delete(e),p.set(e,a);p.size>64;)p.delete(p.keys().next().value)},j=e=>!(!e||typeof e!="object"||e.version!=="2"||typeof e.requestId!="string"||!e.requestId||typeof e.messageId!="string"||!e.messageId||e.requestId!==s.requestId||e.messageId!==s.messageId||!S(e.sequence)||e.sequence<1||!S(e.revision)||e.revision<0||!["text-delta","process-upsert","sources-replace","snapshot","final","cancelled","error"].includes(e.type)||e.type==="text-delta"&&typeof e.delta!="string"||e.type==="process-upsert"&&(!e.item||typeof e.item.id!="string")||e.type==="sources-replace"&&!Array.isArray(e.sources)||(e.type==="snapshot"||e.type==="final")&&!R(e.message,s.messageId)||e.type==="cancelled"&&e.reason!==void 0&&typeof e.reason!="string"||e.type==="error"&&typeof e.error!="string"),y=e=>{if(e.revision>r.cursor.revision){r={...r,recoveryRequired:!0};return}r={...r,cursor:{afterSequence:e.sequence,revision:r.cursor.revision},status:"streaming",recoveryRequired:!1},!(e.revision<r.cursor.revision)&&(e.type==="text-delta"?r.message={...r.message,content:r.message.content+e.delta,status:"streaming"}:e.type==="process-upsert"?r.message={...r.message,process:[...(r.message.process??[]).filter(a=>a.id!==e.item.id),l(e.item)]}:e.type==="sources-replace"?r.message={...r.message,sources:l(e.sources)}:e.type==="cancelled"?(r.status="cancelled",g.set(e.sequence,f(e)),r.message={...r.message,status:"stopped",error:e.reason}):e.type==="error"&&(r.status="error",g.set(e.sequence,f(e)),r.message={...r.message,status:"error",error:e.error,retryable:e.retryable}))},x=(e,a)=>{const n=R(e.message,s.messageId);if(!n)return t("protocol-error",e.sequence,"invalid checkpoint");if(e.revision<r.cursor.revision||e.sequence<r.cursor.afterSequence)return t("stale",e.sequence);const q=r.message.attachments?{attachments:r.message.attachments}:{},{id:u,role:h,content:k,...w}=n;for(r={...r,message:{id:r.message.id,role:"assistant",content:k,...q,...w,status:e.type==="final"?"complete":"streaming"},cursor:{afterSequence:e.sequence,revision:e.revision},recoveryRequired:!1,status:e.type==="final"?"completed":"streaming"},i.forEach((d,A)=>{A<=e.sequence&&i.delete(A)}),e.type==="final"&&g.set(e.sequence,a);i.has(r.cursor.afterSequence+1);){const d=i.get(r.cursor.afterSequence+1);if(r.status==="completed"||r.status==="cancelled"||r.status==="error"||d.revision>r.cursor.revision)break;i.delete(d.sequence),m(d.sequence,f(d)),y(d)}return t("accepted",e.sequence)},I=e=>{const a=f(e);if(!j(e))return t("protocol-error",e==null?void 0:e.sequence,"invalid envelope");const n=g.get(e.sequence);if(n)return n===a?t("duplicate",e.sequence):t("protocol-error",e.sequence,"conflicting terminal");if(r.status==="completed"||r.status==="cancelled"||r.status==="error")return t("terminal-no-op",e.sequence);const q=p.get(e.sequence);if(q)return q===a?t("duplicate",e.sequence):t("protocol-error",e.sequence,"conflicting sequence");if(e.type==="snapshot"||e.type==="final")return e.revision<r.cursor.revision||e.sequence<r.cursor.afterSequence?(m(e.sequence,a),t("stale",e.sequence)):(m(e.sequence,a),x(e,a));if(e.sequence<=r.cursor.afterSequence)return p.has(e.sequence),t("stale",e.sequence);if(e.sequence>r.cursor.afterSequence+1){const u=i.get(e.sequence);return u?f(u)===a?t("duplicate",e.sequence):t("protocol-error",e.sequence,"conflicting buffered sequence"):e.sequence-r.cursor.afterSequence>32||i.size>=32?(r={...r,recoveryRequired:!0},t("gap",e.sequence)):(i.set(e.sequence,e),t("buffered",e.sequence))}if(e.revision>r.cursor.revision)return r={...r,recoveryRequired:!0},t("protocol-error",e.sequence,"revision checkpoint required");for(m(e.sequence,a),y(e);i.has(r.cursor.afterSequence+1);){const u=i.get(r.cursor.afterSequence+1);if(r.status==="completed"||r.status==="cancelled"||r.status==="error"||u.revision>r.cursor.revision)break;i.delete(u.sequence);const h=f(u);if(m(u.sequence,h),y(u),r.status==="error"||r.status==="cancelled")break}return t("accepted",e.sequence)};return{dispatch:I,reduce:I,recover:({reason:e="transport"}={})=>r.status==="completed"||r.status==="cancelled"||r.status==="error"?t("terminal-no-op",r.cursor.afterSequence):b<o?(b+=1,r={...r,status:"reconnecting",recoveryRequired:!0},t("gap",r.cursor.afterSequence,e)):(r={...r,status:"error",message:{...r.message,status:"error",error:"连接中断,请重试",retryable:!0},recoveryRequired:!1},t("gap",r.cursor.afterSequence,e)),failRecovery:(e="transport",a=!0)=>r.status==="completed"||r.status==="cancelled"||r.status==="error"?t("terminal-no-op",r.cursor.afterSequence):(r={...r,status:"error",message:{...r.message,status:"error",error:e,retryable:a},recoveryRequired:!1},t("gap",r.cursor.afterSequence,e)),getState:()=>r}},E=(s,o)=>s.dispatch(o);exports.createAIStreamReducer=O;exports.reduceAIStreamEvent=E;