@harnessio/ai-chat-core 0.0.6 → 0.0.7

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,36 +1,36 @@
1
1
  var $ = Object.defineProperty;
2
- var U = (i, s, t) => s in i ? $(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
- var c = (i, s, t) => U(i, typeof s != "symbol" ? s + "" : s, t);
2
+ var U = (i, r, t) => r in i ? $(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t;
3
+ var c = (i, r, t) => U(i, typeof r != "symbol" ? r + "" : r, t);
4
4
  import B, { createContext as H, useContext as Q, useState as x, useEffect as w, useReducer as J } from "react";
5
5
  class W {
6
6
  constructor() {
7
7
  c(this, "plugins", /* @__PURE__ */ new Map());
8
8
  c(this, "renderersByType", /* @__PURE__ */ new Map());
9
9
  }
10
- registerPlugin(s) {
11
- this.plugins.has(s.id), this.plugins.set(s.id, s), s.renderers.forEach((t) => {
10
+ registerPlugin(r) {
11
+ this.plugins.has(r.id), this.plugins.set(r.id, r), r.renderers.forEach((t) => {
12
12
  const e = this.renderersByType.get(t.type) || [];
13
- e.push(t), e.sort((n, r) => ((r == null ? void 0 : r.priority) ?? 0) - ((n == null ? void 0 : n.priority) ?? 0)), this.renderersByType.set(t.type, e);
13
+ e.push(t), e.sort((n, s) => ((s == null ? void 0 : s.priority) ?? 0) - ((n == null ? void 0 : n.priority) ?? 0)), this.renderersByType.set(t.type, e);
14
14
  });
15
15
  }
16
- unregisterPlugin(s) {
17
- const t = this.plugins.get(s);
16
+ unregisterPlugin(r) {
17
+ const t = this.plugins.get(r);
18
18
  return t ? (t.renderers.forEach((e) => {
19
- const r = (this.renderersByType.get(e.type) || []).filter((a) => !t.renderers.includes(a));
20
- r.length === 0 ? this.renderersByType.delete(e.type) : this.renderersByType.set(e.type, r);
21
- }), this.plugins.delete(s)) : !1;
19
+ const s = (this.renderersByType.get(e.type) || []).filter((a) => !t.renderers.includes(a));
20
+ s.length === 0 ? this.renderersByType.delete(e.type) : this.renderersByType.set(e.type, s);
21
+ }), this.plugins.delete(r)) : !1;
22
22
  }
23
- getPlugin(s) {
24
- return this.plugins.get(s);
23
+ getPlugin(r) {
24
+ return this.plugins.get(r);
25
25
  }
26
26
  getAllPlugins() {
27
27
  return Array.from(this.plugins.values());
28
28
  }
29
- getRenderersByType(s) {
30
- return this.renderersByType.get(s) || [];
29
+ getRenderersByType(r) {
30
+ return this.renderersByType.get(r) || [];
31
31
  }
32
- getBestRendererForType(s) {
33
- return this.getRenderersByType(s)[0];
32
+ getBestRendererForType(r) {
33
+ return this.getRenderersByType(r)[0];
34
34
  }
35
35
  clear() {
36
36
  this.plugins.clear(), this.renderersByType.clear();
@@ -41,29 +41,29 @@ class z {
41
41
  c(this, "handlers", /* @__PURE__ */ new Map());
42
42
  c(this, "renderers", /* @__PURE__ */ new Map());
43
43
  }
44
- registerHandler(s, t) {
45
- this.handlers.set(s, t);
44
+ registerHandler(r, t) {
45
+ this.handlers.set(r, t);
46
46
  }
47
- registerRenderer(s, t) {
48
- this.renderers.set(s, t);
47
+ registerRenderer(r, t) {
48
+ this.renderers.set(r, t);
49
49
  }
50
- unregister(s) {
51
- this.handlers.delete(s), this.renderers.delete(s);
50
+ unregister(r) {
51
+ this.handlers.delete(r), this.renderers.delete(r);
52
52
  }
53
- getHandler(s) {
54
- return this.handlers.get(s);
53
+ getHandler(r) {
54
+ return this.handlers.get(r);
55
55
  }
56
- getRenderer(s) {
57
- return this.renderers.get(s);
56
+ getRenderer(r) {
57
+ return this.renderers.get(r);
58
58
  }
59
59
  getStrategy() {
60
60
  return "queue";
61
61
  }
62
- hasHandler(s) {
63
- return this.handlers.has(s);
62
+ hasHandler(r) {
63
+ return this.handlers.has(r);
64
64
  }
65
- hasRenderer(s) {
66
- return this.renderers.has(s);
65
+ hasRenderer(r) {
66
+ return this.renderers.has(r);
67
67
  }
68
68
  clear() {
69
69
  this.handlers.clear(), this.renderers.clear();
@@ -73,29 +73,29 @@ class z {
73
73
  }
74
74
  }
75
75
  class V {
76
- constructor(s) {
76
+ constructor(r) {
77
77
  c(this, "executions", /* @__PURE__ */ new Map());
78
78
  c(this, "executionQueue", []);
79
79
  c(this, "isProcessing", !1);
80
80
  c(this, "runningByName", /* @__PURE__ */ new Map());
81
81
  c(this, "subscribers", /* @__PURE__ */ new Set());
82
82
  c(this, "getHandler");
83
- this.getHandler = s;
83
+ this.getHandler = r;
84
84
  }
85
- async executeCapability(s, t, e, n, r = "queue") {
86
- if (!this.getHandler(s)) {
87
- console.warn(`No handler registered for capability: ${s}`);
85
+ async executeCapability(r, t, e, n, s = "queue") {
86
+ if (!this.getHandler(r)) {
87
+ console.warn(`No handler registered for capability: ${r}`);
88
88
  return;
89
89
  }
90
90
  const o = {
91
91
  id: t,
92
- name: s,
92
+ name: r,
93
93
  args: e,
94
94
  status: { type: "queued" },
95
95
  timestamp: Date.now(),
96
96
  messageId: n
97
97
  };
98
- switch (this.executions.set(t, o), this.notifySubscribers(t), r) {
98
+ switch (this.executions.set(t, o), this.notifySubscribers(t), s) {
99
99
  case "queue":
100
100
  default:
101
101
  this.executionQueue.push(t);
@@ -106,41 +106,41 @@ class V {
106
106
  async processQueue() {
107
107
  if (!(this.isProcessing || this.executionQueue.length === 0)) {
108
108
  for (this.isProcessing = !0; this.executionQueue.length > 0; ) {
109
- const s = this.executionQueue.shift(), t = this.executions.get(s);
109
+ const r = this.executionQueue.shift(), t = this.executions.get(r);
110
110
  if (!t) continue;
111
111
  const e = this.getHandler(t.name);
112
112
  if (!e) continue;
113
- t.status = { type: "running" }, this.notifySubscribers(s);
113
+ t.status = { type: "running" }, this.notifySubscribers(r);
114
114
  const n = this.runningByName.get(t.name) || [];
115
- n.push(s), this.runningByName.set(t.name, n);
115
+ n.push(r), this.runningByName.set(t.name, n);
116
116
  try {
117
- const r = await e.execute(t.args, {
117
+ const s = await e.execute(t.args, {
118
118
  messageId: t.messageId,
119
- capabilityId: s
119
+ capabilityId: r
120
120
  });
121
- t.status = { type: "complete", result: r }, t.result = r;
122
- } catch (r) {
123
- const a = r instanceof Error ? r.message : "Unknown error";
121
+ t.status = { type: "complete", result: s }, t.result = s;
122
+ } catch (s) {
123
+ const a = s instanceof Error ? s.message : "Unknown error";
124
124
  t.status = { type: "error", error: a }, t.error = a;
125
125
  } finally {
126
- const r = this.runningByName.get(t.name) || [], a = r.indexOf(s);
127
- a > -1 && r.splice(a, 1), r.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, r), this.notifySubscribers(s);
126
+ const s = this.runningByName.get(t.name) || [], a = s.indexOf(r);
127
+ a > -1 && s.splice(a, 1), s.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, s), this.notifySubscribers(r);
128
128
  }
129
129
  }
130
130
  this.isProcessing = !1;
131
131
  }
132
132
  }
133
- getExecution(s) {
134
- return this.executions.get(s);
133
+ getExecution(r) {
134
+ return this.executions.get(r);
135
135
  }
136
- getExecutionsByMessage(s) {
137
- return Array.from(this.executions.values()).filter((t) => t.messageId === s);
136
+ getExecutionsByMessage(r) {
137
+ return Array.from(this.executions.values()).filter((t) => t.messageId === r);
138
138
  }
139
- subscribe(s) {
140
- return this.subscribers.add(s), () => this.subscribers.delete(s);
139
+ subscribe(r) {
140
+ return this.subscribers.add(r), () => this.subscribers.delete(r);
141
141
  }
142
- notifySubscribers(s) {
143
- this.subscribers.forEach((t) => t(s));
142
+ notifySubscribers(r) {
143
+ this.subscribers.forEach((t) => t(r));
144
144
  }
145
145
  clear() {
146
146
  this.executions.clear(), this.executionQueue = [], this.runningByName.clear();
@@ -150,14 +150,14 @@ class y {
150
150
  constructor() {
151
151
  c(this, "_subscriptions", /* @__PURE__ */ new Set());
152
152
  }
153
- subscribe(s) {
154
- return this._subscriptions.add(s), () => {
155
- this._subscriptions.delete(s);
153
+ subscribe(r) {
154
+ return this._subscriptions.add(r), () => {
155
+ this._subscriptions.delete(r);
156
156
  };
157
157
  }
158
158
  notifySubscribers() {
159
- for (const s of this._subscriptions)
160
- s();
159
+ for (const r of this._subscriptions)
160
+ r();
161
161
  }
162
162
  getSubscriberCount() {
163
163
  return this._subscriptions.size;
@@ -196,10 +196,10 @@ class G extends y {
196
196
  get focusedContentIndex() {
197
197
  return this._state.focusedContentIndex;
198
198
  }
199
- focus(t, e, n, r = "detail") {
199
+ focus(t, e, n, s = "detail") {
200
200
  this._state = {
201
201
  isActive: !0,
202
- context: r,
202
+ context: s,
203
203
  focusedContent: t,
204
204
  focusedMessage: e,
205
205
  focusedMessageId: e.id,
@@ -216,8 +216,8 @@ class G extends y {
216
216
  focusedContentIndex: null
217
217
  }, this.notifySubscribers();
218
218
  }
219
- toggle(t, e, n, r = "detail") {
220
- this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === n && this._state.context === r ? this.blur() : this.focus(t, e, n, r);
219
+ toggle(t, e, n, s = "detail") {
220
+ this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === n && this._state.context === s ? this.blur() : this.focus(t, e, n, s);
221
221
  }
222
222
  switchContext(t) {
223
223
  this._state.isActive && this._state.focusedContent && (this._state = {
@@ -229,10 +229,10 @@ class G extends y {
229
229
  if (!this._state.focusedMessageId || !t.length) return;
230
230
  const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
231
231
  if (e === -1) return;
232
- const n = t[e], r = this._state.focusedContentIndex ?? 0;
233
- if (r + 1 < n.content.length) {
234
- const a = n.content[r + 1];
235
- this.focus(a, n, r + 1, this._state.context || "detail");
232
+ const n = t[e], s = this._state.focusedContentIndex ?? 0;
233
+ if (s + 1 < n.content.length) {
234
+ const a = n.content[s + 1];
235
+ this.focus(a, n, s + 1, this._state.context || "detail");
236
236
  return;
237
237
  }
238
238
  if (e + 1 < t.length) {
@@ -244,10 +244,10 @@ class G extends y {
244
244
  if (!this._state.focusedMessageId || !t.length) return;
245
245
  const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
246
246
  if (e === -1) return;
247
- const n = t[e], r = this._state.focusedContentIndex ?? 0;
248
- if (r > 0) {
249
- const a = n.content[r - 1];
250
- this.focus(a, n, r - 1, this._state.context || "detail");
247
+ const n = t[e], s = this._state.focusedContentIndex ?? 0;
248
+ if (s > 0) {
249
+ const a = n.content[s - 1];
250
+ this.focus(a, n, s - 1, this._state.context || "detail");
251
251
  return;
252
252
  }
253
253
  if (e > 0) {
@@ -462,22 +462,22 @@ class v extends y {
462
462
  };
463
463
  this.updateMessages([...this._messages, n]);
464
464
  try {
465
- const r = this.config.streamAdapter.stream({
465
+ const s = this.config.streamAdapter.stream({
466
466
  messages: this._messages,
467
467
  conversationId: this._conversationId,
468
468
  signal: this._abortController.signal
469
469
  });
470
- for await (const a of r) {
470
+ for await (const a of s) {
471
471
  if (this._abortController.signal.aborted)
472
472
  break;
473
473
  this.handleStreamEvent(e, a.event);
474
474
  }
475
475
  this.updateMessageStatus(e, { type: "complete" });
476
- } catch (r) {
477
- if (r instanceof Error && r.name === "AbortError")
476
+ } catch (s) {
477
+ if (s instanceof Error && s.name === "AbortError")
478
478
  this.updateMessageStatus(e, { type: "cancelled" });
479
479
  else {
480
- const a = r instanceof Error ? r.message : "Unknown error";
480
+ const a = s instanceof Error ? s.message : "Unknown error";
481
481
  this.updateMessageStatus(e, {
482
482
  type: "error",
483
483
  error: a
@@ -490,24 +490,24 @@ class v extends y {
490
490
  handleStreamEvent(t, e) {
491
491
  const n = this._messages.findIndex((o) => o.id === t);
492
492
  if (n === -1) return;
493
- const r = this._messages[n];
493
+ const s = this._messages[n];
494
494
  if (e.type === "part-start")
495
- this.handlePartStart(r, e);
495
+ this.handlePartStart(s, e);
496
496
  else if (e.type === "text-delta" || e.type === "assistant_thought")
497
- this.handleTextDelta(r, e);
497
+ this.handleTextDelta(s, e);
498
498
  else if (e.type === "part-finish")
499
499
  this.handlePartFinish();
500
500
  else if (e.type === "metadata") {
501
501
  const o = e;
502
- r.metadata = {
503
- ...r.metadata,
502
+ s.metadata = {
503
+ ...s.metadata,
504
504
  conversationId: o.conversationId,
505
505
  interactionId: o.interactionId
506
506
  }, o.conversationId && !this._conversationId && (this._conversationId = o.conversationId), o.title && !this._title && (this._title = o.title);
507
507
  } else if (e.type === "capability_execution") {
508
508
  const o = e;
509
- r.content = [
510
- ...r.content,
509
+ s.content = [
510
+ ...s.content,
511
511
  {
512
512
  type: "capability",
513
513
  capabilityId: o.capabilityId,
@@ -523,8 +523,8 @@ class v extends y {
523
523
  );
524
524
  } else if (e.type === "error") {
525
525
  const o = e;
526
- r.content = [
527
- ...r.content,
526
+ s.content = [
527
+ ...s.content,
528
528
  {
529
529
  type: "error",
530
530
  data: o.error
@@ -532,8 +532,8 @@ class v extends y {
532
532
  ];
533
533
  } else {
534
534
  const o = e;
535
- r.content = [
536
- ...r.content,
535
+ s.content = [
536
+ ...s.content,
537
537
  {
538
538
  type: o.type,
539
539
  data: o.data,
@@ -543,36 +543,36 @@ class v extends y {
543
543
  }
544
544
  const a = [
545
545
  ...this._messages.slice(0, n),
546
- { ...r, timestamp: Date.now() },
546
+ { ...s, timestamp: Date.now() },
547
547
  ...this._messages.slice(n + 1)
548
548
  ];
549
549
  this.updateMessages(a);
550
550
  }
551
551
  handlePartStart(t, e) {
552
552
  const n = t.content.length;
553
- let r;
553
+ let s;
554
554
  switch (e.part.type) {
555
555
  case "assistant_thought":
556
- r = {
556
+ s = {
557
557
  type: e.part.type,
558
558
  data: [],
559
559
  parentId: e.part.parentId
560
560
  };
561
561
  break;
562
562
  case "text":
563
- r = {
563
+ s = {
564
564
  type: e.part.type,
565
565
  data: "",
566
566
  parentId: e.part.parentId
567
567
  };
568
568
  break;
569
569
  default:
570
- r = {
570
+ s = {
571
571
  type: e.part.type,
572
572
  parentId: e.part.parentId
573
573
  };
574
574
  }
575
- t.content = [...t.content, r], this._currentPart = {
575
+ t.content = [...t.content, s], this._currentPart = {
576
576
  messageId: t.id,
577
577
  contentIndex: n,
578
578
  type: e.part.type,
@@ -597,7 +597,7 @@ class v extends y {
597
597
  updateMessageStatus(t, e) {
598
598
  const n = this._messages.findIndex((a) => a.id === t);
599
599
  if (n === -1) return;
600
- const r = [
600
+ const s = [
601
601
  ...this._messages.slice(0, n),
602
602
  {
603
603
  ...this._messages[n],
@@ -605,7 +605,7 @@ class v extends y {
605
605
  },
606
606
  ...this._messages.slice(n + 1)
607
607
  ];
608
- this.updateMessages(r);
608
+ this.updateMessages(s);
609
609
  }
610
610
  clear() {
611
611
  this.updateMessages([]);
@@ -647,13 +647,13 @@ class Z extends y {
647
647
  updatedAt: Date.now()
648
648
  };
649
649
  this._threadStates.set(this._mainThreadId, n);
650
- const r = new I({
650
+ const s = new I({
651
651
  state: n,
652
652
  onSwitchTo: this.switchToThread.bind(this),
653
653
  onRename: this.renameThread.bind(this),
654
654
  onDelete: this.deleteThread.bind(this)
655
655
  });
656
- this._threadItems.set(this._mainThreadId, r);
656
+ this._threadItems.set(this._mainThreadId, s);
657
657
  }
658
658
  get isLoading() {
659
659
  return this._isLoading;
@@ -667,8 +667,8 @@ class Z extends y {
667
667
  }
668
668
  getState() {
669
669
  const t = [], e = {};
670
- for (const [n, r] of this._threadStates)
671
- e[n] = r, r.status.type === "regular" && t.push(n);
670
+ for (const [n, s] of this._threadStates)
671
+ e[n] = s, s.status.type === "regular" && t.push(n);
672
672
  return {
673
673
  mainThreadId: this._mainThreadId,
674
674
  threads: t,
@@ -683,8 +683,8 @@ class Z extends y {
683
683
  throw new Error(`Thread ${t} not found`);
684
684
  const n = this._threadStates.get(this._mainThreadId);
685
685
  n && (n.isMain = !1, this._threadStates.set(this._mainThreadId, n), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(n)), this._mainThreadId = t;
686
- const r = this._threadStates.get(t);
687
- if (r && (r.isMain = !0, this._threadStates.set(t, r), (o = this._threadItems.get(t)) == null || o.updateState(r), e.setConversationId(r.conversationId), e.setTitle(r.title)), this.config.threadListAdapter && (r != null && r.conversationId)) {
686
+ const s = this._threadStates.get(t);
687
+ if (s && (s.isMain = !0, this._threadStates.set(t, s), (o = this._threadItems.get(t)) == null || o.updateState(s), e.setConversationId(s.conversationId), e.setTitle(s.title)), this.config.threadListAdapter && (s != null && s.conversationId)) {
688
688
  this._isLoading = !0, this.notifySubscribers();
689
689
  try {
690
690
  const u = await this.config.threadListAdapter.loadThread(t);
@@ -703,7 +703,7 @@ class Z extends y {
703
703
  capabilityExecutionManager: this.config.capabilityExecutionManager
704
704
  }), n = new R(e);
705
705
  this._threads.set(t, n);
706
- const r = {
706
+ const s = {
707
707
  id: t,
708
708
  title: "New Chat",
709
709
  status: { type: "regular" },
@@ -711,19 +711,19 @@ class Z extends y {
711
711
  createdAt: Date.now(),
712
712
  updatedAt: Date.now()
713
713
  };
714
- this._threadStates.set(t, r);
714
+ this._threadStates.set(t, s);
715
715
  const a = new I({
716
- state: r,
716
+ state: s,
717
717
  onSwitchTo: this.switchToThread.bind(this),
718
718
  onRename: this.renameThread.bind(this),
719
719
  onDelete: this.deleteThread.bind(this)
720
720
  });
721
721
  if (this._threadItems.set(t, a), n.subscribe(() => {
722
- this.notifySubscribers();
722
+ this.syncThreadStateFromRuntime(t, n), this.notifySubscribers();
723
723
  }), this.config.threadListAdapter)
724
724
  try {
725
725
  const o = await this.config.threadListAdapter.createThread();
726
- r.conversationId = o.conversationId, this._threadStates.set(t, r), a.updateState(r);
726
+ s.conversationId = o.conversationId, this._threadStates.set(t, s), a.updateState(s);
727
727
  } catch (o) {
728
728
  console.error("Failed to create thread:", o);
729
729
  }
@@ -742,16 +742,16 @@ class Z extends y {
742
742
  continue;
743
743
  const n = new v({
744
744
  streamAdapter: this.config.streamAdapter
745
- }), r = new R(n);
746
- this._threads.set(e.id, r), this._threadStates.set(e.id, e);
745
+ }), s = new R(n);
746
+ this._threads.set(e.id, s), this._threadStates.set(e.id, e);
747
747
  const a = new I({
748
748
  state: e,
749
749
  onSwitchTo: this.switchToThread.bind(this),
750
750
  onRename: this.renameThread.bind(this),
751
751
  onDelete: this.deleteThread.bind(this)
752
752
  });
753
- this._threadItems.set(e.id, a), r.subscribe(() => {
754
- this.notifySubscribers();
753
+ this._threadItems.set(e.id, a), s.subscribe(() => {
754
+ this.syncThreadStateFromRuntime(e.id, s), this.notifySubscribers();
755
755
  });
756
756
  }
757
757
  } catch (t) {
@@ -760,11 +760,19 @@ class Z extends y {
760
760
  this._isLoading = !1, this.notifySubscribers();
761
761
  }
762
762
  }
763
+ /**
764
+ * Syncs conversationId and title from thread runtime to thread state
765
+ */
766
+ syncThreadStateFromRuntime(t, e) {
767
+ var s;
768
+ const n = this._threadStates.get(t);
769
+ n && (n.conversationId !== e.conversationId || n.title !== e.title) && (n.conversationId = e.conversationId, n.title = e.title || n.title, n.updatedAt = Date.now(), this._threadStates.set(t, n), (s = this._threadItems.get(t)) == null || s.updateState(n));
770
+ }
763
771
  async renameThread(t, e) {
764
- var r;
772
+ var s;
765
773
  const n = this._threadStates.get(t);
766
774
  if (n) {
767
- if (n.title = e, n.updatedAt = Date.now(), this._threadStates.set(t, n), (r = this._threadItems.get(t)) == null || r.updateState(n), this.config.threadListAdapter)
775
+ if (n.title = e, n.updatedAt = Date.now(), this._threadStates.set(t, n), (s = this._threadItems.get(t)) == null || s.updateState(n), this.config.threadListAdapter)
768
776
  try {
769
777
  await this.config.threadListAdapter.updateThread(t, { title: e });
770
778
  } catch (a) {
@@ -851,12 +859,12 @@ class ft extends y {
851
859
  var e;
852
860
  if (t.length !== 0 && !this._contentFocusRuntime.isActive)
853
861
  for (let n = t.length - 1; n >= 0; n--) {
854
- const r = t[n];
855
- if (r.role === "assistant")
856
- for (let a = r.content.length - 1; a >= 0; a--) {
857
- const o = r.content[a], u = this.pluginRegistry.getRenderersByType(o.type);
862
+ const s = t[n];
863
+ if (s.role === "assistant")
864
+ for (let a = s.content.length - 1; a >= 0; a--) {
865
+ const o = s.content[a], u = this.pluginRegistry.getRenderersByType(o.type);
858
866
  if (u.length > 0 && ((e = u[0].capabilities) != null && e.supportsFocus)) {
859
- this._contentFocusRuntime.focus(o, r, a, "detail");
867
+ this._contentFocusRuntime.focus(o, s, a, "detail");
860
868
  return;
861
869
  }
862
870
  }
@@ -873,18 +881,18 @@ var E, L;
873
881
  function tt() {
874
882
  if (L) return E;
875
883
  L = 1;
876
- var i = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
877
- function e(r) {
878
- if (r == null)
884
+ var i = Object.getOwnPropertySymbols, r = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
885
+ function e(s) {
886
+ if (s == null)
879
887
  throw new TypeError("Object.assign cannot be called with null or undefined");
880
- return Object(r);
888
+ return Object(s);
881
889
  }
882
890
  function n() {
883
891
  try {
884
892
  if (!Object.assign)
885
893
  return !1;
886
- var r = new String("abc");
887
- if (r[5] = "de", Object.getOwnPropertyNames(r)[0] === "5")
894
+ var s = new String("abc");
895
+ if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
888
896
  return !1;
889
897
  for (var a = {}, o = 0; o < 10; o++)
890
898
  a["_" + String.fromCharCode(o)] = o;
@@ -901,11 +909,11 @@ function tt() {
901
909
  return !1;
902
910
  }
903
911
  }
904
- return E = n() ? Object.assign : function(r, a) {
905
- for (var o, u = e(r), f, l = 1; l < arguments.length; l++) {
912
+ return E = n() ? Object.assign : function(s, a) {
913
+ for (var o, u = e(s), f, l = 1; l < arguments.length; l++) {
906
914
  o = Object(arguments[l]);
907
915
  for (var h in o)
908
- s.call(o, h) && (u[h] = o[h]);
916
+ r.call(o, h) && (u[h] = o[h]);
909
917
  if (i) {
910
918
  f = i(o);
911
919
  for (var d = 0; d < f.length; d++)
@@ -927,18 +935,18 @@ var j;
927
935
  function et() {
928
936
  if (j) return _;
929
937
  j = 1, tt();
930
- var i = B, s = 60103;
938
+ var i = B, r = 60103;
931
939
  if (_.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
932
940
  var t = Symbol.for;
933
- s = t("react.element"), _.Fragment = t("react.fragment");
941
+ r = t("react.element"), _.Fragment = t("react.fragment");
934
942
  }
935
- var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = Object.prototype.hasOwnProperty, r = { key: !0, ref: !0, __self: !0, __source: !0 };
943
+ var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
936
944
  function a(o, u, f) {
937
945
  var l, h = {}, d = null, p = null;
938
946
  f !== void 0 && (d = "" + f), u.key !== void 0 && (d = "" + u.key), u.ref !== void 0 && (p = u.ref);
939
- for (l in u) n.call(u, l) && !r.hasOwnProperty(l) && (h[l] = u[l]);
947
+ for (l in u) n.call(u, l) && !s.hasOwnProperty(l) && (h[l] = u[l]);
940
948
  if (o && o.defaultProps) for (l in u = o.defaultProps, u) h[l] === void 0 && (h[l] = u[l]);
941
- return { $$typeof: s, type: o, key: d, ref: p, props: h, _owner: e.current };
949
+ return { $$typeof: r, type: o, key: d, ref: p, props: h, _owner: e.current };
942
950
  }
943
951
  return _.jsx = a, _.jsxs = a, _;
944
952
  }
@@ -948,8 +956,8 @@ function st() {
948
956
  }
949
957
  var S = st();
950
958
  const k = H(null);
951
- function pt({ runtime: i, children: s }) {
952
- return /* @__PURE__ */ S.jsx(k.Provider, { value: i, children: s });
959
+ function pt({ runtime: i, children: r }) {
960
+ return /* @__PURE__ */ S.jsx(k.Provider, { value: i, children: r });
953
961
  }
954
962
  function rt() {
955
963
  const i = Q(k);
@@ -963,27 +971,27 @@ function g() {
963
971
  function gt() {
964
972
  const i = g();
965
973
  return {
966
- switchToThread: (s) => i.threads.switchToThread(s),
974
+ switchToThread: (r) => i.threads.switchToThread(r),
967
975
  switchToNewThread: () => i.threads.switchToNewThread(),
968
976
  loadThreads: () => {
969
- var s, t;
970
- return (t = (s = i.threads).loadThreads) == null ? void 0 : t.call(s);
977
+ var r, t;
978
+ return (t = (r = i.threads).loadThreads) == null ? void 0 : t.call(r);
971
979
  },
972
- renameThread: (s, t) => {
980
+ renameThread: (r, t) => {
973
981
  var e, n;
974
- return (n = (e = i.threads).renameThread) == null ? void 0 : n.call(e, s, t);
982
+ return (n = (e = i.threads).renameThread) == null ? void 0 : n.call(e, r, t);
975
983
  },
976
- deleteThread: (s) => {
984
+ deleteThread: (r) => {
977
985
  var t, e;
978
- return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, s);
986
+ return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, r);
979
987
  }
980
988
  };
981
989
  }
982
990
  function bt() {
983
- const i = g(), [s, t] = x(i.threads.getState());
991
+ const i = g(), [r, t] = x(i.threads.getState());
984
992
  return w(() => i.threads.subscribe(() => {
985
993
  t(i.threads.getState());
986
- }), [i]), s;
994
+ }), [i]), r;
987
995
  }
988
996
  function nt() {
989
997
  return g().threads.getMainThread();
@@ -998,18 +1006,18 @@ var M = { exports: {} }, A = {};
998
1006
  * This source code is licensed under the MIT license found in the
999
1007
  * LICENSE file in the root directory of this source tree.
1000
1008
  */
1001
- var N;
1009
+ var D;
1002
1010
  function it() {
1003
- if (N) return A;
1004
- N = 1;
1011
+ if (D) return A;
1012
+ D = 1;
1005
1013
  var i = B;
1006
- function s(h, d) {
1014
+ function r(h, d) {
1007
1015
  return h === d && (h !== 0 || 1 / h === 1 / d) || h !== h && d !== d;
1008
1016
  }
1009
- var t = typeof Object.is == "function" ? Object.is : s, e = i.useState, n = i.useEffect, r = i.useLayoutEffect, a = i.useDebugValue;
1017
+ var t = typeof Object.is == "function" ? Object.is : r, e = i.useState, n = i.useEffect, s = i.useLayoutEffect, a = i.useDebugValue;
1010
1018
  function o(h, d) {
1011
1019
  var p = d(), m = e({ inst: { value: p, getSnapshot: d } }), b = m[0].inst, T = m[1];
1012
- return r(
1020
+ return s(
1013
1021
  function() {
1014
1022
  b.value = p, b.getSnapshot = d, u(b) && T({ inst: b });
1015
1023
  },
@@ -1039,30 +1047,30 @@ function it() {
1039
1047
  var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : o;
1040
1048
  return A.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : l, A;
1041
1049
  }
1042
- var D;
1050
+ var N;
1043
1051
  function at() {
1044
- return D || (D = 1, M.exports = it()), M.exports;
1052
+ return N || (N = 1, M.exports = it()), M.exports;
1045
1053
  }
1046
1054
  var ot = at();
1047
1055
  function yt() {
1048
1056
  const i = g();
1049
1057
  return ot.useSyncExternalStore(
1050
- (s) => i.subscribe(() => {
1051
- s();
1058
+ (r) => i.subscribe(() => {
1059
+ r();
1052
1060
  }),
1053
1061
  () => i.thread.messages,
1054
1062
  () => i.thread.messages
1055
1063
  );
1056
1064
  }
1057
1065
  function mt() {
1058
- const i = nt(), [s, t] = x(""), [e, n] = x(!1);
1066
+ const i = nt(), [r, t] = x(""), [e, n] = x(!1);
1059
1067
  return {
1060
- text: s,
1068
+ text: r,
1061
1069
  setText: t,
1062
1070
  isSubmitting: e,
1063
1071
  send: async (a) => {
1064
- if (a == null || a.preventDefault(), !s.trim() || e) return;
1065
- const o = s;
1072
+ if (a == null || a.preventDefault(), !r.trim() || e) return;
1073
+ const o = r;
1066
1074
  t(""), n(!0);
1067
1075
  try {
1068
1076
  await i.send(o);
@@ -1076,8 +1084,8 @@ function mt() {
1076
1084
  append: (a) => t((o) => o + a)
1077
1085
  };
1078
1086
  }
1079
- function q(i, s) {
1080
- var r, a, o, u;
1087
+ function q(i, r) {
1088
+ var s, a, o, u;
1081
1089
  const e = g().pluginRegistry.getBestRendererForType(i);
1082
1090
  if (!e)
1083
1091
  return {
@@ -1087,7 +1095,7 @@ function q(i, s) {
1087
1095
  supportsPreview: !1,
1088
1096
  supportsFullscreen: !1
1089
1097
  };
1090
- const n = s ? (r = e.auxiliary) == null ? void 0 : r[s] : null;
1098
+ const n = r ? (s = e.auxiliary) == null ? void 0 : s[r] : null;
1091
1099
  return {
1092
1100
  component: e.component,
1093
1101
  auxiliaryComponent: n,
@@ -1097,46 +1105,46 @@ function q(i, s) {
1097
1105
  };
1098
1106
  }
1099
1107
  function _t() {
1100
- const i = g(), [s, t] = x(i.contentFocus.state);
1108
+ const i = g(), [r, t] = x(i.contentFocus.state);
1101
1109
  return w(() => i.contentFocus.subscribe(() => {
1102
1110
  t(i.contentFocus.state);
1103
1111
  }), [i]), {
1104
- ...s,
1105
- focus: (e, n, r, a) => i.contentFocus.focus(e, n, r, a),
1112
+ ...r,
1113
+ focus: (e, n, s, a) => i.contentFocus.focus(e, n, s, a),
1106
1114
  blur: () => i.contentFocus.blur(),
1107
- toggle: (e, n, r, a) => i.contentFocus.toggle(e, n, r, a),
1115
+ toggle: (e, n, s, a) => i.contentFocus.toggle(e, n, s, a),
1108
1116
  switchContext: (e) => i.contentFocus.switchContext(e),
1109
1117
  focusNext: () => i.contentFocus.focusNext(i.thread.messages),
1110
1118
  focusPrevious: () => i.contentFocus.focusPrevious(i.thread.messages)
1111
1119
  };
1112
1120
  }
1113
1121
  function ut(i) {
1114
- const s = g();
1115
- w(() => (i.execute && s.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && s.capabilityRegistry.registerRenderer(i.name, {
1122
+ const r = g();
1123
+ w(() => (i.execute && r.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && r.capabilityRegistry.registerRenderer(i.name, {
1116
1124
  component: i.render
1117
1125
  }), () => {
1118
- s.capabilityRegistry.unregister(i.name);
1119
- }), [i.name, s]);
1126
+ r.capabilityRegistry.unregister(i.name);
1127
+ }), [i.name, r]);
1120
1128
  }
1121
1129
  function ct(i) {
1122
- const s = g(), [t, e] = x(
1123
- () => s.capabilityExecutionManager.getExecution(i)
1124
- ), [, n] = J((r) => r + 1, 0);
1130
+ const r = g(), [t, e] = x(
1131
+ () => r.capabilityExecutionManager.getExecution(i)
1132
+ ), [, n] = J((s) => s + 1, 0);
1125
1133
  return w(() => {
1126
- const r = s.capabilityExecutionManager.getExecution(i);
1127
- return e(r), s.capabilityExecutionManager.subscribe((o) => {
1134
+ const s = r.capabilityExecutionManager.getExecution(i);
1135
+ return e(s), r.capabilityExecutionManager.subscribe((o) => {
1128
1136
  if (o === i) {
1129
- const u = s.capabilityExecutionManager.getExecution(i);
1137
+ const u = r.capabilityExecutionManager.getExecution(i);
1130
1138
  e(u), n();
1131
1139
  }
1132
1140
  });
1133
- }, [i, s]), t;
1141
+ }, [i, r]), t;
1134
1142
  }
1135
- function ht({ message: i, content: s }) {
1136
- const t = g(), e = s, n = ct(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1137
- if (!r || !n)
1143
+ function ht({ message: i, content: r }) {
1144
+ const t = g(), e = r, n = ct(e.capabilityId), s = t.capabilityRegistry.getRenderer(e.capabilityName);
1145
+ if (!s || !n)
1138
1146
  return null;
1139
- const a = r.component;
1147
+ const a = s.component;
1140
1148
  return /* @__PURE__ */ S.jsx(
1141
1149
  a,
1142
1150
  {
@@ -1149,70 +1157,70 @@ function ht({ message: i, content: s }) {
1149
1157
  }
1150
1158
  );
1151
1159
  }
1152
- function xt({ message: i, content: s }) {
1153
- const { component: t } = q(s.type);
1154
- if (s.type === "capability")
1155
- return /* @__PURE__ */ S.jsx(ht, { message: i, content: s });
1160
+ function xt({ message: i, content: r }) {
1161
+ const { component: t } = q(r.type);
1162
+ if (r.type === "capability")
1163
+ return /* @__PURE__ */ S.jsx(ht, { message: i, content: r });
1156
1164
  if (!t)
1157
1165
  return null;
1158
1166
  const e = t;
1159
- return /* @__PURE__ */ S.jsx(e, { content: s, message: i });
1167
+ return /* @__PURE__ */ S.jsx(e, { content: r, message: i });
1160
1168
  }
1161
1169
  function St({
1162
1170
  message: i,
1163
- content: s,
1171
+ content: r,
1164
1172
  context: t,
1165
1173
  onClose: e,
1166
1174
  onNavigate: n,
1167
- onSwitchContext: r
1175
+ onSwitchContext: s
1168
1176
  }) {
1169
- const { auxiliaryComponent: a } = q(s.type, t);
1177
+ const { auxiliaryComponent: a } = q(r.type, t);
1170
1178
  if (!a)
1171
1179
  return null;
1172
1180
  const o = a;
1173
1181
  return /* @__PURE__ */ S.jsx(
1174
1182
  o,
1175
1183
  {
1176
- content: s,
1184
+ content: r,
1177
1185
  message: i,
1178
1186
  context: t,
1179
1187
  onClose: e,
1180
1188
  onNavigate: n,
1181
- onSwitchContext: r
1189
+ onSwitchContext: s
1182
1190
  }
1183
1191
  );
1184
1192
  }
1185
1193
  function wt(i) {
1186
- const s = () => (ut(i), null);
1187
- return s.displayName = `Capability(${i.name})`, s;
1194
+ const r = () => (ut(i), null);
1195
+ return r.displayName = `Capability(${i.name})`, r;
1188
1196
  }
1189
1197
  class Tt {
1190
1198
  getAllowedEvents() {
1191
1199
  return null;
1192
1200
  }
1193
- shouldProcessEvent(s) {
1201
+ shouldProcessEvent(r) {
1194
1202
  const t = this.getAllowedEvents();
1195
- return t ? t.includes(s) : !0;
1203
+ return t ? t.includes(r) : !0;
1196
1204
  }
1197
- async *stream(s) {
1198
- const { signal: t } = s, { url: e, options: n } = this.prepareRequest(s), r = await fetch(e, { ...n, signal: t });
1199
- if (!r.ok)
1200
- throw new Error(`HTTP error! status: ${r.status}`);
1201
- if (!r.body)
1205
+ async *stream(r) {
1206
+ const { signal: t } = r, { url: e, options: n } = this.prepareRequest(r), s = await fetch(e, { ...n, signal: t });
1207
+ if (!s.ok)
1208
+ throw new Error(`HTTP error! status: ${s.status}`);
1209
+ if (!s.body)
1202
1210
  throw new Error("Response body is null");
1203
- yield* this.parseSSEStream(r.body, t);
1211
+ yield* this.parseSSEStream(s.body, t);
1204
1212
  }
1205
- async *parseSSEStream(s, t) {
1206
- const e = s.getReader(), n = new TextDecoder();
1207
- let r = "", a = null;
1213
+ async *parseSSEStream(r, t) {
1214
+ const e = r.getReader(), n = new TextDecoder();
1215
+ let s = "", a = null;
1208
1216
  try {
1209
1217
  for (; ; ) {
1210
1218
  const { done: o, value: u } = await e.read();
1211
1219
  if (o || t != null && t.aborted) break;
1212
- r += n.decode(u, { stream: !0 });
1213
- const f = r.split(`
1220
+ s += n.decode(u, { stream: !0 });
1221
+ const f = s.split(`
1214
1222
  `);
1215
- r = f.pop() || "";
1223
+ s = f.pop() || "";
1216
1224
  for (const l of f) {
1217
1225
  const h = l.trim();
1218
1226
  if (!h) {