@aheart-ui/ai 0.0.0-stage → 1.0.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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -2
  3. package/es/actions.vue.d.ts +34 -0
  4. package/es/actions.vue.js +27 -0
  5. package/es/actions.vue2.js +4 -0
  6. package/es/agent-execution.vue.d.ts +106 -0
  7. package/es/agent-execution.vue.js +441 -0
  8. package/es/agent-execution.vue2.js +4 -0
  9. package/es/agent-workbench.vue.d.ts +186 -0
  10. package/es/agent-workbench.vue.js +537 -0
  11. package/es/agent-workbench.vue2.js +4 -0
  12. package/es/attachments.vue.d.ts +39 -0
  13. package/es/attachments.vue.js +39 -0
  14. package/es/attachments.vue2.js +4 -0
  15. package/es/bubble.vue.d.ts +27 -0
  16. package/es/bubble.vue.js +82 -0
  17. package/es/bubble.vue2.js +4 -0
  18. package/es/chat-panel.vue.d.ts +108 -0
  19. package/es/chat-panel.vue.js +330 -0
  20. package/es/chat-panel.vue2.js +4 -0
  21. package/es/conversations.vue.d.ts +39 -0
  22. package/es/conversations.vue.js +29 -0
  23. package/es/conversations.vue2.js +4 -0
  24. package/es/form-field.vue.d.ts +28 -0
  25. package/es/form-field.vue.js +176 -0
  26. package/es/form-field.vue2.js +4 -0
  27. package/es/form-schema.d.ts +73 -0
  28. package/es/form-schema.js +105 -0
  29. package/es/form.vue.d.ts +81 -0
  30. package/es/form.vue.js +376 -0
  31. package/es/form.vue2.js +4 -0
  32. package/es/index.d.ts +20 -0
  33. package/es/index.js +42 -0
  34. package/es/package.json +3 -0
  35. package/es/process.vue.d.ts +30 -0
  36. package/es/process.vue.js +29 -0
  37. package/es/process.vue2.js +4 -0
  38. package/es/prompts.vue.d.ts +39 -0
  39. package/es/prompts.vue.js +33 -0
  40. package/es/prompts.vue2.js +4 -0
  41. package/es/safe-markdown.d.ts +3 -0
  42. package/es/safe-markdown.js +23 -0
  43. package/es/sender.vue.d.ts +52 -0
  44. package/es/sender.vue.js +46 -0
  45. package/es/sender.vue2.js +4 -0
  46. package/es/sources.vue.d.ts +30 -0
  47. package/es/sources.vue.js +34 -0
  48. package/es/sources.vue2.js +4 -0
  49. package/es/stream-reducer.d.ts +35 -0
  50. package/es/stream-reducer.js +85 -0
  51. package/es/style.css +1586 -0
  52. package/es/thought-chain.vue.d.ts +30 -0
  53. package/es/thought-chain.vue.js +15 -0
  54. package/es/thought-chain.vue2.js +4 -0
  55. package/es/types.d.ts +203 -0
  56. package/es/welcome.vue.d.ts +41 -0
  57. package/es/welcome.vue.js +27 -0
  58. package/es/welcome.vue2.js +4 -0
  59. package/lib/actions.vue.d.ts +34 -0
  60. package/lib/actions.vue.js +1 -0
  61. package/lib/actions.vue2.js +1 -0
  62. package/lib/agent-execution.vue.d.ts +106 -0
  63. package/lib/agent-execution.vue.js +1 -0
  64. package/lib/agent-execution.vue2.js +1 -0
  65. package/lib/agent-workbench.vue.d.ts +186 -0
  66. package/lib/agent-workbench.vue.js +1 -0
  67. package/lib/agent-workbench.vue2.js +1 -0
  68. package/lib/attachments.vue.d.ts +39 -0
  69. package/lib/attachments.vue.js +1 -0
  70. package/lib/attachments.vue2.js +1 -0
  71. package/lib/bubble.vue.d.ts +27 -0
  72. package/lib/bubble.vue.js +1 -0
  73. package/lib/bubble.vue2.js +1 -0
  74. package/lib/chat-panel.vue.d.ts +108 -0
  75. package/lib/chat-panel.vue.js +1 -0
  76. package/lib/chat-panel.vue2.js +1 -0
  77. package/lib/conversations.vue.d.ts +39 -0
  78. package/lib/conversations.vue.js +1 -0
  79. package/lib/conversations.vue2.js +1 -0
  80. package/lib/form-field.vue.d.ts +28 -0
  81. package/lib/form-field.vue.js +1 -0
  82. package/lib/form-field.vue2.js +1 -0
  83. package/lib/form-schema.d.ts +73 -0
  84. package/lib/form-schema.js +1 -0
  85. package/lib/form.vue.d.ts +81 -0
  86. package/lib/form.vue.js +1 -0
  87. package/lib/form.vue2.js +1 -0
  88. package/lib/index.d.ts +20 -0
  89. package/lib/index.js +1 -0
  90. package/lib/package.json +3 -0
  91. package/lib/process.vue.d.ts +30 -0
  92. package/lib/process.vue.js +1 -0
  93. package/lib/process.vue2.js +1 -0
  94. package/lib/prompts.vue.d.ts +39 -0
  95. package/lib/prompts.vue.js +1 -0
  96. package/lib/prompts.vue2.js +1 -0
  97. package/lib/safe-markdown.d.ts +3 -0
  98. package/lib/safe-markdown.js +2 -0
  99. package/lib/sender.vue.d.ts +52 -0
  100. package/lib/sender.vue.js +1 -0
  101. package/lib/sender.vue2.js +1 -0
  102. package/lib/sources.vue.d.ts +30 -0
  103. package/lib/sources.vue.js +1 -0
  104. package/lib/sources.vue2.js +1 -0
  105. package/lib/stream-reducer.d.ts +35 -0
  106. package/lib/stream-reducer.js +1 -0
  107. package/lib/style.css +1586 -0
  108. package/lib/thought-chain.vue.d.ts +30 -0
  109. package/lib/thought-chain.vue.js +1 -0
  110. package/lib/thought-chain.vue2.js +1 -0
  111. package/lib/types.d.ts +203 -0
  112. package/lib/welcome.vue.d.ts +41 -0
  113. package/lib/welcome.vue.js +1 -0
  114. package/lib/welcome.vue2.js +1 -0
  115. package/package.json +70 -3
@@ -0,0 +1,52 @@
1
+ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").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/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
12
+ submit: (content: string) => void;
13
+ stop: () => void;
14
+ "update:modelValue": (value: string) => void;
15
+ }, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").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/runtime-core").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,46 @@
1
+ import { defineComponent as r, openBlock as o, createElementBlock as i, withModifiers as s, createElementVNode as b, withKeys as c } from "vue";
2
+ const f = ["value", "placeholder", "disabled", "onKeydown"], p = ["disabled"], v = /* @__PURE__ */ r({
3
+ name: "AAISender",
4
+ __name: "sender",
5
+ props: {
6
+ modelValue: { default: "" },
7
+ placeholder: { default: "输入消息" },
8
+ disabled: { type: Boolean, default: !1 },
9
+ loading: { type: Boolean, default: !1 }
10
+ },
11
+ emits: ["update:modelValue", "submit", "stop"],
12
+ setup(e, { emit: m }) {
13
+ const l = e, a = m, d = () => {
14
+ const n = l.modelValue.trim();
15
+ n && !l.disabled && !l.loading && a("submit", n);
16
+ };
17
+ return (n, t) => (o(), i("form", {
18
+ class: "aheart-ai-sender",
19
+ onSubmit: s(d, ["prevent"])
20
+ }, [
21
+ b("textarea", {
22
+ value: e.modelValue,
23
+ "aria-label": "消息内容",
24
+ placeholder: e.placeholder,
25
+ disabled: e.disabled || e.loading,
26
+ onInput: t[0] || (t[0] = (u) => a("update:modelValue", u.target.value)),
27
+ onKeydown: c(s(d, ["exact", "prevent"]), ["enter"])
28
+ }, null, 40, f),
29
+ e.loading ? (o(), i("button", {
30
+ key: 0,
31
+ type: "button",
32
+ "aria-label": "停止生成",
33
+ onClick: t[1] || (t[1] = (u) => a("stop"))
34
+ }, "停止")) : (o(), i("button", {
35
+ key: 1,
36
+ type: "submit",
37
+ "aria-label": "发送消息",
38
+ disabled: e.disabled || !e.modelValue.trim(),
39
+ onClick: s(d, ["prevent"])
40
+ }, "发送", 8, p))
41
+ ], 32));
42
+ }
43
+ });
44
+ export {
45
+ v as default
46
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./sender.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,30 @@
1
+ import type { AISource } from './types';
2
+ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ sources?: AISource[] | undefined;
4
+ }>, {
5
+ sources: () => never[];
6
+ }>>, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
7
+ sources?: AISource[] | undefined;
8
+ }>, {
9
+ sources: () => never[];
10
+ }>>> & Readonly<{}>, {
11
+ sources: AISource[];
12
+ }, {}, {}, {}, string, import("@vue/runtime-core").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,34 @@
1
+ import { defineComponent as c, openBlock as t, createElementBlock as r, createElementVNode as s, Fragment as d, renderList as m, unref as a, toDisplayString as n, createCommentVNode as i } from "vue";
2
+ import { getSafeUrl as u } from "./safe-markdown.js";
3
+ const f = {
4
+ key: 0,
5
+ class: "aheart-ai-sources",
6
+ "aria-label": "参考来源"
7
+ }, p = ["href"], _ = { key: 1 }, h = { key: 2 }, S = /* @__PURE__ */ c({
8
+ name: "AAISources",
9
+ __name: "sources",
10
+ props: {
11
+ sources: { default: () => [] }
12
+ },
13
+ setup(o) {
14
+ return (k, l) => o.sources.length ? (t(), r("section", f, [
15
+ l[0] || (l[0] = s("h3", null, "参考来源", -1)),
16
+ s("ul", null, [
17
+ (t(!0), r(d, null, m(o.sources, (e) => (t(), r("li", {
18
+ key: e.id
19
+ }, [
20
+ a(u)(e.url) ? (t(), r("a", {
21
+ key: 0,
22
+ href: a(u)(e.url),
23
+ target: "_blank",
24
+ rel: "noreferrer"
25
+ }, n(e.title), 9, p)) : (t(), r("span", _, n(e.title), 1)),
26
+ e.description ? (t(), r("p", h, n(e.description), 1)) : i("", !0)
27
+ ]))), 128))
28
+ ])
29
+ ])) : i("", !0);
30
+ }
31
+ });
32
+ export {
33
+ S as default
34
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./sources.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -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,85 @@
1
+ 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) => {
2
+ if (!s || typeof s != "object") return;
3
+ const o = s;
4
+ if (typeof o.id != "string" || typeof o.name != "string" || typeof o.summary != "string") return;
5
+ const c = { id: o.id, name: o.name, summary: o.summary };
6
+ for (const r of ["inputStatus", "inputSummary", "resultStatus", "resultSummary", "error"])
7
+ typeof o[r] == "string" && (c[r] = o[r]);
8
+ return c;
9
+ }, R = (s, o) => {
10
+ if (!s || typeof s != "object") return;
11
+ const c = s;
12
+ if (c.id !== o || c.role !== "assistant" || typeof c.content != "string") return;
13
+ const r = { id: o, role: "assistant", content: c.content };
14
+ 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) {
15
+ const a = M(c.toolCall);
16
+ a && (r.toolCall = a);
17
+ }
18
+ return r;
19
+ }, E = (s) => {
20
+ const o = S(s.maxReconnectAttempts) ? Math.max(0, s.maxReconnectAttempts) : 1, c = s.initialMessage ?? { id: s.messageId, role: "assistant", content: "", status: "streaming" };
21
+ let r = {
22
+ requestId: s.requestId,
23
+ messageId: s.messageId,
24
+ cursor: { afterSequence: 0, revision: 0 },
25
+ message: l(c),
26
+ status: "idle",
27
+ recoveryRequired: !1,
28
+ diagnostic: { kind: "accepted" }
29
+ };
30
+ const a = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
31
+ let b = 0;
32
+ const g = /* @__PURE__ */ new Map(), t = (e, i, n) => (r = { ...r, diagnostic: { kind: e, ...i === void 0 ? {} : { sequence: i }, ...n ? { reason: n } : {} } }, l(r)), m = (e, i) => {
33
+ for (p.delete(e), p.set(e, i); p.size > 64; ) p.delete(p.keys().next().value);
34
+ }, 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) => {
35
+ if (e.revision > r.cursor.revision) {
36
+ r = { ...r, recoveryRequired: !0 };
37
+ return;
38
+ }
39
+ 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((i) => i.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 }));
40
+ }, x = (e, i) => {
41
+ const n = R(e.message, s.messageId);
42
+ if (!n) return t("protocol-error", e.sequence, "invalid checkpoint");
43
+ if (e.revision < r.cursor.revision || e.sequence < r.cursor.afterSequence) return t("stale", e.sequence);
44
+ const q = r.message.attachments ? { attachments: r.message.attachments } : {}, { id: u, role: h, content: k, ...w } = n;
45
+ 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" }, a.forEach((d, A) => {
46
+ A <= e.sequence && a.delete(A);
47
+ }), e.type === "final" && g.set(e.sequence, i); a.has(r.cursor.afterSequence + 1); ) {
48
+ const d = a.get(r.cursor.afterSequence + 1);
49
+ if (r.status === "completed" || r.status === "cancelled" || r.status === "error" || d.revision > r.cursor.revision) break;
50
+ a.delete(d.sequence), m(d.sequence, f(d)), y(d);
51
+ }
52
+ return t("accepted", e.sequence);
53
+ }, I = (e) => {
54
+ const i = f(e);
55
+ if (!j(e)) return t("protocol-error", e == null ? void 0 : e.sequence, "invalid envelope");
56
+ const n = g.get(e.sequence);
57
+ if (n) return n === i ? t("duplicate", e.sequence) : t("protocol-error", e.sequence, "conflicting terminal");
58
+ if (r.status === "completed" || r.status === "cancelled" || r.status === "error") return t("terminal-no-op", e.sequence);
59
+ const q = p.get(e.sequence);
60
+ if (q) return q === i ? t("duplicate", e.sequence) : t("protocol-error", e.sequence, "conflicting sequence");
61
+ if (e.type === "snapshot" || e.type === "final")
62
+ return e.revision < r.cursor.revision || e.sequence < r.cursor.afterSequence ? (m(e.sequence, i), t("stale", e.sequence)) : (m(e.sequence, i), x(e, i));
63
+ if (e.sequence <= r.cursor.afterSequence)
64
+ return p.has(e.sequence), t("stale", e.sequence);
65
+ if (e.sequence > r.cursor.afterSequence + 1) {
66
+ const u = a.get(e.sequence);
67
+ return u ? f(u) === i ? t("duplicate", e.sequence) : t("protocol-error", e.sequence, "conflicting buffered sequence") : e.sequence - r.cursor.afterSequence > 32 || a.size >= 32 ? (r = { ...r, recoveryRequired: !0 }, t("gap", e.sequence)) : (a.set(e.sequence, e), t("buffered", e.sequence));
68
+ }
69
+ if (e.revision > r.cursor.revision)
70
+ return r = { ...r, recoveryRequired: !0 }, t("protocol-error", e.sequence, "revision checkpoint required");
71
+ for (m(e.sequence, i), y(e); a.has(r.cursor.afterSequence + 1); ) {
72
+ const u = a.get(r.cursor.afterSequence + 1);
73
+ if (r.status === "completed" || r.status === "cancelled" || r.status === "error" || u.revision > r.cursor.revision) break;
74
+ a.delete(u.sequence);
75
+ const h = f(u);
76
+ if (m(u.sequence, h), y(u), r.status === "error" || r.status === "cancelled") break;
77
+ }
78
+ return t("accepted", e.sequence);
79
+ };
80
+ 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", i = !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: i }, recoveryRequired: !1 }, t("gap", r.cursor.afterSequence, e)), getState: () => r };
81
+ }, $ = (s, o) => s.dispatch(o);
82
+ export {
83
+ E as createAIStreamReducer,
84
+ $ as reduceAIStreamEvent
85
+ };