@qfei-design/make-ai-assistant 0.1.0 → 0.1.2
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 +63 -4
- package/README.md +61 -4
- package/capabilities.json +18 -0
- package/dist/conversation-Dy2Sghjv.js +684 -0
- package/dist/conversation-Yku9Lzj_.cjs +1 -0
- package/dist/core/conversation.d.ts +30 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/make-app.cjs +1 -0
- package/dist/make-app.d.ts +36 -0
- package/dist/make-app.mjs +287 -0
- package/dist/make-console.cjs +1 -0
- package/dist/make-console.d.ts +58 -0
- package/dist/make-console.mjs +366 -0
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +384 -326
- package/dist/sse.cjs +1 -1
- package/dist/sse.mjs +1 -1
- package/dist/styles.css +29 -0
- package/docs/backend-contract.md +52 -3
- package/package.ai.json +9 -5
- package/package.json +11 -1
- package/recipes.json +36 -0
- package/dist/conversation-B5kECJz8.js +0 -595
- package/dist/conversation-DpYszfVd.cjs +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { resolveArtifactTemplate as
|
|
3
|
-
import { extendArtifactTemplateRegistry as
|
|
4
|
-
import { useState as
|
|
5
|
-
import {
|
|
6
|
-
import { d as
|
|
7
|
-
function
|
|
1
|
+
import { jsxs as n, jsx as a, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { resolveArtifactTemplate as be, createArtifactTemplateRegistry as de, createArtifactCapabilities as Ae } from "./index.mjs";
|
|
3
|
+
import { extendArtifactTemplateRegistry as We } from "./index.mjs";
|
|
4
|
+
import { useState as P, useRef as T, useMemo as Ne, useEffect as Q } from "react";
|
|
5
|
+
import { a as G, c as ee, M as I, b as we, p as Te, r as J } from "./conversation-Dy2Sghjv.js";
|
|
6
|
+
import { d as ea, e as aa, f as ta, g as sa, v as na } from "./conversation-Dy2Sghjv.js";
|
|
7
|
+
function Me({
|
|
8
8
|
artifact: e,
|
|
9
9
|
context: t,
|
|
10
|
-
fallback:
|
|
11
|
-
onAction:
|
|
12
|
-
onActionError:
|
|
13
|
-
registry:
|
|
10
|
+
fallback: s,
|
|
11
|
+
onAction: l,
|
|
12
|
+
onActionError: c,
|
|
13
|
+
registry: r
|
|
14
14
|
}) {
|
|
15
|
-
const m =
|
|
15
|
+
const m = be(r, e, t);
|
|
16
16
|
if (!m)
|
|
17
|
-
return
|
|
17
|
+
return s ? s(e) : /* @__PURE__ */ n("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
18
18
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
19
|
-
/* @__PURE__ */
|
|
19
|
+
/* @__PURE__ */ n("span", { children: [
|
|
20
20
|
"结果类型:",
|
|
21
21
|
e.kind
|
|
22
22
|
] })
|
|
23
23
|
] });
|
|
24
|
-
const
|
|
24
|
+
const h = {
|
|
25
25
|
context: t,
|
|
26
|
-
onAction:
|
|
27
|
-
onActionError:
|
|
26
|
+
onAction: l,
|
|
27
|
+
onActionError: c
|
|
28
28
|
};
|
|
29
|
-
return m.template.render(e, t,
|
|
29
|
+
return m.template.render(e, t, h);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const C = (e, t, s) => {
|
|
32
32
|
if (e == null || e === "") return "—";
|
|
33
33
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
34
34
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
35
|
-
const
|
|
36
|
-
maximumFractionDigits:
|
|
37
|
-
minimumFractionDigits:
|
|
35
|
+
const l = t?.precision, c = {
|
|
36
|
+
maximumFractionDigits: l ?? 2,
|
|
37
|
+
minimumFractionDigits: l
|
|
38
38
|
};
|
|
39
|
-
t?.style === "currency" && t.currency ? (
|
|
39
|
+
t?.style === "currency" && t.currency ? (c.style = "currency", c.currency = t.currency) : t?.style === "percent" && (c.style = "percent");
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
return `${new Intl.NumberFormat(
|
|
41
|
+
const r = t?.style === "percent" ? e / 100 : e;
|
|
42
|
+
return `${new Intl.NumberFormat(s, c).format(r)}${t?.unit ?? ""}`;
|
|
43
43
|
} catch {
|
|
44
44
|
return `${e}${t?.unit ?? ""}`;
|
|
45
45
|
}
|
|
46
|
-
},
|
|
47
|
-
let t = Number.POSITIVE_INFINITY,
|
|
48
|
-
for (const
|
|
49
|
-
t = Math.min(t,
|
|
50
|
-
return Number.isFinite(t) && Number.isFinite(
|
|
51
|
-
},
|
|
52
|
-
if (!
|
|
53
|
-
const
|
|
46
|
+
}, me = (e) => {
|
|
47
|
+
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
48
|
+
for (const l of e)
|
|
49
|
+
t = Math.min(t, l), s = Math.max(s, l);
|
|
50
|
+
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
51
|
+
}, ue = (e, t, s) => {
|
|
52
|
+
if (!s.onAction) return;
|
|
53
|
+
const l = (r) => {
|
|
54
54
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
55
55
|
actionId: e.id,
|
|
56
56
|
artifactId: t.artifact.id,
|
|
57
|
-
errorType:
|
|
57
|
+
errorType: r instanceof Error ? r.name : typeof r,
|
|
58
58
|
intent: e.intent
|
|
59
59
|
});
|
|
60
|
-
},
|
|
61
|
-
if (
|
|
60
|
+
}, c = (r) => {
|
|
61
|
+
if (s.onActionError) {
|
|
62
62
|
try {
|
|
63
63
|
Promise.resolve(
|
|
64
|
-
|
|
65
|
-
).catch(
|
|
64
|
+
s.onActionError(r, e, t)
|
|
65
|
+
).catch(l);
|
|
66
66
|
} catch (m) {
|
|
67
|
-
|
|
67
|
+
l(m);
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
console.error("[make-ai-assistant] host action failed", {
|
|
72
72
|
actionId: e.id,
|
|
73
73
|
artifactId: t.artifact.id,
|
|
74
|
-
errorType:
|
|
74
|
+
errorType: r instanceof Error ? r.name : typeof r,
|
|
75
75
|
intent: e.intent
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
try {
|
|
79
|
-
Promise.resolve(
|
|
80
|
-
} catch (
|
|
81
|
-
|
|
79
|
+
Promise.resolve(s.onAction(e, t)).catch(c);
|
|
80
|
+
} catch (r) {
|
|
81
|
+
c(r);
|
|
82
82
|
}
|
|
83
|
-
},
|
|
83
|
+
}, K = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ n(
|
|
84
84
|
"button",
|
|
85
85
|
{
|
|
86
|
-
className: `make-ai-artifact__action make-ai-artifact__action--${
|
|
86
|
+
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
87
87
|
type: "button",
|
|
88
|
-
onClick: () =>
|
|
88
|
+
onClick: () => ue(s, { artifact: e, context: t.context }, t),
|
|
89
89
|
children: [
|
|
90
|
-
|
|
90
|
+
s.label,
|
|
91
91
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
|
-
|
|
95
|
-
)) }) : null,
|
|
94
|
+
s.id
|
|
95
|
+
)) }) : null, V = (e, t, s = "") => /* @__PURE__ */ n(
|
|
96
96
|
"section",
|
|
97
97
|
{
|
|
98
98
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
99
|
-
className: `make-ai-artifact ${
|
|
99
|
+
className: `make-ai-artifact ${s}`.trim(),
|
|
100
100
|
"data-artifact-density": e.presentation?.density,
|
|
101
101
|
"data-artifact-kind": e.kind,
|
|
102
102
|
children: [
|
|
@@ -105,137 +105,137 @@ const w = (e, t, n) => {
|
|
|
105
105
|
t
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
|
-
),
|
|
108
|
+
), Ce = ({
|
|
109
109
|
artifact: e,
|
|
110
110
|
renderContext: t
|
|
111
111
|
}) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const s = e.data.delta, l = s ? C(
|
|
113
|
+
s.value,
|
|
114
|
+
s.format === "percent" ? { style: "percent" } : void 0,
|
|
115
115
|
t.context.locale
|
|
116
116
|
) : void 0;
|
|
117
|
-
return
|
|
117
|
+
return V(
|
|
118
118
|
e,
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
119
|
+
/* @__PURE__ */ n(M, { children: [
|
|
120
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: C(
|
|
121
121
|
e.data.value,
|
|
122
122
|
e.data.format,
|
|
123
123
|
t.context.locale
|
|
124
124
|
) }),
|
|
125
|
-
|
|
125
|
+
s ? /* @__PURE__ */ n(
|
|
126
126
|
"div",
|
|
127
127
|
{
|
|
128
|
-
className: `make-ai-artifact__delta make-ai-artifact__delta--${
|
|
128
|
+
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
129
129
|
children: [
|
|
130
|
-
/* @__PURE__ */ a("span", { "aria-hidden": "true", children:
|
|
131
|
-
/* @__PURE__ */ a("span", { children:
|
|
132
|
-
|
|
130
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
|
|
131
|
+
/* @__PURE__ */ a("span", { children: l }),
|
|
132
|
+
s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
|
|
133
133
|
]
|
|
134
134
|
}
|
|
135
135
|
) : null,
|
|
136
136
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
137
|
-
|
|
137
|
+
K(e, t)
|
|
138
138
|
] }),
|
|
139
139
|
"make-ai-artifact--metric"
|
|
140
140
|
);
|
|
141
|
-
},
|
|
141
|
+
}, Ee = ({
|
|
142
142
|
artifact: e,
|
|
143
143
|
renderContext: t
|
|
144
|
-
}) =>
|
|
144
|
+
}) => V(
|
|
145
145
|
e,
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((
|
|
148
|
-
/* @__PURE__ */ a("span", { children:
|
|
149
|
-
/* @__PURE__ */ a("strong", { children:
|
|
150
|
-
|
|
151
|
-
] },
|
|
152
|
-
|
|
146
|
+
/* @__PURE__ */ n(M, { children: [
|
|
147
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ n("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
148
|
+
/* @__PURE__ */ a("span", { children: s.label }),
|
|
149
|
+
/* @__PURE__ */ a("strong", { children: C(s.value, s.format, t.context.locale) }),
|
|
150
|
+
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
151
|
+
] }, s.id)) }),
|
|
152
|
+
K(e, t)
|
|
153
153
|
] }),
|
|
154
154
|
"make-ai-artifact--comparison"
|
|
155
|
-
),
|
|
155
|
+
), Re = ({
|
|
156
156
|
artifact: e,
|
|
157
157
|
renderContext: t
|
|
158
158
|
}) => {
|
|
159
|
-
const
|
|
160
|
-
return
|
|
159
|
+
const s = e.data.series.flatMap((m) => m.points.map((h) => h.y)), { max: l, min: c } = me(s), r = l - c || 1;
|
|
160
|
+
return V(
|
|
161
161
|
e,
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((m) => /* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ n(M, { children: [
|
|
163
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((m) => /* @__PURE__ */ n("div", { className: "make-ai-artifact__trend-series", children: [
|
|
164
164
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: m.label }),
|
|
165
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: m.points.map((
|
|
166
|
-
const
|
|
167
|
-
return /* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: m.points.map((h, N) => {
|
|
166
|
+
const u = 18 + (h.y - c) / r * 70;
|
|
167
|
+
return /* @__PURE__ */ n("div", { className: "make-ai-artifact__trend-point", children: [
|
|
168
168
|
/* @__PURE__ */ a(
|
|
169
169
|
"span",
|
|
170
170
|
{
|
|
171
|
-
"aria-label": `${
|
|
172
|
-
|
|
171
|
+
"aria-label": `${h.x}: ${C(
|
|
172
|
+
h.y,
|
|
173
173
|
m.format,
|
|
174
174
|
t.context.locale
|
|
175
175
|
)}`,
|
|
176
176
|
className: "make-ai-artifact__trend-bar",
|
|
177
177
|
role: "img",
|
|
178
|
-
style: { height: `${
|
|
179
|
-
title: `${
|
|
180
|
-
|
|
178
|
+
style: { height: `${u}%` },
|
|
179
|
+
title: `${h.x}: ${C(
|
|
180
|
+
h.y,
|
|
181
181
|
m.format,
|
|
182
182
|
t.context.locale
|
|
183
183
|
)}`
|
|
184
184
|
}
|
|
185
185
|
),
|
|
186
|
-
/* @__PURE__ */ a("small", { children:
|
|
187
|
-
] }, `${
|
|
186
|
+
/* @__PURE__ */ a("small", { children: h.x })
|
|
187
|
+
] }, `${h.x}-${N}`);
|
|
188
188
|
}) })
|
|
189
189
|
] }, m.id)) }),
|
|
190
|
-
|
|
190
|
+
K(e, t)
|
|
191
191
|
] }),
|
|
192
192
|
"make-ai-artifact--trend"
|
|
193
193
|
);
|
|
194
|
-
},
|
|
194
|
+
}, $e = ({
|
|
195
195
|
artifact: e,
|
|
196
196
|
renderContext: t
|
|
197
197
|
}) => {
|
|
198
|
-
const { max:
|
|
199
|
-
e.data.items.map((
|
|
200
|
-
),
|
|
201
|
-
return
|
|
198
|
+
const { max: s } = me(
|
|
199
|
+
e.data.items.map((c) => Math.abs(c.value))
|
|
200
|
+
), l = Math.max(s, 1);
|
|
201
|
+
return V(
|
|
202
202
|
e,
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((
|
|
205
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children:
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */ a("span", { children:
|
|
208
|
-
|
|
203
|
+
/* @__PURE__ */ n(M, { children: [
|
|
204
|
+
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((c, r) => /* @__PURE__ */ n("li", { children: [
|
|
205
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: r + 1 }),
|
|
206
|
+
/* @__PURE__ */ n("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
207
|
+
/* @__PURE__ */ a("span", { children: c.label }),
|
|
208
|
+
c.description ? /* @__PURE__ */ a("small", { children: c.description }) : null
|
|
209
209
|
] }),
|
|
210
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(
|
|
211
|
-
/* @__PURE__ */ a("strong", { children:
|
|
212
|
-
] },
|
|
213
|
-
|
|
210
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(c.value) / l * 100}%` } }) }),
|
|
211
|
+
/* @__PURE__ */ a("strong", { children: C(c.value, c.format, t.context.locale) })
|
|
212
|
+
] }, c.id)) }),
|
|
213
|
+
K(e, t)
|
|
214
214
|
] }),
|
|
215
215
|
"make-ai-artifact--ranking"
|
|
216
216
|
);
|
|
217
|
-
},
|
|
217
|
+
}, Se = (e, t) => t.action ?? {
|
|
218
218
|
id: `open-${t.id}`,
|
|
219
219
|
label: t.title ?? t.id,
|
|
220
220
|
intent: "open-record",
|
|
221
221
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
222
|
-
},
|
|
222
|
+
}, Fe = ({
|
|
223
223
|
artifact: e,
|
|
224
224
|
renderContext: t
|
|
225
|
-
}) =>
|
|
225
|
+
}) => V(
|
|
226
226
|
e,
|
|
227
|
-
/* @__PURE__ */
|
|
228
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((
|
|
229
|
-
const
|
|
230
|
-
/* @__PURE__ */ a("strong", { children:
|
|
231
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((
|
|
232
|
-
/* @__PURE__ */ a("small", { children:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
227
|
+
/* @__PURE__ */ n(M, { children: [
|
|
228
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
|
|
229
|
+
const l = Se(e, s), c = /* @__PURE__ */ n(M, { children: [
|
|
230
|
+
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
231
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((r) => /* @__PURE__ */ n("span", { children: [
|
|
232
|
+
/* @__PURE__ */ a("small", { children: r.label }),
|
|
233
|
+
C(
|
|
234
|
+
s.values[r.key],
|
|
235
|
+
r.format,
|
|
236
236
|
t.context.locale
|
|
237
237
|
)
|
|
238
|
-
] },
|
|
238
|
+
] }, r.key)) }),
|
|
239
239
|
t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
|
|
240
240
|
] });
|
|
241
241
|
return t.onAction ? /* @__PURE__ */ a(
|
|
@@ -243,53 +243,53 @@ const w = (e, t, n) => {
|
|
|
243
243
|
{
|
|
244
244
|
className: "make-ai-artifact__record",
|
|
245
245
|
type: "button",
|
|
246
|
-
onClick: () =>
|
|
246
|
+
onClick: () => ue(l, {
|
|
247
247
|
artifact: e,
|
|
248
248
|
context: t.context
|
|
249
249
|
}, t),
|
|
250
|
-
children:
|
|
250
|
+
children: c
|
|
251
251
|
},
|
|
252
|
-
|
|
253
|
-
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children:
|
|
252
|
+
s.id
|
|
253
|
+
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: c }, s.id);
|
|
254
254
|
}) }),
|
|
255
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
255
|
+
e.data.total !== void 0 ? /* @__PURE__ */ n("p", { className: "make-ai-artifact__record-total", children: [
|
|
256
256
|
"共 ",
|
|
257
257
|
e.data.total,
|
|
258
258
|
" 条"
|
|
259
259
|
] }) : null,
|
|
260
|
-
|
|
260
|
+
K(e, t)
|
|
261
261
|
] }),
|
|
262
262
|
"make-ai-artifact--record-list"
|
|
263
|
-
),
|
|
263
|
+
), xe = ({
|
|
264
264
|
artifact: e,
|
|
265
265
|
renderContext: t
|
|
266
|
-
}) =>
|
|
266
|
+
}) => V(
|
|
267
267
|
e,
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ n(M, { children: [
|
|
269
|
+
/* @__PURE__ */ n("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
270
270
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
271
271
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
272
272
|
] }),
|
|
273
|
-
|
|
273
|
+
K(e, t)
|
|
274
274
|
] }),
|
|
275
275
|
"make-ai-artifact--notice"
|
|
276
|
-
),
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
],
|
|
276
|
+
), D = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), De = [
|
|
277
|
+
D("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Ce, { artifact: e, renderContext: s })),
|
|
278
|
+
D("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ee, { artifact: e, renderContext: s })),
|
|
279
|
+
D("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Re, { artifact: e, renderContext: s })),
|
|
280
|
+
D("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a($e, { artifact: e, renderContext: s })),
|
|
281
|
+
D("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(Fe, { artifact: e, renderContext: s })),
|
|
282
|
+
D("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(xe, { artifact: e, renderContext: s }))
|
|
283
|
+
], Pe = de(De).templates, Ke = (e = Pe) => de(e), Ve = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
284
284
|
class p extends Error {
|
|
285
285
|
}
|
|
286
|
-
const
|
|
286
|
+
const le = (e) => {
|
|
287
287
|
try {
|
|
288
288
|
const t = e?.return?.();
|
|
289
289
|
if (!t) return;
|
|
290
|
-
Promise.resolve(t).catch((
|
|
290
|
+
Promise.resolve(t).catch((s) => {
|
|
291
291
|
console.error("[make-ai-assistant] transport iterator close failed", {
|
|
292
|
-
errorType:
|
|
292
|
+
errorType: s instanceof Error ? s.name : typeof s
|
|
293
293
|
});
|
|
294
294
|
});
|
|
295
295
|
} catch (t) {
|
|
@@ -297,283 +297,341 @@ const ne = (e) => {
|
|
|
297
297
|
errorType: t instanceof Error ? t.name : typeof t
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
|
-
},
|
|
300
|
+
}, pe = () => /* @__PURE__ */ n("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
301
301
|
/* @__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" }),
|
|
302
302
|
/* @__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" })
|
|
303
|
-
] }),
|
|
303
|
+
] }), qe = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), ze = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), He = () => /* @__PURE__ */ n("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
304
304
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
305
305
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
306
|
-
] }),
|
|
306
|
+
] }), B = () => /* @__PURE__ */ a("span", { className: "make-ai-assistant__avatar", "aria-hidden": "true", children: /* @__PURE__ */ a(pe, {}) }), Le = (e, t, s, l, c) => e.messages.map((r) => /* @__PURE__ */ n(
|
|
307
307
|
"article",
|
|
308
308
|
{
|
|
309
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
309
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${r.role}`,
|
|
310
310
|
children: [
|
|
311
|
-
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
|
|
311
|
+
r.role === "assistant" ? /* @__PURE__ */ a(B, {}) : null,
|
|
312
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__message-stack", children: [
|
|
313
|
+
r.content ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: r.content }) : r.status === "streaming" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__typing", "aria-label": "AI 正在思考", children: [
|
|
314
314
|
/* @__PURE__ */ a("span", {}),
|
|
315
315
|
/* @__PURE__ */ a("span", {}),
|
|
316
316
|
/* @__PURE__ */ a("span", {})
|
|
317
317
|
] }) : null,
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
r.artifacts.map((m) => /* @__PURE__ */ a(
|
|
319
|
+
Me,
|
|
320
320
|
{
|
|
321
321
|
artifact: m,
|
|
322
322
|
context: t,
|
|
323
|
-
onAction:
|
|
324
|
-
onActionError:
|
|
325
|
-
registry:
|
|
323
|
+
onAction: l,
|
|
324
|
+
onActionError: c,
|
|
325
|
+
registry: s
|
|
326
326
|
},
|
|
327
327
|
m.id
|
|
328
328
|
))
|
|
329
329
|
] })
|
|
330
330
|
]
|
|
331
331
|
},
|
|
332
|
-
|
|
332
|
+
r.id
|
|
333
333
|
));
|
|
334
|
-
function
|
|
334
|
+
function Be({
|
|
335
335
|
context: e,
|
|
336
336
|
onAction: t,
|
|
337
|
-
onActionError:
|
|
338
|
-
onClose:
|
|
339
|
-
onNewConversation:
|
|
340
|
-
registry:
|
|
337
|
+
onActionError: s,
|
|
338
|
+
onClose: l,
|
|
339
|
+
onNewConversation: c,
|
|
340
|
+
registry: r,
|
|
341
341
|
subtitle: m,
|
|
342
|
-
suggestions:
|
|
343
|
-
title:
|
|
344
|
-
transport:
|
|
342
|
+
suggestions: h = [],
|
|
343
|
+
title: N = "Make AI 助手",
|
|
344
|
+
transport: u
|
|
345
345
|
}) {
|
|
346
|
-
const [
|
|
347
|
-
() =>
|
|
348
|
-
[
|
|
349
|
-
),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return M.current = void 0, E.current = void 0, !_ && !g ? !1 : (console.info("[make-ai-assistant] local run cancellation requested", { reason: o }), _?.abort(), ne(g), !0);
|
|
346
|
+
const [b, w] = P(""), [d, v] = P(G), [O, q] = P(void 0), [he, fe] = P(0), [E, Z] = P(() => u.loadConversation ? "loading" : "ready"), R = T(void 0), $ = T(void 0), S = T(0), W = T(null), j = T(!0), ae = T(e.app.id), te = Ne(
|
|
347
|
+
() => r ?? Ke(),
|
|
348
|
+
[r]
|
|
349
|
+
), U = (o) => {
|
|
350
|
+
const k = R.current, _ = $.current?.iterator;
|
|
351
|
+
return !k && !_ ? !1 : (S.current += 1, R.current = void 0, $.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: o }), k?.abort(), le(_), !0);
|
|
353
352
|
};
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}, []),
|
|
357
|
-
const o =
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
353
|
+
Q(() => () => {
|
|
354
|
+
U("unmount");
|
|
355
|
+
}, []), Q(() => {
|
|
356
|
+
const o = u.loadConversation, k = ae.current !== e.app.id;
|
|
357
|
+
if (ae.current = e.app.id, U("reinitialize"), k && (w(""), j.current = !0), q(void 0), v(G()), !o) {
|
|
358
|
+
Z("ready");
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const _ = new AbortController();
|
|
362
|
+
return Z("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
363
|
+
appId: e.app.id
|
|
364
|
+
}), o.call(u, e, { signal: _.signal }).then((g) => {
|
|
365
|
+
_.signal.aborted || (v(G(g)), Z("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
366
|
+
appId: e.app.id,
|
|
367
|
+
messageCount: g.messages.length
|
|
368
|
+
}));
|
|
369
|
+
}).catch((g) => {
|
|
370
|
+
_.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
371
|
+
appId: e.app.id,
|
|
372
|
+
errorType: g instanceof Error ? g.name : typeof g
|
|
373
|
+
}), Z("error"));
|
|
374
|
+
}), () => _.abort();
|
|
375
|
+
}, [e.app.id, he, u]), Q(() => {
|
|
376
|
+
const o = W.current;
|
|
377
|
+
if (!o || !j.current) return;
|
|
378
|
+
const k = requestAnimationFrame(() => {
|
|
379
|
+
if (!j.current) return;
|
|
380
|
+
const _ = d.status === "streaming" || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
381
|
+
typeof o.scrollTo == "function" ? o.scrollTo({ top: o.scrollHeight, behavior: _ }) : o.scrollTop = o.scrollHeight;
|
|
363
382
|
});
|
|
364
|
-
return () => cancelAnimationFrame(
|
|
383
|
+
return () => cancelAnimationFrame(k);
|
|
365
384
|
}, [d.messages, d.status]);
|
|
366
|
-
const
|
|
367
|
-
const o =
|
|
368
|
-
o && (
|
|
369
|
-
},
|
|
370
|
-
const
|
|
371
|
-
if (!
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
) >
|
|
376
|
-
|
|
377
|
-
`输入内容过长,请控制在 ${
|
|
385
|
+
const _e = () => {
|
|
386
|
+
const o = W.current;
|
|
387
|
+
o && (j.current = o.scrollHeight - o.scrollTop - o.clientHeight <= 48);
|
|
388
|
+
}, X = async (o) => {
|
|
389
|
+
const k = o.trim();
|
|
390
|
+
if (!k || E !== "ready" || d.status === "streaming" || R.current) return;
|
|
391
|
+
if (ee(
|
|
392
|
+
k,
|
|
393
|
+
I.messageCharacters
|
|
394
|
+
) > I.messageCharacters) {
|
|
395
|
+
q(
|
|
396
|
+
`输入内容过长,请控制在 ${I.messageCharacters} 个字符以内`
|
|
378
397
|
);
|
|
379
398
|
return;
|
|
380
399
|
}
|
|
381
|
-
const
|
|
382
|
-
|
|
400
|
+
const _ = { id: Ve("user"), content: k }, g = new AbortController(), F = S.current + 1;
|
|
401
|
+
S.current = F, R.current = g, q(void 0), w(""), v((y) => we(y, _));
|
|
383
402
|
try {
|
|
384
|
-
let
|
|
385
|
-
const
|
|
386
|
-
[...d.messages.map((
|
|
387
|
-
),
|
|
403
|
+
let y = !1, f, se = 0, ne = 0, z = 0;
|
|
404
|
+
const H = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Set(), ie = /* @__PURE__ */ new Set(
|
|
405
|
+
[...d.messages.map((Y) => Y.id), _.id]
|
|
406
|
+
), L = /* @__PURE__ */ new Set(), oe = u.run(
|
|
388
407
|
{
|
|
389
408
|
threadId: d.threadId,
|
|
390
|
-
message:
|
|
409
|
+
message: _,
|
|
391
410
|
context: e,
|
|
392
|
-
capabilities:
|
|
411
|
+
capabilities: Ae(te)
|
|
393
412
|
},
|
|
394
|
-
{ signal:
|
|
413
|
+
{ signal: g.signal }
|
|
395
414
|
)[Symbol.asyncIterator]();
|
|
396
|
-
for (
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
let
|
|
415
|
+
for ($.current = { iterator: oe, requestVersion: F }; ; ) {
|
|
416
|
+
const Y = await oe.next();
|
|
417
|
+
if (S.current !== F || Y.done) break;
|
|
418
|
+
let i;
|
|
400
419
|
try {
|
|
401
|
-
|
|
402
|
-
} catch (
|
|
420
|
+
i = Te(Y.value);
|
|
421
|
+
} catch (A) {
|
|
403
422
|
throw new p(
|
|
404
|
-
|
|
423
|
+
A instanceof Error ? A.message : "Invalid assistant event"
|
|
405
424
|
);
|
|
406
425
|
}
|
|
407
|
-
if (
|
|
408
|
-
if (f !== void 0 && f !==
|
|
426
|
+
if (i.type === "message.start") {
|
|
427
|
+
if (f !== void 0 && f !== i.runId)
|
|
409
428
|
throw new p("AI 助手响应 run id 不一致");
|
|
410
|
-
if (f ??=
|
|
429
|
+
if (f ??= i.runId, ne += 1, ne > I.assistantMessagesPerRun)
|
|
411
430
|
throw new p("AI 助手单次响应消息数量超过限制");
|
|
412
|
-
if (
|
|
431
|
+
if (ie.has(i.messageId))
|
|
413
432
|
throw new p("AI 助手响应包含重复的 message id");
|
|
414
|
-
|
|
433
|
+
ie.add(i.messageId), L.add(i.messageId), H.set(i.messageId, 0);
|
|
415
434
|
}
|
|
416
|
-
if (
|
|
417
|
-
if (!
|
|
435
|
+
if (i.type === "message.delta") {
|
|
436
|
+
if (!L.has(i.messageId))
|
|
418
437
|
throw new p("AI 助手响应事件顺序无效");
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
438
|
+
const A = H.get(i.messageId) ?? 0, x = ee(
|
|
439
|
+
i.delta,
|
|
440
|
+
I.messageCharacters - z
|
|
422
441
|
);
|
|
423
|
-
if (
|
|
442
|
+
if (z + x > I.messageCharacters)
|
|
424
443
|
throw new p("AI 助手响应文本超过大小限制");
|
|
425
|
-
|
|
444
|
+
z += x, H.set(
|
|
445
|
+
i.messageId,
|
|
446
|
+
A + x
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
if (i.type === "message.replace") {
|
|
450
|
+
if (!L.has(i.messageId))
|
|
451
|
+
throw new p("AI 助手响应事件顺序无效");
|
|
452
|
+
const A = H.get(i.messageId) ?? 0, x = ee(
|
|
453
|
+
i.content,
|
|
454
|
+
I.messageCharacters
|
|
455
|
+
), ce = z - A + x;
|
|
456
|
+
if (ce > I.messageCharacters)
|
|
426
457
|
throw new p("AI 助手响应文本超过大小限制");
|
|
458
|
+
z = ce, H.set(i.messageId, x);
|
|
427
459
|
}
|
|
428
|
-
if (
|
|
429
|
-
if (
|
|
460
|
+
if (i.type === "run.progress") {
|
|
461
|
+
if (f !== void 0 && f !== i.runId)
|
|
462
|
+
throw new p("AI 助手响应 run id 不一致");
|
|
463
|
+
f ??= i.runId;
|
|
464
|
+
}
|
|
465
|
+
if (i.type === "artifact") {
|
|
466
|
+
if (!L.has(i.messageId))
|
|
430
467
|
throw new p("AI 助手响应事件顺序无效");
|
|
431
|
-
if (
|
|
468
|
+
if (se += 1, se > I.artifactsPerRun)
|
|
432
469
|
throw new p("AI 助手单次响应 Artifact 数量超过限制");
|
|
433
|
-
if (
|
|
470
|
+
if (re.has(i.artifact.id))
|
|
434
471
|
throw new p("AI 助手响应包含重复的 Artifact id");
|
|
435
|
-
|
|
472
|
+
re.add(i.artifact.id);
|
|
436
473
|
}
|
|
437
|
-
if (
|
|
474
|
+
if (i.type === "message.complete" && !L.delete(i.messageId))
|
|
438
475
|
throw new p("AI 助手响应事件顺序无效");
|
|
439
|
-
if (
|
|
476
|
+
if (i.type === "run.complete" && f !== void 0 && f !== i.runId)
|
|
440
477
|
throw new p("AI 助手响应 run id 不一致");
|
|
441
|
-
if (
|
|
478
|
+
if (i.type === "run.cancelled" && i.runId !== void 0 && f !== void 0 && f !== i.runId)
|
|
442
479
|
throw new p("AI 助手响应 run id 不一致");
|
|
443
|
-
if (
|
|
444
|
-
|
|
480
|
+
if (v((A) => J(A, i)), i.type === "error" || i.type === "run.cancelled" || i.type === "run.complete") {
|
|
481
|
+
y = !0;
|
|
445
482
|
break;
|
|
446
483
|
}
|
|
447
484
|
}
|
|
448
|
-
if (!
|
|
485
|
+
if (!y)
|
|
449
486
|
throw new p("AI 助手流式响应在终止事件前结束");
|
|
450
|
-
} catch (
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
453
|
-
|
|
454
|
-
(f) =>
|
|
487
|
+
} catch (y) {
|
|
488
|
+
if (S.current !== F) return;
|
|
489
|
+
if (g.signal.aborted) {
|
|
490
|
+
v(
|
|
491
|
+
(f) => J(f, { type: "run.cancelled" })
|
|
455
492
|
);
|
|
456
493
|
return;
|
|
457
494
|
}
|
|
458
495
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
459
496
|
appId: e.app.id,
|
|
460
|
-
errorType:
|
|
461
|
-
}),
|
|
462
|
-
(f) =>
|
|
497
|
+
errorType: y instanceof Error ? y.name : typeof y
|
|
498
|
+
}), v(
|
|
499
|
+
(f) => J(f, {
|
|
463
500
|
type: "error",
|
|
464
501
|
code: "TRANSPORT_ERROR",
|
|
465
|
-
message:
|
|
502
|
+
message: y instanceof p ? y.message : "连接失败,请重试",
|
|
466
503
|
retryable: !0
|
|
467
504
|
})
|
|
468
505
|
);
|
|
469
506
|
} finally {
|
|
470
|
-
|
|
507
|
+
S.current === F && R.current === g && (R.current = void 0), $.current?.requestVersion === F && (le($.current.iterator), $.current = void 0);
|
|
471
508
|
}
|
|
472
|
-
},
|
|
473
|
-
o.preventDefault(),
|
|
474
|
-
},
|
|
475
|
-
o.key === "Enter" && !o.shiftKey && !o.nativeEvent.isComposing && (o.preventDefault(),
|
|
476
|
-
},
|
|
477
|
-
|
|
478
|
-
(o) =>
|
|
509
|
+
}, ke = (o) => {
|
|
510
|
+
o.preventDefault(), X(b);
|
|
511
|
+
}, ge = (o) => {
|
|
512
|
+
o.key === "Enter" && !o.shiftKey && !o.nativeEvent.isComposing && (o.preventDefault(), X(b));
|
|
513
|
+
}, ve = () => {
|
|
514
|
+
U("stop") && v(
|
|
515
|
+
(o) => J(o, { type: "run.cancelled" })
|
|
479
516
|
);
|
|
480
|
-
},
|
|
481
|
-
|
|
482
|
-
};
|
|
483
|
-
return /* @__PURE__ */
|
|
484
|
-
/* @__PURE__ */
|
|
485
|
-
/* @__PURE__ */ a(
|
|
486
|
-
/* @__PURE__ */
|
|
487
|
-
/* @__PURE__ */ a("h2", { children:
|
|
488
|
-
/* @__PURE__ */
|
|
517
|
+
}, ye = () => {
|
|
518
|
+
U("new-conversation"), w(""), q(void 0), v(G()), c?.();
|
|
519
|
+
}, Ie = u.features?.remoteCancellation === !1 ? "停止接收" : "停止生成";
|
|
520
|
+
return /* @__PURE__ */ n("section", { className: "make-ai-assistant make-ai-assistant__panel", children: [
|
|
521
|
+
/* @__PURE__ */ n("header", { className: "make-ai-assistant__header", children: [
|
|
522
|
+
/* @__PURE__ */ a(B, {}),
|
|
523
|
+
/* @__PURE__ */ n("div", { children: [
|
|
524
|
+
/* @__PURE__ */ a("h2", { children: N }),
|
|
525
|
+
/* @__PURE__ */ n("p", { children: [
|
|
489
526
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__online-dot" }),
|
|
490
527
|
m ?? e.app.name ?? "当前应用"
|
|
491
528
|
] })
|
|
492
529
|
] }),
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */ a(
|
|
530
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__header-actions", children: [
|
|
531
|
+
u.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
495
532
|
"button",
|
|
496
533
|
{
|
|
497
534
|
"aria-label": "新建对话",
|
|
498
535
|
className: "make-ai-assistant__icon-button",
|
|
499
536
|
type: "button",
|
|
500
|
-
onClick:
|
|
501
|
-
children: /* @__PURE__ */ a(
|
|
537
|
+
onClick: ye,
|
|
538
|
+
children: /* @__PURE__ */ a(ze, {})
|
|
502
539
|
}
|
|
503
|
-
),
|
|
504
|
-
|
|
540
|
+
) : null,
|
|
541
|
+
l ? /* @__PURE__ */ a(
|
|
505
542
|
"button",
|
|
506
543
|
{
|
|
507
544
|
"aria-label": "关闭 Make AI 助手",
|
|
508
545
|
className: "make-ai-assistant__icon-button",
|
|
509
546
|
type: "button",
|
|
510
|
-
onClick:
|
|
511
|
-
children: /* @__PURE__ */ a(
|
|
547
|
+
onClick: l,
|
|
548
|
+
children: /* @__PURE__ */ a(qe, {})
|
|
512
549
|
}
|
|
513
550
|
) : null
|
|
514
551
|
] })
|
|
515
552
|
] }),
|
|
516
|
-
/* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ n("div", { className: "make-ai-assistant__privacy-note", role: "note", children: [
|
|
517
554
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "◇" }),
|
|
518
555
|
"当前页面上下文会随请求发送,数据权限以宿主服务端校验结果为准"
|
|
519
556
|
] }),
|
|
520
|
-
/* @__PURE__ */
|
|
557
|
+
/* @__PURE__ */ n(
|
|
521
558
|
"div",
|
|
522
559
|
{
|
|
523
560
|
className: "make-ai-assistant__body",
|
|
524
561
|
"aria-live": "polite",
|
|
525
|
-
ref:
|
|
526
|
-
onScroll:
|
|
562
|
+
ref: W,
|
|
563
|
+
onScroll: _e,
|
|
527
564
|
children: [
|
|
528
|
-
|
|
529
|
-
/* @__PURE__ */ a(
|
|
565
|
+
E === "loading" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
566
|
+
/* @__PURE__ */ a(B, {}),
|
|
567
|
+
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
568
|
+
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
569
|
+
] }) : E === "error" ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", role: "alert", children: [
|
|
570
|
+
/* @__PURE__ */ a(B, {}),
|
|
571
|
+
/* @__PURE__ */ a("h3", { children: "暂时无法加载对话" }),
|
|
572
|
+
/* @__PURE__ */ a("p", { children: "请检查网络后重试。" }),
|
|
573
|
+
/* @__PURE__ */ a(
|
|
574
|
+
"button",
|
|
575
|
+
{
|
|
576
|
+
className: "make-ai-assistant__retry",
|
|
577
|
+
type: "button",
|
|
578
|
+
onClick: () => fe((o) => o + 1),
|
|
579
|
+
children: "重新加载"
|
|
580
|
+
}
|
|
581
|
+
)
|
|
582
|
+
] }) : d.messages.length === 0 ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__empty", children: [
|
|
583
|
+
/* @__PURE__ */ a(B, {}),
|
|
530
584
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
531
585
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App 和页面上下文理解问题,并用适合的方式展示结果。" })
|
|
532
|
-
] }) :
|
|
533
|
-
d.
|
|
586
|
+
] }) : Le(d, e, te, t, s),
|
|
587
|
+
d.progress ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__progress", role: "status", children: [
|
|
588
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
589
|
+
d.progress.message
|
|
590
|
+
] }) : null,
|
|
591
|
+
d.error ? /* @__PURE__ */ n("div", { className: "make-ai-assistant__error", role: "alert", children: [
|
|
534
592
|
/* @__PURE__ */ a("strong", { children: "暂时无法完成" }),
|
|
535
593
|
/* @__PURE__ */ a("span", { children: d.error.message })
|
|
536
594
|
] }) : null
|
|
537
595
|
]
|
|
538
596
|
}
|
|
539
597
|
),
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
|
|
598
|
+
/* @__PURE__ */ n("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
599
|
+
E === "ready" && h.length > 0 && d.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: h.map((o, k) => /* @__PURE__ */ a(
|
|
542
600
|
"button",
|
|
543
601
|
{
|
|
544
602
|
type: "button",
|
|
545
603
|
onClick: () => {
|
|
546
|
-
|
|
604
|
+
X(o);
|
|
547
605
|
},
|
|
548
606
|
children: o
|
|
549
607
|
},
|
|
550
|
-
`${
|
|
608
|
+
`${k}-${o}`
|
|
551
609
|
)) }) : null,
|
|
552
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ n("form", { className: "make-ai-assistant__composer", onSubmit: ke, children: [
|
|
553
611
|
/* @__PURE__ */ a(
|
|
554
612
|
"textarea",
|
|
555
613
|
{
|
|
556
614
|
"aria-label": "向 Make AI 助手提问",
|
|
557
|
-
"aria-describedby":
|
|
558
|
-
"aria-invalid":
|
|
615
|
+
"aria-describedby": O ? "make-ai-composer-error" : void 0,
|
|
616
|
+
"aria-invalid": O ? !0 : void 0,
|
|
559
617
|
autoFocus: !0,
|
|
560
|
-
disabled: d.status === "streaming",
|
|
618
|
+
disabled: E !== "ready" || d.status === "streaming",
|
|
561
619
|
placeholder: `询问当前 ${e.app.name ?? "App"} 中的数据…`,
|
|
562
620
|
rows: 2,
|
|
563
|
-
value:
|
|
621
|
+
value: b,
|
|
564
622
|
onChange: (o) => {
|
|
565
|
-
|
|
623
|
+
w(o.currentTarget.value), q(void 0);
|
|
566
624
|
},
|
|
567
|
-
onKeyDown:
|
|
625
|
+
onKeyDown: ge
|
|
568
626
|
}
|
|
569
627
|
),
|
|
570
628
|
d.status === "streaming" ? /* @__PURE__ */ a(
|
|
571
629
|
"button",
|
|
572
630
|
{
|
|
573
|
-
"aria-label":
|
|
631
|
+
"aria-label": Ie,
|
|
574
632
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
575
633
|
type: "button",
|
|
576
|
-
onClick:
|
|
634
|
+
onClick: ve,
|
|
577
635
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
578
636
|
}
|
|
579
637
|
) : /* @__PURE__ */ a(
|
|
@@ -581,81 +639,81 @@ function Fe({
|
|
|
581
639
|
{
|
|
582
640
|
"aria-label": "发送",
|
|
583
641
|
className: "make-ai-assistant__send",
|
|
584
|
-
disabled: !
|
|
642
|
+
disabled: E !== "ready" || !b.trim(),
|
|
585
643
|
type: "submit",
|
|
586
|
-
children: /* @__PURE__ */ a(
|
|
644
|
+
children: /* @__PURE__ */ a(He, {})
|
|
587
645
|
}
|
|
588
646
|
)
|
|
589
647
|
] }),
|
|
590
|
-
|
|
648
|
+
O ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: O }) : null,
|
|
591
649
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
592
650
|
] })
|
|
593
651
|
] });
|
|
594
652
|
}
|
|
595
|
-
function
|
|
653
|
+
function Ge({
|
|
596
654
|
defaultOpen: e = !1,
|
|
597
655
|
hideLauncher: t = !1,
|
|
598
|
-
launcher:
|
|
599
|
-
onOpenChange:
|
|
600
|
-
open:
|
|
601
|
-
...
|
|
656
|
+
launcher: s,
|
|
657
|
+
onOpenChange: l,
|
|
658
|
+
open: c,
|
|
659
|
+
...r
|
|
602
660
|
}) {
|
|
603
|
-
const [m,
|
|
604
|
-
|
|
605
|
-
},
|
|
606
|
-
return
|
|
607
|
-
if (!
|
|
608
|
-
const d = (
|
|
609
|
-
|
|
661
|
+
const [m, h] = P(e), N = T(null), u = c ?? m, b = (d) => {
|
|
662
|
+
c === void 0 && h(d), l?.(d), d || requestAnimationFrame(() => N.current?.focus());
|
|
663
|
+
}, w = () => b(!u);
|
|
664
|
+
return Q(() => {
|
|
665
|
+
if (!u) return;
|
|
666
|
+
const d = (v) => {
|
|
667
|
+
v.key === "Escape" && (b(!1), requestAnimationFrame(() => N.current?.focus()));
|
|
610
668
|
};
|
|
611
669
|
return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
|
|
612
|
-
}, [
|
|
613
|
-
!t && (!
|
|
670
|
+
}, [l, u]), /* @__PURE__ */ n("div", { className: "make-ai-assistant", "data-open": u || void 0, children: [
|
|
671
|
+
!t && (!u || s) ? s ? s({ open: u, toggle: w }) : /* @__PURE__ */ n(
|
|
614
672
|
"button",
|
|
615
673
|
{
|
|
616
|
-
"aria-label":
|
|
617
|
-
"aria-expanded":
|
|
674
|
+
"aria-label": u ? "关闭 Make AI 助手" : "打开 Make AI 助手",
|
|
675
|
+
"aria-expanded": u,
|
|
618
676
|
className: "make-ai-assistant__launcher",
|
|
619
|
-
ref:
|
|
677
|
+
ref: N,
|
|
620
678
|
type: "button",
|
|
621
|
-
onClick:
|
|
679
|
+
onClick: w,
|
|
622
680
|
children: [
|
|
623
681
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
624
|
-
/* @__PURE__ */ a(
|
|
682
|
+
/* @__PURE__ */ a(pe, {})
|
|
625
683
|
]
|
|
626
684
|
}
|
|
627
685
|
) : null,
|
|
628
|
-
|
|
686
|
+
u ? /* @__PURE__ */ a(
|
|
629
687
|
"aside",
|
|
630
688
|
{
|
|
631
689
|
"aria-label": "Make AI 助手",
|
|
632
690
|
"aria-modal": "false",
|
|
633
691
|
className: "make-ai-assistant__drawer",
|
|
634
692
|
role: "dialog",
|
|
635
|
-
children: /* @__PURE__ */ a(
|
|
693
|
+
children: /* @__PURE__ */ a(Be, { ...r, onClose: () => b(!1) })
|
|
636
694
|
}
|
|
637
695
|
) : null
|
|
638
696
|
] });
|
|
639
697
|
}
|
|
640
698
|
export {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
699
|
+
Me as ArtifactRenderer,
|
|
700
|
+
Be as AssistantPanel,
|
|
701
|
+
ea as MAKE_AI_ARTIFACT_KINDS,
|
|
702
|
+
aa as MAKE_AI_ARTIFACT_LIMITS,
|
|
703
|
+
ta as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
704
|
+
I as MAKE_AI_CONVERSATION_LIMITS,
|
|
705
|
+
Ge as MakeAiAssistant,
|
|
706
|
+
we as appendUserMessage,
|
|
707
|
+
Ae as createArtifactCapabilities,
|
|
708
|
+
de as createArtifactTemplateRegistry,
|
|
709
|
+
G as createAssistantConversationState,
|
|
710
|
+
Ke as createPlatformArtifactRegistry,
|
|
711
|
+
We as extendArtifactTemplateRegistry,
|
|
712
|
+
C as formatArtifactValue,
|
|
713
|
+
sa as parseArtifact,
|
|
714
|
+
Te as parseAssistantEvent,
|
|
715
|
+
Pe as platformArtifactTemplates,
|
|
716
|
+
J as reduceAssistantEvent,
|
|
717
|
+
be as resolveArtifactTemplate,
|
|
718
|
+
na as validateArtifact
|
|
661
719
|
};
|