@arbor-education/agent-view-frontend 0.4.2 → 0.4.4

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