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