@arbor-education/agent-view-frontend 0.4.1 → 0.4.3

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