@harnessio/ai-chat-core 0.0.14 → 0.0.16

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 J = Object.defineProperty;
2
- var W = (i, s, t) => s in i ? J(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
- var u = (i, s, t) => W(i, typeof s != "symbol" ? s + "" : s, t);
4
- import k, { createContext as q, useContext as U, useState as b, useEffect as w, useReducer as z, useCallback as C, useMemo as V } from "react";
2
+ var W = (i, r, t) => r in i ? J(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t;
3
+ var u = (i, r, t) => W(i, typeof r != "symbol" ? r + "" : r, t);
4
+ import B, { createContext as q, useContext as U, useState as b, useEffect as w, useReducer as z, useCallback as C, useMemo as V } from "react";
5
5
  class G {
6
6
  constructor() {
7
7
  u(this, "plugins", /* @__PURE__ */ new Map());
8
8
  u(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((r, n) => ((n == null ? void 0 : n.priority) ?? 0) - ((r == null ? void 0 : r.priority) ?? 0)), this.renderersByType.set(t.type, e);
13
+ e.push(t), e.sort((s, n) => ((n == null ? void 0 : n.priority) ?? 0) - ((s == null ? void 0 : s.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
19
  const n = (this.renderersByType.get(e.type) || []).filter((a) => !t.renderers.includes(a));
20
20
  n.length === 0 ? this.renderersByType.delete(e.type) : this.renderersByType.set(e.type, n);
21
- }), this.plugins.delete(s)) : !1;
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 Y {
41
41
  u(this, "handlers", /* @__PURE__ */ new Map());
42
42
  u(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,27 +73,27 @@ class Y {
73
73
  }
74
74
  }
75
75
  class K {
76
- constructor(s) {
76
+ constructor(r) {
77
77
  u(this, "executions", /* @__PURE__ */ new Map());
78
78
  u(this, "executionQueue", []);
79
79
  u(this, "isProcessing", !1);
80
80
  u(this, "runningByName", /* @__PURE__ */ new Map());
81
81
  u(this, "subscribers", /* @__PURE__ */ new Set());
82
82
  u(this, "getHandler");
83
- this.getHandler = s;
83
+ this.getHandler = r;
84
84
  }
85
- async executeCapability(s, t, e, r, n = "queue") {
86
- if (!this.getHandler(s)) {
87
- console.warn(`No handler registered for capability: ${s}`);
85
+ async executeCapability(r, t, e, s, n = "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
- messageId: r
96
+ messageId: s
97
97
  };
98
98
  switch (this.executions.set(t, o), this.notifySubscribers(t), n) {
99
99
  case "queue":
@@ -106,41 +106,41 @@ class K {
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);
114
- const r = this.runningByName.get(t.name) || [];
115
- r.push(s), this.runningByName.set(t.name, r);
113
+ t.status = { type: "running" }, this.notifySubscribers(r);
114
+ const s = this.runningByName.get(t.name) || [];
115
+ s.push(r), this.runningByName.set(t.name, s);
116
116
  try {
117
117
  const n = await e.execute(t.args, {
118
118
  messageId: t.messageId,
119
- capabilityId: s
119
+ capabilityId: r
120
120
  });
121
121
  t.status = { type: "complete", result: n }, t.result = n;
122
122
  } catch (n) {
123
123
  const a = n instanceof Error ? n.message : "Unknown error";
124
124
  t.status = { type: "error", error: a }, t.error = a;
125
125
  } finally {
126
- const n = this.runningByName.get(t.name) || [], a = n.indexOf(s);
127
- a > -1 && n.splice(a, 1), n.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, n), this.notifySubscribers(s);
126
+ const n = this.runningByName.get(t.name) || [], a = n.indexOf(r);
127
+ a > -1 && n.splice(a, 1), n.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, n), 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
  u(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,14 +196,14 @@ class X extends y {
196
196
  get focusedContentIndex() {
197
197
  return this._state.focusedContentIndex;
198
198
  }
199
- focus(t, e, r, n = "detail") {
199
+ focus(t, e, s, n = "detail") {
200
200
  this._state = {
201
201
  isActive: !0,
202
202
  context: n,
203
203
  focusedContent: t,
204
204
  focusedMessage: e,
205
205
  focusedMessageId: e.id,
206
- focusedContentIndex: r
206
+ focusedContentIndex: s
207
207
  }, this.notifySubscribers();
208
208
  }
209
209
  blur() {
@@ -216,8 +216,8 @@ class X extends y {
216
216
  focusedContentIndex: null
217
217
  }, this.notifySubscribers();
218
218
  }
219
- toggle(t, e, r, n = "detail") {
220
- this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === r && this._state.context === n ? this.blur() : this.focus(t, e, r, n);
219
+ toggle(t, e, s, n = "detail") {
220
+ this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === s && this._state.context === n ? this.blur() : this.focus(t, e, s, n);
221
221
  }
222
222
  switchContext(t) {
223
223
  this._state.isActive && this._state.focusedContent && (this._state = {
@@ -229,10 +229,10 @@ class X 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 r = t[e], n = this._state.focusedContentIndex ?? 0;
233
- if (n + 1 < r.content.length) {
234
- const a = r.content[n + 1];
235
- this.focus(a, r, n + 1, this._state.context || "detail");
232
+ const s = t[e], n = this._state.focusedContentIndex ?? 0;
233
+ if (n + 1 < s.content.length) {
234
+ const a = s.content[n + 1];
235
+ this.focus(a, s, n + 1, this._state.context || "detail");
236
236
  return;
237
237
  }
238
238
  if (e + 1 < t.length) {
@@ -244,10 +244,10 @@ class X 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 r = t[e], n = this._state.focusedContentIndex ?? 0;
247
+ const s = t[e], n = this._state.focusedContentIndex ?? 0;
248
248
  if (n > 0) {
249
- const a = r.content[n - 1];
250
- this.focus(a, r, n - 1, this._state.context || "detail");
249
+ const a = s.content[n - 1];
250
+ this.focus(a, s, n - 1, this._state.context || "detail");
251
251
  return;
252
252
  }
253
253
  if (e > 0) {
@@ -263,7 +263,7 @@ let Z = 0, tt = 0;
263
263
  function F() {
264
264
  return `msg-${Date.now()}-${++Z}`;
265
265
  }
266
- function j() {
266
+ function D() {
267
267
  return `thread-${Date.now()}-${++tt}`;
268
268
  }
269
269
  class I extends y {
@@ -434,8 +434,8 @@ class R extends y {
434
434
  };
435
435
  }
436
436
  updateMessages(t) {
437
- var e, r;
438
- this._messages = t, (r = (e = this.config).onMessagesChange) == null || r.call(e, this._messages), this.notifySubscribers();
437
+ var e, s;
438
+ this._messages = t, (s = (e = this.config).onMessagesChange) == null || s.call(e, this._messages), this.notifySubscribers();
439
439
  }
440
440
  append(t) {
441
441
  const e = {
@@ -453,14 +453,14 @@ class R extends y {
453
453
  if (this._isRunning)
454
454
  throw new Error("A run is already in progress");
455
455
  this.append(t), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
456
- const e = F(), r = {
456
+ const e = F(), s = {
457
457
  id: e,
458
458
  role: "assistant",
459
459
  content: [],
460
460
  status: { type: "running" },
461
461
  timestamp: Date.now()
462
462
  };
463
- this.updateMessages([...this._messages, r]);
463
+ this.updateMessages([...this._messages, s]);
464
464
  try {
465
465
  const n = this.config.streamAdapter.stream({
466
466
  messages: this._messages,
@@ -488,9 +488,9 @@ class R extends y {
488
488
  }
489
489
  }
490
490
  handleStreamEvent(t, e) {
491
- const r = this._messages.findIndex((o) => o.id === t);
492
- if (r === -1) return;
493
- const n = this._messages[r];
491
+ const s = this._messages.findIndex((o) => o.id === t);
492
+ if (s === -1) return;
493
+ const n = this._messages[s];
494
494
  if (e.type === "part-start")
495
495
  this.handlePartStart(n, e);
496
496
  else if (e.type === "text-delta" || e.type === "assistant_thought")
@@ -505,16 +505,25 @@ class R extends y {
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
- const o = e;
509
- n.content = [
510
- ...n.content,
511
- {
512
- type: "capability",
513
- capabilityId: o.capabilityId,
508
+ const o = e, c = {
509
+ type: "capability",
510
+ capabilityId: o.capabilityId,
511
+ capabilityName: o.capabilityName,
512
+ args: o.args
513
+ };
514
+ n.content.push(c);
515
+ const d = o.artifact;
516
+ d && n.content.push({
517
+ type: "artifact",
518
+ data: {
514
519
  capabilityName: o.capabilityName,
515
- args: o.args
520
+ originalArgs: o.args,
521
+ displayData: {
522
+ name: d.displayName,
523
+ type: d.displayType
524
+ }
516
525
  }
517
- ], this.config.capabilityExecutionManager && this.config.capabilityExecutionManager.executeCapability(
526
+ }), this.config.capabilityExecutionManager && this.config.capabilityExecutionManager.executeCapability(
518
527
  o.capabilityName,
519
528
  o.capabilityId,
520
529
  o.args,
@@ -542,14 +551,14 @@ class R extends y {
542
551
  ];
543
552
  }
544
553
  const a = [
545
- ...this._messages.slice(0, r),
554
+ ...this._messages.slice(0, s),
546
555
  { ...n, timestamp: Date.now() },
547
- ...this._messages.slice(r + 1)
556
+ ...this._messages.slice(s + 1)
548
557
  ];
549
558
  this.updateMessages(a);
550
559
  }
551
560
  handlePartStart(t, e) {
552
- const r = t.content.length;
561
+ const s = t.content.length;
553
562
  let n;
554
563
  switch (e.part.type) {
555
564
  case "assistant_thought":
@@ -577,7 +586,7 @@ class R extends y {
577
586
  }
578
587
  t.content = [...t.content, n], this._currentPart = {
579
588
  messageId: t.id,
580
- contentIndex: r,
589
+ contentIndex: s,
581
590
  type: e.part.type,
582
591
  parentId: e.part.parentId
583
592
  };
@@ -587,8 +596,8 @@ class R extends y {
587
596
  console.warn("Received text-delta without part-start");
588
597
  return;
589
598
  }
590
- const r = t.content[this._currentPart.contentIndex];
591
- r.type === "assistant_thought" ? (Array.isArray(r.data) || (r.data = []), e.delta.trim() && r.data.push(e.delta.trim())) : r.data = (r.data || "") + e.delta;
599
+ const s = t.content[this._currentPart.contentIndex];
600
+ s.type === "assistant_thought" ? (Array.isArray(s.data) || (s.data = []), e.delta.trim() && s.data.push(e.delta.trim())) : s.data = (s.data || "") + e.delta;
592
601
  }
593
602
  handlePartFinish() {
594
603
  if (!this._currentPart) {
@@ -597,9 +606,9 @@ class R extends y {
597
606
  }
598
607
  const t = this._messages.findIndex((e) => e.id === this._currentPart.messageId);
599
608
  if (t !== -1) {
600
- const e = this._messages[t], r = e.content[this._currentPart.contentIndex];
601
- if (r) {
602
- r.status = { type: "complete" };
609
+ const e = this._messages[t], s = e.content[this._currentPart.contentIndex];
610
+ if (s) {
611
+ s.status = { type: "complete" };
603
612
  const n = [
604
613
  ...this._messages.slice(0, t),
605
614
  { ...e, timestamp: Date.now() },
@@ -611,32 +620,32 @@ class R extends y {
611
620
  this._currentPart = null;
612
621
  }
613
622
  updateMessageStatus(t, e) {
614
- const r = this._messages.findIndex((a) => a.id === t);
615
- if (r === -1) return;
623
+ const s = this._messages.findIndex((a) => a.id === t);
624
+ if (s === -1) return;
616
625
  const n = [
617
- ...this._messages.slice(0, r),
626
+ ...this._messages.slice(0, s),
618
627
  {
619
- ...this._messages[r],
628
+ ...this._messages[s],
620
629
  status: e
621
630
  },
622
- ...this._messages.slice(r + 1)
631
+ ...this._messages.slice(s + 1)
623
632
  ];
624
633
  this.updateMessages(n);
625
634
  }
626
635
  completeStreamingContent(t) {
627
636
  const e = this._messages.findIndex((c) => c.id === t);
628
637
  if (e === -1) return;
629
- const r = this._messages[e];
630
- if (!r.content.some((c) => {
631
- var l;
632
- return ((l = c.status) == null ? void 0 : l.type) === "streaming";
638
+ const s = this._messages[e];
639
+ if (!s.content.some((c) => {
640
+ var d;
641
+ return ((d = c.status) == null ? void 0 : d.type) === "streaming";
633
642
  })) return;
634
- const a = r.content.map((c) => {
635
- var l;
636
- return ((l = c.status) == null ? void 0 : l.type) === "streaming" ? { ...c, status: { type: "complete" } } : c;
643
+ const a = s.content.map((c) => {
644
+ var d;
645
+ return ((d = c.status) == null ? void 0 : d.type) === "streaming" ? { ...c, status: { type: "complete" } } : c;
637
646
  }), o = [
638
647
  ...this._messages.slice(0, e),
639
- { ...r, content: a, timestamp: Date.now() },
648
+ { ...s, content: a, timestamp: Date.now() },
640
649
  ...this._messages.slice(e + 1)
641
650
  ];
642
651
  this.updateMessages(o);
@@ -668,13 +677,13 @@ class st extends y {
668
677
  u(this, "_searchQuery");
669
678
  u(this, "_abortController", null);
670
679
  u(this, "main");
671
- this.config = t, this._mainThreadId = j();
680
+ this.config = t, this._mainThreadId = D();
672
681
  const e = new R({
673
682
  streamAdapter: t.streamAdapter,
674
683
  capabilityExecutionManager: t.capabilityExecutionManager
675
684
  });
676
685
  this.main = new v(e), this._threads.set(this._mainThreadId, this.main);
677
- const r = {
686
+ const s = {
678
687
  id: this._mainThreadId,
679
688
  title: "New Chat",
680
689
  status: { type: "regular" },
@@ -682,9 +691,9 @@ class st extends y {
682
691
  createdAt: Date.now(),
683
692
  updatedAt: Date.now()
684
693
  };
685
- this._threadStates.set(this._mainThreadId, r);
694
+ this._threadStates.set(this._mainThreadId, s);
686
695
  const n = new I({
687
- state: r,
696
+ state: s,
688
697
  onSwitchTo: this.switchToThread.bind(this),
689
698
  onRename: this.renameThread.bind(this),
690
699
  onDelete: this.deleteThread.bind(this)
@@ -703,8 +712,8 @@ class st extends y {
703
712
  }
704
713
  getState() {
705
714
  const t = [], e = {};
706
- for (const [r, n] of this._threadStates)
707
- e[r] = n, n.status.type === "regular" && t.push(r);
715
+ for (const [s, n] of this._threadStates)
716
+ e[s] = n, n.status.type === "regular" && t.push(s);
708
717
  return {
709
718
  mainThreadId: this._mainThreadId,
710
719
  threads: t,
@@ -718,8 +727,8 @@ class st extends y {
718
727
  const e = this._threads.get(t);
719
728
  if (!e)
720
729
  throw new Error(`Thread ${t} not found`);
721
- const r = this._threadStates.get(this._mainThreadId);
722
- r && (r.isMain = !1, this._threadStates.set(this._mainThreadId, r), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(r)), this._mainThreadId = t;
730
+ const s = this._threadStates.get(this._mainThreadId);
731
+ s && (s.isMain = !1, this._threadStates.set(this._mainThreadId, s), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(s)), this._mainThreadId = t;
723
732
  const n = this._threadStates.get(t);
724
733
  if (n && (n.isMain = !0, this._threadStates.set(t, n), (o = this._threadItems.get(t)) == null || o.updateState(n), e.setConversationId(n.conversationId), e.setTitle(n.title)), this.config.threadListAdapter && (n != null && n.conversationId)) {
725
734
  this._isLoading = !0, this.notifySubscribers();
@@ -735,11 +744,11 @@ class st extends y {
735
744
  this.notifySubscribers();
736
745
  }
737
746
  async switchToNewThread() {
738
- const t = j(), e = new R({
747
+ const t = D(), e = new R({
739
748
  streamAdapter: this.config.streamAdapter,
740
749
  capabilityExecutionManager: this.config.capabilityExecutionManager
741
- }), r = new v(e);
742
- this._threads.set(t, r);
750
+ }), s = new v(e);
751
+ this._threads.set(t, s);
743
752
  const n = {
744
753
  id: t,
745
754
  title: "New Chat",
@@ -755,8 +764,8 @@ class st extends y {
755
764
  onRename: this.renameThread.bind(this),
756
765
  onDelete: this.deleteThread.bind(this)
757
766
  });
758
- if (this._threadItems.set(t, a), r.subscribe(() => {
759
- this.syncThreadStateFromRuntime(t, r), this.notifySubscribers();
767
+ if (this._threadItems.set(t, a), s.subscribe(() => {
768
+ this.syncThreadStateFromRuntime(t, s), this.notifySubscribers();
760
769
  }), this.config.threadListAdapter)
761
770
  try {
762
771
  const o = await this.config.threadListAdapter.createThread();
@@ -771,25 +780,30 @@ class st extends y {
771
780
  return console.warn("No threadListAdapter configured"), [];
772
781
  if (this._isLoading)
773
782
  return [];
774
- this._abortController && this._abortController.abort(), this._abortController = new AbortController(), (t == null ? void 0 : t.query) !== void 0 && (this._searchQuery = t.query), this._isLoading = !0, this.notifySubscribers();
783
+ if (this._abortController && this._abortController.abort(), this._abortController = new AbortController(), (t == null ? void 0 : t.query) !== void 0 && (this._searchQuery = t.query), t != null && t.replace) {
784
+ const e = Array.from(this._threads.keys()).filter((s) => s !== this._mainThreadId);
785
+ for (const s of e)
786
+ this._threads.delete(s), this._threadItems.delete(s), this._threadStates.delete(s);
787
+ }
788
+ this._isLoading = !0, this.notifySubscribers();
775
789
  try {
776
790
  const e = await this.config.threadListAdapter.loadThreads(t);
777
- for (const r of e) {
778
- if (this._threadStates.has(r.id))
791
+ for (const s of e) {
792
+ if (this._threadStates.has(s.id))
779
793
  continue;
780
794
  const n = new R({
781
795
  streamAdapter: this.config.streamAdapter,
782
796
  capabilityExecutionManager: this.config.capabilityExecutionManager
783
797
  }), a = new v(n);
784
- this._threads.set(r.id, a), this._threadStates.set(r.id, r);
798
+ this._threads.set(s.id, a), this._threadStates.set(s.id, s);
785
799
  const o = new I({
786
- state: r,
800
+ state: s,
787
801
  onSwitchTo: this.switchToThread.bind(this),
788
802
  onRename: this.renameThread.bind(this),
789
803
  onDelete: this.deleteThread.bind(this)
790
804
  });
791
- this._threadItems.set(r.id, o), a.subscribe(() => {
792
- this.syncThreadStateFromRuntime(r.id, a), this.notifySubscribers();
805
+ this._threadItems.set(s.id, o), a.subscribe(() => {
806
+ this.syncThreadStateFromRuntime(s.id, a), this.notifySubscribers();
793
807
  });
794
808
  }
795
809
  return e;
@@ -804,14 +818,14 @@ class st extends y {
804
818
  */
805
819
  syncThreadStateFromRuntime(t, e) {
806
820
  var n;
807
- const r = this._threadStates.get(t);
808
- r && (r.conversationId !== e.conversationId || r.title !== e.title) && (r.conversationId = e.conversationId, r.title = e.title || r.title, r.updatedAt = Date.now(), this._threadStates.set(t, r), (n = this._threadItems.get(t)) == null || n.updateState(r));
821
+ const s = this._threadStates.get(t);
822
+ s && (s.conversationId !== e.conversationId || s.title !== e.title) && (s.conversationId = e.conversationId, s.title = e.title || s.title, s.updatedAt = Date.now(), this._threadStates.set(t, s), (n = this._threadItems.get(t)) == null || n.updateState(s));
809
823
  }
810
824
  async renameThread(t, e) {
811
825
  var n;
812
- const r = this._threadStates.get(t);
813
- if (r) {
814
- if (r.title = e, r.updatedAt = Date.now(), this._threadStates.set(t, r), (n = this._threadItems.get(t)) == null || n.updateState(r), this.config.threadListAdapter)
826
+ const s = this._threadStates.get(t);
827
+ if (s) {
828
+ if (s.title = e, s.updatedAt = Date.now(), this._threadStates.set(t, s), (n = this._threadItems.get(t)) == null || n.updateState(s), this.config.threadListAdapter)
815
829
  try {
816
830
  await this.config.threadListAdapter.updateThread(t, { title: e });
817
831
  } catch (a) {
@@ -824,7 +838,7 @@ class st extends y {
824
838
  if (t === this._mainThreadId && this._threads.size === 1)
825
839
  throw new Error("Cannot delete the last thread");
826
840
  if (t === this._mainThreadId) {
827
- const e = Array.from(this._threads.keys()).find((r) => r !== t);
841
+ const e = Array.from(this._threads.keys()).find((s) => s !== t);
828
842
  e && await this.switchToThread(e);
829
843
  }
830
844
  if (this._threads.delete(t), this._threadItems.delete(t), this._threadStates.delete(t), this.config.threadListAdapter)
@@ -897,8 +911,8 @@ class bt extends y {
897
911
  autoFocusLastContent(t) {
898
912
  var e;
899
913
  if (t.length !== 0 && !this._contentFocusRuntime.isActive)
900
- for (let r = t.length - 1; r >= 0; r--) {
901
- const n = t[r];
914
+ for (let s = t.length - 1; s >= 0; s--) {
915
+ const n = t[s];
902
916
  if (n.role === "assistant")
903
917
  for (let a = n.content.length - 1; a >= 0; a--) {
904
918
  const o = n.content[a], c = this.pluginRegistry.getRenderersByType(o.type);
@@ -916,17 +930,17 @@ object-assign
916
930
  (c) Sindre Sorhus
917
931
  @license MIT
918
932
  */
919
- var M, O;
933
+ var M, j;
920
934
  function rt() {
921
- if (O) return M;
922
- O = 1;
923
- var i = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
935
+ if (j) return M;
936
+ j = 1;
937
+ var i = Object.getOwnPropertySymbols, r = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
924
938
  function e(n) {
925
939
  if (n == null)
926
940
  throw new TypeError("Object.assign cannot be called with null or undefined");
927
941
  return Object(n);
928
942
  }
929
- function r() {
943
+ function s() {
930
944
  try {
931
945
  if (!Object.assign)
932
946
  return !1;
@@ -940,23 +954,23 @@ function rt() {
940
954
  });
941
955
  if (c.join("") !== "0123456789")
942
956
  return !1;
943
- var l = {};
957
+ var d = {};
944
958
  return "abcdefghijklmnopqrst".split("").forEach(function(f) {
945
- l[f] = f;
946
- }), Object.keys(Object.assign({}, l)).join("") === "abcdefghijklmnopqrst";
959
+ d[f] = f;
960
+ }), Object.keys(Object.assign({}, d)).join("") === "abcdefghijklmnopqrst";
947
961
  } catch {
948
962
  return !1;
949
963
  }
950
964
  }
951
- return M = r() ? Object.assign : function(n, a) {
952
- for (var o, c = e(n), l, f = 1; f < arguments.length; f++) {
965
+ return M = s() ? Object.assign : function(n, a) {
966
+ for (var o, c = e(n), d, f = 1; f < arguments.length; f++) {
953
967
  o = Object(arguments[f]);
954
968
  for (var h in o)
955
- s.call(o, h) && (c[h] = o[h]);
969
+ r.call(o, h) && (c[h] = o[h]);
956
970
  if (i) {
957
- l = i(o);
958
- for (var d = 0; d < l.length; d++)
959
- t.call(o, l[d]) && (c[l[d]] = o[l[d]]);
971
+ d = i(o);
972
+ for (var l = 0; l < d.length; l++)
973
+ t.call(o, d[l]) && (c[d[l]] = o[d[l]]);
960
974
  }
961
975
  }
962
976
  return c;
@@ -970,33 +984,33 @@ function rt() {
970
984
  * This source code is licensed under the MIT license found in the
971
985
  * LICENSE file in the root directory of this source tree.
972
986
  */
973
- var D;
987
+ var N;
974
988
  function nt() {
975
- if (D) return x;
976
- D = 1, rt();
977
- var i = k, s = 60103;
989
+ if (N) return x;
990
+ N = 1, rt();
991
+ var i = B, r = 60103;
978
992
  if (x.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
979
993
  var t = Symbol.for;
980
- s = t("react.element"), x.Fragment = t("react.fragment");
994
+ r = t("react.element"), x.Fragment = t("react.fragment");
981
995
  }
982
- var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, r = Object.prototype.hasOwnProperty, n = { key: !0, ref: !0, __self: !0, __source: !0 };
983
- function a(o, c, l) {
984
- var f, h = {}, d = null, g = null;
985
- l !== void 0 && (d = "" + l), c.key !== void 0 && (d = "" + c.key), c.ref !== void 0 && (g = c.ref);
986
- for (f in c) r.call(c, f) && !n.hasOwnProperty(f) && (h[f] = c[f]);
996
+ var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = Object.prototype.hasOwnProperty, n = { key: !0, ref: !0, __self: !0, __source: !0 };
997
+ function a(o, c, d) {
998
+ var f, h = {}, l = null, p = null;
999
+ d !== void 0 && (l = "" + d), c.key !== void 0 && (l = "" + c.key), c.ref !== void 0 && (p = c.ref);
1000
+ for (f in c) s.call(c, f) && !n.hasOwnProperty(f) && (h[f] = c[f]);
987
1001
  if (o && o.defaultProps) for (f in c = o.defaultProps, c) h[f] === void 0 && (h[f] = c[f]);
988
- return { $$typeof: s, type: o, key: d, ref: g, props: h, _owner: e.current };
1002
+ return { $$typeof: r, type: o, key: l, ref: p, props: h, _owner: e.current };
989
1003
  }
990
1004
  return x.jsx = a, x.jsxs = a, x;
991
1005
  }
992
- var L;
1006
+ var O;
993
1007
  function it() {
994
- return L || (L = 1, E.exports = nt()), E.exports;
1008
+ return O || (O = 1, E.exports = nt()), E.exports;
995
1009
  }
996
1010
  var S = it();
997
1011
  const $ = q(null);
998
- function yt({ runtime: i, children: s }) {
999
- return /* @__PURE__ */ S.jsx($.Provider, { value: i, children: s });
1012
+ function yt({ runtime: i, children: r }) {
1013
+ return /* @__PURE__ */ S.jsx($.Provider, { value: i, children: r });
1000
1014
  }
1001
1015
  function at() {
1002
1016
  const i = U($);
@@ -1004,36 +1018,36 @@ function at() {
1004
1018
  throw new Error("useAssistantRuntimeContext must be used within AssistantRuntimeProvider");
1005
1019
  return i;
1006
1020
  }
1007
- function p() {
1021
+ function g() {
1008
1022
  return at();
1009
1023
  }
1010
1024
  function _t() {
1011
- const i = p();
1025
+ const i = g();
1012
1026
  return {
1013
- switchToThread: (s) => i.threads.switchToThread(s),
1027
+ switchToThread: (r) => i.threads.switchToThread(r),
1014
1028
  switchToNewThread: () => i.threads.switchToNewThread(),
1015
- loadThreads: (s) => i.threads.loadThreads(s),
1016
- renameThread: (s, t) => {
1017
- var e, r;
1018
- return (r = (e = i.threads).renameThread) == null ? void 0 : r.call(e, s, t);
1029
+ loadThreads: (r) => i.threads.loadThreads(r),
1030
+ renameThread: (r, t) => {
1031
+ var e, s;
1032
+ return (s = (e = i.threads).renameThread) == null ? void 0 : s.call(e, r, t);
1019
1033
  },
1020
- deleteThread: (s) => {
1034
+ deleteThread: (r) => {
1021
1035
  var t, e;
1022
- return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, s);
1036
+ return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, r);
1023
1037
  }
1024
1038
  };
1025
1039
  }
1026
1040
  function xt() {
1027
- const i = p(), [s, t] = b(i.threads.getState());
1041
+ const i = g(), [r, t] = b(i.threads.getState());
1028
1042
  return w(() => i.threads.subscribe(() => {
1029
1043
  t(i.threads.getState());
1030
- }), [i]), s;
1044
+ }), [i]), r;
1031
1045
  }
1032
1046
  function ot() {
1033
- const s = p().threads.getMainThread(), [, t] = b({});
1034
- return w(() => s.subscribe(() => {
1047
+ const r = g().threads.getMainThread(), [, t] = b({});
1048
+ return w(() => r.subscribe(() => {
1035
1049
  t({});
1036
- }), [s]), s;
1050
+ }), [r]), r;
1037
1051
  }
1038
1052
  var A = { exports: {} }, P = {};
1039
1053
  /**
@@ -1045,87 +1059,87 @@ var A = { exports: {} }, P = {};
1045
1059
  * This source code is licensed under the MIT license found in the
1046
1060
  * LICENSE file in the root directory of this source tree.
1047
1061
  */
1048
- var N;
1062
+ var L;
1049
1063
  function ct() {
1050
- if (N) return P;
1051
- N = 1;
1052
- var i = k;
1053
- function s(h, d) {
1054
- return h === d && (h !== 0 || 1 / h === 1 / d) || h !== h && d !== d;
1055
- }
1056
- var t = typeof Object.is == "function" ? Object.is : s, e = i.useState, r = i.useEffect, n = i.useLayoutEffect, a = i.useDebugValue;
1057
- function o(h, d) {
1058
- var g = d(), _ = e({ inst: { value: g, getSnapshot: d } }), m = _[0].inst, T = _[1];
1064
+ if (L) return P;
1065
+ L = 1;
1066
+ var i = B;
1067
+ function r(h, l) {
1068
+ return h === l && (h !== 0 || 1 / h === 1 / l) || h !== h && l !== l;
1069
+ }
1070
+ var t = typeof Object.is == "function" ? Object.is : r, e = i.useState, s = i.useEffect, n = i.useLayoutEffect, a = i.useDebugValue;
1071
+ function o(h, l) {
1072
+ var p = l(), _ = e({ inst: { value: p, getSnapshot: l } }), m = _[0].inst, T = _[1];
1059
1073
  return n(
1060
1074
  function() {
1061
- m.value = g, m.getSnapshot = d, c(m) && T({ inst: m });
1075
+ m.value = p, m.getSnapshot = l, c(m) && T({ inst: m });
1062
1076
  },
1063
- [h, g, d]
1064
- ), r(
1077
+ [h, p, l]
1078
+ ), s(
1065
1079
  function() {
1066
1080
  return c(m) && T({ inst: m }), h(function() {
1067
1081
  c(m) && T({ inst: m });
1068
1082
  });
1069
1083
  },
1070
1084
  [h]
1071
- ), a(g), g;
1085
+ ), a(p), p;
1072
1086
  }
1073
1087
  function c(h) {
1074
- var d = h.getSnapshot;
1088
+ var l = h.getSnapshot;
1075
1089
  h = h.value;
1076
1090
  try {
1077
- var g = d();
1078
- return !t(h, g);
1091
+ var p = l();
1092
+ return !t(h, p);
1079
1093
  } catch {
1080
1094
  return !0;
1081
1095
  }
1082
1096
  }
1083
- function l(h, d) {
1084
- return d();
1097
+ function d(h, l) {
1098
+ return l();
1085
1099
  }
1086
- var f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? l : o;
1100
+ var f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : o;
1087
1101
  return P.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : f, P;
1088
1102
  }
1089
- var B;
1103
+ var k;
1090
1104
  function ut() {
1091
- return B || (B = 1, A.exports = ct()), A.exports;
1105
+ return k || (k = 1, A.exports = ct()), A.exports;
1092
1106
  }
1093
1107
  var ht = ut();
1094
1108
  function St() {
1095
- const i = p();
1109
+ const i = g();
1096
1110
  return ht.useSyncExternalStore(
1097
- (s) => i.subscribe(() => {
1098
- s();
1111
+ (r) => i.subscribe(() => {
1112
+ r();
1099
1113
  }),
1100
1114
  () => i.thread.messages,
1101
1115
  () => i.thread.messages
1102
1116
  );
1103
1117
  }
1104
1118
  function wt() {
1105
- const i = ot(), [s, t] = b(""), [e, r] = b(!1);
1119
+ const i = ot(), [r, t] = b(""), [e, s] = b(!1);
1106
1120
  return {
1107
- text: s,
1121
+ text: r,
1108
1122
  setText: t,
1109
1123
  isSubmitting: e,
1110
1124
  send: async (a) => {
1111
- if (a == null || a.preventDefault(), !s.trim() || e) return;
1112
- const o = s;
1113
- t(""), r(!0);
1125
+ if (a == null || a.preventDefault(), !r.trim() || e) return;
1126
+ const o = r;
1127
+ t(""), s(!0);
1114
1128
  try {
1115
1129
  await i.send(o);
1116
1130
  } catch (c) {
1117
1131
  console.error("Failed to send message:", c), t(o);
1118
1132
  } finally {
1119
- r(!1);
1133
+ s(!1);
1120
1134
  }
1121
1135
  },
1122
1136
  clear: () => t(""),
1123
1137
  append: (a) => t((o) => o + a)
1124
1138
  };
1125
1139
  }
1126
- function Q(i, s) {
1140
+ function Q(i, r) {
1127
1141
  var n, a, o, c;
1128
- const e = p().pluginRegistry.getBestRendererForType(i);
1142
+ const e = g().pluginRegistry.getBestRendererForType(i);
1129
1143
  if (!e)
1130
1144
  return {
1131
1145
  component: null,
@@ -1134,92 +1148,92 @@ function Q(i, s) {
1134
1148
  supportsPreview: !1,
1135
1149
  supportsFullscreen: !1
1136
1150
  };
1137
- const r = s ? (n = e.auxiliary) == null ? void 0 : n[s] : null;
1151
+ const s = r ? (n = e.auxiliary) == null ? void 0 : n[r] : null;
1138
1152
  return {
1139
1153
  component: e.component,
1140
- auxiliaryComponent: r,
1154
+ auxiliaryComponent: s,
1141
1155
  supportsFocus: ((a = e.capabilities) == null ? void 0 : a.supportsFocus) ?? !1,
1142
1156
  supportsPreview: ((o = e.capabilities) == null ? void 0 : o.supportsPreview) ?? !1,
1143
1157
  supportsFullscreen: ((c = e.capabilities) == null ? void 0 : c.supportsFullscreen) ?? !1
1144
1158
  };
1145
1159
  }
1146
1160
  function Ct() {
1147
- const i = p(), [s, t] = b(i.contentFocus.state);
1161
+ const i = g(), [r, t] = b(i.contentFocus.state);
1148
1162
  return w(() => i.contentFocus.subscribe(() => {
1149
1163
  t(i.contentFocus.state);
1150
1164
  }), [i]), {
1151
- ...s,
1152
- focus: (e, r, n, a) => i.contentFocus.focus(e, r, n, a),
1165
+ ...r,
1166
+ focus: (e, s, n, a) => i.contentFocus.focus(e, s, n, a),
1153
1167
  blur: () => i.contentFocus.blur(),
1154
- toggle: (e, r, n, a) => i.contentFocus.toggle(e, r, n, a),
1168
+ toggle: (e, s, n, a) => i.contentFocus.toggle(e, s, n, a),
1155
1169
  switchContext: (e) => i.contentFocus.switchContext(e),
1156
1170
  focusNext: () => i.contentFocus.focusNext(i.thread.messages),
1157
1171
  focusPrevious: () => i.contentFocus.focusPrevious(i.thread.messages)
1158
1172
  };
1159
1173
  }
1160
1174
  function dt(i) {
1161
- const s = p();
1162
- w(() => (i.execute && s.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && s.capabilityRegistry.registerRenderer(i.name, {
1175
+ const r = g();
1176
+ w(() => (i.execute && r.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && r.capabilityRegistry.registerRenderer(i.name, {
1163
1177
  component: i.render
1164
1178
  }), () => {
1165
- s.capabilityRegistry.unregister(i.name);
1166
- }), [i.name, s]);
1179
+ r.capabilityRegistry.unregister(i.name);
1180
+ }), [i.name, r]);
1167
1181
  }
1168
1182
  function lt(i) {
1169
- const s = p(), [t, e] = b(
1170
- () => s.capabilityExecutionManager.getExecution(i)
1171
- ), [, r] = z((n) => n + 1, 0);
1183
+ const r = g(), [t, e] = b(
1184
+ () => r.capabilityExecutionManager.getExecution(i)
1185
+ ), [, s] = z((n) => n + 1, 0);
1172
1186
  return w(() => {
1173
- const n = s.capabilityExecutionManager.getExecution(i);
1174
- return e(n), s.capabilityExecutionManager.subscribe((o) => {
1187
+ const n = r.capabilityExecutionManager.getExecution(i);
1188
+ return e(n), r.capabilityExecutionManager.subscribe((o) => {
1175
1189
  if (o === i) {
1176
- const c = s.capabilityExecutionManager.getExecution(i);
1177
- e(c), r();
1190
+ const c = r.capabilityExecutionManager.getExecution(i);
1191
+ e(c), s();
1178
1192
  }
1179
1193
  });
1180
- }, [i, s]), t;
1194
+ }, [i, r]), t;
1181
1195
  }
1182
1196
  const H = q(void 0);
1183
1197
  function Tt({ children: i }) {
1184
- const [s, t] = b({}), e = C((c, l) => {
1198
+ const [r, t] = b({}), e = C((c, d) => {
1185
1199
  t((f) => {
1186
- if (l === null) {
1187
- const { [c]: h, ...d } = f;
1188
- return d;
1200
+ if (d === null) {
1201
+ const { [c]: h, ...l } = f;
1202
+ return l;
1189
1203
  }
1190
1204
  return {
1191
1205
  ...f,
1192
- [c]: { id: c, ...l }
1206
+ [c]: { id: c, ...d }
1193
1207
  };
1194
1208
  });
1195
- }, []), r = C((c) => {
1196
- t((l) => {
1197
- const { [c]: f, ...h } = l;
1209
+ }, []), s = C((c) => {
1210
+ t((d) => {
1211
+ const { [c]: f, ...h } = d;
1198
1212
  return h;
1199
1213
  });
1200
- }, []), n = C(() => Object.values(s).reduce(
1201
- (c, l) => {
1202
- const f = Object.entries(l.data).reduce(
1203
- (h, [d, g]) => ({
1214
+ }, []), n = C(() => Object.values(r).reduce(
1215
+ (c, d) => {
1216
+ const f = Object.entries(d.data).reduce(
1217
+ (h, [l, p]) => ({
1204
1218
  ...h,
1205
- [d]: typeof g == "string" ? g : JSON.stringify(g)
1219
+ [l]: typeof p == "string" ? p : JSON.stringify(p)
1206
1220
  }),
1207
1221
  {}
1208
1222
  );
1209
1223
  return { ...c, ...f };
1210
1224
  },
1211
1225
  {}
1212
- ), [s]), a = C(() => {
1226
+ ), [r]), a = C(() => {
1213
1227
  t({});
1214
1228
  }, []), o = V(
1215
1229
  () => ({
1216
- contexts: s,
1230
+ contexts: r,
1217
1231
  setContext: e,
1218
- removeContext: r,
1232
+ removeContext: s,
1219
1233
  getContextData: n,
1220
1234
  clearContexts: a
1221
1235
  }),
1222
- [s, e, r, n, a]
1236
+ [r, e, s, n, a]
1223
1237
  );
1224
1238
  return /* @__PURE__ */ S.jsx(H.Provider, { value: o, children: i });
1225
1239
  }
@@ -1230,93 +1244,93 @@ function ft() {
1230
1244
  return i;
1231
1245
  }
1232
1246
  function It(i) {
1233
- const { setContext: s, removeContext: t } = ft(), { id: e = "currentPage", ...r } = i;
1234
- w(() => (s(e, r), () => {
1247
+ const { setContext: r, removeContext: t } = ft(), { id: e = "currentPage", ...s } = i;
1248
+ w(() => (r(e, s), () => {
1235
1249
  t(e);
1236
- }), [e, r.displayName, JSON.stringify(r.data), r.priority, r.icon]);
1250
+ }), [e, s.displayName, JSON.stringify(s.data), s.priority, s.icon]);
1237
1251
  }
1238
- function gt({ message: i, content: s }) {
1239
- const t = p(), e = s, r = lt(e.capabilityId), n = t.capabilityRegistry.getRenderer(e.capabilityName);
1240
- if (!n || !r)
1252
+ function pt({ message: i, content: r }) {
1253
+ const t = g(), e = r, s = lt(e.capabilityId), n = t.capabilityRegistry.getRenderer(e.capabilityName);
1254
+ if (!n || !s)
1241
1255
  return null;
1242
1256
  const a = n.component;
1243
1257
  return /* @__PURE__ */ S.jsx(
1244
1258
  a,
1245
1259
  {
1246
- capabilityName: r.name,
1247
- capabilityId: r.id,
1248
- args: r.args,
1249
- result: r.result,
1250
- status: r.status,
1260
+ capabilityName: s.name,
1261
+ capabilityId: s.id,
1262
+ args: s.args,
1263
+ result: s.result,
1264
+ status: s.status,
1251
1265
  message: i
1252
1266
  }
1253
1267
  );
1254
1268
  }
1255
- function vt({ message: i, content: s }) {
1256
- const { component: t } = Q(s.type);
1257
- if (s.type === "capability")
1258
- return /* @__PURE__ */ S.jsx(gt, { message: i, content: s });
1269
+ function vt({ message: i, content: r }) {
1270
+ const { component: t } = Q(r.type);
1271
+ if (r.type === "capability")
1272
+ return /* @__PURE__ */ S.jsx(pt, { message: i, content: r });
1259
1273
  if (!t)
1260
1274
  return null;
1261
1275
  const e = t;
1262
- return /* @__PURE__ */ S.jsx(e, { content: s, message: i });
1276
+ return /* @__PURE__ */ S.jsx(e, { content: r, message: i });
1263
1277
  }
1264
1278
  function Rt({
1265
1279
  message: i,
1266
- content: s,
1280
+ content: r,
1267
1281
  context: t,
1268
1282
  onClose: e,
1269
- onNavigate: r,
1283
+ onNavigate: s,
1270
1284
  onSwitchContext: n
1271
1285
  }) {
1272
- const { auxiliaryComponent: a } = Q(s.type, t);
1286
+ const { auxiliaryComponent: a } = Q(r.type, t);
1273
1287
  if (!a)
1274
1288
  return null;
1275
1289
  const o = a;
1276
1290
  return /* @__PURE__ */ S.jsx(
1277
1291
  o,
1278
1292
  {
1279
- content: s,
1293
+ content: r,
1280
1294
  message: i,
1281
1295
  context: t,
1282
1296
  onClose: e,
1283
- onNavigate: r,
1297
+ onNavigate: s,
1284
1298
  onSwitchContext: n
1285
1299
  }
1286
1300
  );
1287
1301
  }
1288
1302
  function Et(i) {
1289
- const s = () => (dt(i), null);
1290
- return s.displayName = `Capability(${i.name})`, s;
1303
+ const r = () => (dt(i), null);
1304
+ return r.displayName = `Capability(${i.name})`, r;
1291
1305
  }
1292
1306
  class Mt {
1293
1307
  getAllowedEvents() {
1294
1308
  return null;
1295
1309
  }
1296
- shouldProcessEvent(s) {
1310
+ shouldProcessEvent(r) {
1297
1311
  const t = this.getAllowedEvents();
1298
- return t ? t.includes(s) : !0;
1312
+ return t ? t.includes(r) : !0;
1299
1313
  }
1300
- async *stream(s) {
1301
- const { signal: t } = s, { url: e, options: r } = this.prepareRequest(s), n = await fetch(e, { ...r, signal: t });
1314
+ async *stream(r) {
1315
+ const { signal: t } = r, { url: e, options: s } = this.prepareRequest(r), n = await fetch(e, { ...s, signal: t });
1302
1316
  if (!n.ok)
1303
1317
  throw new Error(`HTTP error! status: ${n.status}`);
1304
1318
  if (!n.body)
1305
1319
  throw new Error("Response body is null");
1306
1320
  yield* this.parseSSEStream(n.body, t);
1307
1321
  }
1308
- async *parseSSEStream(s, t) {
1309
- const e = s.getReader(), r = new TextDecoder();
1322
+ async *parseSSEStream(r, t) {
1323
+ const e = r.getReader(), s = new TextDecoder();
1310
1324
  let n = "", a = null;
1311
1325
  try {
1312
1326
  for (; ; ) {
1313
1327
  const { done: o, value: c } = await e.read();
1314
1328
  if (o || t != null && t.aborted) break;
1315
- n += r.decode(c, { stream: !0 });
1316
- const l = n.split(`
1329
+ n += s.decode(c, { stream: !0 });
1330
+ const d = n.split(`
1317
1331
  `);
1318
- n = l.pop() || "";
1319
- for (const f of l) {
1332
+ n = d.pop() || "";
1333
+ for (const f of d) {
1320
1334
  const h = f.trim();
1321
1335
  if (!h) {
1322
1336
  a = null;
@@ -1328,15 +1342,15 @@ class Mt {
1328
1342
  continue;
1329
1343
  }
1330
1344
  if (h.startsWith("data:")) {
1331
- const d = h.substring(5).trim();
1332
- if (d === "eof" || h === "eof")
1345
+ const l = h.substring(5).trim();
1346
+ if (l === "eof" || h === "eof")
1333
1347
  break;
1334
1348
  try {
1335
- const g = JSON.parse(d);
1349
+ const p = JSON.parse(l);
1336
1350
  if (a && this.shouldProcessEvent(a)) {
1337
1351
  const _ = this.convertEvent({
1338
1352
  event: a,
1339
- data: g
1353
+ data: p
1340
1354
  });
1341
1355
  _ && (yield _);
1342
1356
  }
@@ -1359,7 +1373,7 @@ export {
1359
1373
  Mt as BaseSSEStreamAdapter,
1360
1374
  K as CapabilityExecutionManager,
1361
1375
  Y as CapabilityRegistry,
1362
- gt as CapabilityRendererComp,
1376
+ pt as CapabilityRendererComp,
1363
1377
  Tt as ChatContextProvider,
1364
1378
  et as ComposerRuntime,
1365
1379
  vt as ContentRenderer,
@@ -1368,8 +1382,9 @@ export {
1368
1382
  st as ThreadListRuntime,
1369
1383
  v as ThreadRuntime,
1370
1384
  R as ThreadRuntimeCore,
1385
+ F as generateMessageId,
1371
1386
  Et as makeCapability,
1372
- p as useAssistantRuntime,
1387
+ g as useAssistantRuntime,
1373
1388
  dt as useCapability,
1374
1389
  lt as useCapabilityExecution,
1375
1390
  ft as useChatContext,