@arbor-education/agent-view-frontend 0.4.6 → 0.4.7
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/index.cjs +3 -3
- package/dist/index.d.ts +40 -12
- package/dist/index.js +1531 -1408
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import { Heading as
|
|
5
|
-
import { CHAT_RESPONSE_TYPE_AGENT as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as l, jsx as a, Fragment as ce } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as fe, useState as _, useLayoutEffect as We, useEffect as F, useMemo as W, useCallback as E } from "react";
|
|
3
|
+
import Y from "classnames";
|
|
4
|
+
import { Heading as ve, Icon as O, Dot as St, SlideoverUtils as Be, SlideoverManager as jt, Modal as se, Button as Z, Tabs as nt, SelectDropdown as Xt, TextInput as Qt, Combobox as ut, Card as Zt } from "@arbor-education/design-system.components";
|
|
5
|
+
import { CHAT_RESPONSE_TYPE_AGENT as Ct, CHAT_RESPONSE_TYPE_ERROR as en, ChatPanel as tn, CHAT_RESPONSE_TYPE_USER as nn, CHAT_RESPONSE_TYPE_INFO as an } from "@arbor-education/ask-arbor-chat-panel";
|
|
6
|
+
const C = {
|
|
7
7
|
"generating-a-response": "generating-a-response",
|
|
8
8
|
hitl: "hitl",
|
|
9
9
|
complete: "complete",
|
|
10
10
|
failed: "failed"
|
|
11
|
-
},
|
|
11
|
+
}, G = {
|
|
12
12
|
"generating-a-response": "generating-a-response",
|
|
13
13
|
hitl: "hitl",
|
|
14
14
|
complete: "complete",
|
|
15
15
|
failed: "failed"
|
|
16
|
-
},
|
|
16
|
+
}, H = {
|
|
17
17
|
briefing: "briefing",
|
|
18
18
|
running: "running",
|
|
19
19
|
stopped: "stopped",
|
|
20
20
|
complete: "complete"
|
|
21
|
-
},
|
|
21
|
+
}, te = {
|
|
22
22
|
agent: "agent",
|
|
23
23
|
user: "user",
|
|
24
24
|
system: "system"
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
}, de = {
|
|
26
|
+
document_html: "document_html",
|
|
27
|
+
mis_record: "mis_record",
|
|
28
|
+
workflow: "workflow",
|
|
29
|
+
file: "file",
|
|
30
|
+
link: "link"
|
|
31
|
+
}, pt = {
|
|
31
32
|
cancelled: "cancelled",
|
|
32
33
|
archived: "archived"
|
|
33
|
-
},
|
|
34
|
+
}, at = {
|
|
34
35
|
in_progress: "in_progress",
|
|
35
36
|
requires_attention: "requires_attention",
|
|
36
37
|
available: "available"
|
|
37
38
|
}, Q = {
|
|
38
|
-
[
|
|
39
|
+
[G.complete]: {
|
|
39
40
|
label: "Complete",
|
|
40
41
|
icon: "circle-check",
|
|
41
42
|
color: "var(--color-semantic-success-600)"
|
|
42
43
|
},
|
|
43
|
-
[
|
|
44
|
+
[G.failed]: {
|
|
44
45
|
label: "Failed",
|
|
45
46
|
icon: "circle-x",
|
|
46
47
|
color: "var(--color-semantic-destructive-600)"
|
|
47
48
|
},
|
|
48
|
-
[
|
|
49
|
+
[G.hitl]: {
|
|
49
50
|
label: "Requires attention",
|
|
50
51
|
icon: "triangle-alert",
|
|
51
52
|
color: "var(--color-semantic-warning-600)"
|
|
52
53
|
},
|
|
53
|
-
[
|
|
54
|
+
[G["generating-a-response"]]: {
|
|
54
55
|
label: "Generating a response",
|
|
55
56
|
icon: "sparkles",
|
|
56
57
|
color: "var(--color-brand-600)"
|
|
57
58
|
}
|
|
58
|
-
},
|
|
59
|
-
[
|
|
60
|
-
status:
|
|
59
|
+
}, Ke = {
|
|
60
|
+
[C["generating-a-response"]]: {
|
|
61
|
+
status: C["generating-a-response"],
|
|
61
62
|
title: "Active",
|
|
62
63
|
dotColour: "green",
|
|
63
64
|
statusIcon: {
|
|
@@ -65,8 +66,8 @@ const T = {
|
|
|
65
66
|
color: Q["generating-a-response"].color
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
|
-
[
|
|
69
|
-
status:
|
|
69
|
+
[C.hitl]: {
|
|
70
|
+
status: C.hitl,
|
|
70
71
|
title: "Requires attention",
|
|
71
72
|
dotColour: "orange",
|
|
72
73
|
statusIcon: {
|
|
@@ -74,8 +75,8 @@ const T = {
|
|
|
74
75
|
color: Q.hitl.color
|
|
75
76
|
}
|
|
76
77
|
},
|
|
77
|
-
[
|
|
78
|
-
status:
|
|
78
|
+
[C.complete]: {
|
|
79
|
+
status: C.complete,
|
|
79
80
|
title: "Complete",
|
|
80
81
|
dotColour: "green",
|
|
81
82
|
dotModifier: "grey-dark",
|
|
@@ -84,8 +85,8 @@ const T = {
|
|
|
84
85
|
color: Q.complete.color
|
|
85
86
|
}
|
|
86
87
|
},
|
|
87
|
-
[
|
|
88
|
-
status:
|
|
88
|
+
[C.failed]: {
|
|
89
|
+
status: C.failed,
|
|
89
90
|
title: "Failed",
|
|
90
91
|
dotColour: "salmon",
|
|
91
92
|
statusIcon: {
|
|
@@ -93,28 +94,28 @@ const T = {
|
|
|
93
94
|
color: Q.failed.color
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
],
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
],
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
106
|
-
[
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
},
|
|
97
|
+
}, sn = [
|
|
98
|
+
C["generating-a-response"],
|
|
99
|
+
C.hitl
|
|
100
|
+
], rn = [
|
|
101
|
+
C.complete,
|
|
102
|
+
C.failed
|
|
103
|
+
], on = "m4", ln = "1", Tt = "msg-opening", qe = "Unable to load agent tasks. Please try again.", cn = "Unable to load the resources for this agent", dn = "Unable to load this document. Please try again.", Et = "Unable to load the timeline for this agent", gn = "Something went wrong. Please try again.", Rt = "Unable to load agents. Please try again.", _e = "Loading tasks…", mt = "Loading agents…", hn = "Task", un = {
|
|
104
|
+
[H.briefing]: "Briefing",
|
|
105
|
+
[H.running]: "Working",
|
|
106
|
+
[H.stopped]: "Stopped",
|
|
107
|
+
[H.complete]: "Complete"
|
|
108
|
+
}, pn = [
|
|
109
|
+
C["generating-a-response"],
|
|
110
|
+
C.hitl,
|
|
111
|
+
C.complete,
|
|
112
|
+
C.failed
|
|
113
|
+
], mn = {
|
|
114
|
+
[C["generating-a-response"]]: "Agents currently working on tasks for you.",
|
|
115
|
+
[C.hitl]: "Agents that need your input before they can continue.",
|
|
116
|
+
[C.complete]: "Agents that have finished their work.",
|
|
117
|
+
[C.failed]: "Agents that failed or were stopped."
|
|
118
|
+
}, _n = () => /* @__PURE__ */ l(
|
|
118
119
|
"svg",
|
|
119
120
|
{
|
|
120
121
|
className: "agent-view__empty-illustration",
|
|
@@ -123,7 +124,7 @@ const T = {
|
|
|
123
124
|
role: "img",
|
|
124
125
|
"aria-label": "Preview of the agents board layout",
|
|
125
126
|
children: [
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ a(
|
|
127
128
|
"rect",
|
|
128
129
|
{
|
|
129
130
|
x: "0",
|
|
@@ -134,7 +135,7 @@ const T = {
|
|
|
134
135
|
fill: "var(--color-grey-100)"
|
|
135
136
|
}
|
|
136
137
|
),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
+
/* @__PURE__ */ a(
|
|
138
139
|
"rect",
|
|
139
140
|
{
|
|
140
141
|
x: "16",
|
|
@@ -146,7 +147,7 @@ const T = {
|
|
|
146
147
|
stroke: "var(--card-default-color-border)"
|
|
147
148
|
}
|
|
148
149
|
),
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ a(
|
|
150
151
|
"rect",
|
|
151
152
|
{
|
|
152
153
|
x: "130",
|
|
@@ -158,7 +159,7 @@ const T = {
|
|
|
158
159
|
stroke: "var(--card-default-color-border)"
|
|
159
160
|
}
|
|
160
161
|
),
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ a(
|
|
162
163
|
"rect",
|
|
163
164
|
{
|
|
164
165
|
x: "244",
|
|
@@ -170,7 +171,7 @@ const T = {
|
|
|
170
171
|
stroke: "var(--card-default-color-border)"
|
|
171
172
|
}
|
|
172
173
|
),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
+
/* @__PURE__ */ a(
|
|
174
175
|
"rect",
|
|
175
176
|
{
|
|
176
177
|
x: "244",
|
|
@@ -182,7 +183,7 @@ const T = {
|
|
|
182
183
|
stroke: "var(--card-default-color-border)"
|
|
183
184
|
}
|
|
184
185
|
),
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ a(
|
|
186
187
|
"rect",
|
|
187
188
|
{
|
|
188
189
|
x: "28",
|
|
@@ -193,7 +194,7 @@ const T = {
|
|
|
193
194
|
fill: "var(--color-grey-050)"
|
|
194
195
|
}
|
|
195
196
|
),
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ a(
|
|
197
198
|
"rect",
|
|
198
199
|
{
|
|
199
200
|
x: "28",
|
|
@@ -204,7 +205,7 @@ const T = {
|
|
|
204
205
|
fill: "var(--color-grey-050)"
|
|
205
206
|
}
|
|
206
207
|
),
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ a(
|
|
208
209
|
"rect",
|
|
209
210
|
{
|
|
210
211
|
x: "142",
|
|
@@ -215,9 +216,9 @@ const T = {
|
|
|
215
216
|
fill: "var(--color-semantic-warning-050)"
|
|
216
217
|
}
|
|
217
218
|
),
|
|
218
|
-
/* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ a("circle", { cx: "40", cy: "70", r: "4", fill: "var(--color-brand-600)" }),
|
|
220
|
+
/* @__PURE__ */ a("circle", { cx: "40", cy: "114", r: "4", fill: "var(--color-brand-600)" }),
|
|
221
|
+
/* @__PURE__ */ a(
|
|
221
222
|
"circle",
|
|
222
223
|
{
|
|
223
224
|
cx: "154",
|
|
@@ -226,250 +227,250 @@ const T = {
|
|
|
226
227
|
fill: "var(--color-semantic-warning-600)"
|
|
227
228
|
}
|
|
228
229
|
),
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ a("circle", { cx: "256", cy: "52", r: "4", fill: "var(--color-grey-400)" }),
|
|
231
|
+
/* @__PURE__ */ a("circle", { cx: "256", cy: "160", r: "4", fill: "var(--color-semantic-destructive-500)" })
|
|
231
232
|
]
|
|
232
233
|
}
|
|
233
|
-
),
|
|
234
|
-
const e =
|
|
235
|
-
return e.statusIcon ? /* @__PURE__ */
|
|
236
|
-
|
|
234
|
+
), fn = ({ status: t }) => {
|
|
235
|
+
const e = Ke[t];
|
|
236
|
+
return e.statusIcon ? /* @__PURE__ */ a(
|
|
237
|
+
O,
|
|
237
238
|
{
|
|
238
239
|
name: e.statusIcon.name,
|
|
239
240
|
size: 16,
|
|
240
241
|
color: e.statusIcon.color,
|
|
241
242
|
screenReaderText: e.title
|
|
242
243
|
}
|
|
243
|
-
) : /* @__PURE__ */
|
|
244
|
-
},
|
|
244
|
+
) : /* @__PURE__ */ a(St, { colour: e.dotColour, label: e.title });
|
|
245
|
+
}, vn = () => /* @__PURE__ */ l(
|
|
245
246
|
"section",
|
|
246
247
|
{
|
|
247
248
|
className: "agent-view__empty",
|
|
248
249
|
"aria-label": "About the agents board",
|
|
249
250
|
children: [
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
const e =
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ l("div", { className: "agent-view__empty-content", children: [
|
|
252
|
+
/* @__PURE__ */ a(ve, { level: 4, children: "Your agents board" }),
|
|
253
|
+
/* @__PURE__ */ a("p", { className: "agent-view__empty-lead", children: "When you start an agent, it appears here so you can track progress at a glance. Agents move between columns as their status changes." }),
|
|
254
|
+
/* @__PURE__ */ a("ul", { className: "agent-view__empty-columns", children: pn.map((t) => {
|
|
255
|
+
const e = Ke[t];
|
|
256
|
+
return /* @__PURE__ */ l("li", { className: "agent-view__empty-column", children: [
|
|
257
|
+
/* @__PURE__ */ a("span", { className: "agent-view__empty-column-indicator", children: /* @__PURE__ */ a(fn, { status: t }) }),
|
|
258
|
+
/* @__PURE__ */ l("span", { className: "agent-view__empty-column-text", children: [
|
|
259
|
+
/* @__PURE__ */ a("span", { className: "agent-view__empty-column-title", children: e.title }),
|
|
260
|
+
/* @__PURE__ */ a("span", { className: "agent-view__empty-column-description", children: mn[t] })
|
|
260
261
|
] })
|
|
261
262
|
] }, t);
|
|
262
263
|
}) }),
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ l("p", { className: "agent-view__empty-hint", children: [
|
|
264
265
|
"Use ",
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
+
/* @__PURE__ */ a("strong", { children: "Start an agent" }),
|
|
266
267
|
" above to begin."
|
|
267
268
|
] })
|
|
268
269
|
] }),
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
+
/* @__PURE__ */ a("div", { className: "agent-view__empty-visual", children: /* @__PURE__ */ a(_n, {}) })
|
|
270
271
|
]
|
|
271
272
|
}
|
|
272
|
-
),
|
|
273
|
+
), wn = (t, e) => ({
|
|
273
274
|
...t,
|
|
274
275
|
...e.length > 0 ? { children: e } : {}
|
|
275
|
-
}),
|
|
276
|
-
const e = [],
|
|
276
|
+
}), It = (t) => {
|
|
277
|
+
const e = [], n = [];
|
|
277
278
|
for (const s of t) {
|
|
278
|
-
const r = s.children ?
|
|
279
|
-
if (e.push(...r.needsInput), s.status ===
|
|
279
|
+
const r = s.children ? It(s.children) : { needsInput: [], tasks: [] };
|
|
280
|
+
if (e.push(...r.needsInput), s.status === G.hitl) {
|
|
280
281
|
e.push({ ...s, children: void 0 });
|
|
281
282
|
continue;
|
|
282
283
|
}
|
|
283
|
-
|
|
284
|
+
n.push(wn(s, r.tasks));
|
|
284
285
|
}
|
|
285
|
-
return { needsInput: e, tasks:
|
|
286
|
-
},
|
|
287
|
-
const s = e.item.status ===
|
|
288
|
-
return s !== r ? s ? -1 : 1 : e.index -
|
|
289
|
-
}).map(({ item: e }) => e),
|
|
286
|
+
return { needsInput: e, tasks: n };
|
|
287
|
+
}, yn = (t) => t.map((e, n) => ({ item: e, index: n })).sort((e, n) => {
|
|
288
|
+
const s = e.item.status === G.hitl, r = n.item.status === G.hitl;
|
|
289
|
+
return s !== r ? s ? -1 : 1 : e.index - n.index;
|
|
290
|
+
}).map(({ item: e }) => e), st = 2, Nn = (t) => {
|
|
290
291
|
if (!t)
|
|
291
292
|
return { canScrollUp: !1, canScrollDown: !1 };
|
|
292
293
|
const e = t.scrollHeight - t.clientHeight;
|
|
293
|
-
return e <=
|
|
294
|
-
canScrollUp: t.scrollTop >
|
|
295
|
-
canScrollDown: t.scrollTop < e -
|
|
294
|
+
return e <= st ? { canScrollUp: !1, canScrollDown: !1 } : {
|
|
295
|
+
canScrollUp: t.scrollTop > st,
|
|
296
|
+
canScrollDown: t.scrollTop < e - st
|
|
296
297
|
};
|
|
297
|
-
},
|
|
298
|
+
}, kn = (t, e) => {
|
|
298
299
|
if (!t || !e)
|
|
299
300
|
return null;
|
|
300
|
-
const
|
|
301
|
+
const n = t.getBoundingClientRect(), s = e.getBoundingClientRect();
|
|
301
302
|
return {
|
|
302
|
-
top: s.top -
|
|
303
|
-
left: s.left -
|
|
303
|
+
top: s.top - n.top,
|
|
304
|
+
left: s.left - n.left,
|
|
304
305
|
width: s.width,
|
|
305
306
|
height: s.height
|
|
306
307
|
};
|
|
307
|
-
},
|
|
308
|
+
}, Ve = ({
|
|
308
309
|
children: t,
|
|
309
310
|
className: e,
|
|
310
|
-
contentClassName:
|
|
311
|
+
contentClassName: n,
|
|
311
312
|
scrollSelector: s,
|
|
312
313
|
style: r,
|
|
313
|
-
"aria-label":
|
|
314
|
+
"aria-label": i
|
|
314
315
|
}) => {
|
|
315
|
-
const
|
|
316
|
-
var
|
|
317
|
-
return s ? ((
|
|
318
|
-
},
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
(
|
|
322
|
-
),
|
|
323
|
-
(
|
|
316
|
+
const o = fe(null), d = fe(null), [c, w] = _(!1), [f, h] = _(!1), [u, x] = _(null), v = () => {
|
|
317
|
+
var N;
|
|
318
|
+
return s ? ((N = o.current) == null ? void 0 : N.querySelector(s)) ?? null : d.current;
|
|
319
|
+
}, b = () => {
|
|
320
|
+
const N = v(), y = Nn(N);
|
|
321
|
+
if (w(
|
|
322
|
+
(m) => m === y.canScrollUp ? m : y.canScrollUp
|
|
323
|
+
), h(
|
|
324
|
+
(m) => m === y.canScrollDown ? m : y.canScrollDown
|
|
324
325
|
), s) {
|
|
325
|
-
const
|
|
326
|
-
|
|
326
|
+
const m = kn(o.current, N);
|
|
327
|
+
x((T) => (T == null ? void 0 : T.top) === (m == null ? void 0 : m.top) && (T == null ? void 0 : T.left) === (m == null ? void 0 : m.left) && (T == null ? void 0 : T.width) === (m == null ? void 0 : m.width) && (T == null ? void 0 : T.height) === (m == null ? void 0 : m.height) ? T : m);
|
|
327
328
|
} else
|
|
328
|
-
|
|
329
|
+
x((m) => m === null ? m : null);
|
|
329
330
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}),
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
331
|
+
We(() => {
|
|
332
|
+
b();
|
|
333
|
+
}), F(() => {
|
|
334
|
+
const N = o.current;
|
|
335
|
+
if (!N)
|
|
335
336
|
return;
|
|
336
|
-
let
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
if (
|
|
341
|
-
|
|
337
|
+
let y = null, m = null;
|
|
338
|
+
const T = () => {
|
|
339
|
+
y == null || y.removeEventListener("scroll", b), m == null || m.disconnect(), m = null, y = null;
|
|
340
|
+
}, P = (z) => {
|
|
341
|
+
if (z === y) {
|
|
342
|
+
b();
|
|
342
343
|
return;
|
|
343
344
|
}
|
|
344
|
-
if (
|
|
345
|
-
|
|
345
|
+
if (T(), y = z, !y) {
|
|
346
|
+
b();
|
|
346
347
|
return;
|
|
347
348
|
}
|
|
348
|
-
|
|
349
|
+
y.addEventListener("scroll", b, { passive: !0 }), m = new ResizeObserver(() => b()), m.observe(y), y.firstElementChild instanceof HTMLElement && m.observe(y.firstElementChild), b();
|
|
349
350
|
};
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
351
|
+
P(v());
|
|
352
|
+
const I = new MutationObserver(() => {
|
|
353
|
+
P(v());
|
|
353
354
|
});
|
|
354
|
-
return
|
|
355
|
+
return I.observe(N, {
|
|
355
356
|
childList: !0,
|
|
356
357
|
subtree: !0,
|
|
357
358
|
characterData: !0
|
|
358
|
-
}), window.addEventListener("resize",
|
|
359
|
-
window.removeEventListener("resize",
|
|
359
|
+
}), window.addEventListener("resize", b), () => {
|
|
360
|
+
window.removeEventListener("resize", b), I.disconnect(), T();
|
|
360
361
|
};
|
|
361
362
|
}, [s]);
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
if (!
|
|
363
|
+
const A = (N) => {
|
|
364
|
+
const y = v();
|
|
365
|
+
if (!y)
|
|
365
366
|
return;
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
top:
|
|
367
|
+
const m = Math.max(y.clientHeight * 0.75, 120);
|
|
368
|
+
y.scrollBy({
|
|
369
|
+
top: N === "up" ? -m : m,
|
|
369
370
|
behavior: "smooth"
|
|
370
371
|
});
|
|
371
|
-
},
|
|
372
|
-
c && /* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
372
|
+
}, D = /* @__PURE__ */ l(ce, { children: [
|
|
373
|
+
c && /* @__PURE__ */ l(ce, { children: [
|
|
374
|
+
/* @__PURE__ */ a("div", { className: "scrollable-region__fade scrollable-region__fade--top", "aria-hidden": "true" }),
|
|
375
|
+
/* @__PURE__ */ a(
|
|
375
376
|
"button",
|
|
376
377
|
{
|
|
377
378
|
type: "button",
|
|
378
379
|
className: "scrollable-region__edge scrollable-region__edge--top",
|
|
379
380
|
"aria-label": "Scroll up",
|
|
380
|
-
onClick: () =>
|
|
381
|
-
children: /* @__PURE__ */
|
|
381
|
+
onClick: () => A("up"),
|
|
382
|
+
children: /* @__PURE__ */ a(O, { name: "chevron-up", size: 16, color: "currentColor" })
|
|
382
383
|
}
|
|
383
384
|
)
|
|
384
385
|
] }),
|
|
385
|
-
|
|
386
|
-
/* @__PURE__ */
|
|
386
|
+
f && /* @__PURE__ */ l(ce, { children: [
|
|
387
|
+
/* @__PURE__ */ a(
|
|
387
388
|
"div",
|
|
388
389
|
{
|
|
389
390
|
className: "scrollable-region__fade scrollable-region__fade--bottom",
|
|
390
391
|
"aria-hidden": "true"
|
|
391
392
|
}
|
|
392
393
|
),
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
+
/* @__PURE__ */ a(
|
|
394
395
|
"button",
|
|
395
396
|
{
|
|
396
397
|
type: "button",
|
|
397
398
|
className: "scrollable-region__edge scrollable-region__edge--bottom",
|
|
398
399
|
"aria-label": "Scroll down",
|
|
399
|
-
onClick: () =>
|
|
400
|
-
children: /* @__PURE__ */
|
|
400
|
+
onClick: () => A("down"),
|
|
401
|
+
children: /* @__PURE__ */ a(O, { name: "chevron-down", size: 16, color: "currentColor" })
|
|
401
402
|
}
|
|
402
403
|
)
|
|
403
404
|
] })
|
|
404
405
|
] });
|
|
405
|
-
return /* @__PURE__ */
|
|
406
|
+
return /* @__PURE__ */ a(
|
|
406
407
|
"div",
|
|
407
408
|
{
|
|
408
|
-
ref:
|
|
409
|
-
className:
|
|
409
|
+
ref: o,
|
|
410
|
+
className: Y("scrollable-region", e),
|
|
410
411
|
style: r,
|
|
411
|
-
"aria-label":
|
|
412
|
-
children: s ? /* @__PURE__ */
|
|
412
|
+
"aria-label": i,
|
|
413
|
+
children: s ? /* @__PURE__ */ l(ce, { children: [
|
|
413
414
|
t,
|
|
414
|
-
|
|
415
|
+
u && (c || f) && /* @__PURE__ */ a(
|
|
415
416
|
"div",
|
|
416
417
|
{
|
|
417
418
|
className: "scrollable-region__overlay",
|
|
418
419
|
style: {
|
|
419
|
-
top:
|
|
420
|
-
left:
|
|
421
|
-
width:
|
|
422
|
-
height:
|
|
420
|
+
top: u.top,
|
|
421
|
+
left: u.left,
|
|
422
|
+
width: u.width,
|
|
423
|
+
height: u.height
|
|
423
424
|
},
|
|
424
|
-
children:
|
|
425
|
+
children: D
|
|
425
426
|
}
|
|
426
427
|
)
|
|
427
|
-
] }) : /* @__PURE__ */
|
|
428
|
-
|
|
429
|
-
/* @__PURE__ */
|
|
428
|
+
] }) : /* @__PURE__ */ l(ce, { children: [
|
|
429
|
+
D,
|
|
430
|
+
/* @__PURE__ */ a(
|
|
430
431
|
"div",
|
|
431
432
|
{
|
|
432
433
|
ref: d,
|
|
433
|
-
className:
|
|
434
|
+
className: Y("scrollable-region__viewport", n),
|
|
434
435
|
children: t
|
|
435
436
|
}
|
|
436
437
|
)
|
|
437
438
|
] })
|
|
438
439
|
}
|
|
439
440
|
);
|
|
440
|
-
},
|
|
441
|
+
}, An = 48, bn = ({
|
|
441
442
|
checklist: t
|
|
442
443
|
}) => {
|
|
443
|
-
const e =
|
|
444
|
-
return
|
|
444
|
+
const e = fe(null), n = fe(!1);
|
|
445
|
+
return We(() => {
|
|
445
446
|
const s = e.current;
|
|
446
447
|
if (!s)
|
|
447
448
|
return;
|
|
448
449
|
const r = s.scrollHeight - s.scrollTop - s.clientHeight;
|
|
449
|
-
(!
|
|
450
|
-
}, [t]), t.length === 0 ? /* @__PURE__ */
|
|
451
|
-
|
|
450
|
+
(!n.current || r <= An) && (s.scrollTop = s.scrollHeight, n.current = !0);
|
|
451
|
+
}, [t]), t.length === 0 ? /* @__PURE__ */ a("p", { className: "agent-view__progress-empty", children: "No tasks to display." }) : /* @__PURE__ */ a(
|
|
452
|
+
Ve,
|
|
452
453
|
{
|
|
453
454
|
className: "agent-view__progress-scroll",
|
|
454
455
|
scrollSelector: ".agent-view__progress-list",
|
|
455
|
-
children: /* @__PURE__ */
|
|
456
|
+
children: /* @__PURE__ */ a(
|
|
456
457
|
"ul",
|
|
457
458
|
{
|
|
458
459
|
ref: e,
|
|
459
460
|
className: "agent-view__progress-list",
|
|
460
461
|
"aria-label": "Agent tasks",
|
|
461
|
-
children:
|
|
462
|
+
children: yn(t).map((s) => {
|
|
462
463
|
const r = Q[s.status];
|
|
463
|
-
return /* @__PURE__ */
|
|
464
|
+
return /* @__PURE__ */ l(
|
|
464
465
|
"li",
|
|
465
466
|
{
|
|
466
|
-
className:
|
|
467
|
+
className: Y(
|
|
467
468
|
"agent-view__progress-item",
|
|
468
469
|
`agent-view__progress-item--${s.status.replace(/_/g, "-")}`
|
|
469
470
|
),
|
|
470
471
|
children: [
|
|
471
|
-
/* @__PURE__ */
|
|
472
|
-
|
|
472
|
+
/* @__PURE__ */ a(
|
|
473
|
+
O,
|
|
473
474
|
{
|
|
474
475
|
name: r.icon,
|
|
475
476
|
size: 16,
|
|
@@ -477,9 +478,9 @@ const T = {
|
|
|
477
478
|
screenReaderText: `${r.label}:`
|
|
478
479
|
}
|
|
479
480
|
),
|
|
480
|
-
/* @__PURE__ */
|
|
481
|
-
/* @__PURE__ */
|
|
482
|
-
s.status !==
|
|
481
|
+
/* @__PURE__ */ l("div", { className: "agent-view__progress-item-content", children: [
|
|
482
|
+
/* @__PURE__ */ a("span", { className: "agent-view__progress-label", children: s.task }),
|
|
483
|
+
s.status !== G.complete && /* @__PURE__ */ a(
|
|
483
484
|
"span",
|
|
484
485
|
{
|
|
485
486
|
className: "agent-view__progress-description",
|
|
@@ -496,23 +497,23 @@ const T = {
|
|
|
496
497
|
)
|
|
497
498
|
}
|
|
498
499
|
);
|
|
499
|
-
},
|
|
500
|
+
}, Sn = ({
|
|
500
501
|
prompts: t,
|
|
501
502
|
classNamePrefix: e = "agent-workspace",
|
|
502
|
-
onSelect:
|
|
503
|
-
}) => t.length === 0 ? null : /* @__PURE__ */
|
|
503
|
+
onSelect: n
|
|
504
|
+
}) => t.length === 0 ? null : /* @__PURE__ */ a("div", { className: `${e}__chips`, children: t.map((s) => /* @__PURE__ */ a(
|
|
504
505
|
"button",
|
|
505
506
|
{
|
|
506
507
|
type: "button",
|
|
507
508
|
className: `${e}__chip`,
|
|
508
|
-
onClick: () =>
|
|
509
|
+
onClick: () => n(s),
|
|
509
510
|
children: s
|
|
510
511
|
},
|
|
511
512
|
s
|
|
512
513
|
)) });
|
|
513
|
-
class
|
|
514
|
-
constructor(e,
|
|
515
|
-
this.connector = e, this.canSend =
|
|
514
|
+
class Cn {
|
|
515
|
+
constructor(e, n) {
|
|
516
|
+
this.connector = e, this.canSend = n.canSend, this.onTurn = n.onTurn, this.onAwaitingChange = n.onAwaitingChange;
|
|
516
517
|
}
|
|
517
518
|
get canRate() {
|
|
518
519
|
return !1;
|
|
@@ -530,10 +531,10 @@ class gn {
|
|
|
530
531
|
return {};
|
|
531
532
|
}
|
|
532
533
|
async sendMessage(e) {
|
|
533
|
-
var
|
|
534
|
+
var n, s;
|
|
534
535
|
if (!this.canSend())
|
|
535
536
|
return null;
|
|
536
|
-
(
|
|
537
|
+
(n = this.onAwaitingChange) == null || n.call(this, !0);
|
|
537
538
|
try {
|
|
538
539
|
const r = await this.connector.sendMessage(
|
|
539
540
|
e.userMessage,
|
|
@@ -542,14 +543,14 @@ class gn {
|
|
|
542
543
|
return this.onTurn(r), {
|
|
543
544
|
id: r.message.id,
|
|
544
545
|
text: r.message.text,
|
|
545
|
-
type:
|
|
546
|
+
type: Ct,
|
|
546
547
|
...r.message.followUpPrompts ? { followUpPrompts: r.message.followUpPrompts } : {}
|
|
547
548
|
};
|
|
548
549
|
} catch {
|
|
549
550
|
return {
|
|
550
551
|
id: `error-${Date.now()}`,
|
|
551
|
-
text:
|
|
552
|
-
type:
|
|
552
|
+
text: gn,
|
|
553
|
+
type: en
|
|
553
554
|
};
|
|
554
555
|
} finally {
|
|
555
556
|
(s = this.onAwaitingChange) == null || s.call(this, !1);
|
|
@@ -567,92 +568,92 @@ class gn {
|
|
|
567
568
|
return !1;
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
|
-
const
|
|
571
|
+
const Tn = ({
|
|
571
572
|
connector: t,
|
|
572
573
|
phase: e,
|
|
573
|
-
chatHistory:
|
|
574
|
+
chatHistory: n,
|
|
574
575
|
chatSessionKey: s,
|
|
575
576
|
startQuery: r,
|
|
576
|
-
clarificationMessage:
|
|
577
|
-
enableUpload:
|
|
577
|
+
clarificationMessage: i,
|
|
578
|
+
enableUpload: o = !1,
|
|
578
579
|
onTurn: d,
|
|
579
580
|
onAwaitingChange: c,
|
|
580
|
-
onClarificationPrompt:
|
|
581
|
-
onDismissClarification:
|
|
581
|
+
onClarificationPrompt: w,
|
|
582
|
+
onDismissClarification: f
|
|
582
583
|
}) => {
|
|
583
|
-
const
|
|
584
|
-
() => new
|
|
585
|
-
canSend: () => e ===
|
|
584
|
+
const h = W(
|
|
585
|
+
() => new Cn(t, {
|
|
586
|
+
canSend: () => e === H.running,
|
|
586
587
|
onTurn: d,
|
|
587
588
|
onAwaitingChange: c
|
|
588
589
|
}),
|
|
589
590
|
[t, e, d, c]
|
|
590
|
-
),
|
|
591
|
-
return /* @__PURE__ */
|
|
592
|
-
|
|
591
|
+
), u = e !== H.running, x = e === H.running;
|
|
592
|
+
return /* @__PURE__ */ l("section", { className: "agent-workspace__chat-body", "aria-label": "Chat", children: [
|
|
593
|
+
i && /* @__PURE__ */ l(
|
|
593
594
|
"div",
|
|
594
595
|
{
|
|
595
596
|
className: "agent-workspace__clarification",
|
|
596
597
|
role: "region",
|
|
597
598
|
"aria-label": "Agent question",
|
|
598
599
|
children: [
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
/* @__PURE__ */ a("p", { className: "agent-workspace__clarification-text", children: i.text }),
|
|
601
|
+
i.followUpPrompts && /* @__PURE__ */ a(
|
|
602
|
+
Sn,
|
|
602
603
|
{
|
|
603
|
-
prompts:
|
|
604
|
-
onSelect:
|
|
604
|
+
prompts: i.followUpPrompts,
|
|
605
|
+
onSelect: w
|
|
605
606
|
}
|
|
606
607
|
),
|
|
607
|
-
/* @__PURE__ */
|
|
608
|
+
/* @__PURE__ */ a(
|
|
608
609
|
"button",
|
|
609
610
|
{
|
|
610
611
|
type: "button",
|
|
611
612
|
className: "agent-workspace__clarification-dismiss",
|
|
612
|
-
onClick:
|
|
613
|
+
onClick: f,
|
|
613
614
|
children: "Dismiss"
|
|
614
615
|
}
|
|
615
616
|
)
|
|
616
617
|
]
|
|
617
618
|
}
|
|
618
619
|
),
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
|
|
620
|
+
/* @__PURE__ */ a("div", { className: "agent-workspace__ask-arbor", children: /* @__PURE__ */ a(Ve, { scrollSelector: ".chat-panel-message-list", children: /* @__PURE__ */ a(
|
|
621
|
+
tn,
|
|
621
622
|
{
|
|
622
|
-
connector:
|
|
623
|
-
chatHistory:
|
|
623
|
+
connector: h,
|
|
624
|
+
chatHistory: n,
|
|
624
625
|
startQuery: r,
|
|
625
|
-
lockConversation:
|
|
626
|
-
enableUpload:
|
|
627
|
-
speechEnabled:
|
|
626
|
+
lockConversation: u,
|
|
627
|
+
enableUpload: o,
|
|
628
|
+
speechEnabled: x,
|
|
628
629
|
speechLanguage: "en-GB",
|
|
629
630
|
speechSubmissionDelay: 1e3,
|
|
630
631
|
slashMenuItems: [],
|
|
631
632
|
menuContent: [],
|
|
632
633
|
introHeading: "Message your agent",
|
|
633
634
|
introBody: "Ask questions, share trip details, or paste a link. The agent will update the checklist as it works.",
|
|
634
|
-
placeholder:
|
|
635
|
+
placeholder: x ? "Message the agent, paste a link, or attach a file…" : "The agent is not accepting messages."
|
|
635
636
|
},
|
|
636
637
|
s
|
|
637
638
|
) }) }),
|
|
638
|
-
e ===
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
639
|
+
e === H.stopped && /* @__PURE__ */ l("div", { className: "agent-workspace__notice", role: "status", children: [
|
|
640
|
+
/* @__PURE__ */ a(O, { name: "circle-alert", size: 16, color: "var(--color-semantic-warning-600)" }),
|
|
641
|
+
/* @__PURE__ */ a("span", { children: "You stopped the agent. Its progress is saved in the checklist on the left." })
|
|
641
642
|
] }),
|
|
642
|
-
e ===
|
|
643
|
-
/* @__PURE__ */
|
|
644
|
-
/* @__PURE__ */
|
|
643
|
+
e === H.complete && /* @__PURE__ */ l("div", { className: "agent-workspace__notice", role: "status", children: [
|
|
644
|
+
/* @__PURE__ */ a(O, { name: "party-popper", size: 16, color: "var(--color-semantic-success-600)" }),
|
|
645
|
+
/* @__PURE__ */ a("span", { children: "The agent has finished." })
|
|
645
646
|
] })
|
|
646
647
|
] });
|
|
647
|
-
},
|
|
648
|
+
}, Ot = ({
|
|
648
649
|
item: t,
|
|
649
650
|
depth: e,
|
|
650
|
-
canRequestInput:
|
|
651
|
+
canRequestInput: n,
|
|
651
652
|
onAttentionItemClick: s
|
|
652
653
|
}) => {
|
|
653
|
-
const r = Q[t.status],
|
|
654
|
-
/* @__PURE__ */
|
|
655
|
-
|
|
654
|
+
const r = Q[t.status], i = t.status.replace(/_/g, "-"), o = t.status === G.hitl && n && s, d = /* @__PURE__ */ l("div", { className: "agent-workspace__task-row", children: [
|
|
655
|
+
/* @__PURE__ */ a(
|
|
656
|
+
O,
|
|
656
657
|
{
|
|
657
658
|
name: r.icon,
|
|
658
659
|
size: 16,
|
|
@@ -660,19 +661,19 @@ const hn = ({
|
|
|
660
661
|
screenReaderText: `${r.label}:`
|
|
661
662
|
}
|
|
662
663
|
),
|
|
663
|
-
/* @__PURE__ */
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
t.status !==
|
|
664
|
+
/* @__PURE__ */ l("div", { className: "agent-workspace__task-content", children: [
|
|
665
|
+
/* @__PURE__ */ a("span", { className: "agent-workspace__task-label", children: t.task }),
|
|
666
|
+
t.status !== G.complete && t.description && /* @__PURE__ */ a("span", { className: "agent-workspace__task-description", children: t.description })
|
|
666
667
|
] })
|
|
667
668
|
] });
|
|
668
|
-
return /* @__PURE__ */
|
|
669
|
+
return /* @__PURE__ */ l(
|
|
669
670
|
"li",
|
|
670
671
|
{
|
|
671
|
-
className:
|
|
672
|
+
className: Y("agent-workspace__task", `agent-workspace__task--${i}`, {
|
|
672
673
|
"agent-workspace__task--child": e > 0
|
|
673
674
|
}),
|
|
674
675
|
children: [
|
|
675
|
-
|
|
676
|
+
o ? /* @__PURE__ */ a(
|
|
676
677
|
"button",
|
|
677
678
|
{
|
|
678
679
|
type: "button",
|
|
@@ -682,12 +683,12 @@ const hn = ({
|
|
|
682
683
|
children: d
|
|
683
684
|
}
|
|
684
685
|
) : d,
|
|
685
|
-
t.children && t.children.length > 0 && /* @__PURE__ */
|
|
686
|
-
|
|
686
|
+
t.children && t.children.length > 0 && /* @__PURE__ */ a("ul", { className: "agent-workspace__task-children", children: t.children.map((c) => /* @__PURE__ */ a(
|
|
687
|
+
Ot,
|
|
687
688
|
{
|
|
688
689
|
item: c,
|
|
689
690
|
depth: e + 1,
|
|
690
|
-
canRequestInput:
|
|
691
|
+
canRequestInput: n,
|
|
691
692
|
onAttentionItemClick: s
|
|
692
693
|
},
|
|
693
694
|
c.task
|
|
@@ -695,132 +696,193 @@ const hn = ({
|
|
|
695
696
|
]
|
|
696
697
|
}
|
|
697
698
|
);
|
|
698
|
-
},
|
|
699
|
+
}, _t = ({
|
|
699
700
|
items: t,
|
|
700
701
|
ariaLabel: e,
|
|
701
|
-
canRequestInput:
|
|
702
|
+
canRequestInput: n,
|
|
702
703
|
onAttentionItemClick: s
|
|
703
|
-
}) => /* @__PURE__ */
|
|
704
|
-
|
|
704
|
+
}) => /* @__PURE__ */ a("ul", { className: "agent-workspace__task-list", "aria-label": e, children: t.map((r) => /* @__PURE__ */ a(
|
|
705
|
+
Ot,
|
|
705
706
|
{
|
|
706
707
|
item: r,
|
|
707
708
|
depth: 0,
|
|
708
|
-
canRequestInput:
|
|
709
|
+
canRequestInput: n,
|
|
709
710
|
onAttentionItemClick: s
|
|
710
711
|
},
|
|
711
712
|
r.task
|
|
712
|
-
)) }),
|
|
713
|
+
)) }), En = ({
|
|
713
714
|
checklist: t,
|
|
714
715
|
isLoading: e,
|
|
715
|
-
error:
|
|
716
|
+
error: n,
|
|
716
717
|
phase: s,
|
|
717
718
|
canRequestInput: r,
|
|
718
|
-
onAttentionItemClick:
|
|
719
|
+
onAttentionItemClick: i
|
|
719
720
|
}) => {
|
|
720
|
-
const
|
|
721
|
-
() => t ?
|
|
721
|
+
const o = W(
|
|
722
|
+
() => t ? It(t) : null,
|
|
722
723
|
[t]
|
|
723
724
|
);
|
|
724
|
-
return /* @__PURE__ */
|
|
725
|
+
return /* @__PURE__ */ l(
|
|
725
726
|
"section",
|
|
726
727
|
{
|
|
727
728
|
className: "agent-workspace__panel agent-workspace__panel--checklist",
|
|
728
729
|
"aria-label": "Checklist",
|
|
729
730
|
children: [
|
|
730
|
-
/* @__PURE__ */
|
|
731
|
-
/* @__PURE__ */
|
|
732
|
-
e && /* @__PURE__ */
|
|
733
|
-
/* @__PURE__ */
|
|
734
|
-
|
|
731
|
+
/* @__PURE__ */ a("div", { className: "agent-workspace__panel-header", children: /* @__PURE__ */ a(ve, { level: 4, children: "Checklist" }) }),
|
|
732
|
+
/* @__PURE__ */ a("div", { className: "agent-workspace__panel-body", "aria-live": "polite", children: /* @__PURE__ */ l(Ve, { children: [
|
|
733
|
+
e && /* @__PURE__ */ l("div", { className: "agent-workspace__loading", children: [
|
|
734
|
+
/* @__PURE__ */ a(
|
|
735
|
+
O,
|
|
735
736
|
{
|
|
736
737
|
name: "loader",
|
|
737
738
|
size: 16,
|
|
738
739
|
color: "var(--color-brand-600)",
|
|
739
740
|
className: "agent-workspace__task-icon--spinning",
|
|
740
|
-
screenReaderText:
|
|
741
|
+
screenReaderText: _e
|
|
741
742
|
}
|
|
742
743
|
),
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
+
/* @__PURE__ */ a("span", { children: _e })
|
|
744
745
|
] }),
|
|
745
|
-
!e &&
|
|
746
|
-
!e && !
|
|
747
|
-
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
|
|
746
|
+
!e && n && /* @__PURE__ */ a("p", { className: "agent-workspace__error", role: "alert", children: n }),
|
|
747
|
+
!e && !n && o && /* @__PURE__ */ l(ce, { children: [
|
|
748
|
+
o.needsInput.length > 0 && /* @__PURE__ */ l("div", { className: "agent-workspace__task-group", children: [
|
|
749
|
+
/* @__PURE__ */ a("p", { className: "agent-workspace__task-group-label", children: "Needs your input" }),
|
|
750
|
+
/* @__PURE__ */ a(
|
|
751
|
+
_t,
|
|
751
752
|
{
|
|
752
|
-
items:
|
|
753
|
+
items: o.needsInput,
|
|
753
754
|
ariaLabel: "Tasks needing your input",
|
|
754
755
|
canRequestInput: r,
|
|
755
|
-
onAttentionItemClick:
|
|
756
|
+
onAttentionItemClick: i
|
|
756
757
|
}
|
|
757
758
|
)
|
|
758
759
|
] }),
|
|
759
|
-
|
|
760
|
+
o.tasks.length > 0 && /* @__PURE__ */ l(
|
|
760
761
|
"div",
|
|
761
762
|
{
|
|
762
|
-
className:
|
|
763
|
-
"agent-workspace__task-group--following":
|
|
763
|
+
className: Y("agent-workspace__task-group", {
|
|
764
|
+
"agent-workspace__task-group--following": o.needsInput.length > 0
|
|
764
765
|
}),
|
|
765
766
|
children: [
|
|
766
|
-
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
|
|
767
|
+
o.needsInput.length > 0 && /* @__PURE__ */ a("p", { className: "agent-workspace__task-group-label", children: "Other tasks" }),
|
|
768
|
+
/* @__PURE__ */ a(
|
|
769
|
+
_t,
|
|
769
770
|
{
|
|
770
|
-
items:
|
|
771
|
+
items: o.tasks,
|
|
771
772
|
ariaLabel: "Agent tasks",
|
|
772
773
|
canRequestInput: r,
|
|
773
|
-
onAttentionItemClick:
|
|
774
|
+
onAttentionItemClick: i
|
|
774
775
|
}
|
|
775
776
|
)
|
|
776
777
|
]
|
|
777
778
|
}
|
|
778
779
|
)
|
|
779
780
|
] }),
|
|
780
|
-
!e && !
|
|
781
|
+
!e && !n && (!o || o.needsInput.length === 0 && o.tasks.length === 0) && /* @__PURE__ */ a("p", { className: "agent-workspace__empty", children: s === H.briefing ? "Tasks will appear here once the agent starts." : "No tasks to display." })
|
|
781
782
|
] }) })
|
|
782
783
|
]
|
|
783
784
|
}
|
|
784
785
|
);
|
|
785
|
-
},
|
|
786
|
-
|
|
786
|
+
}, Rn = ({
|
|
787
|
+
resource: t,
|
|
788
|
+
html: e,
|
|
789
|
+
isLoading: n,
|
|
790
|
+
error: s,
|
|
791
|
+
onClose: r
|
|
792
|
+
}) => {
|
|
793
|
+
F(() => {
|
|
794
|
+
if (!t)
|
|
795
|
+
return;
|
|
796
|
+
const o = Be.removeSlideover;
|
|
797
|
+
return Be.removeSlideover = () => {
|
|
798
|
+
o(), r();
|
|
799
|
+
}, () => {
|
|
800
|
+
Be.removeSlideover = o;
|
|
801
|
+
};
|
|
802
|
+
}, [t, r]), F(() => {
|
|
803
|
+
if (!t)
|
|
804
|
+
return;
|
|
805
|
+
const o = (d) => {
|
|
806
|
+
d.key === "Escape" && Be.removeSlideover();
|
|
807
|
+
};
|
|
808
|
+
return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
|
|
809
|
+
}, [t]);
|
|
810
|
+
const i = W(() => t ? [
|
|
811
|
+
{
|
|
812
|
+
centerHeaderText: !1,
|
|
813
|
+
children: /* @__PURE__ */ l("div", { className: "resource-preview-slideover__body", children: [
|
|
814
|
+
n && /* @__PURE__ */ l("div", { className: "resource-preview-slideover__status", children: [
|
|
815
|
+
/* @__PURE__ */ a(
|
|
816
|
+
O,
|
|
817
|
+
{
|
|
818
|
+
name: "loader",
|
|
819
|
+
size: 16,
|
|
820
|
+
color: "var(--color-brand-600)",
|
|
821
|
+
className: "agent-workspace__task-icon--spinning",
|
|
822
|
+
screenReaderText: "Loading document"
|
|
823
|
+
}
|
|
824
|
+
),
|
|
825
|
+
/* @__PURE__ */ a("span", { children: "Loading document…" })
|
|
826
|
+
] }),
|
|
827
|
+
!n && s && /* @__PURE__ */ a("p", { className: "resource-preview-slideover__error", role: "alert", children: s }),
|
|
828
|
+
!n && !s && e !== null && /* @__PURE__ */ a(
|
|
829
|
+
"iframe",
|
|
830
|
+
{
|
|
831
|
+
className: "resource-preview-slideover__frame",
|
|
832
|
+
title: t.title,
|
|
833
|
+
sandbox: "",
|
|
834
|
+
srcDoc: e
|
|
835
|
+
}
|
|
836
|
+
)
|
|
837
|
+
] })
|
|
838
|
+
}
|
|
839
|
+
] : [], [t, e, n, s]);
|
|
840
|
+
return /* @__PURE__ */ a("div", { className: "resource-preview-slideover", children: /* @__PURE__ */ a(jt, { slideovers: i }) });
|
|
841
|
+
}, In = {
|
|
842
|
+
[de.mis_record]: {
|
|
787
843
|
icon: "table",
|
|
788
844
|
label: "Arbor MIS",
|
|
789
845
|
color: "var(--color-brand-600)"
|
|
790
846
|
},
|
|
791
|
-
[
|
|
847
|
+
[de.document_html]: {
|
|
848
|
+
icon: "file",
|
|
849
|
+
label: "Document",
|
|
850
|
+
color: "var(--color-semantic-caution-800)"
|
|
851
|
+
},
|
|
852
|
+
[de.file]: {
|
|
792
853
|
icon: "file",
|
|
793
854
|
label: "File",
|
|
794
855
|
color: "var(--color-semantic-caution-800)"
|
|
795
856
|
},
|
|
796
|
-
[
|
|
857
|
+
[de.workflow]: {
|
|
797
858
|
icon: "list-tree",
|
|
798
859
|
label: "Workflow",
|
|
799
860
|
color: "var(--color-semantic-warning-700)"
|
|
800
861
|
},
|
|
801
|
-
[
|
|
862
|
+
[de.link]: {
|
|
802
863
|
icon: "link",
|
|
803
864
|
label: "Link",
|
|
804
865
|
color: "var(--color-semantic-info-700)"
|
|
805
866
|
}
|
|
806
|
-
},
|
|
867
|
+
}, On = ({
|
|
807
868
|
resources: t,
|
|
808
869
|
isLoading: e = !1,
|
|
809
|
-
error:
|
|
810
|
-
|
|
870
|
+
error: n = null,
|
|
871
|
+
onOpenResource: s
|
|
872
|
+
}) => /* @__PURE__ */ l(
|
|
811
873
|
"section",
|
|
812
874
|
{
|
|
813
875
|
className: "agent-workspace__panel agent-workspace__panel--documents",
|
|
814
876
|
"aria-label": "Resources",
|
|
815
877
|
children: [
|
|
816
|
-
/* @__PURE__ */
|
|
817
|
-
/* @__PURE__ */
|
|
818
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ l("div", { className: "agent-workspace__panel-header", children: [
|
|
879
|
+
/* @__PURE__ */ a(ve, { level: 4, children: "Resources" }),
|
|
880
|
+
/* @__PURE__ */ a("span", { className: "agent-workspace__panel-count", children: t.length })
|
|
819
881
|
] }),
|
|
820
|
-
/* @__PURE__ */
|
|
821
|
-
e && /* @__PURE__ */
|
|
822
|
-
/* @__PURE__ */
|
|
823
|
-
|
|
882
|
+
/* @__PURE__ */ a("div", { className: "agent-workspace__panel-body", "aria-live": "polite", children: /* @__PURE__ */ l(Ve, { children: [
|
|
883
|
+
e && /* @__PURE__ */ l("div", { className: "agent-workspace__loading", children: [
|
|
884
|
+
/* @__PURE__ */ a(
|
|
885
|
+
O,
|
|
824
886
|
{
|
|
825
887
|
name: "loader",
|
|
826
888
|
size: 16,
|
|
@@ -829,295 +891,400 @@ const hn = ({
|
|
|
829
891
|
screenReaderText: "Loading resources"
|
|
830
892
|
}
|
|
831
893
|
),
|
|
832
|
-
/* @__PURE__ */
|
|
894
|
+
/* @__PURE__ */ a("span", { children: "Loading resources…" })
|
|
833
895
|
] }),
|
|
834
|
-
!e &&
|
|
835
|
-
!e && !
|
|
836
|
-
const
|
|
837
|
-
return /* @__PURE__ */
|
|
838
|
-
"
|
|
896
|
+
!e && n && /* @__PURE__ */ a("p", { className: "agent-workspace__error", role: "alert", children: n }),
|
|
897
|
+
!e && !n && t.length > 0 && /* @__PURE__ */ a("ul", { className: "agent-workspace__resource-list", "aria-label": "Agent resources", children: t.map((r) => {
|
|
898
|
+
const i = In[r.type], o = r.misRecordUrl;
|
|
899
|
+
return /* @__PURE__ */ a("li", { className: "agent-workspace__resource", children: o ? /* @__PURE__ */ a(
|
|
900
|
+
"a",
|
|
839
901
|
{
|
|
840
|
-
className: "agent-workspace__resource",
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
color: r.color,
|
|
859
|
-
screenReaderText: `${r.label}:`
|
|
860
|
-
}
|
|
861
|
-
)
|
|
862
|
-
}
|
|
863
|
-
),
|
|
864
|
-
/* @__PURE__ */ o("span", { className: "agent-workspace__resource-content", children: [
|
|
865
|
-
/* @__PURE__ */ o("span", { className: "agent-workspace__resource-top", children: [
|
|
866
|
-
/* @__PURE__ */ n("span", { className: "agent-workspace__resource-name", children: s.name }),
|
|
867
|
-
/* @__PURE__ */ n(
|
|
868
|
-
"span",
|
|
869
|
-
{
|
|
870
|
-
className: `agent-workspace__resource-badge agent-workspace__resource-badge--${s.type.toLowerCase()}`,
|
|
871
|
-
children: r.label
|
|
872
|
-
}
|
|
873
|
-
)
|
|
874
|
-
] }),
|
|
875
|
-
s.description && /* @__PURE__ */ n("span", { className: "agent-workspace__resource-description", children: s.description })
|
|
876
|
-
] }),
|
|
877
|
-
/* @__PURE__ */ n(
|
|
878
|
-
P,
|
|
879
|
-
{
|
|
880
|
-
name: "external-link",
|
|
881
|
-
size: 12,
|
|
882
|
-
color: "var(--color-grey-500)",
|
|
883
|
-
screenReaderText: "Opens in a new tab",
|
|
884
|
-
className: "agent-workspace__resource-open"
|
|
885
|
-
}
|
|
886
|
-
)
|
|
887
|
-
]
|
|
888
|
-
}
|
|
889
|
-
)
|
|
890
|
-
},
|
|
891
|
-
`${s.type}-${s.uri}`
|
|
892
|
-
);
|
|
902
|
+
className: "agent-workspace__resource-card",
|
|
903
|
+
href: o,
|
|
904
|
+
target: "_blank",
|
|
905
|
+
rel: "noreferrer",
|
|
906
|
+
onClick: (d) => {
|
|
907
|
+
d.preventDefault(), s(r);
|
|
908
|
+
},
|
|
909
|
+
children: /* @__PURE__ */ a(ft, { resource: r, config: i, external: !0 })
|
|
910
|
+
}
|
|
911
|
+
) : /* @__PURE__ */ a(
|
|
912
|
+
"button",
|
|
913
|
+
{
|
|
914
|
+
type: "button",
|
|
915
|
+
className: "agent-workspace__resource-card",
|
|
916
|
+
onClick: () => s(r),
|
|
917
|
+
children: /* @__PURE__ */ a(ft, { resource: r, config: i })
|
|
918
|
+
}
|
|
919
|
+
) }, r.id);
|
|
893
920
|
}) }),
|
|
894
|
-
!e && !
|
|
921
|
+
!e && !n && t.length === 0 && /* @__PURE__ */ a("p", { className: "agent-workspace__empty", children: "No resources yet." })
|
|
895
922
|
] }) })
|
|
896
923
|
]
|
|
897
924
|
}
|
|
898
|
-
),
|
|
925
|
+
), ft = ({ resource: t, config: e, external: n = !1 }) => /* @__PURE__ */ l(ce, { children: [
|
|
926
|
+
/* @__PURE__ */ a(
|
|
927
|
+
"span",
|
|
928
|
+
{
|
|
929
|
+
className: `agent-workspace__resource-icon agent-workspace__resource-icon--${t.type}`,
|
|
930
|
+
children: /* @__PURE__ */ a(O, { name: e.icon, size: 16, color: e.color, screenReaderText: `${e.label}:` })
|
|
931
|
+
}
|
|
932
|
+
),
|
|
933
|
+
/* @__PURE__ */ a("span", { className: "agent-workspace__resource-content", children: /* @__PURE__ */ l("span", { className: "agent-workspace__resource-top", children: [
|
|
934
|
+
/* @__PURE__ */ a("span", { className: "agent-workspace__resource-name", children: t.title }),
|
|
935
|
+
/* @__PURE__ */ a("span", { className: `agent-workspace__resource-badge agent-workspace__resource-badge--${t.type}`, children: e.label })
|
|
936
|
+
] }) }),
|
|
937
|
+
n && /* @__PURE__ */ a(
|
|
938
|
+
O,
|
|
939
|
+
{
|
|
940
|
+
name: "external-link",
|
|
941
|
+
size: 12,
|
|
942
|
+
color: "var(--color-grey-500)",
|
|
943
|
+
screenReaderText: "Opens in a new tab",
|
|
944
|
+
className: "agent-workspace__resource-open"
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
] }), Je = (t) => {
|
|
899
948
|
const e = Date.parse(t);
|
|
900
949
|
return Number.isFinite(e) ? e : 0;
|
|
901
|
-
},
|
|
950
|
+
}, Pn = new Intl.DateTimeFormat("en-GB", {
|
|
902
951
|
day: "numeric",
|
|
903
952
|
month: "long",
|
|
904
953
|
year: "numeric",
|
|
905
954
|
hour: "numeric",
|
|
906
955
|
minute: "2-digit"
|
|
907
|
-
}),
|
|
956
|
+
}), rt = (t) => {
|
|
908
957
|
const e = new Date(t);
|
|
909
|
-
return Number.isFinite(e.getTime()) ?
|
|
910
|
-
},
|
|
958
|
+
return Number.isFinite(e.getTime()) ? Pn.format(e) : t;
|
|
959
|
+
}, Fe = (t) => t.replace(
|
|
911
960
|
/[A-Za-z0-9]+(?:[_-][A-Za-z0-9]+)+/g,
|
|
912
|
-
(e) => e.split(/[_-]/).map((
|
|
913
|
-
), Ee = (t, e) => e <= 1 ? 0 : t / (e - 1) * 100,
|
|
961
|
+
(e) => e.split(/[_-]/).map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ")
|
|
962
|
+
), Ee = (t, e) => e <= 1 ? 0 : t / (e - 1) * 100, Pt = (t) => Math.max(t, 0) + 2, Ln = (t) => t + 1, Un = (t, e) => {
|
|
914
963
|
if (e.length === 0)
|
|
915
964
|
return 50;
|
|
916
|
-
const
|
|
917
|
-
if (d <=
|
|
965
|
+
const n = Pt(e.length), s = Ee(1, n), r = Ee(e.length, n), i = e.map((f) => Je(f.timestamp)), o = Math.min(...i), d = Math.max(...i);
|
|
966
|
+
if (d <= o)
|
|
918
967
|
return s;
|
|
919
|
-
const c = (
|
|
920
|
-
return s +
|
|
921
|
-
},
|
|
968
|
+
const c = (Je(t.timestamp) - o) / (d - o), w = Math.min(1, Math.max(0, c));
|
|
969
|
+
return s + w * (r - s);
|
|
970
|
+
}, xn = 8, Dn = 20, $n = (t, e = xn, n = Dn) => {
|
|
922
971
|
const s = /* @__PURE__ */ new Map();
|
|
923
972
|
if (t.length === 0)
|
|
924
973
|
return s;
|
|
925
974
|
const r = [...t].sort(
|
|
926
|
-
(
|
|
927
|
-
),
|
|
928
|
-
for (const
|
|
929
|
-
const d =
|
|
930
|
-
d &&
|
|
931
|
-
}
|
|
932
|
-
for (const
|
|
933
|
-
const d = [...
|
|
934
|
-
(
|
|
975
|
+
(o, d) => o.leftPercent - d.leftPercent || o.timestampMs - d.timestampMs || o.id.localeCompare(d.id)
|
|
976
|
+
), i = [];
|
|
977
|
+
for (const o of r) {
|
|
978
|
+
const d = i[i.length - 1];
|
|
979
|
+
d && o.leftPercent - d[d.length - 1].leftPercent < e ? d.push(o) : i.push([o]);
|
|
980
|
+
}
|
|
981
|
+
for (const o of i) {
|
|
982
|
+
const d = [...o].sort(
|
|
983
|
+
(w, f) => w.timestampMs - f.timestampMs || w.id.localeCompare(f.id)
|
|
935
984
|
), c = (d.length - 1) / 2;
|
|
936
|
-
d.forEach((
|
|
937
|
-
s.set(
|
|
985
|
+
d.forEach((w, f) => {
|
|
986
|
+
s.set(w.id, (f - c) * n);
|
|
938
987
|
});
|
|
939
988
|
}
|
|
940
989
|
return s;
|
|
941
|
-
},
|
|
990
|
+
}, Ge = (t, e = 0) => ({
|
|
942
991
|
left: `calc(${t / 100} * (100% - var(--agent-timeline-node-size)) + (var(--agent-timeline-node-size) / 2) + ${e}px)`,
|
|
943
992
|
transform: "translateX(-50%)"
|
|
944
|
-
}),
|
|
993
|
+
}), Mn = (t) => t.type !== "message-sent", Hn = ({
|
|
945
994
|
timeline: t,
|
|
946
995
|
isLoading: e,
|
|
947
|
-
error:
|
|
996
|
+
error: n,
|
|
948
997
|
onOpenChatSession: s
|
|
949
998
|
}) => {
|
|
950
|
-
const r = ((t == null ? void 0 : t.actionLog) ?? []).filter(
|
|
951
|
-
id: `action-${
|
|
952
|
-
leftPercent: Ee(
|
|
953
|
-
timestampMs:
|
|
954
|
-
})),
|
|
955
|
-
id:
|
|
956
|
-
leftPercent:
|
|
957
|
-
timestampMs:
|
|
958
|
-
})),
|
|
999
|
+
const r = ((t == null ? void 0 : t.actionLog) ?? []).filter(Mn), i = (t == null ? void 0 : t.chatSessions) ?? [], o = !e && !n && r.length === 0 && i.length === 0, d = Pt(r.length), c = r.map((h, u) => ({
|
|
1000
|
+
id: `action-${h.timestamp}-${u}`,
|
|
1001
|
+
leftPercent: Ee(Ln(u), d),
|
|
1002
|
+
timestampMs: Je(h.timestamp)
|
|
1003
|
+
})), w = i.map((h) => ({
|
|
1004
|
+
id: h.sessionId,
|
|
1005
|
+
leftPercent: Un(h, r),
|
|
1006
|
+
timestampMs: Je(h.timestamp)
|
|
1007
|
+
})), f = $n([
|
|
959
1008
|
...c,
|
|
960
|
-
...
|
|
1009
|
+
...w
|
|
961
1010
|
]);
|
|
962
|
-
return /* @__PURE__ */
|
|
1011
|
+
return /* @__PURE__ */ l(
|
|
963
1012
|
"section",
|
|
964
1013
|
{
|
|
965
1014
|
className: "agent-workspace__timeline",
|
|
966
1015
|
"aria-label": "Agent timeline",
|
|
967
1016
|
children: [
|
|
968
|
-
e && /* @__PURE__ */
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
!e && !
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
/* @__PURE__ */
|
|
1017
|
+
e && /* @__PURE__ */ a("p", { className: "agent-workspace__timeline-status", role: "status", children: "Loading timeline…" }),
|
|
1018
|
+
n && /* @__PURE__ */ a("p", { className: "agent-workspace__timeline-status", role: "alert", children: n || Et }),
|
|
1019
|
+
o && /* @__PURE__ */ a("p", { className: "agent-workspace__timeline-status", role: "status", children: "No timeline activity yet." }),
|
|
1020
|
+
!e && !n && !o && /* @__PURE__ */ l("div", { className: "agent-timeline", children: [
|
|
1021
|
+
/* @__PURE__ */ a("div", { className: "agent-timeline__track", "aria-hidden": "true" }),
|
|
1022
|
+
/* @__PURE__ */ l(
|
|
974
1023
|
"div",
|
|
975
1024
|
{
|
|
976
1025
|
className: "agent-timeline__station agent-timeline__station--terminus",
|
|
977
|
-
style:
|
|
1026
|
+
style: Ge(Ee(0, d)),
|
|
978
1027
|
children: [
|
|
979
|
-
/* @__PURE__ */
|
|
1028
|
+
/* @__PURE__ */ a(
|
|
980
1029
|
"span",
|
|
981
1030
|
{
|
|
982
1031
|
className: "agent-timeline__station-node agent-timeline__station-node--terminus",
|
|
983
1032
|
"aria-hidden": "true",
|
|
984
|
-
children: /* @__PURE__ */
|
|
1033
|
+
children: /* @__PURE__ */ a(O, { name: "arrow-right-from-line", size: 16, color: "currentColor" })
|
|
985
1034
|
}
|
|
986
1035
|
),
|
|
987
|
-
/* @__PURE__ */
|
|
1036
|
+
/* @__PURE__ */ a("span", { className: "agent-timeline__terminus-label", children: "Start" })
|
|
988
1037
|
]
|
|
989
1038
|
}
|
|
990
1039
|
),
|
|
991
|
-
r.map((
|
|
992
|
-
const
|
|
993
|
-
return /* @__PURE__ */
|
|
1040
|
+
r.map((h, u) => {
|
|
1041
|
+
const x = `action-${h.timestamp}-${u}`, v = c[u].leftPercent, b = h.type === "checklist-updated", A = h.type === "status-transition", D = b ? "checklist" : A ? "status" : "note";
|
|
1042
|
+
return /* @__PURE__ */ l(
|
|
994
1043
|
"div",
|
|
995
1044
|
{
|
|
996
|
-
className: `agent-timeline__station agent-timeline__station--${
|
|
997
|
-
style:
|
|
1045
|
+
className: `agent-timeline__station agent-timeline__station--${D}`,
|
|
1046
|
+
style: Ge(v, f.get(x) ?? 0),
|
|
998
1047
|
children: [
|
|
999
|
-
/* @__PURE__ */
|
|
1048
|
+
/* @__PURE__ */ l(
|
|
1000
1049
|
"button",
|
|
1001
1050
|
{
|
|
1002
1051
|
type: "button",
|
|
1003
|
-
className: `agent-timeline__station-node agent-timeline__station-node--${
|
|
1004
|
-
"aria-label": `${
|
|
1052
|
+
className: `agent-timeline__station-node agent-timeline__station-node--${D}`,
|
|
1053
|
+
"aria-label": `${Fe(h.type)}: ${Fe(h.entry)}`,
|
|
1005
1054
|
children: [
|
|
1006
|
-
|
|
1007
|
-
|
|
1055
|
+
b && /* @__PURE__ */ a(O, { name: "check-solid", size: 16, color: "currentColor" }),
|
|
1056
|
+
A && /* @__PURE__ */ a(O, { name: "iteration-ccw", size: 16, color: "currentColor" })
|
|
1008
1057
|
]
|
|
1009
1058
|
}
|
|
1010
1059
|
),
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1060
|
+
/* @__PURE__ */ l("div", { className: "agent-timeline__pill", role: "tooltip", children: [
|
|
1061
|
+
/* @__PURE__ */ a("strong", { className: "agent-timeline__pill-type", children: Fe(h.type) }),
|
|
1062
|
+
/* @__PURE__ */ a("span", { className: "agent-timeline__pill-entry", children: Fe(h.entry) }),
|
|
1063
|
+
/* @__PURE__ */ a("span", { className: "agent-timeline__pill-entry", children: rt(h.timestamp) })
|
|
1015
1064
|
] })
|
|
1016
1065
|
]
|
|
1017
1066
|
},
|
|
1018
|
-
|
|
1067
|
+
x
|
|
1019
1068
|
);
|
|
1020
1069
|
}),
|
|
1021
|
-
/* @__PURE__ */
|
|
1070
|
+
/* @__PURE__ */ l(
|
|
1022
1071
|
"div",
|
|
1023
1072
|
{
|
|
1024
1073
|
className: "agent-timeline__station agent-timeline__station--terminus",
|
|
1025
|
-
style:
|
|
1074
|
+
style: Ge(Ee(d - 1, d)),
|
|
1026
1075
|
children: [
|
|
1027
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ a(
|
|
1028
1077
|
"span",
|
|
1029
1078
|
{
|
|
1030
1079
|
className: "agent-timeline__station-node agent-timeline__station-node--terminus",
|
|
1031
1080
|
"aria-hidden": "true",
|
|
1032
|
-
children: /* @__PURE__ */
|
|
1081
|
+
children: /* @__PURE__ */ a(O, { name: "flag", size: 16, color: "currentColor" })
|
|
1033
1082
|
}
|
|
1034
1083
|
),
|
|
1035
|
-
/* @__PURE__ */
|
|
1084
|
+
/* @__PURE__ */ a("span", { className: "agent-timeline__terminus-label", children: "Finish" })
|
|
1036
1085
|
]
|
|
1037
1086
|
}
|
|
1038
1087
|
),
|
|
1039
|
-
|
|
1040
|
-
const
|
|
1041
|
-
return /* @__PURE__ */
|
|
1088
|
+
i.map((h, u) => {
|
|
1089
|
+
const x = w[u].leftPercent;
|
|
1090
|
+
return /* @__PURE__ */ l(
|
|
1042
1091
|
"div",
|
|
1043
1092
|
{
|
|
1044
1093
|
className: "agent-timeline__chat-station",
|
|
1045
|
-
style:
|
|
1046
|
-
|
|
1047
|
-
|
|
1094
|
+
style: Ge(
|
|
1095
|
+
x,
|
|
1096
|
+
f.get(h.sessionId) ?? 0
|
|
1048
1097
|
),
|
|
1049
1098
|
children: [
|
|
1050
|
-
/* @__PURE__ */
|
|
1099
|
+
/* @__PURE__ */ a(
|
|
1051
1100
|
"button",
|
|
1052
1101
|
{
|
|
1053
1102
|
type: "button",
|
|
1054
1103
|
className: "agent-timeline__chat-node",
|
|
1055
|
-
"aria-label": `Open chat session from ${
|
|
1056
|
-
onClick: () => s(
|
|
1057
|
-
children: /* @__PURE__ */
|
|
1104
|
+
"aria-label": `Open chat session from ${rt(h.timestamp)}`,
|
|
1105
|
+
onClick: () => s(h.sessionId),
|
|
1106
|
+
children: /* @__PURE__ */ a(O, { name: "sparkles", size: 16, color: "currentColor" })
|
|
1058
1107
|
}
|
|
1059
1108
|
),
|
|
1060
|
-
/* @__PURE__ */
|
|
1061
|
-
/* @__PURE__ */
|
|
1062
|
-
/* @__PURE__ */
|
|
1109
|
+
/* @__PURE__ */ l("div", { className: "agent-timeline__pill", role: "tooltip", children: [
|
|
1110
|
+
/* @__PURE__ */ a("strong", { className: "agent-timeline__pill-type", children: "Chat session" }),
|
|
1111
|
+
/* @__PURE__ */ a("span", { className: "agent-timeline__pill-entry", children: rt(h.timestamp) })
|
|
1063
1112
|
] })
|
|
1064
1113
|
]
|
|
1065
1114
|
},
|
|
1066
|
-
|
|
1115
|
+
h.sessionId
|
|
1067
1116
|
);
|
|
1068
1117
|
})
|
|
1069
1118
|
] })
|
|
1070
1119
|
]
|
|
1071
1120
|
}
|
|
1072
1121
|
);
|
|
1073
|
-
},
|
|
1122
|
+
}, zn = [
|
|
1074
1123
|
"I'll get the details and come back to you",
|
|
1075
1124
|
"Skip this for now"
|
|
1076
|
-
],
|
|
1077
|
-
var
|
|
1078
|
-
const e = (
|
|
1125
|
+
], Bn = (t) => {
|
|
1126
|
+
var n;
|
|
1127
|
+
const e = (n = t.prompt) != null && n.trim() ? t.prompt.trim() : `I need a bit more from you on "${t.task}". ${t.description} What can you tell me?`;
|
|
1079
1128
|
return {
|
|
1080
1129
|
id: `clarification-${Date.now()}`,
|
|
1081
|
-
author:
|
|
1130
|
+
author: te.agent,
|
|
1082
1131
|
text: e,
|
|
1083
|
-
followUpPrompts: t.clarificationPrompts ??
|
|
1132
|
+
followUpPrompts: t.clarificationPrompts ?? zn
|
|
1084
1133
|
};
|
|
1085
|
-
},
|
|
1134
|
+
}, me = (t) => ({
|
|
1086
1135
|
id: t.id,
|
|
1087
1136
|
text: t.text,
|
|
1088
|
-
type: t.author ===
|
|
1137
|
+
type: t.author === te.user ? nn : t.author === te.system ? an : Ct,
|
|
1089
1138
|
...t.followUpPrompts ? { followUpPrompts: t.followUpPrompts } : {}
|
|
1090
1139
|
});
|
|
1091
1140
|
class Te extends Error {
|
|
1092
|
-
constructor(e,
|
|
1093
|
-
super(s ?? `Agent service request failed (${e})`), this.name = "AgentServiceError", this.status = e, this.detail =
|
|
1141
|
+
constructor(e, n, s) {
|
|
1142
|
+
super(s ?? `Agent service request failed (${e})`), this.name = "AgentServiceError", this.status = e, this.detail = n;
|
|
1094
1143
|
}
|
|
1095
1144
|
}
|
|
1096
|
-
const
|
|
1145
|
+
const Fn = "/api/v1", M = {
|
|
1097
1146
|
agentDefinitions: "/agent-definitions",
|
|
1098
1147
|
agents: "/agents",
|
|
1099
1148
|
conversations: "/conversations",
|
|
1100
1149
|
tripOptions: "/trip-options",
|
|
1101
1150
|
demoDataset: "/demo/dataset"
|
|
1102
|
-
},
|
|
1151
|
+
}, K = {
|
|
1103
1152
|
GET: "GET",
|
|
1104
1153
|
POST: "POST"
|
|
1105
|
-
},
|
|
1154
|
+
}, Gn = {
|
|
1106
1155
|
error: "error"
|
|
1107
|
-
},
|
|
1156
|
+
}, qn = {
|
|
1108
1157
|
user: "user"
|
|
1109
|
-
},
|
|
1158
|
+
}, ge = {
|
|
1110
1159
|
acceptJson: "application/json",
|
|
1160
|
+
acceptHtml: "text/html",
|
|
1111
1161
|
acceptEventStream: "text/event-stream",
|
|
1112
1162
|
contentTypeJson: "application/json",
|
|
1113
1163
|
arborApplicationUrl: "X-Arbor-Application-Url"
|
|
1114
|
-
},
|
|
1115
|
-
|
|
1164
|
+
}, Kn = 100, Jn = (t) => {
|
|
1165
|
+
switch (t) {
|
|
1166
|
+
case pt.cancelled:
|
|
1167
|
+
return C.failed;
|
|
1168
|
+
case pt.archived:
|
|
1169
|
+
return C.complete;
|
|
1170
|
+
case C.hitl:
|
|
1171
|
+
case C.complete:
|
|
1172
|
+
case C.failed:
|
|
1173
|
+
case C["generating-a-response"]:
|
|
1174
|
+
return t;
|
|
1175
|
+
default:
|
|
1176
|
+
return C["generating-a-response"];
|
|
1177
|
+
}
|
|
1178
|
+
}, Wn = (t) => {
|
|
1179
|
+
switch (t) {
|
|
1180
|
+
case at.requires_attention:
|
|
1181
|
+
return G.hitl;
|
|
1182
|
+
case at.in_progress:
|
|
1183
|
+
case at.available:
|
|
1184
|
+
return G["generating-a-response"];
|
|
1185
|
+
case G.failed:
|
|
1186
|
+
case G.complete:
|
|
1187
|
+
case G.hitl:
|
|
1188
|
+
case G["generating-a-response"]:
|
|
1189
|
+
return t;
|
|
1190
|
+
default:
|
|
1191
|
+
return G["generating-a-response"];
|
|
1192
|
+
}
|
|
1193
|
+
}, Lt = (t) => ({
|
|
1194
|
+
ref: t.name,
|
|
1195
|
+
display_name: t.display_name,
|
|
1196
|
+
agent_intent: t.agent_intent ?? "",
|
|
1197
|
+
description: t.description
|
|
1198
|
+
}), Da = (t) => ({
|
|
1199
|
+
id: t.id,
|
|
1200
|
+
name: t.name,
|
|
1201
|
+
...t.has_run_before ? { hasRunBefore: t.has_run_before } : {}
|
|
1202
|
+
}), Vn = new Set(Object.values(de)), Yn = (t) => Vn.has(t) ? t : de.document_html, jn = (t) => ({
|
|
1203
|
+
id: t.id,
|
|
1204
|
+
type: Yn(t.type),
|
|
1205
|
+
title: t.title,
|
|
1206
|
+
createdDatetime: t.created_datetime,
|
|
1207
|
+
lastUpdatedDatetime: t.last_updated_datetime,
|
|
1208
|
+
misRecordUrl: t.mis_record_url
|
|
1209
|
+
}), Xn = (t) => ({
|
|
1210
|
+
resources: t.resources.map(jn),
|
|
1211
|
+
pageNumber: t.page_number,
|
|
1212
|
+
pageSize: t.page_size,
|
|
1213
|
+
totalRecords: t.total_records
|
|
1214
|
+
}), Qn = (t) => ({
|
|
1215
|
+
actionLog: (t.action_log ?? []).map((e) => ({
|
|
1216
|
+
timestamp: e.timestamp,
|
|
1217
|
+
type: e.type,
|
|
1218
|
+
entry: e.entry,
|
|
1219
|
+
origin: e.origin
|
|
1220
|
+
})),
|
|
1221
|
+
chatSessions: (t.chat_sessions ?? []).map((e) => ({
|
|
1222
|
+
sessionId: e.session_id,
|
|
1223
|
+
timestamp: e.timestamp
|
|
1224
|
+
}))
|
|
1225
|
+
}), vt = (t) => {
|
|
1226
|
+
var n;
|
|
1227
|
+
const e = t.invocation_id ?? t.id;
|
|
1228
|
+
return {
|
|
1229
|
+
id: t.id,
|
|
1230
|
+
invocation_id: e,
|
|
1231
|
+
agent_definition_ref: t.agent_definition_ref,
|
|
1232
|
+
...t.agent_intent ? { agent_intent: t.agent_intent } : {},
|
|
1233
|
+
invocation_name: ((n = t.invocation_name) == null ? void 0 : n.trim()) || t.agent_definition_ref,
|
|
1234
|
+
application_id: t.application_id,
|
|
1235
|
+
...t.application_name ? { application_name: t.application_name } : {},
|
|
1236
|
+
created_by: t.created_by,
|
|
1237
|
+
status: Jn(t.status),
|
|
1238
|
+
context_ref: t.context_ref ?? null,
|
|
1239
|
+
checklist_ref: t.checklist_ref ?? null
|
|
1240
|
+
};
|
|
1241
|
+
}, Ut = (t) => {
|
|
1242
|
+
var e;
|
|
1243
|
+
return {
|
|
1244
|
+
task: t.task ?? t.name ?? t.label ?? hn,
|
|
1245
|
+
status: Wn(t.status),
|
|
1246
|
+
description: t.description ?? "",
|
|
1247
|
+
...t.prompt ? { prompt: t.prompt } : {},
|
|
1248
|
+
...(e = t.follow_up_prompts) != null && e.length ? { clarificationPrompts: t.follow_up_prompts } : {}
|
|
1249
|
+
};
|
|
1250
|
+
}, Zn = (t) => Array.isArray(t) ? t : t.checklist_items ?? t.checklist ?? t.items ?? [], xt = (t, e, n) => {
|
|
1251
|
+
var i;
|
|
1252
|
+
const s = !Array.isArray(e) && (e.opening_message || (i = e.opening_follow_up_prompts) != null && i.length) ? e : n, r = s ? Ye(s) : void 0;
|
|
1253
|
+
return {
|
|
1254
|
+
invocation_id: t,
|
|
1255
|
+
checklist: Zn(e).map(Ut),
|
|
1256
|
+
...r ? { openingMessage: r } : {}
|
|
1257
|
+
};
|
|
1258
|
+
}, ea = (t, e) => {
|
|
1259
|
+
const n = Ye(e);
|
|
1260
|
+
return {
|
|
1261
|
+
invocation_id: e.invocation_id ?? t,
|
|
1262
|
+
checklist: (e.checklist_items ?? []).map(Ut),
|
|
1263
|
+
...n ? { openingMessage: n } : {}
|
|
1264
|
+
};
|
|
1265
|
+
}, Ye = (t) => {
|
|
1266
|
+
var n, s;
|
|
1267
|
+
const e = (n = t.opening_message) == null ? void 0 : n.trim();
|
|
1268
|
+
if (e)
|
|
1269
|
+
return {
|
|
1270
|
+
id: Tt,
|
|
1271
|
+
author: te.agent,
|
|
1272
|
+
text: e,
|
|
1273
|
+
...(s = t.opening_follow_up_prompts) != null && s.length ? { followUpPrompts: t.opening_follow_up_prompts } : {}
|
|
1274
|
+
};
|
|
1275
|
+
}, ta = (t) => t.filter(
|
|
1276
|
+
(e) => (e.role === "user" || e.role === "assistant") && typeof e.content == "string" && e.content.length > 0 && e.message_type !== "tool_request"
|
|
1277
|
+
).map((e) => ({
|
|
1278
|
+
id: e.message_id,
|
|
1279
|
+
author: e.role === "user" ? te.user : te.agent,
|
|
1280
|
+
text: e.content
|
|
1281
|
+
})), na = /:invocationId\b/g, aa = /:resourceId\b/g, sa = (t) => t.trim().replace(/^Bearer\s+/i, ""), ra = (t) => t.endsWith("/") ? t.slice(0, -1) : t;
|
|
1282
|
+
class lt {
|
|
1116
1283
|
constructor(e) {
|
|
1117
1284
|
var s;
|
|
1118
|
-
this.baseUrl =
|
|
1119
|
-
const
|
|
1120
|
-
this.token =
|
|
1285
|
+
this.baseUrl = ra(e.baseUrl ?? "");
|
|
1286
|
+
const n = (s = e.token) == null ? void 0 : s.trim();
|
|
1287
|
+
this.token = n ? sa(n) : void 0, this.customHeaders = e.headers, this.urls = e.urls ?? {}, this.fetchImpl = e.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1121
1288
|
}
|
|
1122
1289
|
// Replaces the extra headers merged into every subsequent request,
|
|
1123
1290
|
// without recreating the client (e.g. an application-URL header that
|
|
@@ -1127,421 +1294,333 @@ class nt {
|
|
|
1127
1294
|
}
|
|
1128
1295
|
async listAgentDefinitions() {
|
|
1129
1296
|
return (await this.request(
|
|
1130
|
-
|
|
1131
|
-
this.resolveUrl("agentDefinitions",
|
|
1297
|
+
K.GET,
|
|
1298
|
+
this.resolveUrl("agentDefinitions", M.agentDefinitions)
|
|
1132
1299
|
)).agent_definitions ?? [];
|
|
1133
1300
|
}
|
|
1134
1301
|
getAgentDefinition(e) {
|
|
1135
1302
|
return this.request(
|
|
1136
|
-
|
|
1137
|
-
this.apiUrl(
|
|
1138
|
-
`${G.agentDefinitions}/${encodeURIComponent(e)}`
|
|
1139
|
-
)
|
|
1303
|
+
K.GET,
|
|
1304
|
+
this.apiUrl(`${M.agentDefinitions}/${encodeURIComponent(e)}`)
|
|
1140
1305
|
);
|
|
1141
1306
|
}
|
|
1142
1307
|
listTripOptions() {
|
|
1143
|
-
return this.request(
|
|
1144
|
-
q.GET,
|
|
1145
|
-
this.apiUrl(G.tripOptions)
|
|
1146
|
-
);
|
|
1308
|
+
return this.request(K.GET, this.apiUrl(M.tripOptions));
|
|
1147
1309
|
}
|
|
1148
1310
|
getDataset() {
|
|
1149
1311
|
return this.request(
|
|
1150
|
-
|
|
1151
|
-
this.apiUrl(
|
|
1312
|
+
K.GET,
|
|
1313
|
+
this.apiUrl(M.demoDataset)
|
|
1152
1314
|
);
|
|
1153
1315
|
}
|
|
1154
1316
|
setDataset(e) {
|
|
1155
1317
|
return this.request(
|
|
1156
|
-
|
|
1157
|
-
this.apiUrl(
|
|
1318
|
+
K.POST,
|
|
1319
|
+
this.apiUrl(M.demoDataset),
|
|
1158
1320
|
{ dataset: e }
|
|
1159
1321
|
);
|
|
1160
1322
|
}
|
|
1161
1323
|
listAgents(e = {}) {
|
|
1162
|
-
const
|
|
1163
|
-
e.status &&
|
|
1164
|
-
const s =
|
|
1324
|
+
const n = new URLSearchParams();
|
|
1325
|
+
e.status && n.set("status", e.status), e.agentDefinitionRef && n.set("agent_definition_ref", e.agentDefinitionRef);
|
|
1326
|
+
const s = n.toString() ? `?${n.toString()}` : "";
|
|
1165
1327
|
return this.request(
|
|
1166
|
-
|
|
1167
|
-
`${this.resolveUrl("agents",
|
|
1328
|
+
K.GET,
|
|
1329
|
+
`${this.resolveUrl("agents", M.agents)}${s}`
|
|
1168
1330
|
);
|
|
1169
1331
|
}
|
|
1170
|
-
createAgent(e,
|
|
1171
|
-
var
|
|
1332
|
+
createAgent(e, n = {}) {
|
|
1333
|
+
var o, d;
|
|
1172
1334
|
const s = {
|
|
1173
1335
|
agent_definition_ref: e
|
|
1174
|
-
}, r = (
|
|
1175
|
-
return r && (s.invocation_name = r),
|
|
1176
|
-
|
|
1177
|
-
this.resolveUrl("agents",
|
|
1336
|
+
}, r = (o = n.invocationName) == null ? void 0 : o.trim(), i = (d = n.agentIntent) == null ? void 0 : d.trim();
|
|
1337
|
+
return r && (s.invocation_name = r), i && (s.agent_intent = i), this.request(
|
|
1338
|
+
K.POST,
|
|
1339
|
+
this.resolveUrl("agents", M.agents),
|
|
1178
1340
|
s
|
|
1179
1341
|
);
|
|
1180
1342
|
}
|
|
1181
1343
|
getAgent(e) {
|
|
1182
1344
|
return this.request(
|
|
1183
|
-
|
|
1184
|
-
this.resolveUrl(
|
|
1185
|
-
"agent",
|
|
1186
|
-
`${G.agents}/${encodeURIComponent(e)}`,
|
|
1187
|
-
e
|
|
1188
|
-
)
|
|
1345
|
+
K.GET,
|
|
1346
|
+
this.resolveUrl("agent", `${M.agents}/${encodeURIComponent(e)}`, e)
|
|
1189
1347
|
);
|
|
1190
1348
|
}
|
|
1191
1349
|
getAgentChecklist(e) {
|
|
1192
1350
|
return this.request(
|
|
1193
|
-
|
|
1351
|
+
K.GET,
|
|
1194
1352
|
this.resolveUrl(
|
|
1195
1353
|
"agentChecklist",
|
|
1196
|
-
`${
|
|
1354
|
+
`${M.agents}/${encodeURIComponent(e)}/checklist`,
|
|
1197
1355
|
e
|
|
1198
1356
|
)
|
|
1199
1357
|
);
|
|
1200
1358
|
}
|
|
1201
|
-
getAgentResources(e) {
|
|
1359
|
+
getAgentResources(e, n = {}) {
|
|
1360
|
+
const s = new URLSearchParams();
|
|
1361
|
+
n.pageNumber !== void 0 && s.set("page_number", String(n.pageNumber)), n.pageSize !== void 0 && s.set("page_size", String(n.pageSize)), n.type && s.set("type", n.type);
|
|
1362
|
+
const r = s.toString(), i = this.resolveUrl(
|
|
1363
|
+
"agentResources",
|
|
1364
|
+
`${M.agents}/${encodeURIComponent(e)}/resources`,
|
|
1365
|
+
e
|
|
1366
|
+
);
|
|
1202
1367
|
return this.request(
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
"agentResources",
|
|
1206
|
-
`${G.agents}/${encodeURIComponent(e)}/resources`,
|
|
1207
|
-
e
|
|
1208
|
-
)
|
|
1368
|
+
K.GET,
|
|
1369
|
+
r ? `${i}?${r}` : i
|
|
1209
1370
|
);
|
|
1210
1371
|
}
|
|
1372
|
+
async listAllAgentResources(e) {
|
|
1373
|
+
const n = Kn;
|
|
1374
|
+
let s = 1;
|
|
1375
|
+
const r = [];
|
|
1376
|
+
let i = Number.POSITIVE_INFINITY;
|
|
1377
|
+
for (; r.length < i; ) {
|
|
1378
|
+
const o = Xn(
|
|
1379
|
+
await this.getAgentResources(e, { pageNumber: s, pageSize: n })
|
|
1380
|
+
);
|
|
1381
|
+
if (i = o.totalRecords, o.resources.length === 0 || (r.push(...o.resources), r.length >= i))
|
|
1382
|
+
break;
|
|
1383
|
+
s += 1;
|
|
1384
|
+
}
|
|
1385
|
+
return r;
|
|
1386
|
+
}
|
|
1387
|
+
getAgentResourceHtml(e, n) {
|
|
1388
|
+
return this.requestText(K.GET, this.resolveResourceHtmlUrl(e, n));
|
|
1389
|
+
}
|
|
1211
1390
|
getAgentTimeline(e) {
|
|
1212
1391
|
return this.request(
|
|
1213
|
-
|
|
1392
|
+
K.GET,
|
|
1214
1393
|
this.resolveUrl(
|
|
1215
1394
|
"agentTimeline",
|
|
1216
|
-
`${
|
|
1395
|
+
`${M.agents}/${encodeURIComponent(e)}/agent-timeline`,
|
|
1217
1396
|
e
|
|
1218
1397
|
)
|
|
1219
1398
|
);
|
|
1220
1399
|
}
|
|
1221
1400
|
getAgentContext(e) {
|
|
1222
1401
|
return this.request(
|
|
1223
|
-
|
|
1224
|
-
this.apiUrl(
|
|
1225
|
-
`${G.agents}/${encodeURIComponent(e)}/context`
|
|
1226
|
-
)
|
|
1402
|
+
K.GET,
|
|
1403
|
+
this.apiUrl(`${M.agents}/${encodeURIComponent(e)}/context`)
|
|
1227
1404
|
);
|
|
1228
1405
|
}
|
|
1229
1406
|
cancelAgent(e) {
|
|
1230
1407
|
return this.request(
|
|
1231
|
-
|
|
1232
|
-
this.apiUrl(
|
|
1233
|
-
`${G.agents}/${encodeURIComponent(e)}/cancel`
|
|
1234
|
-
)
|
|
1408
|
+
K.POST,
|
|
1409
|
+
this.apiUrl(`${M.agents}/${encodeURIComponent(e)}/cancel`)
|
|
1235
1410
|
);
|
|
1236
1411
|
}
|
|
1237
1412
|
archiveAgent(e) {
|
|
1238
1413
|
return this.request(
|
|
1239
|
-
|
|
1240
|
-
this.apiUrl(
|
|
1241
|
-
`${G.agents}/${encodeURIComponent(e)}/archive`
|
|
1242
|
-
)
|
|
1414
|
+
K.POST,
|
|
1415
|
+
this.apiUrl(`${M.agents}/${encodeURIComponent(e)}/archive`)
|
|
1243
1416
|
);
|
|
1244
1417
|
}
|
|
1245
1418
|
getConversation(e) {
|
|
1246
1419
|
return this.request(
|
|
1247
|
-
|
|
1420
|
+
K.GET,
|
|
1248
1421
|
this.resolveUrl(
|
|
1249
1422
|
"agentConversation",
|
|
1250
|
-
`${
|
|
1423
|
+
`${M.conversations}/${encodeURIComponent(e)}`,
|
|
1251
1424
|
e
|
|
1252
1425
|
)
|
|
1253
1426
|
);
|
|
1254
1427
|
}
|
|
1255
1428
|
// Streams a chat turn. Resolves with the final SSE event; `onEvent` fires
|
|
1256
1429
|
// for every event as it arrives.
|
|
1257
|
-
async chat(e,
|
|
1258
|
-
const r = !!(s.uploadFiles && s.uploadFiles.length > 0),
|
|
1430
|
+
async chat(e, n, s = {}) {
|
|
1431
|
+
const r = !!(s.uploadFiles && s.uploadFiles.length > 0), i = await this.fetchImpl(
|
|
1259
1432
|
this.resolveUrl(
|
|
1260
1433
|
"agentChat",
|
|
1261
|
-
`${
|
|
1434
|
+
`${M.agents}/${encodeURIComponent(e)}/chat`,
|
|
1262
1435
|
e
|
|
1263
1436
|
),
|
|
1264
1437
|
{
|
|
1265
|
-
method:
|
|
1438
|
+
method: K.POST,
|
|
1266
1439
|
headers: {
|
|
1267
1440
|
...this.customHeaders,
|
|
1268
1441
|
...this.authHeaders(),
|
|
1269
|
-
Accept:
|
|
1442
|
+
Accept: ge.acceptEventStream,
|
|
1270
1443
|
// Let the browser set the multipart boundary when uploading.
|
|
1271
|
-
...r ? {} : { "Content-Type":
|
|
1444
|
+
...r ? {} : { "Content-Type": ge.contentTypeJson }
|
|
1272
1445
|
},
|
|
1273
|
-
body: r ?
|
|
1446
|
+
body: r ? ia(n, s.uploadFiles ?? []) : JSON.stringify(n),
|
|
1274
1447
|
signal: s.signal
|
|
1275
1448
|
}
|
|
1276
1449
|
);
|
|
1277
|
-
if (!
|
|
1278
|
-
throw await this.toError(
|
|
1279
|
-
if (!
|
|
1280
|
-
throw new Te(
|
|
1281
|
-
|
|
1282
|
-
null,
|
|
1283
|
-
"Chat response contained no stream body"
|
|
1284
|
-
);
|
|
1285
|
-
return this.consumeSse(l.body, s.onEvent);
|
|
1450
|
+
if (!i.ok)
|
|
1451
|
+
throw await this.toError(i);
|
|
1452
|
+
if (!i.body)
|
|
1453
|
+
throw new Te(i.status, null, "Chat response contained no stream body");
|
|
1454
|
+
return this.consumeSse(i.body, s.onEvent);
|
|
1286
1455
|
}
|
|
1287
1456
|
authHeaders() {
|
|
1288
1457
|
return this.token ? { Authorization: `Bearer ${this.token}` } : {};
|
|
1289
1458
|
}
|
|
1290
1459
|
// Builds a URL from the base url + shared API prefix + route.
|
|
1291
1460
|
apiUrl(e) {
|
|
1292
|
-
return `${this.baseUrl}${
|
|
1461
|
+
return `${this.baseUrl}${Fn}${e}`;
|
|
1293
1462
|
}
|
|
1294
1463
|
// Resolves the URL for an operation, preferring a per-operation override
|
|
1295
1464
|
// (with `:invocationId` substituted) and falling back to the base url.
|
|
1296
|
-
resolveUrl(e,
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
)
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
{
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1465
|
+
resolveUrl(e, n, s, r) {
|
|
1466
|
+
const i = this.urls[e];
|
|
1467
|
+
if (!i)
|
|
1468
|
+
return this.apiUrl(n);
|
|
1469
|
+
let o = i;
|
|
1470
|
+
return s && (o = o.replace(na, encodeURIComponent(s))), r && (o = o.replace(aa, encodeURIComponent(r))), o;
|
|
1471
|
+
}
|
|
1472
|
+
resolveResourceHtmlUrl(e, n) {
|
|
1473
|
+
return this.urls.agentResourceHtml ? this.resolveUrl(
|
|
1474
|
+
"agentResourceHtml",
|
|
1475
|
+
`${M.agents}/${encodeURIComponent(e)}/resources/${encodeURIComponent(
|
|
1476
|
+
n
|
|
1477
|
+
)}`,
|
|
1478
|
+
e,
|
|
1479
|
+
n
|
|
1480
|
+
) : this.urls.agentResources ? `${this.resolveUrl(
|
|
1481
|
+
"agentResources",
|
|
1482
|
+
`${M.agents}/${encodeURIComponent(e)}/resources`,
|
|
1483
|
+
e
|
|
1484
|
+
).replace(/\/$/, "")}/${encodeURIComponent(n)}` : this.apiUrl(
|
|
1485
|
+
`${M.agents}/${encodeURIComponent(e)}/resources/${encodeURIComponent(
|
|
1486
|
+
n
|
|
1487
|
+
)}`
|
|
1316
1488
|
);
|
|
1489
|
+
}
|
|
1490
|
+
async request(e, n, s) {
|
|
1491
|
+
const r = await this.fetchImpl(n, {
|
|
1492
|
+
method: e,
|
|
1493
|
+
headers: {
|
|
1494
|
+
...this.customHeaders,
|
|
1495
|
+
...this.authHeaders(),
|
|
1496
|
+
Accept: ge.acceptJson,
|
|
1497
|
+
...s === void 0 ? {} : { "Content-Type": ge.contentTypeJson }
|
|
1498
|
+
},
|
|
1499
|
+
...s === void 0 ? {} : { body: JSON.stringify(s) }
|
|
1500
|
+
});
|
|
1317
1501
|
if (!r.ok)
|
|
1318
1502
|
throw await this.toError(r);
|
|
1319
1503
|
if (r.status !== 204)
|
|
1320
1504
|
return await r.json();
|
|
1321
1505
|
}
|
|
1506
|
+
async requestText(e, n) {
|
|
1507
|
+
const s = await this.fetchImpl(n, {
|
|
1508
|
+
method: e,
|
|
1509
|
+
headers: {
|
|
1510
|
+
...this.customHeaders,
|
|
1511
|
+
...this.authHeaders(),
|
|
1512
|
+
Accept: ge.acceptHtml
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
if (!s.ok)
|
|
1516
|
+
throw await this.toError(s);
|
|
1517
|
+
return s.text();
|
|
1518
|
+
}
|
|
1322
1519
|
async toError(e) {
|
|
1323
|
-
let
|
|
1520
|
+
let n = null;
|
|
1324
1521
|
try {
|
|
1325
|
-
|
|
1522
|
+
n = await e.json();
|
|
1326
1523
|
} catch {
|
|
1327
1524
|
}
|
|
1328
1525
|
return new Te(
|
|
1329
1526
|
e.status,
|
|
1330
|
-
|
|
1527
|
+
n,
|
|
1331
1528
|
`Agent service request failed (${e.status} ${e.statusText})`
|
|
1332
1529
|
);
|
|
1333
1530
|
}
|
|
1334
|
-
async consumeSse(e,
|
|
1531
|
+
async consumeSse(e, n) {
|
|
1335
1532
|
const s = e.getReader(), r = new TextDecoder();
|
|
1336
|
-
let
|
|
1533
|
+
let i = "", o;
|
|
1337
1534
|
const d = (c) => {
|
|
1338
|
-
const { event:
|
|
1339
|
-
if (
|
|
1535
|
+
const { event: w, data: f } = oa(c);
|
|
1536
|
+
if (f === null)
|
|
1340
1537
|
return;
|
|
1341
|
-
if (
|
|
1342
|
-
const
|
|
1343
|
-
throw new Te(
|
|
1344
|
-
502,
|
|
1345
|
-
v,
|
|
1346
|
-
(v == null ? void 0 : v.message) ?? "Chat stream error"
|
|
1347
|
-
);
|
|
1538
|
+
if (w === Gn.error) {
|
|
1539
|
+
const u = wt(f);
|
|
1540
|
+
throw new Te(502, u, (u == null ? void 0 : u.message) ?? "Chat stream error");
|
|
1348
1541
|
}
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1542
|
+
const h = wt(f);
|
|
1543
|
+
h && (o = h, n == null || n(h));
|
|
1351
1544
|
};
|
|
1352
1545
|
for (; ; ) {
|
|
1353
|
-
const { done: c, value:
|
|
1546
|
+
const { done: c, value: w } = await s.read();
|
|
1354
1547
|
if (c)
|
|
1355
1548
|
break;
|
|
1356
|
-
|
|
1357
|
-
const
|
|
1549
|
+
i += r.decode(w, { stream: !0 });
|
|
1550
|
+
const f = i.split(`
|
|
1358
1551
|
|
|
1359
1552
|
`);
|
|
1360
|
-
|
|
1361
|
-
for (const
|
|
1362
|
-
d(
|
|
1553
|
+
i = f.pop() ?? "";
|
|
1554
|
+
for (const h of f)
|
|
1555
|
+
d(h);
|
|
1363
1556
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
throw new Te(
|
|
1366
|
-
|
|
1367
|
-
null,
|
|
1368
|
-
"Chat stream ended without any events"
|
|
1369
|
-
);
|
|
1370
|
-
return i;
|
|
1557
|
+
if (i.trim() && d(i), !o)
|
|
1558
|
+
throw new Te(502, null, "Chat stream ended without any events");
|
|
1559
|
+
return o;
|
|
1371
1560
|
}
|
|
1372
1561
|
}
|
|
1373
|
-
const
|
|
1562
|
+
const oa = (t) => {
|
|
1374
1563
|
let e = null;
|
|
1375
|
-
const
|
|
1564
|
+
const n = [];
|
|
1376
1565
|
for (const s of t.split(`
|
|
1377
1566
|
`)) {
|
|
1378
1567
|
const r = s.trimEnd();
|
|
1379
|
-
r.startsWith("event:") ? e = r.slice(6).trim() : r.startsWith("data:") &&
|
|
1568
|
+
r.startsWith("event:") ? e = r.slice(6).trim() : r.startsWith("data:") && n.push(r.slice(5).trim());
|
|
1380
1569
|
}
|
|
1381
1570
|
return {
|
|
1382
1571
|
event: e,
|
|
1383
|
-
data:
|
|
1572
|
+
data: n.length > 0 ? n.join(`
|
|
1384
1573
|
`) : null
|
|
1385
1574
|
};
|
|
1386
|
-
},
|
|
1575
|
+
}, wt = (t) => {
|
|
1387
1576
|
try {
|
|
1388
1577
|
return JSON.parse(t);
|
|
1389
1578
|
} catch {
|
|
1390
1579
|
return;
|
|
1391
1580
|
}
|
|
1392
1581
|
};
|
|
1393
|
-
function
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1582
|
+
function ia(t, e) {
|
|
1583
|
+
const n = new FormData();
|
|
1584
|
+
n.append("body", JSON.stringify(t));
|
|
1396
1585
|
for (const s of e)
|
|
1397
|
-
|
|
1398
|
-
return
|
|
1586
|
+
n.append("files", s, s.name);
|
|
1587
|
+
return n;
|
|
1399
1588
|
}
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
return T.failed;
|
|
1404
|
-
case it.archived:
|
|
1405
|
-
return T.complete;
|
|
1406
|
-
case T.hitl:
|
|
1407
|
-
case T.complete:
|
|
1408
|
-
case T.failed:
|
|
1409
|
-
case T["generating-a-response"]:
|
|
1410
|
-
return t;
|
|
1411
|
-
default:
|
|
1412
|
-
return T["generating-a-response"];
|
|
1413
|
-
}
|
|
1414
|
-
}, Dn = (t) => {
|
|
1415
|
-
switch (t) {
|
|
1416
|
-
case Xe.requires_attention:
|
|
1417
|
-
return F.hitl;
|
|
1418
|
-
case Xe.in_progress:
|
|
1419
|
-
case Xe.available:
|
|
1420
|
-
return F["generating-a-response"];
|
|
1421
|
-
case F.failed:
|
|
1422
|
-
case F.complete:
|
|
1423
|
-
case F.hitl:
|
|
1424
|
-
case F["generating-a-response"]:
|
|
1425
|
-
return t;
|
|
1426
|
-
default:
|
|
1427
|
-
return F["generating-a-response"];
|
|
1428
|
-
}
|
|
1429
|
-
}, St = (t) => ({
|
|
1430
|
-
ref: t.name,
|
|
1431
|
-
display_name: t.display_name,
|
|
1432
|
-
agent_intent: t.agent_intent ?? "",
|
|
1433
|
-
description: t.description
|
|
1434
|
-
}), fa = (t) => ({
|
|
1435
|
-
id: t.id,
|
|
1436
|
-
name: t.name,
|
|
1437
|
-
...t.has_run_before ? { hasRunBefore: t.has_run_before } : {}
|
|
1438
|
-
}), Mn = new Set(Object.values(pe)), Un = (t) => t && Mn.has(t) ? t : pe.LINK, $n = (t) => ({
|
|
1439
|
-
uri: t.uri ?? "",
|
|
1440
|
-
type: Un(t.type),
|
|
1441
|
-
name: t.name ?? "",
|
|
1442
|
-
description: t.description ?? ""
|
|
1443
|
-
}), bt = (t) => (Array.isArray(t) ? t : t.resources ?? []).map($n), Hn = (t) => ({
|
|
1444
|
-
actionLog: (t.action_log ?? []).map((e) => ({
|
|
1445
|
-
timestamp: e.timestamp,
|
|
1446
|
-
type: e.type,
|
|
1447
|
-
entry: e.entry,
|
|
1448
|
-
origin: e.origin
|
|
1449
|
-
})),
|
|
1450
|
-
chatSessions: (t.chat_sessions ?? []).map((e) => ({
|
|
1451
|
-
sessionId: e.session_id,
|
|
1452
|
-
timestamp: e.timestamp
|
|
1453
|
-
}))
|
|
1454
|
-
}), dt = (t) => {
|
|
1455
|
-
var a;
|
|
1456
|
-
const e = t.invocation_id ?? t.id;
|
|
1457
|
-
return {
|
|
1458
|
-
id: t.id,
|
|
1459
|
-
invocation_id: e,
|
|
1460
|
-
agent_definition_ref: t.agent_definition_ref,
|
|
1461
|
-
...t.agent_intent ? { agent_intent: t.agent_intent } : {},
|
|
1462
|
-
invocation_name: ((a = t.invocation_name) == null ? void 0 : a.trim()) || t.agent_definition_ref,
|
|
1463
|
-
application_id: t.application_id,
|
|
1464
|
-
...t.application_name ? { application_name: t.application_name } : {},
|
|
1465
|
-
created_by: t.created_by,
|
|
1466
|
-
status: xn(t.status),
|
|
1467
|
-
context_ref: t.context_ref ?? null,
|
|
1468
|
-
checklist_ref: t.checklist_ref ?? null
|
|
1469
|
-
};
|
|
1470
|
-
}, Ct = (t) => {
|
|
1471
|
-
var e;
|
|
1472
|
-
return {
|
|
1473
|
-
task: t.task ?? t.name ?? t.label ?? Yt,
|
|
1474
|
-
status: Dn(t.status),
|
|
1475
|
-
description: t.description ?? "",
|
|
1476
|
-
...t.prompt ? { prompt: t.prompt } : {},
|
|
1477
|
-
...(e = t.follow_up_prompts) != null && e.length ? { clarificationPrompts: t.follow_up_prompts } : {}
|
|
1478
|
-
};
|
|
1479
|
-
}, Bn = (t) => Array.isArray(t) ? t : t.checklist_items ?? t.checklist ?? t.items ?? [], Tt = (t, e, a) => {
|
|
1480
|
-
var l;
|
|
1481
|
-
const s = !Array.isArray(e) && (e.opening_message || (l = e.opening_follow_up_prompts) != null && l.length) ? e : a, r = s ? Fe(s) : void 0;
|
|
1482
|
-
return {
|
|
1483
|
-
invocation_id: t,
|
|
1484
|
-
checklist: Bn(e).map(Ct),
|
|
1485
|
-
...r ? { openingMessage: r } : {}
|
|
1486
|
-
};
|
|
1487
|
-
}, Fn = (t, e) => {
|
|
1488
|
-
const a = Fe(e);
|
|
1489
|
-
return {
|
|
1490
|
-
invocation_id: e.invocation_id ?? t,
|
|
1491
|
-
checklist: (e.checklist_items ?? []).map(Ct),
|
|
1492
|
-
...a ? { openingMessage: a } : {}
|
|
1493
|
-
};
|
|
1494
|
-
}, Fe = (t) => {
|
|
1495
|
-
var a, s;
|
|
1496
|
-
const e = (a = t.opening_message) == null ? void 0 : a.trim();
|
|
1497
|
-
if (e)
|
|
1498
|
-
return {
|
|
1499
|
-
id: vt,
|
|
1500
|
-
author: ne.agent,
|
|
1501
|
-
text: e,
|
|
1502
|
-
...(s = t.opening_follow_up_prompts) != null && s.length ? { followUpPrompts: t.opening_follow_up_prompts } : {}
|
|
1503
|
-
};
|
|
1504
|
-
}, zn = (t) => t.filter(
|
|
1505
|
-
(e) => (e.role === "user" || e.role === "assistant") && typeof e.content == "string" && e.content.length > 0 && e.message_type !== "tool_request"
|
|
1506
|
-
).map((e) => ({
|
|
1507
|
-
id: e.message_id,
|
|
1508
|
-
author: e.role === "user" ? ne.user : ne.agent,
|
|
1509
|
-
text: e.content
|
|
1510
|
-
})), Gn = {
|
|
1511
|
-
id: vt,
|
|
1512
|
-
author: ne.agent,
|
|
1589
|
+
const la = {
|
|
1590
|
+
id: Tt,
|
|
1591
|
+
author: te.agent,
|
|
1513
1592
|
text: "Type a question or upload a file. You can ask it how it's progressing, or send an instruction and it'll act on it."
|
|
1514
1593
|
};
|
|
1515
|
-
let
|
|
1516
|
-
const
|
|
1594
|
+
let yt = 0;
|
|
1595
|
+
const ca = (t) => (yt += 1, `${t}-${Date.now()}-${yt}`), da = (t) => {
|
|
1517
1596
|
const e = t.destination ? ` to ${t.destination}` : "";
|
|
1518
1597
|
return `Let's get started on ${t.tripName.trim() || t.destination.trim() || "this task"}${e}. What will you do first?`;
|
|
1519
1598
|
};
|
|
1520
|
-
class
|
|
1521
|
-
constructor(e,
|
|
1522
|
-
this.seededChecklist = [], this.client = e, this.agentId =
|
|
1599
|
+
class ga {
|
|
1600
|
+
constructor(e, n, s = {}) {
|
|
1601
|
+
this.seededChecklist = [], this.client = e, this.agentId = n, this.chatId = s.chatId ?? n, this.opening = s.openingMessage ?? la, this.model = s.model;
|
|
1523
1602
|
}
|
|
1524
1603
|
openingMessage() {
|
|
1525
1604
|
return this.opening;
|
|
1526
1605
|
}
|
|
1527
1606
|
async bootstrapConversation() {
|
|
1528
|
-
const e = await this.client.getConversation(this.chatId),
|
|
1529
|
-
return
|
|
1607
|
+
const e = await this.client.getConversation(this.chatId), n = ta(e.messages);
|
|
1608
|
+
return n.length === 0 ? [this.opening] : n;
|
|
1530
1609
|
}
|
|
1531
1610
|
async start(e) {
|
|
1532
|
-
return { ...await this.exchange(
|
|
1611
|
+
return { ...await this.exchange(da(e)), phase: H.running };
|
|
1533
1612
|
}
|
|
1534
|
-
sendMessage(e,
|
|
1535
|
-
return this.exchange(e,
|
|
1613
|
+
sendMessage(e, n) {
|
|
1614
|
+
return this.exchange(e, n);
|
|
1536
1615
|
}
|
|
1537
1616
|
async stop() {
|
|
1538
1617
|
}
|
|
1539
1618
|
seedChecklist(e) {
|
|
1540
1619
|
this.seededChecklist = e;
|
|
1541
1620
|
}
|
|
1542
|
-
async exchange(e,
|
|
1543
|
-
var
|
|
1544
|
-
const s = [{ role:
|
|
1621
|
+
async exchange(e, n) {
|
|
1622
|
+
var o;
|
|
1623
|
+
const s = [{ role: qn.user, content: e }], r = await this.client.chat(
|
|
1545
1624
|
this.agentId,
|
|
1546
1625
|
{
|
|
1547
1626
|
messages: s,
|
|
@@ -1553,153 +1632,150 @@ class Wn {
|
|
|
1553
1632
|
source: "agent_view_frontend"
|
|
1554
1633
|
}
|
|
1555
1634
|
},
|
|
1556
|
-
...
|
|
1557
|
-
),
|
|
1558
|
-
id: r.event_id ||
|
|
1559
|
-
author:
|
|
1635
|
+
...n && n.length > 0 ? [{ uploadFiles: n }] : []
|
|
1636
|
+
), i = {
|
|
1637
|
+
id: r.event_id || ca("msg-agent"),
|
|
1638
|
+
author: te.agent,
|
|
1560
1639
|
text: r.message.content,
|
|
1561
|
-
...(
|
|
1640
|
+
...(o = r.follow_up_prompts) != null && o.length ? { followUpPrompts: r.follow_up_prompts } : {}
|
|
1562
1641
|
};
|
|
1563
1642
|
try {
|
|
1564
|
-
const d = await this.client.getAgent(this.agentId), { checklist: c } =
|
|
1565
|
-
return this.seededChecklist = c, { message:
|
|
1643
|
+
const d = await this.client.getAgent(this.agentId), { checklist: c } = ea(this.agentId, d);
|
|
1644
|
+
return this.seededChecklist = c, { message: i, checklist: c };
|
|
1566
1645
|
} catch {
|
|
1567
|
-
return { message:
|
|
1646
|
+
return { message: i, ...this.seededChecklist.length ? { checklist: this.seededChecklist } : {} };
|
|
1568
1647
|
}
|
|
1569
1648
|
}
|
|
1570
1649
|
}
|
|
1571
|
-
const
|
|
1650
|
+
const Dt = (t, e) => (n) => {
|
|
1572
1651
|
var s, r;
|
|
1573
|
-
return new
|
|
1652
|
+
return new ga(t, n.invocation_id, {
|
|
1574
1653
|
model: e == null ? void 0 : e.model,
|
|
1575
|
-
chatId: ((s = e == null ? void 0 : e.resolveChatId) == null ? void 0 : s.call(e,
|
|
1576
|
-
openingMessage: ((r = e == null ? void 0 : e.resolveOpeningMessage) == null ? void 0 : r.call(e,
|
|
1654
|
+
chatId: ((s = e == null ? void 0 : e.resolveChatId) == null ? void 0 : s.call(e, n)) ?? (e == null ? void 0 : e.chatId) ?? n.invocation_id,
|
|
1655
|
+
openingMessage: ((r = e == null ? void 0 : e.resolveOpeningMessage) == null ? void 0 : r.call(e, n)) ?? (e == null ? void 0 : e.openingMessage)
|
|
1577
1656
|
});
|
|
1578
|
-
},
|
|
1657
|
+
}, $t = (t) => t instanceof Te ? t.message : t instanceof TypeError ? "Network error while contacting the agent service." : t instanceof Error && t.message ? t.message : Rt, ha = (t) => {
|
|
1579
1658
|
const e = {};
|
|
1580
|
-
for (const
|
|
1581
|
-
const s =
|
|
1659
|
+
for (const n of t) {
|
|
1660
|
+
const s = Ye(n);
|
|
1582
1661
|
if (!s)
|
|
1583
1662
|
continue;
|
|
1584
|
-
const r =
|
|
1585
|
-
e[r] = s, e[
|
|
1663
|
+
const r = n.invocation_id ?? n.id;
|
|
1664
|
+
e[r] = s, e[n.id] = s;
|
|
1586
1665
|
}
|
|
1587
1666
|
return e;
|
|
1588
|
-
},
|
|
1589
|
-
const { jwt: e, headers:
|
|
1590
|
-
() => new
|
|
1667
|
+
}, ua = (t) => JSON.stringify(t), ot = (t, e) => JSON.stringify(t) === JSON.stringify(e), pa = (t) => {
|
|
1668
|
+
const { jwt: e, headers: n, urls: s } = t, r = JSON.stringify(n ?? {}), i = ua(s), o = W(
|
|
1669
|
+
() => new lt({
|
|
1591
1670
|
token: e,
|
|
1592
|
-
headers:
|
|
1671
|
+
headers: n,
|
|
1593
1672
|
urls: s
|
|
1594
1673
|
}),
|
|
1595
1674
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
|
|
1596
|
-
[e,
|
|
1675
|
+
[e, i]
|
|
1597
1676
|
);
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
}, [
|
|
1601
|
-
const [d, c] =
|
|
1677
|
+
We(() => {
|
|
1678
|
+
o.setHeaders(n);
|
|
1679
|
+
}, [o, r]);
|
|
1680
|
+
const [d, c] = _([]), [w, f] = _(
|
|
1602
1681
|
[]
|
|
1603
|
-
), [
|
|
1604
|
-
(
|
|
1605
|
-
const
|
|
1682
|
+
), [h, u] = _({}), [x, v] = _("loading"), [b, A] = _(null), [D, N] = _(0), y = E(
|
|
1683
|
+
(L, B) => {
|
|
1684
|
+
const U = L.map(vt), J = B.map(Lt), j = ha(L);
|
|
1606
1685
|
c(
|
|
1607
|
-
(
|
|
1608
|
-
),
|
|
1609
|
-
(
|
|
1610
|
-
),
|
|
1611
|
-
(
|
|
1612
|
-
),
|
|
1686
|
+
(q) => ot(q, U) ? q : U
|
|
1687
|
+
), f(
|
|
1688
|
+
(q) => ot(q, J) ? q : J
|
|
1689
|
+
), u(
|
|
1690
|
+
(q) => ot(q, j) ? q : j
|
|
1691
|
+
), v("idle"), A(null);
|
|
1613
1692
|
},
|
|
1614
1693
|
[]
|
|
1615
1694
|
);
|
|
1616
|
-
|
|
1617
|
-
let
|
|
1618
|
-
return
|
|
1695
|
+
F(() => {
|
|
1696
|
+
let L = !1;
|
|
1697
|
+
return v("loading"), A(null), (async () => {
|
|
1619
1698
|
try {
|
|
1620
|
-
const [
|
|
1621
|
-
|
|
1622
|
-
|
|
1699
|
+
const [B, U] = await Promise.all([
|
|
1700
|
+
o.listAgents(),
|
|
1701
|
+
o.listAgentDefinitions()
|
|
1623
1702
|
]);
|
|
1624
|
-
if (
|
|
1703
|
+
if (L)
|
|
1625
1704
|
return;
|
|
1626
|
-
|
|
1627
|
-
} catch (
|
|
1628
|
-
if (
|
|
1705
|
+
y(B, U);
|
|
1706
|
+
} catch (B) {
|
|
1707
|
+
if (L)
|
|
1629
1708
|
return;
|
|
1630
|
-
c([]),
|
|
1709
|
+
c([]), f([]), u({}), v("error"), A($t(B));
|
|
1631
1710
|
}
|
|
1632
1711
|
})(), () => {
|
|
1633
|
-
|
|
1712
|
+
L = !0;
|
|
1634
1713
|
};
|
|
1635
|
-
}, [
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
}, []),
|
|
1714
|
+
}, [y, o, D]);
|
|
1715
|
+
const m = E(() => {
|
|
1716
|
+
N((L) => L + 1);
|
|
1717
|
+
}, []), T = E(async () => {
|
|
1639
1718
|
try {
|
|
1640
|
-
const [
|
|
1641
|
-
|
|
1642
|
-
|
|
1719
|
+
const [L, B] = await Promise.all([
|
|
1720
|
+
o.listAgents(),
|
|
1721
|
+
o.listAgentDefinitions()
|
|
1643
1722
|
]);
|
|
1644
|
-
|
|
1723
|
+
y(L, B);
|
|
1645
1724
|
} catch {
|
|
1646
1725
|
}
|
|
1647
|
-
}, [
|
|
1648
|
-
async (
|
|
1649
|
-
const [
|
|
1650
|
-
|
|
1651
|
-
|
|
1726
|
+
}, [y, o]), P = E(
|
|
1727
|
+
async (L) => {
|
|
1728
|
+
const [B, U] = await Promise.all([
|
|
1729
|
+
o.getAgentChecklist(L),
|
|
1730
|
+
o.getAgent(L).catch(() => null)
|
|
1652
1731
|
]);
|
|
1653
|
-
return
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1732
|
+
return xt(
|
|
1733
|
+
L,
|
|
1734
|
+
B,
|
|
1735
|
+
U ?? void 0
|
|
1657
1736
|
);
|
|
1658
1737
|
},
|
|
1659
|
-
[
|
|
1660
|
-
),
|
|
1661
|
-
async (
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
},
|
|
1665
|
-
[i]
|
|
1666
|
-
), U = x(
|
|
1738
|
+
[o]
|
|
1739
|
+
), I = E(
|
|
1740
|
+
async (L) => o.listAllAgentResources(L),
|
|
1741
|
+
[o]
|
|
1742
|
+
), z = E(
|
|
1667
1743
|
async ({
|
|
1668
|
-
definition:
|
|
1669
|
-
invocationName:
|
|
1744
|
+
definition: L,
|
|
1745
|
+
invocationName: B
|
|
1670
1746
|
}) => {
|
|
1671
|
-
const
|
|
1672
|
-
invocationName:
|
|
1673
|
-
}),
|
|
1674
|
-
return c((
|
|
1675
|
-
|
|
1676
|
-
[
|
|
1677
|
-
[
|
|
1678
|
-
})),
|
|
1747
|
+
const U = await o.createAgent(L.ref, {
|
|
1748
|
+
invocationName: B
|
|
1749
|
+
}), J = await o.getAgent(U.id), j = vt(J), q = Ye(J);
|
|
1750
|
+
return c(($) => [j, ...$]), q && u(($) => ({
|
|
1751
|
+
...$,
|
|
1752
|
+
[j.invocation_id]: q,
|
|
1753
|
+
[j.id]: q
|
|
1754
|
+
})), j;
|
|
1679
1755
|
},
|
|
1680
|
-
[
|
|
1756
|
+
[o]
|
|
1681
1757
|
), ee = W(
|
|
1682
|
-
() =>
|
|
1683
|
-
resolveOpeningMessage: (
|
|
1758
|
+
() => Dt(o, {
|
|
1759
|
+
resolveOpeningMessage: (L) => h[L.invocation_id] ?? h[L.id]
|
|
1684
1760
|
}),
|
|
1685
|
-
[
|
|
1761
|
+
[o, h]
|
|
1686
1762
|
);
|
|
1687
1763
|
return {
|
|
1688
1764
|
agents: d,
|
|
1689
|
-
agentDefinitions:
|
|
1690
|
-
loadState:
|
|
1691
|
-
loadError:
|
|
1692
|
-
reload:
|
|
1693
|
-
refresh:
|
|
1694
|
-
fetchAgentChecklist:
|
|
1695
|
-
fetchAgentResources:
|
|
1696
|
-
createAgent:
|
|
1765
|
+
agentDefinitions: w,
|
|
1766
|
+
loadState: x,
|
|
1767
|
+
loadError: b,
|
|
1768
|
+
reload: m,
|
|
1769
|
+
refresh: T,
|
|
1770
|
+
fetchAgentChecklist: P,
|
|
1771
|
+
fetchAgentResources: I,
|
|
1772
|
+
createAgent: z,
|
|
1697
1773
|
chatConnector: ee
|
|
1698
1774
|
};
|
|
1699
|
-
},
|
|
1700
|
-
const { agent: e, jwt:
|
|
1701
|
-
() => new
|
|
1702
|
-
token:
|
|
1775
|
+
}, ma = (t) => JSON.stringify(t), _a = (t) => {
|
|
1776
|
+
const { agent: e, jwt: n, headers: s, urls: r, chatId: i } = t, o = JSON.stringify(s ?? {}), d = ma(r), c = W(
|
|
1777
|
+
() => new lt({
|
|
1778
|
+
token: n,
|
|
1703
1779
|
headers: s,
|
|
1704
1780
|
urls: {
|
|
1705
1781
|
agent: r.agentUrl,
|
|
@@ -1711,289 +1787,323 @@ const Et = (t, e) => (a) => {
|
|
|
1711
1787
|
}
|
|
1712
1788
|
}),
|
|
1713
1789
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
|
|
1714
|
-
[
|
|
1790
|
+
[n, d]
|
|
1715
1791
|
);
|
|
1716
|
-
|
|
1792
|
+
We(() => {
|
|
1717
1793
|
c.setHeaders(s);
|
|
1718
|
-
}, [c,
|
|
1719
|
-
const
|
|
1720
|
-
async (
|
|
1721
|
-
const [
|
|
1722
|
-
c.getAgentChecklist(
|
|
1723
|
-
c.getAgent(
|
|
1794
|
+
}, [c, o]);
|
|
1795
|
+
const w = E(
|
|
1796
|
+
async (v) => {
|
|
1797
|
+
const [b, A] = await Promise.all([
|
|
1798
|
+
c.getAgentChecklist(v),
|
|
1799
|
+
c.getAgent(v).catch(() => null)
|
|
1724
1800
|
]);
|
|
1725
|
-
return
|
|
1801
|
+
return xt(
|
|
1802
|
+
v,
|
|
1726
1803
|
b,
|
|
1727
|
-
|
|
1728
|
-
R ?? void 0
|
|
1804
|
+
A ?? void 0
|
|
1729
1805
|
);
|
|
1730
1806
|
},
|
|
1731
1807
|
[c]
|
|
1732
|
-
),
|
|
1733
|
-
async (
|
|
1734
|
-
const w = await c.getAgentResources(b);
|
|
1735
|
-
return bt(w);
|
|
1736
|
-
},
|
|
1808
|
+
), f = E(
|
|
1809
|
+
async (v) => c.listAllAgentResources(v),
|
|
1737
1810
|
[c]
|
|
1738
|
-
),
|
|
1739
|
-
async (b) =>
|
|
1740
|
-
|
|
1741
|
-
|
|
1811
|
+
), h = E(
|
|
1812
|
+
async (v, b) => c.getAgentResourceHtml(v, b),
|
|
1813
|
+
[c]
|
|
1814
|
+
), u = E(
|
|
1815
|
+
async (v) => {
|
|
1816
|
+
const b = await c.getAgentTimeline(v);
|
|
1817
|
+
return Qn(b);
|
|
1742
1818
|
},
|
|
1743
1819
|
[c]
|
|
1744
1820
|
);
|
|
1745
1821
|
return {
|
|
1746
1822
|
connector: W(
|
|
1747
|
-
() =>
|
|
1748
|
-
chatId:
|
|
1823
|
+
() => Dt(c, {
|
|
1824
|
+
chatId: i ?? e.invocation_id
|
|
1749
1825
|
})(e),
|
|
1750
1826
|
// Key on invocation/chat ids so a new Agent object reference does not rebuild the connector.
|
|
1751
1827
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1752
|
-
[c, e.invocation_id,
|
|
1828
|
+
[c, e.invocation_id, i]
|
|
1753
1829
|
),
|
|
1754
|
-
fetchAgentChecklist:
|
|
1755
|
-
fetchAgentResources:
|
|
1756
|
-
|
|
1830
|
+
fetchAgentChecklist: w,
|
|
1831
|
+
fetchAgentResources: f,
|
|
1832
|
+
fetchAgentResourceHtml: h,
|
|
1833
|
+
fetchAgentTimeline: u
|
|
1757
1834
|
};
|
|
1758
|
-
},
|
|
1759
|
-
const
|
|
1760
|
-
return `${
|
|
1761
|
-
},
|
|
1835
|
+
}, fa = 3e4, va = (t, e) => {
|
|
1836
|
+
const n = t.hasRunBefore ? e || "This trip" : t.tripName.trim() || "A new trip", s = t.destination ? ` to ${t.destination}` : "", r = t.hasRunBefore ? " It has run before." : "";
|
|
1837
|
+
return `${n}${s}.${r}`.trim();
|
|
1838
|
+
}, wa = (t) => {
|
|
1762
1839
|
switch (t) {
|
|
1763
|
-
case
|
|
1764
|
-
return
|
|
1765
|
-
case
|
|
1766
|
-
return
|
|
1840
|
+
case C.failed:
|
|
1841
|
+
return H.stopped;
|
|
1842
|
+
case C.complete:
|
|
1843
|
+
return H.complete;
|
|
1767
1844
|
default:
|
|
1768
|
-
return
|
|
1845
|
+
return H.running;
|
|
1769
1846
|
}
|
|
1770
|
-
},
|
|
1771
|
-
e([
|
|
1772
|
-
},
|
|
1847
|
+
}, Nt = (t, e) => {
|
|
1848
|
+
e([me(t)]);
|
|
1849
|
+
}, ya = (t, e) => t.length === e.length && t.every((n, s) => {
|
|
1773
1850
|
const r = e[s];
|
|
1774
|
-
return r !== void 0 &&
|
|
1775
|
-
}),
|
|
1851
|
+
return r !== void 0 && n.id === r.id && n.text === r.text;
|
|
1852
|
+
}), Na = ({
|
|
1776
1853
|
agent: t,
|
|
1777
1854
|
invocationId: e,
|
|
1778
|
-
open:
|
|
1855
|
+
open: n,
|
|
1779
1856
|
onClose: s,
|
|
1780
1857
|
jwt: r,
|
|
1781
|
-
headers:
|
|
1782
|
-
agentUrl:
|
|
1858
|
+
headers: i,
|
|
1859
|
+
agentUrl: o,
|
|
1783
1860
|
agentChecklistUrl: d,
|
|
1784
1861
|
agentResourcesUrl: c,
|
|
1785
|
-
agentTimelineUrl:
|
|
1786
|
-
agentChatUrl:
|
|
1787
|
-
agentConversationUrl:
|
|
1788
|
-
chatId:
|
|
1789
|
-
enableUpload:
|
|
1790
|
-
initialBrief:
|
|
1791
|
-
initialPhase:
|
|
1792
|
-
initialChecklist:
|
|
1862
|
+
agentTimelineUrl: w,
|
|
1863
|
+
agentChatUrl: f,
|
|
1864
|
+
agentConversationUrl: h,
|
|
1865
|
+
chatId: u,
|
|
1866
|
+
enableUpload: x,
|
|
1867
|
+
initialBrief: v,
|
|
1868
|
+
initialPhase: b,
|
|
1869
|
+
initialChecklist: A
|
|
1793
1870
|
}) => {
|
|
1794
|
-
const [
|
|
1871
|
+
const [D, N] = _(u ?? e), [y, m] = _("chat"), [T, P] = _(!1), { connector: I, fetchAgentChecklist: z, fetchAgentResources: ee, fetchAgentResourceHtml: L, fetchAgentTimeline: B } = _a({
|
|
1795
1872
|
agent: { ...t, invocation_id: e },
|
|
1796
1873
|
jwt: r,
|
|
1797
|
-
headers:
|
|
1798
|
-
chatId:
|
|
1874
|
+
headers: i,
|
|
1875
|
+
chatId: D,
|
|
1799
1876
|
urls: {
|
|
1800
|
-
agentUrl:
|
|
1877
|
+
agentUrl: o,
|
|
1801
1878
|
agentChecklistUrl: d,
|
|
1802
1879
|
agentResourcesUrl: c,
|
|
1803
|
-
agentTimelineUrl:
|
|
1804
|
-
agentChatUrl:
|
|
1805
|
-
agentConversationUrl:
|
|
1880
|
+
agentTimelineUrl: w,
|
|
1881
|
+
agentChatUrl: f,
|
|
1882
|
+
agentConversationUrl: h
|
|
1806
1883
|
}
|
|
1807
|
-
}),
|
|
1808
|
-
|
|
1809
|
-
), [
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
}, [
|
|
1813
|
-
|
|
1814
|
-
}, [
|
|
1815
|
-
|
|
1816
|
-
}, [e,
|
|
1817
|
-
if (!
|
|
1884
|
+
}), U = fe(I), [J, j] = _(
|
|
1885
|
+
b ?? (v ? H.running : wa(t.status))
|
|
1886
|
+
), [q, $] = _([]), [Re, he] = _(0), [we, ue] = _(), [je, ne] = _(null), [Xe, ye] = _([]), [re, Ne] = _(!1), [Ie, pe] = _(null), [Oe, Pe] = _(null), [Le, ke] = _(null), [Ue, Ae] = _(!1), [Qe, be] = _(null), [oe, xe] = _(null), [p, S] = _(!1), [k, V] = _(null), [ie, ae] = _(A ?? null), [le, Se] = _(!1), [Ht, ct] = _(null), [De, Ze] = _(!1), [$e, zt] = _(!1), [Me, Bt] = _(!1), dt = fe(De);
|
|
1887
|
+
F(() => {
|
|
1888
|
+
U.current = I;
|
|
1889
|
+
}, [I]), F(() => {
|
|
1890
|
+
dt.current = De;
|
|
1891
|
+
}, [De]), F(() => {
|
|
1892
|
+
N(u ?? e), m("chat"), P(!1), $([]), he((g) => g + 1);
|
|
1893
|
+
}, [e, u]), F(() => {
|
|
1894
|
+
if (!n || v)
|
|
1818
1895
|
return;
|
|
1819
|
-
const
|
|
1820
|
-
if (!
|
|
1821
|
-
|
|
1896
|
+
const g = U.current.bootstrapConversation;
|
|
1897
|
+
if (!g) {
|
|
1898
|
+
Nt(U.current.openingMessage(), $);
|
|
1822
1899
|
return;
|
|
1823
1900
|
}
|
|
1824
|
-
let
|
|
1825
|
-
return
|
|
1901
|
+
let R = !1;
|
|
1902
|
+
return Ze(!0), (async () => {
|
|
1826
1903
|
try {
|
|
1827
|
-
const X = await
|
|
1828
|
-
if (
|
|
1904
|
+
const X = await g.call(U.current);
|
|
1905
|
+
if (R)
|
|
1829
1906
|
return;
|
|
1830
|
-
|
|
1907
|
+
$(X.map(me));
|
|
1831
1908
|
} catch {
|
|
1832
|
-
|
|
1909
|
+
R || Nt(U.current.openingMessage(), $);
|
|
1833
1910
|
} finally {
|
|
1834
|
-
|
|
1911
|
+
R || Ze(!1);
|
|
1835
1912
|
}
|
|
1836
1913
|
})(), () => {
|
|
1837
|
-
|
|
1914
|
+
R = !0;
|
|
1838
1915
|
};
|
|
1839
|
-
}, [
|
|
1840
|
-
if (!
|
|
1916
|
+
}, [n, v, e, D]), F(() => {
|
|
1917
|
+
if (!n || v)
|
|
1841
1918
|
return;
|
|
1842
|
-
const
|
|
1843
|
-
const
|
|
1844
|
-
|
|
1919
|
+
const g = window.setInterval(() => {
|
|
1920
|
+
const R = U.current.bootstrapConversation;
|
|
1921
|
+
R && (async () => {
|
|
1845
1922
|
try {
|
|
1846
|
-
const X = await
|
|
1847
|
-
if (
|
|
1923
|
+
const X = await R.call(U.current);
|
|
1924
|
+
if (dt.current)
|
|
1848
1925
|
return;
|
|
1849
|
-
const Ce = X.map(
|
|
1850
|
-
|
|
1851
|
-
(
|
|
1926
|
+
const Ce = X.map(me);
|
|
1927
|
+
$(
|
|
1928
|
+
(ht) => ya(ht, Ce) ? ht : Ce
|
|
1852
1929
|
);
|
|
1853
1930
|
} catch {
|
|
1854
1931
|
}
|
|
1855
1932
|
})();
|
|
1856
|
-
},
|
|
1933
|
+
}, fa);
|
|
1857
1934
|
return () => {
|
|
1858
|
-
window.clearInterval(
|
|
1935
|
+
window.clearInterval(g);
|
|
1859
1936
|
};
|
|
1860
|
-
}, [
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1937
|
+
}, [n, v, e, D]);
|
|
1938
|
+
const He = E(() => {
|
|
1939
|
+
c && (async () => {
|
|
1940
|
+
try {
|
|
1941
|
+
const g = await ee(e);
|
|
1942
|
+
ye(g), pe(null);
|
|
1943
|
+
} catch {
|
|
1944
|
+
}
|
|
1945
|
+
})();
|
|
1946
|
+
}, [c, ee, e]), Ft = E(
|
|
1947
|
+
(g) => {
|
|
1948
|
+
g.checklist && ae(g.checklist), g.phase && j(g.phase), He();
|
|
1949
|
+
},
|
|
1950
|
+
[He]
|
|
1951
|
+
);
|
|
1952
|
+
F(() => {
|
|
1953
|
+
var g, R;
|
|
1954
|
+
!n || v || A && A.length > 0 && ((R = (g = U.current).seedChecklist) == null || R.call(g, A));
|
|
1955
|
+
}, [n, v, A]), F(() => {
|
|
1956
|
+
if (!n || v)
|
|
1869
1957
|
return;
|
|
1870
|
-
let
|
|
1871
|
-
return Se(!(
|
|
1872
|
-
var
|
|
1958
|
+
let g = !1;
|
|
1959
|
+
return Se(!(A != null && A.length)), ct(null), (async () => {
|
|
1960
|
+
var R, X;
|
|
1873
1961
|
try {
|
|
1874
|
-
const Ce = await
|
|
1875
|
-
if (
|
|
1962
|
+
const Ce = await z(e);
|
|
1963
|
+
if (g)
|
|
1876
1964
|
return;
|
|
1877
|
-
|
|
1965
|
+
A != null && A.length || (ae(Ce.checklist), (X = (R = U.current).seedChecklist) == null || X.call(R, Ce.checklist));
|
|
1878
1966
|
} catch {
|
|
1879
|
-
!
|
|
1967
|
+
!g && !(A != null && A.length) && ct(qe);
|
|
1880
1968
|
} finally {
|
|
1881
|
-
|
|
1969
|
+
g || Se(!1);
|
|
1882
1970
|
}
|
|
1883
1971
|
})(), () => {
|
|
1884
|
-
|
|
1972
|
+
g = !0;
|
|
1885
1973
|
};
|
|
1886
|
-
}, [
|
|
1887
|
-
if (!
|
|
1974
|
+
}, [n, e, v, A, z]), F(() => {
|
|
1975
|
+
if (!n || !c)
|
|
1888
1976
|
return;
|
|
1889
|
-
let
|
|
1890
|
-
return
|
|
1977
|
+
let g = !1;
|
|
1978
|
+
return Ne(!0), pe(null), (async () => {
|
|
1891
1979
|
try {
|
|
1892
|
-
const
|
|
1893
|
-
|
|
1980
|
+
const R = await ee(e);
|
|
1981
|
+
g || ye(R);
|
|
1894
1982
|
} catch {
|
|
1895
|
-
|
|
1983
|
+
g || pe(cn);
|
|
1896
1984
|
} finally {
|
|
1897
|
-
|
|
1985
|
+
g || Ne(!1);
|
|
1898
1986
|
}
|
|
1899
1987
|
})(), () => {
|
|
1900
|
-
|
|
1988
|
+
g = !0;
|
|
1901
1989
|
};
|
|
1902
|
-
}, [
|
|
1903
|
-
|
|
1990
|
+
}, [n, e, c, ee]);
|
|
1991
|
+
const Gt = E(() => {
|
|
1992
|
+
Pe(null), ke(null), be(null), Ae(!1);
|
|
1993
|
+
}, []), qt = E(
|
|
1994
|
+
(g) => {
|
|
1995
|
+
if (g.misRecordUrl) {
|
|
1996
|
+
window.open(g.misRecordUrl, "_blank", "noopener,noreferrer");
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
Pe(g), ke(null), be(null), Ae(!0), (async () => {
|
|
2000
|
+
try {
|
|
2001
|
+
const R = await L(e, g.id);
|
|
2002
|
+
ke(R);
|
|
2003
|
+
} catch {
|
|
2004
|
+
be(dn);
|
|
2005
|
+
} finally {
|
|
2006
|
+
Ae(!1);
|
|
2007
|
+
}
|
|
2008
|
+
})();
|
|
2009
|
+
},
|
|
2010
|
+
[L, e]
|
|
2011
|
+
);
|
|
2012
|
+
F(() => {
|
|
2013
|
+
if (!n || !w)
|
|
1904
2014
|
return;
|
|
1905
|
-
let
|
|
1906
|
-
return
|
|
2015
|
+
let g = !1;
|
|
2016
|
+
return S(!0), V(null), (async () => {
|
|
1907
2017
|
try {
|
|
1908
|
-
const
|
|
1909
|
-
|
|
2018
|
+
const R = await B(e);
|
|
2019
|
+
g || xe(R);
|
|
1910
2020
|
} catch {
|
|
1911
|
-
|
|
2021
|
+
g || V(Et);
|
|
1912
2022
|
} finally {
|
|
1913
|
-
|
|
2023
|
+
g || S(!1);
|
|
1914
2024
|
}
|
|
1915
2025
|
})(), () => {
|
|
1916
|
-
|
|
2026
|
+
g = !0;
|
|
1917
2027
|
};
|
|
1918
|
-
}, [
|
|
1919
|
-
if (!
|
|
2028
|
+
}, [n, e, w, B]), F(() => {
|
|
2029
|
+
if (!n || !v)
|
|
1920
2030
|
return;
|
|
1921
|
-
let
|
|
1922
|
-
const
|
|
2031
|
+
let g = !1;
|
|
2032
|
+
const R = {
|
|
1923
2033
|
id: `user-brief-${Date.now()}`,
|
|
1924
|
-
author:
|
|
1925
|
-
text:
|
|
2034
|
+
author: te.user,
|
|
2035
|
+
text: va(v, t.invocation_name)
|
|
1926
2036
|
};
|
|
1927
2037
|
return (async () => {
|
|
1928
|
-
const X = await
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
]), X.checklist &&
|
|
2038
|
+
const X = await U.current.start(v);
|
|
2039
|
+
g || ($([
|
|
2040
|
+
me(U.current.openingMessage()),
|
|
2041
|
+
me(R),
|
|
2042
|
+
me(X.message)
|
|
2043
|
+
]), X.checklist && ae(X.checklist), j(X.phase ?? H.running), He());
|
|
1934
2044
|
})(), () => {
|
|
1935
|
-
|
|
2045
|
+
g = !0;
|
|
1936
2046
|
};
|
|
1937
|
-
}, [
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1940
|
-
}, []),
|
|
1941
|
-
(
|
|
1942
|
-
).sessionId : void 0,
|
|
1943
|
-
|
|
1944
|
-
}, [
|
|
1945
|
-
(
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
2047
|
+
}, [n, v, t.invocation_name, e, He]);
|
|
2048
|
+
const Kt = E((g) => {
|
|
2049
|
+
ne(Bn(g));
|
|
2050
|
+
}, []), et = u ?? e, ze = oe == null ? void 0 : oe.chatSessions, gt = ze != null && ze.length ? ze.reduce(
|
|
2051
|
+
(g, R) => Date.parse(R.timestamp) < Date.parse(g.timestamp) ? R : g
|
|
2052
|
+
).sessionId : void 0, tt = E(() => {
|
|
2053
|
+
m("chat"), P(!1), D !== et && (N(et), $([]), he((g) => g + 1));
|
|
2054
|
+
}, [D, et]), Jt = E(
|
|
2055
|
+
(g) => {
|
|
2056
|
+
if (g === gt) {
|
|
2057
|
+
tt();
|
|
1948
2058
|
return;
|
|
1949
2059
|
}
|
|
1950
|
-
|
|
2060
|
+
N(g), P(!0), m("chat"), $([]), he((R) => R + 1);
|
|
1951
2061
|
},
|
|
1952
|
-
[
|
|
1953
|
-
),
|
|
1954
|
-
|
|
1955
|
-
}, []),
|
|
1956
|
-
await
|
|
1957
|
-
}, []),
|
|
1958
|
-
return /* @__PURE__ */
|
|
1959
|
-
/* @__PURE__ */
|
|
1960
|
-
/* @__PURE__ */
|
|
1961
|
-
/* @__PURE__ */
|
|
1962
|
-
/* @__PURE__ */
|
|
1963
|
-
/* @__PURE__ */
|
|
2062
|
+
[gt, tt]
|
|
2063
|
+
), Wt = E((g) => {
|
|
2064
|
+
ne(null), ue(g), he((R) => R + 1);
|
|
2065
|
+
}, []), Vt = E(async () => {
|
|
2066
|
+
await U.current.stop(), j(H.stopped);
|
|
2067
|
+
}, []), Yt = ie;
|
|
2068
|
+
return /* @__PURE__ */ l(se, { open: n, closeHandler: s, hideCloseButton: !0, className: "agent-workspace", children: [
|
|
2069
|
+
/* @__PURE__ */ l(se.Header, { className: "agent-workspace__header", children: [
|
|
2070
|
+
/* @__PURE__ */ l("div", { className: "agent-workspace__header-title", children: [
|
|
2071
|
+
/* @__PURE__ */ a("span", { className: "agent-workspace__header-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a(O, { name: "ask-arbor", size: 24 }) }),
|
|
2072
|
+
/* @__PURE__ */ a(se.Title, { children: t.invocation_name }),
|
|
2073
|
+
/* @__PURE__ */ a(
|
|
1964
2074
|
"span",
|
|
1965
2075
|
{
|
|
1966
|
-
className:
|
|
1967
|
-
children:
|
|
2076
|
+
className: Y("agent-workspace__phase", `agent-workspace__phase--${J}`),
|
|
2077
|
+
children: un[J]
|
|
1968
2078
|
}
|
|
1969
2079
|
)
|
|
1970
2080
|
] }),
|
|
1971
|
-
/* @__PURE__ */
|
|
1972
|
-
/* @__PURE__ */
|
|
2081
|
+
/* @__PURE__ */ l("div", { className: "agent-workspace__header-actions", children: [
|
|
2082
|
+
/* @__PURE__ */ a(
|
|
1973
2083
|
Z,
|
|
1974
2084
|
{
|
|
1975
|
-
variant:
|
|
2085
|
+
variant: $e ? "secondary" : "primary",
|
|
1976
2086
|
size: "S",
|
|
1977
2087
|
iconLeftName: "clipboard-list",
|
|
1978
2088
|
iconLeftScreenReaderText: "Toggle checklist",
|
|
1979
|
-
"aria-pressed":
|
|
1980
|
-
onClick: () =>
|
|
2089
|
+
"aria-pressed": !$e,
|
|
2090
|
+
onClick: () => zt((g) => !g),
|
|
1981
2091
|
children: "Checklist"
|
|
1982
2092
|
}
|
|
1983
2093
|
),
|
|
1984
|
-
/* @__PURE__ */
|
|
2094
|
+
/* @__PURE__ */ a(
|
|
1985
2095
|
Z,
|
|
1986
2096
|
{
|
|
1987
|
-
variant:
|
|
2097
|
+
variant: Me ? "secondary" : "primary",
|
|
1988
2098
|
size: "S",
|
|
1989
2099
|
iconLeftName: "files",
|
|
1990
2100
|
iconLeftScreenReaderText: "Toggle resources",
|
|
1991
|
-
"aria-pressed": !
|
|
1992
|
-
onClick: () =>
|
|
2101
|
+
"aria-pressed": !Me,
|
|
2102
|
+
onClick: () => Bt((g) => !g),
|
|
1993
2103
|
children: "Resources"
|
|
1994
2104
|
}
|
|
1995
2105
|
),
|
|
1996
|
-
/* @__PURE__ */
|
|
2106
|
+
/* @__PURE__ */ a(
|
|
1997
2107
|
Z,
|
|
1998
2108
|
{
|
|
1999
2109
|
variant: "secondary",
|
|
@@ -2006,26 +2116,26 @@ const Et = (t, e) => (a) => {
|
|
|
2006
2116
|
)
|
|
2007
2117
|
] })
|
|
2008
2118
|
] }),
|
|
2009
|
-
/* @__PURE__ */
|
|
2119
|
+
/* @__PURE__ */ l(
|
|
2010
2120
|
se.Body,
|
|
2011
2121
|
{
|
|
2012
|
-
className:
|
|
2013
|
-
"agent-workspace__body--no-checklist":
|
|
2014
|
-
"agent-workspace__body--no-resources":
|
|
2122
|
+
className: Y("agent-workspace__body", {
|
|
2123
|
+
"agent-workspace__body--no-checklist": $e,
|
|
2124
|
+
"agent-workspace__body--no-resources": Me
|
|
2015
2125
|
}),
|
|
2016
2126
|
children: [
|
|
2017
2127
|
" ",
|
|
2018
|
-
/* @__PURE__ */
|
|
2128
|
+
/* @__PURE__ */ l(
|
|
2019
2129
|
"section",
|
|
2020
2130
|
{
|
|
2021
|
-
className:
|
|
2022
|
-
"agent-workspace__panel--timeline": !!
|
|
2131
|
+
className: Y("agent-workspace__panel", "agent-workspace__panel--chat", {
|
|
2132
|
+
"agent-workspace__panel--timeline": !!w && y === "timeline"
|
|
2023
2133
|
}),
|
|
2024
2134
|
"aria-label": "Agent",
|
|
2025
2135
|
children: [
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2028
|
-
|
|
2136
|
+
/* @__PURE__ */ l("div", { className: "agent-workspace__panel-header", children: [
|
|
2137
|
+
/* @__PURE__ */ a(ve, { level: 4, children: "Agent" }),
|
|
2138
|
+
J === H.running && /* @__PURE__ */ a(
|
|
2029
2139
|
Z,
|
|
2030
2140
|
{
|
|
2031
2141
|
className: "agent-workspace__panel-header-action",
|
|
@@ -2033,74 +2143,74 @@ const Et = (t, e) => (a) => {
|
|
|
2033
2143
|
size: "S",
|
|
2034
2144
|
iconLeftName: "circle-x",
|
|
2035
2145
|
iconLeftScreenReaderText: "Stop",
|
|
2036
|
-
onClick: () => void
|
|
2146
|
+
onClick: () => void Vt(),
|
|
2037
2147
|
children: "Stop agent"
|
|
2038
2148
|
}
|
|
2039
2149
|
)
|
|
2040
2150
|
] }),
|
|
2041
|
-
|
|
2042
|
-
/* @__PURE__ */
|
|
2043
|
-
|
|
2151
|
+
w && /* @__PURE__ */ l(nt, { className: "agent-workspace__center-tabs", "aria-label": "Center panel", children: [
|
|
2152
|
+
/* @__PURE__ */ a(
|
|
2153
|
+
nt.Item,
|
|
2044
2154
|
{
|
|
2045
|
-
active:
|
|
2155
|
+
active: y === "chat",
|
|
2046
2156
|
tabElementProps: {
|
|
2047
2157
|
id: "agent-center-tab-chat",
|
|
2048
|
-
onClick: () =>
|
|
2158
|
+
onClick: () => m("chat")
|
|
2049
2159
|
},
|
|
2050
2160
|
children: "Chat"
|
|
2051
2161
|
}
|
|
2052
2162
|
),
|
|
2053
|
-
/* @__PURE__ */
|
|
2054
|
-
|
|
2163
|
+
/* @__PURE__ */ a(
|
|
2164
|
+
nt.Item,
|
|
2055
2165
|
{
|
|
2056
|
-
active:
|
|
2166
|
+
active: y === "timeline",
|
|
2057
2167
|
tabElementProps: {
|
|
2058
2168
|
id: "agent-center-tab-timeline",
|
|
2059
|
-
onClick: () =>
|
|
2169
|
+
onClick: () => m("timeline")
|
|
2060
2170
|
},
|
|
2061
2171
|
children: "Timeline"
|
|
2062
2172
|
}
|
|
2063
2173
|
)
|
|
2064
2174
|
] }),
|
|
2065
|
-
|
|
2175
|
+
w && y === "chat" && T && /* @__PURE__ */ a("div", { className: "agent-workspace__center-back", children: /* @__PURE__ */ a(
|
|
2066
2176
|
Z,
|
|
2067
2177
|
{
|
|
2068
2178
|
variant: "tertiary",
|
|
2069
2179
|
size: "S",
|
|
2070
2180
|
iconLeftName: "arrow-left",
|
|
2071
2181
|
iconLeftScreenReaderText: "Back to main chat",
|
|
2072
|
-
onClick:
|
|
2182
|
+
onClick: tt,
|
|
2073
2183
|
children: "Back to main chat"
|
|
2074
2184
|
}
|
|
2075
2185
|
) }),
|
|
2076
|
-
|
|
2077
|
-
|
|
2186
|
+
w && y === "timeline" && /* @__PURE__ */ a(
|
|
2187
|
+
Hn,
|
|
2078
2188
|
{
|
|
2079
|
-
timeline:
|
|
2080
|
-
isLoading:
|
|
2081
|
-
error:
|
|
2082
|
-
onOpenChatSession:
|
|
2189
|
+
timeline: oe,
|
|
2190
|
+
isLoading: p,
|
|
2191
|
+
error: k,
|
|
2192
|
+
onOpenChatSession: Jt
|
|
2083
2193
|
}
|
|
2084
2194
|
),
|
|
2085
|
-
/* @__PURE__ */
|
|
2195
|
+
/* @__PURE__ */ a(
|
|
2086
2196
|
"div",
|
|
2087
2197
|
{
|
|
2088
2198
|
className: "agent-workspace__chat-keep-alive",
|
|
2089
|
-
hidden: !!
|
|
2090
|
-
children: /* @__PURE__ */
|
|
2091
|
-
|
|
2199
|
+
hidden: !!w && y !== "chat",
|
|
2200
|
+
children: /* @__PURE__ */ a(
|
|
2201
|
+
Tn,
|
|
2092
2202
|
{
|
|
2093
|
-
connector:
|
|
2094
|
-
phase:
|
|
2095
|
-
chatHistory:
|
|
2096
|
-
chatSessionKey:
|
|
2097
|
-
startQuery:
|
|
2098
|
-
clarificationMessage:
|
|
2099
|
-
enableUpload:
|
|
2100
|
-
onTurn:
|
|
2101
|
-
onAwaitingChange:
|
|
2102
|
-
onClarificationPrompt:
|
|
2103
|
-
onDismissClarification: () =>
|
|
2203
|
+
connector: I,
|
|
2204
|
+
phase: J,
|
|
2205
|
+
chatHistory: q,
|
|
2206
|
+
chatSessionKey: Re,
|
|
2207
|
+
startQuery: we,
|
|
2208
|
+
clarificationMessage: je,
|
|
2209
|
+
enableUpload: x,
|
|
2210
|
+
onTurn: Ft,
|
|
2211
|
+
onAwaitingChange: Ze,
|
|
2212
|
+
onClarificationPrompt: Wt,
|
|
2213
|
+
onDismissClarification: () => ne(null)
|
|
2104
2214
|
}
|
|
2105
2215
|
)
|
|
2106
2216
|
}
|
|
@@ -2108,267 +2218,280 @@ const Et = (t, e) => (a) => {
|
|
|
2108
2218
|
]
|
|
2109
2219
|
}
|
|
2110
2220
|
),
|
|
2111
|
-
|
|
2112
|
-
|
|
2221
|
+
!$e && /* @__PURE__ */ a(
|
|
2222
|
+
En,
|
|
2223
|
+
{
|
|
2224
|
+
checklist: Yt,
|
|
2225
|
+
isLoading: le,
|
|
2226
|
+
error: Ht,
|
|
2227
|
+
phase: J,
|
|
2228
|
+
canRequestInput: J === H.running && !De,
|
|
2229
|
+
onAttentionItemClick: Kt
|
|
2230
|
+
}
|
|
2231
|
+
),
|
|
2232
|
+
!Me && /* @__PURE__ */ a(
|
|
2233
|
+
On,
|
|
2113
2234
|
{
|
|
2114
|
-
|
|
2115
|
-
isLoading:
|
|
2116
|
-
error:
|
|
2117
|
-
|
|
2118
|
-
canRequestInput: H === B.running && !S,
|
|
2119
|
-
onAttentionItemClick: Lt
|
|
2235
|
+
resources: Xe,
|
|
2236
|
+
isLoading: re,
|
|
2237
|
+
error: Ie,
|
|
2238
|
+
onOpenResource: qt
|
|
2120
2239
|
}
|
|
2121
2240
|
),
|
|
2122
|
-
|
|
2123
|
-
|
|
2241
|
+
/* @__PURE__ */ a(
|
|
2242
|
+
Rn,
|
|
2124
2243
|
{
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2244
|
+
resource: Oe,
|
|
2245
|
+
html: Le,
|
|
2246
|
+
isLoading: Ue,
|
|
2247
|
+
error: Qe,
|
|
2248
|
+
onClose: Gt
|
|
2128
2249
|
}
|
|
2129
2250
|
)
|
|
2130
2251
|
]
|
|
2131
2252
|
}
|
|
2132
2253
|
)
|
|
2133
2254
|
] });
|
|
2134
|
-
},
|
|
2255
|
+
}, ka = "Unable to load agent definitions. Please try again.", Aa = "Unable to start the agent.", kt = "Loading agents…", Mt = ({
|
|
2135
2256
|
open: t,
|
|
2136
2257
|
onClose: e,
|
|
2137
|
-
onStart:
|
|
2258
|
+
onStart: n,
|
|
2138
2259
|
agentDefinitions: s,
|
|
2139
2260
|
definitionsState: r = "idle",
|
|
2140
|
-
definitionsError:
|
|
2141
|
-
onRetryDefinitions:
|
|
2261
|
+
definitionsError: i = null,
|
|
2262
|
+
onRetryDefinitions: o,
|
|
2142
2263
|
embedded: d = !1
|
|
2143
2264
|
}) => {
|
|
2144
|
-
const c
|
|
2145
|
-
value:
|
|
2146
|
-
label:
|
|
2265
|
+
const [c, w] = _(void 0), [f, h] = _(""), [u, x] = _(!1), [v, b] = _(null), A = [...s].sort((P, I) => P.display_name.localeCompare(I.display_name)).map((P) => ({
|
|
2266
|
+
value: P.ref,
|
|
2267
|
+
label: P.display_name
|
|
2147
2268
|
}));
|
|
2148
|
-
|
|
2149
|
-
t && (
|
|
2150
|
-
}, [t
|
|
2151
|
-
const
|
|
2152
|
-
(
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2269
|
+
F(() => {
|
|
2270
|
+
t && (w(void 0), h(""), x(!1), b(null));
|
|
2271
|
+
}, [t]);
|
|
2272
|
+
const D = c !== void 0 && f.trim().length > 0, N = E(
|
|
2273
|
+
(P) => {
|
|
2274
|
+
const I = s.find((z) => z.ref === P[0]);
|
|
2275
|
+
I && w(I);
|
|
2155
2276
|
},
|
|
2156
2277
|
[s]
|
|
2157
|
-
),
|
|
2158
|
-
if (!(!
|
|
2159
|
-
|
|
2278
|
+
), y = E(async () => {
|
|
2279
|
+
if (!(!c || !D || u)) {
|
|
2280
|
+
x(!0), b(null);
|
|
2160
2281
|
try {
|
|
2161
|
-
await
|
|
2162
|
-
} catch (
|
|
2163
|
-
|
|
2282
|
+
await n({ definition: c, invocationName: f.trim() });
|
|
2283
|
+
} catch (P) {
|
|
2284
|
+
b(P instanceof Error ? P.message : Aa);
|
|
2164
2285
|
} finally {
|
|
2165
|
-
|
|
2286
|
+
x(!1);
|
|
2166
2287
|
}
|
|
2167
2288
|
}
|
|
2168
|
-
}, [
|
|
2289
|
+
}, [D, c, f, u, n]);
|
|
2169
2290
|
if (r === "idle" && s.length === 0 || !t)
|
|
2170
2291
|
return null;
|
|
2171
|
-
const
|
|
2172
|
-
/* @__PURE__ */
|
|
2173
|
-
d ? /* @__PURE__ */
|
|
2292
|
+
const m = /* @__PURE__ */ l("div", { className: "new-agent__header-title", children: [
|
|
2293
|
+
/* @__PURE__ */ a("span", { className: "new-agent__header-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a(O, { name: "ask-arbor", size: 24 }) }),
|
|
2294
|
+
d ? /* @__PURE__ */ a("h2", { className: "new-agent__title", children: "Start an agent" }) : /* @__PURE__ */ a(se.Title, { children: "Start an agent" })
|
|
2174
2295
|
] });
|
|
2175
|
-
let
|
|
2176
|
-
return r === "loading" ?
|
|
2177
|
-
/* @__PURE__ */
|
|
2178
|
-
|
|
2296
|
+
let T;
|
|
2297
|
+
return r === "loading" ? T = /* @__PURE__ */ l("div", { className: "new-agent__state", "aria-live": "polite", children: [
|
|
2298
|
+
/* @__PURE__ */ a(
|
|
2299
|
+
O,
|
|
2179
2300
|
{
|
|
2180
2301
|
name: "loader",
|
|
2181
2302
|
size: 24,
|
|
2182
2303
|
color: "var(--color-brand-600)",
|
|
2183
2304
|
className: "new-agent__spinner",
|
|
2184
|
-
screenReaderText:
|
|
2305
|
+
screenReaderText: kt
|
|
2185
2306
|
}
|
|
2186
2307
|
),
|
|
2187
|
-
/* @__PURE__ */
|
|
2188
|
-
] }) : r === "error" ?
|
|
2189
|
-
/* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */
|
|
2191
|
-
|
|
2192
|
-
] }) :
|
|
2308
|
+
/* @__PURE__ */ a("p", { className: "new-agent__state-message", children: kt })
|
|
2309
|
+
] }) : r === "error" ? T = /* @__PURE__ */ l("div", { className: "new-agent__state new-agent__state--error", role: "alert", children: [
|
|
2310
|
+
/* @__PURE__ */ a(O, { name: "triangle-alert", size: 24, color: "var(--color-semantic-destructive-600)" }),
|
|
2311
|
+
/* @__PURE__ */ a("p", { className: "new-agent__state-message", children: i ?? ka }),
|
|
2312
|
+
o ? /* @__PURE__ */ a(Z, { variant: "secondary", size: "S", onClick: o, children: "Try again" }) : null
|
|
2313
|
+
] }) : T = /* @__PURE__ */ l(
|
|
2193
2314
|
"form",
|
|
2194
2315
|
{
|
|
2195
2316
|
className: "new-agent__form",
|
|
2196
2317
|
"aria-label": "Start an agent",
|
|
2197
|
-
onSubmit: (
|
|
2198
|
-
|
|
2318
|
+
onSubmit: (P) => {
|
|
2319
|
+
P.preventDefault(), D && !u && y();
|
|
2199
2320
|
},
|
|
2200
2321
|
children: [
|
|
2201
|
-
/* @__PURE__ */
|
|
2202
|
-
/* @__PURE__ */
|
|
2203
|
-
/* @__PURE__ */
|
|
2204
|
-
|
|
2322
|
+
/* @__PURE__ */ l("div", { className: "new-agent__type-field", children: [
|
|
2323
|
+
/* @__PURE__ */ a("label", { className: "new-agent__type-label", htmlFor: "new-agent-type", children: "What would you like your agent to do?" }),
|
|
2324
|
+
/* @__PURE__ */ a(
|
|
2325
|
+
Xt,
|
|
2205
2326
|
{
|
|
2206
2327
|
id: "new-agent-type",
|
|
2207
|
-
placeholder: "
|
|
2208
|
-
options:
|
|
2209
|
-
selectedValues: [
|
|
2328
|
+
placeholder: "Which agent would you like to start?",
|
|
2329
|
+
options: A,
|
|
2330
|
+
selectedValues: c ? [c.ref] : [],
|
|
2210
2331
|
onSelectionChange: N
|
|
2211
2332
|
}
|
|
2212
|
-
)
|
|
2213
|
-
/* @__PURE__ */ n("p", { className: "new-agent__type-description", children: p.description })
|
|
2333
|
+
)
|
|
2214
2334
|
] }),
|
|
2215
|
-
/* @__PURE__ */
|
|
2216
|
-
/* @__PURE__ */
|
|
2217
|
-
/* @__PURE__ */
|
|
2218
|
-
|
|
2335
|
+
/* @__PURE__ */ l("div", { className: "new-agent__type-field", children: [
|
|
2336
|
+
/* @__PURE__ */ a("label", { className: "new-agent__type-label", htmlFor: "new-agent-invocation-name", children: "Name" }),
|
|
2337
|
+
/* @__PURE__ */ a(
|
|
2338
|
+
Qt,
|
|
2219
2339
|
{
|
|
2220
2340
|
id: "new-agent-invocation-name",
|
|
2221
|
-
value:
|
|
2341
|
+
value: f,
|
|
2222
2342
|
placeholder: "What would you like to call your agent?",
|
|
2223
|
-
onChange: (
|
|
2343
|
+
onChange: (P) => h(P.target.value)
|
|
2224
2344
|
}
|
|
2225
2345
|
)
|
|
2226
2346
|
] }),
|
|
2227
|
-
|
|
2228
|
-
/* @__PURE__ */
|
|
2347
|
+
v ? /* @__PURE__ */ a("p", { className: "new-agent__error", role: "alert", children: v }) : null,
|
|
2348
|
+
/* @__PURE__ */ a("div", { className: "new-agent__actions", children: /* @__PURE__ */ a(
|
|
2229
2349
|
Z,
|
|
2230
2350
|
{
|
|
2231
2351
|
type: "submit",
|
|
2232
2352
|
variant: "primary",
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2353
|
+
className: Y("new-agent__start-button", {
|
|
2354
|
+
"new-agent__start-button--starting": u
|
|
2355
|
+
}),
|
|
2356
|
+
disabled: !D || u,
|
|
2357
|
+
iconLeftName: u ? "loader" : "sparkles",
|
|
2358
|
+
iconLeftScreenReaderText: u ? "Starting" : void 0,
|
|
2359
|
+
children: u ? "Starting…" : "Start"
|
|
2237
2360
|
}
|
|
2238
2361
|
) })
|
|
2239
2362
|
]
|
|
2240
2363
|
}
|
|
2241
|
-
)
|
|
2242
|
-
/* @__PURE__ */
|
|
2243
|
-
/* @__PURE__ */
|
|
2244
|
-
] }) : /* @__PURE__ */
|
|
2245
|
-
/* @__PURE__ */
|
|
2246
|
-
/* @__PURE__ */
|
|
2364
|
+
), d ? /* @__PURE__ */ l("div", { className: Y("new-agent", "new-agent--embedded"), children: [
|
|
2365
|
+
/* @__PURE__ */ a("div", { className: "new-agent__header", children: m }),
|
|
2366
|
+
/* @__PURE__ */ a("div", { className: "new-agent__body", children: T })
|
|
2367
|
+
] }) : /* @__PURE__ */ l(se, { open: t, closeHandler: e, className: "new-agent", children: [
|
|
2368
|
+
/* @__PURE__ */ a(se.Header, { className: "new-agent__header", children: m }),
|
|
2369
|
+
/* @__PURE__ */ a(se.Body, { className: "new-agent__body", children: T })
|
|
2247
2370
|
] });
|
|
2248
|
-
},
|
|
2371
|
+
}, At = (t) => {
|
|
2249
2372
|
window.location.assign(t);
|
|
2250
|
-
},
|
|
2373
|
+
}, ba = ({
|
|
2251
2374
|
open: t,
|
|
2252
2375
|
authToken: e,
|
|
2253
|
-
headers:
|
|
2376
|
+
headers: n,
|
|
2254
2377
|
agentDefinitionsUrl: s,
|
|
2255
2378
|
agentsUrl: r,
|
|
2256
|
-
closeUrl:
|
|
2257
|
-
successUrl:
|
|
2379
|
+
closeUrl: i,
|
|
2380
|
+
successUrl: o,
|
|
2258
2381
|
onClose: d,
|
|
2259
2382
|
onStart: c,
|
|
2260
|
-
embedded:
|
|
2383
|
+
embedded: w = !1
|
|
2261
2384
|
}) => {
|
|
2262
|
-
const
|
|
2263
|
-
() => new
|
|
2385
|
+
const f = JSON.stringify(n ?? {}), h = W(
|
|
2386
|
+
() => new lt({
|
|
2264
2387
|
token: e,
|
|
2265
|
-
headers:
|
|
2388
|
+
headers: n,
|
|
2266
2389
|
urls: {
|
|
2267
2390
|
agentDefinitions: s,
|
|
2268
2391
|
agents: r
|
|
2269
2392
|
}
|
|
2270
2393
|
}),
|
|
2271
2394
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
|
|
2272
|
-
[e, s, r,
|
|
2273
|
-
), [
|
|
2274
|
-
|
|
2395
|
+
[e, s, r, f]
|
|
2396
|
+
), [u, x] = _([]), [v, b] = _("loading"), [A, D] = _(null), [N, y] = _(0);
|
|
2397
|
+
F(() => {
|
|
2275
2398
|
if (!t)
|
|
2276
2399
|
return;
|
|
2277
|
-
let
|
|
2278
|
-
return
|
|
2400
|
+
let I = !1;
|
|
2401
|
+
return b("loading"), D(null), (async () => {
|
|
2279
2402
|
try {
|
|
2280
|
-
const
|
|
2281
|
-
if (
|
|
2403
|
+
const z = await h.listAgentDefinitions();
|
|
2404
|
+
if (I)
|
|
2282
2405
|
return;
|
|
2283
|
-
|
|
2284
|
-
} catch (
|
|
2285
|
-
if (
|
|
2406
|
+
x(z.map(Lt)), b("idle");
|
|
2407
|
+
} catch (z) {
|
|
2408
|
+
if (I)
|
|
2286
2409
|
return;
|
|
2287
|
-
|
|
2410
|
+
x([]), D($t(z)), b("error");
|
|
2288
2411
|
}
|
|
2289
2412
|
})(), () => {
|
|
2290
|
-
|
|
2413
|
+
I = !0;
|
|
2291
2414
|
};
|
|
2292
|
-
}, [
|
|
2293
|
-
const
|
|
2294
|
-
d == null || d(),
|
|
2295
|
-
}, [
|
|
2296
|
-
async (
|
|
2297
|
-
await
|
|
2298
|
-
invocationName:
|
|
2299
|
-
}), c == null || c(
|
|
2415
|
+
}, [h, t, N]);
|
|
2416
|
+
const m = E(() => {
|
|
2417
|
+
d == null || d(), i && At(i);
|
|
2418
|
+
}, [i, d]), T = E(
|
|
2419
|
+
async (I) => {
|
|
2420
|
+
await h.createAgent(I.definition.ref, {
|
|
2421
|
+
invocationName: I.invocationName
|
|
2422
|
+
}), c == null || c(I), o && At(o);
|
|
2300
2423
|
},
|
|
2301
|
-
[
|
|
2302
|
-
),
|
|
2303
|
-
|
|
2424
|
+
[h, c, o]
|
|
2425
|
+
), P = E(() => {
|
|
2426
|
+
y((I) => I + 1);
|
|
2304
2427
|
}, []);
|
|
2305
|
-
return /* @__PURE__ */
|
|
2306
|
-
|
|
2428
|
+
return /* @__PURE__ */ a(
|
|
2429
|
+
Mt,
|
|
2307
2430
|
{
|
|
2308
2431
|
open: t,
|
|
2309
|
-
onClose:
|
|
2310
|
-
onStart:
|
|
2311
|
-
agentDefinitions:
|
|
2312
|
-
definitionsState:
|
|
2313
|
-
definitionsError:
|
|
2314
|
-
onRetryDefinitions:
|
|
2315
|
-
embedded:
|
|
2432
|
+
onClose: m,
|
|
2433
|
+
onStart: T,
|
|
2434
|
+
agentDefinitions: u,
|
|
2435
|
+
definitionsState: v,
|
|
2436
|
+
definitionsError: A,
|
|
2437
|
+
onRetryDefinitions: P,
|
|
2438
|
+
embedded: w
|
|
2316
2439
|
}
|
|
2317
2440
|
);
|
|
2318
|
-
},
|
|
2319
|
-
|
|
2441
|
+
}, Sa = (t) => "agentDefinitionsUrl" in t, Ca = (t) => Sa(t) ? /* @__PURE__ */ a(ba, { ...t }) : /* @__PURE__ */ a(Mt, { ...t }), Ta = (t) => t !== void 0 && t.some((e) => e.status === G.hitl), Ea = (t, e) => Ta(e) ? C.hitl : t.status, Ra = ({ column: t, label: e }) => t.statusIcon ? /* @__PURE__ */ a("span", { className: "agent-view__status-indicator", children: /* @__PURE__ */ a(
|
|
2442
|
+
O,
|
|
2320
2443
|
{
|
|
2321
2444
|
name: t.statusIcon.name,
|
|
2322
2445
|
size: 16,
|
|
2323
2446
|
color: t.statusIcon.color,
|
|
2324
|
-
className:
|
|
2447
|
+
className: Y({
|
|
2325
2448
|
"agent-view__progress-icon--spinning": t.statusIcon.spin
|
|
2326
2449
|
}),
|
|
2327
2450
|
screenReaderText: e
|
|
2328
2451
|
}
|
|
2329
|
-
) }) : /* @__PURE__ */
|
|
2452
|
+
) }) : /* @__PURE__ */ a(
|
|
2330
2453
|
"span",
|
|
2331
2454
|
{
|
|
2332
|
-
className:
|
|
2455
|
+
className: Y("agent-view__dot", {
|
|
2333
2456
|
[`agent-view__dot--${t.dotModifier}`]: t.dotModifier
|
|
2334
2457
|
}),
|
|
2335
|
-
children: /* @__PURE__ */
|
|
2458
|
+
children: /* @__PURE__ */ a(St, { colour: t.dotColour, label: e })
|
|
2336
2459
|
}
|
|
2337
|
-
),
|
|
2460
|
+
), Ia = ({
|
|
2338
2461
|
agent: t,
|
|
2339
2462
|
agentName: e,
|
|
2340
|
-
column:
|
|
2463
|
+
column: n,
|
|
2341
2464
|
isExpanded: s,
|
|
2342
2465
|
isLoading: r,
|
|
2343
|
-
checklist:
|
|
2344
|
-
error:
|
|
2466
|
+
checklist: i,
|
|
2467
|
+
error: o,
|
|
2345
2468
|
onToggle: d,
|
|
2346
2469
|
onViewAgent: c
|
|
2347
2470
|
}) => {
|
|
2348
|
-
const { id:
|
|
2349
|
-
return /* @__PURE__ */
|
|
2471
|
+
const { id: w, invocation_name: f } = t, h = `agent-card-${w}-header`, u = `agent-card-${w}-progress`;
|
|
2472
|
+
return /* @__PURE__ */ a(
|
|
2350
2473
|
"li",
|
|
2351
2474
|
{
|
|
2352
|
-
className:
|
|
2475
|
+
className: Y("agent-view__card", {
|
|
2353
2476
|
"agent-view__card--expanded": s
|
|
2354
2477
|
}),
|
|
2355
|
-
children: /* @__PURE__ */
|
|
2356
|
-
/* @__PURE__ */
|
|
2478
|
+
children: /* @__PURE__ */ l(Zt, { spacing: "dense", children: [
|
|
2479
|
+
/* @__PURE__ */ a(
|
|
2357
2480
|
"button",
|
|
2358
2481
|
{
|
|
2359
2482
|
type: "button",
|
|
2360
2483
|
className: "agent-view__card-toggle",
|
|
2361
2484
|
"aria-expanded": s,
|
|
2362
|
-
"aria-controls":
|
|
2363
|
-
"aria-label":
|
|
2364
|
-
id:
|
|
2365
|
-
onClick: () => d(
|
|
2366
|
-
children: /* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
2368
|
-
/* @__PURE__ */
|
|
2369
|
-
/* @__PURE__ */
|
|
2370
|
-
/* @__PURE__ */
|
|
2371
|
-
|
|
2485
|
+
"aria-controls": u,
|
|
2486
|
+
"aria-label": f,
|
|
2487
|
+
id: h,
|
|
2488
|
+
onClick: () => d(w),
|
|
2489
|
+
children: /* @__PURE__ */ l("div", { className: "agent-view__card-content", children: [
|
|
2490
|
+
/* @__PURE__ */ a(Ra, { column: n }),
|
|
2491
|
+
/* @__PURE__ */ a("span", { className: "agent-view__card-invocation-name", children: f }),
|
|
2492
|
+
/* @__PURE__ */ a("span", { className: "agent-view__card-agent-name", children: e }),
|
|
2493
|
+
/* @__PURE__ */ a(
|
|
2494
|
+
O,
|
|
2372
2495
|
{
|
|
2373
2496
|
name: s ? "chevron-up" : "chevron-down",
|
|
2374
2497
|
size: 16,
|
|
@@ -2378,42 +2501,42 @@ const Et = (t, e) => (a) => {
|
|
|
2378
2501
|
] })
|
|
2379
2502
|
}
|
|
2380
2503
|
),
|
|
2381
|
-
s && /* @__PURE__ */
|
|
2504
|
+
s && /* @__PURE__ */ l(
|
|
2382
2505
|
"div",
|
|
2383
2506
|
{
|
|
2384
|
-
id:
|
|
2385
|
-
"aria-labelledby":
|
|
2507
|
+
id: u,
|
|
2508
|
+
"aria-labelledby": h,
|
|
2386
2509
|
className: "agent-view__card-progress",
|
|
2387
2510
|
children: [
|
|
2388
|
-
r && /* @__PURE__ */
|
|
2389
|
-
/* @__PURE__ */
|
|
2390
|
-
|
|
2511
|
+
r && /* @__PURE__ */ l("div", { className: "agent-view__progress-loading", "aria-live": "polite", children: [
|
|
2512
|
+
/* @__PURE__ */ a(
|
|
2513
|
+
O,
|
|
2391
2514
|
{
|
|
2392
2515
|
name: "loader",
|
|
2393
2516
|
size: 16,
|
|
2394
2517
|
color: "var(--color-brand-600)",
|
|
2395
2518
|
className: "agent-view__progress-icon--spinning",
|
|
2396
|
-
screenReaderText:
|
|
2519
|
+
screenReaderText: _e
|
|
2397
2520
|
}
|
|
2398
2521
|
),
|
|
2399
|
-
/* @__PURE__ */
|
|
2522
|
+
/* @__PURE__ */ a("span", { children: _e })
|
|
2400
2523
|
] }),
|
|
2401
|
-
!r &&
|
|
2402
|
-
!r && !
|
|
2403
|
-
!r && !
|
|
2404
|
-
/* @__PURE__ */
|
|
2405
|
-
|
|
2524
|
+
!r && o && /* @__PURE__ */ a("p", { className: "agent-view__progress-error", role: "alert", children: o }),
|
|
2525
|
+
!r && !o && i !== null && /* @__PURE__ */ a(bn, { checklist: i }),
|
|
2526
|
+
!r && !o && i === null && /* @__PURE__ */ l("div", { className: "agent-view__progress-loading", "aria-live": "polite", children: [
|
|
2527
|
+
/* @__PURE__ */ a(
|
|
2528
|
+
O,
|
|
2406
2529
|
{
|
|
2407
2530
|
name: "loader",
|
|
2408
2531
|
size: 16,
|
|
2409
2532
|
color: "var(--color-brand-600)",
|
|
2410
2533
|
className: "agent-view__progress-icon--spinning",
|
|
2411
|
-
screenReaderText:
|
|
2534
|
+
screenReaderText: _e
|
|
2412
2535
|
}
|
|
2413
2536
|
),
|
|
2414
|
-
/* @__PURE__ */
|
|
2537
|
+
/* @__PURE__ */ a("span", { children: _e })
|
|
2415
2538
|
] }),
|
|
2416
|
-
/* @__PURE__ */
|
|
2539
|
+
/* @__PURE__ */ a("div", { className: "agent-view__card-actions", children: /* @__PURE__ */ a(
|
|
2417
2540
|
Z,
|
|
2418
2541
|
{
|
|
2419
2542
|
variant: "secondary",
|
|
@@ -2428,240 +2551,240 @@ const Et = (t, e) => (a) => {
|
|
|
2428
2551
|
] })
|
|
2429
2552
|
}
|
|
2430
2553
|
);
|
|
2431
|
-
},
|
|
2554
|
+
}, bt = ({
|
|
2432
2555
|
column: t,
|
|
2433
2556
|
agents: e,
|
|
2434
|
-
expandedAgentId:
|
|
2557
|
+
expandedAgentId: n,
|
|
2435
2558
|
loadingAgentId: s,
|
|
2436
2559
|
checklistByInvocationId: r,
|
|
2437
|
-
errorByAgentId:
|
|
2438
|
-
definitionNameByRef:
|
|
2560
|
+
errorByAgentId: i,
|
|
2561
|
+
definitionNameByRef: o,
|
|
2439
2562
|
onToggleAgent: d,
|
|
2440
2563
|
onViewAgent: c,
|
|
2441
|
-
isSplit:
|
|
2442
|
-
}) => /* @__PURE__ */
|
|
2564
|
+
isSplit: w = !1
|
|
2565
|
+
}) => /* @__PURE__ */ l(
|
|
2443
2566
|
"section",
|
|
2444
2567
|
{
|
|
2445
|
-
className:
|
|
2446
|
-
"agent-view__column--split":
|
|
2568
|
+
className: Y("agent-view__column", {
|
|
2569
|
+
"agent-view__column--split": w
|
|
2447
2570
|
}),
|
|
2448
2571
|
"aria-label": t.title,
|
|
2449
2572
|
children: [
|
|
2450
|
-
/* @__PURE__ */
|
|
2451
|
-
/* @__PURE__ */
|
|
2452
|
-
/* @__PURE__ */
|
|
2573
|
+
/* @__PURE__ */ l("div", { className: "agent-view__column-header", children: [
|
|
2574
|
+
/* @__PURE__ */ a(ve, { level: 4, children: t.title }),
|
|
2575
|
+
/* @__PURE__ */ a("span", { className: "agent-view__column-count", children: e.length })
|
|
2453
2576
|
] }),
|
|
2454
|
-
/* @__PURE__ */
|
|
2455
|
-
|
|
2577
|
+
/* @__PURE__ */ a("ul", { className: "agent-view__card-list", children: e.map((f) => /* @__PURE__ */ a(
|
|
2578
|
+
Ia,
|
|
2456
2579
|
{
|
|
2457
|
-
agent:
|
|
2458
|
-
agentName:
|
|
2580
|
+
agent: f,
|
|
2581
|
+
agentName: it(f, o),
|
|
2459
2582
|
column: t,
|
|
2460
|
-
isExpanded:
|
|
2461
|
-
isLoading: s ===
|
|
2462
|
-
checklist: r[
|
|
2463
|
-
error:
|
|
2583
|
+
isExpanded: n === f.id,
|
|
2584
|
+
isLoading: s === f.id,
|
|
2585
|
+
checklist: r[f.invocation_id] ?? null,
|
|
2586
|
+
error: i[f.id] ?? null,
|
|
2464
2587
|
onToggle: d,
|
|
2465
2588
|
onViewAgent: c
|
|
2466
2589
|
},
|
|
2467
|
-
|
|
2590
|
+
f.id
|
|
2468
2591
|
)) })
|
|
2469
2592
|
]
|
|
2470
2593
|
}
|
|
2471
|
-
),
|
|
2594
|
+
), it = (t, e) => e.get(t.agent_definition_ref) ?? t.agent_definition_ref.replace(/_/g, " "), $a = ({
|
|
2472
2595
|
jwt: t,
|
|
2473
2596
|
headers: e,
|
|
2474
|
-
agentDefinitionsUrl:
|
|
2597
|
+
agentDefinitionsUrl: n,
|
|
2475
2598
|
agentsUrl: s,
|
|
2476
2599
|
agentUrl: r,
|
|
2477
|
-
agentChecklistUrl:
|
|
2478
|
-
agentResourcesUrl:
|
|
2600
|
+
agentChecklistUrl: i,
|
|
2601
|
+
agentResourcesUrl: o,
|
|
2479
2602
|
agentTimelineUrl: d,
|
|
2480
2603
|
agentChatUrl: c,
|
|
2481
|
-
agentConversationUrl:
|
|
2482
|
-
enableUpload:
|
|
2483
|
-
showHeader:
|
|
2484
|
-
institutions:
|
|
2604
|
+
agentConversationUrl: w,
|
|
2605
|
+
enableUpload: f,
|
|
2606
|
+
showHeader: h = !1,
|
|
2607
|
+
institutions: u
|
|
2485
2608
|
}) => {
|
|
2486
|
-
var
|
|
2487
|
-
const
|
|
2609
|
+
var xe;
|
|
2610
|
+
const x = W(
|
|
2488
2611
|
() => ({
|
|
2489
|
-
agentDefinitions:
|
|
2612
|
+
agentDefinitions: n,
|
|
2490
2613
|
agents: s,
|
|
2491
2614
|
agent: r,
|
|
2492
|
-
agentChecklist:
|
|
2493
|
-
...
|
|
2615
|
+
agentChecklist: i,
|
|
2616
|
+
...o ? { agentResources: o } : {},
|
|
2494
2617
|
...d ? { agentTimeline: d } : {},
|
|
2495
2618
|
agentChat: c,
|
|
2496
|
-
agentConversation:
|
|
2619
|
+
agentConversation: w
|
|
2497
2620
|
}),
|
|
2498
2621
|
[
|
|
2499
|
-
|
|
2622
|
+
n,
|
|
2500
2623
|
s,
|
|
2501
2624
|
r,
|
|
2502
|
-
l,
|
|
2503
2625
|
i,
|
|
2626
|
+
o,
|
|
2504
2627
|
d,
|
|
2505
2628
|
c,
|
|
2506
|
-
|
|
2629
|
+
w
|
|
2507
2630
|
]
|
|
2508
|
-
), [
|
|
2509
|
-
(
|
|
2510
|
-
)) == null ? void 0 :
|
|
2511
|
-
const
|
|
2512
|
-
return
|
|
2513
|
-
}, [e,
|
|
2514
|
-
agents:
|
|
2515
|
-
agentDefinitions:
|
|
2516
|
-
loadState:
|
|
2517
|
-
loadError:
|
|
2518
|
-
reload:
|
|
2519
|
-
refresh:
|
|
2520
|
-
fetchAgentChecklist:
|
|
2631
|
+
), [v, b] = _(null), A = v ? (xe = u == null ? void 0 : u.find(
|
|
2632
|
+
(p) => p.applicationId === v.application_id
|
|
2633
|
+
)) == null ? void 0 : xe.applicationUrl : void 0, D = W(() => {
|
|
2634
|
+
const p = { ...e ?? {} };
|
|
2635
|
+
return A ? p[ge.arborApplicationUrl] = A : delete p[ge.arborApplicationUrl], p;
|
|
2636
|
+
}, [e, A]), {
|
|
2637
|
+
agents: N,
|
|
2638
|
+
agentDefinitions: y,
|
|
2639
|
+
loadState: m,
|
|
2640
|
+
loadError: T,
|
|
2641
|
+
reload: P,
|
|
2642
|
+
refresh: I,
|
|
2643
|
+
fetchAgentChecklist: z,
|
|
2521
2644
|
createAgent: ee
|
|
2522
|
-
} =
|
|
2523
|
-
const
|
|
2524
|
-
(
|
|
2645
|
+
} = pa({ jwt: t, headers: D, urls: x }), [L, B] = _(!1), [U, J] = _(null), [j, q] = _(null), [$, Re] = _({}), [he, we] = _({}), [ue, je] = _([]), [ne, Xe] = _([]), ye = W(() => {
|
|
2646
|
+
const p = new Set(N.map((k) => k.application_id)), S = new Map(
|
|
2647
|
+
(u ?? []).map((k) => [k.applicationId, k.name])
|
|
2525
2648
|
);
|
|
2526
|
-
return [...
|
|
2527
|
-
(k,
|
|
2649
|
+
return [...p].sort(
|
|
2650
|
+
(k, V) => (S.get(k) ?? k).localeCompare(S.get(V) ?? V)
|
|
2528
2651
|
).map((k) => ({
|
|
2529
2652
|
value: k,
|
|
2530
2653
|
label: S.get(k) ?? k
|
|
2531
2654
|
}));
|
|
2532
|
-
}, [
|
|
2533
|
-
() => new Map(
|
|
2534
|
-
[
|
|
2535
|
-
),
|
|
2536
|
-
|
|
2655
|
+
}, [N, u]), re = W(
|
|
2656
|
+
() => new Map(y.map((p) => [p.ref, p.display_name])),
|
|
2657
|
+
[y]
|
|
2658
|
+
), Ne = W(() => [...new Set(
|
|
2659
|
+
N.map((S) => it(S, re))
|
|
2537
2660
|
)].sort((S, k) => S.localeCompare(k)).map((S) => ({
|
|
2538
2661
|
value: S,
|
|
2539
2662
|
label: S
|
|
2540
|
-
})), [
|
|
2541
|
-
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2663
|
+
})), [N, re]), Ie = W(() => N.filter((p) => !(ue.length > 0 && !ue.includes(p.application_id) || ne.length > 0 && !ne.includes(it(p, re)))), [N, re, ne, ue]), pe = ye.length > 1, Oe = Ne.length > 1, Pe = pe || Oe;
|
|
2664
|
+
F(() => {
|
|
2665
|
+
const p = window.setInterval(() => {
|
|
2666
|
+
I();
|
|
2544
2667
|
}, 6e4);
|
|
2545
2668
|
return () => {
|
|
2546
|
-
window.clearInterval(
|
|
2669
|
+
window.clearInterval(p);
|
|
2547
2670
|
};
|
|
2548
|
-
}, [
|
|
2549
|
-
if (
|
|
2671
|
+
}, [I]), F(() => {
|
|
2672
|
+
if (N.length === 0)
|
|
2550
2673
|
return;
|
|
2551
|
-
let
|
|
2674
|
+
let p = !1;
|
|
2552
2675
|
return (async () => {
|
|
2553
2676
|
const S = await Promise.allSettled(
|
|
2554
|
-
|
|
2555
|
-
const
|
|
2677
|
+
N.map(async (k) => {
|
|
2678
|
+
const V = await z(k.invocation_id);
|
|
2556
2679
|
return {
|
|
2557
2680
|
agentId: k.id,
|
|
2558
2681
|
invocationId: k.invocation_id,
|
|
2559
|
-
checklist:
|
|
2682
|
+
checklist: V.checklist
|
|
2560
2683
|
};
|
|
2561
2684
|
})
|
|
2562
2685
|
);
|
|
2563
|
-
|
|
2564
|
-
const
|
|
2565
|
-
let
|
|
2566
|
-
for (const
|
|
2567
|
-
if (
|
|
2686
|
+
p || (Re((k) => {
|
|
2687
|
+
const V = { ...k };
|
|
2688
|
+
let ie = !1;
|
|
2689
|
+
for (const ae of S) {
|
|
2690
|
+
if (ae.status !== "fulfilled")
|
|
2568
2691
|
continue;
|
|
2569
|
-
const { invocationId: le, checklist:
|
|
2570
|
-
JSON.stringify(k[le]) !== JSON.stringify(
|
|
2692
|
+
const { invocationId: le, checklist: Se } = ae.value;
|
|
2693
|
+
JSON.stringify(k[le]) !== JSON.stringify(Se) && (V[le] = Se, ie = !0);
|
|
2571
2694
|
}
|
|
2572
|
-
return
|
|
2573
|
-
}),
|
|
2574
|
-
const
|
|
2575
|
-
let
|
|
2576
|
-
return S.forEach((
|
|
2577
|
-
|
|
2578
|
-
}),
|
|
2695
|
+
return ie ? V : k;
|
|
2696
|
+
}), we((k) => {
|
|
2697
|
+
const V = { ...k };
|
|
2698
|
+
let ie = !1;
|
|
2699
|
+
return S.forEach((ae, le) => {
|
|
2700
|
+
ae.status === "rejected" && V[N[le].id] !== qe && (V[N[le].id] = qe, ie = !0);
|
|
2701
|
+
}), ie ? V : k;
|
|
2579
2702
|
}));
|
|
2580
2703
|
})(), () => {
|
|
2581
|
-
|
|
2704
|
+
p = !0;
|
|
2582
2705
|
};
|
|
2583
|
-
}, [
|
|
2584
|
-
const
|
|
2585
|
-
async (
|
|
2586
|
-
if (
|
|
2587
|
-
|
|
2706
|
+
}, [N, z]);
|
|
2707
|
+
const Le = E(
|
|
2708
|
+
async (p) => {
|
|
2709
|
+
if (!$[p.invocation_id]) {
|
|
2710
|
+
q(p.id), we((S) => {
|
|
2588
2711
|
const k = { ...S };
|
|
2589
|
-
return delete k[
|
|
2712
|
+
return delete k[p.id], k;
|
|
2590
2713
|
});
|
|
2591
2714
|
try {
|
|
2592
|
-
const S = await
|
|
2593
|
-
|
|
2715
|
+
const S = await z(p.invocation_id);
|
|
2716
|
+
Re((k) => ({
|
|
2594
2717
|
...k,
|
|
2595
|
-
[
|
|
2718
|
+
[p.invocation_id]: S.checklist
|
|
2596
2719
|
}));
|
|
2597
2720
|
} catch {
|
|
2598
|
-
|
|
2721
|
+
we((S) => ({
|
|
2599
2722
|
...S,
|
|
2600
|
-
[
|
|
2723
|
+
[p.id]: qe
|
|
2601
2724
|
}));
|
|
2602
2725
|
} finally {
|
|
2603
|
-
|
|
2726
|
+
q((S) => S === p.id ? null : S);
|
|
2604
2727
|
}
|
|
2605
2728
|
}
|
|
2606
2729
|
},
|
|
2607
|
-
[
|
|
2608
|
-
),
|
|
2609
|
-
(
|
|
2610
|
-
if (
|
|
2611
|
-
|
|
2730
|
+
[z, $]
|
|
2731
|
+
), ke = E(
|
|
2732
|
+
(p) => {
|
|
2733
|
+
if (U === p) {
|
|
2734
|
+
J(null);
|
|
2612
2735
|
return;
|
|
2613
2736
|
}
|
|
2614
|
-
const S =
|
|
2615
|
-
S && (
|
|
2737
|
+
const S = N.find(({ id: k }) => k === p);
|
|
2738
|
+
S && (J(p), Le(S));
|
|
2616
2739
|
},
|
|
2617
|
-
[
|
|
2618
|
-
),
|
|
2619
|
-
const
|
|
2620
|
-
for (const S of
|
|
2621
|
-
const k =
|
|
2740
|
+
[N, U, Le]
|
|
2741
|
+
), Ue = W(() => {
|
|
2742
|
+
const p = {};
|
|
2743
|
+
for (const S of Ie) {
|
|
2744
|
+
const k = Ea(
|
|
2622
2745
|
S,
|
|
2623
|
-
|
|
2746
|
+
$[S.invocation_id]
|
|
2624
2747
|
);
|
|
2625
|
-
(
|
|
2748
|
+
(p[k] ?? (p[k] = [])).push(S);
|
|
2626
2749
|
}
|
|
2627
|
-
return
|
|
2628
|
-
}, [
|
|
2629
|
-
|
|
2630
|
-
}, []),
|
|
2631
|
-
async (
|
|
2632
|
-
const S = await ee(
|
|
2633
|
-
|
|
2750
|
+
return p;
|
|
2751
|
+
}, [Ie, $]), Ae = E((p) => {
|
|
2752
|
+
b(p);
|
|
2753
|
+
}, []), Qe = E(
|
|
2754
|
+
async (p) => {
|
|
2755
|
+
const S = await ee(p);
|
|
2756
|
+
b(S), B(!1);
|
|
2634
2757
|
},
|
|
2635
2758
|
[ee]
|
|
2636
|
-
),
|
|
2637
|
-
|
|
2638
|
-
}, []),
|
|
2639
|
-
expandedAgentId:
|
|
2640
|
-
loadingAgentId:
|
|
2641
|
-
checklistByInvocationId:
|
|
2642
|
-
errorByAgentId:
|
|
2643
|
-
definitionNameByRef:
|
|
2644
|
-
onToggleAgent:
|
|
2645
|
-
onViewAgent:
|
|
2759
|
+
), be = E(() => {
|
|
2760
|
+
b(null);
|
|
2761
|
+
}, []), oe = {
|
|
2762
|
+
expandedAgentId: U,
|
|
2763
|
+
loadingAgentId: j,
|
|
2764
|
+
checklistByInvocationId: $,
|
|
2765
|
+
errorByAgentId: he,
|
|
2766
|
+
definitionNameByRef: re,
|
|
2767
|
+
onToggleAgent: ke,
|
|
2768
|
+
onViewAgent: Ae
|
|
2646
2769
|
};
|
|
2647
|
-
return /* @__PURE__ */
|
|
2648
|
-
|
|
2649
|
-
/* @__PURE__ */
|
|
2650
|
-
/* @__PURE__ */
|
|
2770
|
+
return /* @__PURE__ */ l("div", { className: "agent-view-frontend agent-view", children: [
|
|
2771
|
+
h && /* @__PURE__ */ l("div", { className: "agent-view__header", children: [
|
|
2772
|
+
/* @__PURE__ */ a(ve, { level: 1, children: "Agents" }),
|
|
2773
|
+
/* @__PURE__ */ a(
|
|
2651
2774
|
Z,
|
|
2652
2775
|
{
|
|
2653
2776
|
variant: "primary",
|
|
2654
2777
|
size: "S",
|
|
2655
2778
|
iconLeftName: "sparkles",
|
|
2656
2779
|
iconLeftScreenReaderText: "Start an agent",
|
|
2657
|
-
onClick: () =>
|
|
2780
|
+
onClick: () => B(!0),
|
|
2658
2781
|
children: "Start an agent"
|
|
2659
2782
|
}
|
|
2660
2783
|
)
|
|
2661
2784
|
] }),
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
/* @__PURE__ */
|
|
2785
|
+
N.length > 0 && Pe && /* @__PURE__ */ l("div", { className: "agent-view__filters", children: [
|
|
2786
|
+
pe && /* @__PURE__ */ l("div", { className: "agent-view__filter", children: [
|
|
2787
|
+
/* @__PURE__ */ a(
|
|
2665
2788
|
"label",
|
|
2666
2789
|
{
|
|
2667
2790
|
className: "agent-view__filter-label",
|
|
@@ -2669,25 +2792,25 @@ const Et = (t, e) => (a) => {
|
|
|
2669
2792
|
children: "Institution"
|
|
2670
2793
|
}
|
|
2671
2794
|
),
|
|
2672
|
-
/* @__PURE__ */
|
|
2673
|
-
|
|
2795
|
+
/* @__PURE__ */ a(
|
|
2796
|
+
ut,
|
|
2674
2797
|
{
|
|
2675
2798
|
id: "agent-view-institution-filter",
|
|
2676
2799
|
triggerVariant: "button",
|
|
2677
2800
|
multiple: !0,
|
|
2678
2801
|
searchType: "substring",
|
|
2679
2802
|
placeholder: "All institutions",
|
|
2680
|
-
options:
|
|
2681
|
-
value:
|
|
2682
|
-
onValueChange:
|
|
2803
|
+
options: ye,
|
|
2804
|
+
value: ue,
|
|
2805
|
+
onValueChange: je,
|
|
2683
2806
|
showSelectionCountBadge: !0,
|
|
2684
2807
|
showClearAll: !0,
|
|
2685
2808
|
clearAllLabel: "Clear institutions"
|
|
2686
2809
|
}
|
|
2687
2810
|
)
|
|
2688
2811
|
] }),
|
|
2689
|
-
Oe && /* @__PURE__ */
|
|
2690
|
-
/* @__PURE__ */
|
|
2812
|
+
Oe && /* @__PURE__ */ l("div", { className: "agent-view__filter", children: [
|
|
2813
|
+
/* @__PURE__ */ a(
|
|
2691
2814
|
"label",
|
|
2692
2815
|
{
|
|
2693
2816
|
className: "agent-view__filter-label",
|
|
@@ -2695,17 +2818,17 @@ const Et = (t, e) => (a) => {
|
|
|
2695
2818
|
children: "Agent"
|
|
2696
2819
|
}
|
|
2697
2820
|
),
|
|
2698
|
-
/* @__PURE__ */
|
|
2699
|
-
|
|
2821
|
+
/* @__PURE__ */ a(
|
|
2822
|
+
ut,
|
|
2700
2823
|
{
|
|
2701
2824
|
id: "agent-view-agent-filter",
|
|
2702
2825
|
triggerVariant: "button",
|
|
2703
2826
|
multiple: !0,
|
|
2704
2827
|
searchType: "substring",
|
|
2705
2828
|
placeholder: "All agents",
|
|
2706
|
-
options:
|
|
2707
|
-
value:
|
|
2708
|
-
onValueChange:
|
|
2829
|
+
options: Ne,
|
|
2830
|
+
value: ne,
|
|
2831
|
+
onValueChange: Xe,
|
|
2709
2832
|
showSelectionCountBadge: !0,
|
|
2710
2833
|
showClearAll: !0,
|
|
2711
2834
|
clearAllLabel: "Clear agents"
|
|
@@ -2713,117 +2836,117 @@ const Et = (t, e) => (a) => {
|
|
|
2713
2836
|
)
|
|
2714
2837
|
] })
|
|
2715
2838
|
] }),
|
|
2716
|
-
|
|
2717
|
-
/* @__PURE__ */
|
|
2718
|
-
|
|
2839
|
+
m === "error" ? /* @__PURE__ */ l("div", { className: "agent-view__state agent-view__state--error", role: "alert", children: [
|
|
2840
|
+
/* @__PURE__ */ a(
|
|
2841
|
+
O,
|
|
2719
2842
|
{
|
|
2720
2843
|
name: "triangle-alert",
|
|
2721
2844
|
size: 24,
|
|
2722
2845
|
color: "var(--color-semantic-destructive-600)"
|
|
2723
2846
|
}
|
|
2724
2847
|
),
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
] }) :
|
|
2728
|
-
/* @__PURE__ */
|
|
2729
|
-
|
|
2848
|
+
/* @__PURE__ */ a("p", { className: "agent-view__state-message", children: T ?? Rt }),
|
|
2849
|
+
/* @__PURE__ */ a(Z, { variant: "secondary", size: "S", onClick: P, children: "Try again" })
|
|
2850
|
+
] }) : m === "loading" && N.length === 0 ? /* @__PURE__ */ l("div", { className: "agent-view__state", "aria-live": "polite", children: [
|
|
2851
|
+
/* @__PURE__ */ a(
|
|
2852
|
+
O,
|
|
2730
2853
|
{
|
|
2731
2854
|
name: "loader",
|
|
2732
2855
|
size: 24,
|
|
2733
2856
|
color: "var(--color-brand-600)",
|
|
2734
2857
|
className: "agent-view__progress-icon--spinning",
|
|
2735
|
-
screenReaderText:
|
|
2858
|
+
screenReaderText: mt
|
|
2736
2859
|
}
|
|
2737
2860
|
),
|
|
2738
|
-
/* @__PURE__ */
|
|
2739
|
-
] }) :
|
|
2740
|
-
|
|
2741
|
-
|
|
2861
|
+
/* @__PURE__ */ a("p", { className: "agent-view__state-message", children: mt })
|
|
2862
|
+
] }) : N.length === 0 ? /* @__PURE__ */ a(vn, {}) : /* @__PURE__ */ l("div", { className: "agent-view__board", children: [
|
|
2863
|
+
sn.map((p) => /* @__PURE__ */ a(
|
|
2864
|
+
bt,
|
|
2742
2865
|
{
|
|
2743
|
-
column:
|
|
2744
|
-
agents:
|
|
2745
|
-
...
|
|
2866
|
+
column: Ke[p],
|
|
2867
|
+
agents: Ue[p] ?? [],
|
|
2868
|
+
...oe
|
|
2746
2869
|
},
|
|
2747
|
-
|
|
2870
|
+
p
|
|
2748
2871
|
)),
|
|
2749
|
-
/* @__PURE__ */
|
|
2750
|
-
|
|
2872
|
+
/* @__PURE__ */ a("div", { className: "agent-view__split-column", children: rn.map((p) => /* @__PURE__ */ a(
|
|
2873
|
+
bt,
|
|
2751
2874
|
{
|
|
2752
|
-
column:
|
|
2753
|
-
agents:
|
|
2875
|
+
column: Ke[p],
|
|
2876
|
+
agents: Ue[p] ?? [],
|
|
2754
2877
|
isSplit: !0,
|
|
2755
|
-
...
|
|
2878
|
+
...oe
|
|
2756
2879
|
},
|
|
2757
|
-
|
|
2880
|
+
p
|
|
2758
2881
|
)) })
|
|
2759
2882
|
] }),
|
|
2760
|
-
|
|
2761
|
-
|
|
2883
|
+
v && /* @__PURE__ */ a(
|
|
2884
|
+
Na,
|
|
2762
2885
|
{
|
|
2763
|
-
agent:
|
|
2764
|
-
invocationId:
|
|
2886
|
+
agent: v,
|
|
2887
|
+
invocationId: v.invocation_id,
|
|
2765
2888
|
open: !0,
|
|
2766
2889
|
jwt: t,
|
|
2767
|
-
headers:
|
|
2890
|
+
headers: D,
|
|
2768
2891
|
agentUrl: r,
|
|
2769
|
-
agentChecklistUrl:
|
|
2770
|
-
agentResourcesUrl:
|
|
2892
|
+
agentChecklistUrl: i,
|
|
2893
|
+
agentResourcesUrl: o,
|
|
2771
2894
|
agentTimelineUrl: d,
|
|
2772
2895
|
agentChatUrl: c,
|
|
2773
|
-
agentConversationUrl:
|
|
2774
|
-
enableUpload:
|
|
2775
|
-
initialChecklist:
|
|
2776
|
-
onClose:
|
|
2896
|
+
agentConversationUrl: w,
|
|
2897
|
+
enableUpload: f,
|
|
2898
|
+
initialChecklist: $[v.invocation_id] ?? null,
|
|
2899
|
+
onClose: be
|
|
2777
2900
|
},
|
|
2778
|
-
|
|
2901
|
+
v.id
|
|
2779
2902
|
),
|
|
2780
|
-
/* @__PURE__ */
|
|
2781
|
-
|
|
2903
|
+
/* @__PURE__ */ a(
|
|
2904
|
+
Ca,
|
|
2782
2905
|
{
|
|
2783
|
-
open:
|
|
2784
|
-
onClose: () =>
|
|
2785
|
-
onStart:
|
|
2786
|
-
agentDefinitions:
|
|
2906
|
+
open: L,
|
|
2907
|
+
onClose: () => B(!1),
|
|
2908
|
+
onStart: Qe,
|
|
2909
|
+
agentDefinitions: y
|
|
2787
2910
|
}
|
|
2788
2911
|
)
|
|
2789
2912
|
] });
|
|
2790
|
-
},
|
|
2791
|
-
const
|
|
2913
|
+
}, Ma = (t, e) => {
|
|
2914
|
+
const n = Date.now(), s = e.trim() || t.agent_intent;
|
|
2792
2915
|
return {
|
|
2793
|
-
id: `agent-${
|
|
2794
|
-
invocation_id: `inv-${
|
|
2916
|
+
id: `agent-${n}`,
|
|
2917
|
+
invocation_id: `inv-${n}`,
|
|
2795
2918
|
agent_definition_ref: t.ref,
|
|
2796
2919
|
agent_intent: t.agent_intent,
|
|
2797
2920
|
invocation_name: s,
|
|
2798
|
-
application_id:
|
|
2799
|
-
created_by:
|
|
2800
|
-
status:
|
|
2921
|
+
application_id: on,
|
|
2922
|
+
created_by: ln,
|
|
2923
|
+
status: C["generating-a-response"],
|
|
2801
2924
|
context_ref: null,
|
|
2802
2925
|
checklist_ref: null
|
|
2803
2926
|
};
|
|
2804
2927
|
};
|
|
2805
2928
|
export {
|
|
2806
|
-
|
|
2807
|
-
|
|
2929
|
+
$a as AgentMonitorKanban,
|
|
2930
|
+
lt as AgentServiceClient,
|
|
2808
2931
|
Te as AgentServiceError,
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2932
|
+
Na as AgentView,
|
|
2933
|
+
ga as HttpChatConnector,
|
|
2934
|
+
Ca as NewAgentModal,
|
|
2935
|
+
Ma as buildAgentFromDefinition,
|
|
2936
|
+
Dt as createHttpChatConnectorFactory,
|
|
2937
|
+
vt as mapApiAgent,
|
|
2938
|
+
Lt as mapApiAgentDefinition,
|
|
2939
|
+
Jn as mapApiAgentStatus,
|
|
2940
|
+
Qn as mapApiAgentTimelineResponse,
|
|
2941
|
+
xt as mapApiChecklistEndpointResponse,
|
|
2942
|
+
Ut as mapApiChecklistItem,
|
|
2943
|
+
ea as mapApiChecklistResponse,
|
|
2944
|
+
Wn as mapApiChecklistStatus,
|
|
2945
|
+
ta as mapApiConversationMessages,
|
|
2946
|
+
Ye as mapApiOpeningMessage,
|
|
2947
|
+
jn as mapApiResource,
|
|
2948
|
+
Xn as mapApiResourcesEndpointResponse,
|
|
2949
|
+
Da as mapApiTripOption,
|
|
2950
|
+
pa as useAgentService,
|
|
2951
|
+
_a as useAgentWorkspace
|
|
2829
2952
|
};
|