@arbor-education/agent-view-frontend 0.4.9 → 0.4.11-alpha.2

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 p, useLayoutEffect as Se, useEffect as H, useMemo as Y, useCallback as C } from "react";
3
+ import W from "classnames";
4
+ import { Heading as Ce, Icon as P, Dot as zt, SlideoverUtils as Xe, SlideoverManager as mn, Modal as ue, Button as te, Tabs as dt, SelectDropdown as _n, TextInput as fn, Combobox as At, Card as vn } from "@arbor-education/design-system.components";
5
+ import { CHAT_RESPONSE_TYPE_AGENT as Gt, CHAT_RESPONSE_TYPE_ERROR as wn, ChatPanel as yn, CHAT_RESPONSE_TYPE_USER as kn, CHAT_RESPONSE_TYPE_INFO as Nn } 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
+ }, $ = {
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
+ }, An = {
33
+ user_file: "user_file"
34
+ }, bt = {
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
+ [$.complete]: {
40
43
  label: "Complete",
41
44
  icon: "circle-check",
42
45
  color: "var(--color-semantic-success-600)"
43
46
  },
44
- [q.failed]: {
47
+ [$.failed]: {
45
48
  label: "Failed",
46
49
  icon: "circle-x",
47
50
  color: "var(--color-semantic-destructive-600)"
48
51
  },
49
- [q.hitl]: {
52
+ [$.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
+ [$["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
+ }, et = {
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
+ }, bn = [
101
+ E["generating-a-response"],
102
+ E.hitl
103
+ ], Sn = [
104
+ E.complete,
105
+ E.failed
106
+ ], Cn = "m4", En = "1", Ft = "msg-opening", Qe = "Unable to load agent tasks. Please try again.", Tn = "Unable to load the resources for this agent", Rn = "Unable to load this document. Please try again.", Bt = "Unable to load the timeline for this agent", In = "Something went wrong. Please try again.", qt = "Unable to load agents. Please try again.", be = "Loading tasks…", St = "Loading agents…", On = "Task", Ln = {
107
+ [B.briefing]: "Briefing",
108
+ [B.running]: "Working",
109
+ [B.stopped]: "Stopped",
110
+ [B.complete]: "Complete"
111
+ }, Un = [
112
+ E["generating-a-response"],
113
+ E.hitl,
114
+ E.complete,
115
+ E.failed
116
+ ], Pn = {
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
+ }, xn = () => /* @__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,249 +230,262 @@ 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
+ ), Dn = ({ status: e }) => {
238
+ const t = et[e];
239
+ return t.statusIcon ? /* @__PURE__ */ a(
237
240
  P,
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(zt, { colour: t.dotColour, label: t.title });
248
+ }, Mn = () => /* @__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(Ce, { 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: Un.map((e) => {
258
+ const t = et[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(Dn, { 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: Pn[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(xn, {}) })
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
+ ), $n = () => ({
277
+ needsInput: [],
278
+ complete: [],
279
+ failed: [],
280
+ tasks: []
281
+ }), Hn = (e, t) => ({
282
+ ...e,
283
+ ...t.length > 0 ? { children: t } : {}
284
+ }), Jt = (e) => {
285
+ const t = [], n = [], s = [], r = [];
286
+ for (const o of e) {
287
+ const i = o.children ? Jt(o.children) : $n();
288
+ if (t.push(...i.needsInput), n.push(...i.complete), s.push(...i.failed), o.status === $.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 === $.complete) {
293
+ n.push({ ...o, children: void 0 });
294
+ continue;
295
+ }
296
+ if (o.status === $.failed) {
297
+ s.push({ ...o, children: void 0 });
298
+ continue;
299
+ }
300
+ r.push(Hn(o, i.tasks));
301
+ }
302
+ return { needsInput: t, complete: n, failed: s, tasks: r };
303
+ }, Ct = (e) => e === $.hitl ? 0 : e === $.complete ? 1 : e === $.failed ? 2 : 3, zn = (e) => e.map((t, n) => ({ item: t, index: n })).sort((t, n) => {
304
+ const s = Ct(t.item.status) - Ct(n.item.status);
305
+ return s !== 0 ? s : t.index - n.index;
306
+ }).map(({ item: t }) => t), ht = 2, Gn = (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
+ }, Fn = (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), u = le(null), [c, g] = p(!1), [_, N] = p(!1), [y, I] = p(null), L = () => {
333
+ var O;
334
+ return s ? ((O = i.current) == null ? void 0 : O.querySelector(s)) ?? null : u.current;
335
+ }, f = () => {
336
+ const O = L(), A = Gn(O);
337
+ if (g(
338
+ (m) => m === A.canScrollUp ? m : A.canScrollUp
339
+ ), N(
340
+ (m) => m === A.canScrollDown ? m : A.canScrollDown
341
+ ), s) {
342
+ const m = Fn(i.current, O);
343
+ I((b) => (b == null ? void 0 : b.top) === (m == null ? void 0 : m.top) && (b == null ? void 0 : b.left) === (m == null ? void 0 : m.left) && (b == null ? void 0 : b.width) === (m == null ? void 0 : m.width) && (b == null ? void 0 : b.height) === (m == null ? void 0 : m.height) ? b : m);
328
344
  } else
329
- x((m) => m === null ? m : null);
345
+ I((m) => m === null ? m : null);
330
346
  };
331
- je(() => {
332
- b();
333
- }), G(() => {
334
- const N = i.current;
335
- if (!N)
347
+ Se(() => {
348
+ f();
349
+ }), H(() => {
350
+ const O = i.current;
351
+ if (!O)
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, m = null;
354
+ const b = () => {
355
+ A == null || A.removeEventListener("scroll", f), m == null || m.disconnect(), m = 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 (b(), 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 }), m = new ResizeObserver(() => f()), m.observe(A), A.firstElementChild instanceof HTMLElement && m.observe(A.firstElementChild), f();
350
366
  };
351
- L(w());
352
- const O = new MutationObserver(() => {
353
- L(w());
367
+ v(L());
368
+ const R = new MutationObserver(() => {
369
+ v(L());
354
370
  });
355
- return O.observe(N, {
371
+ return R.observe(O, {
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(), b();
361
377
  };
362
- }, [a]);
363
- const S = (N) => {
364
- const k = w();
365
- if (!k)
378
+ }, [s]);
379
+ const K = (O) => {
380
+ const A = L();
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 m = Math.max(A.clientHeight * 0.75, 120);
384
+ A.scrollBy({
385
+ top: O === "up" ? -m : m,
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(P, { name: "chevron-up", size: 16, color: "currentColor" })
383
399
  }
384
400
  )
385
401
  ] }),
386
- f && /* @__PURE__ */ l(he, { children: [
387
- /* @__PURE__ */ s(
402
+ _ && /* @__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(P, { 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 || _) && /* @__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: u,
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
+ }, Bn = 48, qn = ({
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 Se(() => {
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 <= Bn) && (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: zn(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(
488
+ /* @__PURE__ */ a(
473
489
  P,
474
490
  {
475
491
  name: r.icon,
@@ -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 !== $.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
+ }, Jn = ({
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 Kn {
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: Gt,
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: In,
569
+ type: wn
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 Wn = ({
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: u,
580
596
  onAwaitingChange: c,
581
- onClarificationPrompt: v,
582
- onDismissClarification: f
597
+ onClarificationPrompt: g,
598
+ onDismissClarification: _
583
599
  }) => {
584
- const h = Y(
585
- () => new On(t, {
586
- canSend: () => e === F.running,
587
- onTurn: d,
600
+ const N = Y(
601
+ () => new Kn(e, {
602
+ canSend: () => t === B.running,
603
+ onTurn: u,
588
604
  onAwaitingChange: c
589
605
  }),
590
- [t, e, d, c]
591
- ), u = e !== F.running, x = e === F.running;
606
+ [e, t, u, 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,62 +613,62 @@ 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
+ Jn,
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: _,
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
+ yn,
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(P, { 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(P, { 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
+ }, Kt = ({
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(
670
+ const r = ee[e.status], o = e.status.replace(/_/g, "-"), i = e.status === $.hitl && n && s, u = /* @__PURE__ */ l("div", { className: "agent-workspace__task-row", children: [
671
+ /* @__PURE__ */ a(
656
672
  P,
657
673
  {
658
674
  name: r.icon,
@@ -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 !== $.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: u
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
+ ) : u,
702
+ e.children && e.children.length > 0 && /* @__PURE__ */ a("ul", { className: "agent-workspace__task-children", children: e.children.map((c) => /* @__PURE__ */ a(
703
+ Kt,
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
+ }, Ze = ({
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
+ Kt,
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
+ )) }), jn = ({
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 ? Jt(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(
747
+ /* @__PURE__ */ a("div", { className: "agent-workspace__panel-header", children: /* @__PURE__ */ a(Ce, { 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(
735
751
  P,
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: be
742
758
  }
743
759
  ),
744
- /* @__PURE__ */ s("span", { children: ke })
760
+ /* @__PURE__ */ a("span", { children: be })
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
+ Ze,
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
+ Ze,
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
+ Ze,
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
+ Ze,
770
826
  {
771
827
  items: i.tasks,
772
828
  ariaLabel: "Agent tasks",
@@ -778,41 +834,41 @@ 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
+ }, Vn = ({
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 = Xe.removeSlideover;
853
+ return Xe.removeSlideover = () => {
798
854
  i(), r();
799
855
  }, () => {
800
- qe.removeSlideover = i;
856
+ Xe.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 = (u) => {
862
+ u.key === "Escape" && Xe.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(
871
+ /* @__PURE__ */ a(
816
872
  P,
817
873
  {
818
874
  name: "loader",
@@ -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(mn, { slideovers: o }) });
897
+ }, Yn = {
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
+ }, Xn = ({
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,12 +937,12 @@ 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(Ce, { 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(
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(
885
946
  P,
886
947
  {
887
948
  name: "loader",
@@ -891,50 +952,50 @@ 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 = Yn[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: (u) => {
968
+ u.preventDefault(), s(r);
908
969
  },
909
- children: /* @__PURE__ */ s(Nt, { resource: r, config: o, external: !0 })
970
+ children: /* @__PURE__ */ a(Et, { 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(Et, { 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
+ ), Et = ({ 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(P, { 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(
998
+ n && /* @__PURE__ */ a(
938
999
  P,
939
1000
  {
940
1001
  name: "external-link",
@@ -944,686 +1005,759 @@ 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
+ ] }), Tt = (e) => {
1009
+ const t = Date.parse(e);
1010
+ return Number.isFinite(t) ? t : 0;
1011
+ }, Zn = 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()) ? Zn.format(t) : e;
1020
+ }, Rt = (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
+ ), It = (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
+ }, Qn = 60 * 60 * 1e3, Wt = 60 * 60 * 1e3, He = 24 * Wt, mt = 7 * He, ea = (e) => e.type !== "message-sent", ta = (e, t) => {
1030
+ const n = e.filter(ea).map((r, o) => ({
1031
+ kind: "action",
1032
+ id: `action-${r.timestamp}-${o}`,
1033
+ timestampMs: Tt(r.timestamp),
1034
+ item: r
1035
+ })), s = t.map((r) => ({
1036
+ kind: "chat",
1037
+ id: r.sessionId,
1038
+ timestampMs: Tt(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
+ }, na = (e) => e >= mt ? "weeks" : e >= He ? "days" : "hours", aa = (e) => {
1045
+ if (e < He) {
1046
+ const s = Math.max(1, Math.round(e / Wt));
1047
+ return s === 1 ? "1 hour later" : `${s} hours later`;
1048
+ }
1049
+ if (e < mt) {
1050
+ const s = Math.max(1, Math.round(e / He));
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 * He)));
1057
+ return n === 1 ? "1 month later" : `${n} months later`;
1058
+ }, sa = (e, t = Qn) => {
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: aa(i),
1069
+ size: na(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
+ }, ra = (e) => e.type === "checklist-updated" ? "checklist" : e.type === "status-transition" ? "status" : "note", ia = ({
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 = ta(r, o), u = sa(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 || Bt }),
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(
1088
+ "span",
1089
+ {
1090
+ className: "agent-timeline__station-node agent-timeline__station-node--terminus",
1091
+ "aria-hidden": "true",
1092
+ children: /* @__PURE__ */ a(P, { 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
+ u.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(P, { 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: _ } = g, N = ra(_), 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__ */ l(
1138
+ "button",
1139
+ {
1140
+ type: "button",
1141
+ className: `agent-timeline__station-node agent-timeline__station-node--${N}`,
1142
+ "aria-label": `${Rt(_.type)}: ${It(_.entry)}`,
1143
+ children: [
1144
+ y && /* @__PURE__ */ a(P, { name: "check-solid", size: 16, color: "currentColor" }),
1145
+ I && /* @__PURE__ */ a(P, { 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: Rt(_.type) }),
1151
+ /* @__PURE__ */ a("span", { className: "agent-timeline__label-entry", children: It(_.entry) }),
1152
+ /* @__PURE__ */ a("span", { className: "agent-timeline__label-time", children: ut(_.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(
1161
+ "span",
1162
+ {
1163
+ className: "agent-timeline__station-node agent-timeline__station-node--terminus",
1164
+ "aria-hidden": "true",
1165
+ children: /* @__PURE__ */ a(P, { 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
+ }, oa = [
1123
1173
  "I'll get the details and come back to you",
1124
1174
  "Skip this for now"
1125
- ], Kn = (t) => {
1175
+ ], la = (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 ?? oa
1133
1183
  };
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;
1184
+ }, Ae = (e) => ({
1185
+ id: e.id,
1186
+ text: e.text,
1187
+ type: e.author === ne.user ? kn : e.author === ne.system ? Nn : Gt,
1188
+ ...e.followUpPrompts ? { followUpPrompts: e.followUpPrompts } : {}
1189
+ }), Ot = "MESSAGE_TYPE_REPOLL", Lt = "agentMessage:new_message", jt = "arbor-agent-", ve = {
1190
+ all: "ALL",
1191
+ checklist: "CHECKLIST",
1192
+ resources: "RESOURCES",
1193
+ chat: "CHAT",
1194
+ timeline: "TIMELINE"
1195
+ }, ca = new Set(Object.values(ve)), da = (e, t) => `${e.endsWith("-") ? e : `${e}-`}${t}`, ga = (e) => typeof e == "string" && ca.has(e) ? e : ve.all, ha = (e) => {
1196
+ if (!e || typeof e != "object")
1197
+ return null;
1198
+ const t = e;
1199
+ return t.type !== Ot ? null : {
1200
+ type: Ot,
1201
+ target: ga(t.target)
1202
+ };
1203
+ }, ua = (e) => {
1204
+ const t = Array.isArray(e) ? e : [e], n = [];
1205
+ for (const s of t) {
1206
+ const r = ha(s);
1207
+ r && n.push(r);
1208
+ }
1209
+ return n;
1210
+ }, pa = ({
1211
+ enabled: e,
1212
+ channelPrefix: t,
1213
+ agentId: n,
1214
+ subscribeToPusher: s,
1215
+ onRepoll: r
1216
+ }) => {
1217
+ const o = le(r);
1218
+ H(() => {
1219
+ o.current = r;
1220
+ }, [r]), H(() => {
1221
+ if (!e || !(t != null && t.trim()) || !s || !n)
1222
+ return;
1223
+ const i = da(t.trim(), n), u = s(
1224
+ i,
1225
+ Lt,
1226
+ (c) => {
1227
+ console.log("[agent-view pusher] message received", {
1228
+ channel: i,
1229
+ event: Lt,
1230
+ payload: c
1231
+ });
1232
+ for (const g of ua(c))
1233
+ o.current(g.target);
1234
+ }
1235
+ );
1236
+ return () => {
1237
+ u();
1238
+ };
1239
+ }, [e, t, n, s]);
1240
+ };
1241
+ class $e extends Error {
1242
+ constructor(t, n, s) {
1243
+ super(s ?? `Agent service request failed (${t})`), this.name = "AgentServiceError", this.status = t, this.detail = n;
1143
1244
  }
1144
1245
  }
1145
- const Wn = "/api/v1", B = {
1246
+ const ma = "/api/v1", F = {
1146
1247
  agentDefinitions: "/agent-definitions",
1147
1248
  agents: "/agents",
1148
1249
  conversations: "/conversations",
1149
1250
  tripOptions: "/trip-options",
1150
1251
  demoDataset: "/demo/dataset"
1151
- }, K = {
1252
+ }, J = {
1152
1253
  GET: "GET",
1153
1254
  POST: "POST"
1154
- }, Vn = {
1255
+ }, _a = {
1155
1256
  error: "error"
1156
- }, Yn = {
1257
+ }, fa = {
1157
1258
  user: "user"
1158
- }, pe = {
1259
+ }, we = {
1159
1260
  acceptJson: "application/json",
1160
1261
  acceptHtml: "text/html",
1161
1262
  acceptEventStream: "text/event-stream",
1162
1263
  contentTypeJson: "application/json",
1163
1264
  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;
1265
+ }, va = 100, wa = (e) => {
1266
+ switch (e) {
1267
+ case bt.cancelled:
1268
+ return E.failed;
1269
+ case bt.archived:
1270
+ return E.complete;
1271
+ case E.hitl:
1272
+ case E.complete:
1273
+ case E.failed:
1274
+ case E["generating-a-response"]:
1275
+ return e;
1175
1276
  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;
1277
+ return E["generating-a-response"];
1278
+ }
1279
+ }, ya = (e) => {
1280
+ switch (e) {
1281
+ case gt.requires_attention:
1282
+ return $.hitl;
1283
+ case gt.in_progress:
1284
+ case gt.available:
1285
+ return $["generating-a-response"];
1286
+ case $.failed:
1287
+ case $.complete:
1288
+ case $.hitl:
1289
+ case $["generating-a-response"]:
1290
+ return e;
1190
1291
  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
1292
+ return $["generating-a-response"];
1293
+ }
1294
+ }, Vt = (e) => ({
1295
+ ref: e.name,
1296
+ display_name: e.display_name,
1297
+ agent_intent: e.agent_intent ?? "",
1298
+ description: e.description
1299
+ }), gs = (e) => ({
1300
+ id: e.id,
1301
+ name: e.name,
1302
+ ...e.has_run_before ? { hasRunBefore: e.has_run_before } : {}
1303
+ }), ka = new Set(Object.values(he)), Na = (e) => ka.has(e) ? e : he.document_html, Aa = (e) => ({
1304
+ id: e.id,
1305
+ type: Na(e.type),
1306
+ title: e.title,
1307
+ createdDatetime: e.created_datetime,
1308
+ lastUpdatedDatetime: e.last_updated_datetime,
1309
+ misRecordUrl: e.mis_record_url
1310
+ }), ba = (e) => ({
1311
+ resources: e.resources.map(Aa),
1312
+ pageNumber: e.page_number,
1313
+ pageSize: e.page_size,
1314
+ totalRecords: e.total_records
1315
+ }), Sa = (e) => ({
1316
+ actionLog: (e.action_log ?? []).map((t) => ({
1317
+ timestamp: t.timestamp,
1318
+ type: t.type,
1319
+ entry: t.entry,
1320
+ origin: t.origin
1220
1321
  })),
1221
- chatSessions: (t.chat_sessions ?? []).map((e) => ({
1222
- sessionId: e.session_id,
1223
- timestamp: e.timestamp
1322
+ chatSessions: (e.chat_sessions ?? []).map((t) => ({
1323
+ sessionId: t.session_id,
1324
+ timestamp: t.timestamp
1224
1325
  }))
1225
- }), At = (t) => {
1326
+ }), Ut = (e) => {
1226
1327
  var n;
1227
- const e = t.invocation_id ?? t.id;
1328
+ const t = e.invocation_id ?? e.id;
1228
1329
  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
1330
+ id: e.id,
1331
+ invocation_id: t,
1332
+ agent_definition_ref: e.agent_definition_ref,
1333
+ ...e.agent_intent ? { agent_intent: e.agent_intent } : {},
1334
+ invocation_name: ((n = e.invocation_name) == null ? void 0 : n.trim()) || e.agent_definition_ref,
1335
+ application_id: e.application_id,
1336
+ ...e.application_name ? { application_name: e.application_name } : {},
1337
+ created_by: e.created_by,
1338
+ status: wa(e.status),
1339
+ context_ref: e.context_ref ?? null,
1340
+ checklist_ref: e.checklist_ref ?? null
1240
1341
  };
1241
- }, Ht = (t) => {
1242
- var e;
1342
+ }, Yt = (e) => {
1343
+ var t;
1243
1344
  return {
1244
- task: 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 } : {}
1345
+ task: e.item ?? e.task ?? e.name ?? e.label ?? On,
1346
+ status: ya(e.status),
1347
+ description: e.description ?? "",
1348
+ ...e.prompt ? { prompt: e.prompt } : {},
1349
+ ...(t = e.follow_up_prompts) != null && t.length ? { clarificationPrompts: e.follow_up_prompts } : {}
1249
1350
  };
1250
- }, as = (t) => Array.isArray(t) ? t : t.checklist_items ?? t.checklist ?? t.items ?? [], zt = (t, e, n) => {
1351
+ }, Ca = (e) => Array.isArray(e) ? e : e.checklist_items ?? e.checklist ?? e.items ?? [], Xt = (e, t, n) => {
1251
1352
  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;
1353
+ 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
1354
  return {
1254
- invocation_id: t,
1255
- checklist: as(e).map(Ht),
1355
+ invocation_id: e,
1356
+ checklist: Ca(t).map(Yt),
1256
1357
  ...r ? { openingMessage: r } : {}
1257
1358
  };
1258
- }, rs = (t, e) => {
1259
- const n = Qe(e);
1359
+ }, Ea = (e, t) => {
1360
+ const n = nt(t);
1260
1361
  return {
1261
- invocation_id: e.invocation_id ?? t,
1262
- checklist: (e.checklist_items ?? []).map(Ht),
1362
+ invocation_id: t.invocation_id ?? e,
1363
+ checklist: (t.checklist_items ?? []).map(Yt),
1263
1364
  ...n ? { openingMessage: n } : {}
1264
1365
  };
1265
- }, Qe = (t) => {
1266
- var n, a;
1267
- const e = (n = t.opening_message) == null ? void 0 : n.trim();
1268
- if (e)
1366
+ }, nt = (e) => {
1367
+ var n, s;
1368
+ const t = (n = e.opening_message) == null ? void 0 : n.trim();
1369
+ if (t)
1269
1370
  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 } : {}
1371
+ id: Ft,
1372
+ author: ne.agent,
1373
+ text: t,
1374
+ ...(s = e.opening_follow_up_prompts) != null && s.length ? { followUpPrompts: e.opening_follow_up_prompts } : {}
1274
1375
  };
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);
1376
+ }, Ta = (e) => {
1377
+ try {
1378
+ const t = JSON.parse(e);
1379
+ if (Array.isArray(t)) {
1380
+ const n = t.filter(
1381
+ (s) => !!s && typeof s == "object" && typeof s.text == "string"
1382
+ ).map((s) => s.text);
1383
+ if (n.length > 0)
1384
+ return n.join(`
1385
+ `);
1386
+ }
1387
+ } catch {
1388
+ }
1389
+ return e;
1390
+ }, Ra = (e) => {
1391
+ const t = e.trim();
1392
+ return t.length > 0 ? `File upload
1393
+
1394
+ ${t}` : "File upload";
1395
+ }, Ia = (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) => {
1396
+ if (t.message_type === "user_file") {
1397
+ const n = typeof t.content == "string" ? t.content : "", s = Ta(n);
1398
+ return {
1399
+ id: t.message_id,
1400
+ author: ne.user,
1401
+ kind: An.user_file,
1402
+ text: Ra(s)
1403
+ };
1404
+ }
1405
+ return {
1406
+ id: t.message_id,
1407
+ author: t.role === "user" ? ne.user : ne.agent,
1408
+ text: t.content
1409
+ };
1410
+ }), Oa = /:invocationId\b/g, La = /:resourceId\b/g, Ua = (e) => e.trim().replace(/^Bearer\s+/i, ""), Pa = (e) => e.endsWith("/") ? e.slice(0, -1) : e;
1411
+ class ft {
1412
+ constructor(t) {
1413
+ var s;
1414
+ this.baseUrl = Pa(t.baseUrl ?? "");
1415
+ const n = (s = t.token) == null ? void 0 : s.trim();
1416
+ this.token = n ? Ua(n) : void 0, this.customHeaders = t.headers, this.urls = t.urls ?? {}, this.fetchImpl = t.fetch ?? globalThis.fetch.bind(globalThis);
1288
1417
  }
1289
1418
  // Replaces the extra headers merged into every subsequent request,
1290
1419
  // without recreating the client (e.g. an application-URL header that
1291
1420
  // changes as the user switches institutions).
1292
- setHeaders(e) {
1293
- this.customHeaders = e;
1421
+ setHeaders(t) {
1422
+ this.customHeaders = t;
1294
1423
  }
1295
1424
  async listAgentDefinitions() {
1296
1425
  return (await this.request(
1297
- K.GET,
1298
- this.resolveUrl("agentDefinitions", B.agentDefinitions)
1426
+ J.GET,
1427
+ this.resolveUrl("agentDefinitions", F.agentDefinitions)
1299
1428
  )).agent_definitions ?? [];
1300
1429
  }
1301
- getAgentDefinition(e) {
1430
+ getAgentDefinition(t) {
1302
1431
  return this.request(
1303
- K.GET,
1304
- this.apiUrl(`${B.agentDefinitions}/${encodeURIComponent(e)}`)
1432
+ J.GET,
1433
+ this.apiUrl(`${F.agentDefinitions}/${encodeURIComponent(t)}`)
1305
1434
  );
1306
1435
  }
1307
1436
  listTripOptions() {
1308
- return this.request(K.GET, this.apiUrl(B.tripOptions));
1437
+ return this.request(J.GET, this.apiUrl(F.tripOptions));
1309
1438
  }
1310
1439
  getDataset() {
1311
1440
  return this.request(
1312
- K.GET,
1313
- this.apiUrl(B.demoDataset)
1441
+ J.GET,
1442
+ this.apiUrl(F.demoDataset)
1314
1443
  );
1315
1444
  }
1316
- setDataset(e) {
1445
+ setDataset(t) {
1317
1446
  return this.request(
1318
- K.POST,
1319
- this.apiUrl(B.demoDataset),
1320
- { dataset: e }
1447
+ J.POST,
1448
+ this.apiUrl(F.demoDataset),
1449
+ { dataset: t }
1321
1450
  );
1322
1451
  }
1323
- listAgents(e = {}) {
1452
+ listAgents(t = {}) {
1324
1453
  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()}` : "";
1454
+ t.status && n.set("status", t.status), t.agentDefinitionRef && n.set("agent_definition_ref", t.agentDefinitionRef);
1455
+ const s = n.toString() ? `?${n.toString()}` : "";
1327
1456
  return this.request(
1328
- K.GET,
1329
- `${this.resolveUrl("agents", B.agents)}${a}`
1457
+ J.GET,
1458
+ `${this.resolveUrl("agents", F.agents)}${s}`
1330
1459
  );
1331
1460
  }
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
1461
+ createAgent(t, n = {}) {
1462
+ var i, u;
1463
+ const s = {
1464
+ agent_definition_ref: t
1465
+ }, r = (i = n.invocationName) == null ? void 0 : i.trim(), o = (u = n.agentIntent) == null ? void 0 : u.trim();
1466
+ return r && (s.invocation_name = r), o && (s.agent_intent = o), this.request(
1467
+ J.POST,
1468
+ this.resolveUrl("agents", F.agents),
1469
+ s
1341
1470
  );
1342
1471
  }
1343
- getAgent(e) {
1472
+ getAgent(t) {
1344
1473
  return this.request(
1345
- K.GET,
1346
- this.resolveUrl("agent", `${B.agents}/${encodeURIComponent(e)}`, e)
1474
+ J.GET,
1475
+ this.resolveUrl("agent", `${F.agents}/${encodeURIComponent(t)}`, t)
1347
1476
  );
1348
1477
  }
1349
- getAgentChecklist(e) {
1478
+ getAgentChecklist(t) {
1350
1479
  return this.request(
1351
- K.GET,
1480
+ J.GET,
1352
1481
  this.resolveUrl(
1353
1482
  "agentChecklist",
1354
- `${B.agents}/${encodeURIComponent(e)}/checklist`,
1355
- e
1483
+ `${F.agents}/${encodeURIComponent(t)}/checklist`,
1484
+ t
1356
1485
  )
1357
1486
  );
1358
1487
  }
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(
1488
+ getAgentResources(t, n = {}) {
1489
+ const s = new URLSearchParams();
1490
+ 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);
1491
+ const r = s.toString(), o = this.resolveUrl(
1363
1492
  "agentResources",
1364
- `${B.agents}/${encodeURIComponent(e)}/resources`,
1365
- e
1493
+ `${F.agents}/${encodeURIComponent(t)}/resources`,
1494
+ t
1366
1495
  );
1367
1496
  return this.request(
1368
- K.GET,
1497
+ J.GET,
1369
1498
  r ? `${o}?${r}` : o
1370
1499
  );
1371
1500
  }
1372
- async listAllAgentResources(e) {
1373
- const n = jn;
1374
- let a = 1;
1501
+ async listAllAgentResources(t) {
1502
+ const n = va;
1503
+ let s = 1;
1375
1504
  const r = [];
1376
1505
  let o = Number.POSITIVE_INFINITY;
1377
1506
  for (; r.length < o; ) {
1378
- const i = ns(
1379
- await this.getAgentResources(e, { pageNumber: a, pageSize: n })
1507
+ const i = ba(
1508
+ await this.getAgentResources(t, { pageNumber: s, pageSize: n })
1380
1509
  );
1381
1510
  if (o = i.totalRecords, i.resources.length === 0 || (r.push(...i.resources), r.length >= o))
1382
1511
  break;
1383
- a += 1;
1512
+ s += 1;
1384
1513
  }
1385
1514
  return r;
1386
1515
  }
1387
- getAgentResourceHtml(e, n) {
1388
- return this.requestText(K.GET, this.resolveResourceHtmlUrl(e, n));
1516
+ getAgentResourceHtml(t, n) {
1517
+ return this.requestText(J.GET, this.resolveResourceHtmlUrl(t, n));
1389
1518
  }
1390
- getAgentTimeline(e) {
1519
+ getAgentTimeline(t) {
1391
1520
  return this.request(
1392
- K.GET,
1521
+ J.GET,
1393
1522
  this.resolveUrl(
1394
1523
  "agentTimeline",
1395
- `${B.agents}/${encodeURIComponent(e)}/agent-timeline`,
1396
- e
1524
+ `${F.agents}/${encodeURIComponent(t)}/agent-timeline`,
1525
+ t
1397
1526
  )
1398
1527
  );
1399
1528
  }
1400
- getAgentContext(e) {
1529
+ getAgentContext(t) {
1401
1530
  return this.request(
1402
- K.GET,
1403
- this.apiUrl(`${B.agents}/${encodeURIComponent(e)}/context`)
1531
+ J.GET,
1532
+ this.apiUrl(`${F.agents}/${encodeURIComponent(t)}/context`)
1404
1533
  );
1405
1534
  }
1406
- cancelAgent(e) {
1535
+ cancelAgent(t) {
1407
1536
  return this.request(
1408
- K.POST,
1409
- this.apiUrl(`${B.agents}/${encodeURIComponent(e)}/cancel`)
1537
+ J.POST,
1538
+ this.resolveUrl(
1539
+ "stopAgent",
1540
+ `${F.agents}/${encodeURIComponent(t)}/cancel`,
1541
+ t
1542
+ )
1410
1543
  );
1411
1544
  }
1412
- archiveAgent(e) {
1545
+ archiveAgent(t) {
1413
1546
  return this.request(
1414
- K.POST,
1415
- this.apiUrl(`${B.agents}/${encodeURIComponent(e)}/archive`)
1547
+ J.POST,
1548
+ this.apiUrl(`${F.agents}/${encodeURIComponent(t)}/archive`)
1416
1549
  );
1417
1550
  }
1418
- getConversation(e) {
1551
+ getConversation(t) {
1419
1552
  return this.request(
1420
- K.GET,
1553
+ J.GET,
1421
1554
  this.resolveUrl(
1422
1555
  "agentConversation",
1423
- `${B.conversations}/${encodeURIComponent(e)}`,
1424
- e
1556
+ `${F.conversations}/${encodeURIComponent(t)}`,
1557
+ t
1425
1558
  )
1426
1559
  );
1427
1560
  }
1428
1561
  // Streams a chat turn. Resolves with the final SSE event; `onEvent` fires
1429
1562
  // 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(
1563
+ async chat(t, n, s = {}) {
1564
+ const r = !!(s.uploadFiles && s.uploadFiles.length > 0), o = await this.fetchImpl(
1432
1565
  this.resolveUrl(
1433
1566
  "agentChat",
1434
- `${B.agents}/${encodeURIComponent(e)}/chat`,
1435
- e
1567
+ `${F.agents}/${encodeURIComponent(t)}/chat`,
1568
+ t
1436
1569
  ),
1437
1570
  {
1438
- method: K.POST,
1571
+ method: J.POST,
1439
1572
  headers: {
1440
1573
  ...this.customHeaders,
1441
1574
  ...this.authHeaders(),
1442
- Accept: pe.acceptEventStream,
1575
+ Accept: we.acceptEventStream,
1443
1576
  // Let the browser set the multipart boundary when uploading.
1444
- ...r ? {} : { "Content-Type": pe.contentTypeJson }
1577
+ ...r ? {} : { "Content-Type": we.contentTypeJson }
1445
1578
  },
1446
- body: r ? hs(n, a.uploadFiles ?? []) : JSON.stringify(n),
1447
- signal: a.signal
1579
+ body: r ? Da(n, s.uploadFiles ?? []) : JSON.stringify(n),
1580
+ signal: s.signal
1448
1581
  }
1449
1582
  );
1450
1583
  if (!o.ok)
1451
1584
  throw await this.toError(o);
1452
1585
  if (!o.body)
1453
- throw new Oe(o.status, null, "Chat response contained no stream body");
1454
- return this.consumeSse(o.body, a.onEvent);
1586
+ throw new $e(o.status, null, "Chat response contained no stream body");
1587
+ return this.consumeSse(o.body, s.onEvent);
1455
1588
  }
1456
1589
  authHeaders() {
1457
1590
  return this.token ? { Authorization: `Bearer ${this.token}` } : {};
1458
1591
  }
1459
1592
  // Builds a URL from the base url + shared API prefix + route.
1460
- apiUrl(e) {
1461
- return `${this.baseUrl}${Wn}${e}`;
1593
+ apiUrl(t) {
1594
+ return `${this.baseUrl}${ma}${t}`;
1462
1595
  }
1463
1596
  // Resolves the URL for an operation, preferring a per-operation override
1464
1597
  // (with `:invocationId` substituted) and falling back to the base url.
1465
- resolveUrl(e, n, a, r) {
1466
- const o = this.urls[e];
1598
+ resolveUrl(t, n, s, r) {
1599
+ const o = this.urls[t];
1467
1600
  if (!o)
1468
1601
  return this.apiUrl(n);
1469
1602
  let i = o;
1470
- return a && (i = i.replace(os, encodeURIComponent(a))), r && (i = i.replace(ls, encodeURIComponent(r))), i;
1603
+ return s && (i = i.replace(Oa, encodeURIComponent(s))), r && (i = i.replace(La, encodeURIComponent(r))), i;
1471
1604
  }
1472
- resolveResourceHtmlUrl(e, n) {
1605
+ resolveResourceHtmlUrl(t, n) {
1473
1606
  return this.urls.agentResourceHtml ? this.resolveUrl(
1474
1607
  "agentResourceHtml",
1475
- `${B.agents}/${encodeURIComponent(e)}/resources/${encodeURIComponent(
1608
+ `${F.agents}/${encodeURIComponent(t)}/resources/${encodeURIComponent(
1476
1609
  n
1477
1610
  )}`,
1478
- e,
1611
+ t,
1479
1612
  n
1480
1613
  ) : this.urls.agentResources ? `${this.resolveUrl(
1481
1614
  "agentResources",
1482
- `${B.agents}/${encodeURIComponent(e)}/resources`,
1483
- e
1615
+ `${F.agents}/${encodeURIComponent(t)}/resources`,
1616
+ t
1484
1617
  ).replace(/\/$/, "")}/${encodeURIComponent(n)}` : this.apiUrl(
1485
- `${B.agents}/${encodeURIComponent(e)}/resources/${encodeURIComponent(
1618
+ `${F.agents}/${encodeURIComponent(t)}/resources/${encodeURIComponent(
1486
1619
  n
1487
1620
  )}`
1488
1621
  );
1489
1622
  }
1490
- async request(e, n, a) {
1623
+ async request(t, n, s) {
1491
1624
  const r = await this.fetchImpl(n, {
1492
- method: e,
1625
+ method: t,
1493
1626
  headers: {
1494
1627
  ...this.customHeaders,
1495
1628
  ...this.authHeaders(),
1496
- Accept: pe.acceptJson,
1497
- ...a === void 0 ? {} : { "Content-Type": pe.contentTypeJson }
1629
+ Accept: we.acceptJson,
1630
+ ...s === void 0 ? {} : { "Content-Type": we.contentTypeJson }
1498
1631
  },
1499
- ...a === void 0 ? {} : { body: JSON.stringify(a) }
1632
+ ...s === void 0 ? {} : { body: JSON.stringify(s) }
1500
1633
  });
1501
1634
  if (!r.ok)
1502
1635
  throw await this.toError(r);
1503
1636
  if (r.status !== 204)
1504
1637
  return await r.json();
1505
1638
  }
1506
- async requestText(e, n) {
1507
- const a = await this.fetchImpl(n, {
1508
- method: e,
1639
+ async requestText(t, n) {
1640
+ const s = await this.fetchImpl(n, {
1641
+ method: t,
1509
1642
  headers: {
1510
1643
  ...this.customHeaders,
1511
1644
  ...this.authHeaders(),
1512
- Accept: pe.acceptHtml
1645
+ Accept: we.acceptHtml
1513
1646
  }
1514
1647
  });
1515
- if (!a.ok)
1516
- throw await this.toError(a);
1517
- return a.text();
1648
+ if (!s.ok)
1649
+ throw await this.toError(s);
1650
+ return s.text();
1518
1651
  }
1519
- async toError(e) {
1652
+ async toError(t) {
1520
1653
  let n = null;
1521
1654
  try {
1522
- n = await e.json();
1655
+ n = await t.json();
1523
1656
  } catch {
1524
1657
  }
1525
- return new Oe(
1526
- e.status,
1658
+ return new $e(
1659
+ t.status,
1527
1660
  n,
1528
- `Agent service request failed (${e.status} ${e.statusText})`
1661
+ `Agent service request failed (${t.status} ${t.statusText})`
1529
1662
  );
1530
1663
  }
1531
- async consumeSse(e, n) {
1532
- const a = e.getReader(), r = new TextDecoder();
1664
+ async consumeSse(t, n) {
1665
+ const s = t.getReader(), r = new TextDecoder();
1533
1666
  let o = "", i;
1534
- const d = (c) => {
1535
- const { event: v, data: f } = gs(c);
1536
- if (f === null)
1667
+ const u = (c) => {
1668
+ const { event: g, data: _ } = xa(c);
1669
+ if (_ === null)
1537
1670
  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");
1671
+ if (g === _a.error) {
1672
+ const y = Pt(_);
1673
+ throw new $e(502, y, (y == null ? void 0 : y.message) ?? "Chat stream error");
1541
1674
  }
1542
- const h = St(f);
1543
- h && (i = h, n == null || n(h));
1675
+ const N = Pt(_);
1676
+ N && (i = N, n == null || n(N));
1544
1677
  };
1545
1678
  for (; ; ) {
1546
- const { done: c, value: v } = await a.read();
1679
+ const { done: c, value: g } = await s.read();
1547
1680
  if (c)
1548
1681
  break;
1549
- o += r.decode(v, { stream: !0 });
1550
- const f = o.split(`
1682
+ o += r.decode(g, { stream: !0 });
1683
+ const _ = o.split(`
1551
1684
 
1552
1685
  `);
1553
- o = f.pop() ?? "";
1554
- for (const h of f)
1555
- d(h);
1686
+ o = _.pop() ?? "";
1687
+ for (const N of _)
1688
+ u(N);
1556
1689
  }
1557
- if (o.trim() && d(o), !i)
1558
- throw new Oe(502, null, "Chat stream ended without any events");
1690
+ if (o.trim() && u(o), !i)
1691
+ throw new $e(502, null, "Chat stream ended without any events");
1559
1692
  return i;
1560
1693
  }
1561
1694
  }
1562
- const gs = (t) => {
1563
- let e = null;
1695
+ const xa = (e) => {
1696
+ let t = null;
1564
1697
  const n = [];
1565
- for (const a of t.split(`
1698
+ for (const s of e.split(`
1566
1699
  `)) {
1567
- const r = a.trimEnd();
1568
- r.startsWith("event:") ? e = r.slice(6).trim() : r.startsWith("data:") && n.push(r.slice(5).trim());
1700
+ const r = s.trimEnd();
1701
+ r.startsWith("event:") ? t = r.slice(6).trim() : r.startsWith("data:") && n.push(r.slice(5).trim());
1569
1702
  }
1570
1703
  return {
1571
- event: e,
1704
+ event: t,
1572
1705
  data: n.length > 0 ? n.join(`
1573
1706
  `) : null
1574
1707
  };
1575
- }, St = (t) => {
1708
+ }, Pt = (e) => {
1576
1709
  try {
1577
- return JSON.parse(t);
1710
+ return JSON.parse(e);
1578
1711
  } catch {
1579
1712
  return;
1580
1713
  }
1581
1714
  };
1582
- function hs(t, e) {
1715
+ function Da(e, t) {
1583
1716
  const n = new FormData();
1584
- n.append("body", JSON.stringify(t));
1585
- for (const a of e)
1586
- n.append("files", a, a.name);
1717
+ n.append("body", JSON.stringify(e));
1718
+ for (const s of t)
1719
+ n.append("files", s, s.name);
1587
1720
  return n;
1588
1721
  }
1589
- const us = {
1590
- id: Pt,
1591
- author: ae.agent,
1722
+ const Ma = {
1723
+ id: Ft,
1724
+ author: ne.agent,
1592
1725
  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
1726
  };
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?`;
1727
+ let xt = 0;
1728
+ const $a = (e) => (xt += 1, `${e}-${Date.now()}-${xt}`), Ha = (e) => {
1729
+ const t = e.destination ? ` to ${e.destination}` : "";
1730
+ return `Let's get started on ${e.tripName.trim() || e.destination.trim() || "this task"}${t}. What will you do first?`;
1598
1731
  };
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;
1732
+ class za {
1733
+ constructor(t, n, s = {}) {
1734
+ this.seededChecklist = [], this.client = t, this.agentId = n, this.chatId = s.chatId ?? n, this.opening = s.openingMessage ?? Ma, this.model = s.model;
1602
1735
  }
1603
1736
  openingMessage() {
1604
1737
  return this.opening;
1605
1738
  }
1606
1739
  async bootstrapConversation() {
1607
- const e = await this.client.getConversation(this.chatId), n = is(e.messages);
1740
+ const t = await this.client.getConversation(this.chatId), n = Ia(t.messages);
1608
1741
  return n.length === 0 ? [this.opening] : n;
1609
1742
  }
1610
- async start(e) {
1611
- return { ...await this.exchange(ms(e)), phase: F.running };
1743
+ async start(t) {
1744
+ return { ...await this.exchange(Ha(t)), phase: B.running };
1612
1745
  }
1613
- sendMessage(e, n) {
1614
- return this.exchange(e, n);
1746
+ sendMessage(t, n) {
1747
+ return this.exchange(t, n);
1615
1748
  }
1616
1749
  async stop() {
1750
+ await this.client.cancelAgent(this.agentId);
1617
1751
  }
1618
- seedChecklist(e) {
1619
- this.seededChecklist = e;
1752
+ seedChecklist(t) {
1753
+ this.seededChecklist = t;
1620
1754
  }
1621
- async exchange(e, n) {
1755
+ async exchange(t, n) {
1622
1756
  var i;
1623
- const a = [{ role: Yn.user, content: e }], r = await this.client.chat(
1757
+ const s = [{ role: fa.user, content: t }], r = await this.client.chat(
1624
1758
  this.agentId,
1625
1759
  {
1626
- messages: a,
1760
+ messages: s,
1627
1761
  chat_id: this.chatId,
1628
1762
  ...this.model ? { model: this.model } : {},
1629
1763
  moderation_enabled: !0,
@@ -1634,623 +1768,679 @@ class _s {
1634
1768
  },
1635
1769
  ...n && n.length > 0 ? [{ uploadFiles: n }] : []
1636
1770
  ), o = {
1637
- id: r.event_id || ps("msg-agent"),
1638
- author: ae.agent,
1771
+ id: r.event_id || $a("msg-agent"),
1772
+ author: ne.agent,
1639
1773
  text: r.message.content,
1640
1774
  ...(i = r.follow_up_prompts) != null && i.length ? { followUpPrompts: r.follow_up_prompts } : {}
1641
1775
  };
1642
1776
  try {
1643
- const d = await this.client.getAgent(this.agentId), { checklist: c } = rs(this.agentId, d);
1777
+ const u = await this.client.getAgent(this.agentId), { checklist: c } = Ea(this.agentId, u);
1644
1778
  return this.seededChecklist = c, { message: o, checklist: c };
1645
1779
  } catch {
1646
1780
  return { message: o, ...this.seededChecklist.length ? { checklist: this.seededChecklist } : {} };
1647
1781
  }
1648
1782
  }
1649
1783
  }
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)
1784
+ const Zt = (e, t) => (n) => {
1785
+ var s, r;
1786
+ return new za(e, n.invocation_id, {
1787
+ model: t == null ? void 0 : t.model,
1788
+ chatId: ((s = t == null ? void 0 : t.resolveChatId) == null ? void 0 : s.call(t, n)) ?? (t == null ? void 0 : t.chatId) ?? n.invocation_id,
1789
+ openingMessage: ((r = t == null ? void 0 : t.resolveOpeningMessage) == null ? void 0 : r.call(t, n)) ?? (t == null ? void 0 : t.openingMessage)
1656
1790
  });
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)
1791
+ }, Qt = (e) => e instanceof $e ? e.message : e instanceof TypeError ? "Network error while contacting the agent service." : e instanceof Error && e.message ? e.message : qt, Ga = (e) => {
1792
+ const t = {};
1793
+ for (const n of e) {
1794
+ const s = nt(n);
1795
+ if (!s)
1662
1796
  continue;
1663
1797
  const r = n.invocation_id ?? n.id;
1664
- e[r] = a, e[n.id] = a;
1798
+ t[r] = s, t[n.id] = s;
1665
1799
  }
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,
1800
+ return t;
1801
+ }, Fa = (e) => JSON.stringify(e), pt = (e, t) => JSON.stringify(e) === JSON.stringify(t), Ba = (e) => {
1802
+ const { jwt: t, headers: n, urls: s } = e, r = JSON.stringify(n ?? {}), o = Fa(s), i = Y(
1803
+ () => new ft({
1804
+ token: t,
1671
1805
  headers: n,
1672
- urls: a
1806
+ urls: s
1673
1807
  }),
1674
1808
  // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
1675
- [e, o]
1809
+ [t, o]
1676
1810
  );
1677
- je(() => {
1811
+ Se(() => {
1678
1812
  i.setHeaders(n);
1679
1813
  }, [i, r]);
1680
- const [d, c] = _([]), [v, f] = _(
1814
+ const [u, c] = p([]), [g, _] = p(
1681
1815
  []
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);
1816
+ ), [N, y] = p({}), [I, L] = p("loading"), [f, K] = p(null), [T, O] = p(0), A = C(
1817
+ (U, G) => {
1818
+ const q = U.map(Ut), X = G.map(Vt), Z = Ga(U);
1685
1819
  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);
1820
+ (D) => pt(D, q) ? D : q
1821
+ ), _(
1822
+ (D) => pt(D, X) ? D : X
1823
+ ), y(
1824
+ (D) => pt(D, Z) ? D : Z
1825
+ ), L("idle"), K(null);
1692
1826
  },
1693
1827
  []
1694
1828
  );
1695
- G(() => {
1829
+ H(() => {
1696
1830
  let U = !1;
1697
- return w("loading"), S(null), (async () => {
1831
+ return L("loading"), K(null), (async () => {
1698
1832
  try {
1699
- const [H, I] = await Promise.all([
1833
+ const [G, q] = await Promise.all([
1700
1834
  i.listAgents(),
1701
1835
  i.listAgentDefinitions()
1702
1836
  ]);
1703
1837
  if (U)
1704
1838
  return;
1705
- k(H, I);
1706
- } catch (H) {
1839
+ A(G, q);
1840
+ } catch (G) {
1707
1841
  if (U)
1708
1842
  return;
1709
- c([]), f([]), u({}), w("error"), S(Ft(H));
1843
+ c([]), _([]), y({}), L("error"), K(Qt(G));
1710
1844
  }
1711
1845
  })(), () => {
1712
1846
  U = !0;
1713
1847
  };
1714
- }, [k, i, D]);
1715
- const m = T(() => {
1716
- N((U) => U + 1);
1717
- }, []), E = T(async () => {
1848
+ }, [A, i, T]);
1849
+ const m = C(() => {
1850
+ O((U) => U + 1);
1851
+ }, []), b = C(async () => {
1718
1852
  try {
1719
- const [U, H] = await Promise.all([
1853
+ const [U, G] = await Promise.all([
1720
1854
  i.listAgents(),
1721
1855
  i.listAgentDefinitions()
1722
1856
  ]);
1723
- k(U, H);
1857
+ A(U, G);
1724
1858
  } catch {
1725
1859
  }
1726
- }, [k, i]), L = T(
1860
+ }, [A, i]), v = C(
1727
1861
  async (U) => {
1728
- const [H, I] = await Promise.all([
1862
+ const [G, q] = await Promise.all([
1729
1863
  i.getAgentChecklist(U),
1730
1864
  i.getAgent(U).catch(() => null)
1731
1865
  ]);
1732
- return zt(
1866
+ return Xt(
1733
1867
  U,
1734
- H,
1735
- I ?? void 0
1868
+ G,
1869
+ q ?? void 0
1736
1870
  );
1737
1871
  },
1738
1872
  [i]
1739
- ), O = T(
1873
+ ), R = C(
1740
1874
  async (U) => i.listAllAgentResources(U),
1741
1875
  [i]
1742
- ), M = T(
1876
+ ), z = C(
1743
1877
  async ({
1744
1878
  definition: U,
1745
- invocationName: H
1879
+ invocationName: G
1746
1880
  }) => {
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;
1881
+ const q = await i.createAgent(U.ref, {
1882
+ invocationName: G
1883
+ }), X = await i.getAgent(q.id), Z = Ut(X), D = nt(X);
1884
+ return c((x) => [Z, ...x]), D && y((x) => ({
1885
+ ...x,
1886
+ [Z.invocation_id]: D,
1887
+ [Z.id]: D
1888
+ })), Z;
1755
1889
  },
1756
1890
  [i]
1757
- ), te = Y(
1758
- () => Bt(i, {
1759
- resolveOpeningMessage: (U) => h[U.invocation_id] ?? h[U.id]
1891
+ ), Ee = Y(
1892
+ () => Zt(i, {
1893
+ resolveOpeningMessage: (U) => N[U.invocation_id] ?? N[U.id]
1760
1894
  }),
1761
- [i, h]
1895
+ [i, N]
1762
1896
  );
1763
1897
  return {
1764
- agents: d,
1765
- agentDefinitions: v,
1766
- loadState: x,
1767
- loadError: b,
1898
+ agents: u,
1899
+ agentDefinitions: g,
1900
+ loadState: I,
1901
+ loadError: f,
1768
1902
  reload: m,
1769
- refresh: E,
1770
- fetchAgentChecklist: L,
1771
- fetchAgentResources: O,
1772
- createAgent: M,
1773
- chatConnector: te
1903
+ refresh: b,
1904
+ fetchAgentChecklist: v,
1905
+ fetchAgentResources: R,
1906
+ createAgent: z,
1907
+ chatConnector: Ee
1774
1908
  };
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({
1909
+ }, qa = (e) => JSON.stringify(e), Ja = (e) => {
1910
+ const { agent: t, jwt: n, headers: s, urls: r, chatId: o } = e, i = JSON.stringify(s ?? {}), u = qa(r), c = Y(
1911
+ () => new ft({
1778
1912
  token: n,
1779
- headers: a,
1913
+ headers: s,
1780
1914
  urls: {
1781
1915
  agent: r.agentUrl,
1782
1916
  agentChecklist: r.agentChecklistUrl,
1783
1917
  ...r.agentResourcesUrl ? { agentResources: r.agentResourcesUrl } : {},
1784
1918
  ...r.agentTimelineUrl ? { agentTimeline: r.agentTimelineUrl } : {},
1785
1919
  agentChat: r.agentChatUrl,
1786
- agentConversation: r.agentConversationUrl
1920
+ agentConversation: r.agentConversationUrl,
1921
+ ...r.stopAgentUrl ? { stopAgent: r.stopAgentUrl } : {}
1787
1922
  }
1788
1923
  }),
1789
1924
  // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
1790
- [n, d]
1925
+ [n, u]
1791
1926
  );
1792
- je(() => {
1793
- c.setHeaders(a);
1927
+ Se(() => {
1928
+ c.setHeaders(s);
1794
1929
  }, [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)
1930
+ const g = C(
1931
+ async (L) => {
1932
+ const [f, K] = await Promise.all([
1933
+ c.getAgentChecklist(L),
1934
+ c.getAgent(L).catch(() => null)
1800
1935
  ]);
1801
- return zt(
1802
- w,
1803
- b,
1804
- S ?? void 0
1936
+ return Xt(
1937
+ L,
1938
+ f,
1939
+ K ?? void 0
1805
1940
  );
1806
1941
  },
1807
1942
  [c]
1808
- ), f = T(
1809
- async (w) => c.listAllAgentResources(w),
1943
+ ), _ = C(
1944
+ async (L) => c.listAllAgentResources(L),
1810
1945
  [c]
1811
- ), h = T(
1812
- async (w, b) => c.getAgentResourceHtml(w, b),
1946
+ ), N = C(
1947
+ async (L, f) => c.getAgentResourceHtml(L, f),
1813
1948
  [c]
1814
- ), u = T(
1815
- async (w) => {
1816
- const b = await c.getAgentTimeline(w);
1817
- return ss(b);
1949
+ ), y = C(
1950
+ async (L) => {
1951
+ const f = await c.getAgentTimeline(L);
1952
+ return Sa(f);
1818
1953
  },
1819
1954
  [c]
1820
1955
  );
1821
1956
  return {
1822
1957
  connector: Y(
1823
- () => Bt(c, {
1824
- chatId: o ?? e.invocation_id
1825
- })(e),
1958
+ () => Zt(c, {
1959
+ chatId: o ?? t.invocation_id
1960
+ })(t),
1826
1961
  // Key on invocation/chat ids so a new Agent object reference does not rebuild the connector.
1827
1962
  // eslint-disable-next-line react-hooks/exhaustive-deps
1828
- [c, e.invocation_id, o]
1963
+ [c, t.invocation_id, o]
1829
1964
  ),
1830
- fetchAgentChecklist: v,
1831
- fetchAgentResources: f,
1832
- fetchAgentResourceHtml: h,
1833
- fetchAgentTimeline: u
1965
+ fetchAgentChecklist: g,
1966
+ fetchAgentResources: _,
1967
+ fetchAgentResourceHtml: N,
1968
+ fetchAgentTimeline: y
1834
1969
  };
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;
1970
+ }, en = (e) => {
1971
+ const t = document.querySelector(e);
1972
+ t instanceof HTMLElement && t.removeAttribute("aria-describedby");
1973
+ }, Ka = 3e4, Wa = (e, t) => {
1974
+ 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." : "";
1975
+ return `${n}${s}.${r}`.trim();
1976
+ }, ja = (e) => {
1977
+ switch (e) {
1978
+ case E.failed:
1979
+ return B.stopped;
1980
+ case E.complete:
1981
+ return B.complete;
1844
1982
  default:
1845
- return F.running;
1983
+ return B.running;
1846
1984
  }
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];
1985
+ }, Dt = (e, t) => {
1986
+ t([Ae(e)]);
1987
+ }, Va = (e, t) => e.length === t.length && e.every((n, s) => {
1988
+ const r = t[s];
1851
1989
  return r !== void 0 && n.id === r.id && n.text === r.text;
1852
- }), Cs = ({
1853
- agent: t,
1854
- invocationId: e,
1990
+ }), Ya = ({
1991
+ agent: e,
1992
+ invocationId: t,
1855
1993
  open: n,
1856
- onClose: a,
1994
+ onClose: s,
1857
1995
  jwt: r,
1858
1996
  headers: o,
1859
1997
  agentUrl: i,
1860
- agentChecklistUrl: d,
1998
+ agentChecklistUrl: u,
1861
1999
  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
2000
+ agentTimelineUrl: g,
2001
+ agentChatUrl: _,
2002
+ agentConversationUrl: N,
2003
+ stopAgentUrl: y,
2004
+ chatId: I,
2005
+ enableUpload: L,
2006
+ initialBrief: f,
2007
+ initialPhase: K,
2008
+ initialChecklist: T,
2009
+ usePusherToRepoll: O = !1,
2010
+ pusherChannelPrefix: A = jt,
2011
+ subscribeToPusher: m
1870
2012
  }) => {
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 },
2013
+ const [b, v] = p(I ?? t), [R, z] = p("chat"), [Ee, U] = p(!1), {
2014
+ connector: G,
2015
+ fetchAgentChecklist: q,
2016
+ fetchAgentResources: X,
2017
+ fetchAgentResourceHtml: Z,
2018
+ fetchAgentTimeline: D
2019
+ } = Ja({
2020
+ agent: { ...e, invocation_id: t },
1873
2021
  jwt: r,
1874
2022
  headers: o,
1875
- chatId: D,
2023
+ chatId: b,
1876
2024
  urls: {
1877
2025
  agentUrl: i,
1878
- agentChecklistUrl: d,
2026
+ agentChecklistUrl: u,
1879
2027
  agentResourcesUrl: c,
1880
- agentTimelineUrl: v,
1881
- agentChatUrl: f,
1882
- agentConversationUrl: h
2028
+ agentTimelineUrl: g,
2029
+ agentChatUrl: _,
2030
+ agentConversationUrl: N,
2031
+ stopAgentUrl: y
1883
2032
  }
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)
2033
+ }), x = le(G), [ae, Te] = p(
2034
+ K ?? (f ? B.running : ja(e.status))
2035
+ ), [ze, j] = p([]), [Ge, ye] = p(0), [Re, ke] = p(), [at, ce] = p(null), [st, Ie] = p([]), [pe, Oe] = p(!1), [Fe, Ne] = p(null), [Be, qe] = p(null), [Je, Le] = p(null), [Ke, Ue] = p(!1), [rt, Pe] = p(null), [de, xe] = p(null), [h, S] = p(!1), [k, V] = p(null), [se, re] = p(T ?? null), [me, De] = p(!1), [nn, it] = p(null), [We, ot] = p(!1), [je, an] = p(!1), [Ve, sn] = p(!1), vt = le(We), wt = le(0), yt = le(0);
2036
+ H(() => {
2037
+ x.current = G;
2038
+ }, [G]), Se(() => {
2039
+ n && en(".agent-workspace");
2040
+ }, [n]), H(() => {
2041
+ vt.current = We;
2042
+ }, [We]), H(() => {
2043
+ v(I ?? t), z("chat"), U(!1), j([]), ye((d) => d + 1);
2044
+ }, [t, I]), H(() => {
2045
+ if (!n || f)
1895
2046
  return;
1896
- const g = I.current.bootstrapConversation;
1897
- if (!g) {
1898
- Ct(I.current.openingMessage(), z);
2047
+ const d = x.current.bootstrapConversation;
2048
+ if (!d) {
2049
+ Dt(x.current.openingMessage(), j);
1899
2050
  return;
1900
2051
  }
1901
- let y = !1;
1902
- return st(!0), (async () => {
2052
+ let w = !1;
2053
+ return ot(!0), (async () => {
1903
2054
  try {
1904
- const $ = await g.call(I.current);
1905
- if (y)
2055
+ const M = await d.call(x.current);
2056
+ if (w)
1906
2057
  return;
1907
- z($.map(ye));
2058
+ j(M.map(Ae));
1908
2059
  } catch {
1909
- y || Ct(I.current.openingMessage(), z);
2060
+ w || Dt(x.current.openingMessage(), j);
1910
2061
  } finally {
1911
- y || st(!1);
2062
+ w || ot(!1);
1912
2063
  }
1913
2064
  })(), () => {
1914
- y = !0;
2065
+ w = !0;
1915
2066
  };
1916
- }, [n, w, e, D]);
1917
- const ve = T(() => {
1918
- const g = ++pt.current;
2067
+ }, [n, f, t, b]);
2068
+ const ie = C(() => {
2069
+ const d = ++wt.current;
1919
2070
  (async () => {
1920
- var y, $;
2071
+ var w, M;
1921
2072
  try {
1922
- const Q = await M(e);
1923
- if (g !== pt.current)
2073
+ const Q = await q(t);
2074
+ if (d !== wt.current)
1924
2075
  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);
2076
+ re(
2077
+ (ge) => JSON.stringify(ge) === JSON.stringify(Q.checklist) ? ge : Q.checklist
2078
+ ), it(null), (M = (w = x.current).seedChecklist) == null || M.call(w, Q.checklist);
1928
2079
  } catch {
1929
2080
  }
1930
2081
  })();
1931
- }, [M, e]), Fe = T(() => {
2082
+ }, [q, t]), _e = C(() => {
1932
2083
  c && (async () => {
1933
2084
  try {
1934
- const g = await te(e);
1935
- Se(g), fe(null);
2085
+ const d = await X(t);
2086
+ Ie(d), Ne(null);
1936
2087
  } catch {
1937
2088
  }
1938
2089
  })();
1939
- }, [c, te, e]), we = T(() => {
1940
- if (!v)
2090
+ }, [c, X, t]), oe = C(() => {
2091
+ if (!g)
1941
2092
  return;
1942
- const g = ++mt.current;
2093
+ const d = ++yt.current;
1943
2094
  (async () => {
1944
2095
  try {
1945
- const y = await H(e);
1946
- if (g !== mt.current)
2096
+ const w = await D(t);
2097
+ if (d !== yt.current)
1947
2098
  return;
1948
- Ee(
1949
- ($) => JSON.stringify($) === JSON.stringify(y) ? $ : y
2099
+ xe(
2100
+ (M) => JSON.stringify(M) === JSON.stringify(w) ? M : w
1950
2101
  ), V(null);
1951
2102
  } catch {
1952
2103
  }
1953
2104
  })();
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 () => {
2105
+ }, [g, D, t]), Me = C(
2106
+ (d) => {
2107
+ const w = x.current.bootstrapConversation;
2108
+ w && (async () => {
1961
2109
  try {
1962
- const $ = await y.call(I.current);
1963
- if (ut.current)
2110
+ const M = await w.call(x.current);
2111
+ if (vt.current)
1964
2112
  return;
1965
- const Q = $.map(ye);
1966
- let oe = !1;
1967
- z((ft) => bs(ft, Q) ? ft : (oe = !0, Q)), oe && (ve(), we());
2113
+ const Q = M.map(Ae);
2114
+ let ge = !1;
2115
+ j((Nt) => Va(Nt, Q) ? Nt : (ge = !0, Q)), ge && (d != null && d.refreshSidePanelsOnChange) && (ie(), oe());
1968
2116
  } catch {
1969
2117
  }
1970
2118
  })();
1971
- }, Ns);
2119
+ },
2120
+ [ie, oe]
2121
+ ), rn = C(
2122
+ (d) => {
2123
+ switch (d) {
2124
+ case ve.checklist:
2125
+ ie();
2126
+ return;
2127
+ case ve.resources:
2128
+ _e();
2129
+ return;
2130
+ case ve.chat:
2131
+ Me();
2132
+ return;
2133
+ case ve.timeline:
2134
+ oe();
2135
+ return;
2136
+ case ve.all:
2137
+ default:
2138
+ ie(), _e(), Me(), oe();
2139
+ }
2140
+ },
2141
+ [ie, Me, _e, oe]
2142
+ );
2143
+ pa({
2144
+ enabled: n && O,
2145
+ channelPrefix: A,
2146
+ agentId: e.id,
2147
+ subscribeToPusher: m,
2148
+ onRepoll: rn
2149
+ }), H(() => {
2150
+ if (!n || f || O)
2151
+ return;
2152
+ const d = window.setInterval(() => {
2153
+ Me({ refreshSidePanelsOnChange: !0 });
2154
+ }, Ka);
1972
2155
  return () => {
1973
- window.clearInterval(g);
2156
+ window.clearInterval(d);
1974
2157
  };
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();
2158
+ }, [
2159
+ n,
2160
+ f,
2161
+ O,
2162
+ t,
2163
+ b,
2164
+ Me
2165
+ ]);
2166
+ const on = C(
2167
+ (d) => {
2168
+ var w, M;
2169
+ d.checklist ? (re(d.checklist), (M = (w = x.current).seedChecklist) == null || M.call(w, d.checklist)) : ie(), d.phase && Te(d.phase), _e(), oe();
1980
2170
  },
1981
- [ve, Fe, we]
2171
+ [ie, _e, oe]
1982
2172
  );
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)
2173
+ H(() => {
2174
+ var d, w;
2175
+ !n || f || T && T.length > 0 && ((w = (d = x.current).seedChecklist) == null || w.call(d, T));
2176
+ }, [n, f, T]), H(() => {
2177
+ if (!n || f)
1988
2178
  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, $;
2179
+ let d = !1;
2180
+ return De((w) => T != null && T.length ? !1 : w || se === null || se.length === 0), it(null), (async () => {
2181
+ var w, M;
1992
2182
  try {
1993
- const Q = await M(e);
1994
- if (g)
2183
+ const Q = await q(t);
2184
+ if (d)
1995
2185
  return;
1996
- S != null && S.length || (se(Q.checklist), ($ = (y = I.current).seedChecklist) == null || $.call(y, Q.checklist));
2186
+ T != null && T.length || (re(Q.checklist), (M = (w = x.current).seedChecklist) == null || M.call(w, Q.checklist));
1997
2187
  } catch {
1998
- !g && !(S != null && S.length) && nt(We);
2188
+ !d && !(T != null && T.length) && it(Qe);
1999
2189
  } finally {
2000
- g || Ie(!1);
2190
+ d || De(!1);
2001
2191
  }
2002
2192
  })(), () => {
2003
- g = !0;
2193
+ d = !0;
2004
2194
  };
2005
- }, [n, e, w, S, M]), G(() => {
2195
+ }, [n, t, f, T, q]), H(() => {
2006
2196
  if (!n || !c)
2007
2197
  return;
2008
- let g = !1;
2009
- return be(!0), fe(null), (async () => {
2198
+ let d = !1;
2199
+ return Oe(!0), Ne(null), (async () => {
2010
2200
  try {
2011
- const y = await te(e);
2012
- g || Se(y);
2201
+ const w = await X(t);
2202
+ d || Ie(w);
2013
2203
  } catch {
2014
- g || fe(pn);
2204
+ d || Ne(Tn);
2015
2205
  } finally {
2016
- g || be(!1);
2206
+ d || Oe(!1);
2017
2207
  }
2018
2208
  })(), () => {
2019
- g = !0;
2209
+ d = !0;
2020
2210
  };
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");
2211
+ }, [n, t, c, X]);
2212
+ const ln = C(() => {
2213
+ qe(null), Le(null), Pe(null), Ue(!1);
2214
+ }, []), cn = C(
2215
+ (d) => {
2216
+ if (d.misRecordUrl) {
2217
+ window.open(d.misRecordUrl, "_blank", "noopener,noreferrer");
2028
2218
  return;
2029
2219
  }
2030
- De(g), Ce(null), Re(null), Te(!0), (async () => {
2220
+ qe(d), Le(null), Pe(null), Ue(!0), (async () => {
2031
2221
  try {
2032
- const y = await U(e, g.id);
2033
- Ce(y);
2222
+ const w = await Z(t, d.id);
2223
+ Le(w);
2034
2224
  } catch {
2035
- Re(mn);
2225
+ Pe(Rn);
2036
2226
  } finally {
2037
- Te(!1);
2227
+ Ue(!1);
2038
2228
  }
2039
2229
  })();
2040
2230
  },
2041
- [U, e]
2231
+ [Z, t]
2042
2232
  );
2043
- G(() => {
2044
- if (!n || !v)
2233
+ H(() => {
2234
+ if (!n || !g)
2045
2235
  return;
2046
- let g = !1;
2047
- return C((y) => y || ie === null), V(null), (async () => {
2236
+ let d = !1;
2237
+ return S((w) => w || de === null), V(null), (async () => {
2048
2238
  try {
2049
- const y = await H(e);
2050
- g || Ee(y);
2239
+ const w = await D(t);
2240
+ d || xe(w);
2051
2241
  } catch {
2052
- g || V(Lt);
2242
+ d || V(Bt);
2053
2243
  } finally {
2054
- g || C(!1);
2244
+ d || S(!1);
2055
2245
  }
2056
2246
  })(), () => {
2057
- g = !0;
2247
+ d = !0;
2058
2248
  };
2059
- }, [n, e, v, H]), G(() => {
2060
- if (!n || !w)
2249
+ }, [n, t, g, D]), H(() => {
2250
+ if (!n || !f)
2061
2251
  return;
2062
- let g = !1;
2063
- const y = {
2252
+ let d = !1;
2253
+ const w = {
2064
2254
  id: `user-brief-${Date.now()}`,
2065
- author: ae.user,
2066
- text: As(w, t.invocation_name)
2255
+ author: ne.user,
2256
+ text: Wa(f, e.invocation_name)
2067
2257
  };
2068
2258
  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());
2259
+ var Q, ge;
2260
+ const M = await x.current.start(f);
2261
+ d || (j([
2262
+ Ae(x.current.openingMessage()),
2263
+ Ae(w),
2264
+ Ae(M.message)
2265
+ ]), M.checklist ? (re(M.checklist), (ge = (Q = x.current).seedChecklist) == null || ge.call(Q, M.checklist)) : ie(), Te(M.phase ?? B.running), _e(), oe());
2076
2266
  })(), () => {
2077
- g = !0;
2267
+ d = !0;
2078
2268
  };
2079
2269
  }, [
2080
2270
  n,
2081
- w,
2082
- t.invocation_name,
2083
- e,
2084
- ve,
2085
- Fe,
2086
- we
2271
+ f,
2272
+ e.invocation_name,
2273
+ t,
2274
+ ie,
2275
+ _e,
2276
+ oe
2087
2277
  ]);
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();
2278
+ const dn = C((d) => {
2279
+ ce(la(d));
2280
+ }, []), lt = I ?? t, Ye = de == null ? void 0 : de.chatSessions, kt = Ye != null && Ye.length ? Ye.reduce(
2281
+ (d, w) => Date.parse(w.timestamp) < Date.parse(d.timestamp) ? w : d
2282
+ ).sessionId : void 0, ct = C(() => {
2283
+ z("chat"), U(!1), b !== lt && (v(lt), j([]), ye((d) => d + 1));
2284
+ }, [b, lt]), gn = C(
2285
+ (d) => {
2286
+ if (d === kt) {
2287
+ ct();
2098
2288
  return;
2099
2289
  }
2100
- N(g), L(!0), m("chat"), z([]), me((y) => y + 1);
2290
+ v(d), U(!0), z("chat"), j([]), ye((w) => w + 1);
2101
2291
  },
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: [
2292
+ [kt, ct]
2293
+ ), hn = C((d) => {
2294
+ ce(null), ke(d), ye((w) => w + 1);
2295
+ }, []), un = C(async () => {
2296
+ await x.current.stop(), Te(B.stopped);
2297
+ }, []), pn = se;
2298
+ return /* @__PURE__ */ l(ue, { open: n, closeHandler: s, hideCloseButton: !0, className: "agent-workspace", children: [
2299
+ /* @__PURE__ */ l(ue.Header, { className: "agent-workspace__header", children: [
2110
2300
  /* @__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(
2301
+ /* @__PURE__ */ a("span", { className: "agent-workspace__header-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a(P, { name: "ask-arbor", size: 24 }) }),
2302
+ /* @__PURE__ */ a(ue.Title, { children: e.invocation_name }),
2303
+ /* @__PURE__ */ a(
2114
2304
  "span",
2115
2305
  {
2116
- className: j("agent-workspace__phase", `agent-workspace__phase--${W}`),
2117
- children: vn[W]
2306
+ className: W("agent-workspace__phase", `agent-workspace__phase--${ae}`),
2307
+ children: Ln[ae]
2118
2308
  }
2119
2309
  )
2120
2310
  ] }),
2121
2311
  /* @__PURE__ */ l("div", { className: "agent-workspace__header-actions", children: [
2122
- /* @__PURE__ */ s(
2123
- ee,
2312
+ /* @__PURE__ */ a(
2313
+ te,
2124
2314
  {
2125
- variant: ze ? "secondary" : "primary",
2315
+ variant: je ? "secondary" : "primary",
2126
2316
  size: "S",
2127
2317
  iconLeftName: "clipboard-list",
2128
2318
  iconLeftScreenReaderText: "Toggle checklist",
2129
- "aria-pressed": !ze,
2130
- onClick: () => Jt((g) => !g),
2319
+ "aria-pressed": !je,
2320
+ onClick: () => an((d) => !d),
2131
2321
  children: "Checklist"
2132
2322
  }
2133
2323
  ),
2134
- /* @__PURE__ */ s(
2135
- ee,
2324
+ /* @__PURE__ */ a(
2325
+ te,
2136
2326
  {
2137
- variant: Be ? "secondary" : "primary",
2327
+ variant: Ve ? "secondary" : "primary",
2138
2328
  size: "S",
2139
2329
  iconLeftName: "files",
2140
2330
  iconLeftScreenReaderText: "Toggle resources",
2141
- "aria-pressed": !Be,
2142
- onClick: () => Kt((g) => !g),
2331
+ "aria-pressed": !Ve,
2332
+ onClick: () => sn((d) => !d),
2143
2333
  children: "Resources"
2144
2334
  }
2145
2335
  ),
2146
- /* @__PURE__ */ s(
2147
- ee,
2336
+ /* @__PURE__ */ a(
2337
+ te,
2148
2338
  {
2149
2339
  variant: "secondary",
2150
2340
  size: "S",
2151
2341
  iconLeftName: "x",
2152
2342
  iconLeftScreenReaderText: "Close",
2153
- onClick: a,
2343
+ onClick: s,
2154
2344
  children: "Close"
2155
2345
  }
2156
2346
  )
2157
2347
  ] })
2158
2348
  ] }),
2159
2349
  /* @__PURE__ */ l(
2160
- ce.Body,
2350
+ ue.Body,
2161
2351
  {
2162
- className: j("agent-workspace__body", {
2163
- "agent-workspace__body--no-checklist": ze,
2164
- "agent-workspace__body--no-resources": Be
2352
+ className: W("agent-workspace__body", {
2353
+ "agent-workspace__body--no-checklist": je,
2354
+ "agent-workspace__body--no-resources": Ve
2165
2355
  }),
2166
2356
  children: [
2167
- " ",
2357
+ " ",
2168
2358
  /* @__PURE__ */ l(
2169
2359
  "section",
2170
2360
  {
2171
- className: j("agent-workspace__panel", "agent-workspace__panel--chat", {
2172
- "agent-workspace__panel--timeline": !!v && k === "timeline"
2361
+ className: W("agent-workspace__panel", "agent-workspace__panel--chat", {
2362
+ "agent-workspace__panel--timeline": !!g && R === "timeline"
2173
2363
  }),
2174
2364
  "aria-label": "Agent",
2175
2365
  children: [
2176
2366
  /* @__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,
2367
+ /* @__PURE__ */ a(Ce, { level: 4, children: "Agent" }),
2368
+ y && ae === B.running && /* @__PURE__ */ a(
2369
+ te,
2180
2370
  {
2181
2371
  className: "agent-workspace__panel-header-action",
2182
2372
  variant: "secondary-destructive",
2183
2373
  size: "S",
2184
2374
  iconLeftName: "circle-x",
2185
2375
  iconLeftScreenReaderText: "Stop",
2186
- onClick: () => void Zt(),
2376
+ onClick: () => void un(),
2187
2377
  children: "Stop agent"
2188
2378
  }
2189
2379
  )
2190
2380
  ] }),
2191
- v && /* @__PURE__ */ l(it, { className: "agent-workspace__center-tabs", "aria-label": "Center panel", children: [
2192
- /* @__PURE__ */ s(
2193
- it.Item,
2381
+ g && /* @__PURE__ */ l(dt, { className: "agent-workspace__center-tabs", "aria-label": "Center panel", children: [
2382
+ /* @__PURE__ */ a(
2383
+ dt.Item,
2194
2384
  {
2195
- active: k === "chat",
2385
+ active: R === "chat",
2196
2386
  tabElementProps: {
2197
2387
  id: "agent-center-tab-chat",
2198
- onClick: () => m("chat")
2388
+ onClick: () => z("chat")
2199
2389
  },
2200
2390
  children: "Chat"
2201
2391
  }
2202
2392
  ),
2203
- /* @__PURE__ */ s(
2204
- it.Item,
2393
+ /* @__PURE__ */ a(
2394
+ dt.Item,
2205
2395
  {
2206
- active: k === "timeline",
2396
+ active: R === "timeline",
2207
2397
  tabElementProps: {
2208
2398
  id: "agent-center-tab-timeline",
2209
- onClick: () => m("timeline")
2399
+ onClick: () => z("timeline")
2210
2400
  },
2211
2401
  children: "Timeline"
2212
2402
  }
2213
2403
  )
2214
2404
  ] }),
2215
- v && k === "chat" && E && /* @__PURE__ */ s("div", { className: "agent-workspace__center-back", children: /* @__PURE__ */ s(
2216
- ee,
2405
+ g && R === "chat" && Ee && /* @__PURE__ */ a("div", { className: "agent-workspace__center-back", children: /* @__PURE__ */ a(
2406
+ te,
2217
2407
  {
2218
2408
  variant: "tertiary",
2219
2409
  size: "S",
2220
2410
  iconLeftName: "arrow-left",
2221
2411
  iconLeftScreenReaderText: "Back to main chat",
2222
- onClick: rt,
2412
+ onClick: ct,
2223
2413
  children: "Back to main chat"
2224
2414
  }
2225
2415
  ) }),
2226
- v && k === "timeline" && /* @__PURE__ */ s(
2227
- qn,
2416
+ g && R === "timeline" && /* @__PURE__ */ a(
2417
+ ia,
2228
2418
  {
2229
- timeline: ie,
2230
- isLoading: p,
2231
- error: A,
2232
- onOpenChatSession: Xt
2419
+ timeline: de,
2420
+ isLoading: h,
2421
+ error: k,
2422
+ onOpenChatSession: gn
2233
2423
  }
2234
2424
  ),
2235
- /* @__PURE__ */ s(
2425
+ /* @__PURE__ */ a(
2236
2426
  "div",
2237
2427
  {
2238
2428
  className: "agent-workspace__chat-keep-alive",
2239
- hidden: !!v && k !== "chat",
2240
- children: /* @__PURE__ */ s(
2241
- Pn,
2429
+ hidden: !!g && R !== "chat",
2430
+ children: /* @__PURE__ */ a(
2431
+ Wn,
2242
2432
  {
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)
2433
+ connector: G,
2434
+ phase: ae,
2435
+ chatHistory: ze,
2436
+ chatSessionKey: Ge,
2437
+ startQuery: Re,
2438
+ clarificationMessage: at,
2439
+ enableUpload: L,
2440
+ onTurn: on,
2441
+ onAwaitingChange: ot,
2442
+ onClarificationPrompt: hn,
2443
+ onDismissClarification: () => ce(null)
2254
2444
  }
2255
2445
  )
2256
2446
  }
@@ -2258,282 +2448,284 @@ const Bt = (t, e) => (n) => {
2258
2448
  ]
2259
2449
  }
2260
2450
  ),
2261
- !ze && /* @__PURE__ */ s(
2262
- Ln,
2451
+ !je && /* @__PURE__ */ a(
2452
+ jn,
2263
2453
  {
2264
- checklist: en,
2265
- isLoading: ge,
2266
- error: qt,
2267
- phase: W,
2268
- canRequestInput: W === F.running && !He,
2269
- onAttentionItemClick: jt
2454
+ checklist: pn,
2455
+ isLoading: me,
2456
+ error: nn,
2457
+ phase: ae,
2458
+ canRequestInput: ae === B.running && !We,
2459
+ onAttentionItemClick: dn
2270
2460
  }
2271
2461
  ),
2272
- !Be && /* @__PURE__ */ s(
2273
- Dn,
2462
+ !Ve && /* @__PURE__ */ a(
2463
+ Xn,
2274
2464
  {
2275
- resources: et,
2276
- isLoading: de,
2277
- error: Ue,
2278
- onOpenResource: Yt
2465
+ resources: st,
2466
+ isLoading: pe,
2467
+ error: Fe,
2468
+ onOpenResource: cn
2279
2469
  }
2280
2470
  ),
2281
- /* @__PURE__ */ s(
2282
- Un,
2471
+ /* @__PURE__ */ a(
2472
+ Vn,
2283
2473
  {
2284
- resource: xe,
2285
- html: $e,
2286
- isLoading: Me,
2287
- error: tt,
2288
- onClose: Vt
2474
+ resource: Be,
2475
+ html: Je,
2476
+ isLoading: Ke,
2477
+ error: rt,
2478
+ onClose: ln
2289
2479
  }
2290
2480
  )
2291
2481
  ]
2292
2482
  }
2293
2483
  )
2294
2484
  ] });
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,
2485
+ }, Xa = "Unable to load agent definitions. Please try again.", Za = "Unable to start the agent.", Mt = "Loading agents…", tn = ({
2486
+ open: e,
2487
+ onClose: t,
2298
2488
  onStart: n,
2299
- agentDefinitions: a,
2489
+ agentDefinitions: s,
2300
2490
  definitionsState: r = "idle",
2301
2491
  definitionsError: o = null,
2302
2492
  onRetryDefinitions: i,
2303
- embedded: d = !1
2493
+ embedded: u = !1
2304
2494
  }) => {
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
2495
+ const [c, g] = p(void 0), [_, N] = p(""), [y, I] = p(!1), [L, f] = p(null), K = [...s].sort((v, R) => v.display_name.localeCompare(R.display_name)).map((v) => ({
2496
+ value: v.ref,
2497
+ label: v.display_name
2308
2498
  }));
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);
2499
+ H(() => {
2500
+ e && (g(void 0), N(""), I(!1), f(null));
2501
+ }, [e]), Se(() => {
2502
+ !e || u || en(".new-agent");
2503
+ }, [e, u]);
2504
+ const T = c !== void 0 && _.trim().length > 0, O = C(
2505
+ (v) => {
2506
+ const R = s.find((z) => z.ref === v[0]);
2507
+ R && g(R);
2316
2508
  },
2317
- [a]
2318
- ), k = T(async () => {
2319
- if (!(!c || !D || u)) {
2320
- x(!0), b(null);
2509
+ [s]
2510
+ ), A = C(async () => {
2511
+ if (!(!c || !T || y)) {
2512
+ I(!0), f(null);
2321
2513
  try {
2322
- await n({ definition: c, invocationName: f.trim() });
2323
- } catch (L) {
2324
- b(L instanceof Error ? L.message : Rs);
2514
+ await n({ definition: c, invocationName: _.trim() });
2515
+ } catch (v) {
2516
+ f(v instanceof Error ? v.message : Za);
2325
2517
  } finally {
2326
- x(!1);
2518
+ I(!1);
2327
2519
  }
2328
2520
  }
2329
- }, [D, c, f, u, n]);
2330
- if (r === "idle" && a.length === 0 || !t)
2521
+ }, [T, c, _, y, n]);
2522
+ if (r === "idle" && s.length === 0 || !e)
2331
2523
  return null;
2332
2524
  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" })
2525
+ /* @__PURE__ */ a("span", { className: "new-agent__header-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a(P, { name: "ask-arbor", size: 24 }) }),
2526
+ u ? /* @__PURE__ */ a("h2", { className: "new-agent__title", children: "Start an agent" }) : /* @__PURE__ */ a(ue.Title, { children: "Start an agent" })
2335
2527
  ] });
2336
- let E;
2337
- return r === "loading" ? E = /* @__PURE__ */ l("div", { className: "new-agent__state", "aria-live": "polite", children: [
2338
- /* @__PURE__ */ s(
2528
+ let b;
2529
+ return r === "loading" ? b = /* @__PURE__ */ l("div", { className: "new-agent__state", "aria-live": "polite", children: [
2530
+ /* @__PURE__ */ a(
2339
2531
  P,
2340
2532
  {
2341
2533
  name: "loader",
2342
2534
  size: 24,
2343
2535
  color: "var(--color-brand-600)",
2344
2536
  className: "new-agent__spinner",
2345
- screenReaderText: Tt
2537
+ screenReaderText: Mt
2346
2538
  }
2347
2539
  ),
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(
2540
+ /* @__PURE__ */ a("p", { className: "new-agent__state-message", children: Mt })
2541
+ ] }) : r === "error" ? b = /* @__PURE__ */ l("div", { className: "new-agent__state new-agent__state--error", role: "alert", children: [
2542
+ /* @__PURE__ */ a(P, { name: "triangle-alert", size: 24, color: "var(--color-semantic-destructive-600)" }),
2543
+ /* @__PURE__ */ a("p", { className: "new-agent__state-message", children: o ?? Xa }),
2544
+ i ? /* @__PURE__ */ a(te, { variant: "secondary", size: "S", onClick: i, children: "Try again" }) : null
2545
+ ] }) : b = /* @__PURE__ */ l(
2354
2546
  "form",
2355
2547
  {
2356
2548
  className: "new-agent__form",
2357
2549
  "aria-label": "Start an agent",
2358
- onSubmit: (L) => {
2359
- L.preventDefault(), D && !u && k();
2550
+ onSubmit: (v) => {
2551
+ v.preventDefault(), T && !y && A();
2360
2552
  },
2361
2553
  children: [
2362
2554
  /* @__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,
2555
+ /* @__PURE__ */ a("label", { className: "new-agent__type-label", htmlFor: "new-agent-type", children: "What would you like your agent to do?" }),
2556
+ /* @__PURE__ */ a(
2557
+ _n,
2366
2558
  {
2367
2559
  id: "new-agent-type",
2368
2560
  placeholder: "Which agent would you like to start?",
2369
- options: S,
2561
+ options: K,
2370
2562
  selectedValues: c ? [c.ref] : [],
2371
- onSelectionChange: N
2563
+ onSelectionChange: O
2372
2564
  }
2373
2565
  )
2374
2566
  ] }),
2375
2567
  /* @__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,
2568
+ /* @__PURE__ */ a("label", { className: "new-agent__type-label", htmlFor: "new-agent-invocation-name", children: "Name" }),
2569
+ /* @__PURE__ */ a(
2570
+ fn,
2379
2571
  {
2380
2572
  id: "new-agent-invocation-name",
2381
- value: f,
2573
+ value: _,
2382
2574
  placeholder: "What would you like to call your agent?",
2383
- onChange: (L) => h(L.target.value)
2575
+ onChange: (v) => N(v.target.value)
2384
2576
  }
2385
2577
  )
2386
2578
  ] }),
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,
2579
+ L ? /* @__PURE__ */ a("p", { className: "new-agent__error", role: "alert", children: L }) : null,
2580
+ /* @__PURE__ */ a("div", { className: "new-agent__actions", children: /* @__PURE__ */ a(
2581
+ te,
2390
2582
  {
2391
2583
  type: "submit",
2392
2584
  variant: "primary",
2393
- className: j("new-agent__start-button", {
2394
- "new-agent__start-button--starting": u
2585
+ className: W("new-agent__start-button", {
2586
+ "new-agent__start-button--starting": y
2395
2587
  }),
2396
- disabled: !D || u,
2397
- iconLeftName: u ? "loader" : "sparkles",
2398
- iconLeftScreenReaderText: u ? "Starting" : void 0,
2399
- children: u ? "Starting…" : "Start"
2588
+ disabled: !T || y,
2589
+ iconLeftName: y ? "loader" : "sparkles",
2590
+ iconLeftScreenReaderText: y ? "Starting" : void 0,
2591
+ children: y ? "Starting…" : "Start"
2400
2592
  }
2401
2593
  ) })
2402
2594
  ]
2403
2595
  }
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 })
2596
+ ), u ? /* @__PURE__ */ l("div", { className: W("new-agent", "new-agent--embedded"), children: [
2597
+ /* @__PURE__ */ a("div", { className: "new-agent__header", children: m }),
2598
+ /* @__PURE__ */ a("div", { className: "new-agent__body", children: b })
2599
+ ] }) : /* @__PURE__ */ l(ue, { open: e, closeHandler: t, className: "new-agent", children: [
2600
+ /* @__PURE__ */ a(ue.Header, { className: "new-agent__header", children: m }),
2601
+ /* @__PURE__ */ a(ue.Body, { className: "new-agent__body", children: b })
2410
2602
  ] });
2411
- }, Rt = (t) => {
2412
- window.location.assign(t);
2413
- }, Es = ({
2414
- open: t,
2415
- authToken: e,
2603
+ }, $t = (e) => {
2604
+ window.location.assign(e);
2605
+ }, Qa = ({
2606
+ open: e,
2607
+ authToken: t,
2416
2608
  headers: n,
2417
- agentDefinitionsUrl: a,
2609
+ agentDefinitionsUrl: s,
2418
2610
  agentsUrl: r,
2419
2611
  closeUrl: o,
2420
2612
  successUrl: i,
2421
- onClose: d,
2613
+ onClose: u,
2422
2614
  onStart: c,
2423
- embedded: v = !1
2615
+ embedded: g = !1
2424
2616
  }) => {
2425
- const f = JSON.stringify(n ?? {}), h = Y(
2426
- () => new ht({
2427
- token: e,
2617
+ const _ = JSON.stringify(n ?? {}), N = Y(
2618
+ () => new ft({
2619
+ token: t,
2428
2620
  headers: n,
2429
2621
  urls: {
2430
- agentDefinitions: a,
2622
+ agentDefinitions: s,
2431
2623
  agents: r
2432
2624
  }
2433
2625
  }),
2434
2626
  // 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)
2627
+ [t, s, r, _]
2628
+ ), [y, I] = p([]), [L, f] = p("loading"), [K, T] = p(null), [O, A] = p(0);
2629
+ H(() => {
2630
+ if (!e)
2439
2631
  return;
2440
- let O = !1;
2441
- return b("loading"), D(null), (async () => {
2632
+ let R = !1;
2633
+ return f("loading"), T(null), (async () => {
2442
2634
  try {
2443
- const M = await h.listAgentDefinitions();
2444
- if (O)
2635
+ const z = await N.listAgentDefinitions();
2636
+ if (R)
2445
2637
  return;
2446
- x(M.map(Mt)), b("idle");
2447
- } catch (M) {
2448
- if (O)
2638
+ I(z.map(Vt)), f("idle");
2639
+ } catch (z) {
2640
+ if (R)
2449
2641
  return;
2450
- x([]), D(Ft(M)), b("error");
2642
+ I([]), T(Qt(z)), f("error");
2451
2643
  }
2452
2644
  })(), () => {
2453
- O = !0;
2645
+ R = !0;
2454
2646
  };
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);
2647
+ }, [N, e, O]);
2648
+ const m = C(() => {
2649
+ u == null || u(), o && $t(o);
2650
+ }, [o, u]), b = C(
2651
+ async (R) => {
2652
+ await N.createAgent(R.definition.ref, {
2653
+ invocationName: R.invocationName
2654
+ }), c == null || c(R), i && $t(i);
2463
2655
  },
2464
- [h, c, i]
2465
- ), L = T(() => {
2466
- k((O) => O + 1);
2656
+ [N, c, i]
2657
+ ), v = C(() => {
2658
+ A((R) => R + 1);
2467
2659
  }, []);
2468
- return /* @__PURE__ */ s(
2469
- Gt,
2660
+ return /* @__PURE__ */ a(
2661
+ tn,
2470
2662
  {
2471
- open: t,
2663
+ open: e,
2472
2664
  onClose: m,
2473
- onStart: E,
2474
- agentDefinitions: u,
2475
- definitionsState: w,
2476
- definitionsError: S,
2477
- onRetryDefinitions: L,
2478
- embedded: v
2665
+ onStart: b,
2666
+ agentDefinitions: y,
2667
+ definitionsState: L,
2668
+ definitionsError: K,
2669
+ onRetryDefinitions: v,
2670
+ embedded: g
2479
2671
  }
2480
2672
  );
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(
2673
+ }, es = (e) => "agentDefinitionsUrl" in e, ts = (e) => es(e) ? /* @__PURE__ */ a(Qa, { ...e }) : /* @__PURE__ */ a(tn, { ...e }), ns = (e) => e !== void 0 && e.some((t) => t.status === $.hitl), as = (e, t) => ns(t) ? E.hitl : e.status, ss = ({ column: e, label: t }) => e.statusIcon ? /* @__PURE__ */ a("span", { className: "agent-view__status-indicator", children: /* @__PURE__ */ a(
2482
2674
  P,
2483
2675
  {
2484
- name: t.statusIcon.name,
2676
+ name: e.statusIcon.name,
2485
2677
  size: 16,
2486
- color: t.statusIcon.color,
2487
- className: j({
2488
- "agent-view__progress-icon--spinning": t.statusIcon.spin
2678
+ color: e.statusIcon.color,
2679
+ className: W({
2680
+ "agent-view__progress-icon--spinning": e.statusIcon.spin
2489
2681
  }),
2490
- screenReaderText: e
2682
+ screenReaderText: t
2491
2683
  }
2492
- ) }) : /* @__PURE__ */ s(
2684
+ ) }) : /* @__PURE__ */ a(
2493
2685
  "span",
2494
2686
  {
2495
- className: j("agent-view__dot", {
2496
- [`agent-view__dot--${t.dotModifier}`]: t.dotModifier
2687
+ className: W("agent-view__dot", {
2688
+ [`agent-view__dot--${e.dotModifier}`]: e.dotModifier
2497
2689
  }),
2498
- children: /* @__PURE__ */ s(It, { colour: t.dotColour, label: e })
2690
+ children: /* @__PURE__ */ a(zt, { colour: e.dotColour, label: t })
2499
2691
  }
2500
- ), xs = ({
2501
- agent: t,
2502
- agentName: e,
2692
+ ), rs = ({
2693
+ agent: e,
2694
+ agentName: t,
2503
2695
  column: n,
2504
- isExpanded: a,
2696
+ isExpanded: s,
2505
2697
  isLoading: r,
2506
2698
  checklist: o,
2507
2699
  error: i,
2508
- onToggle: d,
2700
+ onToggle: u,
2509
2701
  onViewAgent: c
2510
2702
  }) => {
2511
- const { id: v, invocation_name: f } = t, h = `agent-card-${v}-header`, u = `agent-card-${v}-progress`;
2512
- return /* @__PURE__ */ s(
2703
+ const { id: g, invocation_name: _ } = e, N = `agent-card-${g}-header`, y = `agent-card-${g}-progress`;
2704
+ return /* @__PURE__ */ a(
2513
2705
  "li",
2514
2706
  {
2515
- className: j("agent-view__card", {
2516
- "agent-view__card--expanded": a
2707
+ className: W("agent-view__card", {
2708
+ "agent-view__card--expanded": s
2517
2709
  }),
2518
- children: /* @__PURE__ */ l(an, { spacing: "dense", children: [
2519
- /* @__PURE__ */ s(
2710
+ children: /* @__PURE__ */ l(vn, { spacing: "dense", children: [
2711
+ /* @__PURE__ */ a(
2520
2712
  "button",
2521
2713
  {
2522
2714
  type: "button",
2523
2715
  className: "agent-view__card-toggle",
2524
- "aria-expanded": a,
2525
- "aria-controls": u,
2526
- "aria-label": f,
2527
- id: h,
2528
- onClick: () => d(v),
2716
+ "aria-expanded": s,
2717
+ "aria-controls": y,
2718
+ "aria-label": _,
2719
+ id: N,
2720
+ onClick: () => u(g),
2529
2721
  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(
2722
+ /* @__PURE__ */ a(ss, { column: n }),
2723
+ /* @__PURE__ */ a("span", { className: "agent-view__card-invocation-name", children: _ }),
2724
+ /* @__PURE__ */ a("span", { className: "agent-view__card-agent-name", children: t }),
2725
+ /* @__PURE__ */ a(
2534
2726
  P,
2535
2727
  {
2536
- name: a ? "chevron-up" : "chevron-down",
2728
+ name: s ? "chevron-up" : "chevron-down",
2537
2729
  size: 16,
2538
2730
  className: "agent-view__card-chevron"
2539
2731
  }
@@ -2541,290 +2733,278 @@ const Bt = (t, e) => (n) => {
2541
2733
  ] })
2542
2734
  }
2543
2735
  ),
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
- )
2736
+ s && /* @__PURE__ */ l("div", { id: y, "aria-labelledby": N, className: "agent-view__card-progress", children: [
2737
+ r && /* @__PURE__ */ l("div", { className: "agent-view__progress-loading", "aria-live": "polite", children: [
2738
+ /* @__PURE__ */ a(
2739
+ P,
2740
+ {
2741
+ name: "loader",
2742
+ size: 16,
2743
+ color: "var(--color-brand-600)",
2744
+ className: "agent-view__progress-icon--spinning",
2745
+ screenReaderText: be
2746
+ }
2747
+ ),
2748
+ /* @__PURE__ */ a("span", { children: be })
2749
+ ] }),
2750
+ !r && i && /* @__PURE__ */ a("p", { className: "agent-view__progress-error", role: "alert", children: i }),
2751
+ !r && !i && o !== null && /* @__PURE__ */ a(qn, { checklist: o }),
2752
+ !r && !i && o === null && /* @__PURE__ */ l("div", { className: "agent-view__progress-loading", "aria-live": "polite", children: [
2753
+ /* @__PURE__ */ a(
2754
+ P,
2755
+ {
2756
+ name: "loader",
2757
+ size: 16,
2758
+ color: "var(--color-brand-600)",
2759
+ className: "agent-view__progress-icon--spinning",
2760
+ screenReaderText: be
2761
+ }
2762
+ ),
2763
+ /* @__PURE__ */ a("span", { children: be })
2764
+ ] }),
2765
+ /* @__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" }) })
2766
+ ] })
2591
2767
  ] })
2592
2768
  }
2593
2769
  );
2594
- }, Et = ({
2595
- column: t,
2596
- agents: e,
2770
+ }, Ht = ({
2771
+ column: e,
2772
+ agents: t,
2597
2773
  expandedAgentId: n,
2598
- loadingAgentId: a,
2774
+ loadingAgentId: s,
2599
2775
  checklistByInvocationId: r,
2600
2776
  errorByAgentId: o,
2601
2777
  definitionNameByRef: i,
2602
- onToggleAgent: d,
2778
+ onToggleAgent: u,
2603
2779
  onViewAgent: c,
2604
- isSplit: v = !1
2780
+ isSplit: g = !1
2605
2781
  }) => /* @__PURE__ */ l(
2606
2782
  "section",
2607
2783
  {
2608
- className: j("agent-view__column", {
2609
- "agent-view__column--split": v
2784
+ className: W("agent-view__column", {
2785
+ "agent-view__column--split": g
2610
2786
  }),
2611
- "aria-label": t.title,
2787
+ "aria-label": e.title,
2612
2788
  children: [
2613
2789
  /* @__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 })
2790
+ /* @__PURE__ */ a(Ce, { level: 4, children: e.title }),
2791
+ /* @__PURE__ */ a("span", { className: "agent-view__column-count", children: t.length })
2616
2792
  ] }),
2617
- /* @__PURE__ */ s("ul", { className: "agent-view__card-list", children: e.map((f) => /* @__PURE__ */ s(
2618
- xs,
2793
+ /* @__PURE__ */ a("ul", { className: "agent-view__card-list", children: t.map((_) => /* @__PURE__ */ a(
2794
+ rs,
2619
2795
  {
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,
2796
+ agent: _,
2797
+ agentName: _t(_, i),
2798
+ column: e,
2799
+ isExpanded: n === _.id,
2800
+ isLoading: s === _.id,
2801
+ checklist: r[_.invocation_id] ?? null,
2802
+ error: o[_.id] ?? null,
2803
+ onToggle: u,
2628
2804
  onViewAgent: c
2629
2805
  },
2630
- f.id
2806
+ _.id
2631
2807
  )) })
2632
2808
  ]
2633
2809
  }
2634
- ), gt = (t, e) => e.get(t.agent_definition_ref) ?? t.agent_definition_ref.replace(/_/g, " "), Fs = ({
2635
- jwt: t,
2636
- headers: e,
2810
+ ), _t = (e, t) => t.get(e.agent_definition_ref) ?? e.agent_definition_ref.replace(/_/g, " "), hs = ({
2811
+ jwt: e,
2812
+ headers: t,
2637
2813
  agentDefinitionsUrl: n,
2638
- agentsUrl: a,
2814
+ agentsUrl: s,
2639
2815
  agentUrl: r,
2640
2816
  agentChecklistUrl: o,
2641
2817
  agentResourcesUrl: i,
2642
- agentTimelineUrl: d,
2818
+ agentTimelineUrl: u,
2643
2819
  agentChatUrl: c,
2644
- agentConversationUrl: v,
2645
- enableUpload: f,
2646
- showHeader: h = !1,
2647
- institutions: u
2820
+ agentConversationUrl: g,
2821
+ stopAgentUrl: _,
2822
+ enableUpload: N,
2823
+ showHeader: y = !1,
2824
+ institutions: I,
2825
+ usePusherToRepoll: L = !1,
2826
+ pusherChannelPrefix: f = jt,
2827
+ subscribeToPusher: K
2648
2828
  }) => {
2649
- var Ee;
2650
- const x = Y(
2829
+ var xe;
2830
+ const T = Y(
2651
2831
  () => ({
2652
2832
  agentDefinitions: n,
2653
- agents: a,
2833
+ agents: s,
2654
2834
  agent: r,
2655
2835
  agentChecklist: o,
2656
2836
  ...i ? { agentResources: i } : {},
2657
- ...d ? { agentTimeline: d } : {},
2837
+ ...u ? { agentTimeline: u } : {},
2658
2838
  agentChat: c,
2659
- agentConversation: v
2839
+ agentConversation: g
2660
2840
  }),
2661
2841
  [
2662
2842
  n,
2663
- a,
2843
+ s,
2664
2844
  r,
2665
2845
  o,
2666
2846
  i,
2667
- d,
2847
+ u,
2668
2848
  c,
2669
- v
2849
+ g
2670
2850
  ]
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,
2681
- 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
+ ), [O, A] = p(null), m = O ? (xe = I == null ? void 0 : I.find(
2852
+ (h) => h.applicationId === O.application_id
2853
+ )) == null ? void 0 : xe.applicationUrl : void 0, b = Y(() => {
2854
+ const h = { ...t ?? {} };
2855
+ return m ? h[we.arborApplicationUrl] = m : delete h[we.arborApplicationUrl], h;
2856
+ }, [t, m]), {
2857
+ agents: v,
2858
+ agentDefinitions: R,
2859
+ loadState: z,
2860
+ loadError: Ee,
2861
+ reload: U,
2862
+ refresh: G,
2863
+ fetchAgentChecklist: q,
2864
+ createAgent: X
2865
+ } = Ba({ jwt: e, headers: b, urls: T }), [Z, D] = p(!1), [x, ae] = p(null), [Te, ze] = p(null), [j, Ge] = p({}), [ye, Re] = p({}), [ke, at] = p([]), [ce, st] = p([]), Ie = Y(() => {
2866
+ const h = new Set(v.map((k) => k.application_id)), S = new Map(
2867
+ (I ?? []).map((k) => [k.applicationId, k.name])
2688
2868
  );
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
2869
+ return [...h].sort(
2870
+ (k, V) => (S.get(k) ?? k).localeCompare(S.get(V) ?? V)
2871
+ ).map((k) => ({
2872
+ value: k,
2873
+ label: S.get(k) ?? k
2694
2874
  }));
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();
2875
+ }, [v, I]), pe = Y(
2876
+ () => new Map(R.map((h) => [h.ref, h.display_name])),
2877
+ [R]
2878
+ ), Oe = Y(() => [...new Set(
2879
+ v.map((S) => _t(S, pe))
2880
+ )].sort((S, k) => S.localeCompare(k)).map((S) => ({
2881
+ value: S,
2882
+ label: S
2883
+ })), [v, pe]), Fe = Y(() => v.filter((h) => !(ke.length > 0 && !ke.includes(h.application_id) || ce.length > 0 && !ce.includes(_t(h, pe)))), [v, pe, ce, ke]), Ne = Ie.length > 1, Be = Oe.length > 1, qe = Ne || Be;
2884
+ H(() => {
2885
+ const h = window.setInterval(() => {
2886
+ G();
2707
2887
  }, 6e4);
2708
2888
  return () => {
2709
- window.clearInterval(p);
2889
+ window.clearInterval(h);
2710
2890
  };
2711
- }, [O]), G(() => {
2712
- if (N.length === 0)
2891
+ }, [G]), H(() => {
2892
+ if (v.length === 0)
2713
2893
  return;
2714
- let p = !1;
2894
+ let h = !1;
2715
2895
  return (async () => {
2716
- const C = await Promise.allSettled(
2717
- N.map(async (A) => {
2718
- const V = await M(A.invocation_id);
2896
+ const S = await Promise.allSettled(
2897
+ v.map(async (k) => {
2898
+ const V = await q(k.invocation_id);
2719
2899
  return {
2720
- agentId: A.id,
2721
- invocationId: A.invocation_id,
2900
+ agentId: k.id,
2901
+ invocationId: k.invocation_id,
2722
2902
  checklist: V.checklist
2723
2903
  };
2724
2904
  })
2725
2905
  );
2726
- p || (Le((A) => {
2727
- const V = { ...A };
2728
- let ne = !1;
2729
- for (const se of C) {
2730
- if (se.status !== "fulfilled")
2906
+ h || (Ge((k) => {
2907
+ const V = { ...k };
2908
+ let se = !1;
2909
+ for (const re of S) {
2910
+ if (re.status !== "fulfilled")
2731
2911
  continue;
2732
- const { invocationId: ge, checklist: Ie } = se.value;
2733
- JSON.stringify(A[ge]) !== JSON.stringify(Ie) && (V[ge] = Ie, ne = !0);
2912
+ const { invocationId: me, checklist: De } = re.value;
2913
+ JSON.stringify(k[me]) !== JSON.stringify(De) && (V[me] = De, se = !0);
2734
2914
  }
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;
2915
+ return se ? V : k;
2916
+ }), Re((k) => {
2917
+ const V = { ...k };
2918
+ let se = !1;
2919
+ return S.forEach((re, me) => {
2920
+ re.status === "rejected" && V[v[me].id] !== Qe && (V[v[me].id] = Qe, se = !0);
2921
+ }), se ? V : k;
2742
2922
  }));
2743
2923
  })(), () => {
2744
- p = !0;
2924
+ h = !0;
2745
2925
  };
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;
2926
+ }, [v, q]);
2927
+ const Je = C(
2928
+ async (h) => {
2929
+ if (!j[h.invocation_id]) {
2930
+ ze(h.id), Re((S) => {
2931
+ const k = { ...S };
2932
+ return delete k[h.id], k;
2753
2933
  });
2754
2934
  try {
2755
- const C = await M(p.invocation_id);
2756
- Le((A) => ({
2757
- ...A,
2758
- [p.invocation_id]: C.checklist
2935
+ const S = await q(h.invocation_id);
2936
+ Ge((k) => ({
2937
+ ...k,
2938
+ [h.invocation_id]: S.checklist
2759
2939
  }));
2760
2940
  } catch {
2761
- Ae((C) => ({
2762
- ...C,
2763
- [p.id]: We
2941
+ Re((S) => ({
2942
+ ...S,
2943
+ [h.id]: Qe
2764
2944
  }));
2765
2945
  } finally {
2766
- J((C) => C === p.id ? null : C);
2946
+ ze((S) => S === h.id ? null : S);
2767
2947
  }
2768
2948
  }
2769
2949
  },
2770
- [M, z]
2771
- ), Ce = T(
2772
- (p) => {
2773
- if (I === p) {
2774
- W(null);
2950
+ [q, j]
2951
+ ), Le = C(
2952
+ (h) => {
2953
+ if (x === h) {
2954
+ ae(null);
2775
2955
  return;
2776
2956
  }
2777
- const C = N.find(({ id: A }) => A === p);
2778
- C && (W(p), $e(C));
2957
+ const S = v.find(({ id: k }) => k === h);
2958
+ S && (ae(h), Je(S));
2779
2959
  },
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]
2960
+ [v, x, Je]
2961
+ ), Ke = Y(() => {
2962
+ const h = {};
2963
+ for (const S of Fe) {
2964
+ const k = as(
2965
+ S,
2966
+ j[S.invocation_id]
2787
2967
  );
2788
- (p[A] ?? (p[A] = [])).push(C);
2968
+ (h[k] ?? (h[k] = [])).push(S);
2789
2969
  }
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);
2970
+ return h;
2971
+ }, [Fe, j]), Ue = C((h) => {
2972
+ A(h);
2973
+ }, []), rt = C(
2974
+ async (h) => {
2975
+ const S = await X(h);
2976
+ A(S), D(!1);
2797
2977
  },
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
2978
+ [X]
2979
+ ), Pe = C(() => {
2980
+ A(null);
2981
+ }, []), de = {
2982
+ expandedAgentId: x,
2983
+ loadingAgentId: Te,
2984
+ checklistByInvocationId: j,
2985
+ errorByAgentId: ye,
2986
+ definitionNameByRef: pe,
2987
+ onToggleAgent: Le,
2988
+ onViewAgent: Ue
2809
2989
  };
2810
2990
  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,
2991
+ y && /* @__PURE__ */ l("div", { className: "agent-view__header", children: [
2992
+ /* @__PURE__ */ a(Ce, { level: 1, children: "Agents" }),
2993
+ /* @__PURE__ */ a(
2994
+ te,
2815
2995
  {
2816
2996
  variant: "primary",
2817
2997
  size: "S",
2818
2998
  iconLeftName: "sparkles",
2819
2999
  iconLeftScreenReaderText: "Start an agent",
2820
- onClick: () => H(!0),
3000
+ onClick: () => D(!0),
2821
3001
  children: "Start an agent"
2822
3002
  }
2823
3003
  )
2824
3004
  ] }),
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(
3005
+ v.length > 0 && qe && /* @__PURE__ */ l("div", { className: "agent-view__filters", children: [
3006
+ Ne && /* @__PURE__ */ l("div", { className: "agent-view__filter", children: [
3007
+ /* @__PURE__ */ a(
2828
3008
  "label",
2829
3009
  {
2830
3010
  className: "agent-view__filter-label",
@@ -2832,43 +3012,36 @@ const Bt = (t, e) => (n) => {
2832
3012
  children: "Institution"
2833
3013
  }
2834
3014
  ),
2835
- /* @__PURE__ */ s(
2836
- vt,
3015
+ /* @__PURE__ */ a(
3016
+ At,
2837
3017
  {
2838
3018
  id: "agent-view-institution-filter",
2839
3019
  triggerVariant: "button",
2840
3020
  multiple: !0,
2841
3021
  searchType: "substring",
2842
3022
  placeholder: "All institutions",
2843
- options: Se,
2844
- value: _e,
2845
- onValueChange: Ze,
3023
+ options: Ie,
3024
+ value: ke,
3025
+ onValueChange: at,
2846
3026
  showSelectionCountBadge: !0,
2847
3027
  showClearAll: !0,
2848
3028
  clearAllLabel: "Clear institutions"
2849
3029
  }
2850
3030
  )
2851
3031
  ] }),
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,
3032
+ Be && /* @__PURE__ */ l("div", { className: "agent-view__filter", children: [
3033
+ /* @__PURE__ */ a("label", { className: "agent-view__filter-label", htmlFor: "agent-view-agent-filter", children: "Agent" }),
3034
+ /* @__PURE__ */ a(
3035
+ At,
2863
3036
  {
2864
3037
  id: "agent-view-agent-filter",
2865
3038
  triggerVariant: "button",
2866
3039
  multiple: !0,
2867
3040
  searchType: "substring",
2868
3041
  placeholder: "All agents",
2869
- options: be,
2870
- value: re,
2871
- onValueChange: et,
3042
+ options: Oe,
3043
+ value: ce,
3044
+ onValueChange: st,
2872
3045
  showSelectionCountBadge: !0,
2873
3046
  showClearAll: !0,
2874
3047
  clearAllLabel: "Clear agents"
@@ -2876,117 +3049,122 @@ const Bt = (t, e) => (n) => {
2876
3049
  )
2877
3050
  ] })
2878
3051
  ] }),
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(
3052
+ z === "error" ? /* @__PURE__ */ l("div", { className: "agent-view__state agent-view__state--error", role: "alert", children: [
3053
+ /* @__PURE__ */ a(P, { name: "triangle-alert", size: 24, color: "var(--color-semantic-destructive-600)" }),
3054
+ /* @__PURE__ */ a("p", { className: "agent-view__state-message", children: Ee ?? qt }),
3055
+ /* @__PURE__ */ a(te, { variant: "secondary", size: "S", onClick: U, children: "Try again" })
3056
+ ] }) : z === "loading" && v.length === 0 ? /* @__PURE__ */ l("div", { className: "agent-view__state", "aria-live": "polite", children: [
3057
+ /* @__PURE__ */ a(
2892
3058
  P,
2893
3059
  {
2894
3060
  name: "loader",
2895
3061
  size: 24,
2896
3062
  color: "var(--color-brand-600)",
2897
3063
  className: "agent-view__progress-icon--spinning",
2898
- screenReaderText: yt
3064
+ screenReaderText: St
2899
3065
  }
2900
3066
  ),
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,
3067
+ /* @__PURE__ */ a("p", { className: "agent-view__state-message", children: St })
3068
+ ] }) : v.length === 0 ? /* @__PURE__ */ a(Mn, {}) : /* @__PURE__ */ l("div", { className: "agent-view__board", children: [
3069
+ bn.map((h) => /* @__PURE__ */ a(
3070
+ Ht,
2905
3071
  {
2906
- column: Ve[p],
2907
- agents: Me[p] ?? [],
2908
- ...ie
3072
+ column: et[h],
3073
+ agents: Ke[h] ?? [],
3074
+ ...de
2909
3075
  },
2910
- p
3076
+ h
2911
3077
  )),
2912
- /* @__PURE__ */ s("div", { className: "agent-view__split-column", children: gn.map((p) => /* @__PURE__ */ s(
2913
- Et,
3078
+ /* @__PURE__ */ a("div", { className: "agent-view__split-column", children: Sn.map((h) => /* @__PURE__ */ a(
3079
+ Ht,
2914
3080
  {
2915
- column: Ve[p],
2916
- agents: Me[p] ?? [],
3081
+ column: et[h],
3082
+ agents: Ke[h] ?? [],
2917
3083
  isSplit: !0,
2918
- ...ie
3084
+ ...de
2919
3085
  },
2920
- p
3086
+ h
2921
3087
  )) })
2922
3088
  ] }),
2923
- w && /* @__PURE__ */ s(
2924
- Cs,
3089
+ O && /* @__PURE__ */ a(
3090
+ Ya,
2925
3091
  {
2926
- agent: w,
2927
- invocationId: w.invocation_id,
3092
+ agent: O,
3093
+ invocationId: O.invocation_id,
2928
3094
  open: !0,
2929
- jwt: t,
2930
- headers: D,
3095
+ jwt: e,
3096
+ headers: b,
2931
3097
  agentUrl: r,
2932
3098
  agentChecklistUrl: o,
2933
3099
  agentResourcesUrl: i,
2934
- agentTimelineUrl: d,
3100
+ agentTimelineUrl: u,
2935
3101
  agentChatUrl: c,
2936
- agentConversationUrl: v,
2937
- enableUpload: f,
2938
- initialChecklist: z[w.invocation_id] ?? null,
2939
- onClose: Re
3102
+ agentConversationUrl: g,
3103
+ stopAgentUrl: _,
3104
+ enableUpload: N,
3105
+ initialChecklist: j[O.invocation_id] ?? null,
3106
+ usePusherToRepoll: L,
3107
+ pusherChannelPrefix: f,
3108
+ subscribeToPusher: K,
3109
+ onClose: Pe
2940
3110
  },
2941
- w.id
3111
+ O.id
2942
3112
  ),
2943
- /* @__PURE__ */ s(
2944
- Os,
3113
+ /* @__PURE__ */ a(
3114
+ ts,
2945
3115
  {
2946
- open: U,
2947
- onClose: () => H(!1),
2948
- onStart: tt,
2949
- agentDefinitions: k
3116
+ open: Z,
3117
+ onClose: () => D(!1),
3118
+ onStart: rt,
3119
+ agentDefinitions: R
2950
3120
  }
2951
3121
  )
2952
3122
  ] });
2953
- }, Gs = (t, e) => {
2954
- const n = Date.now(), a = e.trim() || t.agent_intent;
3123
+ }, us = (e, t) => {
3124
+ const n = Date.now(), s = t.trim() || e.agent_intent;
2955
3125
  return {
2956
3126
  id: `agent-${n}`,
2957
3127
  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"],
3128
+ agent_definition_ref: e.ref,
3129
+ agent_intent: e.agent_intent,
3130
+ invocation_name: s,
3131
+ application_id: Cn,
3132
+ created_by: En,
3133
+ status: E["generating-a-response"],
2964
3134
  context_ref: null,
2965
3135
  checklist_ref: null
2966
3136
  };
2967
3137
  };
2968
3138
  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
3139
+ hs as AgentMonitorKanban,
3140
+ ft as AgentServiceClient,
3141
+ $e as AgentServiceError,
3142
+ Ya as AgentView,
3143
+ jt as DEFAULT_PUSHER_CHANNEL_PREFIX,
3144
+ za as HttpChatConnector,
3145
+ Ot as MESSAGE_TYPE_REPOLL,
3146
+ ts as NewAgentModal,
3147
+ Lt as PUSHER_AGENT_MESSAGE_EVENT,
3148
+ ve as REPOLL_TARGET,
3149
+ us as buildAgentFromDefinition,
3150
+ da as buildAgentPusherChannel,
3151
+ Zt as createHttpChatConnectorFactory,
3152
+ Ra as formatUserFileChatCardText,
3153
+ Ut as mapApiAgent,
3154
+ Vt as mapApiAgentDefinition,
3155
+ wa as mapApiAgentStatus,
3156
+ Sa as mapApiAgentTimelineResponse,
3157
+ Xt as mapApiChecklistEndpointResponse,
3158
+ Yt as mapApiChecklistItem,
3159
+ Ea as mapApiChecklistResponse,
3160
+ ya as mapApiChecklistStatus,
3161
+ Ia as mapApiConversationMessages,
3162
+ nt as mapApiOpeningMessage,
3163
+ Aa as mapApiResource,
3164
+ ba as mapApiResourcesEndpointResponse,
3165
+ gs as mapApiTripOption,
3166
+ Ta as parseConversationContentCaption,
3167
+ ua as parseRepollMessages,
3168
+ Ba as useAgentService,
3169
+ Ja as useAgentWorkspace
2992
3170
  };