@qfei-design/make-ai-assistant 0.1.3 → 0.1.5
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 +33 -10
- package/README.md +22 -4
- package/dist/{conversation-Dy2Sghjv.js → conversation-B7eGUXi-.js} +241 -198
- package/dist/conversation-Cv1wdvCR.cjs +1 -0
- package/dist/core/conversation.d.ts +11 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/make-app.cjs +1 -1
- package/dist/make-app.mjs +7 -6
- package/dist/make-console.cjs +1 -1
- package/dist/make-console.mjs +56 -55
- package/dist/react/make-ai-assistant.d.ts +3 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +602 -419
- package/dist/sse.cjs +1 -1
- package/dist/sse.mjs +1 -1
- package/dist/styles.css +276 -11
- package/package.json +1 -1
- package/dist/conversation-Yku9Lzj_.cjs +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { resolveArtifactTemplate as
|
|
3
|
-
import { extendArtifactTemplateRegistry as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { a as
|
|
6
|
-
import { d as
|
|
7
|
-
function
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { resolveArtifactTemplate as ia, createArtifactTemplateRegistry as Pe, createArtifactCapabilities as oa } from "./index.mjs";
|
|
3
|
+
import { extendArtifactTemplateRegistry as Ga } from "./index.mjs";
|
|
4
|
+
import { useState as E, useRef as S, useMemo as Fe, useEffect as ge } from "react";
|
|
5
|
+
import { a as ue, r as pe, c as he, M as A, b as ca, p as la } from "./conversation-B7eGUXi-.js";
|
|
6
|
+
import { d as ja, e as Ya, f as Ja, g as Qa, v as Wa } from "./conversation-B7eGUXi-.js";
|
|
7
|
+
function da({
|
|
8
8
|
artifact: e,
|
|
9
9
|
context: a,
|
|
10
10
|
fallback: s,
|
|
11
11
|
onAction: c,
|
|
12
|
-
onActionError:
|
|
13
|
-
registry:
|
|
12
|
+
onActionError: o,
|
|
13
|
+
registry: d
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
return s ? s(e) : /* @__PURE__ */
|
|
15
|
+
const m = ia(d, e, a);
|
|
16
|
+
if (!m)
|
|
17
|
+
return s ? s(e) : /* @__PURE__ */ n("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
18
18
|
/* @__PURE__ */ t("strong", { children: "暂不支持展示此结果" }),
|
|
19
|
-
/* @__PURE__ */
|
|
19
|
+
/* @__PURE__ */ n("span", { children: [
|
|
20
20
|
"结果类型:",
|
|
21
21
|
e.kind
|
|
22
22
|
] })
|
|
23
23
|
] });
|
|
24
|
-
const
|
|
24
|
+
const h = {
|
|
25
25
|
context: a,
|
|
26
26
|
onAction: c,
|
|
27
|
-
onActionError:
|
|
27
|
+
onActionError: o
|
|
28
28
|
};
|
|
29
|
-
return
|
|
29
|
+
return m.template.render(e, a, h);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const D = (e, a, s) => {
|
|
32
32
|
if (e == null || e === "") return "—";
|
|
33
33
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
34
34
|
if (typeof e != "number") return `${e}${a?.unit ?? ""}`;
|
|
35
|
-
const c = a?.precision,
|
|
35
|
+
const c = a?.precision, o = {
|
|
36
36
|
maximumFractionDigits: c ?? 2,
|
|
37
37
|
minimumFractionDigits: c
|
|
38
38
|
};
|
|
39
|
-
a?.style === "currency" && a.currency ? (
|
|
39
|
+
a?.style === "currency" && a.currency ? (o.style = "currency", o.currency = a.currency) : a?.style === "percent" && (o.style = "percent");
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
return `${new Intl.NumberFormat(s,
|
|
41
|
+
const d = a?.style === "percent" ? e / 100 : e;
|
|
42
|
+
return `${new Intl.NumberFormat(s, o).format(d)}${a?.unit ?? ""}`;
|
|
43
43
|
} catch {
|
|
44
44
|
return `${e}${a?.unit ?? ""}`;
|
|
45
45
|
}
|
|
46
|
-
},
|
|
46
|
+
}, Ue = (e) => {
|
|
47
47
|
let a = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
48
48
|
for (const c of e)
|
|
49
49
|
a = Math.min(a, c), s = Math.max(s, c);
|
|
50
50
|
return Number.isFinite(a) && Number.isFinite(s) ? { min: a, max: s } : { min: 0, max: 0 };
|
|
51
|
-
},
|
|
51
|
+
}, qe = (e, a, s) => {
|
|
52
52
|
if (!s.onAction) return;
|
|
53
|
-
const c = (
|
|
53
|
+
const c = (d) => {
|
|
54
54
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
55
55
|
actionId: e.id,
|
|
56
56
|
artifactId: a.artifact.id,
|
|
57
|
-
errorType:
|
|
57
|
+
errorType: d instanceof Error ? d.name : typeof d,
|
|
58
58
|
intent: e.intent
|
|
59
59
|
});
|
|
60
|
-
},
|
|
60
|
+
}, o = (d) => {
|
|
61
61
|
if (s.onActionError) {
|
|
62
62
|
try {
|
|
63
63
|
Promise.resolve(
|
|
64
|
-
s.onActionError(
|
|
64
|
+
s.onActionError(d, e, a)
|
|
65
65
|
).catch(c);
|
|
66
|
-
} catch (
|
|
67
|
-
c(
|
|
66
|
+
} catch (m) {
|
|
67
|
+
c(m);
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
console.error("[make-ai-assistant] host action failed", {
|
|
72
72
|
actionId: e.id,
|
|
73
73
|
artifactId: a.artifact.id,
|
|
74
|
-
errorType:
|
|
74
|
+
errorType: d instanceof Error ? d.name : typeof d,
|
|
75
75
|
intent: e.intent
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
try {
|
|
79
|
-
Promise.resolve(s.onAction(e, a)).catch(
|
|
80
|
-
} catch (
|
|
81
|
-
|
|
79
|
+
Promise.resolve(s.onAction(e, a)).catch(o);
|
|
80
|
+
} catch (d) {
|
|
81
|
+
o(d);
|
|
82
82
|
}
|
|
83
|
-
},
|
|
83
|
+
}, J = (e, a) => e.actions?.length && a.onAction ? /* @__PURE__ */ t("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ n(
|
|
84
84
|
"button",
|
|
85
85
|
{
|
|
86
86
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
87
87
|
type: "button",
|
|
88
|
-
onClick: () =>
|
|
88
|
+
onClick: () => qe(s, { artifact: e, context: a.context }, a),
|
|
89
89
|
children: [
|
|
90
90
|
s.label,
|
|
91
91
|
/* @__PURE__ */ t("span", { "aria-hidden": "true", children: "→" })
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
s.id
|
|
95
|
-
)) }) : null,
|
|
95
|
+
)) }) : null, Q = (e, a, s = "") => /* @__PURE__ */ n(
|
|
96
96
|
"section",
|
|
97
97
|
{
|
|
98
98
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
@@ -105,24 +105,24 @@ const $ = (e, a, s) => {
|
|
|
105
105
|
a
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
|
-
),
|
|
108
|
+
), ma = ({
|
|
109
109
|
artifact: e,
|
|
110
110
|
renderContext: a
|
|
111
111
|
}) => {
|
|
112
|
-
const s = e.data.delta, c = s ?
|
|
112
|
+
const s = e.data.delta, c = s ? D(
|
|
113
113
|
s.value,
|
|
114
114
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
115
115
|
a.context.locale
|
|
116
116
|
) : void 0;
|
|
117
|
-
return
|
|
117
|
+
return Q(
|
|
118
118
|
e,
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */ t("div", { className: "make-ai-artifact__metric-value", children:
|
|
119
|
+
/* @__PURE__ */ n(L, { children: [
|
|
120
|
+
/* @__PURE__ */ t("div", { className: "make-ai-artifact__metric-value", children: D(
|
|
121
121
|
e.data.value,
|
|
122
122
|
e.data.format,
|
|
123
123
|
a.context.locale
|
|
124
124
|
) }),
|
|
125
|
-
s ? /* @__PURE__ */
|
|
125
|
+
s ? /* @__PURE__ */ n(
|
|
126
126
|
"div",
|
|
127
127
|
{
|
|
128
128
|
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
@@ -134,108 +134,108 @@ const $ = (e, a, s) => {
|
|
|
134
134
|
}
|
|
135
135
|
) : null,
|
|
136
136
|
e.data.context ? /* @__PURE__ */ t("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
137
|
-
|
|
137
|
+
J(e, a)
|
|
138
138
|
] }),
|
|
139
139
|
"make-ai-artifact--metric"
|
|
140
140
|
);
|
|
141
|
-
},
|
|
141
|
+
}, ua = ({
|
|
142
142
|
artifact: e,
|
|
143
143
|
renderContext: a
|
|
144
|
-
}) =>
|
|
144
|
+
}) => Q(
|
|
145
145
|
e,
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */ t("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ n(L, { children: [
|
|
147
|
+
/* @__PURE__ */ t("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ n("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
148
148
|
/* @__PURE__ */ t("span", { children: s.label }),
|
|
149
|
-
/* @__PURE__ */ t("strong", { children:
|
|
149
|
+
/* @__PURE__ */ t("strong", { children: D(s.value, s.format, a.context.locale) }),
|
|
150
150
|
s.hint ? /* @__PURE__ */ t("small", { children: s.hint }) : null
|
|
151
151
|
] }, s.id)) }),
|
|
152
|
-
|
|
152
|
+
J(e, a)
|
|
153
153
|
] }),
|
|
154
154
|
"make-ai-artifact--comparison"
|
|
155
|
-
),
|
|
155
|
+
), pa = ({
|
|
156
156
|
artifact: e,
|
|
157
157
|
renderContext: a
|
|
158
158
|
}) => {
|
|
159
|
-
const s = e.data.series.flatMap((
|
|
160
|
-
return
|
|
159
|
+
const s = e.data.series.flatMap((m) => m.points.map((h) => h.y)), { max: c, min: o } = Ue(s), d = c - o || 1;
|
|
160
|
+
return Q(
|
|
161
161
|
e,
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend", children: e.data.series.map((
|
|
164
|
-
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-label", children:
|
|
165
|
-
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-bars", children:
|
|
166
|
-
const
|
|
167
|
-
return /* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ n(L, { children: [
|
|
163
|
+
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend", children: e.data.series.map((m) => /* @__PURE__ */ n("div", { className: "make-ai-artifact__trend-series", children: [
|
|
164
|
+
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-label", children: m.label }),
|
|
165
|
+
/* @__PURE__ */ t("div", { className: "make-ai-artifact__trend-bars", children: m.points.map((h, $) => {
|
|
166
|
+
const y = 18 + (h.y - o) / d * 70;
|
|
167
|
+
return /* @__PURE__ */ n("div", { className: "make-ai-artifact__trend-point", children: [
|
|
168
168
|
/* @__PURE__ */ t(
|
|
169
169
|
"span",
|
|
170
170
|
{
|
|
171
|
-
"aria-label": `${
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
"aria-label": `${h.x}: ${D(
|
|
172
|
+
h.y,
|
|
173
|
+
m.format,
|
|
174
174
|
a.context.locale
|
|
175
175
|
)}`,
|
|
176
176
|
className: "make-ai-artifact__trend-bar",
|
|
177
177
|
role: "img",
|
|
178
|
-
style: { height: `${
|
|
179
|
-
title: `${
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
style: { height: `${y}%` },
|
|
179
|
+
title: `${h.x}: ${D(
|
|
180
|
+
h.y,
|
|
181
|
+
m.format,
|
|
182
182
|
a.context.locale
|
|
183
183
|
)}`
|
|
184
184
|
}
|
|
185
185
|
),
|
|
186
|
-
/* @__PURE__ */ t("small", { children:
|
|
187
|
-
] }, `${
|
|
186
|
+
/* @__PURE__ */ t("small", { children: h.x })
|
|
187
|
+
] }, `${h.x}-${$}`);
|
|
188
188
|
}) })
|
|
189
|
-
] },
|
|
190
|
-
|
|
189
|
+
] }, m.id)) }),
|
|
190
|
+
J(e, a)
|
|
191
191
|
] }),
|
|
192
192
|
"make-ai-artifact--trend"
|
|
193
193
|
);
|
|
194
|
-
},
|
|
194
|
+
}, ha = ({
|
|
195
195
|
artifact: e,
|
|
196
196
|
renderContext: a
|
|
197
197
|
}) => {
|
|
198
|
-
const { max: s } =
|
|
199
|
-
e.data.items.map((
|
|
198
|
+
const { max: s } = Ue(
|
|
199
|
+
e.data.items.map((o) => Math.abs(o.value))
|
|
200
200
|
), c = Math.max(s, 1);
|
|
201
|
-
return
|
|
201
|
+
return Q(
|
|
202
202
|
e,
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */ t("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((
|
|
205
|
-
/* @__PURE__ */ t("span", { className: "make-ai-artifact__rank", children:
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */ t("span", { children:
|
|
208
|
-
|
|
203
|
+
/* @__PURE__ */ n(L, { children: [
|
|
204
|
+
/* @__PURE__ */ t("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((o, d) => /* @__PURE__ */ n("li", { children: [
|
|
205
|
+
/* @__PURE__ */ t("span", { className: "make-ai-artifact__rank", children: d + 1 }),
|
|
206
|
+
/* @__PURE__ */ n("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
207
|
+
/* @__PURE__ */ t("span", { children: o.label }),
|
|
208
|
+
o.description ? /* @__PURE__ */ t("small", { children: o.description }) : null
|
|
209
209
|
] }),
|
|
210
|
-
/* @__PURE__ */ t("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { style: { width: `${Math.abs(
|
|
211
|
-
/* @__PURE__ */ t("strong", { children:
|
|
212
|
-
] },
|
|
213
|
-
|
|
210
|
+
/* @__PURE__ */ t("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { style: { width: `${Math.abs(o.value) / c * 100}%` } }) }),
|
|
211
|
+
/* @__PURE__ */ t("strong", { children: D(o.value, o.format, a.context.locale) })
|
|
212
|
+
] }, o.id)) }),
|
|
213
|
+
J(e, a)
|
|
214
214
|
] }),
|
|
215
215
|
"make-ai-artifact--ranking"
|
|
216
216
|
);
|
|
217
|
-
},
|
|
217
|
+
}, ga = (e, a) => a.action ?? {
|
|
218
218
|
id: `open-${a.id}`,
|
|
219
219
|
label: a.title ?? a.id,
|
|
220
220
|
intent: "open-record",
|
|
221
221
|
target: { entityKey: e.data.entity.key, recordId: a.id }
|
|
222
|
-
},
|
|
222
|
+
}, fa = ({
|
|
223
223
|
artifact: e,
|
|
224
224
|
renderContext: a
|
|
225
|
-
}) =>
|
|
225
|
+
}) => Q(
|
|
226
226
|
e,
|
|
227
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ n(L, { children: [
|
|
228
228
|
/* @__PURE__ */ t("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ t("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
|
|
229
|
-
const c =
|
|
229
|
+
const c = ga(e, s), o = /* @__PURE__ */ n(L, { children: [
|
|
230
230
|
/* @__PURE__ */ t("strong", { children: s.title ?? s.id }),
|
|
231
|
-
/* @__PURE__ */ t("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((
|
|
232
|
-
/* @__PURE__ */ t("small", { children:
|
|
233
|
-
|
|
234
|
-
s.values[
|
|
235
|
-
|
|
231
|
+
/* @__PURE__ */ t("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((d) => /* @__PURE__ */ n("span", { children: [
|
|
232
|
+
/* @__PURE__ */ t("small", { children: d.label }),
|
|
233
|
+
D(
|
|
234
|
+
s.values[d.key],
|
|
235
|
+
d.format,
|
|
236
236
|
a.context.locale
|
|
237
237
|
)
|
|
238
|
-
] },
|
|
238
|
+
] }, d.key)) }),
|
|
239
239
|
a.onAction ? /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "›" }) : null
|
|
240
240
|
] });
|
|
241
241
|
return a.onAction ? /* @__PURE__ */ t(
|
|
@@ -243,47 +243,51 @@ const $ = (e, a, s) => {
|
|
|
243
243
|
{
|
|
244
244
|
className: "make-ai-artifact__record",
|
|
245
245
|
type: "button",
|
|
246
|
-
onClick: () =>
|
|
246
|
+
onClick: () => qe(c, {
|
|
247
247
|
artifact: e,
|
|
248
248
|
context: a.context
|
|
249
249
|
}, a),
|
|
250
|
-
children:
|
|
250
|
+
children: o
|
|
251
251
|
},
|
|
252
252
|
s.id
|
|
253
|
-
) : /* @__PURE__ */ t("div", { className: "make-ai-artifact__record", children:
|
|
253
|
+
) : /* @__PURE__ */ t("div", { className: "make-ai-artifact__record", children: o }, s.id);
|
|
254
254
|
}) }),
|
|
255
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
255
|
+
e.data.total !== void 0 ? /* @__PURE__ */ n("p", { className: "make-ai-artifact__record-total", children: [
|
|
256
256
|
"共 ",
|
|
257
257
|
e.data.total,
|
|
258
258
|
" 条"
|
|
259
259
|
] }) : null,
|
|
260
|
-
|
|
260
|
+
J(e, a)
|
|
261
261
|
] }),
|
|
262
262
|
"make-ai-artifact--record-list"
|
|
263
|
-
),
|
|
263
|
+
), _a = ({
|
|
264
264
|
artifact: e,
|
|
265
265
|
renderContext: a
|
|
266
|
-
}) =>
|
|
266
|
+
}) => Q(
|
|
267
267
|
e,
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ n(L, { children: [
|
|
269
|
+
/* @__PURE__ */ n("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
270
270
|
/* @__PURE__ */ t("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
271
271
|
/* @__PURE__ */ t("p", { children: e.data.body })
|
|
272
272
|
] }),
|
|
273
|
-
|
|
273
|
+
J(e, a)
|
|
274
274
|
] }),
|
|
275
275
|
"make-ai-artifact--notice"
|
|
276
|
-
),
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
],
|
|
284
|
-
|
|
276
|
+
), Y = (e, a, s) => ({ id: e, kinds: [a], priority: 0, render: s }), va = [
|
|
277
|
+
Y("platform.metric.default", "metric", (e, a, s) => /* @__PURE__ */ t(ma, { artifact: e, renderContext: s })),
|
|
278
|
+
Y("platform.comparison.default", "comparison", (e, a, s) => /* @__PURE__ */ t(ua, { artifact: e, renderContext: s })),
|
|
279
|
+
Y("platform.trend.default", "trend", (e, a, s) => /* @__PURE__ */ t(pa, { artifact: e, renderContext: s })),
|
|
280
|
+
Y("platform.ranking.default", "ranking", (e, a, s) => /* @__PURE__ */ t(ha, { artifact: e, renderContext: s })),
|
|
281
|
+
Y("platform.record-list.default", "record-list", (e, a, s) => /* @__PURE__ */ t(fa, { artifact: e, renderContext: s })),
|
|
282
|
+
Y("platform.notice.default", "notice", (e, a, s) => /* @__PURE__ */ t(_a, { artifact: e, renderContext: s }))
|
|
283
|
+
], ka = Pe(va).templates, ya = (e = ka) => Pe(e), Aa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, ba = "Make", Ia = [
|
|
284
|
+
"总结当前页面数据",
|
|
285
|
+
"找出需要关注的记录",
|
|
286
|
+
"列出我有权限查看的数据对象"
|
|
287
|
+
], Ke = (e, a) => a ?? `${e?.trim() || ba} AI 助手`, Na = (e) => e ?? Ia;
|
|
288
|
+
class u extends Error {
|
|
285
289
|
}
|
|
286
|
-
const
|
|
290
|
+
const Le = (e) => {
|
|
287
291
|
try {
|
|
288
292
|
const a = e?.return?.();
|
|
289
293
|
if (!a) return;
|
|
@@ -297,33 +301,71 @@ const pe = (e) => {
|
|
|
297
301
|
errorType: a instanceof Error ? a.name : typeof a
|
|
298
302
|
});
|
|
299
303
|
}
|
|
300
|
-
},
|
|
304
|
+
}, wa = async (e) => {
|
|
305
|
+
if (globalThis.navigator?.clipboard?.writeText) {
|
|
306
|
+
await globalThis.navigator.clipboard.writeText(e);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (typeof document > "u" || !document.body)
|
|
310
|
+
throw new Error("Clipboard API is unavailable");
|
|
311
|
+
const a = document.createElement("textarea");
|
|
312
|
+
a.value = e, a.setAttribute("readonly", ""), a.style.position = "fixed", a.style.inset = "0 auto auto 0", a.style.opacity = "0", document.body.append(a), a.select();
|
|
313
|
+
const s = document.execCommand("copy");
|
|
314
|
+
if (a.remove(), !s)
|
|
315
|
+
throw new Error("Clipboard copy failed");
|
|
316
|
+
}, Be = () => /* @__PURE__ */ n("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
301
317
|
/* @__PURE__ */ t("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" }),
|
|
302
318
|
/* @__PURE__ */ t("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" })
|
|
303
|
-
] }),
|
|
319
|
+
] }), Ta = () => /* @__PURE__ */ t("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ t("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ma = () => /* @__PURE__ */ t("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ t("path", { d: "M12 5v14M5 12h14" }) }), Ca = () => /* @__PURE__ */ n("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
304
320
|
/* @__PURE__ */ t("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
305
321
|
/* @__PURE__ */ t("path", { d: "M7 12h14" })
|
|
306
|
-
] }),
|
|
322
|
+
] }), ae = ({ className: e = "" }) => /* @__PURE__ */ t("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ t(Be, {}) }), Ea = ({ src: e }) => e ? /* @__PURE__ */ t("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ t("img", { alt: "", src: e }) }) : null, Ve = ({ assistantName: e }) => /* @__PURE__ */ n("div", { className: "make-ai-assistant__message-identity", children: [
|
|
323
|
+
/* @__PURE__ */ t(ae, { className: "make-ai-assistant__avatar--message" }),
|
|
324
|
+
/* @__PURE__ */ t("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
325
|
+
] }), He = (e) => {
|
|
307
326
|
for (let a = e.messages.length - 1; a >= 0; a -= 1) {
|
|
308
327
|
const s = e.messages[a];
|
|
309
328
|
if (s.role === "assistant" && s.status === "streaming")
|
|
310
329
|
return s.id;
|
|
311
330
|
}
|
|
312
|
-
},
|
|
331
|
+
}, Sa = (e) => {
|
|
313
332
|
for (let a = e.messages.length - 1; a >= 0; a -= 1)
|
|
314
333
|
if (e.messages[a].role === "user") return a;
|
|
315
334
|
return -1;
|
|
316
|
-
},
|
|
317
|
-
const a =
|
|
335
|
+
}, Oe = (e) => {
|
|
336
|
+
const a = Sa(e);
|
|
318
337
|
if (!(a < 0))
|
|
319
338
|
for (let s = e.messages.length - 1; s > a; s -= 1) {
|
|
320
339
|
const c = e.messages[s];
|
|
321
340
|
if (c.role === "assistant") return c.id;
|
|
322
341
|
}
|
|
323
|
-
},
|
|
342
|
+
}, $a = (e) => {
|
|
343
|
+
if (e.status === "idle")
|
|
344
|
+
for (let a = e.messages.length - 1; a >= 0; a -= 1) {
|
|
345
|
+
const s = e.messages[a];
|
|
346
|
+
if (s.role === "assistant" && s.status === "complete")
|
|
347
|
+
return s.id;
|
|
348
|
+
}
|
|
349
|
+
}, Ra = (e) => {
|
|
350
|
+
for (let a = e.messages.length - 1; a >= 0; a -= 1) {
|
|
351
|
+
const s = e.messages[a];
|
|
352
|
+
if (s.role === "user") return s;
|
|
353
|
+
}
|
|
354
|
+
}, xa = (e, a) => {
|
|
355
|
+
const s = e.messages.findIndex(
|
|
356
|
+
(c) => c.id === a && c.role === "user"
|
|
357
|
+
);
|
|
358
|
+
return {
|
|
359
|
+
...e,
|
|
360
|
+
error: void 0,
|
|
361
|
+
progress: void 0,
|
|
362
|
+
status: "streaming",
|
|
363
|
+
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
364
|
+
};
|
|
365
|
+
}, Fa = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, La = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, ze = ({
|
|
324
366
|
error: e,
|
|
325
367
|
onRetry: a
|
|
326
|
-
}) => /* @__PURE__ */
|
|
368
|
+
}) => /* @__PURE__ */ n("div", { className: "make-ai-assistant__message-status make-ai-assistant__message-status--error", role: "alert", children: [
|
|
327
369
|
/* @__PURE__ */ t("strong", { children: "本次请求未完成" }),
|
|
328
370
|
/* @__PURE__ */ t("span", { children: e.message }),
|
|
329
371
|
e.retryable && a ? /* @__PURE__ */ t(
|
|
@@ -335,316 +377,438 @@ const pe = (e) => {
|
|
|
335
377
|
children: "重新发送"
|
|
336
378
|
}
|
|
337
379
|
) : null
|
|
338
|
-
] }),
|
|
380
|
+
] }), Ge = ({
|
|
381
|
+
active: e,
|
|
382
|
+
steps: a
|
|
383
|
+
}) => {
|
|
384
|
+
if (!a?.length) return null;
|
|
385
|
+
const s = a[a.length - 1] ?? "处理中";
|
|
386
|
+
return /* @__PURE__ */ n("details", { className: "make-ai-assistant__process", open: e, children: [
|
|
387
|
+
/* @__PURE__ */ n("summary", { children: [
|
|
388
|
+
e ? /* @__PURE__ */ n("span", { className: "make-ai-assistant__progress", role: "status", children: [
|
|
389
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true" }),
|
|
390
|
+
/* @__PURE__ */ t("span", { children: s })
|
|
391
|
+
] }) : /* @__PURE__ */ t("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
|
|
392
|
+
/* @__PURE__ */ n("span", { className: "make-ai-assistant__process-count", children: [
|
|
393
|
+
a.length,
|
|
394
|
+
" 步"
|
|
395
|
+
] })
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ t("ol", { children: a.map((c, o) => /* @__PURE__ */ n(
|
|
398
|
+
"li",
|
|
399
|
+
{
|
|
400
|
+
"data-step-active": e && o === a.length - 1 ? !0 : void 0,
|
|
401
|
+
children: [
|
|
402
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true" }),
|
|
403
|
+
/* @__PURE__ */ t("span", { children: c })
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
`${o}-${c}`
|
|
407
|
+
)) })
|
|
408
|
+
] });
|
|
409
|
+
}, Da = ({
|
|
410
|
+
copyFeedback: e,
|
|
411
|
+
onCopy: a,
|
|
412
|
+
onRegenerate: s
|
|
413
|
+
}) => !a && !s ? null : /* @__PURE__ */ n("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
|
|
414
|
+
a ? /* @__PURE__ */ t("button", { type: "button", onClick: a, children: "复制回答" }) : null,
|
|
415
|
+
s ? /* @__PURE__ */ t("button", { type: "button", onClick: s, children: "重新生成" }) : null,
|
|
416
|
+
e ? /* @__PURE__ */ t(
|
|
417
|
+
"span",
|
|
418
|
+
{
|
|
419
|
+
className: "make-ai-assistant__reply-feedback",
|
|
420
|
+
"data-copy-status": e.status,
|
|
421
|
+
role: "status",
|
|
422
|
+
children: e.message
|
|
423
|
+
}
|
|
424
|
+
) : null
|
|
425
|
+
] }), De = ({
|
|
339
426
|
assistantName: e,
|
|
340
427
|
error: a,
|
|
341
428
|
onRetry: s,
|
|
342
429
|
progress: c
|
|
343
430
|
}) => {
|
|
344
|
-
const
|
|
345
|
-
return
|
|
431
|
+
const o = a ? "error" : "progress";
|
|
432
|
+
return a?.message ?? c?.message ? /* @__PURE__ */ t(
|
|
346
433
|
"article",
|
|
347
434
|
{
|
|
348
|
-
"aria-label": `${e}的${
|
|
349
|
-
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${
|
|
435
|
+
"aria-label": `${e}的${o === "error" ? "错误消息" : "状态消息"}`,
|
|
436
|
+
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${o}`,
|
|
350
437
|
"data-message-role": "assistant",
|
|
351
|
-
"data-message-state":
|
|
352
|
-
children: [
|
|
353
|
-
/* @__PURE__ */ t(
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
|
|
356
|
-
a ? /* @__PURE__ */ t(Ie, { error: a, onRetry: s }) : /* @__PURE__ */ r("div", { className: "make-ai-assistant__progress", role: "status", children: [
|
|
357
|
-
/* @__PURE__ */ t("span", { "aria-hidden": "true" }),
|
|
358
|
-
/* @__PURE__ */ t("span", { children: l })
|
|
359
|
-
] })
|
|
360
|
-
] })
|
|
361
|
-
]
|
|
438
|
+
"data-message-state": o,
|
|
439
|
+
children: /* @__PURE__ */ n("div", { className: "make-ai-assistant__message-turn", children: [
|
|
440
|
+
/* @__PURE__ */ t(Ve, { assistantName: e }),
|
|
441
|
+
/* @__PURE__ */ t("div", { className: "make-ai-assistant__message-stack", children: a ? /* @__PURE__ */ t(ze, { error: a, onRetry: s }) : /* @__PURE__ */ t(Ge, { active: !0, steps: c?.steps }) })
|
|
442
|
+
] })
|
|
362
443
|
}
|
|
363
444
|
) : null;
|
|
364
|
-
},
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
445
|
+
}, Pa = (e, a, s, c, o, d, m, h, $, y, k, f, P) => {
|
|
446
|
+
const N = Oe(e), U = He(e), R = $a(e);
|
|
447
|
+
let x;
|
|
448
|
+
return e.messages.map((i) => {
|
|
449
|
+
const _ = i.role === "assistant", q = x;
|
|
450
|
+
_ || (x = i);
|
|
451
|
+
const K = i.id === U, w = i.id === N ? e.error : void 0, B = i.error ?? w, T = _ ? d : h, fe = _ && i.status === "complete" && !B && (i.content.trim() || i.id === R);
|
|
452
|
+
return /* @__PURE__ */ t(
|
|
369
453
|
"article",
|
|
370
454
|
{
|
|
371
|
-
"aria-label": `${
|
|
372
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
373
|
-
"data-message-role":
|
|
374
|
-
"data-message-state":
|
|
375
|
-
"data-message-status":
|
|
376
|
-
children: [
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
/* @__PURE__ */ t(
|
|
380
|
-
|
|
455
|
+
"aria-label": `${T}的消息`,
|
|
456
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${i.role}`,
|
|
457
|
+
"data-message-role": i.role,
|
|
458
|
+
"data-message-state": B ? "error" : void 0,
|
|
459
|
+
"data-message-status": i.status,
|
|
460
|
+
children: /* @__PURE__ */ n("div", { className: "make-ai-assistant__message-turn", children: [
|
|
461
|
+
_ ? /* @__PURE__ */ t(Ve, { assistantName: d }) : /* @__PURE__ */ n("div", { className: "make-ai-assistant__message-identity", children: [
|
|
462
|
+
/* @__PURE__ */ t("span", { className: "make-ai-assistant__message-sender", children: T }),
|
|
463
|
+
/* @__PURE__ */ t(Ea, { src: $ })
|
|
464
|
+
] }),
|
|
465
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__message-stack", children: [
|
|
466
|
+
i.content ? /* @__PURE__ */ t("div", { className: "make-ai-assistant__bubble", children: i.content }) : i.status === "streaming" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
|
|
381
467
|
/* @__PURE__ */ t("span", {}),
|
|
382
468
|
/* @__PURE__ */ t("span", {}),
|
|
383
469
|
/* @__PURE__ */ t("span", {})
|
|
384
470
|
] }) : null,
|
|
385
|
-
_
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
471
|
+
_ ? /* @__PURE__ */ t(
|
|
472
|
+
Ge,
|
|
473
|
+
{
|
|
474
|
+
active: K && e.status === "streaming",
|
|
475
|
+
steps: i.progressSteps
|
|
476
|
+
}
|
|
477
|
+
) : null,
|
|
478
|
+
B ? /* @__PURE__ */ t(
|
|
479
|
+
ze,
|
|
392
480
|
{
|
|
393
|
-
|
|
481
|
+
error: B,
|
|
482
|
+
onRetry: w ? m : void 0
|
|
483
|
+
}
|
|
484
|
+
) : null,
|
|
485
|
+
i.artifacts.map((te) => /* @__PURE__ */ t(
|
|
486
|
+
da,
|
|
487
|
+
{
|
|
488
|
+
artifact: te,
|
|
394
489
|
context: a,
|
|
395
490
|
onAction: c,
|
|
396
|
-
onActionError:
|
|
491
|
+
onActionError: o,
|
|
397
492
|
registry: s
|
|
398
493
|
},
|
|
399
|
-
|
|
400
|
-
))
|
|
494
|
+
te.id
|
|
495
|
+
)),
|
|
496
|
+
fe ? /* @__PURE__ */ t(
|
|
497
|
+
Da,
|
|
498
|
+
{
|
|
499
|
+
copyFeedback: y?.messageId === i.id ? {
|
|
500
|
+
message: y.message,
|
|
501
|
+
status: y.status
|
|
502
|
+
} : void 0,
|
|
503
|
+
onCopy: i.content.trim() ? () => f(i.id, i.content) : void 0,
|
|
504
|
+
onRegenerate: k && i.id === R && q ? () => P({
|
|
505
|
+
userMessage: q,
|
|
506
|
+
assistantMessage: i
|
|
507
|
+
}) : void 0
|
|
508
|
+
}
|
|
509
|
+
) : null
|
|
401
510
|
] })
|
|
402
|
-
]
|
|
511
|
+
] })
|
|
403
512
|
},
|
|
404
|
-
|
|
513
|
+
i.id
|
|
405
514
|
);
|
|
406
515
|
});
|
|
407
516
|
};
|
|
408
|
-
function
|
|
517
|
+
function Ua({
|
|
409
518
|
assistantName: e = "AI 助手",
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
519
|
+
brandName: a,
|
|
520
|
+
context: s,
|
|
521
|
+
onAction: c,
|
|
522
|
+
onActionError: o,
|
|
523
|
+
onClose: d,
|
|
524
|
+
onNewConversation: m,
|
|
525
|
+
registry: h,
|
|
526
|
+
subtitle: $,
|
|
527
|
+
suggestions: y,
|
|
528
|
+
title: k,
|
|
529
|
+
transport: f,
|
|
530
|
+
userAvatarUrl: P,
|
|
531
|
+
userName: N = "你"
|
|
421
532
|
}) {
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
533
|
+
const U = Ke(a, k), [R, x] = E(""), [i, _] = E(ue), q = S(i);
|
|
534
|
+
q.current = i;
|
|
535
|
+
const [K, w] = E(void 0), [B, T] = E(void 0), [fe, te] = E(0), [V, se] = E(() => f.loadConversation ? "loading" : "ready"), [Ze, H] = E(!1), O = S(void 0), z = S(void 0), G = S(0), re = S(null), F = S(!0), ye = S(s.app.id), Ae = Fe(
|
|
536
|
+
() => h ?? ya(),
|
|
537
|
+
[h]
|
|
538
|
+
), be = Fe(
|
|
539
|
+
() => Na(y),
|
|
540
|
+
[y]
|
|
541
|
+
), ne = (r) => {
|
|
542
|
+
const p = O.current, g = z.current?.iterator;
|
|
543
|
+
return !p && !g ? !1 : (G.current += 1, O.current = void 0, z.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: r }), p?.abort(), Le(g), !0);
|
|
428
544
|
};
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}, []),
|
|
432
|
-
const
|
|
433
|
-
if (
|
|
434
|
-
|
|
545
|
+
ge(() => () => {
|
|
546
|
+
ne("unmount");
|
|
547
|
+
}, []), ge(() => {
|
|
548
|
+
const r = f.loadConversation, p = ye.current !== s.app.id;
|
|
549
|
+
if (ye.current = s.app.id, ne("reinitialize"), p && (x(""), F.current = !0), w(void 0), T(void 0), H(!1), _(ue()), !r) {
|
|
550
|
+
se("ready");
|
|
435
551
|
return;
|
|
436
552
|
}
|
|
437
|
-
const
|
|
438
|
-
return
|
|
439
|
-
appId:
|
|
440
|
-
}),
|
|
441
|
-
|
|
442
|
-
appId:
|
|
443
|
-
messageCount:
|
|
553
|
+
const g = new AbortController();
|
|
554
|
+
return se("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
555
|
+
appId: s.app.id
|
|
556
|
+
}), r.call(f, s, { signal: g.signal }).then((b) => {
|
|
557
|
+
g.signal.aborted || (_(ue(b)), se("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
558
|
+
appId: s.app.id,
|
|
559
|
+
messageCount: b.messages.length
|
|
444
560
|
}));
|
|
445
|
-
}).catch((
|
|
446
|
-
|
|
447
|
-
appId:
|
|
448
|
-
errorType:
|
|
449
|
-
}),
|
|
450
|
-
}), () =>
|
|
451
|
-
}, [
|
|
452
|
-
const
|
|
453
|
-
if (!
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
561
|
+
}).catch((b) => {
|
|
562
|
+
g.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
563
|
+
appId: s.app.id,
|
|
564
|
+
errorType: b instanceof Error ? b.name : typeof b
|
|
565
|
+
}), se("error"));
|
|
566
|
+
}), () => g.abort();
|
|
567
|
+
}, [s.app.id, fe, f]), ge(() => {
|
|
568
|
+
const r = re.current;
|
|
569
|
+
if (!r || !F.current) return;
|
|
570
|
+
H(!1);
|
|
571
|
+
const p = requestAnimationFrame(() => {
|
|
572
|
+
if (!F.current) return;
|
|
573
|
+
const g = i.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
574
|
+
typeof r.scrollTo == "function" ? r.scrollTo({ top: r.scrollHeight, behavior: g }) : r.scrollTop = r.scrollHeight;
|
|
458
575
|
});
|
|
459
|
-
return () => cancelAnimationFrame(
|
|
460
|
-
}, [
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
576
|
+
return () => cancelAnimationFrame(p);
|
|
577
|
+
}, [i.messages, i.progress, i.status]);
|
|
578
|
+
const je = () => {
|
|
579
|
+
const r = re.current;
|
|
580
|
+
if (!r) return;
|
|
581
|
+
const p = Fa(r);
|
|
582
|
+
F.current = p, H(!p && q.current.messages.length > 0);
|
|
583
|
+
}, Ye = () => {
|
|
584
|
+
const r = re.current;
|
|
585
|
+
if (!r) return;
|
|
586
|
+
F.current = !0, H(!1);
|
|
587
|
+
const p = La();
|
|
588
|
+
typeof r.scrollTo == "function" ? r.scrollTo({ top: r.scrollHeight, behavior: p }) : r.scrollTop = r.scrollHeight;
|
|
589
|
+
}, Ie = async (r, p) => {
|
|
590
|
+
const g = r.trim(), b = q.current, M = p?.regenerateFrom, _e = f.regenerate;
|
|
591
|
+
if (!g || V !== "ready" || b.status === "streaming" || O.current || M && !_e) return;
|
|
592
|
+
if (he(
|
|
593
|
+
g,
|
|
594
|
+
A.messageCharacters
|
|
595
|
+
) > A.messageCharacters) {
|
|
596
|
+
w(
|
|
597
|
+
`输入内容过长,请控制在 ${A.messageCharacters} 个字符以内`
|
|
473
598
|
);
|
|
474
599
|
return;
|
|
475
600
|
}
|
|
476
|
-
const
|
|
477
|
-
|
|
601
|
+
const ce = {
|
|
602
|
+
id: M?.userMessage.id ?? Aa("user"),
|
|
603
|
+
content: g
|
|
604
|
+
}, le = M ? xa(b, M.userMessage.id) : ca(b, ce), de = new AbortController(), Z = G.current + 1;
|
|
605
|
+
G.current = Z, O.current = de, w(void 0), T(void 0), H(!F.current && b.messages.length > 0), M || x(""), _(le);
|
|
478
606
|
try {
|
|
479
|
-
let
|
|
480
|
-
const
|
|
481
|
-
[
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
607
|
+
let C = !1, v, we = 0, Te = 0, Me = 0, ve = 0, W = 0;
|
|
608
|
+
const X = /* @__PURE__ */ new Map(), Ce = /* @__PURE__ */ new Set(), Ee = /* @__PURE__ */ new Set(
|
|
609
|
+
[
|
|
610
|
+
...le.messages.map((me) => me.id),
|
|
611
|
+
ce.id
|
|
612
|
+
]
|
|
613
|
+
), ee = /* @__PURE__ */ new Set(), Se = oa(Ae), $e = { signal: de.signal };
|
|
614
|
+
let ke;
|
|
615
|
+
if (M) {
|
|
616
|
+
if (!_e)
|
|
617
|
+
throw new u("当前 AI 助手不支持重新生成");
|
|
618
|
+
ke = _e({
|
|
619
|
+
threadId: le.threadId,
|
|
620
|
+
message: ce,
|
|
621
|
+
assistantMessage: {
|
|
622
|
+
id: M.assistantMessage.id,
|
|
623
|
+
content: M.assistantMessage.content
|
|
624
|
+
},
|
|
625
|
+
context: s,
|
|
626
|
+
capabilities: Se
|
|
627
|
+
}, $e);
|
|
628
|
+
} else
|
|
629
|
+
ke = f.run(
|
|
630
|
+
{
|
|
631
|
+
threadId: le.threadId,
|
|
632
|
+
message: ce,
|
|
633
|
+
context: s,
|
|
634
|
+
capabilities: Se
|
|
635
|
+
},
|
|
636
|
+
$e
|
|
637
|
+
);
|
|
638
|
+
const Re = ke[Symbol.asyncIterator]();
|
|
639
|
+
for (z.current = { iterator: Re, requestVersion: Z }; ; ) {
|
|
640
|
+
const me = await Re.next();
|
|
641
|
+
if (G.current !== Z || me.done) break;
|
|
642
|
+
let l;
|
|
495
643
|
try {
|
|
496
|
-
|
|
497
|
-
} catch (
|
|
498
|
-
throw new
|
|
499
|
-
|
|
644
|
+
l = la(me.value);
|
|
645
|
+
} catch (I) {
|
|
646
|
+
throw new u(
|
|
647
|
+
I instanceof Error ? I.message : "Invalid assistant event"
|
|
500
648
|
);
|
|
501
649
|
}
|
|
502
|
-
if (
|
|
503
|
-
if (
|
|
504
|
-
throw new
|
|
505
|
-
if (
|
|
506
|
-
throw new
|
|
507
|
-
if (
|
|
508
|
-
throw new
|
|
509
|
-
|
|
650
|
+
if (l.type === "message.start") {
|
|
651
|
+
if (v !== void 0 && v !== l.runId)
|
|
652
|
+
throw new u("AI 助手响应 run id 不一致");
|
|
653
|
+
if (v ??= l.runId, Te += 1, Te > A.assistantMessagesPerRun)
|
|
654
|
+
throw new u("AI 助手单次响应消息数量超过限制");
|
|
655
|
+
if (Ee.has(l.messageId))
|
|
656
|
+
throw new u("AI 助手响应包含重复的 message id");
|
|
657
|
+
Ee.add(l.messageId), ee.add(l.messageId), X.set(l.messageId, 0);
|
|
510
658
|
}
|
|
511
|
-
if (
|
|
512
|
-
if (!
|
|
513
|
-
throw new
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
659
|
+
if (l.type === "message.delta") {
|
|
660
|
+
if (!ee.has(l.messageId))
|
|
661
|
+
throw new u("AI 助手响应事件顺序无效");
|
|
662
|
+
const I = X.get(l.messageId) ?? 0, j = he(
|
|
663
|
+
l.delta,
|
|
664
|
+
A.messageCharacters - W
|
|
517
665
|
);
|
|
518
|
-
if (
|
|
519
|
-
throw new
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
666
|
+
if (W + j > A.messageCharacters)
|
|
667
|
+
throw new u("AI 助手响应文本超过大小限制");
|
|
668
|
+
W += j, X.set(
|
|
669
|
+
l.messageId,
|
|
670
|
+
I + j
|
|
523
671
|
);
|
|
524
672
|
}
|
|
525
|
-
if (
|
|
526
|
-
if (!
|
|
527
|
-
throw new
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
),
|
|
532
|
-
if (
|
|
533
|
-
throw new
|
|
534
|
-
|
|
673
|
+
if (l.type === "message.replace") {
|
|
674
|
+
if (!ee.has(l.messageId))
|
|
675
|
+
throw new u("AI 助手响应事件顺序无效");
|
|
676
|
+
const I = X.get(l.messageId) ?? 0, j = he(
|
|
677
|
+
l.content,
|
|
678
|
+
A.messageCharacters
|
|
679
|
+
), xe = W - I + j;
|
|
680
|
+
if (xe > A.messageCharacters)
|
|
681
|
+
throw new u("AI 助手响应文本超过大小限制");
|
|
682
|
+
W = xe, X.set(l.messageId, j);
|
|
535
683
|
}
|
|
536
|
-
if (
|
|
537
|
-
if (
|
|
538
|
-
throw new
|
|
539
|
-
|
|
684
|
+
if (l.type === "run.progress") {
|
|
685
|
+
if (v !== void 0 && v !== l.runId)
|
|
686
|
+
throw new u("AI 助手响应 run id 不一致");
|
|
687
|
+
if (v ??= l.runId, Me += 1, Me > A.progressStepsPerRun)
|
|
688
|
+
throw new u("AI 助手处理过程数量超过限制");
|
|
689
|
+
const I = he(
|
|
690
|
+
l.message,
|
|
691
|
+
A.progressCharactersPerRun - ve
|
|
692
|
+
);
|
|
693
|
+
if (ve + I > A.progressCharactersPerRun)
|
|
694
|
+
throw new u("AI 助手处理过程文本超过大小限制");
|
|
695
|
+
ve += I;
|
|
540
696
|
}
|
|
541
|
-
if (
|
|
542
|
-
if (!
|
|
543
|
-
throw new
|
|
544
|
-
if (
|
|
545
|
-
throw new
|
|
546
|
-
if (
|
|
547
|
-
throw new
|
|
548
|
-
|
|
697
|
+
if (l.type === "artifact") {
|
|
698
|
+
if (!ee.has(l.messageId))
|
|
699
|
+
throw new u("AI 助手响应事件顺序无效");
|
|
700
|
+
if (we += 1, we > A.artifactsPerRun)
|
|
701
|
+
throw new u("AI 助手单次响应 Artifact 数量超过限制");
|
|
702
|
+
if (Ce.has(l.artifact.id))
|
|
703
|
+
throw new u("AI 助手响应包含重复的 Artifact id");
|
|
704
|
+
Ce.add(l.artifact.id);
|
|
549
705
|
}
|
|
550
|
-
if (
|
|
551
|
-
throw new
|
|
552
|
-
if (
|
|
553
|
-
throw new
|
|
554
|
-
if (
|
|
555
|
-
throw new
|
|
556
|
-
if (
|
|
557
|
-
|
|
706
|
+
if (l.type === "message.complete" && !ee.delete(l.messageId))
|
|
707
|
+
throw new u("AI 助手响应事件顺序无效");
|
|
708
|
+
if (l.type === "run.complete" && v !== void 0 && v !== l.runId)
|
|
709
|
+
throw new u("AI 助手响应 run id 不一致");
|
|
710
|
+
if (l.type === "run.cancelled" && l.runId !== void 0 && v !== void 0 && v !== l.runId)
|
|
711
|
+
throw new u("AI 助手响应 run id 不一致");
|
|
712
|
+
if (_((I) => pe(I, l)), l.type === "error" || l.type === "run.cancelled" || l.type === "run.complete") {
|
|
713
|
+
C = !0;
|
|
558
714
|
break;
|
|
559
715
|
}
|
|
560
716
|
}
|
|
561
|
-
if (!
|
|
562
|
-
throw new
|
|
563
|
-
} catch (
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
566
|
-
|
|
567
|
-
(
|
|
717
|
+
if (!C)
|
|
718
|
+
throw new u("AI 助手流式响应在终止事件前结束");
|
|
719
|
+
} catch (C) {
|
|
720
|
+
if (G.current !== Z) return;
|
|
721
|
+
if (de.signal.aborted) {
|
|
722
|
+
_(
|
|
723
|
+
(v) => pe(v, { type: "run.cancelled" })
|
|
568
724
|
);
|
|
569
725
|
return;
|
|
570
726
|
}
|
|
571
727
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
572
|
-
appId:
|
|
573
|
-
errorType:
|
|
574
|
-
}),
|
|
575
|
-
(
|
|
728
|
+
appId: s.app.id,
|
|
729
|
+
errorType: C instanceof Error ? C.name : typeof C
|
|
730
|
+
}), _(
|
|
731
|
+
(v) => pe(v, {
|
|
576
732
|
type: "error",
|
|
577
733
|
code: "TRANSPORT_ERROR",
|
|
578
|
-
message:
|
|
734
|
+
message: C instanceof u ? C.message : "连接失败,请重试",
|
|
579
735
|
retryable: !0
|
|
580
736
|
})
|
|
581
737
|
);
|
|
582
738
|
} finally {
|
|
583
|
-
|
|
739
|
+
G.current === Z && O.current === de && (O.current = void 0), z.current?.requestVersion === Z && (Le(z.current.iterator), z.current = void 0);
|
|
584
740
|
}
|
|
585
|
-
},
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
741
|
+
}, ie = (r) => Ie(r), Je = (r) => Ie(r.userMessage.content, { regenerateFrom: r }), Qe = async (r, p) => {
|
|
742
|
+
try {
|
|
743
|
+
await wa(p), T({ messageId: r, message: "已复制", status: "success" });
|
|
744
|
+
} catch (g) {
|
|
745
|
+
console.error("[make-ai-assistant] copy answer failed", {
|
|
746
|
+
errorType: g instanceof Error ? g.name : typeof g
|
|
747
|
+
}), T({ messageId: r, message: "复制失败", status: "error" });
|
|
748
|
+
}
|
|
749
|
+
}, We = (r) => {
|
|
750
|
+
r.preventDefault(), ie(R);
|
|
751
|
+
}, Xe = (r) => {
|
|
752
|
+
r.key === "Enter" && !r.shiftKey && !r.nativeEvent.isComposing && (r.preventDefault(), ie(R));
|
|
753
|
+
}, ea = () => {
|
|
754
|
+
ne("stop") && _(
|
|
755
|
+
(r) => pe(r, { type: "run.cancelled" })
|
|
592
756
|
);
|
|
593
|
-
},
|
|
594
|
-
|
|
595
|
-
},
|
|
596
|
-
|
|
757
|
+
}, aa = () => {
|
|
758
|
+
ne("new-conversation"), x(""), w(void 0), T(void 0), H(!1), F.current = !0, _(ue()), m?.();
|
|
759
|
+
}, ta = f.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", sa = He(i), ra = Oe(i), oe = Ra(i), na = typeof f.regenerate == "function" && f.features?.regeneration !== !1, Ne = () => {
|
|
760
|
+
oe && ie(oe.content);
|
|
597
761
|
};
|
|
598
|
-
return /* @__PURE__ */
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */ t(
|
|
601
|
-
/* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */ t("h2", { children:
|
|
603
|
-
/* @__PURE__ */ t("p", { children:
|
|
762
|
+
return /* @__PURE__ */ n("section", { className: "make-ai-assistant make-ai-assistant__panel", children: [
|
|
763
|
+
/* @__PURE__ */ n("header", { className: "make-ai-assistant__header", children: [
|
|
764
|
+
/* @__PURE__ */ t(ae, {}),
|
|
765
|
+
/* @__PURE__ */ n("div", { children: [
|
|
766
|
+
/* @__PURE__ */ t("h2", { children: U }),
|
|
767
|
+
/* @__PURE__ */ t("p", { children: $ ?? `当前应用:${s.app.name ?? "未命名应用"}` })
|
|
604
768
|
] }),
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
|
|
769
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__header-actions", children: [
|
|
770
|
+
f.features?.newConversation !== !1 ? /* @__PURE__ */ t(
|
|
607
771
|
"button",
|
|
608
772
|
{
|
|
609
773
|
"aria-label": "新建对话",
|
|
610
774
|
className: "make-ai-assistant__icon-button",
|
|
611
775
|
type: "button",
|
|
612
|
-
onClick:
|
|
613
|
-
children: /* @__PURE__ */ t(
|
|
776
|
+
onClick: aa,
|
|
777
|
+
children: /* @__PURE__ */ t(Ma, {})
|
|
614
778
|
}
|
|
615
779
|
) : null,
|
|
616
|
-
|
|
780
|
+
d ? /* @__PURE__ */ t(
|
|
617
781
|
"button",
|
|
618
782
|
{
|
|
619
|
-
"aria-label":
|
|
783
|
+
"aria-label": `关闭 ${U}`,
|
|
620
784
|
className: "make-ai-assistant__icon-button",
|
|
621
785
|
type: "button",
|
|
622
|
-
onClick:
|
|
623
|
-
children: /* @__PURE__ */ t(
|
|
786
|
+
onClick: d,
|
|
787
|
+
children: /* @__PURE__ */ t(Ta, {})
|
|
624
788
|
}
|
|
625
789
|
) : null
|
|
626
790
|
] })
|
|
627
791
|
] }),
|
|
628
|
-
/* @__PURE__ */
|
|
792
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__privacy-note", role: "note", children: [
|
|
629
793
|
/* @__PURE__ */ t("span", { "aria-hidden": "true", children: "◇" }),
|
|
630
794
|
"当前页面上下文会随请求发送,数据权限以宿主服务端校验结果为准"
|
|
631
795
|
] }),
|
|
632
|
-
/* @__PURE__ */
|
|
796
|
+
/* @__PURE__ */ n(
|
|
633
797
|
"div",
|
|
634
798
|
{
|
|
635
799
|
className: "make-ai-assistant__body",
|
|
636
800
|
"aria-live": "polite",
|
|
637
801
|
"aria-relevant": "additions text",
|
|
638
|
-
ref:
|
|
802
|
+
ref: re,
|
|
639
803
|
role: "log",
|
|
640
|
-
onScroll:
|
|
804
|
+
onScroll: je,
|
|
641
805
|
children: [
|
|
642
|
-
|
|
643
|
-
/* @__PURE__ */ t(
|
|
806
|
+
V === "loading" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
807
|
+
/* @__PURE__ */ t(ae, {}),
|
|
644
808
|
/* @__PURE__ */ t("h3", { children: "正在恢复对话" }),
|
|
645
809
|
/* @__PURE__ */ t("p", { children: "正在读取当前 App 的历史消息…" })
|
|
646
|
-
] }) :
|
|
647
|
-
/* @__PURE__ */ t(
|
|
810
|
+
] }) : V === "error" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", role: "alert", children: [
|
|
811
|
+
/* @__PURE__ */ t(ae, {}),
|
|
648
812
|
/* @__PURE__ */ t("h3", { children: "暂时无法加载对话" }),
|
|
649
813
|
/* @__PURE__ */ t("p", { children: "请检查网络后重试。" }),
|
|
650
814
|
/* @__PURE__ */ t(
|
|
@@ -652,79 +816,98 @@ function ea({
|
|
|
652
816
|
{
|
|
653
817
|
className: "make-ai-assistant__retry",
|
|
654
818
|
type: "button",
|
|
655
|
-
onClick: () =>
|
|
819
|
+
onClick: () => te((r) => r + 1),
|
|
656
820
|
children: "重新加载"
|
|
657
821
|
}
|
|
658
822
|
)
|
|
659
|
-
] }) :
|
|
660
|
-
/* @__PURE__ */ t(
|
|
823
|
+
] }) : i.messages.length === 0 ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", children: [
|
|
824
|
+
/* @__PURE__ */ t(ae, {}),
|
|
661
825
|
/* @__PURE__ */ t("h3", { children: "有什么可以帮你?" }),
|
|
662
|
-
/* @__PURE__ */ t("p", { children: "我会结合当前 App
|
|
663
|
-
] }) :
|
|
664
|
-
|
|
665
|
-
a,
|
|
666
|
-
ne,
|
|
826
|
+
/* @__PURE__ */ t("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
827
|
+
] }) : Pa(
|
|
828
|
+
i,
|
|
667
829
|
s,
|
|
830
|
+
Ae,
|
|
668
831
|
c,
|
|
832
|
+
o,
|
|
669
833
|
e,
|
|
670
|
-
|
|
671
|
-
|
|
834
|
+
oe ? Ne : void 0,
|
|
835
|
+
N,
|
|
836
|
+
P,
|
|
837
|
+
B,
|
|
838
|
+
na,
|
|
839
|
+
(r, p) => {
|
|
840
|
+
Qe(r, p);
|
|
841
|
+
},
|
|
842
|
+
(r) => {
|
|
843
|
+
Je(r);
|
|
844
|
+
}
|
|
672
845
|
),
|
|
673
|
-
|
|
674
|
-
|
|
846
|
+
i.progress && !sa ? /* @__PURE__ */ t(
|
|
847
|
+
De,
|
|
675
848
|
{
|
|
676
849
|
assistantName: e,
|
|
677
|
-
progress:
|
|
850
|
+
progress: i.progress
|
|
678
851
|
}
|
|
679
852
|
) : null,
|
|
680
|
-
|
|
681
|
-
|
|
853
|
+
i.error && !ra ? /* @__PURE__ */ t(
|
|
854
|
+
De,
|
|
682
855
|
{
|
|
683
856
|
assistantName: e,
|
|
684
|
-
error:
|
|
685
|
-
onRetry:
|
|
857
|
+
error: i.error,
|
|
858
|
+
onRetry: oe ? Ne : void 0
|
|
686
859
|
}
|
|
687
860
|
) : null
|
|
688
861
|
]
|
|
689
862
|
}
|
|
690
863
|
),
|
|
691
|
-
/* @__PURE__ */
|
|
692
|
-
|
|
864
|
+
Ze ? /* @__PURE__ */ t(
|
|
865
|
+
"button",
|
|
866
|
+
{
|
|
867
|
+
"aria-label": "回到最新消息",
|
|
868
|
+
className: "make-ai-assistant__back-to-latest",
|
|
869
|
+
type: "button",
|
|
870
|
+
onClick: Ye,
|
|
871
|
+
children: "回到最新消息"
|
|
872
|
+
}
|
|
873
|
+
) : null,
|
|
874
|
+
/* @__PURE__ */ n("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
875
|
+
V === "ready" && be.length > 0 && i.messages.length === 0 ? /* @__PURE__ */ t("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: be.map((r, p) => /* @__PURE__ */ t(
|
|
693
876
|
"button",
|
|
694
877
|
{
|
|
695
878
|
type: "button",
|
|
696
879
|
onClick: () => {
|
|
697
|
-
|
|
880
|
+
ie(r);
|
|
698
881
|
},
|
|
699
|
-
children:
|
|
882
|
+
children: r
|
|
700
883
|
},
|
|
701
|
-
`${
|
|
884
|
+
`${p}-${r}`
|
|
702
885
|
)) }) : null,
|
|
703
|
-
/* @__PURE__ */
|
|
886
|
+
/* @__PURE__ */ n("form", { className: "make-ai-assistant__composer", onSubmit: We, children: [
|
|
704
887
|
/* @__PURE__ */ t(
|
|
705
888
|
"textarea",
|
|
706
889
|
{
|
|
707
890
|
"aria-label": `向 ${e} 提问`,
|
|
708
|
-
"aria-describedby":
|
|
709
|
-
"aria-invalid":
|
|
891
|
+
"aria-describedby": K ? "make-ai-composer-error" : void 0,
|
|
892
|
+
"aria-invalid": K ? !0 : void 0,
|
|
710
893
|
autoFocus: !0,
|
|
711
|
-
disabled:
|
|
712
|
-
placeholder: `询问当前 ${
|
|
894
|
+
disabled: V !== "ready" || i.status === "streaming",
|
|
895
|
+
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
713
896
|
rows: 2,
|
|
714
|
-
value:
|
|
715
|
-
onChange: (
|
|
716
|
-
|
|
897
|
+
value: R,
|
|
898
|
+
onChange: (r) => {
|
|
899
|
+
x(r.currentTarget.value), w(void 0);
|
|
717
900
|
},
|
|
718
|
-
onKeyDown:
|
|
901
|
+
onKeyDown: Xe
|
|
719
902
|
}
|
|
720
903
|
),
|
|
721
|
-
|
|
904
|
+
i.status === "streaming" ? /* @__PURE__ */ t(
|
|
722
905
|
"button",
|
|
723
906
|
{
|
|
724
|
-
"aria-label":
|
|
907
|
+
"aria-label": ta,
|
|
725
908
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
726
909
|
type: "button",
|
|
727
|
-
onClick:
|
|
910
|
+
onClick: ea,
|
|
728
911
|
children: /* @__PURE__ */ t("span", { "aria-hidden": "true" })
|
|
729
912
|
}
|
|
730
913
|
) : /* @__PURE__ */ t(
|
|
@@ -732,81 +915,81 @@ function ea({
|
|
|
732
915
|
{
|
|
733
916
|
"aria-label": "发送",
|
|
734
917
|
className: "make-ai-assistant__send",
|
|
735
|
-
disabled:
|
|
918
|
+
disabled: V !== "ready" || !R.trim(),
|
|
736
919
|
type: "submit",
|
|
737
|
-
children: /* @__PURE__ */ t(
|
|
920
|
+
children: /* @__PURE__ */ t(Ca, {})
|
|
738
921
|
}
|
|
739
922
|
)
|
|
740
923
|
] }),
|
|
741
|
-
|
|
924
|
+
K ? /* @__PURE__ */ t("p", { id: "make-ai-composer-error", role: "alert", children: K }) : null,
|
|
742
925
|
/* @__PURE__ */ t("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
743
926
|
] })
|
|
744
927
|
] });
|
|
745
928
|
}
|
|
746
|
-
function
|
|
929
|
+
function Ha({
|
|
747
930
|
defaultOpen: e = !1,
|
|
748
931
|
hideLauncher: a = !1,
|
|
749
932
|
launcher: s,
|
|
750
933
|
onOpenChange: c,
|
|
751
|
-
open:
|
|
752
|
-
...
|
|
934
|
+
open: o,
|
|
935
|
+
...d
|
|
753
936
|
}) {
|
|
754
|
-
const [
|
|
755
|
-
|
|
756
|
-
},
|
|
757
|
-
return
|
|
758
|
-
if (!
|
|
759
|
-
const
|
|
760
|
-
|
|
937
|
+
const m = Ke(d.brandName, d.title), [h, $] = E(e), y = S(null), k = o ?? h, f = (N) => {
|
|
938
|
+
o === void 0 && $(N), c?.(N), N || requestAnimationFrame(() => y.current?.focus());
|
|
939
|
+
}, P = () => f(!k);
|
|
940
|
+
return ge(() => {
|
|
941
|
+
if (!k) return;
|
|
942
|
+
const N = (U) => {
|
|
943
|
+
U.key === "Escape" && (f(!1), requestAnimationFrame(() => y.current?.focus()));
|
|
761
944
|
};
|
|
762
|
-
return document.addEventListener("keydown",
|
|
763
|
-
}, [c,
|
|
764
|
-
!a && (!
|
|
945
|
+
return document.addEventListener("keydown", N), () => document.removeEventListener("keydown", N);
|
|
946
|
+
}, [c, k]), /* @__PURE__ */ n("div", { className: "make-ai-assistant", "data-open": k || void 0, children: [
|
|
947
|
+
!a && (!k || s) ? s ? s({ open: k, toggle: P }) : /* @__PURE__ */ n(
|
|
765
948
|
"button",
|
|
766
949
|
{
|
|
767
|
-
"aria-label":
|
|
768
|
-
"aria-expanded":
|
|
950
|
+
"aria-label": k ? `关闭 ${m}` : `打开 ${m}`,
|
|
951
|
+
"aria-expanded": k,
|
|
769
952
|
className: "make-ai-assistant__launcher",
|
|
770
|
-
ref:
|
|
953
|
+
ref: y,
|
|
771
954
|
type: "button",
|
|
772
|
-
onClick:
|
|
955
|
+
onClick: P,
|
|
773
956
|
children: [
|
|
774
957
|
/* @__PURE__ */ t("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
775
|
-
/* @__PURE__ */ t(
|
|
958
|
+
/* @__PURE__ */ t(Be, {})
|
|
776
959
|
]
|
|
777
960
|
}
|
|
778
961
|
) : null,
|
|
779
|
-
|
|
962
|
+
k ? /* @__PURE__ */ t(
|
|
780
963
|
"aside",
|
|
781
964
|
{
|
|
782
|
-
"aria-label":
|
|
965
|
+
"aria-label": m,
|
|
783
966
|
"aria-modal": "false",
|
|
784
967
|
className: "make-ai-assistant__drawer",
|
|
785
968
|
role: "dialog",
|
|
786
|
-
children: /* @__PURE__ */ t(
|
|
969
|
+
children: /* @__PURE__ */ t(Ua, { ...d, onClose: () => f(!1) })
|
|
787
970
|
}
|
|
788
971
|
) : null
|
|
789
972
|
] });
|
|
790
973
|
}
|
|
791
974
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
975
|
+
da as ArtifactRenderer,
|
|
976
|
+
Ua as AssistantPanel,
|
|
977
|
+
ja as MAKE_AI_ARTIFACT_KINDS,
|
|
978
|
+
Ya as MAKE_AI_ARTIFACT_LIMITS,
|
|
979
|
+
Ja as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
980
|
+
A as MAKE_AI_CONVERSATION_LIMITS,
|
|
981
|
+
Ha as MakeAiAssistant,
|
|
982
|
+
ca as appendUserMessage,
|
|
983
|
+
oa as createArtifactCapabilities,
|
|
984
|
+
Pe as createArtifactTemplateRegistry,
|
|
985
|
+
ue as createAssistantConversationState,
|
|
986
|
+
ya as createPlatformArtifactRegistry,
|
|
987
|
+
Ga as extendArtifactTemplateRegistry,
|
|
988
|
+
D as formatArtifactValue,
|
|
989
|
+
Qa as parseArtifact,
|
|
990
|
+
la as parseAssistantEvent,
|
|
991
|
+
ka as platformArtifactTemplates,
|
|
992
|
+
pe as reduceAssistantEvent,
|
|
993
|
+
ia as resolveArtifactTemplate,
|
|
994
|
+
Wa as validateArtifact
|
|
812
995
|
};
|