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