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