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

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
@@ -2,7 +2,7 @@ import { jsxs as i, jsx as n, Fragment as et } from "react/jsx-runtime";
2
2
  import { useMemo as U, useLayoutEffect as Ge, useState as m, useEffect as G, useCallback as T, useRef as Re } from "react";
3
3
  import H from "classnames";
4
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 qe, 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";
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
6
  const v = {
7
7
  "generating-a-response": "generating-a-response",
8
8
  hitl: "hitl",
@@ -100,7 +100,7 @@ const v = {
100
100
  ], lt = [
101
101
  v.complete,
102
102
  v.failed
103
- ], dt = "m4", gt = "1", ze = "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.", Ke = "Unable to load agents. Please try again.", oe = "Loading tasks…", Pe = "Loading agents…", ht = "Task", _t = "What recent actions have you taken?", mt = {
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
104
  [b.briefing]: "Briefing",
105
105
  [b.running]: "Working",
106
106
  [b.stopped]: "Stopped",
@@ -371,11 +371,14 @@ class Ct {
371
371
  return null;
372
372
  (a = this.onAwaitingChange) == null || a.call(this, !0);
373
373
  try {
374
- const r = await this.connector.sendMessage(t.userMessage);
374
+ const r = await this.connector.sendMessage(
375
+ t.userMessage,
376
+ t.uploadFiles
377
+ );
375
378
  return this.onTurn(r), {
376
379
  id: r.message.id,
377
380
  text: r.message.text,
378
- type: qe,
381
+ type: ze,
379
382
  ...r.message.followUpPrompts ? { followUpPrompts: r.message.followUpPrompts } : {}
380
383
  };
381
384
  } catch {
@@ -406,9 +409,9 @@ const Tt = ({
406
409
  chatHistory: a,
407
410
  chatSessionKey: s,
408
411
  startQuery: r,
409
- clarificationMessage: d,
410
- enableUpload: g = !1,
411
- onTurn: l,
412
+ clarificationMessage: c,
413
+ enableUpload: l = !1,
414
+ onTurn: d,
412
415
  onAwaitingChange: w,
413
416
  onClarificationPrompt: f,
414
417
  onDismissClarification: p
@@ -416,24 +419,24 @@ const Tt = ({
416
419
  const _ = U(
417
420
  () => new Ct(e, {
418
421
  canSend: () => t === b.running,
419
- onTurn: l,
422
+ onTurn: d,
420
423
  onAwaitingChange: w
421
424
  }),
422
- [e, t, l, w]
425
+ [e, t, d, w]
423
426
  ), u = t !== b.running, C = t === b.running;
424
427
  return /* @__PURE__ */ i("section", { className: "agent-workspace__panel agent-workspace__panel--chat", "aria-label": "Chat", children: [
425
- d && /* @__PURE__ */ i(
428
+ c && /* @__PURE__ */ i(
426
429
  "div",
427
430
  {
428
431
  className: "agent-workspace__clarification",
429
432
  role: "region",
430
433
  "aria-label": "Agent question",
431
434
  children: [
432
- /* @__PURE__ */ n("p", { className: "agent-workspace__clarification-text", children: d.text }),
433
- d.followUpPrompts && /* @__PURE__ */ n(
435
+ /* @__PURE__ */ n("p", { className: "agent-workspace__clarification-text", children: c.text }),
436
+ c.followUpPrompts && /* @__PURE__ */ n(
434
437
  bt,
435
438
  {
436
- prompts: d.followUpPrompts,
439
+ prompts: c.followUpPrompts,
437
440
  onSelect: f
438
441
  }
439
442
  ),
@@ -456,7 +459,7 @@ const Tt = ({
456
459
  chatHistory: a,
457
460
  startQuery: r,
458
461
  lockConversation: u,
459
- enableUpload: g,
462
+ enableUpload: l,
460
463
  speechEnabled: C,
461
464
  speechLanguage: "en-GB",
462
465
  speechSubmissionDelay: 1e3,
@@ -483,7 +486,7 @@ const Tt = ({
483
486
  canRequestInput: a,
484
487
  onAttentionItemClick: s
485
488
  }) => {
486
- const r = F[e.status], d = e.status.replace(/_/g, "-"), g = e.status === S.hitl && a && s, l = /* @__PURE__ */ i("div", { className: "agent-workspace__task-row", children: [
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: [
487
490
  /* @__PURE__ */ n(
488
491
  E,
489
492
  {
@@ -504,20 +507,20 @@ const Tt = ({
504
507
  return /* @__PURE__ */ i(
505
508
  "li",
506
509
  {
507
- className: H("agent-workspace__task", `agent-workspace__task--${d}`, {
510
+ className: H("agent-workspace__task", `agent-workspace__task--${c}`, {
508
511
  "agent-workspace__task--child": t > 0
509
512
  }),
510
513
  children: [
511
- g ? /* @__PURE__ */ n(
514
+ l ? /* @__PURE__ */ n(
512
515
  "button",
513
516
  {
514
517
  type: "button",
515
518
  className: "agent-workspace__task-button",
516
519
  "aria-label": `Provide input for ${e.task}`,
517
520
  onClick: () => s(e),
518
- children: l
521
+ children: d
519
522
  }
520
- ) : l,
523
+ ) : d,
521
524
  e.children && e.children.length > 0 && /* @__PURE__ */ n("ul", { className: "agent-workspace__task-children", children: e.children.map((w) => /* @__PURE__ */ n(
522
525
  Je,
523
526
  {
@@ -551,10 +554,10 @@ const Tt = ({
551
554
  error: a,
552
555
  phase: s,
553
556
  canRequestInput: r,
554
- onStop: d,
555
- onAttentionItemClick: g
557
+ onStop: c,
558
+ onAttentionItemClick: l
556
559
  }) => {
557
- const l = U(
560
+ const d = U(
558
561
  () => e ? We(e) : null,
559
562
  [e]
560
563
  );
@@ -573,7 +576,7 @@ const Tt = ({
573
576
  size: "S",
574
577
  iconLeftName: "circle-x",
575
578
  iconLeftScreenReaderText: "Stop",
576
- onClick: d,
579
+ onClick: c,
577
580
  children: "Stop agent"
578
581
  }
579
582
  )
@@ -593,41 +596,41 @@ const Tt = ({
593
596
  /* @__PURE__ */ n("span", { children: oe })
594
597
  ] }),
595
598
  !t && a && /* @__PURE__ */ n("p", { className: "agent-workspace__error", role: "alert", children: a }),
596
- !t && !a && l && /* @__PURE__ */ i(et, { children: [
597
- l.needsInput.length > 0 && /* @__PURE__ */ i("div", { className: "agent-workspace__task-group", children: [
599
+ !t && !a && d && /* @__PURE__ */ i(et, { children: [
600
+ d.needsInput.length > 0 && /* @__PURE__ */ i("div", { className: "agent-workspace__task-group", children: [
598
601
  /* @__PURE__ */ n("p", { className: "agent-workspace__task-group-label", children: "Needs your input" }),
599
602
  /* @__PURE__ */ n(
600
603
  Le,
601
604
  {
602
- items: l.needsInput,
605
+ items: d.needsInput,
603
606
  ariaLabel: "Tasks needing your input",
604
607
  canRequestInput: r,
605
- onAttentionItemClick: g
608
+ onAttentionItemClick: l
606
609
  }
607
610
  )
608
611
  ] }),
609
- l.tasks.length > 0 && /* @__PURE__ */ i(
612
+ d.tasks.length > 0 && /* @__PURE__ */ i(
610
613
  "div",
611
614
  {
612
615
  className: H("agent-workspace__task-group", {
613
- "agent-workspace__task-group--following": l.needsInput.length > 0
616
+ "agent-workspace__task-group--following": d.needsInput.length > 0
614
617
  }),
615
618
  children: [
616
- l.needsInput.length > 0 && /* @__PURE__ */ n("p", { className: "agent-workspace__task-group-label", children: "Other tasks" }),
619
+ d.needsInput.length > 0 && /* @__PURE__ */ n("p", { className: "agent-workspace__task-group-label", children: "Other tasks" }),
617
620
  /* @__PURE__ */ n(
618
621
  Le,
619
622
  {
620
- items: l.tasks,
623
+ items: d.tasks,
621
624
  ariaLabel: "Agent tasks",
622
625
  canRequestInput: r,
623
- onAttentionItemClick: g
626
+ onAttentionItemClick: l
624
627
  }
625
628
  )
626
629
  ]
627
630
  }
628
631
  )
629
632
  ] }),
630
- !t && !a && (!l || l.needsInput.length === 0 && l.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." })
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." })
631
634
  ] })
632
635
  ]
633
636
  }
@@ -753,7 +756,7 @@ const Tt = ({
753
756
  }, pe = (e) => ({
754
757
  id: e.id,
755
758
  text: e.text,
756
- type: e.author === j.user ? ot : e.author === j.system ? it : qe,
759
+ type: e.author === j.user ? ot : e.author === j.system ? it : ze,
757
760
  ...e.followUpPrompts ? { followUpPrompts: e.followUpPrompts } : {}
758
761
  });
759
762
  class ue extends Error {
@@ -835,11 +838,11 @@ class je {
835
838
  );
836
839
  }
837
840
  createAgent(t, a = {}) {
838
- var g, l;
841
+ var l, d;
839
842
  const s = {
840
843
  agent_definition_ref: t
841
- }, r = (g = a.invocationName) == null ? void 0 : g.trim(), d = (l = a.agentIntent) == null ? void 0 : l.trim();
842
- return r && (s.invocation_name = r), d && (s.agent_intent = d), this.request(
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(
843
846
  x.POST,
844
847
  this.resolveUrl("agents", O.agents),
845
848
  s
@@ -902,7 +905,7 @@ class je {
902
905
  // Streams a chat turn. Resolves with the final SSE event; `onEvent` fires
903
906
  // for every event as it arrives.
904
907
  async chat(t, a, s = {}) {
905
- const r = await this.fetchImpl(
908
+ const r = !!(s.uploadFiles && s.uploadFiles.length > 0), c = await this.fetchImpl(
906
909
  this.resolveUrl(
907
910
  "agentChat",
908
911
  `${O.agents}/${encodeURIComponent(t)}/chat`,
@@ -914,21 +917,22 @@ class je {
914
917
  ...this.customHeaders,
915
918
  ...this.authHeaders(),
916
919
  Accept: ie.acceptEventStream,
917
- "Content-Type": ie.contentTypeJson
920
+ // Let the browser set the multipart boundary when uploading.
921
+ ...r ? {} : { "Content-Type": ie.contentTypeJson }
918
922
  },
919
- body: JSON.stringify(a),
923
+ body: r ? Ft(a, s.uploadFiles ?? []) : JSON.stringify(a),
920
924
  signal: s.signal
921
925
  }
922
926
  );
923
- if (!r.ok)
924
- throw await this.toError(r);
925
- if (!r.body)
927
+ if (!c.ok)
928
+ throw await this.toError(c);
929
+ if (!c.body)
926
930
  throw new ue(
927
- r.status,
931
+ c.status,
928
932
  null,
929
933
  "Chat response contained no stream body"
930
934
  );
931
- return this.consumeSse(r.body, s.onEvent);
935
+ return this.consumeSse(c.body, s.onEvent);
932
936
  }
933
937
  authHeaders() {
934
938
  return this.token ? { Authorization: `Bearer ${this.token}` } : {};
@@ -979,8 +983,8 @@ class je {
979
983
  }
980
984
  async consumeSse(t, a) {
981
985
  const s = t.getReader(), r = new TextDecoder();
982
- let d = "", g;
983
- const l = (w) => {
986
+ let c = "", l;
987
+ const d = (w) => {
984
988
  const { event: f, data: p } = Ht(w);
985
989
  if (p === null)
986
990
  return;
@@ -993,27 +997,27 @@ class je {
993
997
  );
994
998
  }
995
999
  const _ = Ue(p);
996
- _ && (g = _, a == null || a(_));
1000
+ _ && (l = _, a == null || a(_));
997
1001
  };
998
1002
  for (; ; ) {
999
1003
  const { done: w, value: f } = await s.read();
1000
1004
  if (w)
1001
1005
  break;
1002
- d += r.decode(f, { stream: !0 });
1003
- const p = d.split(`
1006
+ c += r.decode(f, { stream: !0 });
1007
+ const p = c.split(`
1004
1008
 
1005
1009
  `);
1006
- d = p.pop() ?? "";
1010
+ c = p.pop() ?? "";
1007
1011
  for (const _ of p)
1008
- l(_);
1012
+ d(_);
1009
1013
  }
1010
- if (d.trim() && l(d), !g)
1014
+ if (c.trim() && d(c), !l)
1011
1015
  throw new ue(
1012
1016
  502,
1013
1017
  null,
1014
1018
  "Chat stream ended without any events"
1015
1019
  );
1016
- return g;
1020
+ return l;
1017
1021
  }
1018
1022
  }
1019
1023
  const Ht = (e) => {
@@ -1035,19 +1039,27 @@ const Ht = (e) => {
1035
1039
  } catch {
1036
1040
  return;
1037
1041
  }
1038
- }, Ft = {
1039
- id: ze,
1042
+ };
1043
+ function Ft(e, t) {
1044
+ const a = new FormData();
1045
+ a.append("body", JSON.stringify(e));
1046
+ for (const s of t)
1047
+ a.append("files", s, s.name);
1048
+ return a;
1049
+ }
1050
+ const Gt = {
1051
+ id: Ke,
1040
1052
  author: j.agent,
1041
1053
  text: "I'm connected to this agent. Ask me how it's progressing, or send an instruction and I’ll act on it."
1042
1054
  };
1043
1055
  let $e = 0;
1044
- const Me = (e) => ($e += 1, `${e}-${Date.now()}-${$e}`), Gt = (e) => {
1056
+ const Me = (e) => ($e += 1, `${e}-${Date.now()}-${$e}`), Bt = (e) => {
1045
1057
  const t = e.destination ? ` to ${e.destination}` : "";
1046
1058
  return `Let's get started on ${e.tripName.trim() || e.destination.trim() || "this task"}${t}. What will you do first?`;
1047
1059
  };
1048
- class Bt {
1060
+ class zt {
1049
1061
  constructor(t, a, s = {}) {
1050
- this.seededChecklist = [], this.client = t, this.agentId = a, this.opening = s.openingMessage ?? Ft, this.model = s.model, this.bootstrapPrompt = s.bootstrapPrompt ?? _t;
1062
+ this.seededChecklist = [], this.client = t, this.agentId = a, this.opening = s.openingMessage ?? Gt, this.model = s.model, this.bootstrapPrompt = s.bootstrapPrompt ?? _t;
1051
1063
  }
1052
1064
  openingMessage() {
1053
1065
  return this.opening;
@@ -1064,46 +1076,50 @@ class Bt {
1064
1076
  return [s, r.message];
1065
1077
  }
1066
1078
  async start(t) {
1067
- return { ...await this.exchange(Gt(t)), phase: b.running };
1079
+ return { ...await this.exchange(Bt(t)), phase: b.running };
1068
1080
  }
1069
- sendMessage(t) {
1070
- return this.exchange(t);
1081
+ sendMessage(t, a) {
1082
+ return this.exchange(t, a);
1071
1083
  }
1072
1084
  async stop() {
1073
1085
  }
1074
1086
  seedChecklist(t) {
1075
1087
  this.seededChecklist = t;
1076
1088
  }
1077
- async exchange(t) {
1078
- var d;
1079
- const a = [
1089
+ async exchange(t, a) {
1090
+ var l;
1091
+ const s = [
1080
1092
  { role: Ut.user, content: t }
1081
- ], s = await this.client.chat(this.agentId, {
1082
- messages: a,
1083
- ...this.chatId ? { chat_id: this.chatId } : {},
1084
- ...this.model ? { model: this.model } : {},
1085
- moderation_enabled: !0,
1086
- meta: {
1087
- feature_id: "agent_view",
1088
- source: "agent_view_frontend"
1089
- }
1090
- });
1091
- return this.chatId = s.chat_id, { message: {
1092
- id: s.event_id || Me("msg-agent"),
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"),
1093
1109
  author: j.agent,
1094
- text: s.message.content,
1095
- ...(d = s.follow_up_prompts) != null && d.length ? { followUpPrompts: s.follow_up_prompts } : {}
1110
+ text: r.message.content,
1111
+ ...(l = r.follow_up_prompts) != null && l.length ? { followUpPrompts: r.follow_up_prompts } : {}
1096
1112
  } };
1097
1113
  }
1098
1114
  }
1099
1115
  const Ve = (e, t) => (a) => {
1100
1116
  var s;
1101
- return new Bt(e, a.invocation_id, {
1117
+ return new zt(e, a.invocation_id, {
1102
1118
  model: t == null ? void 0 : t.model,
1103
1119
  bootstrapPrompt: t == null ? void 0 : t.bootstrapPrompt,
1104
1120
  openingMessage: ((s = t == null ? void 0 : t.resolveOpeningMessage) == null ? void 0 : s.call(t, a)) ?? (t == null ? void 0 : t.openingMessage)
1105
1121
  });
1106
- }, qt = (e) => {
1122
+ }, Kt = (e) => {
1107
1123
  switch (e) {
1108
1124
  case xe.cancelled:
1109
1125
  return v.failed;
@@ -1117,7 +1133,7 @@ const Ve = (e, t) => (a) => {
1117
1133
  default:
1118
1134
  return v["generating-a-response"];
1119
1135
  }
1120
- }, zt = (e) => {
1136
+ }, qt = (e) => {
1121
1137
  switch (e) {
1122
1138
  case Te.requires_attention:
1123
1139
  return S.hitl;
@@ -1132,21 +1148,21 @@ const Ve = (e, t) => (a) => {
1132
1148
  default:
1133
1149
  return S["generating-a-response"];
1134
1150
  }
1135
- }, Kt = (e) => ({
1151
+ }, Wt = (e) => ({
1136
1152
  ref: e.name,
1137
1153
  display_name: e.display_name,
1138
1154
  agent_intent: e.agent_intent ?? e.display_name,
1139
1155
  description: e.description
1140
- }), mn = (e) => ({
1156
+ }), fn = (e) => ({
1141
1157
  id: e.id,
1142
1158
  name: e.name,
1143
1159
  ...e.has_run_before ? { hasRunBefore: e.has_run_before } : {}
1144
- }), Wt = new Set(Object.values(re)), Jt = (e) => e && Wt.has(e) ? e : re.LINK, jt = (e) => ({
1160
+ }), Jt = new Set(Object.values(re)), jt = (e) => e && Jt.has(e) ? e : re.LINK, Vt = (e) => ({
1145
1161
  uri: e.uri ?? "",
1146
- type: Jt(e.type),
1162
+ type: jt(e.type),
1147
1163
  name: e.name ?? "",
1148
1164
  description: e.description ?? ""
1149
- }), Ye = (e) => (Array.isArray(e) ? e : e.resources ?? []).map(jt), De = (e) => {
1165
+ }), Ye = (e) => (Array.isArray(e) ? e : e.resources ?? []).map(Vt), De = (e) => {
1150
1166
  var a;
1151
1167
  const t = e.invocation_id ?? e.id;
1152
1168
  return {
@@ -1158,7 +1174,7 @@ const Ve = (e, t) => (a) => {
1158
1174
  application_id: e.application_id,
1159
1175
  ...e.application_name ? { application_name: e.application_name } : {},
1160
1176
  created_by: e.created_by,
1161
- status: qt(e.status),
1177
+ status: Kt(e.status),
1162
1178
  context_ref: e.context_ref ?? null,
1163
1179
  checklist_ref: e.checklist_ref ?? null
1164
1180
  };
@@ -1166,20 +1182,20 @@ const Ve = (e, t) => (a) => {
1166
1182
  var t;
1167
1183
  return {
1168
1184
  task: e.task ?? e.name ?? e.label ?? ht,
1169
- status: zt(e.status),
1185
+ status: qt(e.status),
1170
1186
  description: e.description ?? "",
1171
1187
  ...e.prompt ? { prompt: e.prompt } : {},
1172
1188
  ...(t = e.follow_up_prompts) != null && t.length ? { clarificationPrompts: e.follow_up_prompts } : {}
1173
1189
  };
1174
- }, Vt = (e) => Array.isArray(e) ? e : e.checklist_items ?? e.checklist ?? e.items ?? [], Xe = (e, t, a) => {
1175
- var d;
1176
- const s = !Array.isArray(t) && (t.opening_message || (d = t.opening_follow_up_prompts) != null && d.length) ? t : a, r = s ? we(s) : void 0;
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;
1177
1193
  return {
1178
1194
  invocation_id: e,
1179
- checklist: Vt(t).map(Qe),
1195
+ checklist: Yt(t).map(Qe),
1180
1196
  ...r ? { openingMessage: r } : {}
1181
1197
  };
1182
- }, fn = (e, t) => {
1198
+ }, vn = (e, t) => {
1183
1199
  const a = we(t);
1184
1200
  return {
1185
1201
  invocation_id: t.invocation_id ?? e,
@@ -1191,12 +1207,12 @@ const Ve = (e, t) => (a) => {
1191
1207
  const t = (a = e.opening_message) == null ? void 0 : a.trim();
1192
1208
  if (t)
1193
1209
  return {
1194
- id: ze,
1210
+ id: Ke,
1195
1211
  author: j.agent,
1196
1212
  text: t,
1197
1213
  ...(s = e.opening_follow_up_prompts) != null && s.length ? { followUpPrompts: e.opening_follow_up_prompts } : {}
1198
1214
  };
1199
- }, Yt = (e) => e instanceof ue ? e.message : e instanceof TypeError ? "Network error while contacting the agent service." : e instanceof Error && e.message ? e.message : Ke, Qt = (e) => {
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) => {
1200
1216
  const t = {};
1201
1217
  for (const a of e) {
1202
1218
  const s = we(a);
@@ -1206,20 +1222,20 @@ const Ve = (e, t) => (a) => {
1206
1222
  t[r] = s, t[a.id] = s;
1207
1223
  }
1208
1224
  return t;
1209
- }, Xt = (e) => JSON.stringify(e), Zt = (e) => {
1210
- const { jwt: t, headers: a, urls: s } = e, r = JSON.stringify(a ?? {}), d = Xt(s), g = U(
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(
1211
1227
  () => new je({
1212
1228
  token: t,
1213
1229
  headers: a,
1214
1230
  urls: s
1215
1231
  }),
1216
1232
  // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
1217
- [t, d]
1233
+ [t, c]
1218
1234
  );
1219
1235
  Ge(() => {
1220
- g.setHeaders(a);
1221
- }, [g, r]);
1222
- const [l, w] = m([]), [f, p] = m(
1236
+ l.setHeaders(a);
1237
+ }, [l, r]);
1238
+ const [d, w] = m([]), [f, p] = m(
1223
1239
  []
1224
1240
  ), [_, u] = m({}), [C, R] = m("loading"), [y, A] = m(null), [k, $] = m(0);
1225
1241
  G(() => {
@@ -1227,28 +1243,28 @@ const Ve = (e, t) => (a) => {
1227
1243
  return R("loading"), A(null), (async () => {
1228
1244
  try {
1229
1245
  const [I, D] = await Promise.all([
1230
- g.listAgents(),
1231
- g.listAgentDefinitions()
1246
+ l.listAgents(),
1247
+ l.listAgentDefinitions()
1232
1248
  ]);
1233
1249
  if (N)
1234
1250
  return;
1235
- w(I.map(De)), p(D.map(Kt)), u(Qt(I)), R("idle");
1251
+ w(I.map(De)), p(D.map(Wt)), u(Xt(I)), R("idle");
1236
1252
  } catch (I) {
1237
1253
  if (N)
1238
1254
  return;
1239
- w([]), p([]), u({}), R("error"), A(Yt(I));
1255
+ w([]), p([]), u({}), R("error"), A(Qt(I));
1240
1256
  }
1241
1257
  })(), () => {
1242
1258
  N = !0;
1243
1259
  };
1244
- }, [g, k]);
1260
+ }, [l, k]);
1245
1261
  const V = T(() => {
1246
1262
  $((N) => N + 1);
1247
1263
  }, []), M = T(
1248
1264
  async (N) => {
1249
1265
  const [I, D] = await Promise.all([
1250
- g.getAgentChecklist(N),
1251
- g.getAgent(N).catch(() => null)
1266
+ l.getAgentChecklist(N),
1267
+ l.getAgent(N).catch(() => null)
1252
1268
  ]);
1253
1269
  return Xe(
1254
1270
  N,
@@ -1256,36 +1272,36 @@ const Ve = (e, t) => (a) => {
1256
1272
  D ?? void 0
1257
1273
  );
1258
1274
  },
1259
- [g]
1275
+ [l]
1260
1276
  ), ee = T(
1261
1277
  async (N) => {
1262
- const I = await g.getAgentResources(N);
1278
+ const I = await l.getAgentResources(N);
1263
1279
  return Ye(I);
1264
1280
  },
1265
- [g]
1281
+ [l]
1266
1282
  ), te = T(
1267
1283
  async ({
1268
1284
  definition: N,
1269
1285
  invocationName: I
1270
1286
  }) => {
1271
- const D = await g.createAgent(N.ref, {
1287
+ const D = await l.createAgent(N.ref, {
1272
1288
  invocationName: I
1273
- }), Q = await g.getAgent(D.id), P = De(Q), B = we(Q);
1274
- return w((q) => [P, ...q]), B && u((q) => ({
1275
- ...q,
1289
+ }), Q = await l.getAgent(D.id), P = De(Q), B = we(Q);
1290
+ return w((z) => [P, ...z]), B && u((z) => ({
1291
+ ...z,
1276
1292
  [P.invocation_id]: B,
1277
1293
  [P.id]: B
1278
1294
  })), P;
1279
1295
  },
1280
- [g]
1296
+ [l]
1281
1297
  ), Y = U(
1282
- () => Ve(g, {
1298
+ () => Ve(l, {
1283
1299
  resolveOpeningMessage: (N) => _[N.invocation_id] ?? _[N.id]
1284
1300
  }),
1285
- [g, _]
1301
+ [l, _]
1286
1302
  );
1287
1303
  return {
1288
- agents: l,
1304
+ agents: d,
1289
1305
  agentDefinitions: f,
1290
1306
  loadState: C,
1291
1307
  loadError: y,
@@ -1295,29 +1311,29 @@ const Ve = (e, t) => (a) => {
1295
1311
  createAgent: te,
1296
1312
  chatConnector: Y
1297
1313
  };
1298
- }, en = (e) => JSON.stringify(e), tn = (e) => {
1299
- const { agent: t, jwt: a, headers: s, urls: r } = e, d = JSON.stringify(s ?? {}), g = en(r), l = U(
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(
1300
1316
  () => new je({
1301
1317
  token: a,
1302
1318
  headers: s,
1303
1319
  urls: {
1304
1320
  agent: r.agentUrl,
1305
1321
  agentChecklist: r.agentChecklistUrl,
1306
- agentResources: r.agentResourcesUrl,
1322
+ ...r.agentResourcesUrl ? { agentResources: r.agentResourcesUrl } : {},
1307
1323
  agentChat: r.agentChatUrl
1308
1324
  }
1309
1325
  }),
1310
1326
  // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on serialised config to keep a stable client.
1311
- [a, g]
1327
+ [a, l]
1312
1328
  );
1313
1329
  Ge(() => {
1314
- l.setHeaders(s);
1315
- }, [l, d]);
1330
+ d.setHeaders(s);
1331
+ }, [d, c]);
1316
1332
  const w = T(
1317
1333
  async (_) => {
1318
1334
  const [u, C] = await Promise.all([
1319
- l.getAgentChecklist(_),
1320
- l.getAgent(_).catch(() => null)
1335
+ d.getAgentChecklist(_),
1336
+ d.getAgent(_).catch(() => null)
1321
1337
  ]);
1322
1338
  return Xe(
1323
1339
  _,
@@ -1325,26 +1341,26 @@ const Ve = (e, t) => (a) => {
1325
1341
  C ?? void 0
1326
1342
  );
1327
1343
  },
1328
- [l]
1344
+ [d]
1329
1345
  ), f = T(
1330
1346
  async (_) => {
1331
- const u = await l.getAgentResources(_);
1347
+ const u = await d.getAgentResources(_);
1332
1348
  return Ye(u);
1333
1349
  },
1334
- [l]
1350
+ [d]
1335
1351
  );
1336
1352
  return {
1337
1353
  connector: U(
1338
- () => Ve(l)(t),
1339
- [l, t]
1354
+ () => Ve(d)(t),
1355
+ [d, t]
1340
1356
  ),
1341
1357
  fetchAgentChecklist: w,
1342
1358
  fetchAgentResources: f
1343
1359
  };
1344
- }, nn = (e, t) => {
1360
+ }, an = (e, t) => {
1345
1361
  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." : "";
1346
1362
  return `${a}${s}.${r}`.trim();
1347
- }, an = (e) => {
1363
+ }, sn = (e) => {
1348
1364
  switch (e) {
1349
1365
  case v.failed:
1350
1366
  return b.stopped;
@@ -1355,42 +1371,42 @@ const Ve = (e, t) => (a) => {
1355
1371
  }
1356
1372
  }, He = (e, t) => {
1357
1373
  t([pe(e)]);
1358
- }, sn = ({
1374
+ }, rn = ({
1359
1375
  agent: e,
1360
1376
  open: t,
1361
1377
  onClose: a,
1362
1378
  jwt: s,
1363
1379
  headers: r,
1364
- agentUrl: d,
1365
- agentChecklistUrl: g,
1366
- agentResourcesUrl: l,
1380
+ agentUrl: c,
1381
+ agentChecklistUrl: l,
1382
+ agentResourcesUrl: d,
1367
1383
  agentChatUrl: w,
1368
1384
  enableUpload: f,
1369
1385
  initialBrief: p,
1370
1386
  initialPhase: _,
1371
1387
  initialChecklist: u
1372
1388
  }) => {
1373
- const { connector: C, fetchAgentChecklist: R, fetchAgentResources: y } = tn({
1389
+ const { connector: C, fetchAgentChecklist: R, fetchAgentResources: y } = nn({
1374
1390
  agent: e,
1375
1391
  jwt: s,
1376
1392
  headers: r,
1377
1393
  urls: {
1378
- agentUrl: d,
1379
- agentChecklistUrl: g,
1380
- agentResourcesUrl: l,
1394
+ agentUrl: c,
1395
+ agentChecklistUrl: l,
1396
+ agentResourcesUrl: d,
1381
1397
  agentChatUrl: w
1382
1398
  }
1383
1399
  }), A = Re(C), [k, $] = m(
1384
- _ ?? (p ? b.running : an(e.status))
1385
- ), [V, M] = m([]), [ee, te] = m(0), [Y, N] = m(), [I, D] = m(null), [Q, P] = m([]), [B, q] = m(!1), [ce, X] = m(null), [ke, z] = 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(
1386
1402
  u ?? null
1387
- ), [ye, le] = m(!1), [Z, de] = m(null), [_e, ne] = m(!1), [ae, Ne] = m(!1), [se, Ae] = m(!1), K = Re(!1);
1403
+ ), [ye, le] = m(!1), [Z, de] = m(null), [_e, ne] = m(!1), [ae, Ne] = m(!1), [se, Ae] = m(!1), q = Re(!1);
1388
1404
  G(() => {
1389
1405
  A.current = C;
1390
1406
  }, [C]), G(() => {
1391
- K.current = !1, M([]), te((o) => o + 1);
1407
+ q.current = !1, M([]), te((o) => o + 1);
1392
1408
  }, [e.invocation_id]), G(() => {
1393
- if (!t || p || K.current)
1409
+ if (!t || p || q.current)
1394
1410
  return;
1395
1411
  const o = A.current.bootstrapConversation;
1396
1412
  if (!o) {
@@ -1400,43 +1416,43 @@ const Ve = (e, t) => (a) => {
1400
1416
  );
1401
1417
  return;
1402
1418
  }
1403
- K.current = !0;
1404
- let c = !1;
1419
+ q.current = !0;
1420
+ let g = !1;
1405
1421
  return ne(!0), (async () => {
1406
1422
  try {
1407
1423
  const h = await o.call(A.current);
1408
- if (c)
1424
+ if (g)
1409
1425
  return;
1410
1426
  M(h.map(pe));
1411
1427
  } catch {
1412
- c || He(
1428
+ g || He(
1413
1429
  A.current.openingMessage(),
1414
1430
  M
1415
1431
  );
1416
1432
  } finally {
1417
- c || ne(!1);
1433
+ g || ne(!1);
1418
1434
  }
1419
1435
  })(), () => {
1420
- c = !0;
1436
+ g = !0;
1421
1437
  };
1422
1438
  }, [t, p, e.invocation_id, C]);
1423
1439
  const Se = T((o) => {
1424
- o.checklist && z(o.checklist), o.phase && $(o.phase);
1440
+ o.checklist && K(o.checklist), o.phase && $(o.phase);
1425
1441
  }, []);
1426
1442
  G(() => {
1427
- var o, c;
1428
- !t || p || u && u.length > 0 && ((c = (o = A.current).seedChecklist) == null || c.call(o, u));
1443
+ var o, g;
1444
+ !t || p || u && u.length > 0 && ((g = (o = A.current).seedChecklist) == null || g.call(o, u));
1429
1445
  }, [t, p, u]), G(() => {
1430
1446
  if (!t || p)
1431
1447
  return;
1432
1448
  let o = !1;
1433
1449
  return le(!(u != null && u.length)), de(null), (async () => {
1434
- var c, h;
1450
+ var g, h;
1435
1451
  try {
1436
1452
  const L = await R(e.invocation_id);
1437
1453
  if (o)
1438
1454
  return;
1439
- u != null && u.length || (z(L.checklist), (h = (c = A.current).seedChecklist) == null || h.call(c, L.checklist));
1455
+ u != null && u.length || (K(L.checklist), (h = (g = A.current).seedChecklist) == null || h.call(g, L.checklist));
1440
1456
  } catch {
1441
1457
  !o && !(u != null && u.length) && de(Ee);
1442
1458
  } finally {
@@ -1452,39 +1468,39 @@ const Ve = (e, t) => (a) => {
1452
1468
  u,
1453
1469
  R
1454
1470
  ]), G(() => {
1455
- if (!t)
1471
+ if (!t || !d)
1456
1472
  return;
1457
1473
  let o = !1;
1458
- return q(!0), X(null), (async () => {
1474
+ return z(!0), X(null), (async () => {
1459
1475
  try {
1460
- const c = await y(
1476
+ const g = await y(
1461
1477
  e.invocation_id
1462
1478
  );
1463
- o || P(c);
1479
+ o || P(g);
1464
1480
  } catch {
1465
1481
  o || X(pt);
1466
1482
  } finally {
1467
- o || q(!1);
1483
+ o || z(!1);
1468
1484
  }
1469
1485
  })(), () => {
1470
1486
  o = !0;
1471
1487
  };
1472
- }, [t, e.invocation_id, y]), G(() => {
1473
- if (!t || !p || K.current)
1488
+ }, [t, e.invocation_id, d, y]), G(() => {
1489
+ if (!t || !p || q.current)
1474
1490
  return;
1475
- K.current = !0;
1491
+ q.current = !0;
1476
1492
  const o = {
1477
1493
  id: `user-brief-${Date.now()}`,
1478
1494
  author: j.user,
1479
- text: nn(p, e.invocation_name)
1495
+ text: an(p, e.invocation_name)
1480
1496
  };
1481
1497
  (async () => {
1482
- const c = await A.current.start(p);
1498
+ const g = await A.current.start(p);
1483
1499
  M([
1484
1500
  pe(A.current.openingMessage()),
1485
1501
  pe(o),
1486
- pe(c.message)
1487
- ]), c.checklist && z(c.checklist), $(c.phase ?? b.running);
1502
+ pe(g.message)
1503
+ ]), g.checklist && K(g.checklist), $(g.phase ?? b.running);
1488
1504
  })();
1489
1505
  }, [t, p, e.invocation_name]);
1490
1506
  const be = T(
@@ -1493,7 +1509,7 @@ const Ve = (e, t) => (a) => {
1493
1509
  },
1494
1510
  []
1495
1511
  ), Ce = T((o) => {
1496
- D(null), N(o), te((c) => c + 1);
1512
+ D(null), N(o), te((g) => g + 1);
1497
1513
  }, []), me = T(async () => {
1498
1514
  await A.current.stop(), $(b.stopped);
1499
1515
  }, []), fe = ke;
@@ -1615,34 +1631,34 @@ const Ve = (e, t) => (a) => {
1615
1631
  ]
1616
1632
  }
1617
1633
  );
1618
- }, rn = ({
1634
+ }, on = ({
1619
1635
  open: e,
1620
1636
  onClose: t,
1621
1637
  onStart: a,
1622
1638
  agentDefinitions: s
1623
1639
  }) => {
1624
- const r = s[0], [d, g] = m(
1640
+ const r = s[0], [c, l] = m(
1625
1641
  r
1626
- ), [l, w] = m(""), [f, p] = m(!1), [_, u] = m(null), C = [...s].sort((k, $) => k.agent_intent.localeCompare($.agent_intent)).map((k) => ({
1642
+ ), [d, w] = m(""), [f, p] = m(!1), [_, u] = m(null), C = [...s].sort((k, $) => k.agent_intent.localeCompare($.agent_intent)).map((k) => ({
1627
1643
  value: k.ref,
1628
1644
  label: k.agent_intent
1629
1645
  }));
1630
1646
  G(() => {
1631
- e && (g(r), w(""), p(!1), u(null));
1647
+ e && (l(r), w(""), p(!1), u(null));
1632
1648
  }, [e, r]);
1633
- const R = d !== void 0 && l.trim().length > 0, y = T(
1649
+ const R = c !== void 0 && d.trim().length > 0, y = T(
1634
1650
  (k) => {
1635
1651
  const $ = s.find(
1636
1652
  (V) => V.ref === k[0]
1637
1653
  );
1638
- $ && g($);
1654
+ $ && l($);
1639
1655
  },
1640
1656
  [s]
1641
1657
  ), A = T(async () => {
1642
- if (!(!d || !R || f)) {
1658
+ if (!(!c || !R || f)) {
1643
1659
  p(!0), u(null);
1644
1660
  try {
1645
- await a({ definition: d, invocationName: l.trim() });
1661
+ await a({ definition: c, invocationName: d.trim() });
1646
1662
  } catch (k) {
1647
1663
  u(
1648
1664
  k instanceof Error ? k.message : "Unable to start the agent."
@@ -1651,8 +1667,8 @@ const Ve = (e, t) => (a) => {
1651
1667
  p(!1);
1652
1668
  }
1653
1669
  }
1654
- }, [R, d, l, f, a]);
1655
- return !d || s.length === 0 ? null : /* @__PURE__ */ i(
1670
+ }, [R, c, d, f, a]);
1671
+ return !c || s.length === 0 ? null : /* @__PURE__ */ i(
1656
1672
  W,
1657
1673
  {
1658
1674
  open: e,
@@ -1694,11 +1710,11 @@ const Ve = (e, t) => (a) => {
1694
1710
  id: "new-agent-type",
1695
1711
  placeholder: "Choose an intent",
1696
1712
  options: C,
1697
- selectedValues: [d.ref],
1713
+ selectedValues: [c.ref],
1698
1714
  onSelectionChange: y
1699
1715
  }
1700
1716
  ),
1701
- /* @__PURE__ */ n("p", { className: "new-agent__type-description", children: d.description })
1717
+ /* @__PURE__ */ n("p", { className: "new-agent__type-description", children: c.description })
1702
1718
  ] }),
1703
1719
  /* @__PURE__ */ i("div", { className: "new-agent__type-field", children: [
1704
1720
  /* @__PURE__ */ n(
@@ -1713,7 +1729,7 @@ const Ve = (e, t) => (a) => {
1713
1729
  nt,
1714
1730
  {
1715
1731
  id: "new-agent-invocation-name",
1716
- value: l,
1732
+ value: d,
1717
1733
  placeholder: "e.g. Test with memory3",
1718
1734
  onChange: (k) => w(k.target.value)
1719
1735
  }
@@ -1737,7 +1753,7 @@ const Ve = (e, t) => (a) => {
1737
1753
  ]
1738
1754
  }
1739
1755
  );
1740
- }, on = (e) => e !== void 0 && e.some((t) => t.status === S.hitl), cn = (e, t) => on(t) ? v.hitl : e.status, ln = ({ column: e, label: t }) => e.statusIcon ? /* @__PURE__ */ n("span", { className: "agent-view__status-indicator", children: /* @__PURE__ */ n(
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(
1741
1757
  E,
1742
1758
  {
1743
1759
  name: e.statusIcon.name,
@@ -1756,15 +1772,15 @@ const Ve = (e, t) => (a) => {
1756
1772
  }),
1757
1773
  children: /* @__PURE__ */ n(Be, { colour: e.dotColour, label: t })
1758
1774
  }
1759
- ), dn = ({
1775
+ ), gn = ({
1760
1776
  agent: e,
1761
1777
  agentName: t,
1762
1778
  column: a,
1763
1779
  isExpanded: s,
1764
1780
  isLoading: r,
1765
- checklist: d,
1766
- error: g,
1767
- onToggle: l,
1781
+ checklist: c,
1782
+ error: l,
1783
+ onToggle: d,
1768
1784
  onViewAgent: w
1769
1785
  }) => {
1770
1786
  const { id: f, invocation_name: p } = e, _ = `agent-card-${f}-header`, u = `agent-card-${f}-progress`;
@@ -1784,9 +1800,9 @@ const Ve = (e, t) => (a) => {
1784
1800
  "aria-controls": u,
1785
1801
  "aria-label": p,
1786
1802
  id: _,
1787
- onClick: () => l(f),
1803
+ onClick: () => d(f),
1788
1804
  children: /* @__PURE__ */ i("div", { className: "agent-view__card-content", children: [
1789
- /* @__PURE__ */ n(ln, { column: a }),
1805
+ /* @__PURE__ */ n(dn, { column: a }),
1790
1806
  /* @__PURE__ */ n("span", { className: "agent-view__card-invocation-name", children: p }),
1791
1807
  /* @__PURE__ */ n("span", { className: "agent-view__card-agent-name", children: t }),
1792
1808
  /* @__PURE__ */ n(
@@ -1820,9 +1836,9 @@ const Ve = (e, t) => (a) => {
1820
1836
  ),
1821
1837
  /* @__PURE__ */ n("span", { children: oe })
1822
1838
  ] }),
1823
- !r && g && /* @__PURE__ */ n("p", { className: "agent-view__progress-error", role: "alert", children: g }),
1824
- !r && !g && d !== null && /* @__PURE__ */ n(St, { checklist: d }),
1825
- !r && !g && d === null && /* @__PURE__ */ i("div", { className: "agent-view__progress-loading", "aria-live": "polite", children: [
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: [
1826
1842
  /* @__PURE__ */ n(
1827
1843
  E,
1828
1844
  {
@@ -1856,9 +1872,9 @@ const Ve = (e, t) => (a) => {
1856
1872
  expandedAgentId: a,
1857
1873
  loadingAgentId: s,
1858
1874
  checklistByInvocationId: r,
1859
- errorByAgentId: d,
1860
- definitionNameByRef: g,
1861
- onToggleAgent: l,
1875
+ errorByAgentId: c,
1876
+ definitionNameByRef: l,
1877
+ onToggleAgent: d,
1862
1878
  onViewAgent: w,
1863
1879
  isSplit: f = !1
1864
1880
  }) => /* @__PURE__ */ i(
@@ -1874,31 +1890,31 @@ const Ve = (e, t) => (a) => {
1874
1890
  /* @__PURE__ */ n("span", { className: "agent-view__column-count", children: t.length })
1875
1891
  ] }),
1876
1892
  /* @__PURE__ */ n("ul", { className: "agent-view__card-list", children: t.map((p) => /* @__PURE__ */ n(
1877
- dn,
1893
+ gn,
1878
1894
  {
1879
1895
  agent: p,
1880
- agentName: Ie(p, g),
1896
+ agentName: Ie(p, l),
1881
1897
  column: e,
1882
1898
  isExpanded: a === p.id,
1883
1899
  isLoading: s === p.id,
1884
1900
  checklist: r[p.invocation_id] ?? null,
1885
- error: d[p.id] ?? null,
1886
- onToggle: l,
1901
+ error: c[p.id] ?? null,
1902
+ onToggle: d,
1887
1903
  onViewAgent: w
1888
1904
  },
1889
1905
  p.id
1890
1906
  )) })
1891
1907
  ]
1892
1908
  }
1893
- ), Ie = (e, t) => t.get(e.agent_definition_ref) ?? e.agent_definition_ref.replace(/_/g, " "), vn = ({
1909
+ ), Ie = (e, t) => t.get(e.agent_definition_ref) ?? e.agent_definition_ref.replace(/_/g, " "), wn = ({
1894
1910
  jwt: e,
1895
1911
  headers: t,
1896
1912
  agentDefinitionsUrl: a,
1897
1913
  agentsUrl: s,
1898
1914
  agentUrl: r,
1899
- agentChecklistUrl: d,
1900
- agentResourcesUrl: g,
1901
- agentChatUrl: l,
1915
+ agentChecklistUrl: c,
1916
+ agentResourcesUrl: l,
1917
+ agentChatUrl: d,
1902
1918
  enableUpload: w,
1903
1919
  institutions: f
1904
1920
  }) => {
@@ -1908,17 +1924,17 @@ const Ve = (e, t) => (a) => {
1908
1924
  agentDefinitions: a,
1909
1925
  agents: s,
1910
1926
  agent: r,
1911
- agentChecklist: d,
1912
- agentResources: g,
1913
- agentChat: l
1927
+ agentChecklist: c,
1928
+ ...l ? { agentResources: l } : {},
1929
+ agentChat: d
1914
1930
  }),
1915
1931
  [
1916
1932
  a,
1917
1933
  s,
1918
1934
  r,
1919
- d,
1920
- g,
1921
- l
1935
+ c,
1936
+ l,
1937
+ d
1922
1938
  ]
1923
1939
  ), [_, u] = m(null), C = _ ? (fe = f == null ? void 0 : f.find(
1924
1940
  (o) => o.applicationId === _.application_id
@@ -1933,31 +1949,31 @@ const Ve = (e, t) => (a) => {
1933
1949
  reload: V,
1934
1950
  fetchAgentChecklist: M,
1935
1951
  createAgent: ee
1936
- } = Zt({ jwt: e, headers: R, urls: p }), [te, Y] = m(!1), [N, I] = m(null), [D, Q] = m(null), [P, B] = m({}), [q, ce] = m({}), [X, ke] = m([]), [z, ye] = m([]), le = U(() => {
1937
- const o = new Set(y.map((h) => h.application_id)), c = new Map(
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(
1938
1954
  (f ?? []).map((h) => [h.applicationId, h.name])
1939
1955
  );
1940
1956
  return [...o].sort(
1941
- (h, L) => (c.get(h) ?? h).localeCompare(c.get(L) ?? L)
1957
+ (h, L) => (g.get(h) ?? h).localeCompare(g.get(L) ?? L)
1942
1958
  ).map((h) => ({
1943
1959
  value: h,
1944
- label: c.get(h) ?? h
1960
+ label: g.get(h) ?? h
1945
1961
  }));
1946
1962
  }, [y, f]), Z = U(
1947
1963
  () => new Map(A.map((o) => [o.ref, o.display_name])),
1948
1964
  [A]
1949
1965
  ), de = U(() => [...new Set(
1950
- y.map((c) => Ie(c, Z))
1951
- )].sort((c, h) => c.localeCompare(h)).map((c) => ({
1952
- value: c,
1953
- label: c
1954
- })), [y, Z]), _e = U(() => y.filter((o) => !(X.length > 0 && !X.includes(o.application_id) || z.length > 0 && !z.includes(Ie(o, Z)))), [y, Z, z, X]), ne = le.length > 1, ae = de.length > 1, Ne = ne || ae;
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;
1955
1971
  G(() => {
1956
1972
  if (y.length === 0)
1957
1973
  return;
1958
1974
  let o = !1;
1959
1975
  return (async () => {
1960
- const c = await Promise.allSettled(
1976
+ const g = await Promise.allSettled(
1961
1977
  y.map(async (h) => {
1962
1978
  const L = await M(h.invocation_id);
1963
1979
  return {
@@ -1969,12 +1985,12 @@ const Ve = (e, t) => (a) => {
1969
1985
  );
1970
1986
  o || (B((h) => {
1971
1987
  const L = { ...h };
1972
- for (const ge of c)
1988
+ for (const ge of g)
1973
1989
  ge.status === "fulfilled" && (L[ge.value.invocationId] = ge.value.checklist);
1974
1990
  return L;
1975
1991
  }), ce((h) => {
1976
1992
  const L = { ...h };
1977
- return c.forEach((ge, Ze) => {
1993
+ return g.forEach((ge, Ze) => {
1978
1994
  ge.status === "rejected" && (L[y[Ze].id] = Ee);
1979
1995
  }), L;
1980
1996
  }));
@@ -1985,23 +2001,23 @@ const Ve = (e, t) => (a) => {
1985
2001
  const se = T(
1986
2002
  async (o) => {
1987
2003
  if (!P[o.invocation_id]) {
1988
- Q(o.id), ce((c) => {
1989
- const h = { ...c };
2004
+ Q(o.id), ce((g) => {
2005
+ const h = { ...g };
1990
2006
  return delete h[o.id], h;
1991
2007
  });
1992
2008
  try {
1993
- const c = await M(o.invocation_id);
2009
+ const g = await M(o.invocation_id);
1994
2010
  B((h) => ({
1995
2011
  ...h,
1996
- [o.invocation_id]: c.checklist
2012
+ [o.invocation_id]: g.checklist
1997
2013
  }));
1998
2014
  } catch {
1999
- ce((c) => ({
2000
- ...c,
2015
+ ce((g) => ({
2016
+ ...g,
2001
2017
  [o.id]: Ee
2002
2018
  }));
2003
2019
  } finally {
2004
- Q((c) => c === o.id ? null : c);
2020
+ Q((g) => g === o.id ? null : g);
2005
2021
  }
2006
2022
  }
2007
2023
  },
@@ -2012,26 +2028,26 @@ const Ve = (e, t) => (a) => {
2012
2028
  I(null);
2013
2029
  return;
2014
2030
  }
2015
- const c = y.find(({ id: h }) => h === o);
2016
- c && (I(o), se(c));
2031
+ const g = y.find(({ id: h }) => h === o);
2032
+ g && (I(o), se(g));
2017
2033
  },
2018
2034
  [y, N, se]
2019
- ), K = U(() => {
2035
+ ), q = U(() => {
2020
2036
  const o = {};
2021
- for (const c of _e) {
2022
- const h = cn(
2023
- c,
2024
- P[c.invocation_id]
2037
+ for (const g of _e) {
2038
+ const h = ln(
2039
+ g,
2040
+ P[g.invocation_id]
2025
2041
  );
2026
- (o[h] ?? (o[h] = [])).push(c);
2042
+ (o[h] ?? (o[h] = [])).push(g);
2027
2043
  }
2028
2044
  return o;
2029
2045
  }, [_e, P]), Se = T((o) => {
2030
2046
  u(o);
2031
2047
  }, []), be = T(
2032
2048
  async (o) => {
2033
- const c = await ee(o);
2034
- u(c), Y(!1);
2049
+ const g = await ee(o);
2050
+ u(g), Y(!1);
2035
2051
  },
2036
2052
  [ee]
2037
2053
  ), Ce = T(() => {
@@ -2040,7 +2056,7 @@ const Ve = (e, t) => (a) => {
2040
2056
  expandedAgentId: N,
2041
2057
  loadingAgentId: D,
2042
2058
  checklistByInvocationId: P,
2043
- errorByAgentId: q,
2059
+ errorByAgentId: z,
2044
2060
  definitionNameByRef: Z,
2045
2061
  onToggleAgent: Ae,
2046
2062
  onViewAgent: Se
@@ -2105,7 +2121,7 @@ const Ve = (e, t) => (a) => {
2105
2121
  searchType: "substring",
2106
2122
  placeholder: "All agents",
2107
2123
  options: de,
2108
- value: z,
2124
+ value: K,
2109
2125
  onValueChange: ye,
2110
2126
  showSelectionCountBadge: !0,
2111
2127
  showClearAll: !0,
@@ -2123,7 +2139,7 @@ const Ve = (e, t) => (a) => {
2123
2139
  color: "var(--color-semantic-destructive-600)"
2124
2140
  }
2125
2141
  ),
2126
- /* @__PURE__ */ n("p", { className: "agent-view__state-message", children: $ ?? Ke }),
2142
+ /* @__PURE__ */ n("p", { className: "agent-view__state-message", children: $ ?? qe }),
2127
2143
  /* @__PURE__ */ n(J, { variant: "secondary", size: "S", onClick: V, children: "Try again" })
2128
2144
  ] }) : k === "loading" && y.length === 0 ? /* @__PURE__ */ i("div", { className: "agent-view__state", "aria-live": "polite", children: [
2129
2145
  /* @__PURE__ */ n(
@@ -2142,7 +2158,7 @@ const Ve = (e, t) => (a) => {
2142
2158
  Fe,
2143
2159
  {
2144
2160
  column: ve[o],
2145
- agents: K[o] ?? [],
2161
+ agents: q[o] ?? [],
2146
2162
  ...me
2147
2163
  },
2148
2164
  o
@@ -2151,7 +2167,7 @@ const Ve = (e, t) => (a) => {
2151
2167
  Fe,
2152
2168
  {
2153
2169
  column: ve[o],
2154
- agents: K[o] ?? [],
2170
+ agents: q[o] ?? [],
2155
2171
  isSplit: !0,
2156
2172
  ...me
2157
2173
  },
@@ -2159,16 +2175,16 @@ const Ve = (e, t) => (a) => {
2159
2175
  )) })
2160
2176
  ] }),
2161
2177
  _ && /* @__PURE__ */ n(
2162
- sn,
2178
+ rn,
2163
2179
  {
2164
2180
  agent: _,
2165
2181
  open: !0,
2166
2182
  jwt: e,
2167
2183
  headers: R,
2168
2184
  agentUrl: r,
2169
- agentChecklistUrl: d,
2170
- agentResourcesUrl: g,
2171
- agentChatUrl: l,
2185
+ agentChecklistUrl: c,
2186
+ agentResourcesUrl: l,
2187
+ agentChatUrl: d,
2172
2188
  enableUpload: w,
2173
2189
  initialChecklist: P[_.invocation_id] ?? null,
2174
2190
  onClose: Ce
@@ -2176,7 +2192,7 @@ const Ve = (e, t) => (a) => {
2176
2192
  _.id
2177
2193
  ),
2178
2194
  /* @__PURE__ */ n(
2179
- rn,
2195
+ on,
2180
2196
  {
2181
2197
  open: te,
2182
2198
  onClose: () => Y(!1),
@@ -2185,7 +2201,7 @@ const Ve = (e, t) => (a) => {
2185
2201
  }
2186
2202
  )
2187
2203
  ] });
2188
- }, wn = (e, t) => {
2204
+ }, kn = (e, t) => {
2189
2205
  const a = Date.now(), s = t.trim() || e.agent_intent;
2190
2206
  return {
2191
2207
  id: `agent-${a}`,
@@ -2201,25 +2217,25 @@ const Ve = (e, t) => (a) => {
2201
2217
  };
2202
2218
  };
2203
2219
  export {
2204
- vn as AgentMonitorKanban,
2220
+ wn as AgentMonitorKanban,
2205
2221
  je as AgentServiceClient,
2206
2222
  ue as AgentServiceError,
2207
- sn as AgentView,
2208
- Bt as HttpChatConnector,
2209
- rn as NewAgentModal,
2210
- wn as buildAgentFromDefinition,
2223
+ rn as AgentView,
2224
+ zt as HttpChatConnector,
2225
+ on as NewAgentModal,
2226
+ kn as buildAgentFromDefinition,
2211
2227
  Ve as createHttpChatConnectorFactory,
2212
2228
  De as mapApiAgent,
2213
- Kt as mapApiAgentDefinition,
2214
- qt as mapApiAgentStatus,
2229
+ Wt as mapApiAgentDefinition,
2230
+ Kt as mapApiAgentStatus,
2215
2231
  Xe as mapApiChecklistEndpointResponse,
2216
2232
  Qe as mapApiChecklistItem,
2217
- fn as mapApiChecklistResponse,
2218
- zt as mapApiChecklistStatus,
2233
+ vn as mapApiChecklistResponse,
2234
+ qt as mapApiChecklistStatus,
2219
2235
  we as mapApiOpeningMessage,
2220
- jt as mapApiResource,
2236
+ Vt as mapApiResource,
2221
2237
  Ye as mapApiResourcesEndpointResponse,
2222
- mn as mapApiTripOption,
2223
- Zt as useAgentService,
2224
- tn as useAgentWorkspace
2238
+ fn as mapApiTripOption,
2239
+ en as useAgentService,
2240
+ nn as useAgentWorkspace
2225
2241
  };