@mast-ai/react-ui 0.2.0 → 0.3.0
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/dist/components/MessageList.d.ts +4 -2
- package/dist/context.d.ts +25 -10
- package/dist/index.js +526 -493
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { AgentRunner as
|
|
4
|
-
import { useVirtualizer as
|
|
5
|
-
function
|
|
1
|
+
import { useState as $, useEffect as z, useRef as R, useCallback as D, createContext as nt, useMemo as et, useContext as st, lazy as It, Fragment as mt, Suspense as Nt, useId as wt } from "react";
|
|
2
|
+
import { jsx as e, jsxs as w } from "react/jsx-runtime";
|
|
3
|
+
import { AgentRunner as Et } from "@mast-ai/core";
|
|
4
|
+
import { useVirtualizer as At } from "@tanstack/react-virtual";
|
|
5
|
+
function ct(t, n, r) {
|
|
6
6
|
return { id: crypto.randomUUID(), role: t, text: n, toolEvents: [], isStreaming: r };
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function F(t, n, r) {
|
|
9
9
|
return t.map((s) => s.id === n ? r(s) : s);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
let
|
|
14
|
-
const
|
|
15
|
-
return { ...a, toolEvents:
|
|
11
|
+
function V(t, n, r, s) {
|
|
12
|
+
return F(t, n, (a) => {
|
|
13
|
+
let l = !1;
|
|
14
|
+
const i = a.toolEvents.map((o) => !l && o.name === r && o.isStreaming ? (l = !0, s(o)) : o);
|
|
15
|
+
return { ...a, toolEvents: i };
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
-
let
|
|
21
|
-
const o = (
|
|
22
|
-
return { ...
|
|
18
|
+
function Ct(t, n, r, s, a) {
|
|
19
|
+
return V(t, n, r, (l) => {
|
|
20
|
+
let i = !1;
|
|
21
|
+
const o = (l.nestedToolEvents ?? []).map((m) => !i && m.name === s && m.isStreaming ? (i = !0, a(m)) : m);
|
|
22
|
+
return { ...l, nestedToolEvents: o };
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const [r, s] =
|
|
25
|
+
function Rt(t, n) {
|
|
26
|
+
const [r, s] = $(() => (n == null ? void 0 : n.initialEntries) ?? []), [a, l] = $(
|
|
27
27
|
() => t ? [...t.history] : []
|
|
28
|
-
), [
|
|
29
|
-
|
|
30
|
-
t &&
|
|
28
|
+
), [i, o] = $(!1);
|
|
29
|
+
z(() => {
|
|
30
|
+
t && l([...t.history]);
|
|
31
31
|
}, [t]);
|
|
32
|
-
const [
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
const
|
|
38
|
-
for (let
|
|
39
|
-
const N =
|
|
32
|
+
const [m, u] = $(0), d = R(null), b = R(n == null ? void 0 : n.onTurnComplete);
|
|
33
|
+
b.current = n == null ? void 0 : n.onTurnComplete, z(() => {
|
|
34
|
+
var g;
|
|
35
|
+
m !== 0 && ((g = b.current) == null || g.call(b, r, a));
|
|
36
|
+
}, [m]);
|
|
37
|
+
const S = (g) => {
|
|
38
|
+
for (let T = g.length - 1; T >= 0; T--) {
|
|
39
|
+
const N = g[T];
|
|
40
40
|
if (N.role === "assistant" && N.isStreaming) return N.id;
|
|
41
41
|
}
|
|
42
|
-
},
|
|
42
|
+
}, P = D((g, T) => {
|
|
43
43
|
s((N) => {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
...
|
|
47
|
-
awaitingApproval:
|
|
44
|
+
const A = S(N);
|
|
45
|
+
return A === void 0 ? N : V(N, A, g, (x) => ({
|
|
46
|
+
...x,
|
|
47
|
+
awaitingApproval: T
|
|
48
48
|
}));
|
|
49
49
|
});
|
|
50
|
-
}, []),
|
|
50
|
+
}, []), _ = D((g, T) => {
|
|
51
51
|
s((N) => {
|
|
52
|
-
const
|
|
53
|
-
return
|
|
52
|
+
const A = S(N);
|
|
53
|
+
return A === void 0 ? N : V(N, A, g, (x) => ({ ...x, status: T }));
|
|
54
54
|
});
|
|
55
|
-
}, []),
|
|
56
|
-
(
|
|
57
|
-
if (
|
|
55
|
+
}, []), M = D(
|
|
56
|
+
(g, T) => {
|
|
57
|
+
if (i) return;
|
|
58
58
|
if (t === null) {
|
|
59
59
|
console.warn(
|
|
60
60
|
"useAgent().sendMessage was called while no AgentRunner is configured. Pass a non-null `runner` to <AgentProvider> to enable the agent."
|
|
61
61
|
);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const N =
|
|
65
|
-
s((
|
|
66
|
-
const
|
|
67
|
-
|
|
64
|
+
const N = ct("user", T ?? g, !1), A = ct("assistant", "", !0), x = A.id;
|
|
65
|
+
s((E) => [...E, N, A]), o(!0);
|
|
66
|
+
const h = new AbortController();
|
|
67
|
+
d.current = h, (async () => {
|
|
68
68
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
if (
|
|
69
|
+
const E = t.runStream(
|
|
70
|
+
g,
|
|
71
|
+
h.signal,
|
|
72
|
+
(f, k) => {
|
|
73
|
+
if (k.type === "thinking")
|
|
74
74
|
s(
|
|
75
|
-
(
|
|
76
|
-
...
|
|
77
|
-
subThinking: (
|
|
75
|
+
(v) => V(v, x, f, (C) => ({
|
|
76
|
+
...C,
|
|
77
|
+
subThinking: (C.subThinking ?? "") + k.delta
|
|
78
78
|
}))
|
|
79
79
|
);
|
|
80
|
-
else if (
|
|
80
|
+
else if (k.type === "text_delta")
|
|
81
81
|
s(
|
|
82
|
-
(
|
|
83
|
-
...
|
|
84
|
-
subText: (
|
|
82
|
+
(v) => V(v, x, f, (C) => ({
|
|
83
|
+
...C,
|
|
84
|
+
subText: (C.subText ?? "") + k.delta
|
|
85
85
|
}))
|
|
86
86
|
);
|
|
87
|
-
else if (
|
|
88
|
-
const
|
|
87
|
+
else if (k.type === "tool_call_started") {
|
|
88
|
+
const v = {
|
|
89
89
|
id: crypto.randomUUID(),
|
|
90
90
|
type: "tool_call_started",
|
|
91
|
-
name:
|
|
92
|
-
args:
|
|
91
|
+
name: k.name,
|
|
92
|
+
args: k.args,
|
|
93
93
|
isStreaming: !0
|
|
94
94
|
};
|
|
95
95
|
s(
|
|
96
|
-
(
|
|
97
|
-
...
|
|
98
|
-
nestedToolEvents: [...
|
|
96
|
+
(C) => V(C, x, f, (y) => ({
|
|
97
|
+
...y,
|
|
98
|
+
nestedToolEvents: [...y.nestedToolEvents ?? [], v]
|
|
99
99
|
}))
|
|
100
100
|
);
|
|
101
|
-
} else if (
|
|
102
|
-
const
|
|
101
|
+
} else if (k.type === "tool_call_completed") {
|
|
102
|
+
const v = k;
|
|
103
103
|
s(
|
|
104
|
-
(
|
|
105
|
-
...
|
|
104
|
+
(C) => Ct(C, x, f, v.name, (y) => ({
|
|
105
|
+
...y,
|
|
106
106
|
type: "tool_call_completed",
|
|
107
|
-
result:
|
|
107
|
+
result: v.result,
|
|
108
108
|
isStreaming: !1,
|
|
109
|
-
status:
|
|
109
|
+
status: v.error ? "error" : "success"
|
|
110
110
|
}))
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
|
-
for await (const
|
|
116
|
-
if (
|
|
115
|
+
for await (const f of E)
|
|
116
|
+
if (f.type === "text_delta")
|
|
117
117
|
s(
|
|
118
|
-
(
|
|
119
|
-
...
|
|
120
|
-
text:
|
|
118
|
+
(k) => F(k, x, (v) => ({
|
|
119
|
+
...v,
|
|
120
|
+
text: v.text + f.delta
|
|
121
121
|
}))
|
|
122
122
|
);
|
|
123
|
-
else if (
|
|
123
|
+
else if (f.type === "thinking")
|
|
124
124
|
s(
|
|
125
|
-
(
|
|
126
|
-
...
|
|
127
|
-
thinking: (
|
|
125
|
+
(k) => F(k, x, (v) => ({
|
|
126
|
+
...v,
|
|
127
|
+
thinking: (v.thinking ?? "") + f.delta
|
|
128
128
|
}))
|
|
129
129
|
);
|
|
130
|
-
else if (
|
|
131
|
-
const
|
|
130
|
+
else if (f.type === "tool_call_started") {
|
|
131
|
+
const k = {
|
|
132
132
|
id: crypto.randomUUID(),
|
|
133
133
|
type: "tool_call_started",
|
|
134
|
-
name:
|
|
135
|
-
args:
|
|
134
|
+
name: f.name,
|
|
135
|
+
args: f.args,
|
|
136
136
|
isStreaming: !0
|
|
137
137
|
};
|
|
138
138
|
s(
|
|
139
|
-
(
|
|
140
|
-
...
|
|
141
|
-
toolEvents: [...
|
|
139
|
+
(v) => F(v, x, (C) => ({
|
|
140
|
+
...C,
|
|
141
|
+
toolEvents: [...C.toolEvents, k]
|
|
142
142
|
}))
|
|
143
143
|
);
|
|
144
|
-
} else if (
|
|
144
|
+
} else if (f.type === "tool_call_completed")
|
|
145
145
|
s(
|
|
146
|
-
(
|
|
147
|
-
...
|
|
146
|
+
(k) => V(k, x, f.name, (v) => ({
|
|
147
|
+
...v,
|
|
148
148
|
type: "tool_call_completed",
|
|
149
|
-
result:
|
|
149
|
+
result: f.result,
|
|
150
150
|
isStreaming: !1,
|
|
151
151
|
// Preserve a status set by the proxy (e.g. 'cancelled'); only
|
|
152
152
|
// fall back to error/success based on the runner's flag.
|
|
153
|
-
status:
|
|
153
|
+
status: v.status ?? (f.error ? "error" : "success")
|
|
154
154
|
}))
|
|
155
155
|
);
|
|
156
|
-
else if (
|
|
157
|
-
const
|
|
156
|
+
else if (f.type === "done") {
|
|
157
|
+
const k = f.history;
|
|
158
158
|
s(
|
|
159
|
-
(
|
|
160
|
-
...
|
|
161
|
-
text:
|
|
159
|
+
(v) => F(v, x, (C) => ({
|
|
160
|
+
...C,
|
|
161
|
+
text: f.output,
|
|
162
162
|
isStreaming: !1
|
|
163
163
|
}))
|
|
164
|
-
),
|
|
164
|
+
), l(k), u((v) => v + 1);
|
|
165
165
|
}
|
|
166
166
|
} catch {
|
|
167
167
|
s(
|
|
168
|
-
(
|
|
168
|
+
(E) => F(E, x, (f) => ({ ...f, isStreaming: !1 }))
|
|
169
169
|
);
|
|
170
170
|
} finally {
|
|
171
171
|
o(!1);
|
|
172
172
|
}
|
|
173
173
|
})();
|
|
174
174
|
},
|
|
175
|
-
[t,
|
|
176
|
-
),
|
|
177
|
-
var
|
|
178
|
-
(
|
|
179
|
-
}, []),
|
|
180
|
-
var
|
|
181
|
-
(
|
|
175
|
+
[t, i]
|
|
176
|
+
), c = D(() => {
|
|
177
|
+
var g;
|
|
178
|
+
(g = d.current) == null || g.abort();
|
|
179
|
+
}, []), I = D(() => {
|
|
180
|
+
var g;
|
|
181
|
+
(g = d.current) == null || g.abort(), d.current = null, s([]), l([]), o(!1);
|
|
182
182
|
}, []);
|
|
183
183
|
return {
|
|
184
184
|
entries: r,
|
|
185
185
|
history: a,
|
|
186
|
-
isRunning:
|
|
187
|
-
sendMessage:
|
|
188
|
-
cancel:
|
|
189
|
-
reset:
|
|
190
|
-
setToolAwaitingApproval:
|
|
191
|
-
setToolStatus:
|
|
186
|
+
isRunning: i,
|
|
187
|
+
sendMessage: M,
|
|
188
|
+
cancel: c,
|
|
189
|
+
reset: I,
|
|
190
|
+
setToolAwaitingApproval: P,
|
|
191
|
+
setToolStatus: _
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
const
|
|
194
|
+
const B = {
|
|
195
195
|
width: 16,
|
|
196
196
|
height: 16,
|
|
197
197
|
viewBox: "0 0 24 24",
|
|
@@ -203,78 +203,78 @@ const V = {
|
|
|
203
203
|
"aria-hidden": !0,
|
|
204
204
|
focusable: !1
|
|
205
205
|
};
|
|
206
|
-
function
|
|
207
|
-
return /* @__PURE__ */
|
|
206
|
+
function Pt() {
|
|
207
|
+
return /* @__PURE__ */ w("svg", { ...B, children: [
|
|
208
208
|
/* @__PURE__ */ e("path", { d: "M9 3a3 3 0 0 0-3 3v.5a3 3 0 0 0-2 5.2A3 3 0 0 0 6 17v.5a3 3 0 0 0 6 0V3a3 3 0 0 0-3 0Z" }),
|
|
209
209
|
/* @__PURE__ */ e("path", { d: "M15 3a3 3 0 0 1 3 3v.5a3 3 0 0 1 2 5.2A3 3 0 0 1 18 17v.5a3 3 0 0 1-6 0V3a3 3 0 0 1 3 0Z" })
|
|
210
210
|
] });
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
return /* @__PURE__ */ e("svg", { ...
|
|
212
|
+
function _t() {
|
|
213
|
+
return /* @__PURE__ */ e("svg", { ...B, children: /* @__PURE__ */ e("path", { d: "M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4 2.6-2.6Z" }) });
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
return /* @__PURE__ */
|
|
215
|
+
function Mt() {
|
|
216
|
+
return /* @__PURE__ */ w("svg", { ...B, children: [
|
|
217
217
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "9" }),
|
|
218
218
|
/* @__PURE__ */ e("path", { d: "m8 12 3 3 5-6" })
|
|
219
219
|
] });
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
return /* @__PURE__ */
|
|
221
|
+
function Dt() {
|
|
222
|
+
return /* @__PURE__ */ w("svg", { ...B, children: [
|
|
223
223
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "9" }),
|
|
224
224
|
/* @__PURE__ */ e("path", { d: "m9 9 6 6" }),
|
|
225
225
|
/* @__PURE__ */ e("path", { d: "m15 9-6 6" })
|
|
226
226
|
] });
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return /* @__PURE__ */
|
|
228
|
+
function Lt() {
|
|
229
|
+
return /* @__PURE__ */ w("svg", { ...B, children: [
|
|
230
230
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "9" }),
|
|
231
231
|
/* @__PURE__ */ e("path", { d: "M5.5 5.5 18.5 18.5" })
|
|
232
232
|
] });
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
return /* @__PURE__ */ e("svg", { ...
|
|
234
|
+
function $t() {
|
|
235
|
+
return /* @__PURE__ */ e("svg", { ...B, className: "mast-spin", children: /* @__PURE__ */ e("path", { d: "M12 3a9 9 0 1 0 9 9" }) });
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
return /* @__PURE__ */ e("svg", { ...
|
|
237
|
+
function jt() {
|
|
238
|
+
return /* @__PURE__ */ e("svg", { ...B, fill: "currentColor", stroke: "none", children: /* @__PURE__ */ e("path", { d: "M3 3 21 12 3 21l3-9-3-9Z" }) });
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
return /* @__PURE__ */ e("svg", { ...
|
|
240
|
+
function Ht() {
|
|
241
|
+
return /* @__PURE__ */ e("svg", { ...B, fill: "currentColor", stroke: "none", children: /* @__PURE__ */ e("rect", { x: "5", y: "5", width: "14", height: "14", rx: "1" }) });
|
|
242
242
|
}
|
|
243
|
-
const
|
|
244
|
-
brain: /* @__PURE__ */ e(
|
|
245
|
-
wrench: /* @__PURE__ */ e(
|
|
246
|
-
check: /* @__PURE__ */ e(
|
|
247
|
-
error: /* @__PURE__ */ e(
|
|
248
|
-
cancelled: /* @__PURE__ */ e(
|
|
249
|
-
loader: /* @__PURE__ */ e(
|
|
250
|
-
send: /* @__PURE__ */ e(
|
|
251
|
-
stop: /* @__PURE__ */ e(
|
|
252
|
-
},
|
|
253
|
-
function
|
|
254
|
-
const r =
|
|
255
|
-
brain: t.brain ??
|
|
256
|
-
wrench: t.wrench ??
|
|
257
|
-
check: t.check ??
|
|
258
|
-
error: t.error ??
|
|
259
|
-
cancelled: t.cancelled ??
|
|
260
|
-
loader: t.loader ??
|
|
261
|
-
send: t.send ??
|
|
262
|
-
stop: t.stop ??
|
|
263
|
-
} :
|
|
264
|
-
return /* @__PURE__ */ e(
|
|
243
|
+
const j = {
|
|
244
|
+
brain: /* @__PURE__ */ e(Pt, {}),
|
|
245
|
+
wrench: /* @__PURE__ */ e(_t, {}),
|
|
246
|
+
check: /* @__PURE__ */ e(Mt, {}),
|
|
247
|
+
error: /* @__PURE__ */ e(Dt, {}),
|
|
248
|
+
cancelled: /* @__PURE__ */ e(Lt, {}),
|
|
249
|
+
loader: /* @__PURE__ */ e($t, {}),
|
|
250
|
+
send: /* @__PURE__ */ e(jt, {}),
|
|
251
|
+
stop: /* @__PURE__ */ e(Ht, {})
|
|
252
|
+
}, ht = nt(j);
|
|
253
|
+
function Bt({ icons: t, children: n }) {
|
|
254
|
+
const r = et(() => t ? {
|
|
255
|
+
brain: t.brain ?? j.brain,
|
|
256
|
+
wrench: t.wrench ?? j.wrench,
|
|
257
|
+
check: t.check ?? j.check,
|
|
258
|
+
error: t.error ?? j.error,
|
|
259
|
+
cancelled: t.cancelled ?? j.cancelled,
|
|
260
|
+
loader: t.loader ?? j.loader,
|
|
261
|
+
send: t.send ?? j.send,
|
|
262
|
+
stop: t.stop ?? j.stop
|
|
263
|
+
} : j, [t]);
|
|
264
|
+
return /* @__PURE__ */ e(ht.Provider, { value: r, children: n });
|
|
265
265
|
}
|
|
266
266
|
function J() {
|
|
267
|
-
return
|
|
267
|
+
return st(ht);
|
|
268
268
|
}
|
|
269
|
-
const
|
|
270
|
-
function
|
|
269
|
+
const pt = Symbol.for("@mast-ai/react-ui.INLINE_APPROVAL"), Ut = "User cancelled the tool call.";
|
|
270
|
+
function Kt(t, n) {
|
|
271
271
|
let r = !1, s = !1;
|
|
272
272
|
if (n)
|
|
273
273
|
for (const a of n)
|
|
274
274
|
a.startsWith("!") ? a.slice(1) === t.name && (s = !0) : a === t.name && (r = !0);
|
|
275
275
|
return (t.requiresApproval === !0 || r) && !s;
|
|
276
276
|
}
|
|
277
|
-
class
|
|
277
|
+
class Ot {
|
|
278
278
|
constructor(n, r, s) {
|
|
279
279
|
this.inner = n, this.onApprovalRequired = r, this.hooks = s;
|
|
280
280
|
}
|
|
@@ -282,152 +282,153 @@ class Bt {
|
|
|
282
282
|
return this.inner.definition();
|
|
283
283
|
}
|
|
284
284
|
async call(n, r) {
|
|
285
|
-
var
|
|
285
|
+
var l, i, o, m, u, d;
|
|
286
286
|
const s = this.inner.definition();
|
|
287
|
-
(
|
|
287
|
+
(i = (l = this.hooks).notifyAwaiting) == null || i.call(l, s.name, !0);
|
|
288
288
|
let a;
|
|
289
289
|
try {
|
|
290
|
-
const
|
|
290
|
+
const b = await this.onApprovalRequired({
|
|
291
291
|
id: "",
|
|
292
292
|
type: "tool_call_started",
|
|
293
293
|
name: s.name,
|
|
294
294
|
args: n,
|
|
295
295
|
isStreaming: !0
|
|
296
296
|
});
|
|
297
|
-
|
|
297
|
+
b === pt ? this.hooks.enqueueInline ? a = await this.hooks.enqueueInline(s.name, n) : a = !0 : a = b;
|
|
298
298
|
} finally {
|
|
299
|
-
(
|
|
299
|
+
(m = (o = this.hooks).notifyAwaiting) == null || m.call(o, s.name, !1);
|
|
300
300
|
}
|
|
301
|
-
return a === !1 ? ((
|
|
301
|
+
return a === !1 ? ((d = (u = this.hooks).setStatus) == null || d.call(u, s.name, "cancelled"), Ut) : typeof a == "string" ? a : this.inner.call(n, r);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function Vt(t, n, r, s = {}) {
|
|
305
305
|
return {
|
|
306
306
|
getTools: () => t.getTools(),
|
|
307
307
|
getTool: (a) => {
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
const
|
|
311
|
-
if (!
|
|
308
|
+
const l = t.getTool(a);
|
|
309
|
+
if (!l) return;
|
|
310
|
+
const i = l.definition();
|
|
311
|
+
if (!Kt(i, r())) return l;
|
|
312
312
|
const o = n();
|
|
313
|
-
return o ? new
|
|
313
|
+
return o ? new Ot(l, o, s) : l;
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
const
|
|
318
|
-
function
|
|
317
|
+
const ft = nt(null), Wt = async () => pt;
|
|
318
|
+
function ge({
|
|
319
319
|
runner: t,
|
|
320
320
|
agent: n,
|
|
321
321
|
children: r,
|
|
322
322
|
icons: s,
|
|
323
323
|
onApprovalRequired: a,
|
|
324
|
-
approvalOverride:
|
|
325
|
-
initialHistory:
|
|
324
|
+
approvalOverride: l,
|
|
325
|
+
initialHistory: i,
|
|
326
326
|
initialEntries: o,
|
|
327
|
-
onConversationChange:
|
|
327
|
+
onConversationChange: m,
|
|
328
328
|
theme: u,
|
|
329
|
-
disableRoot:
|
|
329
|
+
disableRoot: d
|
|
330
330
|
}) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
const
|
|
331
|
+
const b = R(m);
|
|
332
|
+
b.current = m;
|
|
333
|
+
const S = R(i), P = R(o), _ = R(a);
|
|
334
|
+
_.current = a;
|
|
335
|
+
const M = R(l);
|
|
336
|
+
M.current = l;
|
|
337
|
+
const c = R(null), I = R(null), g = R(null), T = et(() => {
|
|
338
|
+
var W, X;
|
|
338
339
|
if (t === null) return null;
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const
|
|
342
|
-
notifyAwaiting: (
|
|
343
|
-
var
|
|
344
|
-
return (
|
|
340
|
+
const L = a !== void 0, Y = l !== void 0 && l.length > 0, q = (((X = (W = t.registry) == null ? void 0 : W.getTools) == null ? void 0 : X.call(W)) ?? []).some((O) => O.requiresApproval === !0);
|
|
341
|
+
if (!L && !Y && !q) return t;
|
|
342
|
+
const Z = {
|
|
343
|
+
notifyAwaiting: (O, Q) => {
|
|
344
|
+
var H;
|
|
345
|
+
return (H = c.current) == null ? void 0 : H.call(c, O, Q);
|
|
345
346
|
},
|
|
346
|
-
setStatus: (
|
|
347
|
-
var
|
|
348
|
-
return (
|
|
347
|
+
setStatus: (O, Q) => {
|
|
348
|
+
var H;
|
|
349
|
+
return (H = I.current) == null ? void 0 : H.call(I, O, Q);
|
|
349
350
|
},
|
|
350
|
-
enqueueInline: (
|
|
351
|
-
var
|
|
352
|
-
return ((
|
|
351
|
+
enqueueInline: (O, Q) => {
|
|
352
|
+
var H;
|
|
353
|
+
return ((H = g.current) == null ? void 0 : H.call(g, O, Q)) ?? Promise.resolve(!0);
|
|
353
354
|
}
|
|
354
|
-
},
|
|
355
|
+
}, K = Vt(
|
|
355
356
|
t.registry,
|
|
356
|
-
() =>
|
|
357
|
-
() =>
|
|
358
|
-
|
|
357
|
+
() => _.current ?? Wt,
|
|
358
|
+
() => M.current,
|
|
359
|
+
Z
|
|
359
360
|
);
|
|
360
|
-
return new
|
|
361
|
-
}, [t, a,
|
|
362
|
-
if (
|
|
363
|
-
const
|
|
364
|
-
return
|
|
361
|
+
return new Et(t.adapter, K);
|
|
362
|
+
}, [t, a, l]), [N, A] = $(() => {
|
|
363
|
+
if (T === null) return null;
|
|
364
|
+
const L = T.conversation(n);
|
|
365
|
+
return S.current && S.current.length > 0 && (L.history = [...S.current]), L;
|
|
365
366
|
});
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
const
|
|
369
|
-
|
|
367
|
+
z(() => {
|
|
368
|
+
if (T !== null && N === null) {
|
|
369
|
+
const L = T.conversation(n);
|
|
370
|
+
S.current && S.current.length > 0 && (L.history = [...S.current]), A(L);
|
|
370
371
|
}
|
|
371
|
-
}, [
|
|
372
|
-
const
|
|
373
|
-
(
|
|
374
|
-
var
|
|
375
|
-
(
|
|
372
|
+
}, [T, N, n]);
|
|
373
|
+
const x = D(
|
|
374
|
+
(L, Y) => {
|
|
375
|
+
var G;
|
|
376
|
+
(G = b.current) == null || G.call(b, Y, L);
|
|
376
377
|
},
|
|
377
378
|
[]
|
|
378
379
|
), {
|
|
379
|
-
entries:
|
|
380
|
-
history:
|
|
381
|
-
sendMessage:
|
|
382
|
-
cancel:
|
|
383
|
-
isRunning:
|
|
384
|
-
reset:
|
|
385
|
-
setToolAwaitingApproval:
|
|
386
|
-
setToolStatus:
|
|
387
|
-
} =
|
|
388
|
-
initialEntries:
|
|
389
|
-
onTurnComplete:
|
|
380
|
+
entries: h,
|
|
381
|
+
history: p,
|
|
382
|
+
sendMessage: E,
|
|
383
|
+
cancel: f,
|
|
384
|
+
isRunning: k,
|
|
385
|
+
reset: v,
|
|
386
|
+
setToolAwaitingApproval: C,
|
|
387
|
+
setToolStatus: y
|
|
388
|
+
} = Rt(N, {
|
|
389
|
+
initialEntries: P.current,
|
|
390
|
+
onTurnComplete: x
|
|
390
391
|
});
|
|
391
|
-
|
|
392
|
-
const [
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
const q = (
|
|
396
|
-
|
|
397
|
-
},
|
|
398
|
-
toolName:
|
|
399
|
-
args:
|
|
392
|
+
c.current = C, I.current = y;
|
|
393
|
+
const [U, at] = $([]), lt = R(U);
|
|
394
|
+
lt.current = U;
|
|
395
|
+
const Tt = D((L, Y) => new Promise((G) => {
|
|
396
|
+
const q = (K) => {
|
|
397
|
+
at((W) => W.filter((X) => X !== Z)), G(K);
|
|
398
|
+
}, Z = {
|
|
399
|
+
toolName: L,
|
|
400
|
+
args: Y,
|
|
400
401
|
approve: () => q(!0),
|
|
401
402
|
reject: () => q(!1),
|
|
402
|
-
respondWith: (
|
|
403
|
+
respondWith: (K) => q(K)
|
|
403
404
|
};
|
|
404
|
-
|
|
405
|
+
at((K) => [...K, Z]);
|
|
405
406
|
}), []);
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
}, [
|
|
407
|
+
g.current = Tt;
|
|
408
|
+
const it = D(() => {
|
|
409
|
+
lt.current.forEach((L) => L.reject()), v(), A(T === null ? null : T.conversation(n));
|
|
410
|
+
}, [v, T, n]), ot = T !== null, yt = et(
|
|
410
411
|
() => ({
|
|
411
|
-
messages:
|
|
412
|
-
history:
|
|
413
|
-
sendMessage:
|
|
414
|
-
cancel:
|
|
415
|
-
isRunning:
|
|
416
|
-
reset:
|
|
417
|
-
pendingApprovals:
|
|
418
|
-
isReady:
|
|
412
|
+
messages: h,
|
|
413
|
+
history: p,
|
|
414
|
+
sendMessage: E,
|
|
415
|
+
cancel: f,
|
|
416
|
+
isRunning: k,
|
|
417
|
+
reset: it,
|
|
418
|
+
pendingApprovals: U,
|
|
419
|
+
isReady: ot
|
|
419
420
|
}),
|
|
420
|
-
[
|
|
421
|
-
),
|
|
422
|
-
return /* @__PURE__ */ e(
|
|
421
|
+
[h, p, E, f, k, it, U, ot]
|
|
422
|
+
), St = d === !1 ? /* @__PURE__ */ e("div", { "data-mast-root": !0, "data-mast-theme": u, children: r }) : r;
|
|
423
|
+
return /* @__PURE__ */ e(ft.Provider, { value: yt, children: /* @__PURE__ */ e(Bt, { icons: s, children: St }) });
|
|
423
424
|
}
|
|
424
|
-
function
|
|
425
|
-
const t =
|
|
425
|
+
function tt() {
|
|
426
|
+
const t = st(ft);
|
|
426
427
|
if (!t)
|
|
427
428
|
throw new Error("useAgent() must be called from a component rendered inside <AgentProvider>.");
|
|
428
429
|
return t;
|
|
429
430
|
}
|
|
430
|
-
function
|
|
431
|
+
function Ft(t) {
|
|
431
432
|
if (t === void 0) return "";
|
|
432
433
|
if (typeof t == "string") return t;
|
|
433
434
|
try {
|
|
@@ -436,16 +437,16 @@ function Kt(t) {
|
|
|
436
437
|
return String(t);
|
|
437
438
|
}
|
|
438
439
|
}
|
|
439
|
-
function
|
|
440
|
-
const a = J(),
|
|
441
|
-
return /* @__PURE__ */
|
|
442
|
-
/* @__PURE__ */
|
|
440
|
+
function zt({ entry: t, approve: n, reject: r, className: s }) {
|
|
441
|
+
const a = J(), l = ["mast-inline-approval", s].filter(Boolean).join(" "), i = Ft(t.args);
|
|
442
|
+
return /* @__PURE__ */ w("div", { "data-mast-inline-approval": !0, "data-tool-name": t.name, className: l, children: [
|
|
443
|
+
/* @__PURE__ */ w("div", { className: "mast-inline-approval-header", children: [
|
|
443
444
|
/* @__PURE__ */ e("span", { className: "mast-inline-approval-icon", "aria-hidden": "true", children: a.wrench }),
|
|
444
445
|
/* @__PURE__ */ e("span", { className: "mast-inline-approval-name", children: t.name }),
|
|
445
446
|
/* @__PURE__ */ e("span", { className: "mast-inline-approval-label", children: "requires approval" })
|
|
446
447
|
] }),
|
|
447
|
-
|
|
448
|
-
/* @__PURE__ */
|
|
448
|
+
i ? /* @__PURE__ */ e("pre", { className: "mast-inline-approval-args", children: /* @__PURE__ */ e("code", { children: i }) }) : null,
|
|
449
|
+
/* @__PURE__ */ w("div", { className: "mast-inline-approval-actions", children: [
|
|
449
450
|
/* @__PURE__ */ e(
|
|
450
451
|
"button",
|
|
451
452
|
{
|
|
@@ -467,24 +468,24 @@ function Vt({ entry: t, approve: n, reject: r, className: s }) {
|
|
|
467
468
|
] })
|
|
468
469
|
] });
|
|
469
470
|
}
|
|
470
|
-
function
|
|
471
|
+
function gt({
|
|
471
472
|
content: t,
|
|
472
473
|
isStreaming: n = !1,
|
|
473
474
|
className: r,
|
|
474
475
|
label: s = "Thinking Process",
|
|
475
476
|
open: a
|
|
476
477
|
}) {
|
|
477
|
-
const
|
|
478
|
-
return /* @__PURE__ */
|
|
478
|
+
const l = J(), i = ["mast-thinking-block", r].filter(Boolean).join(" ");
|
|
479
|
+
return /* @__PURE__ */ w(
|
|
479
480
|
"details",
|
|
480
481
|
{
|
|
481
482
|
"data-mast-thinking-block": !0,
|
|
482
483
|
"data-streaming": n ? "true" : void 0,
|
|
483
|
-
className:
|
|
484
|
+
className: i,
|
|
484
485
|
open: a,
|
|
485
486
|
children: [
|
|
486
|
-
/* @__PURE__ */
|
|
487
|
-
/* @__PURE__ */ e("span", { className: "mast-thinking-block-icon", "aria-hidden": "true", children:
|
|
487
|
+
/* @__PURE__ */ w("summary", { className: "mast-thinking-block-summary", children: [
|
|
488
|
+
/* @__PURE__ */ e("span", { className: "mast-thinking-block-icon", "aria-hidden": "true", children: l.brain }),
|
|
488
489
|
/* @__PURE__ */ e("span", { className: "mast-thinking-block-label", children: s }),
|
|
489
490
|
n ? /* @__PURE__ */ e(
|
|
490
491
|
"span",
|
|
@@ -500,8 +501,8 @@ function ut({
|
|
|
500
501
|
}
|
|
501
502
|
);
|
|
502
503
|
}
|
|
503
|
-
const
|
|
504
|
-
function
|
|
504
|
+
const vt = nt(void 0);
|
|
505
|
+
function ut(t) {
|
|
505
506
|
if (t === void 0) return "";
|
|
506
507
|
if (typeof t == "string") return t;
|
|
507
508
|
try {
|
|
@@ -510,7 +511,7 @@ function it(t) {
|
|
|
510
511
|
return String(t);
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
|
-
function
|
|
514
|
+
function Yt(t, n) {
|
|
514
515
|
if (t.isStreaming) return n.loader;
|
|
515
516
|
switch (t.status) {
|
|
516
517
|
case "error":
|
|
@@ -521,27 +522,27 @@ function Wt(t, n) {
|
|
|
521
522
|
return n.check;
|
|
522
523
|
}
|
|
523
524
|
}
|
|
524
|
-
function
|
|
525
|
+
function Gt(t, n) {
|
|
525
526
|
return t === "streaming" ? n ? !0 : void 0 : t;
|
|
526
527
|
}
|
|
527
|
-
function
|
|
528
|
+
function bt({
|
|
528
529
|
entry: t,
|
|
529
530
|
className: n,
|
|
530
531
|
defaultOpen: r = "streaming",
|
|
531
532
|
label: s
|
|
532
533
|
}) {
|
|
533
|
-
const a = J(),
|
|
534
|
-
return /* @__PURE__ */
|
|
534
|
+
const a = J(), l = st(vt), i = ["mast-tool-call-block", n].filter(Boolean).join(" "), o = t.subThinking !== void 0 || t.subText !== void 0, m = t.nestedToolEvents ?? [], u = Yt(t, a), d = ut(t.args), b = ut(t.result), S = Gt(r, t.isStreaming), P = s ?? (l == null ? void 0 : l(t)) ?? t.name;
|
|
535
|
+
return /* @__PURE__ */ w(
|
|
535
536
|
"details",
|
|
536
537
|
{
|
|
537
538
|
"data-mast-tool-call-block": !0,
|
|
538
539
|
"data-streaming": t.isStreaming ? "true" : void 0,
|
|
539
540
|
"data-status": t.status,
|
|
540
541
|
"data-tool-name": t.name,
|
|
541
|
-
className:
|
|
542
|
-
open:
|
|
542
|
+
className: i,
|
|
543
|
+
open: S,
|
|
543
544
|
children: [
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ w("summary", { className: "mast-tool-call-block-header", children: [
|
|
545
546
|
/* @__PURE__ */ e("span", { className: "mast-tool-call-block-chevron", "aria-hidden": "true", children: "▸" }),
|
|
546
547
|
/* @__PURE__ */ e(
|
|
547
548
|
"span",
|
|
@@ -553,12 +554,12 @@ function mt({
|
|
|
553
554
|
}
|
|
554
555
|
),
|
|
555
556
|
/* @__PURE__ */ e("span", { className: "mast-tool-call-block-wrench", "aria-hidden": "true", children: a.wrench }),
|
|
556
|
-
/* @__PURE__ */ e("span", { className: "mast-tool-call-block-name", children:
|
|
557
|
+
/* @__PURE__ */ e("span", { className: "mast-tool-call-block-name", children: P })
|
|
557
558
|
] }),
|
|
558
|
-
/* @__PURE__ */
|
|
559
|
-
o ? /* @__PURE__ */
|
|
559
|
+
/* @__PURE__ */ w("div", { className: "mast-tool-call-block-body", children: [
|
|
560
|
+
o ? /* @__PURE__ */ w("div", { className: "mast-tool-call-block-sub-output", children: [
|
|
560
561
|
t.subThinking !== void 0 ? /* @__PURE__ */ e(
|
|
561
|
-
|
|
562
|
+
gt,
|
|
562
563
|
{
|
|
563
564
|
content: t.subThinking,
|
|
564
565
|
isStreaming: t.isStreaming,
|
|
@@ -568,25 +569,25 @@ function mt({
|
|
|
568
569
|
) : null,
|
|
569
570
|
t.subText !== void 0 ? /* @__PURE__ */ e("div", { className: "mast-tool-call-block-sub-text", "data-testid": "mast-tool-call-sub-text", children: t.subText }) : null
|
|
570
571
|
] }) : null,
|
|
571
|
-
|
|
572
|
-
|
|
572
|
+
m.length > 0 ? /* @__PURE__ */ e("div", { className: "mast-tool-call-block-nested", "data-testid": "mast-tool-call-nested", children: m.map((_) => /* @__PURE__ */ e(bt, { entry: _ }, _.id)) }) : null,
|
|
573
|
+
d ? /* @__PURE__ */ w("details", { className: "mast-tool-call-block-args", children: [
|
|
573
574
|
/* @__PURE__ */ e("summary", { children: "Arguments" }),
|
|
574
|
-
/* @__PURE__ */ e("pre", { className: "mast-tool-call-block-pre", children: /* @__PURE__ */ e("code", { children:
|
|
575
|
+
/* @__PURE__ */ e("pre", { className: "mast-tool-call-block-pre", children: /* @__PURE__ */ e("code", { children: d }) })
|
|
575
576
|
] }) : null,
|
|
576
|
-
!t.isStreaming &&
|
|
577
|
+
!t.isStreaming && b ? /* @__PURE__ */ w("details", { className: "mast-tool-call-block-result", children: [
|
|
577
578
|
/* @__PURE__ */ e("summary", { children: "Result" }),
|
|
578
|
-
/* @__PURE__ */ e("pre", { className: "mast-tool-call-block-pre", children: /* @__PURE__ */ e("code", { children:
|
|
579
|
+
/* @__PURE__ */ e("pre", { className: "mast-tool-call-block-pre", children: /* @__PURE__ */ e("code", { children: b }) })
|
|
579
580
|
] }) : null
|
|
580
581
|
] })
|
|
581
582
|
]
|
|
582
583
|
}
|
|
583
584
|
);
|
|
584
585
|
}
|
|
585
|
-
function
|
|
586
|
+
function qt({ entry: t, className: n }) {
|
|
586
587
|
const r = ["mast-user-message", n].filter(Boolean).join(" ");
|
|
587
588
|
return /* @__PURE__ */ e("div", { "data-mast-user-message": !0, className: r, children: /* @__PURE__ */ e("div", { className: "mast-user-message-bubble", children: t.text }) });
|
|
588
589
|
}
|
|
589
|
-
const
|
|
590
|
+
const Qt = It(async () => {
|
|
590
591
|
try {
|
|
591
592
|
const [{ default: t }, { default: n }, { default: r }] = await Promise.all([
|
|
592
593
|
import("react-markdown"),
|
|
@@ -602,41 +603,41 @@ const Ot = kt(async () => {
|
|
|
602
603
|
};
|
|
603
604
|
}
|
|
604
605
|
});
|
|
605
|
-
function
|
|
606
|
+
function Jt({
|
|
606
607
|
entry: t,
|
|
607
608
|
className: n,
|
|
608
609
|
renderMessage: r,
|
|
609
610
|
renderToolCall: s,
|
|
610
611
|
renderApproval: a,
|
|
611
|
-
getToolLabel:
|
|
612
|
+
getToolLabel: l
|
|
612
613
|
}) {
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
|
|
614
|
+
const i = ["mast-assistant-message", n].filter(Boolean).join(" "), { pendingApprovals: o } = tt(), m = (u) => {
|
|
615
|
+
const d = u.awaitingApproval ? o.find((b) => b.toolName === u.name) : void 0;
|
|
616
|
+
return d && a ? a(u, d) : s ? s(u, d) : d ? /* @__PURE__ */ e(
|
|
617
|
+
zt,
|
|
617
618
|
{
|
|
618
619
|
entry: u,
|
|
619
|
-
approve:
|
|
620
|
-
reject:
|
|
621
|
-
respondWith:
|
|
620
|
+
approve: d.approve,
|
|
621
|
+
reject: d.reject,
|
|
622
|
+
respondWith: d.respondWith
|
|
622
623
|
}
|
|
623
|
-
) : /* @__PURE__ */ e(
|
|
624
|
+
) : /* @__PURE__ */ e(bt, { entry: u });
|
|
624
625
|
};
|
|
625
|
-
return /* @__PURE__ */ e(
|
|
626
|
+
return /* @__PURE__ */ e(vt.Provider, { value: l, children: /* @__PURE__ */ w(
|
|
626
627
|
"div",
|
|
627
628
|
{
|
|
628
629
|
"data-mast-assistant-message": !0,
|
|
629
630
|
"data-streaming": t.isStreaming ? "true" : void 0,
|
|
630
|
-
className:
|
|
631
|
+
className: i,
|
|
631
632
|
children: [
|
|
632
|
-
t.thinking ? /* @__PURE__ */ e(
|
|
633
|
-
t.toolEvents.map((u,
|
|
634
|
-
t.text ? r ? r(t.text) : /* @__PURE__ */ e(
|
|
633
|
+
t.thinking ? /* @__PURE__ */ e(gt, { content: t.thinking, isStreaming: t.isStreaming }) : null,
|
|
634
|
+
t.toolEvents.map((u, d) => /* @__PURE__ */ e(mt, { children: m(u) }, `${u.id}-${d}`)),
|
|
635
|
+
t.text ? r ? r(t.text) : /* @__PURE__ */ e(Nt, { fallback: /* @__PURE__ */ e("p", { className: "mast-assistant-message-text", children: t.text }), children: /* @__PURE__ */ e(Qt, { children: t.text }) }) : null
|
|
635
636
|
]
|
|
636
637
|
}
|
|
637
638
|
) });
|
|
638
639
|
}
|
|
639
|
-
function
|
|
640
|
+
function Zt({
|
|
640
641
|
items: t,
|
|
641
642
|
activeIndex: n,
|
|
642
643
|
onSelect: r,
|
|
@@ -650,137 +651,137 @@ function qt({
|
|
|
650
651
|
id: `${s}-listbox`,
|
|
651
652
|
role: "listbox",
|
|
652
653
|
"aria-label": "Mention picker",
|
|
653
|
-
children: t.map((
|
|
654
|
-
const o =
|
|
654
|
+
children: t.map((l, i) => {
|
|
655
|
+
const o = i === n, m = o ? "mast-mention-picker-item mast-mention-picker-active" : "mast-mention-picker-item";
|
|
655
656
|
return /* @__PURE__ */ e(
|
|
656
657
|
"li",
|
|
657
658
|
{
|
|
658
|
-
id: `${s}-${
|
|
659
|
+
id: `${s}-${i}`,
|
|
659
660
|
role: "option",
|
|
660
661
|
"aria-selected": o,
|
|
661
|
-
className:
|
|
662
|
+
className: m,
|
|
662
663
|
onMouseDown: (u) => {
|
|
663
|
-
u.preventDefault(), r(
|
|
664
|
+
u.preventDefault(), r(l);
|
|
664
665
|
},
|
|
665
|
-
children: a ? a(
|
|
666
|
-
/* @__PURE__ */ e("div", { className: "mast-mention-picker-item-label", children:
|
|
667
|
-
|
|
666
|
+
children: a ? a(l, o) : /* @__PURE__ */ w("div", { children: [
|
|
667
|
+
/* @__PURE__ */ e("div", { className: "mast-mention-picker-item-label", children: l.label }),
|
|
668
|
+
l.description && /* @__PURE__ */ e("div", { className: "mast-mention-picker-item-description", children: l.description })
|
|
668
669
|
] })
|
|
669
670
|
},
|
|
670
|
-
|
|
671
|
+
l.id
|
|
671
672
|
);
|
|
672
673
|
})
|
|
673
674
|
}
|
|
674
675
|
);
|
|
675
676
|
}
|
|
676
|
-
const
|
|
677
|
-
function
|
|
677
|
+
const rt = "@";
|
|
678
|
+
function kt(t) {
|
|
678
679
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
679
680
|
}
|
|
680
|
-
function
|
|
681
|
-
const r =
|
|
681
|
+
function Xt(t, n = rt) {
|
|
682
|
+
const r = kt(n), s = new RegExp(`${r}([^\\s${r}]*)$`), a = t.match(s);
|
|
682
683
|
return a ? a[1] : null;
|
|
683
684
|
}
|
|
684
|
-
function
|
|
685
|
-
const r =
|
|
685
|
+
function te(t, n = rt) {
|
|
686
|
+
const r = kt(n), s = new RegExp(`${r}[^\\s${r}]*$`);
|
|
686
687
|
return t.replace(s, "");
|
|
687
688
|
}
|
|
688
|
-
function
|
|
689
|
-
return t.map((r) => `${r.text}${
|
|
689
|
+
function ee(t, n) {
|
|
690
|
+
return t.map((r) => `${r.text}${rt}${r.item.label}`).join("") + n;
|
|
690
691
|
}
|
|
691
|
-
function
|
|
692
|
-
const n = t.trigger ?? "@", [r, s] =
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
if (
|
|
699
|
-
|
|
692
|
+
function ne(t) {
|
|
693
|
+
const n = t.trigger ?? "@", [r, s] = $([]), [a, l] = $(""), [i, o] = $(null), [m, u] = $(0), [d, b] = $([]), S = R(r);
|
|
694
|
+
S.current = r;
|
|
695
|
+
const P = R(a);
|
|
696
|
+
P.current = a;
|
|
697
|
+
const _ = R(0);
|
|
698
|
+
z(() => {
|
|
699
|
+
if (i === null) {
|
|
700
|
+
b([]);
|
|
700
701
|
return;
|
|
701
702
|
}
|
|
702
|
-
const
|
|
703
|
+
const h = ++_.current;
|
|
703
704
|
if (t.onSearch) {
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}) :
|
|
705
|
+
const p = t.onSearch(i);
|
|
706
|
+
p instanceof Promise ? p.then((E) => {
|
|
707
|
+
h === _.current && b(E);
|
|
708
|
+
}) : b(p);
|
|
708
709
|
}
|
|
709
|
-
}, [
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
710
|
+
}, [i, t.onSearch]);
|
|
711
|
+
const M = new Set(r.map((h) => h.item.id)), c = (() => {
|
|
712
|
+
if (i === null) return [];
|
|
712
713
|
if (t.onSearch)
|
|
713
|
-
return
|
|
714
|
-
const
|
|
714
|
+
return d.filter((p) => !M.has(p.id));
|
|
715
|
+
const h = i.toLowerCase();
|
|
715
716
|
return (t.items ?? []).filter(
|
|
716
|
-
(
|
|
717
|
+
(p) => !M.has(p.id) && p.label.toLowerCase().includes(h)
|
|
717
718
|
);
|
|
718
|
-
})(),
|
|
719
|
-
(
|
|
720
|
-
|
|
719
|
+
})(), I = D(
|
|
720
|
+
(h) => {
|
|
721
|
+
l(h), o(Xt(h, n)), u(0);
|
|
721
722
|
},
|
|
722
723
|
[n]
|
|
723
|
-
),
|
|
724
|
-
(
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
const
|
|
728
|
-
s([...
|
|
724
|
+
), g = D(
|
|
725
|
+
(h) => {
|
|
726
|
+
const p = S.current;
|
|
727
|
+
if (p.some((f) => f.item.id === h.id)) return;
|
|
728
|
+
const E = te(P.current, n);
|
|
729
|
+
s([...p, { text: E, item: h }]), l(""), o(null), u(0);
|
|
729
730
|
},
|
|
730
731
|
[n]
|
|
731
|
-
),
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
736
|
-
|
|
732
|
+
), T = D((h) => {
|
|
733
|
+
const p = S.current, E = p.findIndex((v) => v.item.id === h);
|
|
734
|
+
if (E === -1) return;
|
|
735
|
+
const f = p[E].text, k = [...p.slice(0, E), ...p.slice(E + 1)];
|
|
736
|
+
if (E < k.length) {
|
|
737
|
+
k[E] = { ...k[E], text: f + k[E].text }, s(k);
|
|
737
738
|
return;
|
|
738
739
|
}
|
|
739
|
-
s(
|
|
740
|
-
}, []), N =
|
|
741
|
-
(
|
|
742
|
-
if (
|
|
743
|
-
switch (
|
|
740
|
+
s(k), l(f + P.current);
|
|
741
|
+
}, []), N = D(
|
|
742
|
+
(h) => {
|
|
743
|
+
if (i === null || c.length === 0) return !1;
|
|
744
|
+
switch (h.key) {
|
|
744
745
|
case "ArrowDown":
|
|
745
|
-
return
|
|
746
|
+
return h.preventDefault(), u((p) => (p + 1) % c.length), !0;
|
|
746
747
|
case "ArrowUp":
|
|
747
|
-
return
|
|
748
|
+
return h.preventDefault(), u((p) => p === 0 ? c.length - 1 : p - 1), !0;
|
|
748
749
|
case "Enter":
|
|
749
|
-
return
|
|
750
|
+
return h.preventDefault(), g(c[m] ?? c[0]), !0;
|
|
750
751
|
case "Escape":
|
|
751
|
-
return
|
|
752
|
+
return h.preventDefault(), o(null), !0;
|
|
752
753
|
default:
|
|
753
754
|
return !1;
|
|
754
755
|
}
|
|
755
756
|
},
|
|
756
|
-
[
|
|
757
|
-
),
|
|
758
|
-
const
|
|
759
|
-
return { prompt: t.buildPrompt ? t.buildPrompt(r, a) :
|
|
760
|
-
}, [r, a, t.buildPrompt]),
|
|
761
|
-
s([]),
|
|
757
|
+
[i, c, m, g]
|
|
758
|
+
), A = D(() => {
|
|
759
|
+
const h = ee(r, a);
|
|
760
|
+
return { prompt: t.buildPrompt ? t.buildPrompt(r, a) : h, displayText: h };
|
|
761
|
+
}, [r, a, t.buildPrompt]), x = D(() => {
|
|
762
|
+
s([]), l(""), o(null), u(0);
|
|
762
763
|
}, []);
|
|
763
764
|
return {
|
|
764
765
|
segments: r,
|
|
765
766
|
trailingInput: a,
|
|
766
|
-
mentionQuery:
|
|
767
|
-
filteredItems:
|
|
768
|
-
pickerIndex:
|
|
769
|
-
setTrailingInput:
|
|
767
|
+
mentionQuery: i,
|
|
768
|
+
filteredItems: c,
|
|
769
|
+
pickerIndex: m,
|
|
770
|
+
setTrailingInput: I,
|
|
770
771
|
handleKeyDown: N,
|
|
771
|
-
selectItem:
|
|
772
|
-
removeChip:
|
|
773
|
-
buildSubmission:
|
|
774
|
-
clear:
|
|
772
|
+
selectItem: g,
|
|
773
|
+
removeChip: T,
|
|
774
|
+
buildSubmission: A,
|
|
775
|
+
clear: x
|
|
775
776
|
};
|
|
776
777
|
}
|
|
777
|
-
const
|
|
778
|
-
function
|
|
778
|
+
const se = 1, re = 8;
|
|
779
|
+
function xt(t) {
|
|
779
780
|
const n = t.split(`
|
|
780
781
|
`).length;
|
|
781
|
-
return Math.min(
|
|
782
|
+
return Math.min(re, Math.max(se, n));
|
|
782
783
|
}
|
|
783
|
-
function
|
|
784
|
+
function ae({
|
|
784
785
|
className: t,
|
|
785
786
|
placeholder: n = "Type a message and press Enter.",
|
|
786
787
|
sendLabel: r,
|
|
@@ -788,7 +789,7 @@ function te({
|
|
|
788
789
|
mentions: a
|
|
789
790
|
}) {
|
|
790
791
|
return a ? /* @__PURE__ */ e(
|
|
791
|
-
|
|
792
|
+
ie,
|
|
792
793
|
{
|
|
793
794
|
className: t,
|
|
794
795
|
placeholder: n,
|
|
@@ -797,7 +798,7 @@ function te({
|
|
|
797
798
|
mentions: a
|
|
798
799
|
}
|
|
799
800
|
) : /* @__PURE__ */ e(
|
|
800
|
-
|
|
801
|
+
le,
|
|
801
802
|
{
|
|
802
803
|
className: t,
|
|
803
804
|
placeholder: n,
|
|
@@ -806,19 +807,19 @@ function te({
|
|
|
806
807
|
}
|
|
807
808
|
);
|
|
808
809
|
}
|
|
809
|
-
function
|
|
810
|
-
const { sendMessage: a, cancel:
|
|
811
|
-
|
|
812
|
-
},
|
|
813
|
-
|
|
810
|
+
function le({ className: t, placeholder: n, sendLabel: r, cancelLabel: s }) {
|
|
811
|
+
const { sendMessage: a, cancel: l, isRunning: i, isReady: o } = tt(), m = J(), [u, d] = $(""), b = ["mast-chat-input", t].filter(Boolean).join(" "), S = u.trim(), P = o && !i && S.length > 0, _ = !o || i, M = () => {
|
|
812
|
+
P && (a(S), d(""));
|
|
813
|
+
}, c = (I) => {
|
|
814
|
+
I.key === "Enter" && !I.shiftKey && (I.preventDefault(), M());
|
|
814
815
|
};
|
|
815
|
-
return /* @__PURE__ */
|
|
816
|
+
return /* @__PURE__ */ w(
|
|
816
817
|
"form",
|
|
817
818
|
{
|
|
818
819
|
"data-mast-chat-input": !0,
|
|
819
|
-
className:
|
|
820
|
-
onSubmit: (
|
|
821
|
-
|
|
820
|
+
className: b,
|
|
821
|
+
onSubmit: (I) => {
|
|
822
|
+
I.preventDefault(), M();
|
|
822
823
|
},
|
|
823
824
|
children: [
|
|
824
825
|
/* @__PURE__ */ e("label", { className: "mast-chat-input-label mast-visually-hidden", htmlFor: "mast-chat-input-field", children: "Message" }),
|
|
@@ -829,20 +830,20 @@ function ee({ className: t, placeholder: n, sendLabel: r, cancelLabel: s }) {
|
|
|
829
830
|
className: "mast-chat-input-textarea",
|
|
830
831
|
value: u,
|
|
831
832
|
placeholder: n,
|
|
832
|
-
rows:
|
|
833
|
-
disabled:
|
|
834
|
-
onChange: (
|
|
835
|
-
onKeyDown:
|
|
833
|
+
rows: xt(u),
|
|
834
|
+
disabled: _,
|
|
835
|
+
onChange: (I) => d(I.target.value),
|
|
836
|
+
onKeyDown: c
|
|
836
837
|
}
|
|
837
838
|
),
|
|
838
|
-
|
|
839
|
+
i ? /* @__PURE__ */ e(
|
|
839
840
|
"button",
|
|
840
841
|
{
|
|
841
842
|
type: "button",
|
|
842
843
|
className: "mast-chat-input-cancel",
|
|
843
844
|
"aria-label": "Cancel",
|
|
844
|
-
onClick:
|
|
845
|
-
children: s ??
|
|
845
|
+
onClick: l,
|
|
846
|
+
children: s ?? m.stop
|
|
846
847
|
}
|
|
847
848
|
) : /* @__PURE__ */ e(
|
|
848
849
|
"button",
|
|
@@ -850,95 +851,95 @@ function ee({ className: t, placeholder: n, sendLabel: r, cancelLabel: s }) {
|
|
|
850
851
|
type: "submit",
|
|
851
852
|
className: "mast-chat-input-send",
|
|
852
853
|
"aria-label": "Send",
|
|
853
|
-
disabled: !
|
|
854
|
-
children: r ??
|
|
854
|
+
disabled: !P,
|
|
855
|
+
children: r ?? m.send
|
|
855
856
|
}
|
|
856
857
|
)
|
|
857
858
|
]
|
|
858
859
|
}
|
|
859
860
|
);
|
|
860
861
|
}
|
|
861
|
-
function
|
|
862
|
+
function ie({
|
|
862
863
|
className: t,
|
|
863
864
|
placeholder: n,
|
|
864
865
|
sendLabel: r,
|
|
865
866
|
cancelLabel: s,
|
|
866
867
|
mentions: a
|
|
867
868
|
}) {
|
|
868
|
-
const { sendMessage:
|
|
869
|
-
segments:
|
|
870
|
-
trailingInput:
|
|
871
|
-
mentionQuery:
|
|
872
|
-
filteredItems:
|
|
873
|
-
pickerIndex:
|
|
874
|
-
setTrailingInput:
|
|
875
|
-
handleKeyDown:
|
|
876
|
-
selectItem:
|
|
877
|
-
removeChip:
|
|
869
|
+
const { sendMessage: l, cancel: i, isRunning: o, isReady: m } = tt(), u = J(), d = wt(), {
|
|
870
|
+
segments: b,
|
|
871
|
+
trailingInput: S,
|
|
872
|
+
mentionQuery: P,
|
|
873
|
+
filteredItems: _,
|
|
874
|
+
pickerIndex: M,
|
|
875
|
+
setTrailingInput: c,
|
|
876
|
+
handleKeyDown: I,
|
|
877
|
+
selectItem: g,
|
|
878
|
+
removeChip: T,
|
|
878
879
|
buildSubmission: N,
|
|
879
|
-
clear:
|
|
880
|
-
} =
|
|
881
|
-
if (!
|
|
882
|
-
const { prompt:
|
|
883
|
-
|
|
884
|
-
},
|
|
885
|
-
|
|
880
|
+
clear: A
|
|
881
|
+
} = ne(a), x = ["mast-chat-input", "mast-mention-input", t].filter(Boolean).join(" "), h = b.length > 0 || S.trim().length > 0, p = m && !o && h, E = !m || o, f = P !== null && _.length > 0, k = f ? `${d}-${M}` : void 0, v = () => {
|
|
882
|
+
if (!p) return;
|
|
883
|
+
const { prompt: y, displayText: U } = N();
|
|
884
|
+
U.trim() && (l(y, U), A());
|
|
885
|
+
}, C = (y) => {
|
|
886
|
+
I(y) || y.key === "Enter" && !y.shiftKey && (y.preventDefault(), v());
|
|
886
887
|
};
|
|
887
|
-
return /* @__PURE__ */
|
|
888
|
+
return /* @__PURE__ */ w(
|
|
888
889
|
"form",
|
|
889
890
|
{
|
|
890
891
|
"data-mast-chat-input": !0,
|
|
891
|
-
className:
|
|
892
|
-
onSubmit: (
|
|
893
|
-
|
|
892
|
+
className: x,
|
|
893
|
+
onSubmit: (y) => {
|
|
894
|
+
y.preventDefault(), v();
|
|
894
895
|
},
|
|
895
896
|
children: [
|
|
896
897
|
/* @__PURE__ */ e("label", { className: "mast-chat-input-label mast-visually-hidden", htmlFor: "mast-chat-input-field", children: "Message" }),
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
|
|
899
|
-
|
|
898
|
+
/* @__PURE__ */ w("div", { className: "mast-mention-input-field", children: [
|
|
899
|
+
f && /* @__PURE__ */ e(
|
|
900
|
+
Zt,
|
|
900
901
|
{
|
|
901
|
-
items:
|
|
902
|
-
activeIndex:
|
|
903
|
-
onSelect:
|
|
904
|
-
idPrefix:
|
|
902
|
+
items: _,
|
|
903
|
+
activeIndex: M,
|
|
904
|
+
onSelect: g,
|
|
905
|
+
idPrefix: d,
|
|
905
906
|
renderItem: a.renderItem
|
|
906
907
|
}
|
|
907
908
|
),
|
|
908
|
-
/* @__PURE__ */
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
a.renderChip ? a.renderChip(
|
|
909
|
+
/* @__PURE__ */ w("div", { className: "mast-mention-input-content", children: [
|
|
910
|
+
b.map((y) => /* @__PURE__ */ w(mt, { children: [
|
|
911
|
+
y.text && /* @__PURE__ */ e("span", { className: "mast-mention-segment-text", children: y.text }),
|
|
912
|
+
a.renderChip ? a.renderChip(y.item, () => T(y.item.id)) : /* @__PURE__ */ w("span", { className: "mast-mention-chip", children: [
|
|
912
913
|
"@",
|
|
913
|
-
|
|
914
|
+
y.item.label,
|
|
914
915
|
/* @__PURE__ */ e(
|
|
915
916
|
"button",
|
|
916
917
|
{
|
|
917
918
|
type: "button",
|
|
918
919
|
className: "mast-mention-chip-remove",
|
|
919
|
-
"aria-label": `Remove reference to ${
|
|
920
|
-
onClick: () => y
|
|
920
|
+
"aria-label": `Remove reference to ${y.item.label}`,
|
|
921
|
+
onClick: () => T(y.item.id),
|
|
921
922
|
children: "×"
|
|
922
923
|
}
|
|
923
924
|
)
|
|
924
925
|
] })
|
|
925
|
-
] },
|
|
926
|
+
] }, y.item.id)),
|
|
926
927
|
/* @__PURE__ */ e(
|
|
927
928
|
"textarea",
|
|
928
929
|
{
|
|
929
930
|
id: "mast-chat-input-field",
|
|
930
931
|
className: "mast-chat-input-textarea mast-mention-input-textarea",
|
|
931
|
-
value:
|
|
932
|
-
placeholder:
|
|
933
|
-
rows:
|
|
934
|
-
disabled:
|
|
935
|
-
onChange: (
|
|
936
|
-
onKeyDown:
|
|
932
|
+
value: S,
|
|
933
|
+
placeholder: b.length === 0 ? n : "",
|
|
934
|
+
rows: xt(S),
|
|
935
|
+
disabled: E,
|
|
936
|
+
onChange: (y) => c(y.target.value),
|
|
937
|
+
onKeyDown: C,
|
|
937
938
|
role: "combobox",
|
|
938
|
-
"aria-expanded":
|
|
939
|
-
"aria-controls":
|
|
939
|
+
"aria-expanded": f,
|
|
940
|
+
"aria-controls": f ? `${d}-listbox` : void 0,
|
|
940
941
|
"aria-autocomplete": "list",
|
|
941
|
-
"aria-activedescendant":
|
|
942
|
+
"aria-activedescendant": k
|
|
942
943
|
}
|
|
943
944
|
)
|
|
944
945
|
] })
|
|
@@ -949,7 +950,7 @@ function ne({
|
|
|
949
950
|
type: "button",
|
|
950
951
|
className: "mast-chat-input-cancel",
|
|
951
952
|
"aria-label": "Cancel",
|
|
952
|
-
onClick:
|
|
953
|
+
onClick: i,
|
|
953
954
|
children: s ?? u.stop
|
|
954
955
|
}
|
|
955
956
|
) : /* @__PURE__ */ e(
|
|
@@ -958,7 +959,7 @@ function ne({
|
|
|
958
959
|
type: "submit",
|
|
959
960
|
className: "mast-chat-input-send",
|
|
960
961
|
"aria-label": "Send",
|
|
961
|
-
disabled: !
|
|
962
|
+
disabled: !p,
|
|
962
963
|
children: r ?? u.send
|
|
963
964
|
}
|
|
964
965
|
)
|
|
@@ -966,62 +967,94 @@ function ne({
|
|
|
966
967
|
}
|
|
967
968
|
);
|
|
968
969
|
}
|
|
969
|
-
function
|
|
970
|
+
function oe({
|
|
970
971
|
entry: t,
|
|
971
972
|
className: n,
|
|
972
973
|
renderToolCall: r,
|
|
973
974
|
renderApproval: s,
|
|
974
975
|
renderMessage: a,
|
|
975
|
-
getToolLabel:
|
|
976
|
+
getToolLabel: l
|
|
976
977
|
}) {
|
|
977
|
-
return t.role === "user" ? /* @__PURE__ */ e(
|
|
978
|
-
|
|
978
|
+
return t.role === "user" ? /* @__PURE__ */ e(qt, { entry: t, className: n }) : /* @__PURE__ */ e(
|
|
979
|
+
Jt,
|
|
979
980
|
{
|
|
980
981
|
entry: t,
|
|
981
982
|
className: n,
|
|
982
983
|
renderToolCall: r,
|
|
983
984
|
renderApproval: s,
|
|
984
985
|
renderMessage: a,
|
|
985
|
-
getToolLabel:
|
|
986
|
+
getToolLabel: l
|
|
986
987
|
}
|
|
987
988
|
);
|
|
988
989
|
}
|
|
989
|
-
const
|
|
990
|
-
function
|
|
990
|
+
const ce = 80, ue = 4, dt = 4;
|
|
991
|
+
function de({
|
|
991
992
|
className: t,
|
|
992
993
|
renderToolCall: n,
|
|
993
994
|
renderApproval: r,
|
|
994
995
|
renderMessage: s,
|
|
995
996
|
getToolLabel: a
|
|
996
997
|
}) {
|
|
997
|
-
const { messages:
|
|
998
|
-
count:
|
|
999
|
-
getScrollElement: () =>
|
|
1000
|
-
estimateSize: () =>
|
|
998
|
+
const { messages: l } = tt(), i = R(null), o = R(!0), m = R(0), u = R(null), d = At({
|
|
999
|
+
count: l.length,
|
|
1000
|
+
getScrollElement: () => i.current,
|
|
1001
|
+
estimateSize: () => ce,
|
|
1001
1002
|
overscan: 4
|
|
1002
|
-
})
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1003
|
+
});
|
|
1004
|
+
z(() => {
|
|
1005
|
+
const c = i.current;
|
|
1006
|
+
if (!c) return;
|
|
1007
|
+
m.current = c.scrollTop;
|
|
1008
|
+
const I = () => {
|
|
1009
|
+
const x = c.scrollTop, h = m.current;
|
|
1010
|
+
m.current = x;
|
|
1011
|
+
const p = c.scrollHeight - x - c.clientHeight;
|
|
1012
|
+
x < h - dt ? o.current = !1 : !o.current && p <= ue && (o.current = !0);
|
|
1013
|
+
}, g = (x) => {
|
|
1014
|
+
x.deltaY < 0 && c.scrollHeight > c.clientHeight && (o.current = !1);
|
|
1015
|
+
};
|
|
1016
|
+
let T = null;
|
|
1017
|
+
const N = (x) => {
|
|
1018
|
+
var h;
|
|
1019
|
+
T = ((h = x.touches[0]) == null ? void 0 : h.clientY) ?? null;
|
|
1020
|
+
}, A = (x) => {
|
|
1021
|
+
var p;
|
|
1022
|
+
if (T === null) return;
|
|
1023
|
+
(((p = x.touches[0]) == null ? void 0 : p.clientY) ?? T) - T > 0 && c.scrollHeight > c.clientHeight && (o.current = !1);
|
|
1024
|
+
};
|
|
1025
|
+
return c.addEventListener("scroll", I, { passive: !0 }), c.addEventListener("wheel", g, { passive: !0 }), c.addEventListener("touchstart", N, { passive: !0 }), c.addEventListener("touchmove", A, { passive: !0 }), () => {
|
|
1026
|
+
c.removeEventListener("scroll", I), c.removeEventListener("wheel", g), c.removeEventListener("touchstart", N), c.removeEventListener("touchmove", A);
|
|
1027
|
+
};
|
|
1028
|
+
}, []);
|
|
1029
|
+
const b = l.length > 0 ? l[l.length - 1] : void 0, S = (b == null ? void 0 : b.text.length) ?? 0, P = d.getTotalSize();
|
|
1030
|
+
z(() => {
|
|
1031
|
+
if (l.length === 0 || !o.current) return;
|
|
1032
|
+
const c = i.current;
|
|
1033
|
+
if (c && u.current !== null && c.scrollTop < u.current - dt) {
|
|
1034
|
+
o.current = !1;
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
d.scrollToIndex(l.length - 1, { align: "end" }), c && (u.current = c.scrollTop);
|
|
1038
|
+
}, [l.length, S, P, d]);
|
|
1039
|
+
const _ = d.getVirtualItems(), M = ["mast-message-list", t].filter(Boolean).join(" ");
|
|
1040
|
+
return /* @__PURE__ */ e("div", { ref: i, "data-mast-message-list": !0, className: M, role: "log", "aria-live": "polite", children: /* @__PURE__ */ e("div", { style: { height: `${P}px`, position: "relative", width: "100%" }, children: _.map((c) => {
|
|
1041
|
+
const I = l[c.index];
|
|
1009
1042
|
return /* @__PURE__ */ e(
|
|
1010
1043
|
"div",
|
|
1011
1044
|
{
|
|
1012
|
-
"data-index":
|
|
1013
|
-
ref:
|
|
1045
|
+
"data-index": c.index,
|
|
1046
|
+
ref: d.measureElement,
|
|
1014
1047
|
style: {
|
|
1015
1048
|
position: "absolute",
|
|
1016
1049
|
top: 0,
|
|
1017
1050
|
left: 0,
|
|
1018
1051
|
width: "100%",
|
|
1019
|
-
transform: `translateY(${
|
|
1052
|
+
transform: `translateY(${c.start}px)`
|
|
1020
1053
|
},
|
|
1021
1054
|
children: /* @__PURE__ */ e(
|
|
1022
|
-
|
|
1055
|
+
oe,
|
|
1023
1056
|
{
|
|
1024
|
-
entry:
|
|
1057
|
+
entry: I,
|
|
1025
1058
|
renderToolCall: n,
|
|
1026
1059
|
renderApproval: r,
|
|
1027
1060
|
renderMessage: s,
|
|
@@ -1029,50 +1062,50 @@ function ae({
|
|
|
1029
1062
|
}
|
|
1030
1063
|
)
|
|
1031
1064
|
},
|
|
1032
|
-
|
|
1065
|
+
I.id
|
|
1033
1066
|
);
|
|
1034
1067
|
}) }) });
|
|
1035
1068
|
}
|
|
1036
|
-
function
|
|
1069
|
+
function ve({
|
|
1037
1070
|
theme: t,
|
|
1038
1071
|
className: n,
|
|
1039
1072
|
renderToolCall: r,
|
|
1040
1073
|
renderApproval: s,
|
|
1041
1074
|
renderMessage: a,
|
|
1042
|
-
getToolLabel:
|
|
1043
|
-
inputPlaceholder:
|
|
1075
|
+
getToolLabel: l,
|
|
1076
|
+
inputPlaceholder: i,
|
|
1044
1077
|
mentions: o
|
|
1045
1078
|
}) {
|
|
1046
|
-
const
|
|
1047
|
-
return /* @__PURE__ */
|
|
1079
|
+
const m = ["mast-conversation-panel", n].filter(Boolean).join(" ");
|
|
1080
|
+
return /* @__PURE__ */ w("div", { "data-mast-root": !0, "data-mast-theme": t, className: m, children: [
|
|
1048
1081
|
/* @__PURE__ */ e(
|
|
1049
|
-
|
|
1082
|
+
de,
|
|
1050
1083
|
{
|
|
1051
1084
|
renderToolCall: r,
|
|
1052
1085
|
renderApproval: s,
|
|
1053
1086
|
renderMessage: a,
|
|
1054
|
-
getToolLabel:
|
|
1087
|
+
getToolLabel: l
|
|
1055
1088
|
}
|
|
1056
1089
|
),
|
|
1057
|
-
/* @__PURE__ */ e(
|
|
1090
|
+
/* @__PURE__ */ e(ae, { placeholder: i, mentions: o })
|
|
1058
1091
|
] });
|
|
1059
1092
|
}
|
|
1060
1093
|
export {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1094
|
+
ge as AgentProvider,
|
|
1095
|
+
Jt as AssistantMessage,
|
|
1096
|
+
ae as ChatInput,
|
|
1097
|
+
ve as ConversationPanel,
|
|
1098
|
+
pt as INLINE_APPROVAL,
|
|
1099
|
+
zt as InlineApproval,
|
|
1100
|
+
oe as MessageItem,
|
|
1101
|
+
de as MessageList,
|
|
1102
|
+
gt as ThinkingBlock,
|
|
1103
|
+
bt as ToolCallBlock,
|
|
1104
|
+
qt as UserMessage,
|
|
1105
|
+
ee as buildInlineMentionPrompt,
|
|
1106
|
+
Xt as extractMentionQuery,
|
|
1107
|
+
te as removeMentionTrigger,
|
|
1108
|
+
tt as useAgent,
|
|
1109
|
+
Rt as useAgentStream,
|
|
1110
|
+
ne as useMentions
|
|
1078
1111
|
};
|