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