@amodalai/react 0.2.0 → 0.2.1
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/{event-bus-h26clqbZ.js → chat-api-CqMQa8r3.js} +85 -85
- package/dist/chat-api-CqMQa8r3.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/hooks/useAmodalChat.d.ts +2 -2
- package/dist/hooks/useAmodalChat.d.ts.map +1 -1
- package/dist/hooks/useChat.d.ts +2 -2
- package/dist/hooks/useChat.d.ts.map +1 -1
- package/dist/hooks/useChatStream.d.ts +47 -0
- package/dist/hooks/useChatStream.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/react.js +373 -638
- package/dist/react.js.map +1 -1
- package/dist/theme-C051UgQ1.js +801 -0
- package/dist/theme-C051UgQ1.js.map +1 -0
- package/dist/types.d.ts +19 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/widget.js +3 -3
- package/package.json +1 -1
- package/dist/event-bus-h26clqbZ.js.map +0 -1
- package/dist/theme-VAUsolBG.js +0 -693
- package/dist/theme-VAUsolBG.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,330 +1,63 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { RuntimeClient as
|
|
4
|
-
import { ChatClient as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as u, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as R, useMemo as D, useContext as T, useRef as N, useCallback as x, useState as _, useEffect as I } from "react";
|
|
3
|
+
import { RuntimeClient as j } from "./client.js";
|
|
4
|
+
import { ChatClient as ae, ChatStream as ne } from "./client.js";
|
|
5
|
+
import { u as P } from "./theme-C051UgQ1.js";
|
|
6
|
+
import { a as oe, c as ce, d as le, m as ie, b as de, e as ue, f as me } from "./theme-C051UgQ1.js";
|
|
7
|
+
import { T as he, W as ge, c as _e, a as ve, d as pe, g as be, l as ye, p as we, s as Se, b as xe, e as Ne, u as Ce } from "./chat-api-CqMQa8r3.js";
|
|
8
|
+
const O = R(null);
|
|
9
|
+
function Q({ runtimeUrl: e, getToken: o, children: d }) {
|
|
10
|
+
const s = D(
|
|
11
|
+
() => new j({ runtimeUrl: e, getToken: o }),
|
|
12
|
+
[e, o]
|
|
13
|
+
), m = D(
|
|
14
|
+
() => ({ client: s, runtimeUrl: e }),
|
|
15
|
+
[s, e]
|
|
15
16
|
);
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ u(O.Provider, { value: m, children: d });
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
19
|
+
function k() {
|
|
20
|
+
const e = T(O);
|
|
21
|
+
if (!e)
|
|
21
22
|
throw new Error("useAmodalContext must be used within an <AmodalProvider>");
|
|
22
|
-
return
|
|
23
|
+
return e;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* @license
|
|
26
27
|
* Copyright 2025 Amodal Labs, Inc.
|
|
27
28
|
* SPDX-License-Identifier: MIT
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return $++, `msg-${Date.now()}-${String($)}`;
|
|
41
|
-
}
|
|
42
|
-
function X(s, r) {
|
|
43
|
-
switch (r.type) {
|
|
44
|
-
case "SEND_MESSAGE": {
|
|
45
|
-
const t = {
|
|
46
|
-
type: "user",
|
|
47
|
-
id: P(),
|
|
48
|
-
text: r.text,
|
|
49
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
50
|
-
}, e = {
|
|
51
|
-
type: "assistant_text",
|
|
52
|
-
id: P(),
|
|
53
|
-
text: "",
|
|
54
|
-
toolCalls: [],
|
|
55
|
-
confirmations: [],
|
|
56
|
-
skillActivations: [],
|
|
57
|
-
kbProposals: [],
|
|
58
|
-
widgets: [],
|
|
59
|
-
contentBlocks: [],
|
|
60
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
...s,
|
|
64
|
-
messages: [...s.messages, t, e],
|
|
65
|
-
isStreaming: !0,
|
|
66
|
-
error: null,
|
|
67
|
-
activeToolCalls: []
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
case "STREAM_INIT":
|
|
71
|
-
return { ...s, sessionId: r.sessionId };
|
|
72
|
-
case "STREAM_TEXT_DELTA": {
|
|
73
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
74
|
-
if (e && e.type === "assistant_text") {
|
|
75
|
-
const n = [...e.contentBlocks], a = n[n.length - 1];
|
|
76
|
-
a && a.type === "text" ? n[n.length - 1] = { type: "text", text: a.text + r.content } : n.push({ type: "text", text: r.content }), t[t.length - 1] = { ...e, text: e.text + r.content, contentBlocks: n };
|
|
77
|
-
}
|
|
78
|
-
return { ...s, messages: t };
|
|
79
|
-
}
|
|
80
|
-
case "STREAM_TOOL_CALL_START": {
|
|
81
|
-
const t = [...s.messages], e = t[t.length - 1], n = {
|
|
82
|
-
toolId: r.toolId,
|
|
83
|
-
toolName: r.toolName,
|
|
84
|
-
parameters: r.parameters,
|
|
85
|
-
status: "running"
|
|
86
|
-
};
|
|
87
|
-
if (e && e.type === "assistant_text") {
|
|
88
|
-
const a = [...e.toolCalls, n], c = [...e.contentBlocks], u = c[c.length - 1];
|
|
89
|
-
u && u.type === "tool_calls" ? c[c.length - 1] = { type: "tool_calls", calls: [...u.calls, n] } : c.push({ type: "tool_calls", calls: [n] }), t[t.length - 1] = { ...e, toolCalls: a, contentBlocks: c };
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
...s,
|
|
93
|
-
messages: t,
|
|
94
|
-
activeToolCalls: [...s.activeToolCalls, n]
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
case "STREAM_TOOL_CALL_RESULT": {
|
|
98
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
99
|
-
if (e && e.type === "assistant_text") {
|
|
100
|
-
const a = (i) => i.toolId === r.toolId ? {
|
|
101
|
-
...i,
|
|
102
|
-
status: r.status,
|
|
103
|
-
result: r.result,
|
|
104
|
-
parameters: r.parameters ?? i.parameters,
|
|
105
|
-
duration_ms: r.duration_ms,
|
|
106
|
-
error: r.error
|
|
107
|
-
} : i, c = e.toolCalls.map(a), u = e.contentBlocks.map(
|
|
108
|
-
(i) => i.type === "tool_calls" ? { ...i, calls: i.calls.map(a) } : i
|
|
109
|
-
);
|
|
110
|
-
t[t.length - 1] = { ...e, toolCalls: c, contentBlocks: u };
|
|
111
|
-
}
|
|
112
|
-
const n = s.activeToolCalls.filter(
|
|
113
|
-
(a) => a.toolId !== r.toolId
|
|
114
|
-
);
|
|
115
|
-
return { ...s, messages: t, activeToolCalls: n };
|
|
116
|
-
}
|
|
117
|
-
case "STREAM_SUBAGENT_EVENT": {
|
|
118
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
119
|
-
if (e && e.type === "assistant_text") {
|
|
120
|
-
const n = (u) => u.toolId === r.parentToolId ? { ...u, subagentEvents: [...u.subagentEvents ?? [], r.event] } : u, a = e.toolCalls.map(n), c = e.contentBlocks.map(
|
|
121
|
-
(u) => u.type === "tool_calls" ? { ...u, calls: u.calls.map(n) } : u
|
|
122
|
-
);
|
|
123
|
-
t[t.length - 1] = { ...e, toolCalls: a, contentBlocks: c };
|
|
124
|
-
}
|
|
125
|
-
return { ...s, messages: t };
|
|
126
|
-
}
|
|
127
|
-
case "STREAM_WIDGET": {
|
|
128
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
129
|
-
if (e && e.type === "assistant_text") {
|
|
130
|
-
const n = {
|
|
131
|
-
type: "widget",
|
|
132
|
-
widgetType: r.widgetType,
|
|
133
|
-
data: r.data
|
|
134
|
-
};
|
|
135
|
-
t[t.length - 1] = {
|
|
136
|
-
...e,
|
|
137
|
-
contentBlocks: [...e.contentBlocks, n]
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
return { ...s, messages: t };
|
|
141
|
-
}
|
|
142
|
-
case "STREAM_CONFIRMATION_REQUIRED": {
|
|
143
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
144
|
-
if (e && e.type === "assistant_text") {
|
|
145
|
-
const n = {
|
|
146
|
-
type: "confirmation",
|
|
147
|
-
confirmation: r.confirmation
|
|
148
|
-
};
|
|
149
|
-
t[t.length - 1] = {
|
|
150
|
-
...e,
|
|
151
|
-
confirmations: [...e.confirmations, r.confirmation],
|
|
152
|
-
contentBlocks: [...e.contentBlocks, n]
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
return { ...s, messages: t };
|
|
156
|
-
}
|
|
157
|
-
case "CONFIRMATION_RESPONDED": {
|
|
158
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
159
|
-
if (e && e.type === "assistant_text") {
|
|
160
|
-
const n = e.confirmations.map(
|
|
161
|
-
(c) => c.correlationId === r.correlationId ? { ...c, status: r.approved ? "approved" : "denied" } : c
|
|
162
|
-
), a = e.contentBlocks.map(
|
|
163
|
-
(c) => c.type === "confirmation" && c.confirmation.correlationId === r.correlationId ? { ...c, confirmation: { ...c.confirmation, status: r.approved ? "approved" : "denied" } } : c
|
|
164
|
-
);
|
|
165
|
-
t[t.length - 1] = { ...e, confirmations: n, contentBlocks: a };
|
|
166
|
-
}
|
|
167
|
-
return { ...s, messages: t };
|
|
168
|
-
}
|
|
169
|
-
case "STREAM_ERROR":
|
|
170
|
-
return { ...s, isStreaming: !1, error: r.message, activeToolCalls: [] };
|
|
171
|
-
case "STREAM_DONE": {
|
|
172
|
-
const t = [...s.messages], e = t[t.length - 1];
|
|
173
|
-
if (e && e.type === "assistant_text") {
|
|
174
|
-
const a = (i) => i.status === "running" ? { ...i, status: "error", error: "Stopped" } : i, c = e.toolCalls.map(a), u = e.contentBlocks.map(
|
|
175
|
-
(i) => i.type === "tool_calls" ? { ...i, calls: i.calls.map(a) } : i
|
|
176
|
-
);
|
|
177
|
-
t[t.length - 1] = { ...e, toolCalls: c, contentBlocks: u };
|
|
178
|
-
}
|
|
179
|
-
const n = r.usage ? { inputTokens: s.usage.inputTokens + r.usage.inputTokens, outputTokens: s.usage.outputTokens + r.usage.outputTokens } : s.usage;
|
|
180
|
-
return { ...s, messages: t, isStreaming: !1, activeToolCalls: [], usage: n };
|
|
181
|
-
}
|
|
182
|
-
case "RESET":
|
|
183
|
-
return { ...G };
|
|
184
|
-
default:
|
|
185
|
-
return s;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function W(s) {
|
|
189
|
-
const { client: r } = R(), [t, e] = Q(X, G), n = N((s == null ? void 0 : s.initialSessionId) ?? null), a = N(null), c = N(s);
|
|
190
|
-
c.current = s, n.current = t.sessionId ?? n.current;
|
|
191
|
-
const u = A(
|
|
192
|
-
(_) => {
|
|
193
|
-
if (t.isStreaming) return;
|
|
194
|
-
e({ type: "SEND_MESSAGE", text: _ });
|
|
195
|
-
const h = new AbortController();
|
|
196
|
-
a.current = h, (async () => {
|
|
197
|
-
var o, d, f, l, b, T, x, C, M, D, O;
|
|
198
|
-
let p = !1;
|
|
199
|
-
try {
|
|
200
|
-
const k = r.chatStream(_, {
|
|
201
|
-
sessionId: n.current ?? void 0,
|
|
202
|
-
context: (o = c.current) == null ? void 0 : o.context,
|
|
203
|
-
signal: h.signal
|
|
204
|
-
});
|
|
205
|
-
for await (const g of k)
|
|
206
|
-
switch (g.type) {
|
|
207
|
-
case "init":
|
|
208
|
-
e({ type: "STREAM_INIT", sessionId: g.session_id }), (f = (d = c.current) == null ? void 0 : d.onSessionCreated) == null || f.call(d, g.session_id);
|
|
209
|
-
break;
|
|
210
|
-
case "text_delta":
|
|
211
|
-
e({ type: "STREAM_TEXT_DELTA", content: g.content });
|
|
212
|
-
break;
|
|
213
|
-
case "tool_call_start":
|
|
214
|
-
e({
|
|
215
|
-
type: "STREAM_TOOL_CALL_START",
|
|
216
|
-
toolId: g.tool_id,
|
|
217
|
-
toolName: g.tool_name,
|
|
218
|
-
parameters: g.parameters
|
|
219
|
-
});
|
|
220
|
-
break;
|
|
221
|
-
case "tool_call_result":
|
|
222
|
-
e({
|
|
223
|
-
type: "STREAM_TOOL_CALL_RESULT",
|
|
224
|
-
toolId: g.tool_id,
|
|
225
|
-
status: g.status,
|
|
226
|
-
result: g.result,
|
|
227
|
-
parameters: g.parameters,
|
|
228
|
-
duration_ms: g.duration_ms,
|
|
229
|
-
error: g.error
|
|
230
|
-
}), (b = (l = c.current) == null ? void 0 : l.onToolCall) == null || b.call(l, {
|
|
231
|
-
toolId: g.tool_id,
|
|
232
|
-
toolName: "",
|
|
233
|
-
parameters: {},
|
|
234
|
-
status: g.status,
|
|
235
|
-
result: g.result,
|
|
236
|
-
duration_ms: g.duration_ms,
|
|
237
|
-
error: g.error
|
|
238
|
-
});
|
|
239
|
-
break;
|
|
240
|
-
case "subagent_event":
|
|
241
|
-
e({
|
|
242
|
-
type: "STREAM_SUBAGENT_EVENT",
|
|
243
|
-
parentToolId: g.parent_tool_id,
|
|
244
|
-
event: {
|
|
245
|
-
agentName: g.agent_name,
|
|
246
|
-
eventType: g.event_type,
|
|
247
|
-
toolName: g.tool_name,
|
|
248
|
-
toolArgs: g.tool_args,
|
|
249
|
-
result: g.result,
|
|
250
|
-
text: g.text,
|
|
251
|
-
error: g.error,
|
|
252
|
-
timestamp: g.timestamp
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
break;
|
|
256
|
-
case "widget":
|
|
257
|
-
e({
|
|
258
|
-
type: "STREAM_WIDGET",
|
|
259
|
-
widgetType: g.widget_type,
|
|
260
|
-
data: g.data
|
|
261
|
-
});
|
|
262
|
-
break;
|
|
263
|
-
case "confirmation_required": {
|
|
264
|
-
const L = {
|
|
265
|
-
endpoint: g.endpoint,
|
|
266
|
-
method: g.method,
|
|
267
|
-
reason: g.reason,
|
|
268
|
-
escalated: g.escalated,
|
|
269
|
-
params: g.params,
|
|
270
|
-
connectionName: g.connection_name,
|
|
271
|
-
correlationId: g.correlation_id,
|
|
272
|
-
status: "pending"
|
|
273
|
-
};
|
|
274
|
-
e({ type: "STREAM_CONFIRMATION_REQUIRED", confirmation: L }), (x = (T = c.current) == null ? void 0 : T.onConfirmation) == null || x.call(T, L);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case "error":
|
|
278
|
-
e({ type: "STREAM_ERROR", message: g.message });
|
|
279
|
-
break;
|
|
280
|
-
case "done":
|
|
281
|
-
p = !0, e({
|
|
282
|
-
type: "STREAM_DONE",
|
|
283
|
-
usage: g.usage ? { inputTokens: g.usage.input_tokens, outputTokens: g.usage.output_tokens } : void 0
|
|
284
|
-
}), (M = (C = c.current) == null ? void 0 : C.onStreamEnd) == null || M.call(C);
|
|
285
|
-
break;
|
|
286
|
-
default:
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
} catch (k) {
|
|
290
|
-
k instanceof DOMException && k.name === "AbortError" || e({
|
|
291
|
-
type: "STREAM_ERROR",
|
|
292
|
-
message: k instanceof Error ? k.message : "Unknown error"
|
|
293
|
-
});
|
|
294
|
-
} finally {
|
|
295
|
-
a.current = null, !p && !h.signal.aborted && (e({ type: "STREAM_DONE" }), (O = (D = c.current) == null ? void 0 : D.onStreamEnd) == null || O.call(D));
|
|
296
|
-
}
|
|
297
|
-
})();
|
|
298
|
-
},
|
|
299
|
-
[r, t.isStreaming]
|
|
300
|
-
), i = A(() => {
|
|
301
|
-
a.current && (a.current.abort(), a.current = null), e({ type: "STREAM_DONE" });
|
|
302
|
-
}, []), S = A(() => {
|
|
303
|
-
a.current && (a.current.abort(), a.current = null), n.current = null, e({ type: "RESET" });
|
|
304
|
-
}, []), E = A(
|
|
305
|
-
(_, h) => {
|
|
306
|
-
e({ type: "CONFIRMATION_RESPONDED", correlationId: _, approved: h });
|
|
307
|
-
const m = h ? `I approve the action (correlation: ${_})` : `I deny the action (correlation: ${_})`;
|
|
308
|
-
t.isStreaming || u(m);
|
|
309
|
-
},
|
|
310
|
-
[u, t.isStreaming]
|
|
311
|
-
);
|
|
312
|
-
return w(
|
|
313
|
-
() => () => {
|
|
314
|
-
a.current && a.current.abort();
|
|
30
|
+
function L(e) {
|
|
31
|
+
const { client: o } = k(), d = N(e);
|
|
32
|
+
d.current = e;
|
|
33
|
+
const s = N((e == null ? void 0 : e.initialSessionId) ?? null), m = x(
|
|
34
|
+
(b, p) => {
|
|
35
|
+
var h;
|
|
36
|
+
return o.chatStream(b, {
|
|
37
|
+
...s.current ? { sessionId: s.current } : {},
|
|
38
|
+
...(h = d.current) != null && h.context ? { context: d.current.context } : {},
|
|
39
|
+
signal: p
|
|
40
|
+
});
|
|
315
41
|
},
|
|
316
|
-
[]
|
|
317
|
-
), {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
42
|
+
[o]
|
|
43
|
+
), a = P({
|
|
44
|
+
streamFn: m,
|
|
45
|
+
...e != null && e.onStreamEnd ? { onStreamEnd: e.onStreamEnd } : {},
|
|
46
|
+
...e != null && e.onSessionCreated ? { onSessionCreated: e.onSessionCreated } : {},
|
|
47
|
+
...e != null && e.onToolCall ? { onToolCall: e.onToolCall } : {},
|
|
48
|
+
...e != null && e.onConfirmation ? { onConfirmation: e.onConfirmation } : {}
|
|
49
|
+
});
|
|
50
|
+
return s.current = a.sessionId ?? s.current, {
|
|
51
|
+
messages: a.messages,
|
|
52
|
+
send: a.send,
|
|
53
|
+
stop: a.stop,
|
|
54
|
+
isStreaming: a.isStreaming,
|
|
55
|
+
activeToolCalls: a.activeToolCalls,
|
|
56
|
+
sessionId: a.sessionId,
|
|
57
|
+
error: a.error,
|
|
58
|
+
usage: a.usage,
|
|
59
|
+
reset: a.reset,
|
|
60
|
+
respondToConfirmation: a.respondToConfirmation
|
|
328
61
|
};
|
|
329
62
|
}
|
|
330
63
|
/**
|
|
@@ -332,34 +65,34 @@ function W(s) {
|
|
|
332
65
|
* Copyright 2025 Amodal Labs, Inc.
|
|
333
66
|
* SPDX-License-Identifier: MIT
|
|
334
67
|
*/
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
return /* @__PURE__ */
|
|
338
|
-
/* @__PURE__ */
|
|
339
|
-
/* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
68
|
+
function M({ confirmation: e, onApprove: o, onDeny: d }) {
|
|
69
|
+
const s = e.status === "pending";
|
|
70
|
+
return /* @__PURE__ */ C("div", { className: "amodal-confirm-card", "data-testid": "confirm-card", children: [
|
|
71
|
+
/* @__PURE__ */ C("div", { className: "amodal-confirm-card__header", children: [
|
|
72
|
+
/* @__PURE__ */ u("span", { className: "amodal-confirm-card__method", children: e.method }),
|
|
73
|
+
/* @__PURE__ */ u("span", { className: "amodal-confirm-card__endpoint", children: e.endpoint })
|
|
341
74
|
] }),
|
|
342
|
-
/* @__PURE__ */
|
|
343
|
-
|
|
344
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ u("p", { className: "amodal-confirm-card__reason", children: e.reason }),
|
|
76
|
+
s ? /* @__PURE__ */ C("div", { className: "amodal-confirm-card__actions", children: [
|
|
77
|
+
/* @__PURE__ */ u(
|
|
345
78
|
"button",
|
|
346
79
|
{
|
|
347
80
|
className: "amodal-confirm-card__btn amodal-confirm-card__btn--approve",
|
|
348
|
-
onClick:
|
|
81
|
+
onClick: o,
|
|
349
82
|
"data-testid": "confirm-approve",
|
|
350
83
|
children: "Approve"
|
|
351
84
|
}
|
|
352
85
|
),
|
|
353
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ u(
|
|
354
87
|
"button",
|
|
355
88
|
{
|
|
356
89
|
className: "amodal-confirm-card__btn amodal-confirm-card__btn--deny",
|
|
357
|
-
onClick:
|
|
90
|
+
onClick: d,
|
|
358
91
|
"data-testid": "confirm-deny",
|
|
359
92
|
children: "Deny"
|
|
360
93
|
}
|
|
361
94
|
)
|
|
362
|
-
] }) : /* @__PURE__ */
|
|
95
|
+
] }) : /* @__PURE__ */ u("div", { className: "amodal-confirm-card__status", "data-testid": "confirm-status", children: e.status === "approved" ? "Approved" : "Denied" })
|
|
363
96
|
] });
|
|
364
97
|
}
|
|
365
98
|
/**
|
|
@@ -367,119 +100,119 @@ function H({ confirmation: s, onApprove: r, onDeny: t }) {
|
|
|
367
100
|
* Copyright 2025 Amodal Labs, Inc.
|
|
368
101
|
* SPDX-License-Identifier: MIT
|
|
369
102
|
*/
|
|
370
|
-
function
|
|
371
|
-
const
|
|
372
|
-
return /* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
|
|
103
|
+
function $({ confirmation: e, onApprove: o, onDeny: d }) {
|
|
104
|
+
const s = e.status === "pending";
|
|
105
|
+
return /* @__PURE__ */ C("div", { className: "amodal-review-card", "data-testid": "review-card", children: [
|
|
106
|
+
/* @__PURE__ */ C("div", { className: "amodal-review-card__header", children: [
|
|
107
|
+
/* @__PURE__ */ u("span", { className: "amodal-review-card__method", children: e.method }),
|
|
108
|
+
/* @__PURE__ */ u("span", { className: "amodal-review-card__endpoint", children: e.endpoint }),
|
|
109
|
+
e.escalated && /* @__PURE__ */ u("span", { className: "amodal-review-card__badge", "data-testid": "escalation-badge", children: "Escalated" })
|
|
377
110
|
] }),
|
|
378
|
-
|
|
111
|
+
e.connectionName && /* @__PURE__ */ C("div", { className: "amodal-review-card__connection", children: [
|
|
379
112
|
"Connection: ",
|
|
380
|
-
|
|
113
|
+
e.connectionName
|
|
381
114
|
] }),
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ u("p", { className: "amodal-review-card__reason", children: e.reason }),
|
|
116
|
+
e.params && Object.keys(e.params).length > 0 && /* @__PURE__ */ C("div", { className: "amodal-review-card__params", "data-testid": "review-params", children: [
|
|
117
|
+
/* @__PURE__ */ u("div", { className: "amodal-review-card__params-title", children: "Parameters" }),
|
|
118
|
+
/* @__PURE__ */ u("pre", { className: "amodal-review-card__params-body", children: JSON.stringify(e.params, null, 2) })
|
|
386
119
|
] }),
|
|
387
|
-
|
|
388
|
-
/* @__PURE__ */
|
|
120
|
+
s ? /* @__PURE__ */ C("div", { className: "amodal-review-card__actions", children: [
|
|
121
|
+
/* @__PURE__ */ u(
|
|
389
122
|
"button",
|
|
390
123
|
{
|
|
391
124
|
className: "amodal-review-card__btn amodal-review-card__btn--approve",
|
|
392
|
-
onClick:
|
|
125
|
+
onClick: o,
|
|
393
126
|
"data-testid": "review-approve",
|
|
394
127
|
children: "Approve"
|
|
395
128
|
}
|
|
396
129
|
),
|
|
397
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ u(
|
|
398
131
|
"button",
|
|
399
132
|
{
|
|
400
133
|
className: "amodal-review-card__btn amodal-review-card__btn--deny",
|
|
401
|
-
onClick:
|
|
134
|
+
onClick: d,
|
|
402
135
|
"data-testid": "review-deny",
|
|
403
136
|
children: "Deny"
|
|
404
137
|
}
|
|
405
138
|
)
|
|
406
|
-
] }) : /* @__PURE__ */
|
|
139
|
+
] }) : /* @__PURE__ */ u("div", { className: "amodal-review-card__status", "data-testid": "review-status", children: e.status === "approved" ? "Approved" : "Denied" })
|
|
407
140
|
] });
|
|
408
141
|
}
|
|
409
|
-
function
|
|
410
|
-
placeholder:
|
|
411
|
-
renderText:
|
|
412
|
-
renderToolCall:
|
|
413
|
-
renderConfirmation:
|
|
414
|
-
className:
|
|
142
|
+
function G({
|
|
143
|
+
placeholder: e = "Type a message...",
|
|
144
|
+
renderText: o,
|
|
145
|
+
renderToolCall: d,
|
|
146
|
+
renderConfirmation: s,
|
|
147
|
+
className: m,
|
|
415
148
|
...a
|
|
416
149
|
}) {
|
|
417
|
-
const { messages:
|
|
418
|
-
(
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
150
|
+
const { messages: b, send: p, isStreaming: h, respondToConfirmation: y } = L(a), [v, f] = _(""), g = N(null), c = x(
|
|
151
|
+
(t) => {
|
|
152
|
+
t.preventDefault();
|
|
153
|
+
const n = v.trim();
|
|
154
|
+
n.length === 0 || h || (f(""), p(n));
|
|
422
155
|
},
|
|
423
|
-
[
|
|
424
|
-
),
|
|
425
|
-
return /* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */
|
|
427
|
-
|
|
428
|
-
switch (
|
|
156
|
+
[v, h, p]
|
|
157
|
+
), l = ["amodal-chat", m].filter(Boolean).join(" ");
|
|
158
|
+
return /* @__PURE__ */ C("div", { className: l, "data-testid": "amodal-chat", children: [
|
|
159
|
+
/* @__PURE__ */ C("div", { className: "amodal-chat__messages", "data-testid": "message-list", children: [
|
|
160
|
+
b.map((t) => {
|
|
161
|
+
switch (t.type) {
|
|
429
162
|
case "user":
|
|
430
|
-
return /* @__PURE__ */
|
|
163
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__message amodal-chat__message--user", "data-testid": "user-message", children: t.text }, t.id);
|
|
431
164
|
case "assistant_text":
|
|
432
|
-
return /* @__PURE__ */
|
|
433
|
-
switch (
|
|
165
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__message amodal-chat__message--assistant", "data-testid": "assistant-message", children: t.contentBlocks.map((n, i) => {
|
|
166
|
+
switch (n.type) {
|
|
434
167
|
case "text":
|
|
435
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__text", children: o ? o(n.text) : n.text }, `text-${String(i)}`);
|
|
436
169
|
case "tool_calls":
|
|
437
|
-
return /* @__PURE__ */
|
|
438
|
-
(
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
441
|
-
] },
|
|
442
|
-
) }, `tools-${String(
|
|
170
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__tool-calls", children: n.calls.map(
|
|
171
|
+
(r) => d ? /* @__PURE__ */ u("div", { children: d(r) }, r.toolId) : /* @__PURE__ */ C("div", { className: "amodal-chat__tool-call", "data-testid": "tool-call", children: [
|
|
172
|
+
/* @__PURE__ */ u("span", { className: "amodal-chat__tool-name", children: r.toolName }),
|
|
173
|
+
/* @__PURE__ */ u("span", { className: "amodal-chat__tool-status", children: r.status })
|
|
174
|
+
] }, r.toolId)
|
|
175
|
+
) }, `tools-${String(i)}`);
|
|
443
176
|
case "confirmation": {
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
},
|
|
447
|
-
|
|
177
|
+
const r = n.confirmation, w = () => {
|
|
178
|
+
r.correlationId && y(r.correlationId, !0);
|
|
179
|
+
}, S = () => {
|
|
180
|
+
r.correlationId && y(r.correlationId, !1);
|
|
448
181
|
};
|
|
449
|
-
return
|
|
182
|
+
return s ? /* @__PURE__ */ u("div", { children: s(r, w, S) }, `conf-${String(i)}`) : r.escalated || r.params && Object.keys(r.params).length > 0 ? /* @__PURE__ */ u($, { confirmation: r, onApprove: w, onDeny: S }, `conf-${String(i)}`) : /* @__PURE__ */ u(M, { confirmation: r, onApprove: w, onDeny: S }, `conf-${String(i)}`);
|
|
450
183
|
}
|
|
451
184
|
case "widget":
|
|
452
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__widget", "data-testid": "widget", children: n.widgetType }, `widget-${String(i)}`);
|
|
453
186
|
default:
|
|
454
187
|
return null;
|
|
455
188
|
}
|
|
456
|
-
}) },
|
|
189
|
+
}) }, t.id);
|
|
457
190
|
case "error":
|
|
458
|
-
return /* @__PURE__ */
|
|
191
|
+
return /* @__PURE__ */ u("div", { className: "amodal-chat__message amodal-chat__message--error", "data-testid": "error-message", children: t.message }, t.id);
|
|
459
192
|
default:
|
|
460
193
|
return null;
|
|
461
194
|
}
|
|
462
195
|
}),
|
|
463
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ u("div", { ref: g })
|
|
464
197
|
] }),
|
|
465
|
-
/* @__PURE__ */
|
|
466
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ C("form", { className: "amodal-chat__input-bar", onSubmit: c, "data-testid": "input-bar", children: [
|
|
199
|
+
/* @__PURE__ */ u(
|
|
467
200
|
"input",
|
|
468
201
|
{
|
|
469
202
|
className: "amodal-chat__input",
|
|
470
|
-
value:
|
|
471
|
-
onChange: (
|
|
472
|
-
placeholder:
|
|
473
|
-
disabled:
|
|
203
|
+
value: v,
|
|
204
|
+
onChange: (t) => f(t.target.value),
|
|
205
|
+
placeholder: e,
|
|
206
|
+
disabled: h,
|
|
474
207
|
"data-testid": "chat-input"
|
|
475
208
|
}
|
|
476
209
|
),
|
|
477
|
-
/* @__PURE__ */
|
|
210
|
+
/* @__PURE__ */ u(
|
|
478
211
|
"button",
|
|
479
212
|
{
|
|
480
213
|
className: "amodal-chat__send",
|
|
481
214
|
type: "submit",
|
|
482
|
-
disabled:
|
|
215
|
+
disabled: h || v.trim().length === 0,
|
|
483
216
|
"data-testid": "send-button",
|
|
484
217
|
children: "Send"
|
|
485
218
|
}
|
|
@@ -487,50 +220,50 @@ function ee({
|
|
|
487
220
|
] })
|
|
488
221
|
] });
|
|
489
222
|
}
|
|
490
|
-
function
|
|
491
|
-
const [a,
|
|
492
|
-
context:
|
|
223
|
+
function K({ prompt: e, label: o, context: d, onComplete: s, onError: m }) {
|
|
224
|
+
const [a, b] = _(!1), { messages: p, send: h, isStreaming: y, respondToConfirmation: v } = L({
|
|
225
|
+
context: d,
|
|
493
226
|
onStreamEnd: () => {
|
|
494
|
-
const
|
|
495
|
-
|
|
227
|
+
const t = p[p.length - 1];
|
|
228
|
+
t && t.type === "assistant_text" ? s == null || s(t.text) : t && t.type === "error" && (m == null || m(t.message));
|
|
496
229
|
}
|
|
497
|
-
}),
|
|
498
|
-
a ||
|
|
499
|
-
}, [a,
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
},
|
|
503
|
-
|
|
230
|
+
}), f = x(() => {
|
|
231
|
+
a || y || (b(!0), h(e));
|
|
232
|
+
}, [a, y, h, e]), g = [...p].reverse().find((t) => t.type === "assistant_text"), c = g && g.type === "assistant_text" ? g.confirmations.filter((t) => t.status === "pending") : [], l = (t, n) => {
|
|
233
|
+
const i = () => {
|
|
234
|
+
t.correlationId && v(t.correlationId, !0);
|
|
235
|
+
}, r = () => {
|
|
236
|
+
t.correlationId && v(t.correlationId, !1);
|
|
504
237
|
};
|
|
505
|
-
return
|
|
506
|
-
|
|
238
|
+
return t.escalated || t.params && Object.keys(t.params).length > 0 ? /* @__PURE__ */ u(
|
|
239
|
+
$,
|
|
507
240
|
{
|
|
508
|
-
confirmation:
|
|
509
|
-
onApprove:
|
|
510
|
-
onDeny:
|
|
241
|
+
confirmation: t,
|
|
242
|
+
onApprove: i,
|
|
243
|
+
onDeny: r
|
|
511
244
|
},
|
|
512
|
-
|
|
513
|
-
) : /* @__PURE__ */
|
|
514
|
-
|
|
245
|
+
t.correlationId ?? String(n)
|
|
246
|
+
) : /* @__PURE__ */ u(
|
|
247
|
+
M,
|
|
515
248
|
{
|
|
516
|
-
confirmation:
|
|
517
|
-
onApprove:
|
|
518
|
-
onDeny:
|
|
249
|
+
confirmation: t,
|
|
250
|
+
onApprove: i,
|
|
251
|
+
onDeny: r
|
|
519
252
|
},
|
|
520
|
-
|
|
253
|
+
t.correlationId ?? String(n)
|
|
521
254
|
);
|
|
522
255
|
};
|
|
523
|
-
return a ? /* @__PURE__ */
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
] }) : /* @__PURE__ */
|
|
256
|
+
return a ? /* @__PURE__ */ C("div", { className: "amodal-action", "data-testid": "action-container", children: [
|
|
257
|
+
y && /* @__PURE__ */ u("div", { className: "amodal-action__loading", "data-testid": "action-loading", children: "Processing..." }),
|
|
258
|
+
g && g.type === "assistant_text" && g.text && /* @__PURE__ */ u("div", { className: "amodal-action__result", "data-testid": "action-result", children: g.text }),
|
|
259
|
+
c.map(l)
|
|
260
|
+
] }) : /* @__PURE__ */ u(
|
|
528
261
|
"button",
|
|
529
262
|
{
|
|
530
263
|
className: "amodal-action__trigger",
|
|
531
|
-
onClick:
|
|
264
|
+
onClick: f,
|
|
532
265
|
"data-testid": "action-trigger",
|
|
533
|
-
children:
|
|
266
|
+
children: o ?? "Run"
|
|
534
267
|
}
|
|
535
268
|
);
|
|
536
269
|
}
|
|
@@ -539,115 +272,115 @@ function te({ prompt: s, label: r, context: t, onComplete: e, onError: n }) {
|
|
|
539
272
|
* Copyright 2025 Amodal Labs, Inc.
|
|
540
273
|
* SPDX-License-Identifier: MIT
|
|
541
274
|
*/
|
|
542
|
-
function
|
|
543
|
-
const { prompt:
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
|
|
275
|
+
function U(e) {
|
|
276
|
+
const { prompt: o, context: d, autoFetch: s = !0 } = e, { client: m } = k(), [a, b] = _(null), [p, h] = _(!1), [y, v] = _(null), f = N(null), g = N(!1), c = x(async () => {
|
|
277
|
+
f.current && f.current.abort();
|
|
278
|
+
const t = new AbortController();
|
|
279
|
+
f.current = t, h(!0), v(null);
|
|
547
280
|
try {
|
|
548
|
-
let
|
|
549
|
-
const
|
|
550
|
-
for await (const
|
|
551
|
-
switch (
|
|
281
|
+
let n = "";
|
|
282
|
+
const i = [];
|
|
283
|
+
for await (const r of m.chatStream(o, { context: d, signal: t.signal }))
|
|
284
|
+
switch (r.type) {
|
|
552
285
|
case "text_delta":
|
|
553
|
-
|
|
286
|
+
n += r.content;
|
|
554
287
|
break;
|
|
555
288
|
case "tool_call_start":
|
|
556
|
-
|
|
557
|
-
toolId:
|
|
558
|
-
toolName:
|
|
559
|
-
parameters:
|
|
289
|
+
i.push({
|
|
290
|
+
toolId: r.tool_id,
|
|
291
|
+
toolName: r.tool_name,
|
|
292
|
+
parameters: r.parameters,
|
|
560
293
|
status: "running"
|
|
561
294
|
});
|
|
562
295
|
break;
|
|
563
296
|
case "tool_call_result": {
|
|
564
|
-
const
|
|
565
|
-
|
|
297
|
+
const w = i.find((S) => S.toolId === r.tool_id);
|
|
298
|
+
w && (w.status = r.status, w.result = r.result, w.duration_ms = r.duration_ms, w.error = r.error);
|
|
566
299
|
break;
|
|
567
300
|
}
|
|
568
301
|
case "error":
|
|
569
|
-
|
|
302
|
+
v(r.message);
|
|
570
303
|
break;
|
|
571
304
|
default:
|
|
572
305
|
break;
|
|
573
306
|
}
|
|
574
|
-
|
|
575
|
-
} catch (
|
|
576
|
-
|
|
307
|
+
b({ text: n, toolCalls: i });
|
|
308
|
+
} catch (n) {
|
|
309
|
+
n instanceof DOMException && n.name === "AbortError" || v(n instanceof Error ? n.message : "Unknown error");
|
|
577
310
|
} finally {
|
|
578
|
-
|
|
311
|
+
h(!1), f.current = null;
|
|
579
312
|
}
|
|
580
|
-
}, [
|
|
581
|
-
|
|
582
|
-
}, [
|
|
583
|
-
return
|
|
584
|
-
|
|
585
|
-
}), [
|
|
313
|
+
}, [m, o, d]), l = x(() => {
|
|
314
|
+
c();
|
|
315
|
+
}, [c]);
|
|
316
|
+
return I(() => (s && !g.current && (g.current = !0, c()), () => {
|
|
317
|
+
f.current && f.current.abort();
|
|
318
|
+
}), [s, c]), { brief: a, isLoading: p, error: y, refresh: l };
|
|
586
319
|
}
|
|
587
320
|
/**
|
|
588
321
|
* @license
|
|
589
322
|
* Copyright 2025 Amodal Labs, Inc.
|
|
590
323
|
* SPDX-License-Identifier: MIT
|
|
591
324
|
*/
|
|
592
|
-
function
|
|
593
|
-
const { prompt:
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
|
|
325
|
+
function q(e) {
|
|
326
|
+
const { prompt: o, context: d, autoFetch: s = !0 } = e, { client: m } = k(), [a, b] = _("idle"), [p, h] = _(""), [y, v] = _(""), [f, g] = _(null), c = N(null), l = N(!1), t = x(async () => {
|
|
327
|
+
c.current && c.current.abort();
|
|
328
|
+
const i = new AbortController();
|
|
329
|
+
c.current = i, b("loading"), g(null), h(""), v("");
|
|
597
330
|
try {
|
|
598
|
-
let
|
|
599
|
-
for await (const
|
|
600
|
-
switch (
|
|
331
|
+
let r = "";
|
|
332
|
+
for await (const S of m.chatStream(o, { context: d, signal: i.signal }))
|
|
333
|
+
switch (S.type) {
|
|
601
334
|
case "text_delta":
|
|
602
|
-
|
|
335
|
+
r += S.content;
|
|
603
336
|
break;
|
|
604
337
|
case "error":
|
|
605
|
-
|
|
338
|
+
g(S.message), b("error");
|
|
606
339
|
return;
|
|
607
340
|
default:
|
|
608
341
|
break;
|
|
609
342
|
}
|
|
610
|
-
const
|
|
343
|
+
const w = r.indexOf(`
|
|
611
344
|
|
|
612
345
|
`);
|
|
613
|
-
|
|
614
|
-
} catch (
|
|
615
|
-
|
|
346
|
+
w >= 0 ? (h(r.slice(0, w).trim()), v(r.slice(w + 2).trim())) : h(r.trim()), b("done");
|
|
347
|
+
} catch (r) {
|
|
348
|
+
r instanceof DOMException && r.name === "AbortError" || (g(r instanceof Error ? r.message : "Unknown error"), b("error"));
|
|
616
349
|
} finally {
|
|
617
|
-
|
|
350
|
+
c.current = null;
|
|
618
351
|
}
|
|
619
|
-
}, [
|
|
620
|
-
|
|
621
|
-
}, [
|
|
622
|
-
return
|
|
623
|
-
|
|
624
|
-
}), [
|
|
352
|
+
}, [m, o, d]), n = x(() => {
|
|
353
|
+
t();
|
|
354
|
+
}, [t]);
|
|
355
|
+
return I(() => (s && !l.current && (l.current = !0, t()), () => {
|
|
356
|
+
c.current && c.current.abort();
|
|
357
|
+
}), [s, t]), { status: a, summary: p, details: y, isLoading: a === "loading", error: f, refresh: n };
|
|
625
358
|
}
|
|
626
359
|
/**
|
|
627
360
|
* @license
|
|
628
361
|
* Copyright 2025 Amodal Labs, Inc.
|
|
629
362
|
* SPDX-License-Identifier: MIT
|
|
630
363
|
*/
|
|
631
|
-
function
|
|
632
|
-
const { taskId:
|
|
633
|
-
|
|
634
|
-
const
|
|
635
|
-
|
|
364
|
+
function z(e) {
|
|
365
|
+
const { taskId: o, autoStream: d = !0 } = e, { client: s } = k(), [m, a] = _("idle"), [b, p] = _(""), [h, y] = _(""), [v, f] = _([]), [g, c] = _(null), l = N(null), t = N(!1), n = x(async () => {
|
|
366
|
+
l.current && l.current.abort();
|
|
367
|
+
const w = new AbortController();
|
|
368
|
+
l.current = w, a("running"), c(null), f([]), y(""), p("");
|
|
636
369
|
try {
|
|
637
|
-
let
|
|
638
|
-
for await (const
|
|
639
|
-
switch (
|
|
370
|
+
let S = "";
|
|
371
|
+
for await (const E of s.streamTask(o, w.signal))
|
|
372
|
+
switch (f((A) => [...A, E]), E.type) {
|
|
640
373
|
case "text_delta":
|
|
641
|
-
|
|
374
|
+
S += E.content, y(S);
|
|
642
375
|
break;
|
|
643
376
|
case "tool_call_start":
|
|
644
|
-
|
|
377
|
+
p(`Running ${E.tool_name}...`);
|
|
645
378
|
break;
|
|
646
379
|
case "tool_call_result":
|
|
647
|
-
|
|
380
|
+
p("");
|
|
648
381
|
break;
|
|
649
382
|
case "error":
|
|
650
|
-
|
|
383
|
+
c(E.message), a("error");
|
|
651
384
|
return;
|
|
652
385
|
case "done":
|
|
653
386
|
a("completed");
|
|
@@ -655,25 +388,25 @@ function ae(s) {
|
|
|
655
388
|
default:
|
|
656
389
|
break;
|
|
657
390
|
}
|
|
658
|
-
|
|
659
|
-
} catch (
|
|
660
|
-
|
|
391
|
+
m === "running" && a("completed");
|
|
392
|
+
} catch (S) {
|
|
393
|
+
S instanceof DOMException && S.name === "AbortError" || (c(S instanceof Error ? S.message : "Unknown error"), a("error"));
|
|
661
394
|
} finally {
|
|
662
|
-
|
|
395
|
+
l.current = null;
|
|
663
396
|
}
|
|
664
|
-
}, [
|
|
665
|
-
|
|
666
|
-
}, []),
|
|
667
|
-
return
|
|
668
|
-
|
|
669
|
-
}), [
|
|
670
|
-
status:
|
|
671
|
-
progress:
|
|
672
|
-
result:
|
|
673
|
-
events:
|
|
674
|
-
error:
|
|
675
|
-
start: () => void
|
|
676
|
-
stop:
|
|
397
|
+
}, [s, o, m]), i = x(() => {
|
|
398
|
+
l.current && (l.current.abort(), l.current = null);
|
|
399
|
+
}, []), r = N(n);
|
|
400
|
+
return r.current = n, I(() => (d && !t.current && (t.current = !0, r.current()), () => {
|
|
401
|
+
l.current && l.current.abort();
|
|
402
|
+
}), [d]), {
|
|
403
|
+
status: m,
|
|
404
|
+
progress: b,
|
|
405
|
+
result: h,
|
|
406
|
+
events: v,
|
|
407
|
+
error: g,
|
|
408
|
+
start: () => void n(),
|
|
409
|
+
stop: i
|
|
677
410
|
};
|
|
678
411
|
}
|
|
679
412
|
/**
|
|
@@ -681,74 +414,74 @@ function ae(s) {
|
|
|
681
414
|
* Copyright 2025 Amodal Labs, Inc.
|
|
682
415
|
* SPDX-License-Identifier: MIT
|
|
683
416
|
*/
|
|
684
|
-
function
|
|
685
|
-
const { prompt:
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
417
|
+
function V(e) {
|
|
418
|
+
const { prompt: o, context: d, autoFetch: s = !0 } = e, { client: m } = k(), [a, b] = _(null), [p, h] = _(!1), [y, v] = _(null), f = N(null), g = N(!1), c = x(async () => {
|
|
419
|
+
f.current && f.current.abort();
|
|
420
|
+
const t = new AbortController();
|
|
421
|
+
f.current = t, h(!0), v(null);
|
|
689
422
|
try {
|
|
690
|
-
let
|
|
691
|
-
for await (const
|
|
692
|
-
switch (
|
|
423
|
+
let n = "";
|
|
424
|
+
for await (const i of m.chatStream(o, { context: d, signal: t.signal }))
|
|
425
|
+
switch (i.type) {
|
|
693
426
|
case "text_delta":
|
|
694
|
-
|
|
427
|
+
n += i.content;
|
|
695
428
|
break;
|
|
696
429
|
case "error":
|
|
697
|
-
|
|
430
|
+
v(i.message);
|
|
698
431
|
break;
|
|
699
432
|
default:
|
|
700
433
|
break;
|
|
701
434
|
}
|
|
702
|
-
|
|
703
|
-
} catch (
|
|
704
|
-
|
|
435
|
+
b(n);
|
|
436
|
+
} catch (n) {
|
|
437
|
+
n instanceof DOMException && n.name === "AbortError" || v(n instanceof Error ? n.message : "Unknown error");
|
|
705
438
|
} finally {
|
|
706
|
-
|
|
439
|
+
h(!1), f.current = null;
|
|
707
440
|
}
|
|
708
|
-
}, [
|
|
709
|
-
|
|
710
|
-
}, [
|
|
711
|
-
return
|
|
712
|
-
|
|
713
|
-
}), [
|
|
441
|
+
}, [m, o, d]), l = x(() => {
|
|
442
|
+
c();
|
|
443
|
+
}, [c]);
|
|
444
|
+
return I(() => (s && !g.current && (g.current = !0, c()), () => {
|
|
445
|
+
f.current && f.current.abort();
|
|
446
|
+
}), [s, c]), { data: a, isLoading: p, error: y, refetch: l };
|
|
714
447
|
}
|
|
715
448
|
/**
|
|
716
449
|
* @license
|
|
717
450
|
* Copyright 2025 Amodal Labs, Inc.
|
|
718
451
|
* SPDX-License-Identifier: MIT
|
|
719
452
|
*/
|
|
720
|
-
function
|
|
721
|
-
const { key:
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
|
|
453
|
+
function X(e, o) {
|
|
454
|
+
const { key: d, refreshInterval: s = 3e4 } = o, { client: m } = k(), [a, b] = _(null), [p, h] = _([]), [y, v] = _(!0), [f, g] = _(null), c = N(null), l = x(async () => {
|
|
455
|
+
c.current && c.current.abort();
|
|
456
|
+
const n = new AbortController();
|
|
457
|
+
c.current = n;
|
|
725
458
|
try {
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
} catch (
|
|
729
|
-
|
|
459
|
+
const i = await m.getStoreDocument(e, d, n.signal);
|
|
460
|
+
b(i.document), h(i.history), g(null);
|
|
461
|
+
} catch (i) {
|
|
462
|
+
i instanceof DOMException && i.name === "AbortError" || g(i instanceof Error ? i.message : "Failed to fetch document");
|
|
730
463
|
} finally {
|
|
731
|
-
|
|
464
|
+
v(!1), c.current = null;
|
|
732
465
|
}
|
|
733
|
-
}, [
|
|
734
|
-
|
|
735
|
-
}, [
|
|
736
|
-
return
|
|
737
|
-
|
|
738
|
-
}), [
|
|
739
|
-
if (
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
},
|
|
743
|
-
return () => clearInterval(
|
|
744
|
-
}, [
|
|
466
|
+
}, [m, e, d]), t = x(() => {
|
|
467
|
+
l();
|
|
468
|
+
}, [l]);
|
|
469
|
+
return I(() => (v(!0), l(), () => {
|
|
470
|
+
c.current && c.current.abort();
|
|
471
|
+
}), [l]), I(() => {
|
|
472
|
+
if (s <= 0) return;
|
|
473
|
+
const n = setInterval(() => {
|
|
474
|
+
l();
|
|
475
|
+
}, s);
|
|
476
|
+
return () => clearInterval(n);
|
|
477
|
+
}, [l, s]), {
|
|
745
478
|
data: (a == null ? void 0 : a.payload) ?? null,
|
|
746
479
|
meta: (a == null ? void 0 : a.meta) ?? null,
|
|
747
480
|
document: a,
|
|
748
|
-
history:
|
|
749
|
-
isLoading:
|
|
750
|
-
error:
|
|
751
|
-
refetch:
|
|
481
|
+
history: p,
|
|
482
|
+
isLoading: y,
|
|
483
|
+
error: f,
|
|
484
|
+
refetch: t
|
|
752
485
|
};
|
|
753
486
|
}
|
|
754
487
|
/**
|
|
@@ -756,43 +489,43 @@ function oe(s, r) {
|
|
|
756
489
|
* Copyright 2025 Amodal Labs, Inc.
|
|
757
490
|
* SPDX-License-Identifier: MIT
|
|
758
491
|
*/
|
|
759
|
-
function
|
|
760
|
-
const { filter:
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
|
|
492
|
+
function Y(e, o = {}) {
|
|
493
|
+
const { filter: d, sort: s, limit: m = 20, refreshInterval: a = 3e4 } = o, { client: b } = k(), [p, h] = _([]), [y, v] = _(0), [f, g] = _(!1), [c, l] = _(!0), [t, n] = _(null), i = N(null), r = d ? JSON.stringify(d) : "", w = x(async () => {
|
|
494
|
+
i.current && i.current.abort();
|
|
495
|
+
const E = new AbortController();
|
|
496
|
+
i.current = E;
|
|
764
497
|
try {
|
|
765
|
-
const
|
|
766
|
-
filter:
|
|
767
|
-
sort:
|
|
768
|
-
limit:
|
|
769
|
-
signal:
|
|
498
|
+
const A = await b.getStoreDocuments(e, {
|
|
499
|
+
filter: r ? JSON.parse(r) : void 0,
|
|
500
|
+
sort: s,
|
|
501
|
+
limit: m,
|
|
502
|
+
signal: E.signal
|
|
770
503
|
});
|
|
771
|
-
|
|
772
|
-
} catch (
|
|
773
|
-
|
|
504
|
+
h(A.documents), v(A.total), g(A.hasMore), n(null);
|
|
505
|
+
} catch (A) {
|
|
506
|
+
A instanceof DOMException && A.name === "AbortError" || n(A instanceof Error ? A.message : "Failed to fetch store list");
|
|
774
507
|
} finally {
|
|
775
|
-
|
|
508
|
+
l(!1), i.current = null;
|
|
776
509
|
}
|
|
777
|
-
}, [
|
|
778
|
-
|
|
779
|
-
}, [
|
|
780
|
-
return
|
|
781
|
-
|
|
782
|
-
}), [
|
|
510
|
+
}, [b, e, r, s, m]), S = x(() => {
|
|
511
|
+
w();
|
|
512
|
+
}, [w]);
|
|
513
|
+
return I(() => (l(!0), w(), () => {
|
|
514
|
+
i.current && i.current.abort();
|
|
515
|
+
}), [w]), I(() => {
|
|
783
516
|
if (a <= 0) return;
|
|
784
|
-
const
|
|
785
|
-
|
|
517
|
+
const E = setInterval(() => {
|
|
518
|
+
w();
|
|
786
519
|
}, a);
|
|
787
|
-
return () => clearInterval(
|
|
788
|
-
}, [
|
|
789
|
-
data:
|
|
790
|
-
documents:
|
|
791
|
-
total:
|
|
792
|
-
hasMore:
|
|
793
|
-
isLoading:
|
|
794
|
-
error:
|
|
795
|
-
refetch:
|
|
520
|
+
return () => clearInterval(E);
|
|
521
|
+
}, [w, a]), {
|
|
522
|
+
data: p.map((E) => E.payload),
|
|
523
|
+
documents: p,
|
|
524
|
+
total: y,
|
|
525
|
+
hasMore: f,
|
|
526
|
+
isLoading: c,
|
|
527
|
+
error: t,
|
|
528
|
+
refetch: S
|
|
796
529
|
};
|
|
797
530
|
}
|
|
798
531
|
/**
|
|
@@ -800,87 +533,89 @@ function le(s, r = {}) {
|
|
|
800
533
|
* Copyright 2025 Amodal Labs, Inc.
|
|
801
534
|
* SPDX-License-Identifier: MIT
|
|
802
535
|
*/
|
|
803
|
-
function
|
|
804
|
-
const { client:
|
|
805
|
-
return { execute:
|
|
806
|
-
(
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
let
|
|
811
|
-
|
|
536
|
+
function Z(e, o = {}) {
|
|
537
|
+
const { client: d } = k(), [s, m] = _(!1), [a, b] = _(null), [p, h] = _(null), y = N(null);
|
|
538
|
+
return { execute: x(
|
|
539
|
+
(f) => {
|
|
540
|
+
y.current && y.current.abort();
|
|
541
|
+
const g = new AbortController();
|
|
542
|
+
y.current = g, m(!0), b(null), h(null);
|
|
543
|
+
let c = `Run skill "${e}"`;
|
|
544
|
+
f && Object.keys(f).length > 0 && (c += ` with parameters: ${JSON.stringify(f)}`), o.stores && o.stores.length > 0 && (c += `. Write results to stores: ${o.stores.join(", ")}`), o.confirm && (c += ". Confirm before writing."), (async () => {
|
|
812
545
|
try {
|
|
813
|
-
let
|
|
814
|
-
for await (const
|
|
815
|
-
switch (
|
|
546
|
+
let l = "";
|
|
547
|
+
for await (const t of d.chatStream(c, { signal: g.signal }))
|
|
548
|
+
switch (t.type) {
|
|
816
549
|
case "text_delta":
|
|
817
|
-
|
|
550
|
+
l += t.content;
|
|
818
551
|
break;
|
|
819
552
|
case "error":
|
|
820
|
-
|
|
553
|
+
h(t.message);
|
|
821
554
|
break;
|
|
822
555
|
default:
|
|
823
556
|
break;
|
|
824
557
|
}
|
|
825
|
-
|
|
826
|
-
} catch (
|
|
827
|
-
|
|
558
|
+
b(l);
|
|
559
|
+
} catch (l) {
|
|
560
|
+
l instanceof DOMException && l.name === "AbortError" || h(l instanceof Error ? l.message : "Skill execution failed");
|
|
828
561
|
} finally {
|
|
829
|
-
|
|
562
|
+
m(!1), y.current = null;
|
|
830
563
|
}
|
|
831
564
|
})();
|
|
832
565
|
},
|
|
833
|
-
[
|
|
834
|
-
), loading:
|
|
566
|
+
[d, e, o.stores, o.confirm]
|
|
567
|
+
), loading: s, result: a, error: p };
|
|
835
568
|
}
|
|
836
569
|
/**
|
|
837
570
|
* @license
|
|
838
571
|
* Copyright 2025 Amodal Labs, Inc.
|
|
839
572
|
* SPDX-License-Identifier: MIT
|
|
840
573
|
*/
|
|
841
|
-
const
|
|
842
|
-
function
|
|
843
|
-
const
|
|
574
|
+
const F = R(null);
|
|
575
|
+
function ee() {
|
|
576
|
+
const e = T(F), o = x((d, s) => {
|
|
844
577
|
}, []);
|
|
845
|
-
return
|
|
578
|
+
return e ?? o;
|
|
846
579
|
}
|
|
847
580
|
export {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
581
|
+
K as AmodalAction,
|
|
582
|
+
G as AmodalChat,
|
|
583
|
+
Q as AmodalProvider,
|
|
584
|
+
ae as ChatClient,
|
|
585
|
+
ne as ChatStream,
|
|
586
|
+
M as ConfirmCard,
|
|
587
|
+
F as NavigateContext,
|
|
588
|
+
$ as ReviewCard,
|
|
589
|
+
j as RuntimeClient,
|
|
590
|
+
he as TypedEventEmitter,
|
|
591
|
+
ge as WidgetEventBus,
|
|
592
|
+
oe as applyTheme,
|
|
593
|
+
ce as chatReducer,
|
|
594
|
+
_e as createChatClient,
|
|
595
|
+
ve as createSession,
|
|
596
|
+
pe as defaultEntityExtractor,
|
|
597
|
+
le as defaultTheme,
|
|
598
|
+
be as getSessionHistory,
|
|
599
|
+
ye as listSessions,
|
|
600
|
+
ie as mergeTheme,
|
|
867
601
|
we as parseSSELine,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
602
|
+
Se as streamChat,
|
|
603
|
+
xe as streamSSE,
|
|
604
|
+
Ne as streamSSEGet,
|
|
605
|
+
Ce as updateSession,
|
|
606
|
+
U as useAmodalBrief,
|
|
607
|
+
L as useAmodalChat,
|
|
608
|
+
k as useAmodalContext,
|
|
609
|
+
q as useAmodalInsight,
|
|
610
|
+
V as useAmodalQuery,
|
|
611
|
+
z as useAmodalTask,
|
|
612
|
+
de as useChat,
|
|
613
|
+
P as useChatStream,
|
|
614
|
+
ee as useNavigate,
|
|
615
|
+
ue as useSessionHistory,
|
|
616
|
+
Z as useSkillAction,
|
|
617
|
+
X as useStore,
|
|
618
|
+
Y as useStoreList,
|
|
619
|
+
me as useWidgetEvents
|
|
885
620
|
};
|
|
886
621
|
//# sourceMappingURL=react.js.map
|