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