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