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