@arbor-education/agent-view-frontend 0.4.10 → 0.5.0

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