@qfei-design/make-ai-assistant 0.2.9 → 0.2.10
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.
- package/PUBLIC_API.md +17 -23
- package/README.md +12 -24
- package/capabilities.json +36 -9
- package/dist/conversation-CZfbgCXd.js +1111 -0
- package/dist/conversation-Cvh-IVRV.cjs +1 -0
- package/dist/core/conversation-management.d.ts +212 -0
- package/dist/core/conversation.d.ts +34 -2
- package/dist/core/index.d.ts +2 -0
- package/dist/core/response-state.d.ts +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -4
- package/dist/make-app/protocol.d.ts +27 -0
- package/dist/make-app/stream.d.ts +20 -0
- package/dist/make-app.cjs +1 -1
- package/dist/make-app.d.ts +46 -11
- package/dist/make-app.mjs +698 -259
- package/dist/make-console.cjs +1 -1
- package/dist/make-console.mjs +1 -1
- package/dist/react/conversation-controls.d.ts +15 -0
- package/dist/react/use-attachments.d.ts +26 -0
- package/dist/react/use-conversation-manager.d.ts +35 -0
- package/dist/react.cjs +4 -4
- package/dist/react.mjs +1712 -747
- package/dist/sse.cjs +1 -1
- package/dist/sse.mjs +1 -1
- package/dist/styles.css +51 -0
- package/docs/backend-contract.md +8 -21
- package/docs/make-app-integration.md +80 -0
- package/examples/make-app/README.md +11 -0
- package/examples/make-app/index.html +5 -0
- package/examples/make-app/main.tsx +34 -0
- package/examples/make-app/style.css +4 -0
- package/examples/make-app/transport.ts +163 -0
- package/examples/make-app/vite.config.ts +7 -0
- package/package.json +10 -2
- package/recipes.json +36 -13
- package/dist/conversation-B7eGUXi-.js +0 -727
- package/dist/conversation-Cv1wdvCR.cjs +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { isValidElement as
|
|
3
|
-
import { resolveArtifactTemplate as
|
|
4
|
-
import { extendArtifactTemplateRegistry as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
8
|
-
const t =
|
|
1
|
+
import { jsxs as c, jsx as a, Fragment as Ce } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as da, cloneElement as ua, useRef as R, useState as C, useEffect as ue, useLayoutEffect as yt, useId as ma, useMemo as xt } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as ha, createArtifactTemplateRegistry as Ut, createArtifactCapabilities as pa } from "./index.mjs";
|
|
4
|
+
import { extendArtifactTemplateRegistry as Is } from "./index.mjs";
|
|
5
|
+
import { n as he, k as pt, r as Te, l as Ot, o as qt, c as lt, M as de } from "./conversation-CZfbgCXd.js";
|
|
6
|
+
import { q as Ts, s as Cs, t as Ms, u as Ns, v as Rs } from "./conversation-CZfbgCXd.js";
|
|
7
|
+
const Kt = (e) => e?.trim() || void 0, ke = (e, t) => Kt(e) ?? t, bt = (e) => {
|
|
8
|
+
const t = Kt(e?.primary);
|
|
9
9
|
if (t)
|
|
10
10
|
return {
|
|
11
11
|
"--make-ai-theme-primary": t,
|
|
12
|
-
"--make-ai-theme-primary-hover":
|
|
12
|
+
"--make-ai-theme-primary-hover": ke(
|
|
13
13
|
e?.primaryHover,
|
|
14
14
|
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
|
|
15
15
|
),
|
|
16
|
-
"--make-ai-theme-on-primary":
|
|
16
|
+
"--make-ai-theme-on-primary": ke(
|
|
17
17
|
e?.onPrimary,
|
|
18
18
|
"#fcfcff"
|
|
19
19
|
),
|
|
20
|
-
"--make-ai-theme-bg":
|
|
20
|
+
"--make-ai-theme-bg": ke(
|
|
21
21
|
e?.background,
|
|
22
22
|
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
23
23
|
),
|
|
24
|
-
"--make-ai-theme-surface":
|
|
24
|
+
"--make-ai-theme-surface": ke(
|
|
25
25
|
e?.surface,
|
|
26
26
|
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
27
27
|
),
|
|
28
|
-
"--make-ai-theme-surface-strong":
|
|
28
|
+
"--make-ai-theme-surface-strong": ke(
|
|
29
29
|
e?.surfaceStrong,
|
|
30
30
|
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
31
31
|
),
|
|
32
|
-
"--make-ai-theme-text":
|
|
32
|
+
"--make-ai-theme-text": ke(
|
|
33
33
|
e?.text,
|
|
34
34
|
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
35
35
|
),
|
|
36
|
-
"--make-ai-theme-text-secondary":
|
|
36
|
+
"--make-ai-theme-text-secondary": ke(
|
|
37
37
|
e?.textSecondary,
|
|
38
38
|
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
39
39
|
),
|
|
40
|
-
"--make-ai-theme-border":
|
|
40
|
+
"--make-ai-theme-border": ke(
|
|
41
41
|
e?.border,
|
|
42
42
|
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
43
43
|
),
|
|
44
|
-
"--make-ai-theme-overlay":
|
|
44
|
+
"--make-ai-theme-overlay": ke(
|
|
45
45
|
e?.overlay,
|
|
46
46
|
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
47
47
|
),
|
|
48
|
-
"--make-ai-theme-on-overlay":
|
|
48
|
+
"--make-ai-theme-on-overlay": ke(
|
|
49
49
|
e?.onOverlay,
|
|
50
50
|
"#fcfcff"
|
|
51
51
|
)
|
|
52
52
|
};
|
|
53
|
-
},
|
|
53
|
+
}, $t = (e, t) => !t || !da(e) || typeof e.type != "string" ? e : ua(e, {
|
|
54
54
|
style: { ...e.props.style, ...t }
|
|
55
55
|
});
|
|
56
|
-
function
|
|
56
|
+
function fa({
|
|
57
57
|
artifact: e,
|
|
58
58
|
context: t,
|
|
59
59
|
fallback: s,
|
|
60
|
-
onAction:
|
|
60
|
+
onAction: o,
|
|
61
61
|
onActionError: n,
|
|
62
|
-
registry:
|
|
63
|
-
theme:
|
|
62
|
+
registry: r,
|
|
63
|
+
theme: u
|
|
64
64
|
}) {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
65
|
+
const g = bt(u), _ = ha(r, e, t);
|
|
66
|
+
if (!_) {
|
|
67
|
+
const L = s ? s(e) : /* @__PURE__ */ c("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
68
68
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
69
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ c("span", { children: [
|
|
70
70
|
"结果类型:",
|
|
71
71
|
e.kind
|
|
72
72
|
] })
|
|
73
73
|
] });
|
|
74
|
-
return
|
|
74
|
+
return $t(L, g);
|
|
75
75
|
}
|
|
76
76
|
const p = {
|
|
77
77
|
context: t,
|
|
78
|
-
onAction:
|
|
78
|
+
onAction: o,
|
|
79
79
|
onActionError: n,
|
|
80
|
-
theme:
|
|
81
|
-
themeStyle:
|
|
82
|
-
},
|
|
83
|
-
return
|
|
80
|
+
theme: u,
|
|
81
|
+
themeStyle: g
|
|
82
|
+
}, $ = _.template.render(e, t, p);
|
|
83
|
+
return $t($, g);
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const De = (e, t, s) => {
|
|
86
86
|
if (e == null || e === "") return "—";
|
|
87
87
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
88
88
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
89
|
-
const
|
|
90
|
-
maximumFractionDigits:
|
|
91
|
-
minimumFractionDigits:
|
|
89
|
+
const o = t?.precision, n = {
|
|
90
|
+
maximumFractionDigits: o ?? 2,
|
|
91
|
+
minimumFractionDigits: o
|
|
92
92
|
};
|
|
93
93
|
t?.style === "currency" && t.currency ? (n.style = "currency", n.currency = t.currency) : t?.style === "percent" && (n.style = "percent");
|
|
94
94
|
try {
|
|
95
|
-
const
|
|
96
|
-
return `${new Intl.NumberFormat(s, n).format(
|
|
95
|
+
const r = t?.style === "percent" ? e / 100 : e;
|
|
96
|
+
return `${new Intl.NumberFormat(s, n).format(r)}${t?.unit ?? ""}`;
|
|
97
97
|
} catch {
|
|
98
98
|
return `${e}${t?.unit ?? ""}`;
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, Vt = (e) => {
|
|
101
101
|
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
102
|
-
for (const
|
|
103
|
-
t = Math.min(t,
|
|
102
|
+
for (const o of e)
|
|
103
|
+
t = Math.min(t, o), s = Math.max(s, o);
|
|
104
104
|
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
105
|
-
},
|
|
105
|
+
}, jt = (e, t, s) => {
|
|
106
106
|
if (!s.onAction) return;
|
|
107
|
-
const
|
|
107
|
+
const o = (r) => {
|
|
108
108
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
109
109
|
actionId: e.id,
|
|
110
110
|
artifactId: t.artifact.id,
|
|
111
|
-
errorType:
|
|
111
|
+
errorType: r instanceof Error ? r.name : typeof r,
|
|
112
112
|
intent: e.intent
|
|
113
113
|
});
|
|
114
|
-
}, n = (
|
|
114
|
+
}, n = (r) => {
|
|
115
115
|
if (s.onActionError) {
|
|
116
116
|
try {
|
|
117
117
|
Promise.resolve(
|
|
118
|
-
s.onActionError(
|
|
119
|
-
).catch(
|
|
120
|
-
} catch (
|
|
121
|
-
|
|
118
|
+
s.onActionError(r, e, t)
|
|
119
|
+
).catch(o);
|
|
120
|
+
} catch (u) {
|
|
121
|
+
o(u);
|
|
122
122
|
}
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
console.error("[make-ai-assistant] host action failed", {
|
|
126
126
|
actionId: e.id,
|
|
127
127
|
artifactId: t.artifact.id,
|
|
128
|
-
errorType:
|
|
128
|
+
errorType: r instanceof Error ? r.name : typeof r,
|
|
129
129
|
intent: e.intent
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
132
|
try {
|
|
133
133
|
Promise.resolve(s.onAction(e, t)).catch(n);
|
|
134
|
-
} catch (
|
|
135
|
-
n(
|
|
134
|
+
} catch (r) {
|
|
135
|
+
n(r);
|
|
136
136
|
}
|
|
137
|
-
},
|
|
137
|
+
}, Ue = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ c(
|
|
138
138
|
"button",
|
|
139
139
|
{
|
|
140
140
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
141
141
|
type: "button",
|
|
142
|
-
onClick: () =>
|
|
142
|
+
onClick: () => jt(s, { artifact: e, context: t.context }, t),
|
|
143
143
|
children: [
|
|
144
144
|
s.label,
|
|
145
145
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
146
146
|
]
|
|
147
147
|
},
|
|
148
148
|
s.id
|
|
149
|
-
)) }) : null,
|
|
149
|
+
)) }) : null, Oe = (e, t, s = "", o) => /* @__PURE__ */ c(
|
|
150
150
|
"section",
|
|
151
151
|
{
|
|
152
152
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
153
153
|
className: `make-ai-artifact ${s}`.trim(),
|
|
154
154
|
"data-artifact-density": e.presentation?.density,
|
|
155
155
|
"data-artifact-kind": e.kind,
|
|
156
|
-
style:
|
|
156
|
+
style: o,
|
|
157
157
|
children: [
|
|
158
158
|
e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
|
|
159
159
|
e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
|
|
160
160
|
t
|
|
161
161
|
]
|
|
162
162
|
}
|
|
163
|
-
),
|
|
163
|
+
), ga = ({
|
|
164
164
|
artifact: e,
|
|
165
165
|
renderContext: t
|
|
166
166
|
}) => {
|
|
167
|
-
const s = e.data.delta,
|
|
167
|
+
const s = e.data.delta, o = s ? De(
|
|
168
168
|
s.value,
|
|
169
169
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
170
170
|
t.context.locale
|
|
171
171
|
) : void 0;
|
|
172
|
-
return
|
|
172
|
+
return Oe(
|
|
173
173
|
e,
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
174
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
175
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: De(
|
|
176
176
|
e.data.value,
|
|
177
177
|
e.data.format,
|
|
178
178
|
t.context.locale
|
|
179
179
|
) }),
|
|
180
|
-
s ? /* @__PURE__ */
|
|
180
|
+
s ? /* @__PURE__ */ c(
|
|
181
181
|
"div",
|
|
182
182
|
{
|
|
183
183
|
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
184
184
|
children: [
|
|
185
185
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
|
|
186
|
-
/* @__PURE__ */ a("span", { children:
|
|
186
|
+
/* @__PURE__ */ a("span", { children: o }),
|
|
187
187
|
s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
|
|
188
188
|
]
|
|
189
189
|
}
|
|
190
190
|
) : null,
|
|
191
191
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
192
|
-
|
|
192
|
+
Ue(e, t)
|
|
193
193
|
] }),
|
|
194
194
|
"make-ai-artifact--metric",
|
|
195
195
|
t.themeStyle
|
|
196
196
|
);
|
|
197
|
-
},
|
|
197
|
+
}, va = ({
|
|
198
198
|
artifact: e,
|
|
199
199
|
renderContext: t
|
|
200
|
-
}) =>
|
|
200
|
+
}) => Oe(
|
|
201
201
|
e,
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
203
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
204
204
|
/* @__PURE__ */ a("span", { children: s.label }),
|
|
205
|
-
/* @__PURE__ */ a("strong", { children:
|
|
205
|
+
/* @__PURE__ */ a("strong", { children: De(s.value, s.format, t.context.locale) }),
|
|
206
206
|
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
207
207
|
] }, s.id)) }),
|
|
208
|
-
|
|
208
|
+
Ue(e, t)
|
|
209
209
|
] }),
|
|
210
210
|
"make-ai-artifact--comparison",
|
|
211
211
|
t.themeStyle
|
|
212
|
-
),
|
|
212
|
+
), ya = ({
|
|
213
213
|
artifact: e,
|
|
214
214
|
renderContext: t
|
|
215
215
|
}) => {
|
|
216
|
-
const s = e.data.series.flatMap((
|
|
217
|
-
return
|
|
216
|
+
const s = e.data.series.flatMap((u) => u.points.map((g) => g.y)), { max: o, min: n } = Vt(s), r = o - n || 1;
|
|
217
|
+
return Oe(
|
|
218
218
|
e,
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((
|
|
221
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children:
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children:
|
|
223
|
-
const p = 18 + (
|
|
224
|
-
return /* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
220
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((u) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-series", children: [
|
|
221
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: u.label }),
|
|
222
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: u.points.map((g, _) => {
|
|
223
|
+
const p = 18 + (g.y - n) / r * 70;
|
|
224
|
+
return /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-point", children: [
|
|
225
225
|
/* @__PURE__ */ a(
|
|
226
226
|
"span",
|
|
227
227
|
{
|
|
228
|
-
"aria-label": `${
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
"aria-label": `${g.x}: ${De(
|
|
229
|
+
g.y,
|
|
230
|
+
u.format,
|
|
231
231
|
t.context.locale
|
|
232
232
|
)}`,
|
|
233
233
|
className: "make-ai-artifact__trend-bar",
|
|
234
234
|
role: "img",
|
|
235
235
|
style: { height: `${p}%` },
|
|
236
|
-
title: `${
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
title: `${g.x}: ${De(
|
|
237
|
+
g.y,
|
|
238
|
+
u.format,
|
|
239
239
|
t.context.locale
|
|
240
240
|
)}`
|
|
241
241
|
}
|
|
242
242
|
),
|
|
243
|
-
/* @__PURE__ */ a("small", { children:
|
|
244
|
-
] }, `${
|
|
243
|
+
/* @__PURE__ */ a("small", { children: g.x })
|
|
244
|
+
] }, `${g.x}-${_}`);
|
|
245
245
|
}) })
|
|
246
|
-
] },
|
|
247
|
-
|
|
246
|
+
] }, u.id)) }),
|
|
247
|
+
Ue(e, t)
|
|
248
248
|
] }),
|
|
249
249
|
"make-ai-artifact--trend",
|
|
250
250
|
t.themeStyle
|
|
251
251
|
);
|
|
252
|
-
},
|
|
252
|
+
}, ba = ({
|
|
253
253
|
artifact: e,
|
|
254
254
|
renderContext: t
|
|
255
255
|
}) => {
|
|
256
|
-
const { max: s } =
|
|
256
|
+
const { max: s } = Vt(
|
|
257
257
|
e.data.items.map((n) => Math.abs(n.value))
|
|
258
|
-
),
|
|
259
|
-
return
|
|
258
|
+
), o = Math.max(s, 1);
|
|
259
|
+
return Oe(
|
|
260
260
|
e,
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n,
|
|
263
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children:
|
|
264
|
-
/* @__PURE__ */
|
|
261
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
262
|
+
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n, r) => /* @__PURE__ */ c("li", { children: [
|
|
263
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: r + 1 }),
|
|
264
|
+
/* @__PURE__ */ c("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
265
265
|
/* @__PURE__ */ a("span", { children: n.label }),
|
|
266
266
|
n.description ? /* @__PURE__ */ a("small", { children: n.description }) : null
|
|
267
267
|
] }),
|
|
268
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) /
|
|
269
|
-
/* @__PURE__ */ a("strong", { children:
|
|
268
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) / o * 100}%` } }) }),
|
|
269
|
+
/* @__PURE__ */ a("strong", { children: De(n.value, n.format, t.context.locale) })
|
|
270
270
|
] }, n.id)) }),
|
|
271
|
-
|
|
271
|
+
Ue(e, t)
|
|
272
272
|
] }),
|
|
273
273
|
"make-ai-artifact--ranking",
|
|
274
274
|
t.themeStyle
|
|
275
275
|
);
|
|
276
|
-
},
|
|
276
|
+
}, ka = (e, t) => t.action ?? {
|
|
277
277
|
id: `open-${t.id}`,
|
|
278
278
|
label: t.title ?? t.id,
|
|
279
279
|
intent: "open-record",
|
|
280
280
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
281
|
-
},
|
|
281
|
+
}, _a = ({
|
|
282
282
|
artifact: e,
|
|
283
283
|
renderContext: t
|
|
284
|
-
}) =>
|
|
284
|
+
}) => Oe(
|
|
285
285
|
e,
|
|
286
|
-
/* @__PURE__ */
|
|
286
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
287
287
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
|
|
288
|
-
const
|
|
288
|
+
const o = ka(e, s), n = /* @__PURE__ */ c(Ce, { children: [
|
|
289
289
|
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
290
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((
|
|
291
|
-
/* @__PURE__ */ a("small", { children:
|
|
292
|
-
|
|
293
|
-
s.values[
|
|
294
|
-
|
|
290
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((r) => /* @__PURE__ */ c("span", { children: [
|
|
291
|
+
/* @__PURE__ */ a("small", { children: r.label }),
|
|
292
|
+
De(
|
|
293
|
+
s.values[r.key],
|
|
294
|
+
r.format,
|
|
295
295
|
t.context.locale
|
|
296
296
|
)
|
|
297
|
-
] },
|
|
297
|
+
] }, r.key)) }),
|
|
298
298
|
t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
|
|
299
299
|
] });
|
|
300
300
|
return t.onAction ? /* @__PURE__ */ a(
|
|
@@ -302,7 +302,7 @@ const se = (e, t, s) => {
|
|
|
302
302
|
{
|
|
303
303
|
className: "make-ai-artifact__record",
|
|
304
304
|
type: "button",
|
|
305
|
-
onClick: () =>
|
|
305
|
+
onClick: () => jt(o, {
|
|
306
306
|
artifact: e,
|
|
307
307
|
context: t.context
|
|
308
308
|
}, t),
|
|
@@ -311,111 +311,1027 @@ const se = (e, t, s) => {
|
|
|
311
311
|
s.id
|
|
312
312
|
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: n }, s.id);
|
|
313
313
|
}) }),
|
|
314
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
314
|
+
e.data.total !== void 0 ? /* @__PURE__ */ c("p", { className: "make-ai-artifact__record-total", children: [
|
|
315
315
|
"共 ",
|
|
316
316
|
e.data.total,
|
|
317
317
|
" 条"
|
|
318
318
|
] }) : null,
|
|
319
|
-
|
|
319
|
+
Ue(e, t)
|
|
320
320
|
] }),
|
|
321
321
|
"make-ai-artifact--record-list",
|
|
322
322
|
t.themeStyle
|
|
323
|
-
),
|
|
323
|
+
), wa = ({
|
|
324
324
|
artifact: e,
|
|
325
325
|
renderContext: t
|
|
326
|
-
}) =>
|
|
326
|
+
}) => Oe(
|
|
327
327
|
e,
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */
|
|
328
|
+
/* @__PURE__ */ c(Ce, { children: [
|
|
329
|
+
/* @__PURE__ */ c("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
330
330
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
331
331
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
332
332
|
] }),
|
|
333
|
-
|
|
333
|
+
Ue(e, t)
|
|
334
334
|
] }),
|
|
335
335
|
"make-ai-artifact--notice",
|
|
336
336
|
t.themeStyle
|
|
337
|
-
),
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
],
|
|
337
|
+
), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), Ia = [
|
|
338
|
+
He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(ga, { artifact: e, renderContext: s })),
|
|
339
|
+
He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(va, { artifact: e, renderContext: s })),
|
|
340
|
+
He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ya, { artifact: e, renderContext: s })),
|
|
341
|
+
He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(ba, { artifact: e, renderContext: s })),
|
|
342
|
+
He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(_a, { artifact: e, renderContext: s })),
|
|
343
|
+
He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(wa, { artifact: e, renderContext: s }))
|
|
344
|
+
], Aa = Ut(Ia).templates, Ta = (e = Aa) => Ut(e), We = () => globalThis.crypto.randomUUID(), kt = (e) => {
|
|
345
|
+
const t = e, s = t?.status ?? t?.response?.status;
|
|
346
|
+
return s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
|
|
347
|
+
};
|
|
348
|
+
function Ca(e, t) {
|
|
349
|
+
const s = t.features?.conversationManagement === !0, o = s ? t.scopeKey?.(e) ?? e.app.id : "", n = R(o);
|
|
350
|
+
n.current = o;
|
|
351
|
+
const r = R(o), [u, g] = C(he), _ = R(u), p = (i) => {
|
|
352
|
+
const h = typeof i == "function" ? i(_.current) : i;
|
|
353
|
+
_.current = h, g(h);
|
|
354
|
+
}, [$, L] = C([]), [X, K] = C(), v = R(void 0), [j, te] = C(""), [Z, f] = C(-1), [d, l] = C(!1), [I, E] = C(!1), [ie, M] = C(s), [J, V] = C(!1), [D, Q] = C(), [pe, fe] = C([]), [B, se] = C([]), oe = R(/* @__PURE__ */ new Set()), U = R(/* @__PURE__ */ new Map()), S = R(0), w = R(0), W = R(0), ae = R(void 0), ge = R(void 0), Se = R(/* @__PURE__ */ new Map()), x = (i, h = o) => w.current === i && n.current === h, ee = () => {
|
|
355
|
+
const i = new AbortController();
|
|
356
|
+
return oe.current.add(i), i;
|
|
357
|
+
}, ce = (i) => oe.current.delete(i), le = (i) => {
|
|
358
|
+
v.current = i, K(i);
|
|
359
|
+
}, qe = () => {
|
|
360
|
+
for (const i of U.current.values()) i.abort();
|
|
361
|
+
U.current.clear();
|
|
362
|
+
}, Y = (i) => {
|
|
363
|
+
i instanceof Error && i.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
|
|
364
|
+
errorType: i instanceof Error ? i.name : typeof i
|
|
365
|
+
}), Q(kt(i)));
|
|
366
|
+
}, ne = async (i) => {
|
|
367
|
+
if (!s || !t.listConversations) return;
|
|
368
|
+
const h = w.current, y = ++W.current, k = ee();
|
|
369
|
+
try {
|
|
370
|
+
const A = await t.listConversations(
|
|
371
|
+
e,
|
|
372
|
+
{ cursor: i },
|
|
373
|
+
{ signal: k.signal }
|
|
374
|
+
);
|
|
375
|
+
if (!x(h) || k.signal.aborted || y !== W.current)
|
|
376
|
+
return;
|
|
377
|
+
L((N) => [
|
|
378
|
+
...new Map(
|
|
379
|
+
[...i ? N : [], ...A.chats].map((b) => [
|
|
380
|
+
b.chatId,
|
|
381
|
+
b
|
|
382
|
+
])
|
|
383
|
+
).values()
|
|
384
|
+
]), te(A.nextCursor);
|
|
385
|
+
} catch (A) {
|
|
386
|
+
x(h) && !k.signal.aborted && Y(A);
|
|
387
|
+
} finally {
|
|
388
|
+
ce(k), x(h) && M(!1);
|
|
389
|
+
}
|
|
390
|
+
}, xe = async (i, h, y) => {
|
|
391
|
+
const k = w.current, A = S.current;
|
|
392
|
+
let N;
|
|
393
|
+
try {
|
|
394
|
+
for await (const b of i) {
|
|
395
|
+
if (!x(k) || h.signal.aborted || A !== S.current || v.current?.chatId !== y)
|
|
396
|
+
return;
|
|
397
|
+
const O = Ot(b);
|
|
398
|
+
if (O.type === "response.accepted" || O.type === "response.state") {
|
|
399
|
+
N = O.responseId;
|
|
400
|
+
const P = U.current.get(N);
|
|
401
|
+
if (P && P !== h) {
|
|
402
|
+
O.type === "response.accepted" && p((H) => Te(H, O)), h.abort();
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
U.current.set(N, h);
|
|
406
|
+
}
|
|
407
|
+
p((P) => Te(P, O)), O.type === "response.terminal" && (fe((P) => P.filter((H) => H !== O.responseId)), ne());
|
|
408
|
+
}
|
|
409
|
+
} catch (b) {
|
|
410
|
+
x(k) && !h.signal.aborted && A === S.current && (Y(b), N || p((O) => ({
|
|
411
|
+
...O,
|
|
412
|
+
status: Object.values(O.responses ?? {}).some(
|
|
413
|
+
(P) => !pt(P.status)
|
|
414
|
+
) ? "streaming" : "error"
|
|
415
|
+
})));
|
|
416
|
+
} finally {
|
|
417
|
+
N && U.current.get(N) === h && U.current.delete(N), ce(h);
|
|
418
|
+
}
|
|
419
|
+
}, Me = async (i, h, y, k) => {
|
|
420
|
+
if (!t.getResponse || !t.watchResponse) return;
|
|
421
|
+
const A = new Set(
|
|
422
|
+
i.filter((b) => b.role === "assistant" && b.persistent).map((b) => b.responseId)
|
|
423
|
+
), N = [
|
|
424
|
+
...new Map(
|
|
425
|
+
i.filter(
|
|
426
|
+
(b) => b.role === "user" && b.responseId && !A.has(b.responseId)
|
|
427
|
+
).map((b) => [b.responseId, b.cursor ?? -1])
|
|
428
|
+
).entries()
|
|
429
|
+
].slice(-20);
|
|
430
|
+
for (const [b, O] of N) {
|
|
431
|
+
if (!x(k) || y !== S.current) return;
|
|
432
|
+
if (U.current.has(b)) continue;
|
|
433
|
+
const P = ee();
|
|
434
|
+
try {
|
|
435
|
+
const H = await t.getResponse(
|
|
436
|
+
e,
|
|
437
|
+
{ chatId: h, responseId: b },
|
|
438
|
+
{ signal: P.signal }
|
|
439
|
+
);
|
|
440
|
+
if (!x(k) || P.signal.aborted || y !== S.current || U.current.has(b)) continue;
|
|
441
|
+
p(
|
|
442
|
+
(Ie) => Te(
|
|
443
|
+
Ie,
|
|
444
|
+
pt(H.status) ? { type: "response.snapshot", snapshot: H } : {
|
|
445
|
+
type: "response.state",
|
|
446
|
+
chatId: h,
|
|
447
|
+
responseId: b,
|
|
448
|
+
status: H.status
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
), H.status === "failed" || H.status === "cancelled" ? p(
|
|
452
|
+
(Ie) => Te(Ie, {
|
|
453
|
+
type: "response.terminal",
|
|
454
|
+
chatId: h,
|
|
455
|
+
responseId: b,
|
|
456
|
+
status: H.status
|
|
457
|
+
})
|
|
458
|
+
) : (U.current.set(b, P), xe(
|
|
459
|
+
t.watchResponse(
|
|
460
|
+
e,
|
|
461
|
+
{ chatId: h, responseId: b, historyCursor: O },
|
|
462
|
+
{ signal: P.signal }
|
|
463
|
+
),
|
|
464
|
+
P,
|
|
465
|
+
h
|
|
466
|
+
));
|
|
467
|
+
} catch (H) {
|
|
468
|
+
x(k) && !P.signal.aborted && Y(H);
|
|
469
|
+
} finally {
|
|
470
|
+
U.current.get(b) !== P && ce(P);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}, Ke = async (i) => {
|
|
474
|
+
const h = ++S.current, y = w.current, k = ee();
|
|
475
|
+
qe(), Q(void 0), M(!0), fe([]), ge.current = void 0, le(i), p({ messages: [], status: "idle", threadId: i.chatId }), f(-1), l(!1), E(!1);
|
|
476
|
+
try {
|
|
477
|
+
const [A, N] = await Promise.all([
|
|
478
|
+
t.getConversation(
|
|
479
|
+
e,
|
|
480
|
+
{ chatId: i.chatId },
|
|
481
|
+
{ signal: k.signal }
|
|
482
|
+
),
|
|
483
|
+
t.loadConversation(e, {
|
|
484
|
+
threadId: i.chatId,
|
|
485
|
+
cursor: -1,
|
|
486
|
+
signal: k.signal
|
|
487
|
+
})
|
|
488
|
+
]);
|
|
489
|
+
if (!x(y) || k.signal.aborted || h !== S.current)
|
|
490
|
+
return;
|
|
491
|
+
if (A.chatId !== i.chatId || N.threadId !== i.chatId)
|
|
492
|
+
throw new Error("Conversation mismatch");
|
|
493
|
+
le(A), p(he(N)), f(N.nextCursor ?? -1), l(N.hasMore ?? !1), Me(N.messages, i.chatId, h, y);
|
|
494
|
+
} catch (A) {
|
|
495
|
+
x(y) && !k.signal.aborted && h === S.current && Y(A);
|
|
496
|
+
} finally {
|
|
497
|
+
ce(k), x(y) && h === S.current && M(!1);
|
|
498
|
+
}
|
|
499
|
+
}, ve = async () => {
|
|
500
|
+
if (v.current) return v.current;
|
|
501
|
+
if (ae.current ??= { requestId: We() }, ae.current.promise) return ae.current.promise;
|
|
502
|
+
const i = w.current, h = S.current, y = ee(), k = ae.current;
|
|
503
|
+
return V(!0), k.promise = t.createConversation(
|
|
504
|
+
e,
|
|
505
|
+
{ requestId: k.requestId },
|
|
506
|
+
{ signal: y.signal }
|
|
507
|
+
).then((A) => {
|
|
508
|
+
if (!x(i) || y.signal.aborted || h !== S.current)
|
|
509
|
+
throw Object.assign(new Error("Stale create"), {
|
|
510
|
+
name: "AbortError"
|
|
511
|
+
});
|
|
512
|
+
return ae.current = void 0, le(A), p({ messages: [], status: "idle", threadId: A.chatId }), ne(), A;
|
|
513
|
+
}).finally(() => {
|
|
514
|
+
ce(y), k.promise = void 0, x(i) && V(!1);
|
|
515
|
+
}), k.promise;
|
|
516
|
+
}, Ne = async () => {
|
|
517
|
+
if (!(J || ae.current?.promise)) {
|
|
518
|
+
S.current += 1, qe(), le(void 0), Q(void 0), ge.current = void 0, p(he()), l(!1), f(-1);
|
|
519
|
+
try {
|
|
520
|
+
await ve();
|
|
521
|
+
} catch (i) {
|
|
522
|
+
Y(i);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}, we = async (i) => {
|
|
526
|
+
const h = ee();
|
|
527
|
+
ge.current = i, Q(void 0), _.current.messages.some((y) => y.id === i.message.id) || p((y) => qt(y, i.message)), await xe(
|
|
528
|
+
t.run(i, { signal: h.signal }),
|
|
529
|
+
h,
|
|
530
|
+
i.threadId
|
|
531
|
+
);
|
|
532
|
+
}, Qe = async (i, h) => {
|
|
533
|
+
if (!(!i.trim() && !h?.length))
|
|
534
|
+
try {
|
|
535
|
+
const y = await ve(), k = {
|
|
536
|
+
id: We(),
|
|
537
|
+
content: i,
|
|
538
|
+
...h ? { parts: h } : {}
|
|
539
|
+
};
|
|
540
|
+
await we({
|
|
541
|
+
threadId: y.chatId,
|
|
542
|
+
message: k,
|
|
543
|
+
context: e,
|
|
544
|
+
capabilities: {
|
|
545
|
+
artifactSchemaVersions: [],
|
|
546
|
+
artifactKinds: [],
|
|
547
|
+
templates: []
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
} catch (y) {
|
|
551
|
+
Y(y);
|
|
552
|
+
}
|
|
553
|
+
}, $e = async () => {
|
|
554
|
+
const i = ge.current;
|
|
555
|
+
if (!i || i.threadId !== v.current?.chatId) {
|
|
556
|
+
v.current && await Ke(v.current);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const h = _.current.messages.find(
|
|
560
|
+
(y) => y.id === i.message.id
|
|
561
|
+
);
|
|
562
|
+
if (h?.responseId && t.watchResponse) {
|
|
563
|
+
const y = h.responseId;
|
|
564
|
+
if (U.current.has(y)) return;
|
|
565
|
+
const k = ee();
|
|
566
|
+
U.current.set(y, k), Q(void 0), await xe(
|
|
567
|
+
t.watchResponse(
|
|
568
|
+
e,
|
|
569
|
+
{
|
|
570
|
+
chatId: i.threadId,
|
|
571
|
+
responseId: y,
|
|
572
|
+
historyCursor: h.cursor
|
|
573
|
+
},
|
|
574
|
+
{ signal: k.signal }
|
|
575
|
+
),
|
|
576
|
+
k,
|
|
577
|
+
i.threadId
|
|
578
|
+
);
|
|
579
|
+
} else await we(i);
|
|
580
|
+
}, et = async (i = _.current.activeRunId) => {
|
|
581
|
+
const h = v.current;
|
|
582
|
+
if (!h || !i || !t.cancelResponse || pe.includes(i))
|
|
583
|
+
return;
|
|
584
|
+
const y = w.current, k = S.current, A = ee();
|
|
585
|
+
fe((N) => [...N, i]), Q(void 0);
|
|
586
|
+
try {
|
|
587
|
+
const N = await t.cancelResponse(
|
|
588
|
+
e,
|
|
589
|
+
{ chatId: h.chatId, responseId: i },
|
|
590
|
+
{ signal: A.signal }
|
|
591
|
+
);
|
|
592
|
+
if (!x(y) || k !== S.current) return;
|
|
593
|
+
if (pt(N.status))
|
|
594
|
+
p(
|
|
595
|
+
(b) => Te(b, {
|
|
596
|
+
type: "response.snapshot",
|
|
597
|
+
snapshot: N
|
|
598
|
+
})
|
|
599
|
+
), fe((b) => b.filter((O) => O !== i));
|
|
600
|
+
else if (!U.current.has(i) && t.watchResponse) {
|
|
601
|
+
const b = ee();
|
|
602
|
+
U.current.set(i, b), xe(
|
|
603
|
+
t.watchResponse(
|
|
604
|
+
e,
|
|
605
|
+
{ chatId: h.chatId, responseId: i },
|
|
606
|
+
{ signal: b.signal }
|
|
607
|
+
),
|
|
608
|
+
b,
|
|
609
|
+
h.chatId
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
} catch (N) {
|
|
613
|
+
x(y) && k === S.current && (Y(N), fe((b) => b.filter((O) => O !== i)));
|
|
614
|
+
} finally {
|
|
615
|
+
ce(A);
|
|
616
|
+
}
|
|
617
|
+
}, tt = async (i, h = v.current) => {
|
|
618
|
+
if (!h || J) return;
|
|
619
|
+
const y = w.current, k = ee();
|
|
620
|
+
V(!0), Q(void 0);
|
|
621
|
+
try {
|
|
622
|
+
const A = await t.updateConversation(
|
|
623
|
+
e,
|
|
624
|
+
{ chatId: h.chatId, expectedRevision: h.revision, ...i },
|
|
625
|
+
{ signal: k.signal }
|
|
626
|
+
);
|
|
627
|
+
if (!x(y)) return;
|
|
628
|
+
v.current?.chatId === A.chatId && le(A), await ne();
|
|
629
|
+
} catch (A) {
|
|
630
|
+
if (x(y)) {
|
|
631
|
+
Y(A);
|
|
632
|
+
try {
|
|
633
|
+
const N = await t.getConversation(
|
|
634
|
+
e,
|
|
635
|
+
{ chatId: h.chatId },
|
|
636
|
+
{ signal: k.signal }
|
|
637
|
+
);
|
|
638
|
+
x(y) && v.current?.chatId === h.chatId && le(N);
|
|
639
|
+
} catch {
|
|
640
|
+
}
|
|
641
|
+
ne();
|
|
642
|
+
}
|
|
643
|
+
} finally {
|
|
644
|
+
ce(k), x(y) && V(!1);
|
|
645
|
+
}
|
|
646
|
+
}, at = async (i = v.current) => {
|
|
647
|
+
if (!i || J) return;
|
|
648
|
+
const h = w.current, y = ee();
|
|
649
|
+
V(!0), Q(void 0);
|
|
650
|
+
try {
|
|
651
|
+
if (await t.deleteConversation(
|
|
652
|
+
e,
|
|
653
|
+
{ chatId: i.chatId, expectedRevision: i.revision },
|
|
654
|
+
{ signal: y.signal }
|
|
655
|
+
), !x(h)) return;
|
|
656
|
+
v.current?.chatId === i.chatId && (S.current += 1, qe(), le(void 0), p(he())), await ne();
|
|
657
|
+
} catch (k) {
|
|
658
|
+
x(h) && Y(k);
|
|
659
|
+
} finally {
|
|
660
|
+
ce(y), x(h) && V(!1);
|
|
661
|
+
}
|
|
662
|
+
}, st = async (i, h, y = "", k = "") => {
|
|
663
|
+
const A = v.current;
|
|
664
|
+
if (!A || !i.persistent || !t.setFeedback || B.includes(i.id))
|
|
665
|
+
return;
|
|
666
|
+
const N = {
|
|
667
|
+
chatId: A.chatId,
|
|
668
|
+
messageId: i.id,
|
|
669
|
+
rating: h,
|
|
670
|
+
...y ? { reason: y } : {},
|
|
671
|
+
...k ? { comment: k } : {}
|
|
672
|
+
}, b = Se.current.get(i.id), { requestId: O, ...P } = b ?? {
|
|
673
|
+
requestId: ""
|
|
674
|
+
}, H = b && JSON.stringify(P) === JSON.stringify(N) ? b : { ...N, requestId: We() };
|
|
675
|
+
Se.current.set(i.id, H);
|
|
676
|
+
const Ie = w.current, Ve = S.current, Le = ee();
|
|
677
|
+
se((be) => [...be, i.id]), Q(void 0);
|
|
678
|
+
try {
|
|
679
|
+
const be = await t.setFeedback(e, H, {
|
|
680
|
+
signal: Le.signal
|
|
681
|
+
});
|
|
682
|
+
return !x(Ie) || Ve !== S.current || Se.current.get(i.id) !== H ? void 0 : (p((Pe) => ({
|
|
683
|
+
...Pe,
|
|
684
|
+
messages: Pe.messages.map(
|
|
685
|
+
(Fe) => Fe.id === i.id && be.revision >= (Fe.feedback?.revision ?? 0) ? { ...Fe, feedback: be } : Fe
|
|
686
|
+
)
|
|
687
|
+
})), Se.current.delete(i.id), !0);
|
|
688
|
+
} catch (be) {
|
|
689
|
+
return x(Ie) && Ve === S.current && Y(be), !1;
|
|
690
|
+
} finally {
|
|
691
|
+
ce(Le), x(Ie) && se((be) => be.filter((Pe) => Pe !== i.id));
|
|
692
|
+
}
|
|
693
|
+
}, ye = async () => {
|
|
694
|
+
if (!v.current || !d || ie) return;
|
|
695
|
+
const i = w.current, h = S.current, y = v.current, k = ee();
|
|
696
|
+
M(!0);
|
|
697
|
+
try {
|
|
698
|
+
const A = await t.loadConversation(e, {
|
|
699
|
+
threadId: y.chatId,
|
|
700
|
+
cursor: Z,
|
|
701
|
+
signal: k.signal
|
|
702
|
+
});
|
|
703
|
+
if (!x(i) || h !== S.current) return;
|
|
704
|
+
const N = he(A), b = [
|
|
705
|
+
...new Map(
|
|
706
|
+
[..._.current.messages, ...N.messages].map((H) => [
|
|
707
|
+
H.id,
|
|
708
|
+
H
|
|
709
|
+
])
|
|
710
|
+
).values()
|
|
711
|
+
];
|
|
712
|
+
let O = 0;
|
|
713
|
+
const P = [];
|
|
714
|
+
for (const H of b.slice(-200).reverse()) {
|
|
715
|
+
if (O += [...H.content].length, O > 1e6) break;
|
|
716
|
+
P.unshift(H);
|
|
717
|
+
}
|
|
718
|
+
P.length < b.length && E(!0), p((H) => ({ ...H, messages: P })), f(A.nextCursor ?? Z), l(A.hasMore ?? !1), Me(A.messages, y.chatId, h, i);
|
|
719
|
+
} catch (A) {
|
|
720
|
+
x(i) && Y(A);
|
|
721
|
+
} finally {
|
|
722
|
+
ce(k), x(i) && M(!1);
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
ue(() => (w.current += 1, r.current = o, ae.current = void 0, ge.current = void 0, Se.current.clear(), le(void 0), L([]), te(""), p(he()), Q(void 0), M(s), V(!1), fe([]), se([]), s && ne(), () => {
|
|
726
|
+
w.current += 1, S.current += 1;
|
|
727
|
+
for (const i of oe.current) i.abort();
|
|
728
|
+
oe.current.clear(), U.current.clear();
|
|
729
|
+
}), [s, o, t]);
|
|
730
|
+
const Re = r.current === o;
|
|
731
|
+
return {
|
|
732
|
+
enabled: s,
|
|
733
|
+
state: Re ? u : he(),
|
|
734
|
+
setState: p,
|
|
735
|
+
chats: Re ? $ : [],
|
|
736
|
+
chat: Re ? X : void 0,
|
|
737
|
+
listCursor: j,
|
|
738
|
+
historyMore: d,
|
|
739
|
+
historyTruncated: I,
|
|
740
|
+
loading: !Re || ie,
|
|
741
|
+
busy: J,
|
|
742
|
+
error: Re ? D : void 0,
|
|
743
|
+
cancelling: pe,
|
|
744
|
+
feedbackBusy: B,
|
|
745
|
+
refresh: ne,
|
|
746
|
+
select: Ke,
|
|
747
|
+
create: Ne,
|
|
748
|
+
ensureChat: ve,
|
|
749
|
+
send: Qe,
|
|
750
|
+
retry: $e,
|
|
751
|
+
stop: et,
|
|
752
|
+
update: tt,
|
|
753
|
+
remove: at,
|
|
754
|
+
feedback: st,
|
|
755
|
+
moreHistory: ye,
|
|
756
|
+
setError: Q
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function Ma({
|
|
760
|
+
manager: e
|
|
761
|
+
}) {
|
|
762
|
+
const [t, s] = C(""), [o, n] = C(!1);
|
|
763
|
+
return ue(() => {
|
|
764
|
+
s(e.chat?.title ?? ""), n(!1);
|
|
765
|
+
}, [e.chat?.chatId, e.chat?.title]), /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-controls", children: [
|
|
766
|
+
/* @__PURE__ */ c(
|
|
767
|
+
"nav",
|
|
768
|
+
{
|
|
769
|
+
"aria-label": "对话列表",
|
|
770
|
+
className: "make-ai-assistant__conversation-list",
|
|
771
|
+
children: [
|
|
772
|
+
e.chats.map((r) => /* @__PURE__ */ c(
|
|
773
|
+
"div",
|
|
774
|
+
{
|
|
775
|
+
className: "make-ai-assistant__conversation-row",
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ a(
|
|
778
|
+
"button",
|
|
779
|
+
{
|
|
780
|
+
type: "button",
|
|
781
|
+
"aria-pressed": e.chat?.chatId === r.chatId,
|
|
782
|
+
onClick: () => {
|
|
783
|
+
e.select(r);
|
|
784
|
+
},
|
|
785
|
+
children: r.title || "未命名对话"
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ a(
|
|
789
|
+
"button",
|
|
790
|
+
{
|
|
791
|
+
type: "button",
|
|
792
|
+
disabled: e.busy,
|
|
793
|
+
"aria-label": `${r.pinned ? "取消置顶" : "置顶"} ${r.title}`,
|
|
794
|
+
onClick: () => {
|
|
795
|
+
e.update({ pinned: !r.pinned }, r);
|
|
796
|
+
},
|
|
797
|
+
children: r.pinned ? "★" : "☆"
|
|
798
|
+
}
|
|
799
|
+
)
|
|
800
|
+
]
|
|
801
|
+
},
|
|
802
|
+
r.chatId
|
|
803
|
+
)),
|
|
804
|
+
!e.loading && !e.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
|
|
805
|
+
/* @__PURE__ */ a(
|
|
806
|
+
"button",
|
|
807
|
+
{
|
|
808
|
+
type: "button",
|
|
809
|
+
onClick: () => {
|
|
810
|
+
e.refresh();
|
|
811
|
+
},
|
|
812
|
+
disabled: e.busy,
|
|
813
|
+
children: "刷新列表"
|
|
814
|
+
}
|
|
815
|
+
),
|
|
816
|
+
e.listCursor ? /* @__PURE__ */ a(
|
|
817
|
+
"button",
|
|
818
|
+
{
|
|
819
|
+
type: "button",
|
|
820
|
+
onClick: () => {
|
|
821
|
+
e.refresh(e.listCursor);
|
|
822
|
+
},
|
|
823
|
+
children: "更多对话"
|
|
824
|
+
}
|
|
825
|
+
) : null
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
),
|
|
829
|
+
e.chat ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-actions", children: [
|
|
830
|
+
/* @__PURE__ */ a(
|
|
831
|
+
"input",
|
|
832
|
+
{
|
|
833
|
+
"aria-label": "对话标题",
|
|
834
|
+
maxLength: 255,
|
|
835
|
+
value: t,
|
|
836
|
+
onChange: (r) => s(r.currentTarget.value)
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
/* @__PURE__ */ a(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
type: "button",
|
|
843
|
+
disabled: e.busy || !t.trim(),
|
|
844
|
+
onClick: () => {
|
|
845
|
+
e.update({ title: t });
|
|
846
|
+
},
|
|
847
|
+
children: "保存标题"
|
|
848
|
+
}
|
|
849
|
+
),
|
|
850
|
+
/* @__PURE__ */ a(
|
|
851
|
+
"button",
|
|
852
|
+
{
|
|
853
|
+
type: "button",
|
|
854
|
+
disabled: e.busy,
|
|
855
|
+
onClick: () => n(!0),
|
|
856
|
+
children: "删除对话"
|
|
857
|
+
}
|
|
858
|
+
),
|
|
859
|
+
o ? /* @__PURE__ */ c("div", { role: "group", "aria-label": "确认删除对话", children: [
|
|
860
|
+
/* @__PURE__ */ c("span", { children: [
|
|
861
|
+
"删除“",
|
|
862
|
+
e.chat.title,
|
|
863
|
+
"”?"
|
|
864
|
+
] }),
|
|
865
|
+
/* @__PURE__ */ a(
|
|
866
|
+
"button",
|
|
867
|
+
{
|
|
868
|
+
type: "button",
|
|
869
|
+
disabled: e.busy,
|
|
870
|
+
onClick: () => {
|
|
871
|
+
n(!1), e.remove();
|
|
872
|
+
},
|
|
873
|
+
children: "确认删除"
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => n(!1), children: "保留" })
|
|
877
|
+
] }) : null,
|
|
878
|
+
e.historyMore ? /* @__PURE__ */ a(
|
|
879
|
+
"button",
|
|
880
|
+
{
|
|
881
|
+
type: "button",
|
|
882
|
+
disabled: e.loading,
|
|
883
|
+
onClick: () => {
|
|
884
|
+
e.moreHistory();
|
|
885
|
+
},
|
|
886
|
+
children: "继续加载历史"
|
|
887
|
+
}
|
|
888
|
+
) : null,
|
|
889
|
+
e.historyTruncated || e.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
|
|
890
|
+
] }) : null,
|
|
891
|
+
e.error ? /* @__PURE__ */ c("div", { role: "alert", children: [
|
|
892
|
+
/* @__PURE__ */ a("span", { children: e.error }),
|
|
893
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
894
|
+
e.retry();
|
|
895
|
+
}, children: "恢复对话" })
|
|
896
|
+
] }) : null
|
|
897
|
+
] });
|
|
898
|
+
}
|
|
899
|
+
function Na({
|
|
900
|
+
message: e,
|
|
901
|
+
manager: t
|
|
902
|
+
}) {
|
|
903
|
+
const [s, o] = C(!1), [n, r] = C(""), [u, g] = C(""), _ = t.feedbackBusy.includes(e.id);
|
|
904
|
+
if (!e.persistent || e.role !== "assistant" || e.intermediate)
|
|
905
|
+
return null;
|
|
906
|
+
const p = e.feedback?.rating ?? "none";
|
|
907
|
+
return /* @__PURE__ */ c("div", { className: "make-ai-assistant__feedback", "aria-label": "回答反馈", children: [
|
|
908
|
+
/* @__PURE__ */ a(
|
|
909
|
+
"button",
|
|
910
|
+
{
|
|
911
|
+
type: "button",
|
|
912
|
+
"aria-label": "点赞",
|
|
913
|
+
"aria-pressed": p === "like",
|
|
914
|
+
disabled: _,
|
|
915
|
+
onClick: () => {
|
|
916
|
+
t.feedback(e, p === "like" ? "none" : "like");
|
|
917
|
+
},
|
|
918
|
+
children: "赞"
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
/* @__PURE__ */ a(
|
|
922
|
+
"button",
|
|
923
|
+
{
|
|
924
|
+
type: "button",
|
|
925
|
+
"aria-label": "点踩",
|
|
926
|
+
"aria-pressed": p === "dislike",
|
|
927
|
+
disabled: _,
|
|
928
|
+
onClick: () => {
|
|
929
|
+
if (p === "dislike") {
|
|
930
|
+
t.feedback(e, "none");
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
r(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), o(!0);
|
|
934
|
+
},
|
|
935
|
+
children: "踩"
|
|
936
|
+
}
|
|
937
|
+
),
|
|
938
|
+
p === "dislike" ? /* @__PURE__ */ a(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
type: "button",
|
|
942
|
+
disabled: _,
|
|
943
|
+
onClick: () => {
|
|
944
|
+
r(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), o(!0);
|
|
945
|
+
},
|
|
946
|
+
children: "修改反馈"
|
|
947
|
+
}
|
|
948
|
+
) : null,
|
|
949
|
+
s ? /* @__PURE__ */ c(
|
|
950
|
+
"form",
|
|
951
|
+
{
|
|
952
|
+
onSubmit: ($) => {
|
|
953
|
+
$.preventDefault(), t.feedback(e, "dislike", n, u).then((L) => {
|
|
954
|
+
L && o(!1);
|
|
955
|
+
});
|
|
956
|
+
},
|
|
957
|
+
children: [
|
|
958
|
+
/* @__PURE__ */ a(
|
|
959
|
+
"input",
|
|
960
|
+
{
|
|
961
|
+
"aria-label": "反馈原因",
|
|
962
|
+
maxLength: 128,
|
|
963
|
+
value: n,
|
|
964
|
+
onChange: ($) => r($.currentTarget.value),
|
|
965
|
+
placeholder: "原因(可选)"
|
|
966
|
+
}
|
|
967
|
+
),
|
|
968
|
+
/* @__PURE__ */ a(
|
|
969
|
+
"textarea",
|
|
970
|
+
{
|
|
971
|
+
"aria-label": "反馈说明",
|
|
972
|
+
maxLength: 4e3,
|
|
973
|
+
value: u,
|
|
974
|
+
onChange: ($) => g($.currentTarget.value),
|
|
975
|
+
placeholder: "补充说明(可选)"
|
|
976
|
+
}
|
|
977
|
+
),
|
|
978
|
+
/* @__PURE__ */ a("button", { type: "submit", disabled: _, children: "提交反馈" }),
|
|
979
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => o(!1), children: "取消" })
|
|
980
|
+
]
|
|
981
|
+
}
|
|
982
|
+
) : null
|
|
983
|
+
] });
|
|
984
|
+
}
|
|
985
|
+
const Lt = /* @__PURE__ */ new Set([
|
|
986
|
+
"image/png",
|
|
987
|
+
"image/jpeg",
|
|
988
|
+
"image/webp",
|
|
989
|
+
"image/gif",
|
|
990
|
+
"audio/mpeg",
|
|
991
|
+
"audio/wav",
|
|
992
|
+
"audio/ogg",
|
|
993
|
+
"audio/webm",
|
|
994
|
+
"video/mp4",
|
|
995
|
+
"video/webm",
|
|
996
|
+
"video/ogg"
|
|
997
|
+
]);
|
|
998
|
+
function Ra({
|
|
999
|
+
part: e,
|
|
1000
|
+
context: t,
|
|
1001
|
+
transport: s,
|
|
1002
|
+
chatId: o
|
|
1003
|
+
}) {
|
|
1004
|
+
const [n, r] = C(), [u, g] = C(), [_, p] = C(!1), $ = R([]), L = R(void 0);
|
|
1005
|
+
ue(
|
|
1006
|
+
() => () => {
|
|
1007
|
+
L.current?.abort(), $.current.forEach((K) => URL.revokeObjectURL(K));
|
|
1008
|
+
},
|
|
1009
|
+
[]
|
|
1010
|
+
);
|
|
1011
|
+
const X = async (K) => {
|
|
1012
|
+
if (!s.readContent || _) return;
|
|
1013
|
+
const v = new AbortController();
|
|
1014
|
+
L.current = v, p(!0), g(void 0);
|
|
1015
|
+
try {
|
|
1016
|
+
const j = await s.readContent(
|
|
1017
|
+
t,
|
|
1018
|
+
{ chatId: o, contentRef: e.media.contentRef },
|
|
1019
|
+
{ signal: v.signal }
|
|
1020
|
+
);
|
|
1021
|
+
if (v.signal.aborted) return;
|
|
1022
|
+
const te = new Blob([new Uint8Array(j).buffer], {
|
|
1023
|
+
type: K && Lt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
|
|
1024
|
+
}), Z = URL.createObjectURL(te);
|
|
1025
|
+
if ($.current.push(Z), K) r(Z);
|
|
1026
|
+
else {
|
|
1027
|
+
const f = document.createElement("a");
|
|
1028
|
+
f.href = Z, f.download = e.name ?? "attachment", f.click();
|
|
1029
|
+
}
|
|
1030
|
+
} catch (j) {
|
|
1031
|
+
v.signal.aborted || g(kt(j));
|
|
1032
|
+
} finally {
|
|
1033
|
+
v.signal.aborted || p(!1);
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment", children: [
|
|
1037
|
+
/* @__PURE__ */ c("span", { children: [
|
|
1038
|
+
e.name ?? "附件",
|
|
1039
|
+
" · ",
|
|
1040
|
+
e.media.sizeBytes,
|
|
1041
|
+
" 字节"
|
|
1042
|
+
] }),
|
|
1043
|
+
/* @__PURE__ */ a("button", { type: "button", disabled: _, onClick: () => {
|
|
1044
|
+
X(!1);
|
|
1045
|
+
}, children: "下载附件" }),
|
|
1046
|
+
Lt.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: _, onClick: () => {
|
|
1047
|
+
X(!0);
|
|
1048
|
+
}, children: "预览附件" }) : null,
|
|
1049
|
+
u ? /* @__PURE__ */ a("span", { role: "alert", children: u }) : null,
|
|
1050
|
+
n && e.kind === "image" ? /* @__PURE__ */ a("img", { src: n, alt: e.name ?? "附件图片" }) : null,
|
|
1051
|
+
n && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: n, controls: !0 }) : null,
|
|
1052
|
+
n && e.kind === "video" ? /* @__PURE__ */ a("video", { src: n, controls: !0 }) : null
|
|
1053
|
+
] });
|
|
1054
|
+
}
|
|
1055
|
+
function Ea({
|
|
1056
|
+
message: e,
|
|
1057
|
+
context: t,
|
|
1058
|
+
transport: s,
|
|
1059
|
+
chatId: o
|
|
1060
|
+
}) {
|
|
1061
|
+
return /* @__PURE__ */ a(Ce, { children: e.parts?.map(
|
|
1062
|
+
(n, r) => n.kind === "text" ? null : /* @__PURE__ */ a(
|
|
1063
|
+
Ra,
|
|
1064
|
+
{
|
|
1065
|
+
part: n,
|
|
1066
|
+
context: t,
|
|
1067
|
+
transport: s,
|
|
1068
|
+
chatId: o
|
|
1069
|
+
},
|
|
1070
|
+
n.id ?? `${e.id}:${r}`
|
|
1071
|
+
)
|
|
1072
|
+
) });
|
|
1073
|
+
}
|
|
1074
|
+
const Sa = (e, t) => new Promise((s, o) => {
|
|
1075
|
+
const n = new FileReader(), r = () => t.removeEventListener("abort", u), u = () => {
|
|
1076
|
+
n.abort(), r(), o(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
|
|
1077
|
+
};
|
|
1078
|
+
if (t.aborted) {
|
|
1079
|
+
u();
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
t.addEventListener("abort", u, { once: !0 }), n.onload = () => {
|
|
1083
|
+
r(), s(new Uint8Array(n.result));
|
|
1084
|
+
}, n.onerror = () => {
|
|
1085
|
+
r(), o(new Error("无法读取文件"));
|
|
1086
|
+
}, n.readAsArrayBuffer(e);
|
|
1087
|
+
});
|
|
1088
|
+
function xa(e, t, s) {
|
|
1089
|
+
const [o, n] = C([]), r = R(/* @__PURE__ */ new Map()), u = R(Promise.resolve()), g = t.scopeKey?.(e) ?? e.app.id, _ = R(g);
|
|
1090
|
+
_.current = g;
|
|
1091
|
+
const p = R(void 0), $ = s.enabled && t.features?.attachments === !0, L = (d, l) => {
|
|
1092
|
+
!r.current.has(d.draft.id) || d.scope !== _.current || (d.draft = { ...d.draft, ...l }, n([...r.current.values()].map((I) => I.draft)));
|
|
1093
|
+
}, X = () => {
|
|
1094
|
+
for (const d of r.current.values()) d.controller.abort();
|
|
1095
|
+
r.current.clear(), n([]), p.current = void 0, u.current = Promise.resolve();
|
|
1096
|
+
};
|
|
1097
|
+
ue(() => (X(), X), [g, t]), ue(() => {
|
|
1098
|
+
p.current && s.chat?.chatId !== p.current && X();
|
|
1099
|
+
}, [s.chat?.chatId]);
|
|
1100
|
+
const K = async (d) => {
|
|
1101
|
+
const l = d.controller.signal, I = () => {
|
|
1102
|
+
if (l.aborted || d.scope !== _.current || !r.current.has(d.draft.id))
|
|
1103
|
+
throw Object.assign(new Error("Upload aborted"), {
|
|
1104
|
+
name: "AbortError"
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
try {
|
|
1108
|
+
if (I(), d.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
|
|
1109
|
+
const E = await s.ensureChat();
|
|
1110
|
+
I(), p.current = E.chatId;
|
|
1111
|
+
const ie = d.file.type.split(";")[0].trim().toLowerCase() || "application/octet-stream";
|
|
1112
|
+
L(d, { status: "uploading", error: void 0 });
|
|
1113
|
+
let M = d.draft.upload ? await t.getUpload(
|
|
1114
|
+
e,
|
|
1115
|
+
{ chatId: E.chatId, uploadId: d.draft.upload.id },
|
|
1116
|
+
{ signal: l }
|
|
1117
|
+
) : await t.startUpload(
|
|
1118
|
+
e,
|
|
1119
|
+
{
|
|
1120
|
+
chatId: E.chatId,
|
|
1121
|
+
fileId: d.draft.fileId,
|
|
1122
|
+
name: d.file.name,
|
|
1123
|
+
contentType: ie,
|
|
1124
|
+
sizeBytes: d.file.size
|
|
1125
|
+
},
|
|
1126
|
+
{ signal: l }
|
|
1127
|
+
);
|
|
1128
|
+
if (I(), L(d, { upload: M }), M.name !== d.file.name || M.contentType !== ie || M.sizeBytes !== d.file.size)
|
|
1129
|
+
throw new Error("上传文件身份不一致");
|
|
1130
|
+
if (M.status !== "ready") {
|
|
1131
|
+
M = await t.getUpload(
|
|
1132
|
+
e,
|
|
1133
|
+
{ chatId: E.chatId, uploadId: M.id },
|
|
1134
|
+
{ signal: l }
|
|
1135
|
+
), I();
|
|
1136
|
+
const J = new Set(M.completedParts), V = Math.ceil(d.file.size / M.partSize);
|
|
1137
|
+
for (let D = 0; D < V; D += 1) {
|
|
1138
|
+
if (I(), !J.has(D)) {
|
|
1139
|
+
const Q = await Sa(
|
|
1140
|
+
d.file.slice(
|
|
1141
|
+
D * M.partSize,
|
|
1142
|
+
Math.min(d.file.size, (D + 1) * M.partSize)
|
|
1143
|
+
),
|
|
1144
|
+
l
|
|
1145
|
+
);
|
|
1146
|
+
I(), await t.uploadPart(
|
|
1147
|
+
e,
|
|
1148
|
+
{ chatId: E.chatId, uploadId: M.id, part: D, bytes: Q },
|
|
1149
|
+
{ signal: l }
|
|
1150
|
+
), I(), J.add(D);
|
|
1151
|
+
}
|
|
1152
|
+
L(d, { progress: J.size / Math.max(V, 1) });
|
|
1153
|
+
}
|
|
1154
|
+
L(d, { status: "completing" }), M = await t.completeUpload(
|
|
1155
|
+
e,
|
|
1156
|
+
{ chatId: E.chatId, uploadId: M.id },
|
|
1157
|
+
{ signal: l }
|
|
1158
|
+
), I();
|
|
1159
|
+
}
|
|
1160
|
+
if (M.status !== "ready" || !M.content)
|
|
1161
|
+
throw new Error("上传尚未完成");
|
|
1162
|
+
L(d, { status: "ready", progress: 1, upload: M });
|
|
1163
|
+
} catch (E) {
|
|
1164
|
+
L(d, {
|
|
1165
|
+
status: l.aborted ? "paused" : "failed",
|
|
1166
|
+
error: l.aborted ? void 0 : kt(E)
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}, v = (d) => {
|
|
1170
|
+
if ($) {
|
|
1171
|
+
if (d.length + r.current.size > 32) {
|
|
1172
|
+
s.setError("每条消息最多包含 32 个附件或文本片段");
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
for (const l of d) {
|
|
1176
|
+
const I = {
|
|
1177
|
+
id: We(),
|
|
1178
|
+
fileId: We(),
|
|
1179
|
+
name: l.name,
|
|
1180
|
+
size: l.size,
|
|
1181
|
+
status: "queued",
|
|
1182
|
+
progress: 0
|
|
1183
|
+
}, E = {
|
|
1184
|
+
draft: I,
|
|
1185
|
+
file: l,
|
|
1186
|
+
controller: new AbortController(),
|
|
1187
|
+
scope: g
|
|
1188
|
+
};
|
|
1189
|
+
r.current.set(I.id, E), u.current = u.current.then(() => K(E));
|
|
1190
|
+
}
|
|
1191
|
+
n([...r.current.values()].map((l) => l.draft));
|
|
1192
|
+
}
|
|
1193
|
+
}, j = (d) => {
|
|
1194
|
+
const l = r.current.get(d);
|
|
1195
|
+
!l || !["paused", "failed"].includes(l.draft.status) || (l.controller = new AbortController(), L(l, { status: "queued" }), u.current = u.current.then(() => K(l)));
|
|
1196
|
+
}, te = (d) => {
|
|
1197
|
+
r.current.get(d)?.controller.abort(), r.current.delete(d), n([...r.current.values()].map((I) => I.draft));
|
|
1198
|
+
}, Z = (d) => r.current.get(d)?.controller.abort(), f = o.flatMap((d) => {
|
|
1199
|
+
const l = d.upload;
|
|
1200
|
+
if (d.status !== "ready" || !l?.content) return [];
|
|
1201
|
+
const I = l.contentType.startsWith("image/") && l.contentType !== "image/svg+xml" ? "image" : l.contentType.startsWith("audio/") ? "audio" : l.contentType.startsWith("video/") ? "video" : "file";
|
|
1202
|
+
return [
|
|
1203
|
+
{
|
|
1204
|
+
id: d.id,
|
|
1205
|
+
kind: I,
|
|
1206
|
+
name: l.name,
|
|
1207
|
+
media: {
|
|
1208
|
+
contentRef: l.content.contentRef,
|
|
1209
|
+
contentType: l.contentType,
|
|
1210
|
+
sizeBytes: l.content.sizeBytes,
|
|
1211
|
+
digestSha256: l.content.digestSha256
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
];
|
|
1215
|
+
});
|
|
1216
|
+
return {
|
|
1217
|
+
enabled: $,
|
|
1218
|
+
drafts: o,
|
|
1219
|
+
parts: f,
|
|
1220
|
+
pending: o.some((d) => d.status !== "ready"),
|
|
1221
|
+
add: v,
|
|
1222
|
+
retry: j,
|
|
1223
|
+
remove: te,
|
|
1224
|
+
pause: Z,
|
|
1225
|
+
clear: X
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
function $a({
|
|
1229
|
+
attachments: e
|
|
1230
|
+
}) {
|
|
1231
|
+
return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment-composer", children: [
|
|
1232
|
+
/* @__PURE__ */ c("label", { children: [
|
|
1233
|
+
"添加附件",
|
|
1234
|
+
/* @__PURE__ */ a(
|
|
1235
|
+
"input",
|
|
1236
|
+
{
|
|
1237
|
+
"aria-label": "添加附件",
|
|
1238
|
+
type: "file",
|
|
1239
|
+
multiple: !0,
|
|
1240
|
+
onChange: (t) => {
|
|
1241
|
+
e.add(Array.from(t.currentTarget.files ?? [])), t.currentTarget.value = "";
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
)
|
|
1245
|
+
] }),
|
|
1246
|
+
/* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ c("li", { children: [
|
|
1247
|
+
/* @__PURE__ */ c("span", { children: [
|
|
1248
|
+
t.name,
|
|
1249
|
+
" ·",
|
|
1250
|
+
" ",
|
|
1251
|
+
t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%`
|
|
1252
|
+
] }),
|
|
1253
|
+
t.error ? /* @__PURE__ */ a("span", { role: "alert", children: t.error }) : null,
|
|
1254
|
+
t.status === "failed" || t.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(t.id), children: "重试上传" }) : null,
|
|
1255
|
+
t.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(t.id), children: "暂停上传" }) : null,
|
|
1256
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => e.remove(t.id), children: "移除附件" })
|
|
1257
|
+
] }, t.id)) })
|
|
1258
|
+
] });
|
|
1259
|
+
}
|
|
1260
|
+
const La = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Da = "Make", Pa = [
|
|
345
1261
|
"总结当前页面数据",
|
|
346
1262
|
"找出需要关注的记录",
|
|
347
1263
|
"列出我有权限查看的数据对象"
|
|
348
|
-
],
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
s *
|
|
1264
|
+
], Xt = (e, t) => t ?? `${e?.trim() || Da} AI 助手`, Fa = (e) => e ?? Pa, za = /^只读分析\s*[·•]\s*/u, Ba = (e, t) => e?.trim().replace(za, "").trim() || `当前对象:${t ?? "未命名应用"}`, Ha = 480, Yt = 1024, Wa = 0.72, Dt = 16, _e = 16, Ze = 8, ft = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), Ua = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, Oa = (e, t, s) => {
|
|
1265
|
+
const o = Math.min(
|
|
1266
|
+
Yt,
|
|
1267
|
+
s * Wa
|
|
352
1268
|
);
|
|
353
|
-
return Math.max(e, Math.min(t ??
|
|
354
|
-
},
|
|
1269
|
+
return Math.max(e, Math.min(t ?? o, s));
|
|
1270
|
+
}, Pt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), qa = (e, t, s, o) => {
|
|
355
1271
|
const n = Math.min(
|
|
356
1272
|
Math.max(t.width, 1),
|
|
357
|
-
Math.max(1,
|
|
358
|
-
),
|
|
1273
|
+
Math.max(1, o - _e * 2)
|
|
1274
|
+
), r = Math.min(
|
|
359
1275
|
Math.max(t.height, 1),
|
|
360
|
-
Math.max(1, s -
|
|
361
|
-
),
|
|
1276
|
+
Math.max(1, s - _e * 2)
|
|
1277
|
+
), u = e.left + e.width / 2, g = e.top + e.height / 2, p = [
|
|
362
1278
|
{
|
|
363
|
-
left: e.right +
|
|
1279
|
+
left: e.right + Ze,
|
|
364
1280
|
placement: "right",
|
|
365
|
-
top:
|
|
1281
|
+
top: g - r / 2
|
|
366
1282
|
},
|
|
367
1283
|
{
|
|
368
|
-
left: e.left -
|
|
1284
|
+
left: e.left - Ze - n,
|
|
369
1285
|
placement: "left",
|
|
370
|
-
top:
|
|
1286
|
+
top: g - r / 2
|
|
371
1287
|
},
|
|
372
1288
|
{
|
|
373
|
-
left:
|
|
1289
|
+
left: u - n / 2,
|
|
374
1290
|
placement: "bottom",
|
|
375
|
-
top: e.bottom +
|
|
1291
|
+
top: e.bottom + Ze
|
|
376
1292
|
},
|
|
377
1293
|
{
|
|
378
|
-
left:
|
|
1294
|
+
left: u - n / 2,
|
|
379
1295
|
placement: "top",
|
|
380
|
-
top: e.top -
|
|
1296
|
+
top: e.top - Ze - r
|
|
381
1297
|
}
|
|
382
1298
|
].find(
|
|
383
|
-
({ left:
|
|
1299
|
+
({ left: $, top: L }) => $ >= _e && L >= _e && $ + n <= o - _e && L + r <= s - _e
|
|
384
1300
|
);
|
|
385
1301
|
return p || {
|
|
386
|
-
left:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
1302
|
+
left: Pt(
|
|
1303
|
+
u - n / 2,
|
|
1304
|
+
_e,
|
|
1305
|
+
o - _e - n
|
|
390
1306
|
),
|
|
391
1307
|
placement: "bottom",
|
|
392
|
-
top:
|
|
393
|
-
e.bottom +
|
|
394
|
-
|
|
395
|
-
s -
|
|
1308
|
+
top: Pt(
|
|
1309
|
+
e.bottom + Ze,
|
|
1310
|
+
_e,
|
|
1311
|
+
s - _e - r
|
|
396
1312
|
)
|
|
397
1313
|
};
|
|
398
|
-
},
|
|
399
|
-
class
|
|
1314
|
+
}, Ka = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
1315
|
+
class G extends Error {
|
|
400
1316
|
}
|
|
401
|
-
const
|
|
1317
|
+
const dt = (e, t) => {
|
|
402
1318
|
if (!(typeof e != "object" || e === null))
|
|
403
1319
|
return e[t];
|
|
404
|
-
},
|
|
405
|
-
const t =
|
|
406
|
-
return typeof t == "number" ? t :
|
|
407
|
-
|
|
1320
|
+
}, Va = (e) => {
|
|
1321
|
+
const t = dt(e, "status");
|
|
1322
|
+
return typeof t == "number" ? t : dt(
|
|
1323
|
+
dt(e, "response"),
|
|
408
1324
|
"status"
|
|
409
1325
|
);
|
|
410
|
-
},
|
|
411
|
-
const t =
|
|
412
|
-
return
|
|
1326
|
+
}, ja = (e) => {
|
|
1327
|
+
const t = dt(e, "code"), s = Va(e), o = e instanceof Error ? e.message : "", n = [t, o].filter((_) => typeof _ == "string").join(" ").toLowerCase(), u = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), g = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
|
|
1328
|
+
return u ? {
|
|
413
1329
|
actionLabel: "重新连接",
|
|
414
1330
|
description: "请检查网络后再试。",
|
|
415
1331
|
kind: "network",
|
|
416
1332
|
label: "网络连接",
|
|
417
1333
|
title: "网络连接不可用"
|
|
418
|
-
} :
|
|
1334
|
+
} : g ? {
|
|
419
1335
|
actionLabel: "重新加载",
|
|
420
1336
|
description: "服务暂时未能响应,请稍后重试。",
|
|
421
1337
|
kind: "service",
|
|
@@ -428,7 +1344,7 @@ const $e = (e, t) => {
|
|
|
428
1344
|
label: "加载异常",
|
|
429
1345
|
title: "暂时无法加载对话"
|
|
430
1346
|
};
|
|
431
|
-
},
|
|
1347
|
+
}, Ft = (e) => {
|
|
432
1348
|
try {
|
|
433
1349
|
const t = e?.return?.();
|
|
434
1350
|
if (!t) return;
|
|
@@ -442,7 +1358,7 @@ const $e = (e, t) => {
|
|
|
442
1358
|
errorType: t instanceof Error ? t.name : typeof t
|
|
443
1359
|
});
|
|
444
1360
|
}
|
|
445
|
-
},
|
|
1361
|
+
}, Xa = async (e) => {
|
|
446
1362
|
if (globalThis.navigator?.clipboard?.writeText) {
|
|
447
1363
|
await globalThis.navigator.clipboard.writeText(e);
|
|
448
1364
|
return;
|
|
@@ -454,182 +1370,182 @@ const $e = (e, t) => {
|
|
|
454
1370
|
const s = document.execCommand("copy");
|
|
455
1371
|
if (t.remove(), !s)
|
|
456
1372
|
throw new Error("Clipboard copy failed");
|
|
457
|
-
},
|
|
1373
|
+
}, Gt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
458
1374
|
/* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
|
|
459
1375
|
/* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
|
|
460
|
-
] }),
|
|
1376
|
+
] }), Ya = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ga = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
461
1377
|
/* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
|
|
462
1378
|
/* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
463
|
-
] }),
|
|
1379
|
+
] }), Za = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
464
1380
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
465
1381
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
466
1382
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
467
1383
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
468
|
-
] }),
|
|
1384
|
+
] }), Ja = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
469
1385
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
470
1386
|
/* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
|
|
471
1387
|
/* @__PURE__ */ a("path", { d: "M12 17h.01" })
|
|
472
|
-
] }),
|
|
1388
|
+
] }), Qa = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
473
1389
|
/* @__PURE__ */ a("path", { d: "M12 4v11" }),
|
|
474
1390
|
/* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
|
|
475
1391
|
/* @__PURE__ */ a("path", { d: "M5 20h14" })
|
|
476
|
-
] }),
|
|
1392
|
+
] }), es = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), zt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
477
1393
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
478
1394
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
479
|
-
] }),
|
|
1395
|
+
] }), Zt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
480
1396
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
481
1397
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
482
1398
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
483
1399
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
484
|
-
] }),
|
|
1400
|
+
] }), ts = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
485
1401
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
486
1402
|
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
487
1403
|
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
488
|
-
] }),
|
|
1404
|
+
] }), ut = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Gt, {}) }), as = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, ss = ({
|
|
489
1405
|
userAvatarUrl: e,
|
|
490
1406
|
userName: t
|
|
491
1407
|
}) => {
|
|
492
1408
|
const s = t?.trim();
|
|
493
|
-
return !s && !e ? null : /* @__PURE__ */
|
|
1409
|
+
return !s && !e ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
|
|
494
1410
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
495
|
-
/* @__PURE__ */ a(
|
|
1411
|
+
/* @__PURE__ */ a(as, { src: e })
|
|
496
1412
|
] });
|
|
497
|
-
},
|
|
1413
|
+
}, gt = (e) => {
|
|
498
1414
|
const t = e.trim();
|
|
499
1415
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
500
1416
|
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
501
|
-
},
|
|
502
|
-
const s =
|
|
503
|
-
if (!s || !
|
|
1417
|
+
}, ns = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), rs = (e, t) => {
|
|
1418
|
+
const s = gt(e[t] ?? ""), o = gt(e[t + 1] ?? "");
|
|
1419
|
+
if (!s || !o || s.length !== o.length || !ns(o))
|
|
504
1420
|
return;
|
|
505
1421
|
const n = [];
|
|
506
|
-
let
|
|
507
|
-
for (;
|
|
508
|
-
const
|
|
509
|
-
if (!
|
|
510
|
-
n.push(
|
|
1422
|
+
let r = t + 2;
|
|
1423
|
+
for (; r < e.length; ) {
|
|
1424
|
+
const u = gt(e[r] ?? "");
|
|
1425
|
+
if (!u || u.length !== s.length) break;
|
|
1426
|
+
n.push(u), r += 1;
|
|
511
1427
|
}
|
|
512
|
-
return { headers: s, lastIndex:
|
|
513
|
-
},
|
|
514
|
-
const t = [], s = [],
|
|
1428
|
+
return { headers: s, lastIndex: r - 1, rows: n };
|
|
1429
|
+
}, is = (e) => {
|
|
1430
|
+
const t = [], s = [], o = [], n = [], r = e.replace(/\r\n?/g, `
|
|
515
1431
|
`).split(`
|
|
516
|
-
`),
|
|
1432
|
+
`), u = () => {
|
|
517
1433
|
const p = s.join(`
|
|
518
1434
|
`).trim();
|
|
519
1435
|
s.length = 0, p && t.push({ type: "paragraph", text: p });
|
|
520
|
-
}, m = () => {
|
|
521
|
-
r.length && t.push({ type: "list", items: r.splice(0) });
|
|
522
1436
|
}, g = () => {
|
|
1437
|
+
o.length && t.push({ type: "list", items: o.splice(0) });
|
|
1438
|
+
}, _ = () => {
|
|
523
1439
|
const p = n.join(`
|
|
524
1440
|
`).trim();
|
|
525
1441
|
n.length = 0, p && t.push({ type: "pre", text: p });
|
|
526
1442
|
};
|
|
527
|
-
for (let p = 0; p <
|
|
528
|
-
const
|
|
529
|
-
if (!
|
|
530
|
-
|
|
1443
|
+
for (let p = 0; p < r.length; p += 1) {
|
|
1444
|
+
const $ = r[p] ?? "", L = $.trim();
|
|
1445
|
+
if (!L) {
|
|
1446
|
+
u(), g(), _();
|
|
531
1447
|
continue;
|
|
532
1448
|
}
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
|
|
1449
|
+
const X = rs(r, p);
|
|
1450
|
+
if (X) {
|
|
1451
|
+
u(), g(), _(), t.push({ headers: X.headers, rows: X.rows, type: "table" }), p = X.lastIndex;
|
|
536
1452
|
continue;
|
|
537
1453
|
}
|
|
538
|
-
const
|
|
539
|
-
if (
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
1454
|
+
const K = /^(#{1,6})\s+(.+)$/.exec(L);
|
|
1455
|
+
if (K) {
|
|
1456
|
+
u(), g(), _();
|
|
1457
|
+
const j = (K[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
1458
|
+
j && t.push({
|
|
543
1459
|
type: "heading",
|
|
544
|
-
level:
|
|
545
|
-
text:
|
|
1460
|
+
level: K[1]?.length,
|
|
1461
|
+
text: j
|
|
546
1462
|
});
|
|
547
1463
|
continue;
|
|
548
1464
|
}
|
|
549
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
550
|
-
|
|
1465
|
+
if (/^\s*\|.+\|\s*$/.test($)) {
|
|
1466
|
+
u(), g(), n.push($.trim());
|
|
551
1467
|
continue;
|
|
552
1468
|
}
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
555
|
-
|
|
1469
|
+
const v = /^\s*[-*]\s+(.+)$/.exec($);
|
|
1470
|
+
if (v) {
|
|
1471
|
+
u(), _(), o.push(v[1]?.trim() ?? "");
|
|
556
1472
|
continue;
|
|
557
1473
|
}
|
|
558
|
-
|
|
1474
|
+
g(), _(), s.push(L);
|
|
559
1475
|
}
|
|
560
|
-
return
|
|
561
|
-
},
|
|
1476
|
+
return u(), g(), _(), t;
|
|
1477
|
+
}, Je = (e) => {
|
|
562
1478
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
563
|
-
let
|
|
1479
|
+
let o = 0;
|
|
564
1480
|
for (const n of e.matchAll(s)) {
|
|
565
|
-
const
|
|
566
|
-
|
|
1481
|
+
const r = n[0], u = n.index ?? 0;
|
|
1482
|
+
u > o && t.push(e.slice(o, u)), r.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: r.slice(2, -2) }, `${u}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: r.slice(1, -1) }, `${u}-code`)), o = u + r.length;
|
|
567
1483
|
}
|
|
568
|
-
return
|
|
569
|
-
},
|
|
570
|
-
const t =
|
|
571
|
-
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s,
|
|
1484
|
+
return o < e.length && t.push(e.slice(o)), t;
|
|
1485
|
+
}, Bt = ({ content: e }) => {
|
|
1486
|
+
const t = is(e);
|
|
1487
|
+
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, o) => {
|
|
572
1488
|
if (s.type === "heading") {
|
|
573
1489
|
const n = s.level <= 2 ? "h3" : "h4";
|
|
574
1490
|
return /* @__PURE__ */ a(
|
|
575
1491
|
n,
|
|
576
1492
|
{
|
|
577
1493
|
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
|
|
578
|
-
children:
|
|
1494
|
+
children: Je(s.text)
|
|
579
1495
|
},
|
|
580
|
-
`${
|
|
1496
|
+
`${o}-heading`
|
|
581
1497
|
);
|
|
582
1498
|
}
|
|
583
|
-
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children:
|
|
1499
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Je(s.text) }, `${o}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${o}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
584
1500
|
"div",
|
|
585
1501
|
{
|
|
586
1502
|
"aria-label": "表格内容,可横向滚动",
|
|
587
1503
|
className: "make-ai-assistant__markdown-table-scroll",
|
|
588
1504
|
role: "region",
|
|
589
1505
|
tabIndex: 0,
|
|
590
|
-
children: /* @__PURE__ */
|
|
591
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n,
|
|
592
|
-
/* @__PURE__ */ a("tbody", { children: s.rows.map((n,
|
|
1506
|
+
children: /* @__PURE__ */ c("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
1507
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, r) => /* @__PURE__ */ a("th", { scope: "col", children: Je(n) }, `${r}-${n}`)) }) }),
|
|
1508
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((n, r) => /* @__PURE__ */ a("tr", { children: n.map((u, g) => /* @__PURE__ */ a("td", { children: Je(u) }, `${g}-${u}`)) }, `${r}-${n.join("|")}`)) })
|
|
593
1509
|
] })
|
|
594
1510
|
},
|
|
595
|
-
`${
|
|
596
|
-
) : /* @__PURE__ */ a("ul", { children: s.items.map((n,
|
|
1511
|
+
`${o}-table`
|
|
1512
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, r) => /* @__PURE__ */ a("li", { children: Je(n) }, `${r}-${n}`)) }, `${o}-list`);
|
|
597
1513
|
}) }) : null;
|
|
598
|
-
},
|
|
599
|
-
/* @__PURE__ */ a(
|
|
1514
|
+
}, Jt = ({ assistantName: e }) => /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
|
|
1515
|
+
/* @__PURE__ */ a(ut, { className: "make-ai-assistant__avatar--message" }),
|
|
600
1516
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
601
|
-
] }),
|
|
1517
|
+
] }), Qt = (e) => {
|
|
602
1518
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
603
1519
|
const s = e.messages[t];
|
|
604
1520
|
if (s.role === "assistant" && s.status === "streaming")
|
|
605
1521
|
return s.id;
|
|
606
1522
|
}
|
|
607
|
-
},
|
|
1523
|
+
}, os = (e) => {
|
|
608
1524
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
609
1525
|
if (e.messages[t].role === "user") return t;
|
|
610
1526
|
return -1;
|
|
611
|
-
},
|
|
612
|
-
const t =
|
|
1527
|
+
}, ea = (e) => {
|
|
1528
|
+
const t = os(e);
|
|
613
1529
|
if (!(t < 0))
|
|
614
1530
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
1531
|
+
const o = e.messages[s];
|
|
1532
|
+
if (o.role === "assistant") return o.id;
|
|
617
1533
|
}
|
|
618
|
-
},
|
|
1534
|
+
}, cs = (e) => {
|
|
619
1535
|
if (e.status === "idle")
|
|
620
1536
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
621
1537
|
const s = e.messages[t];
|
|
622
1538
|
if (s.role === "assistant" && s.status === "complete")
|
|
623
1539
|
return s.id;
|
|
624
1540
|
}
|
|
625
|
-
},
|
|
1541
|
+
}, ls = (e) => {
|
|
626
1542
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
627
1543
|
const s = e.messages[t];
|
|
628
1544
|
if (s.role === "user") return s;
|
|
629
1545
|
}
|
|
630
|
-
},
|
|
1546
|
+
}, ds = (e, t) => {
|
|
631
1547
|
const s = e.messages.findIndex(
|
|
632
|
-
(
|
|
1548
|
+
(o) => o.id === t && o.role === "user"
|
|
633
1549
|
);
|
|
634
1550
|
return {
|
|
635
1551
|
...e,
|
|
@@ -638,43 +1554,43 @@ const $e = (e, t) => {
|
|
|
638
1554
|
status: "streaming",
|
|
639
1555
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
640
1556
|
};
|
|
641
|
-
},
|
|
1557
|
+
}, us = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Ht = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, vt = (e, t) => {
|
|
642
1558
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
643
|
-
},
|
|
1559
|
+
}, ta = ({
|
|
644
1560
|
error: e,
|
|
645
1561
|
onRetry: t
|
|
646
|
-
}) => /* @__PURE__ */
|
|
1562
|
+
}) => /* @__PURE__ */ c(
|
|
647
1563
|
"div",
|
|
648
1564
|
{
|
|
649
1565
|
className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
|
|
650
1566
|
"data-error-presentation": "request-failed",
|
|
651
1567
|
role: "alert",
|
|
652
1568
|
children: [
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
1569
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
1570
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ts, {}) }),
|
|
655
1571
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
656
1572
|
] }),
|
|
657
1573
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
658
|
-
e.retryable && t ? /* @__PURE__ */
|
|
1574
|
+
e.retryable && t ? /* @__PURE__ */ c(
|
|
659
1575
|
"button",
|
|
660
1576
|
{
|
|
661
1577
|
className: "make-ai-assistant__retry",
|
|
662
1578
|
type: "button",
|
|
663
1579
|
onClick: t,
|
|
664
1580
|
children: [
|
|
665
|
-
/* @__PURE__ */ a(
|
|
1581
|
+
/* @__PURE__ */ a(Zt, {}),
|
|
666
1582
|
"重新发送"
|
|
667
1583
|
]
|
|
668
1584
|
}
|
|
669
1585
|
) : null
|
|
670
1586
|
]
|
|
671
1587
|
}
|
|
672
|
-
),
|
|
1588
|
+
), ms = ({
|
|
673
1589
|
error: e,
|
|
674
1590
|
onRetry: t
|
|
675
1591
|
}) => {
|
|
676
|
-
const s =
|
|
677
|
-
return /* @__PURE__ */
|
|
1592
|
+
const s = ja(e);
|
|
1593
|
+
return /* @__PURE__ */ c(
|
|
678
1594
|
"section",
|
|
679
1595
|
{
|
|
680
1596
|
"aria-live": "assertive",
|
|
@@ -682,23 +1598,23 @@ const $e = (e, t) => {
|
|
|
682
1598
|
"data-load-failure-kind": s.kind,
|
|
683
1599
|
role: "alert",
|
|
684
1600
|
children: [
|
|
685
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */
|
|
1601
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", children: [
|
|
686
1602
|
/* @__PURE__ */ a("path", { d: "M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z" }),
|
|
687
1603
|
/* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
|
|
688
1604
|
] }) }),
|
|
689
|
-
/* @__PURE__ */
|
|
1605
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__load-failure-copy", children: [
|
|
690
1606
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
|
|
691
1607
|
/* @__PURE__ */ a("h3", { children: s.title }),
|
|
692
1608
|
/* @__PURE__ */ a("p", { children: s.description })
|
|
693
1609
|
] }),
|
|
694
|
-
/* @__PURE__ */
|
|
1610
|
+
/* @__PURE__ */ c(
|
|
695
1611
|
"button",
|
|
696
1612
|
{
|
|
697
1613
|
className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
|
|
698
1614
|
type: "button",
|
|
699
1615
|
onClick: t,
|
|
700
1616
|
children: [
|
|
701
|
-
/* @__PURE__ */ a(
|
|
1617
|
+
/* @__PURE__ */ a(Zt, {}),
|
|
702
1618
|
s.actionLabel
|
|
703
1619
|
]
|
|
704
1620
|
}
|
|
@@ -706,40 +1622,40 @@ const $e = (e, t) => {
|
|
|
706
1622
|
]
|
|
707
1623
|
}
|
|
708
1624
|
);
|
|
709
|
-
},
|
|
1625
|
+
}, aa = ({
|
|
710
1626
|
active: e,
|
|
711
1627
|
steps: t
|
|
712
1628
|
}) => {
|
|
713
1629
|
if (!e || !t?.length) return null;
|
|
714
1630
|
const s = t[t.length - 1] ?? "处理中";
|
|
715
|
-
return /* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */
|
|
717
|
-
/* @__PURE__ */
|
|
1631
|
+
return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", open: !0, children: [
|
|
1632
|
+
/* @__PURE__ */ c("summary", { children: [
|
|
1633
|
+
/* @__PURE__ */ c("span", { className: "make-ai-assistant__progress", role: "status", children: [
|
|
718
1634
|
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
719
1635
|
/* @__PURE__ */ a("span", { children: s })
|
|
720
1636
|
] }),
|
|
721
|
-
/* @__PURE__ */
|
|
1637
|
+
/* @__PURE__ */ c("span", { className: "make-ai-assistant__process-count", children: [
|
|
722
1638
|
t.length,
|
|
723
1639
|
" 步"
|
|
724
1640
|
] })
|
|
725
1641
|
] }),
|
|
726
|
-
/* @__PURE__ */ a("ol", { children: t.map((
|
|
1642
|
+
/* @__PURE__ */ a("ol", { children: t.map((o, n) => /* @__PURE__ */ c(
|
|
727
1643
|
"li",
|
|
728
1644
|
{
|
|
729
1645
|
"data-step-active": n === t.length - 1 ? !0 : void 0,
|
|
730
1646
|
children: [
|
|
731
1647
|
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
732
|
-
/* @__PURE__ */ a("span", { children:
|
|
1648
|
+
/* @__PURE__ */ a("span", { children: o })
|
|
733
1649
|
]
|
|
734
1650
|
},
|
|
735
|
-
`${n}-${
|
|
1651
|
+
`${n}-${o}`
|
|
736
1652
|
)) })
|
|
737
1653
|
] });
|
|
738
|
-
},
|
|
1654
|
+
}, hs = ({
|
|
739
1655
|
copyFeedback: e,
|
|
740
1656
|
onCopy: t,
|
|
741
1657
|
onRegenerate: s
|
|
742
|
-
}) => !t && !s ? null : /* @__PURE__ */
|
|
1658
|
+
}) => !t && !s ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
|
|
743
1659
|
t ? /* @__PURE__ */ a(
|
|
744
1660
|
"button",
|
|
745
1661
|
{
|
|
@@ -748,7 +1664,7 @@ const $e = (e, t) => {
|
|
|
748
1664
|
"data-tooltip": "复制",
|
|
749
1665
|
type: "button",
|
|
750
1666
|
onClick: t,
|
|
751
|
-
children: /* @__PURE__ */ a(
|
|
1667
|
+
children: /* @__PURE__ */ a(Ga, {})
|
|
752
1668
|
}
|
|
753
1669
|
) : null,
|
|
754
1670
|
s ? /* @__PURE__ */ a(
|
|
@@ -759,7 +1675,7 @@ const $e = (e, t) => {
|
|
|
759
1675
|
"data-tooltip": "重新生成",
|
|
760
1676
|
type: "button",
|
|
761
1677
|
onClick: s,
|
|
762
|
-
children: /* @__PURE__ */ a(
|
|
1678
|
+
children: /* @__PURE__ */ a(Za, {})
|
|
763
1679
|
}
|
|
764
1680
|
) : null,
|
|
765
1681
|
e ? /* @__PURE__ */ a(
|
|
@@ -771,424 +1687,464 @@ const $e = (e, t) => {
|
|
|
771
1687
|
children: e.message
|
|
772
1688
|
}
|
|
773
1689
|
) : null
|
|
774
|
-
] }),
|
|
1690
|
+
] }), Wt = ({
|
|
775
1691
|
assistantName: e,
|
|
776
1692
|
error: t,
|
|
777
1693
|
onRetry: s,
|
|
778
|
-
progress:
|
|
1694
|
+
progress: o
|
|
779
1695
|
}) => {
|
|
780
1696
|
const n = t ? "error" : "progress";
|
|
781
|
-
return t?.message ??
|
|
1697
|
+
return t?.message ?? o?.message ? /* @__PURE__ */ a(
|
|
782
1698
|
"article",
|
|
783
1699
|
{
|
|
784
1700
|
"aria-label": `${e}的${n === "error" ? "错误消息" : "状态消息"}`,
|
|
785
1701
|
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${n}`,
|
|
786
1702
|
"data-message-role": "assistant",
|
|
787
1703
|
"data-message-state": n,
|
|
788
|
-
children: /* @__PURE__ */
|
|
789
|
-
/* @__PURE__ */ a(
|
|
790
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
1704
|
+
children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
|
|
1705
|
+
/* @__PURE__ */ a(Jt, { assistantName: e }),
|
|
1706
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ta, { error: t, onRetry: s }) : /* @__PURE__ */ a(aa, { active: !0, steps: o?.steps }) })
|
|
791
1707
|
] })
|
|
792
1708
|
}
|
|
793
1709
|
) : null;
|
|
794
|
-
},
|
|
795
|
-
const
|
|
796
|
-
let
|
|
797
|
-
return e.messages.map((
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1710
|
+
}, ps = (e, t, s, o, n, r, u, g, _, p, $, L, X, K, v, j) => {
|
|
1711
|
+
const te = ea(e), Z = Qt(e), f = cs(e);
|
|
1712
|
+
let d;
|
|
1713
|
+
return e.messages.map((l) => {
|
|
1714
|
+
if (l.intermediate) return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", children: [
|
|
1715
|
+
/* @__PURE__ */ a("summary", { children: "处理过程" }),
|
|
1716
|
+
/* @__PURE__ */ a(Bt, { content: l.content })
|
|
1717
|
+
] }, l.id);
|
|
1718
|
+
const I = l.role === "assistant", E = d;
|
|
1719
|
+
I || (d = l);
|
|
1720
|
+
const ie = l.id === Z, M = l.id === te ? e.error : void 0, J = l.error ?? M, V = !I && !!(_?.trim() || p), D = I ? u : _?.trim() || "用户", Q = I && l.status === "complete" && !J && (l.content.trim() || l.id === f);
|
|
801
1721
|
return /* @__PURE__ */ a(
|
|
802
1722
|
"article",
|
|
803
1723
|
{
|
|
804
|
-
"aria-label": `${
|
|
805
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
806
|
-
"data-message-role":
|
|
807
|
-
"data-message-state":
|
|
808
|
-
"data-message-status":
|
|
809
|
-
"data-message-has-identity":
|
|
810
|
-
children: /* @__PURE__ */
|
|
811
|
-
|
|
812
|
-
/* @__PURE__ */
|
|
813
|
-
|
|
1724
|
+
"aria-label": `${D}的消息`,
|
|
1725
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${l.role}`,
|
|
1726
|
+
"data-message-role": l.role,
|
|
1727
|
+
"data-message-state": J ? "error" : void 0,
|
|
1728
|
+
"data-message-status": l.status,
|
|
1729
|
+
"data-message-has-identity": I || V ? !0 : void 0,
|
|
1730
|
+
children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
|
|
1731
|
+
I ? /* @__PURE__ */ a(Jt, { assistantName: u }) : V ? /* @__PURE__ */ a(ss, { userAvatarUrl: p, userName: _ }) : null,
|
|
1732
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__message-stack", children: [
|
|
1733
|
+
I && l.responseId && e.responses?.[l.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
|
|
1734
|
+
l.content ? I ? /* @__PURE__ */ a(Bt, { content: l.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: l.content }) : l.status === "streaming" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__typing", "aria-label": `${u}正在思考`, children: [
|
|
814
1735
|
/* @__PURE__ */ a("span", {}),
|
|
815
1736
|
/* @__PURE__ */ a("span", {}),
|
|
816
1737
|
/* @__PURE__ */ a("span", {})
|
|
817
1738
|
] }) : null,
|
|
818
|
-
|
|
819
|
-
|
|
1739
|
+
I ? /* @__PURE__ */ a(
|
|
1740
|
+
aa,
|
|
820
1741
|
{
|
|
821
|
-
active:
|
|
822
|
-
steps:
|
|
1742
|
+
active: ie && e.status === "streaming",
|
|
1743
|
+
steps: l.progressSteps
|
|
823
1744
|
}
|
|
824
1745
|
) : null,
|
|
825
|
-
|
|
826
|
-
|
|
1746
|
+
J ? /* @__PURE__ */ a(
|
|
1747
|
+
ta,
|
|
827
1748
|
{
|
|
828
|
-
error:
|
|
829
|
-
onRetry:
|
|
1749
|
+
error: J,
|
|
1750
|
+
onRetry: M ? g : void 0
|
|
830
1751
|
}
|
|
831
1752
|
) : null,
|
|
832
|
-
|
|
833
|
-
|
|
1753
|
+
l.artifacts.map((pe) => /* @__PURE__ */ a(
|
|
1754
|
+
fa,
|
|
834
1755
|
{
|
|
835
|
-
artifact:
|
|
1756
|
+
artifact: pe,
|
|
836
1757
|
context: t,
|
|
837
1758
|
onAction: n,
|
|
838
|
-
onActionError:
|
|
1759
|
+
onActionError: r,
|
|
839
1760
|
registry: s,
|
|
840
|
-
theme:
|
|
1761
|
+
theme: o
|
|
841
1762
|
},
|
|
842
|
-
|
|
1763
|
+
pe.id
|
|
843
1764
|
)),
|
|
844
|
-
|
|
845
|
-
|
|
1765
|
+
v && j && e.threadId ? /* @__PURE__ */ a(Ea, { message: l, context: t, transport: j, chatId: e.threadId }) : null,
|
|
1766
|
+
v && j?.features?.feedback ? /* @__PURE__ */ a(Na, { message: l, manager: v }) : null,
|
|
1767
|
+
Q ? /* @__PURE__ */ a(
|
|
1768
|
+
hs,
|
|
846
1769
|
{
|
|
847
|
-
copyFeedback:
|
|
848
|
-
message:
|
|
849
|
-
status:
|
|
1770
|
+
copyFeedback: $?.messageId === l.id ? {
|
|
1771
|
+
message: $.message,
|
|
1772
|
+
status: $.status
|
|
850
1773
|
} : void 0,
|
|
851
|
-
onCopy:
|
|
852
|
-
onRegenerate:
|
|
853
|
-
userMessage:
|
|
854
|
-
assistantMessage:
|
|
1774
|
+
onCopy: l.content.trim() ? () => X(l.id, l.content) : void 0,
|
|
1775
|
+
onRegenerate: L && l.id === f && E ? () => K({
|
|
1776
|
+
userMessage: E,
|
|
1777
|
+
assistantMessage: l
|
|
855
1778
|
}) : void 0
|
|
856
1779
|
}
|
|
857
1780
|
) : null
|
|
858
1781
|
] })
|
|
859
1782
|
] })
|
|
860
1783
|
},
|
|
861
|
-
|
|
1784
|
+
`${e.threadId ?? "local"}:${l.id}`
|
|
862
1785
|
);
|
|
863
1786
|
});
|
|
864
1787
|
};
|
|
865
|
-
function
|
|
1788
|
+
function sa({
|
|
866
1789
|
assistantName: e = "AI 助手",
|
|
867
1790
|
brandName: t,
|
|
868
1791
|
context: s,
|
|
869
|
-
onAction:
|
|
1792
|
+
onAction: o,
|
|
870
1793
|
onActionError: n,
|
|
871
|
-
onClose:
|
|
872
|
-
onNewConversation:
|
|
873
|
-
headerHeight:
|
|
874
|
-
privacyNotice:
|
|
1794
|
+
onClose: r,
|
|
1795
|
+
onNewConversation: u,
|
|
1796
|
+
headerHeight: g,
|
|
1797
|
+
privacyNotice: _,
|
|
875
1798
|
registry: p,
|
|
876
|
-
subtitle:
|
|
877
|
-
suggestions:
|
|
878
|
-
title:
|
|
879
|
-
theme:
|
|
880
|
-
transport:
|
|
881
|
-
userAvatarUrl:
|
|
882
|
-
userName:
|
|
883
|
-
visible:
|
|
1799
|
+
subtitle: $,
|
|
1800
|
+
suggestions: L,
|
|
1801
|
+
title: X,
|
|
1802
|
+
theme: K,
|
|
1803
|
+
transport: v,
|
|
1804
|
+
userAvatarUrl: j,
|
|
1805
|
+
userName: te,
|
|
1806
|
+
visible: Z
|
|
884
1807
|
}) {
|
|
885
|
-
const
|
|
886
|
-
...
|
|
887
|
-
...
|
|
888
|
-
} : void 0, [
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1808
|
+
const f = Ca(s, v), d = xa(s, v, f), l = Xt(t, X), I = _?.trim(), E = Ba($, s.app.name), ie = Ka(g), M = bt(K), J = M || ie ? {
|
|
1809
|
+
...M,
|
|
1810
|
+
...ie ? { "--make-ai-internal-header-height": ie } : {}
|
|
1811
|
+
} : void 0, [V, D] = C(""), Q = f.enabled ? v.scopeKey?.(s) ?? s.app.id : "";
|
|
1812
|
+
yt(() => {
|
|
1813
|
+
f.enabled && D("");
|
|
1814
|
+
}, [Q, f.enabled]);
|
|
1815
|
+
const [pe, fe] = C(he), B = f.enabled ? f.state : pe, se = f.enabled ? f.setState : fe, oe = R(B);
|
|
1816
|
+
oe.current = B;
|
|
1817
|
+
const [U, S] = C(void 0), [w, W] = C(void 0), [ae, ge] = C(0), [Se, x] = C(() => v.loadConversation ? "loading" : "ready"), ee = f.enabled ? f.loading && !B.messages.length ? "loading" : "ready" : Se, [ce, le] = C(void 0), [qe, Y] = C(!1), [ne, xe] = C(!1), [Me, Ke] = C(void 0), ve = R(void 0), Ne = R(void 0), we = R(0), Qe = R(null), $e = R(null), et = R(null), tt = R(null), at = R(null), st = R(null), ye = R(!0), Re = R(s.app.id), i = R(Z), h = ma(), y = xt(
|
|
1818
|
+
() => p ?? Ta(),
|
|
892
1819
|
[p]
|
|
893
|
-
),
|
|
894
|
-
() =>
|
|
895
|
-
[
|
|
896
|
-
),
|
|
897
|
-
const
|
|
898
|
-
if (!
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
1820
|
+
), k = xt(
|
|
1821
|
+
() => Fa(L),
|
|
1822
|
+
[L]
|
|
1823
|
+
), A = () => {
|
|
1824
|
+
const m = tt.current, F = at.current;
|
|
1825
|
+
if (!m || !F || typeof window > "u") return;
|
|
1826
|
+
const z = qa(
|
|
1827
|
+
m.getBoundingClientRect(),
|
|
1828
|
+
F.getBoundingClientRect(),
|
|
902
1829
|
window.innerHeight,
|
|
903
1830
|
window.innerWidth
|
|
904
1831
|
);
|
|
905
|
-
|
|
906
|
-
(
|
|
1832
|
+
Ke(
|
|
1833
|
+
(q) => q?.left === z.left && q.top === z.top && q.placement === z.placement ? q : z
|
|
907
1834
|
);
|
|
908
|
-
},
|
|
909
|
-
left: `${
|
|
910
|
-
top: `${
|
|
1835
|
+
}, N = () => xe(!0), b = () => xe(!1), O = Me ? {
|
|
1836
|
+
left: `${Me.left}px`,
|
|
1837
|
+
top: `${Me.top}px`
|
|
911
1838
|
} : void 0;
|
|
912
|
-
|
|
913
|
-
if (!ne || !
|
|
914
|
-
|
|
1839
|
+
yt(() => {
|
|
1840
|
+
if (!ne || !I) {
|
|
1841
|
+
Ke(void 0);
|
|
915
1842
|
return;
|
|
916
1843
|
}
|
|
917
|
-
|
|
918
|
-
}, [ne,
|
|
919
|
-
if (!ne || !
|
|
920
|
-
const
|
|
921
|
-
return window.addEventListener("resize",
|
|
922
|
-
window.removeEventListener("resize",
|
|
1844
|
+
A();
|
|
1845
|
+
}, [ne, I]), ue(() => {
|
|
1846
|
+
if (!ne || !I) return;
|
|
1847
|
+
const m = () => A();
|
|
1848
|
+
return window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
|
|
1849
|
+
window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
|
|
923
1850
|
};
|
|
924
|
-
}, [ne,
|
|
925
|
-
const
|
|
926
|
-
const
|
|
927
|
-
return !
|
|
1851
|
+
}, [ne, I]);
|
|
1852
|
+
const P = (m) => {
|
|
1853
|
+
const F = ve.current, z = Ne.current?.iterator;
|
|
1854
|
+
return !F && !z ? !1 : (we.current += 1, ve.current = void 0, Ne.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), F?.abort(), Ft(z), !0);
|
|
928
1855
|
};
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}, []),
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1856
|
+
ue(() => () => {
|
|
1857
|
+
P("unmount");
|
|
1858
|
+
}, []), ue(() => {
|
|
1859
|
+
if (f.enabled) return;
|
|
1860
|
+
const m = v.loadConversation, F = Re.current !== s.app.id;
|
|
1861
|
+
if (Re.current = s.app.id, P("reinitialize"), F && (D(""), ye.current = !0), S(void 0), W(void 0), Y(!1), se(he()), !m) {
|
|
1862
|
+
le(void 0), x("ready");
|
|
935
1863
|
return;
|
|
936
1864
|
}
|
|
937
|
-
const
|
|
938
|
-
return
|
|
1865
|
+
const z = new AbortController();
|
|
1866
|
+
return le(void 0), x("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
939
1867
|
appId: s.app.id
|
|
940
|
-
}),
|
|
941
|
-
|
|
1868
|
+
}), m.call(v, s, { signal: z.signal }).then((q) => {
|
|
1869
|
+
z.signal.aborted || (se(he(q)), x("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
942
1870
|
appId: s.app.id,
|
|
943
|
-
messageCount:
|
|
1871
|
+
messageCount: q.messages.length
|
|
944
1872
|
}));
|
|
945
|
-
}).catch((
|
|
946
|
-
|
|
1873
|
+
}).catch((q) => {
|
|
1874
|
+
z.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
947
1875
|
appId: s.app.id,
|
|
948
|
-
errorType:
|
|
949
|
-
}),
|
|
950
|
-
}), () =>
|
|
951
|
-
}, [s.app.id,
|
|
952
|
-
const
|
|
953
|
-
if (!
|
|
954
|
-
|
|
955
|
-
const
|
|
956
|
-
if (!
|
|
957
|
-
const
|
|
958
|
-
|
|
1876
|
+
errorType: q instanceof Error ? q.name : typeof q
|
|
1877
|
+
}), le(q), x("error"));
|
|
1878
|
+
}), () => z.abort();
|
|
1879
|
+
}, [s.app.id, ae, v, f.enabled]), ue(() => {
|
|
1880
|
+
const m = $e.current;
|
|
1881
|
+
if (!m || !ye.current) return;
|
|
1882
|
+
Y(!1);
|
|
1883
|
+
const F = requestAnimationFrame(() => {
|
|
1884
|
+
if (!ye.current) return;
|
|
1885
|
+
const z = B.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
1886
|
+
vt(m, z);
|
|
959
1887
|
});
|
|
960
|
-
return () => cancelAnimationFrame(
|
|
961
|
-
}, [
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
} else
|
|
971
|
-
const
|
|
972
|
-
(
|
|
1888
|
+
return () => cancelAnimationFrame(F);
|
|
1889
|
+
}, [B.messages, B.progress, B.status]), ue(() => {
|
|
1890
|
+
const m = Z && !i.current;
|
|
1891
|
+
if (i.current = Z, !m) return;
|
|
1892
|
+
const F = requestAnimationFrame(() => {
|
|
1893
|
+
const z = $e.current;
|
|
1894
|
+
if (z && ye.current) {
|
|
1895
|
+
Y(!1);
|
|
1896
|
+
const je = oe.current.status === "streaming" ? "auto" : Ht();
|
|
1897
|
+
vt(z, je);
|
|
1898
|
+
} else z && Y(oe.current.messages.length > 0);
|
|
1899
|
+
const q = et.current;
|
|
1900
|
+
(q && !q.disabled ? q : st.current ?? Qe.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
973
1901
|
});
|
|
974
|
-
return () => cancelAnimationFrame(
|
|
975
|
-
}, [
|
|
976
|
-
const
|
|
977
|
-
const
|
|
978
|
-
if (!
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
},
|
|
982
|
-
const
|
|
983
|
-
if (!
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
},
|
|
988
|
-
const
|
|
989
|
-
if (!
|
|
990
|
-
if (
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
) >
|
|
994
|
-
|
|
995
|
-
`输入内容过长,请控制在 ${
|
|
1902
|
+
return () => cancelAnimationFrame(F);
|
|
1903
|
+
}, [Z]);
|
|
1904
|
+
const H = () => {
|
|
1905
|
+
const m = $e.current;
|
|
1906
|
+
if (!m) return;
|
|
1907
|
+
const F = us(m);
|
|
1908
|
+
ye.current = F, Y(!F && oe.current.messages.length > 0);
|
|
1909
|
+
}, Ie = () => {
|
|
1910
|
+
const m = $e.current;
|
|
1911
|
+
if (!m) return;
|
|
1912
|
+
ye.current = !0, Y(!1);
|
|
1913
|
+
const F = Ht();
|
|
1914
|
+
vt(m, F);
|
|
1915
|
+
}, Ve = async (m, F) => {
|
|
1916
|
+
const z = m.trim(), q = oe.current, Ae = F?.regenerateFrom, je = v.regenerate;
|
|
1917
|
+
if (!z || ee !== "ready" || q.status === "streaming" || ve.current || Ae && !je) return;
|
|
1918
|
+
if (lt(
|
|
1919
|
+
z,
|
|
1920
|
+
de.messageCharacters
|
|
1921
|
+
) > de.messageCharacters) {
|
|
1922
|
+
S(
|
|
1923
|
+
`输入内容过长,请控制在 ${de.messageCharacters} 个字符以内`
|
|
996
1924
|
);
|
|
997
1925
|
return;
|
|
998
1926
|
}
|
|
999
|
-
const
|
|
1000
|
-
id:
|
|
1001
|
-
content:
|
|
1002
|
-
},
|
|
1003
|
-
|
|
1927
|
+
const rt = {
|
|
1928
|
+
id: Ae?.userMessage.id ?? La("user"),
|
|
1929
|
+
content: z
|
|
1930
|
+
}, it = Ae ? ds(q, Ae.userMessage.id) : qt(q, rt), ot = new AbortController(), ze = we.current + 1;
|
|
1931
|
+
we.current = ze, ve.current = ot, S(void 0), W(void 0), Y(!ye.current && q.messages.length > 0), Ae || D(""), se(it);
|
|
1004
1932
|
try {
|
|
1005
|
-
let
|
|
1006
|
-
const
|
|
1933
|
+
let Ee = !1, re, It = 0, At = 0, Tt = 0, mt = 0, Xe = 0;
|
|
1934
|
+
const Ye = /* @__PURE__ */ new Map(), Ct = /* @__PURE__ */ new Set(), Mt = /* @__PURE__ */ new Set(
|
|
1007
1935
|
[
|
|
1008
|
-
...
|
|
1009
|
-
|
|
1936
|
+
...it.messages.map((ct) => ct.id),
|
|
1937
|
+
rt.id
|
|
1010
1938
|
]
|
|
1011
|
-
),
|
|
1012
|
-
let
|
|
1013
|
-
if (
|
|
1014
|
-
if (!
|
|
1015
|
-
throw new
|
|
1016
|
-
|
|
1017
|
-
threadId:
|
|
1018
|
-
message:
|
|
1939
|
+
), Ge = /* @__PURE__ */ new Set(), Nt = pa(y), Rt = { signal: ot.signal };
|
|
1940
|
+
let ht;
|
|
1941
|
+
if (Ae) {
|
|
1942
|
+
if (!je)
|
|
1943
|
+
throw new G("当前 AI 助手不支持重新生成");
|
|
1944
|
+
ht = je({
|
|
1945
|
+
threadId: it.threadId,
|
|
1946
|
+
message: rt,
|
|
1019
1947
|
assistantMessage: {
|
|
1020
|
-
id:
|
|
1021
|
-
content:
|
|
1948
|
+
id: Ae.assistantMessage.id,
|
|
1949
|
+
content: Ae.assistantMessage.content
|
|
1022
1950
|
},
|
|
1023
1951
|
context: s,
|
|
1024
|
-
capabilities:
|
|
1025
|
-
},
|
|
1952
|
+
capabilities: Nt
|
|
1953
|
+
}, Rt);
|
|
1026
1954
|
} else
|
|
1027
|
-
|
|
1955
|
+
ht = v.run(
|
|
1028
1956
|
{
|
|
1029
|
-
threadId:
|
|
1030
|
-
message:
|
|
1957
|
+
threadId: it.threadId,
|
|
1958
|
+
message: rt,
|
|
1031
1959
|
context: s,
|
|
1032
|
-
capabilities:
|
|
1960
|
+
capabilities: Nt
|
|
1033
1961
|
},
|
|
1034
|
-
|
|
1962
|
+
Rt
|
|
1035
1963
|
);
|
|
1036
|
-
const
|
|
1037
|
-
for (
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1040
|
-
let
|
|
1964
|
+
const Et = ht[Symbol.asyncIterator]();
|
|
1965
|
+
for (Ne.current = { iterator: Et, requestVersion: ze }; ; ) {
|
|
1966
|
+
const ct = await Et.next();
|
|
1967
|
+
if (we.current !== ze || ct.done) break;
|
|
1968
|
+
let T;
|
|
1041
1969
|
try {
|
|
1042
|
-
|
|
1043
|
-
} catch (
|
|
1044
|
-
throw new
|
|
1045
|
-
|
|
1970
|
+
T = Ot(ct.value);
|
|
1971
|
+
} catch (me) {
|
|
1972
|
+
throw new G(
|
|
1973
|
+
me instanceof Error ? me.message : "Invalid assistant event"
|
|
1046
1974
|
);
|
|
1047
1975
|
}
|
|
1048
|
-
if (
|
|
1049
|
-
if (
|
|
1050
|
-
throw new
|
|
1051
|
-
if (
|
|
1052
|
-
throw new
|
|
1053
|
-
if (
|
|
1054
|
-
throw new
|
|
1055
|
-
|
|
1976
|
+
if (T.type === "message.start") {
|
|
1977
|
+
if (re !== void 0 && re !== T.runId)
|
|
1978
|
+
throw new G("AI 助手响应 run id 不一致");
|
|
1979
|
+
if (re ??= T.runId, At += 1, At > de.assistantMessagesPerRun)
|
|
1980
|
+
throw new G("AI 助手单次响应消息数量超过限制");
|
|
1981
|
+
if (Mt.has(T.messageId))
|
|
1982
|
+
throw new G("AI 助手响应包含重复的 message id");
|
|
1983
|
+
Mt.add(T.messageId), Ge.add(T.messageId), Ye.set(T.messageId, 0);
|
|
1056
1984
|
}
|
|
1057
|
-
if (
|
|
1058
|
-
if (!
|
|
1059
|
-
throw new
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
|
|
1985
|
+
if (T.type === "message.delta") {
|
|
1986
|
+
if (!Ge.has(T.messageId))
|
|
1987
|
+
throw new G("AI 助手响应事件顺序无效");
|
|
1988
|
+
const me = Ye.get(T.messageId) ?? 0, Be = lt(
|
|
1989
|
+
T.delta,
|
|
1990
|
+
de.messageCharacters - Xe
|
|
1063
1991
|
);
|
|
1064
|
-
if (
|
|
1065
|
-
throw new
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1992
|
+
if (Xe + Be > de.messageCharacters)
|
|
1993
|
+
throw new G("AI 助手响应文本超过大小限制");
|
|
1994
|
+
Xe += Be, Ye.set(
|
|
1995
|
+
T.messageId,
|
|
1996
|
+
me + Be
|
|
1069
1997
|
);
|
|
1070
1998
|
}
|
|
1071
|
-
if (
|
|
1072
|
-
if (!
|
|
1073
|
-
throw new
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
),
|
|
1078
|
-
if (
|
|
1079
|
-
throw new
|
|
1080
|
-
|
|
1999
|
+
if (T.type === "message.replace") {
|
|
2000
|
+
if (!Ge.has(T.messageId))
|
|
2001
|
+
throw new G("AI 助手响应事件顺序无效");
|
|
2002
|
+
const me = Ye.get(T.messageId) ?? 0, Be = lt(
|
|
2003
|
+
T.content,
|
|
2004
|
+
de.messageCharacters
|
|
2005
|
+
), St = Xe - me + Be;
|
|
2006
|
+
if (St > de.messageCharacters)
|
|
2007
|
+
throw new G("AI 助手响应文本超过大小限制");
|
|
2008
|
+
Xe = St, Ye.set(T.messageId, Be);
|
|
1081
2009
|
}
|
|
1082
|
-
if (
|
|
1083
|
-
if (
|
|
1084
|
-
throw new
|
|
1085
|
-
if (
|
|
1086
|
-
throw new
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
2010
|
+
if (T.type === "run.progress") {
|
|
2011
|
+
if (re !== void 0 && re !== T.runId)
|
|
2012
|
+
throw new G("AI 助手响应 run id 不一致");
|
|
2013
|
+
if (re ??= T.runId, Tt += 1, Tt > de.progressStepsPerRun)
|
|
2014
|
+
throw new G("AI 助手处理过程数量超过限制");
|
|
2015
|
+
const me = lt(
|
|
2016
|
+
T.message,
|
|
2017
|
+
de.progressCharactersPerRun - mt
|
|
1090
2018
|
);
|
|
1091
|
-
if (
|
|
1092
|
-
throw new
|
|
1093
|
-
|
|
2019
|
+
if (mt + me > de.progressCharactersPerRun)
|
|
2020
|
+
throw new G("AI 助手处理过程文本超过大小限制");
|
|
2021
|
+
mt += me;
|
|
1094
2022
|
}
|
|
1095
|
-
if (
|
|
1096
|
-
if (!
|
|
1097
|
-
throw new
|
|
1098
|
-
if (
|
|
1099
|
-
throw new
|
|
1100
|
-
if (
|
|
1101
|
-
throw new
|
|
1102
|
-
|
|
2023
|
+
if (T.type === "artifact") {
|
|
2024
|
+
if (!Ge.has(T.messageId))
|
|
2025
|
+
throw new G("AI 助手响应事件顺序无效");
|
|
2026
|
+
if (It += 1, It > de.artifactsPerRun)
|
|
2027
|
+
throw new G("AI 助手单次响应 Artifact 数量超过限制");
|
|
2028
|
+
if (Ct.has(T.artifact.id))
|
|
2029
|
+
throw new G("AI 助手响应包含重复的 Artifact id");
|
|
2030
|
+
Ct.add(T.artifact.id);
|
|
1103
2031
|
}
|
|
1104
|
-
if (
|
|
1105
|
-
throw new
|
|
1106
|
-
if (
|
|
1107
|
-
throw new
|
|
1108
|
-
if (
|
|
1109
|
-
throw new
|
|
1110
|
-
if (
|
|
1111
|
-
|
|
2032
|
+
if (T.type === "message.complete" && !Ge.delete(T.messageId))
|
|
2033
|
+
throw new G("AI 助手响应事件顺序无效");
|
|
2034
|
+
if (T.type === "run.complete" && re !== void 0 && re !== T.runId)
|
|
2035
|
+
throw new G("AI 助手响应 run id 不一致");
|
|
2036
|
+
if (T.type === "run.cancelled" && T.runId !== void 0 && re !== void 0 && re !== T.runId)
|
|
2037
|
+
throw new G("AI 助手响应 run id 不一致");
|
|
2038
|
+
if (se((me) => Te(me, T)), T.type === "error" || T.type === "run.cancelled" || T.type === "run.complete") {
|
|
2039
|
+
Ee = !0;
|
|
1112
2040
|
break;
|
|
1113
2041
|
}
|
|
1114
2042
|
}
|
|
1115
|
-
if (!
|
|
1116
|
-
throw new
|
|
1117
|
-
} catch (
|
|
1118
|
-
if (
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
(
|
|
2043
|
+
if (!Ee)
|
|
2044
|
+
throw new G("AI 助手流式响应在终止事件前结束");
|
|
2045
|
+
} catch (Ee) {
|
|
2046
|
+
if (we.current !== ze) return;
|
|
2047
|
+
if (ot.signal.aborted) {
|
|
2048
|
+
se(
|
|
2049
|
+
(re) => Te(re, { type: "run.cancelled" })
|
|
1122
2050
|
);
|
|
1123
2051
|
return;
|
|
1124
2052
|
}
|
|
1125
2053
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
1126
2054
|
appId: s.app.id,
|
|
1127
|
-
errorType:
|
|
1128
|
-
}),
|
|
1129
|
-
(
|
|
2055
|
+
errorType: Ee instanceof Error ? Ee.name : typeof Ee
|
|
2056
|
+
}), se(
|
|
2057
|
+
(re) => Te(re, {
|
|
1130
2058
|
type: "error",
|
|
1131
2059
|
code: "TRANSPORT_ERROR",
|
|
1132
|
-
message:
|
|
2060
|
+
message: Ee instanceof G ? Ee.message : "连接失败,请重试",
|
|
1133
2061
|
retryable: !0
|
|
1134
2062
|
})
|
|
1135
2063
|
);
|
|
1136
2064
|
} finally {
|
|
1137
|
-
|
|
2065
|
+
we.current === ze && ve.current === ot && (ve.current = void 0), Ne.current?.requestVersion === ze && (Ft(Ne.current.iterator), Ne.current = void 0);
|
|
1138
2066
|
}
|
|
1139
|
-
},
|
|
2067
|
+
}, Le = (m) => {
|
|
2068
|
+
if (f.enabled) {
|
|
2069
|
+
if (d.pending)
|
|
2070
|
+
return S("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
|
|
2071
|
+
if (d.parts.some((q) => !v.features?.modelInputKinds?.includes(q.kind)))
|
|
2072
|
+
return S("当前模型尚未开放此类附件理解,已上传原件可保留或移除"), Promise.resolve();
|
|
2073
|
+
const F = m.trim(), z = d.parts.length ? [...F ? [{ id: We(), kind: "text", text: F }] : [], ...d.parts] : void 0;
|
|
2074
|
+
return D(""), d.clear(), f.send(F, z);
|
|
2075
|
+
}
|
|
2076
|
+
return Ve(m);
|
|
2077
|
+
}, be = (m) => Ve(m.userMessage.content, { regenerateFrom: m }), Pe = async (m, F) => {
|
|
1140
2078
|
try {
|
|
1141
|
-
await
|
|
1142
|
-
} catch (
|
|
2079
|
+
await Xa(F), W({ messageId: m, message: "已复制", status: "success" });
|
|
2080
|
+
} catch (z) {
|
|
1143
2081
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
1144
|
-
errorType:
|
|
1145
|
-
}),
|
|
2082
|
+
errorType: z instanceof Error ? z.name : typeof z
|
|
2083
|
+
}), W({ messageId: m, message: "复制失败", status: "error" });
|
|
2084
|
+
}
|
|
2085
|
+
}, Fe = (m) => {
|
|
2086
|
+
m.preventDefault(), Le(V);
|
|
2087
|
+
}, na = (m) => {
|
|
2088
|
+
m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), Le(V));
|
|
2089
|
+
}, ra = () => {
|
|
2090
|
+
if (f.enabled) {
|
|
2091
|
+
f.stop();
|
|
2092
|
+
return;
|
|
1146
2093
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}, Vt = (c) => {
|
|
1150
|
-
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ae(S));
|
|
1151
|
-
}, qt = () => {
|
|
1152
|
-
Ie("stop") && y(
|
|
1153
|
-
(c) => Ce(c, { type: "run.cancelled" })
|
|
2094
|
+
P("stop") && se(
|
|
2095
|
+
(m) => Te(m, { type: "run.cancelled" })
|
|
1154
2096
|
);
|
|
1155
|
-
},
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
2097
|
+
}, ia = () => {
|
|
2098
|
+
if (f.enabled) {
|
|
2099
|
+
D(""), f.create(), u?.();
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
P("new-conversation"), D(""), S(void 0), W(void 0), Y(!1), ye.current = !0, se(he()), u?.();
|
|
2103
|
+
}, _t = f.enabled && f.cancelling.length ? "停止中" : v.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", oa = Qt(B), ca = ea(B), nt = ls(B), la = typeof v.regenerate == "function" && v.features?.regeneration !== !1, wt = () => {
|
|
2104
|
+
if (f.enabled) {
|
|
2105
|
+
f.retry();
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
nt && Le(nt.content);
|
|
1159
2109
|
};
|
|
1160
|
-
return /* @__PURE__ */
|
|
2110
|
+
return /* @__PURE__ */ c(
|
|
1161
2111
|
"section",
|
|
1162
2112
|
{
|
|
1163
|
-
className:
|
|
1164
|
-
ref:
|
|
1165
|
-
style:
|
|
2113
|
+
className: `make-ai-assistant make-ai-assistant__panel${f.enabled ? " make-ai-assistant__panel--managed" : ""}`,
|
|
2114
|
+
ref: Qe,
|
|
2115
|
+
style: J,
|
|
2116
|
+
onDragOver: (m) => {
|
|
2117
|
+
d.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
|
|
2118
|
+
},
|
|
2119
|
+
onDrop: (m) => {
|
|
2120
|
+
d.enabled && m.dataTransfer.files.length && (m.preventDefault(), d.add(Array.from(m.dataTransfer.files)));
|
|
2121
|
+
},
|
|
1166
2122
|
children: [
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */ a(
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
2123
|
+
/* @__PURE__ */ c("header", { className: "make-ai-assistant__header", children: [
|
|
2124
|
+
/* @__PURE__ */ a(ut, {}),
|
|
2125
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-content", children: [
|
|
2126
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-title-row", children: [
|
|
2127
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: l, children: l }),
|
|
1172
2128
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
|
|
1173
2129
|
] }),
|
|
1174
|
-
/* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */ a("p", { title:
|
|
1176
|
-
|
|
2130
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-context", children: [
|
|
2131
|
+
/* @__PURE__ */ a("p", { title: E, children: E }),
|
|
2132
|
+
I ? /* @__PURE__ */ c(Ce, { children: [
|
|
1177
2133
|
/* @__PURE__ */ a(
|
|
1178
2134
|
"span",
|
|
1179
2135
|
{
|
|
1180
|
-
"aria-describedby":
|
|
1181
|
-
"aria-label": `使用提示:${
|
|
2136
|
+
"aria-describedby": h,
|
|
2137
|
+
"aria-label": `使用提示:${I}`,
|
|
1182
2138
|
className: "make-ai-assistant__header-context-help",
|
|
1183
|
-
"data-tooltip":
|
|
1184
|
-
ref:
|
|
2139
|
+
"data-tooltip": I,
|
|
2140
|
+
ref: tt,
|
|
1185
2141
|
role: "note",
|
|
1186
2142
|
tabIndex: 0,
|
|
1187
|
-
onBlur:
|
|
1188
|
-
onFocus:
|
|
1189
|
-
onPointerEnter:
|
|
1190
|
-
onPointerLeave:
|
|
1191
|
-
children: /* @__PURE__ */ a(
|
|
2143
|
+
onBlur: b,
|
|
2144
|
+
onFocus: N,
|
|
2145
|
+
onPointerEnter: N,
|
|
2146
|
+
onPointerLeave: b,
|
|
2147
|
+
children: /* @__PURE__ */ a(Ja, {})
|
|
1192
2148
|
}
|
|
1193
2149
|
),
|
|
1194
2150
|
/* @__PURE__ */ a(
|
|
@@ -1196,154 +2152,162 @@ function Pt({
|
|
|
1196
2152
|
{
|
|
1197
2153
|
"aria-hidden": !ne,
|
|
1198
2154
|
className: "make-ai-assistant__header-context-tooltip",
|
|
1199
|
-
"data-placement":
|
|
1200
|
-
"data-positioned":
|
|
2155
|
+
"data-placement": Me?.placement,
|
|
2156
|
+
"data-positioned": Me ? !0 : void 0,
|
|
1201
2157
|
"data-visible": ne || void 0,
|
|
1202
|
-
id:
|
|
1203
|
-
ref:
|
|
2158
|
+
id: h,
|
|
2159
|
+
ref: at,
|
|
1204
2160
|
role: "tooltip",
|
|
1205
|
-
style:
|
|
1206
|
-
children:
|
|
2161
|
+
style: O,
|
|
2162
|
+
children: I
|
|
1207
2163
|
}
|
|
1208
2164
|
)
|
|
1209
2165
|
] }) : null
|
|
1210
2166
|
] })
|
|
1211
2167
|
] }),
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
|
|
2168
|
+
/* @__PURE__ */ c("div", { className: "make-ai-assistant__header-actions", children: [
|
|
2169
|
+
v.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
1214
2170
|
"button",
|
|
1215
2171
|
{
|
|
1216
2172
|
"aria-label": "新建对话",
|
|
1217
2173
|
className: "make-ai-assistant__icon-button",
|
|
1218
2174
|
type: "button",
|
|
1219
|
-
onClick:
|
|
1220
|
-
children: /* @__PURE__ */ a(
|
|
2175
|
+
onClick: ia,
|
|
2176
|
+
children: /* @__PURE__ */ a(es, {})
|
|
1221
2177
|
}
|
|
1222
2178
|
) : null,
|
|
1223
|
-
|
|
2179
|
+
r ? /* @__PURE__ */ a(
|
|
1224
2180
|
"button",
|
|
1225
2181
|
{
|
|
1226
|
-
"aria-label": `关闭 ${
|
|
2182
|
+
"aria-label": `关闭 ${l}`,
|
|
1227
2183
|
className: "make-ai-assistant__icon-button",
|
|
1228
2184
|
type: "button",
|
|
1229
|
-
onClick:
|
|
1230
|
-
children: /* @__PURE__ */ a(
|
|
2185
|
+
onClick: r,
|
|
2186
|
+
children: /* @__PURE__ */ a(Ya, {})
|
|
1231
2187
|
}
|
|
1232
2188
|
) : null
|
|
1233
2189
|
] })
|
|
1234
2190
|
] }),
|
|
1235
|
-
/* @__PURE__ */
|
|
2191
|
+
f.enabled ? /* @__PURE__ */ a(Ma, { manager: f }) : null,
|
|
2192
|
+
/* @__PURE__ */ c(
|
|
1236
2193
|
"div",
|
|
1237
2194
|
{
|
|
1238
2195
|
className: "make-ai-assistant__body",
|
|
1239
2196
|
"aria-live": "polite",
|
|
1240
2197
|
"aria-relevant": "additions text",
|
|
1241
|
-
ref:
|
|
2198
|
+
ref: $e,
|
|
1242
2199
|
role: "log",
|
|
1243
|
-
onScroll:
|
|
2200
|
+
onScroll: H,
|
|
1244
2201
|
children: [
|
|
1245
|
-
|
|
1246
|
-
/* @__PURE__ */ a(
|
|
2202
|
+
ee === "loading" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
2203
|
+
/* @__PURE__ */ a(ut, {}),
|
|
1247
2204
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
1248
2205
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
1249
|
-
] }) :
|
|
1250
|
-
|
|
2206
|
+
] }) : ee === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
2207
|
+
ms,
|
|
1251
2208
|
{
|
|
1252
|
-
error:
|
|
1253
|
-
onRetry: () =>
|
|
2209
|
+
error: ce,
|
|
2210
|
+
onRetry: () => ge((m) => m + 1)
|
|
1254
2211
|
}
|
|
1255
|
-
) }) :
|
|
1256
|
-
/* @__PURE__ */ a(
|
|
2212
|
+
) }) : B.messages.length === 0 ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", children: [
|
|
2213
|
+
/* @__PURE__ */ a(ut, {}),
|
|
1257
2214
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
1258
2215
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
1259
|
-
] }) :
|
|
1260
|
-
|
|
2216
|
+
] }) : ps(
|
|
2217
|
+
B,
|
|
1261
2218
|
s,
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
2219
|
+
y,
|
|
2220
|
+
K,
|
|
2221
|
+
o,
|
|
1265
2222
|
n,
|
|
1266
2223
|
e,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
(
|
|
1273
|
-
|
|
2224
|
+
nt ? wt : void 0,
|
|
2225
|
+
te,
|
|
2226
|
+
j,
|
|
2227
|
+
w,
|
|
2228
|
+
la,
|
|
2229
|
+
(m, F) => {
|
|
2230
|
+
Pe(m, F);
|
|
1274
2231
|
},
|
|
1275
|
-
(
|
|
1276
|
-
|
|
1277
|
-
}
|
|
2232
|
+
(m) => {
|
|
2233
|
+
be(m);
|
|
2234
|
+
},
|
|
2235
|
+
f.enabled ? f : void 0,
|
|
2236
|
+
v
|
|
1278
2237
|
),
|
|
1279
|
-
|
|
1280
|
-
|
|
2238
|
+
B.progress && !oa ? /* @__PURE__ */ a(
|
|
2239
|
+
Wt,
|
|
1281
2240
|
{
|
|
1282
2241
|
assistantName: e,
|
|
1283
|
-
progress:
|
|
2242
|
+
progress: B.progress
|
|
1284
2243
|
}
|
|
1285
2244
|
) : null,
|
|
1286
|
-
|
|
1287
|
-
|
|
2245
|
+
B.error && !ca ? /* @__PURE__ */ a(
|
|
2246
|
+
Wt,
|
|
1288
2247
|
{
|
|
1289
2248
|
assistantName: e,
|
|
1290
|
-
error:
|
|
1291
|
-
onRetry:
|
|
2249
|
+
error: B.error,
|
|
2250
|
+
onRetry: nt ? wt : void 0
|
|
1292
2251
|
}
|
|
1293
2252
|
) : null
|
|
1294
2253
|
]
|
|
1295
2254
|
}
|
|
1296
2255
|
),
|
|
1297
|
-
|
|
2256
|
+
qe ? /* @__PURE__ */ a(
|
|
1298
2257
|
"button",
|
|
1299
2258
|
{
|
|
1300
2259
|
"aria-label": "回到最新消息",
|
|
1301
2260
|
className: "make-ai-assistant__back-to-latest",
|
|
1302
2261
|
type: "button",
|
|
1303
|
-
onClick:
|
|
1304
|
-
children: /* @__PURE__ */ a(
|
|
2262
|
+
onClick: Ie,
|
|
2263
|
+
children: /* @__PURE__ */ a(Qa, {})
|
|
1305
2264
|
}
|
|
1306
2265
|
) : null,
|
|
1307
|
-
/* @__PURE__ */
|
|
1308
|
-
|
|
2266
|
+
/* @__PURE__ */ c("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
2267
|
+
d.enabled ? /* @__PURE__ */ a($a, { attachments: d }) : null,
|
|
2268
|
+
ee === "ready" && k.length > 0 && B.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: k.map((m, F) => /* @__PURE__ */ a(
|
|
1309
2269
|
"button",
|
|
1310
2270
|
{
|
|
1311
2271
|
type: "button",
|
|
1312
2272
|
onClick: () => {
|
|
1313
|
-
|
|
2273
|
+
Le(m);
|
|
1314
2274
|
},
|
|
1315
|
-
children:
|
|
2275
|
+
children: m
|
|
1316
2276
|
},
|
|
1317
|
-
`${
|
|
2277
|
+
`${F}-${m}`
|
|
1318
2278
|
)) }) : null,
|
|
1319
|
-
/* @__PURE__ */
|
|
2279
|
+
/* @__PURE__ */ c("form", { className: "make-ai-assistant__composer", onSubmit: Fe, children: [
|
|
1320
2280
|
/* @__PURE__ */ a(
|
|
1321
2281
|
"textarea",
|
|
1322
2282
|
{
|
|
1323
2283
|
"aria-label": `向 ${e} 提问`,
|
|
1324
|
-
"aria-describedby":
|
|
1325
|
-
"aria-invalid":
|
|
2284
|
+
"aria-describedby": U ? "make-ai-composer-error" : void 0,
|
|
2285
|
+
"aria-invalid": U ? !0 : void 0,
|
|
1326
2286
|
autoFocus: !0,
|
|
1327
|
-
disabled:
|
|
2287
|
+
disabled: ee !== "ready" || !f.enabled && B.status === "streaming",
|
|
1328
2288
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
1329
|
-
ref:
|
|
2289
|
+
ref: et,
|
|
1330
2290
|
rows: 2,
|
|
1331
|
-
value:
|
|
1332
|
-
onChange: (
|
|
1333
|
-
|
|
2291
|
+
value: V,
|
|
2292
|
+
onChange: (m) => {
|
|
2293
|
+
D(m.currentTarget.value), S(void 0);
|
|
1334
2294
|
},
|
|
1335
|
-
onKeyDown:
|
|
2295
|
+
onKeyDown: na,
|
|
2296
|
+
onPaste: (m) => {
|
|
2297
|
+
d.enabled && m.clipboardData.files.length && (m.preventDefault(), d.add(Array.from(m.clipboardData.files)));
|
|
2298
|
+
}
|
|
1336
2299
|
}
|
|
1337
2300
|
),
|
|
1338
|
-
|
|
2301
|
+
B.status === "streaming" ? /* @__PURE__ */ a(
|
|
1339
2302
|
"button",
|
|
1340
2303
|
{
|
|
1341
|
-
"aria-label":
|
|
2304
|
+
"aria-label": _t,
|
|
1342
2305
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
1343
|
-
"data-tooltip":
|
|
1344
|
-
ref:
|
|
2306
|
+
"data-tooltip": _t,
|
|
2307
|
+
ref: st,
|
|
2308
|
+
disabled: f.enabled && f.cancelling.includes(B.activeRunId ?? ""),
|
|
1345
2309
|
type: "button",
|
|
1346
|
-
onClick:
|
|
2310
|
+
onClick: ra,
|
|
1347
2311
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
1348
2312
|
}
|
|
1349
2313
|
) : /* @__PURE__ */ a(
|
|
@@ -1351,152 +2315,153 @@ function Pt({
|
|
|
1351
2315
|
{
|
|
1352
2316
|
"aria-label": "发送",
|
|
1353
2317
|
className: "make-ai-assistant__send",
|
|
1354
|
-
disabled:
|
|
2318
|
+
disabled: ee !== "ready" || d.pending || !V.trim() && !d.parts.length,
|
|
1355
2319
|
type: "submit",
|
|
1356
|
-
children: /* @__PURE__ */ a(
|
|
2320
|
+
children: /* @__PURE__ */ a(zt, {})
|
|
1357
2321
|
}
|
|
1358
|
-
)
|
|
2322
|
+
),
|
|
2323
|
+
f.enabled && B.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: f.busy || d.pending || !V.trim() && !d.parts.length, type: "submit", children: /* @__PURE__ */ a(zt, {}) }) : null
|
|
1359
2324
|
] }),
|
|
1360
|
-
|
|
2325
|
+
U ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: U }) : null,
|
|
1361
2326
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
1362
2327
|
] })
|
|
1363
2328
|
]
|
|
1364
2329
|
}
|
|
1365
2330
|
);
|
|
1366
2331
|
}
|
|
1367
|
-
function
|
|
1368
|
-
return /* @__PURE__ */ a(
|
|
2332
|
+
function bs(e) {
|
|
2333
|
+
return /* @__PURE__ */ a(sa, { ...e, visible: !0 });
|
|
1369
2334
|
}
|
|
1370
|
-
function
|
|
2335
|
+
function ks({
|
|
1371
2336
|
defaultOpen: e = !1,
|
|
1372
2337
|
hideLauncher: t = !1,
|
|
1373
2338
|
launcher: s,
|
|
1374
|
-
launcherPosition:
|
|
2339
|
+
launcherPosition: o = "bottom-right",
|
|
1375
2340
|
maxDrawerWidth: n,
|
|
1376
|
-
onOpenChange:
|
|
1377
|
-
open:
|
|
1378
|
-
...
|
|
2341
|
+
onOpenChange: r,
|
|
2342
|
+
open: u,
|
|
2343
|
+
...g
|
|
1379
2344
|
}) {
|
|
1380
|
-
const
|
|
1381
|
-
() => e ||
|
|
1382
|
-
),
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
typeof window > "u" ?
|
|
1386
|
-
),
|
|
1387
|
-
...
|
|
1388
|
-
...
|
|
1389
|
-
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${
|
|
2345
|
+
const _ = Xt(g.brandName, g.title), [p, $] = C(e), [L, X] = C(
|
|
2346
|
+
() => e || u === !0
|
|
2347
|
+
), K = R(null), v = R(null), j = R(void 0), [te, Z] = C(), [f, d] = C(Ha), [l, I] = C(!1), E = u ?? p, ie = bt(g.theme), M = Ua(n), J = () => Oa(
|
|
2348
|
+
f,
|
|
2349
|
+
M,
|
|
2350
|
+
typeof window > "u" ? Yt : window.innerWidth
|
|
2351
|
+
), V = J(), D = te === void 0 ? void 0 : ft(te, f, V), Q = D === void 0 && M === void 0 ? void 0 : {
|
|
2352
|
+
...D === void 0 ? {} : { "--make-ai-internal-drawer-width": `${D}px` },
|
|
2353
|
+
...M === void 0 ? {} : {
|
|
2354
|
+
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${M}px)`
|
|
1390
2355
|
}
|
|
1391
2356
|
};
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
}, [
|
|
1395
|
-
const
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1398
|
-
return
|
|
1399
|
-
},
|
|
1400
|
-
if (
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
minimumWidth:
|
|
1404
|
-
pointerId:
|
|
1405
|
-
startWidth:
|
|
1406
|
-
startX:
|
|
1407
|
-
},
|
|
1408
|
-
},
|
|
1409
|
-
const
|
|
1410
|
-
if (!
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
2357
|
+
yt(() => {
|
|
2358
|
+
D !== void 0 && D !== te && Z(D);
|
|
2359
|
+
}, [D, te]);
|
|
2360
|
+
const pe = () => {
|
|
2361
|
+
if (D !== void 0) return D;
|
|
2362
|
+
const w = v.current?.getBoundingClientRect().width;
|
|
2363
|
+
return w && Number.isFinite(w) && w > 0 ? w : f;
|
|
2364
|
+
}, fe = (w) => {
|
|
2365
|
+
if (w.button !== 0) return;
|
|
2366
|
+
const W = pe(), ae = te === void 0 ? W : f;
|
|
2367
|
+
d(ae), j.current = {
|
|
2368
|
+
minimumWidth: ae,
|
|
2369
|
+
pointerId: w.pointerId,
|
|
2370
|
+
startWidth: W,
|
|
2371
|
+
startX: w.clientX
|
|
2372
|
+
}, I(!0), typeof w.currentTarget.setPointerCapture == "function" && w.currentTarget.setPointerCapture(w.pointerId), w.preventDefault();
|
|
2373
|
+
}, B = (w) => {
|
|
2374
|
+
const W = j.current;
|
|
2375
|
+
if (!W || W.pointerId !== w.pointerId) return;
|
|
2376
|
+
const ae = ft(
|
|
2377
|
+
W.startWidth + W.startX - w.clientX,
|
|
2378
|
+
W.minimumWidth,
|
|
2379
|
+
J()
|
|
1415
2380
|
);
|
|
1416
|
-
|
|
1417
|
-
},
|
|
1418
|
-
const
|
|
1419
|
-
!
|
|
1420
|
-
},
|
|
1421
|
-
const
|
|
1422
|
-
if (
|
|
1423
|
-
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
2381
|
+
Z(ae);
|
|
2382
|
+
}, se = (w) => {
|
|
2383
|
+
const W = j.current;
|
|
2384
|
+
!W || W.pointerId !== w.pointerId || (j.current = void 0, I(!1));
|
|
2385
|
+
}, oe = (w) => {
|
|
2386
|
+
const W = w.key === "ArrowLeft" ? Dt : w.key === "ArrowRight" ? -Dt : void 0;
|
|
2387
|
+
if (W === void 0) return;
|
|
2388
|
+
w.preventDefault();
|
|
2389
|
+
const ae = pe(), ge = te === void 0 ? ae : f;
|
|
2390
|
+
d(ge), Z(ft(
|
|
2391
|
+
ae + W,
|
|
2392
|
+
ge,
|
|
2393
|
+
J()
|
|
1429
2394
|
));
|
|
1430
|
-
},
|
|
1431
|
-
|
|
1432
|
-
},
|
|
1433
|
-
return
|
|
1434
|
-
|
|
1435
|
-
}, [
|
|
1436
|
-
if (!
|
|
1437
|
-
const
|
|
1438
|
-
|
|
2395
|
+
}, U = (w) => {
|
|
2396
|
+
u === void 0 && $(w), r?.(w), w || requestAnimationFrame(() => K.current?.focus());
|
|
2397
|
+
}, S = () => U(!E);
|
|
2398
|
+
return ue(() => {
|
|
2399
|
+
E && X(!0);
|
|
2400
|
+
}, [E]), ue(() => {
|
|
2401
|
+
if (!E) return;
|
|
2402
|
+
const w = (W) => {
|
|
2403
|
+
W.key === "Escape" && (U(!1), requestAnimationFrame(() => K.current?.focus()));
|
|
1439
2404
|
};
|
|
1440
|
-
return document.addEventListener("keydown",
|
|
1441
|
-
}, [
|
|
2405
|
+
return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
|
|
2406
|
+
}, [r, E]), /* @__PURE__ */ c(
|
|
1442
2407
|
"div",
|
|
1443
2408
|
{
|
|
1444
2409
|
className: "make-ai-assistant",
|
|
1445
|
-
"data-open":
|
|
1446
|
-
style:
|
|
2410
|
+
"data-open": E || void 0,
|
|
2411
|
+
style: ie,
|
|
1447
2412
|
children: [
|
|
1448
|
-
!t && (!
|
|
2413
|
+
!t && (!E || s) ? s ? s({ open: E, toggle: S }) : /* @__PURE__ */ c(
|
|
1449
2414
|
"button",
|
|
1450
2415
|
{
|
|
1451
|
-
"aria-label":
|
|
1452
|
-
"aria-expanded":
|
|
2416
|
+
"aria-label": E ? `关闭 ${_}` : `打开 ${_}`,
|
|
2417
|
+
"aria-expanded": E,
|
|
1453
2418
|
className: "make-ai-assistant__launcher",
|
|
1454
|
-
"data-launcher-position":
|
|
1455
|
-
ref:
|
|
2419
|
+
"data-launcher-position": o,
|
|
2420
|
+
ref: K,
|
|
1456
2421
|
type: "button",
|
|
1457
|
-
onClick:
|
|
2422
|
+
onClick: S,
|
|
1458
2423
|
children: [
|
|
1459
2424
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
1460
|
-
/* @__PURE__ */ a(
|
|
2425
|
+
/* @__PURE__ */ a(Gt, {})
|
|
1461
2426
|
]
|
|
1462
2427
|
}
|
|
1463
2428
|
) : null,
|
|
1464
|
-
|
|
2429
|
+
L ? /* @__PURE__ */ c(
|
|
1465
2430
|
"aside",
|
|
1466
2431
|
{
|
|
1467
|
-
"aria-label":
|
|
2432
|
+
"aria-label": _,
|
|
1468
2433
|
"aria-modal": "false",
|
|
1469
2434
|
className: "make-ai-assistant__drawer",
|
|
1470
|
-
"data-resizing":
|
|
1471
|
-
hidden: !
|
|
1472
|
-
ref:
|
|
2435
|
+
"data-resizing": l || void 0,
|
|
2436
|
+
hidden: !E,
|
|
2437
|
+
ref: v,
|
|
1473
2438
|
role: "dialog",
|
|
1474
|
-
style:
|
|
2439
|
+
style: Q,
|
|
1475
2440
|
children: [
|
|
1476
2441
|
/* @__PURE__ */ a(
|
|
1477
2442
|
"div",
|
|
1478
2443
|
{
|
|
1479
2444
|
"aria-label": "调整对话框宽度",
|
|
1480
2445
|
"aria-orientation": "vertical",
|
|
1481
|
-
"aria-valuemax":
|
|
1482
|
-
"aria-valuemin":
|
|
1483
|
-
"aria-valuenow":
|
|
2446
|
+
"aria-valuemax": V,
|
|
2447
|
+
"aria-valuemin": f,
|
|
2448
|
+
"aria-valuenow": D ?? f,
|
|
1484
2449
|
className: "make-ai-assistant__drawer-resize-handle",
|
|
1485
2450
|
role: "separator",
|
|
1486
2451
|
tabIndex: 0,
|
|
1487
|
-
onKeyDown:
|
|
1488
|
-
onPointerCancel:
|
|
1489
|
-
onPointerDown:
|
|
1490
|
-
onPointerMove:
|
|
1491
|
-
onPointerUp:
|
|
2452
|
+
onKeyDown: oe,
|
|
2453
|
+
onPointerCancel: se,
|
|
2454
|
+
onPointerDown: fe,
|
|
2455
|
+
onPointerMove: B,
|
|
2456
|
+
onPointerUp: se
|
|
1492
2457
|
}
|
|
1493
2458
|
),
|
|
1494
2459
|
/* @__PURE__ */ a(
|
|
1495
|
-
|
|
2460
|
+
sa,
|
|
1496
2461
|
{
|
|
1497
|
-
...
|
|
1498
|
-
onClose: () =>
|
|
1499
|
-
visible:
|
|
2462
|
+
...g,
|
|
2463
|
+
onClose: () => U(!1),
|
|
2464
|
+
visible: E
|
|
1500
2465
|
}
|
|
1501
2466
|
)
|
|
1502
2467
|
]
|
|
@@ -1507,24 +2472,24 @@ function as({
|
|
|
1507
2472
|
);
|
|
1508
2473
|
}
|
|
1509
2474
|
export {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
2475
|
+
fa as ArtifactRenderer,
|
|
2476
|
+
bs as AssistantPanel,
|
|
2477
|
+
Ts as MAKE_AI_ARTIFACT_KINDS,
|
|
2478
|
+
Cs as MAKE_AI_ARTIFACT_LIMITS,
|
|
2479
|
+
Ms as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
2480
|
+
de as MAKE_AI_CONVERSATION_LIMITS,
|
|
2481
|
+
ks as MakeAiAssistant,
|
|
2482
|
+
qt as appendUserMessage,
|
|
2483
|
+
pa as createArtifactCapabilities,
|
|
2484
|
+
Ut as createArtifactTemplateRegistry,
|
|
2485
|
+
he as createAssistantConversationState,
|
|
2486
|
+
Ta as createPlatformArtifactRegistry,
|
|
2487
|
+
Is as extendArtifactTemplateRegistry,
|
|
2488
|
+
De as formatArtifactValue,
|
|
2489
|
+
Ns as parseArtifact,
|
|
2490
|
+
Ot as parseAssistantEvent,
|
|
2491
|
+
Aa as platformArtifactTemplates,
|
|
2492
|
+
Te as reduceAssistantEvent,
|
|
2493
|
+
ha as resolveArtifactTemplate,
|
|
2494
|
+
Rs as validateArtifact
|
|
1530
2495
|
};
|