@harnessio/ai-chat-core 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var $ = Object.defineProperty;
2
- var U = (i, s, e) => s in i ? $(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e;
3
- var c = (i, s, e) => U(i, typeof s != "symbol" ? s + "" : s, e);
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);
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() {
@@ -8,16 +8,16 @@ class W {
8
8
  c(this, "renderersByType", /* @__PURE__ */ new Map());
9
9
  }
10
10
  registerPlugin(s) {
11
- this.plugins.has(s.id), this.plugins.set(s.id, s), s.renderers.forEach((e) => {
12
- const t = this.renderersByType.get(e.type) || [];
13
- t.push(e), t.sort((n, r) => ((r == null ? void 0 : r.priority) ?? 0) - ((n == null ? void 0 : n.priority) ?? 0)), this.renderersByType.set(e.type, t);
11
+ this.plugins.has(s.id), this.plugins.set(s.id, s), s.renderers.forEach((t) => {
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);
14
14
  });
15
15
  }
16
16
  unregisterPlugin(s) {
17
- const e = this.plugins.get(s);
18
- return e ? (e.renderers.forEach((t) => {
19
- const r = (this.renderersByType.get(t.type) || []).filter((a) => !e.renderers.includes(a));
20
- r.length === 0 ? this.renderersByType.delete(t.type) : this.renderersByType.set(t.type, r);
17
+ const t = this.plugins.get(s);
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
21
  }), this.plugins.delete(s)) : !1;
22
22
  }
23
23
  getPlugin(s) {
@@ -41,11 +41,11 @@ class z {
41
41
  c(this, "handlers", /* @__PURE__ */ new Map());
42
42
  c(this, "renderers", /* @__PURE__ */ new Map());
43
43
  }
44
- registerHandler(s, e) {
45
- this.handlers.set(s, e);
44
+ registerHandler(s, t) {
45
+ this.handlers.set(s, t);
46
46
  }
47
- registerRenderer(s, e) {
48
- this.renderers.set(s, e);
47
+ registerRenderer(s, t) {
48
+ this.renderers.set(s, t);
49
49
  }
50
50
  unregister(s) {
51
51
  this.handlers.delete(s), this.renderers.delete(s);
@@ -82,23 +82,23 @@ class V {
82
82
  c(this, "getHandler");
83
83
  this.getHandler = s;
84
84
  }
85
- async executeCapability(s, e, t, n, r = "queue") {
85
+ async executeCapability(s, t, e, n, r = "queue") {
86
86
  if (!this.getHandler(s)) {
87
87
  console.warn(`No handler registered for capability: ${s}`);
88
88
  return;
89
89
  }
90
90
  const o = {
91
- id: e,
91
+ id: t,
92
92
  name: s,
93
- args: t,
93
+ args: e,
94
94
  status: { type: "queued" },
95
95
  timestamp: Date.now(),
96
96
  messageId: n
97
97
  };
98
- switch (this.executions.set(e, o), this.notifySubscribers(e), r) {
98
+ switch (this.executions.set(t, o), this.notifySubscribers(t), r) {
99
99
  case "queue":
100
100
  default:
101
- this.executionQueue.push(e);
101
+ this.executionQueue.push(t);
102
102
  break;
103
103
  }
104
104
  this.isProcessing || this.processQueue();
@@ -106,25 +106,25 @@ 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(), e = this.executions.get(s);
110
- if (!e) continue;
111
- const t = this.getHandler(e.name);
109
+ const s = this.executionQueue.shift(), t = this.executions.get(s);
112
110
  if (!t) continue;
113
- e.status = { type: "running" }, this.notifySubscribers(s);
114
- const n = this.runningByName.get(e.name) || [];
115
- n.push(s), this.runningByName.set(e.name, n);
111
+ const e = this.getHandler(t.name);
112
+ if (!e) continue;
113
+ t.status = { type: "running" }, this.notifySubscribers(s);
114
+ const n = this.runningByName.get(t.name) || [];
115
+ n.push(s), this.runningByName.set(t.name, n);
116
116
  try {
117
- const r = await t.execute(e.args, {
118
- messageId: e.messageId,
117
+ const r = await e.execute(t.args, {
118
+ messageId: t.messageId,
119
119
  capabilityId: s
120
120
  });
121
- e.status = { type: "complete", result: r }, e.result = r;
121
+ t.status = { type: "complete", result: r }, t.result = r;
122
122
  } catch (r) {
123
123
  const a = r instanceof Error ? r.message : "Unknown error";
124
- e.status = { type: "error", error: a }, e.error = a;
124
+ t.status = { type: "error", error: a }, t.error = a;
125
125
  } finally {
126
- const r = this.runningByName.get(e.name) || [], a = r.indexOf(s);
127
- a > -1 && r.splice(a, 1), r.length === 0 ? this.runningByName.delete(e.name) : this.runningByName.set(e.name, r), this.notifySubscribers(s);
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);
128
128
  }
129
129
  }
130
130
  this.isProcessing = !1;
@@ -134,13 +134,13 @@ class V {
134
134
  return this.executions.get(s);
135
135
  }
136
136
  getExecutionsByMessage(s) {
137
- return Array.from(this.executions.values()).filter((e) => e.messageId === s);
137
+ return Array.from(this.executions.values()).filter((t) => t.messageId === s);
138
138
  }
139
139
  subscribe(s) {
140
140
  return this.subscribers.add(s), () => this.subscribers.delete(s);
141
141
  }
142
142
  notifySubscribers(s) {
143
- this.subscribers.forEach((e) => e(s));
143
+ this.subscribers.forEach((t) => t(s));
144
144
  }
145
145
  clear() {
146
146
  this.executions.clear(), this.executionQueue = [], this.runningByName.clear();
@@ -196,13 +196,13 @@ class G extends y {
196
196
  get focusedContentIndex() {
197
197
  return this._state.focusedContentIndex;
198
198
  }
199
- focus(e, t, n, r = "detail") {
199
+ focus(t, e, n, r = "detail") {
200
200
  this._state = {
201
201
  isActive: !0,
202
202
  context: r,
203
- focusedContent: e,
204
- focusedMessage: t,
205
- focusedMessageId: t.id,
203
+ focusedContent: t,
204
+ focusedMessage: e,
205
+ focusedMessageId: e.id,
206
206
  focusedContentIndex: n
207
207
  }, this.notifySubscribers();
208
208
  }
@@ -216,42 +216,42 @@ class G extends y {
216
216
  focusedContentIndex: null
217
217
  }, this.notifySubscribers();
218
218
  }
219
- toggle(e, t, n, r = "detail") {
220
- this._state.isActive && this._state.focusedMessageId === t.id && this._state.focusedContentIndex === n && this._state.context === r ? this.blur() : this.focus(e, t, n, r);
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);
221
221
  }
222
- switchContext(e) {
222
+ switchContext(t) {
223
223
  this._state.isActive && this._state.focusedContent && (this._state = {
224
224
  ...this._state,
225
- context: e
225
+ context: t
226
226
  }, this.notifySubscribers());
227
227
  }
228
- focusNext(e) {
229
- if (!this._state.focusedMessageId || !e.length) return;
230
- const t = e.findIndex((a) => a.id === this._state.focusedMessageId);
231
- if (t === -1) return;
232
- const n = e[t], r = this._state.focusedContentIndex ?? 0;
228
+ focusNext(t) {
229
+ if (!this._state.focusedMessageId || !t.length) return;
230
+ const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
231
+ if (e === -1) return;
232
+ const n = t[e], r = this._state.focusedContentIndex ?? 0;
233
233
  if (r + 1 < n.content.length) {
234
234
  const a = n.content[r + 1];
235
235
  this.focus(a, n, r + 1, this._state.context || "detail");
236
236
  return;
237
237
  }
238
- if (t + 1 < e.length) {
239
- const a = e[t + 1];
238
+ if (e + 1 < t.length) {
239
+ const a = t[e + 1];
240
240
  a.content.length > 0 && this.focus(a.content[0], a, 0, this._state.context || "detail");
241
241
  }
242
242
  }
243
- focusPrevious(e) {
244
- if (!this._state.focusedMessageId || !e.length) return;
245
- const t = e.findIndex((a) => a.id === this._state.focusedMessageId);
246
- if (t === -1) return;
247
- const n = e[t], r = this._state.focusedContentIndex ?? 0;
243
+ focusPrevious(t) {
244
+ if (!this._state.focusedMessageId || !t.length) return;
245
+ const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
246
+ if (e === -1) return;
247
+ const n = t[e], r = this._state.focusedContentIndex ?? 0;
248
248
  if (r > 0) {
249
249
  const a = n.content[r - 1];
250
250
  this.focus(a, n, r - 1, this._state.context || "detail");
251
251
  return;
252
252
  }
253
- if (t > 0) {
254
- const a = e[t - 1];
253
+ if (e > 0) {
254
+ const a = t[e - 1];
255
255
  if (a.content.length > 0) {
256
256
  const o = a.content.length - 1;
257
257
  this.focus(a.content[o], a, o, this._state.context || "detail");
@@ -266,11 +266,11 @@ function P() {
266
266
  function F() {
267
267
  return `thread-${Date.now()}-${++K}`;
268
268
  }
269
- class R extends y {
270
- constructor(e) {
269
+ class I extends y {
270
+ constructor(t) {
271
271
  super();
272
272
  c(this, "_state");
273
- this.config = e, this._state = e.state;
273
+ this.config = t, this._state = t.state;
274
274
  }
275
275
  get state() {
276
276
  return this._state;
@@ -278,20 +278,20 @@ class R extends y {
278
278
  getState() {
279
279
  return this._state;
280
280
  }
281
- updateState(e) {
282
- this._state = e, this.notifySubscribers();
281
+ updateState(t) {
282
+ this._state = t, this.notifySubscribers();
283
283
  }
284
284
  async switchTo() {
285
285
  await this.config.onSwitchTo(this._state.id);
286
286
  }
287
- async rename(e) {
288
- await this.config.onRename(this._state.id, e);
287
+ async rename(t) {
288
+ await this.config.onRename(this._state.id, t);
289
289
  }
290
290
  async delete() {
291
291
  await this.config.onDelete(this._state.id);
292
292
  }
293
- subscribe(e) {
294
- return super.subscribe(e);
293
+ subscribe(t) {
294
+ return super.subscribe(t);
295
295
  }
296
296
  }
297
297
  class X extends y {
@@ -312,21 +312,21 @@ class X extends y {
312
312
  isSubmitting: this._isSubmitting
313
313
  };
314
314
  }
315
- setText(e) {
316
- this._text = e, this.notifySubscribers();
315
+ setText(t) {
316
+ this._text = t, this.notifySubscribers();
317
317
  }
318
318
  clear() {
319
319
  this._text = "", this.notifySubscribers();
320
320
  }
321
- setSubmitting(e) {
322
- this._isSubmitting = e, this.notifySubscribers();
321
+ setSubmitting(t) {
322
+ this._isSubmitting = t, this.notifySubscribers();
323
323
  }
324
324
  }
325
- class C extends y {
326
- constructor(e) {
325
+ class R extends y {
326
+ constructor(t) {
327
327
  super();
328
328
  c(this, "composer");
329
- this._core = e, this.composer = new X(), this._core.subscribe(() => {
329
+ this._core = t, this.composer = new X(), this._core.subscribe(() => {
330
330
  this.notifySubscribers();
331
331
  });
332
332
  }
@@ -342,25 +342,33 @@ class C extends y {
342
342
  get capabilities() {
343
343
  return this._core.capabilities;
344
344
  }
345
+ get conversationId() {
346
+ return this._core.conversationId;
347
+ }
348
+ get title() {
349
+ return this._core.title;
350
+ }
345
351
  getState() {
346
352
  return {
347
353
  threadId: "main",
348
354
  // Will be set by ThreadListRuntime
349
355
  isDisabled: this._core.isDisabled,
350
356
  isRunning: this._core.isRunning,
351
- capabilities: this._core.capabilities
357
+ capabilities: this._core.capabilities,
358
+ conversationId: this._core.conversationId,
359
+ title: this._core.title
352
360
  };
353
361
  }
354
- append(e) {
355
- this._core.append(e);
362
+ append(t) {
363
+ this._core.append(t);
356
364
  }
357
- async send(e) {
358
- if (e.trim()) {
365
+ async send(t) {
366
+ if (t.trim()) {
359
367
  this.composer.setSubmitting(!0);
360
368
  try {
361
369
  this.composer.clear(), await this._core.startRun({
362
370
  role: "user",
363
- content: [{ type: "text", data: e }]
371
+ content: [{ type: "text", data: t }]
364
372
  });
365
373
  } catch {
366
374
  } finally {
@@ -374,23 +382,25 @@ class C extends y {
374
382
  clear() {
375
383
  this._core.clear();
376
384
  }
377
- reset(e = []) {
378
- this._core.reset(e);
385
+ reset(t = []) {
386
+ this._core.reset(t);
379
387
  }
380
- subscribe(e) {
381
- return super.subscribe(e);
388
+ subscribe(t) {
389
+ return super.subscribe(t);
382
390
  }
383
391
  }
384
- class E extends y {
385
- constructor(e) {
392
+ class v extends y {
393
+ constructor(t) {
386
394
  super();
387
395
  c(this, "_messages", []);
388
396
  c(this, "_isRunning", !1);
389
397
  c(this, "_isDisabled", !1);
390
398
  c(this, "_abortController", null);
399
+ c(this, "_conversationId");
400
+ c(this, "_title");
391
401
  // Track current part being accumulated
392
402
  c(this, "_currentPart", null);
393
- this.config = e, e.initialMessages && (this._messages = [...e.initialMessages]);
403
+ this.config = t, t.initialMessages && (this._messages = [...t.initialMessages]);
394
404
  }
395
405
  get messages() {
396
406
  return this._messages;
@@ -401,6 +411,12 @@ class E extends y {
401
411
  get isDisabled() {
402
412
  return this._isDisabled;
403
413
  }
414
+ get conversationId() {
415
+ return this._conversationId;
416
+ }
417
+ get title() {
418
+ return this._title;
419
+ }
404
420
  get capabilities() {
405
421
  return {
406
422
  cancel: !0,
@@ -411,28 +427,28 @@ class E extends y {
411
427
  feedback: !1
412
428
  };
413
429
  }
414
- updateMessages(e) {
415
- var t, n;
416
- this._messages = e, (n = (t = this.config).onMessagesChange) == null || n.call(t, this._messages), this.notifySubscribers();
417
- }
418
- append(e) {
419
- const t = {
420
- id: e.id || P(),
421
- parentId: e.parentId,
422
- role: e.role,
423
- content: e.content,
424
- status: e.status || { type: "complete" },
425
- timestamp: e.timestamp || Date.now(),
426
- metadata: e.metadata
430
+ updateMessages(t) {
431
+ var e, n;
432
+ this._messages = t, (n = (e = this.config).onMessagesChange) == null || n.call(e, this._messages), this.notifySubscribers();
433
+ }
434
+ append(t) {
435
+ const e = {
436
+ id: t.id || P(),
437
+ parentId: t.parentId,
438
+ role: t.role,
439
+ content: t.content,
440
+ status: t.status || { type: "complete" },
441
+ timestamp: t.timestamp || Date.now(),
442
+ metadata: t.metadata
427
443
  };
428
- this.updateMessages([...this._messages, t]);
444
+ this.updateMessages([...this._messages, e]);
429
445
  }
430
- async startRun(e) {
446
+ async startRun(t) {
431
447
  if (this._isRunning)
432
448
  throw new Error("A run is already in progress");
433
- this.append(e), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
434
- const t = P(), n = {
435
- id: t,
449
+ this.append(t), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
450
+ const e = P(), n = {
451
+ id: e,
436
452
  role: "assistant",
437
453
  content: [],
438
454
  status: { type: "running" },
@@ -442,20 +458,21 @@ class E extends y {
442
458
  try {
443
459
  const r = this.config.streamAdapter.stream({
444
460
  messages: this._messages,
461
+ conversationId: this._conversationId,
445
462
  signal: this._abortController.signal
446
463
  });
447
464
  for await (const a of r) {
448
465
  if (this._abortController.signal.aborted)
449
466
  break;
450
- this.handleStreamEvent(t, a.event);
467
+ this.handleStreamEvent(e, a.event);
451
468
  }
452
- this.updateMessageStatus(t, { type: "complete" });
469
+ this.updateMessageStatus(e, { type: "complete" });
453
470
  } catch (r) {
454
471
  if (r instanceof Error && r.name === "AbortError")
455
- this.updateMessageStatus(t, { type: "cancelled" });
472
+ this.updateMessageStatus(e, { type: "cancelled" });
456
473
  else {
457
474
  const a = r instanceof Error ? r.message : "Unknown error";
458
- this.updateMessageStatus(t, {
475
+ this.updateMessageStatus(e, {
459
476
  type: "error",
460
477
  error: a
461
478
  });
@@ -464,25 +481,25 @@ class E extends y {
464
481
  this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers();
465
482
  }
466
483
  }
467
- handleStreamEvent(e, t) {
468
- const n = this._messages.findIndex((o) => o.id === e);
484
+ handleStreamEvent(t, e) {
485
+ const n = this._messages.findIndex((o) => o.id === t);
469
486
  if (n === -1) return;
470
487
  const r = this._messages[n];
471
- if (t.type === "part-start")
472
- this.handlePartStart(r, t);
473
- else if (t.type === "text-delta" || t.type === "assistant_thought")
474
- this.handleTextDelta(r, t);
475
- else if (t.type === "part-finish")
488
+ if (e.type === "part-start")
489
+ this.handlePartStart(r, e);
490
+ else if (e.type === "text-delta" || e.type === "assistant_thought")
491
+ this.handleTextDelta(r, e);
492
+ else if (e.type === "part-finish")
476
493
  this.handlePartFinish();
477
- else if (t.type === "metadata") {
478
- const o = t;
494
+ else if (e.type === "metadata") {
495
+ const o = e;
479
496
  r.metadata = {
480
497
  ...r.metadata,
481
498
  conversationId: o.conversationId,
482
499
  interactionId: o.interactionId
483
- };
484
- } else if (t.type === "capability_execution") {
485
- const o = t;
500
+ }, o.conversationId && !this._conversationId && (this._conversationId = o.conversationId), o.title && !this._title && (this._title = o.title);
501
+ } else if (e.type === "capability_execution") {
502
+ const o = e;
486
503
  r.content = [
487
504
  ...r.content,
488
505
  {
@@ -495,11 +512,11 @@ class E extends y {
495
512
  o.capabilityName,
496
513
  o.capabilityId,
497
514
  o.args,
498
- e,
515
+ t,
499
516
  o.strategy
500
517
  );
501
- } else if (t.type === "error") {
502
- const o = t;
518
+ } else if (e.type === "error") {
519
+ const o = e;
503
520
  r.content = [
504
521
  ...r.content,
505
522
  {
@@ -508,7 +525,7 @@ class E extends y {
508
525
  }
509
526
  ];
510
527
  } else {
511
- const o = t;
528
+ const o = e;
512
529
  r.content = [
513
530
  ...r.content,
514
531
  {
@@ -525,44 +542,44 @@ class E extends y {
525
542
  ];
526
543
  this.updateMessages(a);
527
544
  }
528
- handlePartStart(e, t) {
529
- const n = e.content.length;
545
+ handlePartStart(t, e) {
546
+ const n = t.content.length;
530
547
  let r;
531
- switch (t.part.type) {
548
+ switch (e.part.type) {
532
549
  case "assistant_thought":
533
550
  r = {
534
- type: t.part.type,
551
+ type: e.part.type,
535
552
  data: [],
536
- parentId: t.part.parentId
553
+ parentId: e.part.parentId
537
554
  };
538
555
  break;
539
556
  case "text":
540
557
  r = {
541
- type: t.part.type,
558
+ type: e.part.type,
542
559
  data: "",
543
- parentId: t.part.parentId
560
+ parentId: e.part.parentId
544
561
  };
545
562
  break;
546
563
  default:
547
564
  r = {
548
- type: t.part.type,
549
- parentId: t.part.parentId
565
+ type: e.part.type,
566
+ parentId: e.part.parentId
550
567
  };
551
568
  }
552
- e.content = [...e.content, r], this._currentPart = {
553
- messageId: e.id,
569
+ t.content = [...t.content, r], this._currentPart = {
570
+ messageId: t.id,
554
571
  contentIndex: n,
555
- type: t.part.type,
556
- parentId: t.part.parentId
572
+ type: e.part.type,
573
+ parentId: e.part.parentId
557
574
  };
558
575
  }
559
- handleTextDelta(e, t) {
576
+ handleTextDelta(t, e) {
560
577
  if (!this._currentPart) {
561
578
  console.warn("Received text-delta without part-start");
562
579
  return;
563
580
  }
564
- const n = e.content[this._currentPart.contentIndex];
565
- n.type === "assistant_thought" ? (Array.isArray(n.data) || (n.data = []), t.delta.trim() && n.data.push(t.delta.trim())) : n.data = (n.data || "") + t.delta;
581
+ const n = t.content[this._currentPart.contentIndex];
582
+ n.type === "assistant_thought" ? (Array.isArray(n.data) || (n.data = []), e.delta.trim() && n.data.push(e.delta.trim())) : n.data = (n.data || "") + e.delta;
566
583
  }
567
584
  handlePartFinish() {
568
585
  if (!this._currentPart) {
@@ -571,14 +588,14 @@ class E extends y {
571
588
  }
572
589
  this._currentPart = null;
573
590
  }
574
- updateMessageStatus(e, t) {
575
- const n = this._messages.findIndex((a) => a.id === e);
591
+ updateMessageStatus(t, e) {
592
+ const n = this._messages.findIndex((a) => a.id === t);
576
593
  if (n === -1) return;
577
594
  const r = [
578
595
  ...this._messages.slice(0, n),
579
596
  {
580
597
  ...this._messages[n],
581
- status: t
598
+ status: e
582
599
  },
583
600
  ...this._messages.slice(n + 1)
584
601
  ];
@@ -590,12 +607,12 @@ class E extends y {
590
607
  cancelRun() {
591
608
  !this._isRunning || !this._abortController || this._abortController.abort();
592
609
  }
593
- reset(e = []) {
594
- this.updateMessages([...e]);
610
+ reset(t = []) {
611
+ this.updateMessages([...t]);
595
612
  }
596
613
  }
597
614
  class Z extends y {
598
- constructor(e) {
615
+ constructor(t) {
599
616
  super();
600
617
  c(this, "_mainThreadId");
601
618
  c(this, "_threads", /* @__PURE__ */ new Map());
@@ -603,12 +620,12 @@ class Z extends y {
603
620
  c(this, "_threadStates", /* @__PURE__ */ new Map());
604
621
  c(this, "_isLoading", !1);
605
622
  c(this, "main");
606
- this.config = e, this._mainThreadId = F();
607
- const t = new E({
608
- streamAdapter: e.streamAdapter,
609
- capabilityExecutionManager: e.capabilityExecutionManager
623
+ this.config = t, this._mainThreadId = F();
624
+ const e = new v({
625
+ streamAdapter: t.streamAdapter,
626
+ capabilityExecutionManager: t.capabilityExecutionManager
610
627
  });
611
- this.main = new C(t), this._threads.set(this._mainThreadId, this.main);
628
+ this.main = new R(e), this._threads.set(this._mainThreadId, this.main);
612
629
  const n = {
613
630
  id: this._mainThreadId,
614
631
  title: "New Chat",
@@ -618,7 +635,7 @@ class Z extends y {
618
635
  updatedAt: Date.now()
619
636
  };
620
637
  this._threadStates.set(this._mainThreadId, n);
621
- const r = new R({
638
+ const r = new I({
622
639
  state: n,
623
640
  onSwitchTo: this.switchToThread.bind(this),
624
641
  onRename: this.renameThread.bind(this),
@@ -633,33 +650,33 @@ class Z extends y {
633
650
  * Get the currently active main thread
634
651
  */
635
652
  getMainThread() {
636
- const e = this._threads.get(this._mainThreadId);
637
- return e || this.main;
653
+ const t = this._threads.get(this._mainThreadId);
654
+ return t || this.main;
638
655
  }
639
656
  getState() {
640
- const e = [], t = {};
657
+ const t = [], e = {};
641
658
  for (const [n, r] of this._threadStates)
642
- t[n] = r, r.status.type === "regular" && e.push(n);
659
+ e[n] = r, r.status.type === "regular" && t.push(n);
643
660
  return {
644
661
  mainThreadId: this._mainThreadId,
645
- threads: e,
662
+ threads: t,
646
663
  isLoading: this._isLoading,
647
- threadItems: t
664
+ threadItems: e
648
665
  };
649
666
  }
650
- async switchToThread(e) {
667
+ async switchToThread(t) {
651
668
  var a, o;
652
- const t = this._threads.get(e);
653
- if (!t)
654
- throw new Error(`Thread ${e} not found`);
669
+ const e = this._threads.get(t);
670
+ if (!e)
671
+ throw new Error(`Thread ${t} not found`);
655
672
  const n = this._threadStates.get(this._mainThreadId);
656
- n && (n.isMain = !1, this._threadStates.set(this._mainThreadId, n), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(n)), this._mainThreadId = e;
657
- const r = this._threadStates.get(e);
658
- if (r && (r.isMain = !0, this._threadStates.set(e, r), (o = this._threadItems.get(e)) == null || o.updateState(r)), this.config.threadListAdapter && (r != null && r.conversationId)) {
673
+ n && (n.isMain = !1, this._threadStates.set(this._mainThreadId, n), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(n)), this._mainThreadId = t;
674
+ const r = this._threadStates.get(t);
675
+ if (r && (r.isMain = !0, this._threadStates.set(t, r), (o = this._threadItems.get(t)) == null || o.updateState(r)), this.config.threadListAdapter && (r != null && r.conversationId)) {
659
676
  this._isLoading = !0, this.notifySubscribers();
660
677
  try {
661
- const u = await this.config.threadListAdapter.loadThread(e);
662
- t.reset(u);
678
+ const u = await this.config.threadListAdapter.loadThread(t);
679
+ e.reset(u);
663
680
  } catch (u) {
664
681
  console.error("Failed to load thread:", u);
665
682
  } finally {
@@ -669,36 +686,36 @@ class Z extends y {
669
686
  this.notifySubscribers();
670
687
  }
671
688
  async switchToNewThread() {
672
- const e = F(), t = new E({
689
+ const t = F(), e = new v({
673
690
  streamAdapter: this.config.streamAdapter,
674
691
  capabilityExecutionManager: this.config.capabilityExecutionManager
675
- }), n = new C(t);
676
- this._threads.set(e, n);
692
+ }), n = new R(e);
693
+ this._threads.set(t, n);
677
694
  const r = {
678
- id: e,
695
+ id: t,
679
696
  title: "New Chat",
680
697
  status: { type: "regular" },
681
698
  isMain: !1,
682
699
  createdAt: Date.now(),
683
700
  updatedAt: Date.now()
684
701
  };
685
- this._threadStates.set(e, r);
686
- const a = new R({
702
+ this._threadStates.set(t, r);
703
+ const a = new I({
687
704
  state: r,
688
705
  onSwitchTo: this.switchToThread.bind(this),
689
706
  onRename: this.renameThread.bind(this),
690
707
  onDelete: this.deleteThread.bind(this)
691
708
  });
692
- if (this._threadItems.set(e, a), n.subscribe(() => {
709
+ if (this._threadItems.set(t, a), n.subscribe(() => {
693
710
  this.notifySubscribers();
694
711
  }), this.config.threadListAdapter)
695
712
  try {
696
713
  const o = await this.config.threadListAdapter.createThread();
697
- r.conversationId = o.conversationId, this._threadStates.set(e, r), a.updateState(r);
714
+ r.conversationId = o.conversationId, this._threadStates.set(t, r), a.updateState(r);
698
715
  } catch (o) {
699
716
  console.error("Failed to create thread:", o);
700
717
  }
701
- await this.switchToThread(e);
718
+ await this.switchToThread(t);
702
719
  }
703
720
  async loadThreads() {
704
721
  if (!this.config.threadListAdapter) {
@@ -707,61 +724,61 @@ class Z extends y {
707
724
  }
708
725
  this._isLoading = !0, this.notifySubscribers();
709
726
  try {
710
- const e = await this.config.threadListAdapter.loadThreads();
711
- for (const t of e) {
712
- if (this._threadStates.has(t.id))
727
+ const t = await this.config.threadListAdapter.loadThreads();
728
+ for (const e of t) {
729
+ if (this._threadStates.has(e.id))
713
730
  continue;
714
- const n = new E({
731
+ const n = new v({
715
732
  streamAdapter: this.config.streamAdapter
716
- }), r = new C(n);
717
- this._threads.set(t.id, r), this._threadStates.set(t.id, t);
718
- const a = new R({
719
- state: t,
733
+ }), r = new R(n);
734
+ this._threads.set(e.id, r), this._threadStates.set(e.id, e);
735
+ const a = new I({
736
+ state: e,
720
737
  onSwitchTo: this.switchToThread.bind(this),
721
738
  onRename: this.renameThread.bind(this),
722
739
  onDelete: this.deleteThread.bind(this)
723
740
  });
724
- this._threadItems.set(t.id, a), r.subscribe(() => {
741
+ this._threadItems.set(e.id, a), r.subscribe(() => {
725
742
  this.notifySubscribers();
726
743
  });
727
744
  }
728
- } catch (e) {
729
- console.error("Failed to load threads:", e);
745
+ } catch (t) {
746
+ console.error("Failed to load threads:", t);
730
747
  } finally {
731
748
  this._isLoading = !1, this.notifySubscribers();
732
749
  }
733
750
  }
734
- async renameThread(e, t) {
751
+ async renameThread(t, e) {
735
752
  var r;
736
- const n = this._threadStates.get(e);
753
+ const n = this._threadStates.get(t);
737
754
  if (n) {
738
- if (n.title = t, n.updatedAt = Date.now(), this._threadStates.set(e, n), (r = this._threadItems.get(e)) == null || r.updateState(n), this.config.threadListAdapter)
755
+ 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)
739
756
  try {
740
- await this.config.threadListAdapter.updateThread(e, { title: t });
757
+ await this.config.threadListAdapter.updateThread(t, { title: e });
741
758
  } catch (a) {
742
759
  console.error("Failed to rename thread:", a);
743
760
  }
744
761
  this.notifySubscribers();
745
762
  }
746
763
  }
747
- async deleteThread(e) {
748
- if (e === this._mainThreadId && this._threads.size === 1)
764
+ async deleteThread(t) {
765
+ if (t === this._mainThreadId && this._threads.size === 1)
749
766
  throw new Error("Cannot delete the last thread");
750
- if (e === this._mainThreadId) {
751
- const t = Array.from(this._threads.keys()).find((n) => n !== e);
752
- t && await this.switchToThread(t);
767
+ if (t === this._mainThreadId) {
768
+ const e = Array.from(this._threads.keys()).find((n) => n !== t);
769
+ e && await this.switchToThread(e);
753
770
  }
754
- if (this._threads.delete(e), this._threadItems.delete(e), this._threadStates.delete(e), this.config.threadListAdapter)
771
+ if (this._threads.delete(t), this._threadItems.delete(t), this._threadStates.delete(t), this.config.threadListAdapter)
755
772
  try {
756
- await this.config.threadListAdapter.deleteThread(e);
757
- } catch (t) {
758
- console.error("Failed to delete thread:", t);
773
+ await this.config.threadListAdapter.deleteThread(t);
774
+ } catch (e) {
775
+ console.error("Failed to delete thread:", e);
759
776
  }
760
777
  this.notifySubscribers();
761
778
  }
762
779
  }
763
- class pe extends y {
764
- constructor(e) {
780
+ class pt extends y {
781
+ constructor(t) {
765
782
  super();
766
783
  c(this, "threads");
767
784
  c(this, "pluginRegistry");
@@ -769,11 +786,11 @@ class pe extends y {
769
786
  c(this, "capabilityExecutionManager");
770
787
  c(this, "_contentFocusRuntime");
771
788
  c(this, "_currentThreadUnsubscribe");
772
- this.pluginRegistry = new W(), e.plugins && e.plugins.forEach((t) => {
773
- this.pluginRegistry.registerPlugin(t);
774
- }), this.capabilityRegistry = new z(), this.capabilityExecutionManager = new V((t) => this.capabilityRegistry.getHandler(t)), this.threads = new Z({
775
- streamAdapter: e.streamAdapter,
776
- threadListAdapter: e.threadListAdapter,
789
+ this.pluginRegistry = new W(), t.plugins && t.plugins.forEach((e) => {
790
+ this.pluginRegistry.registerPlugin(e);
791
+ }), this.capabilityRegistry = new z(), this.capabilityExecutionManager = new V((e) => this.capabilityRegistry.getHandler(e)), this.threads = new Z({
792
+ streamAdapter: t.streamAdapter,
793
+ threadListAdapter: t.threadListAdapter,
777
794
  capabilityExecutionManager: this.capabilityExecutionManager
778
795
  }), this._contentFocusRuntime = new G(), this._contentFocusRuntime.subscribe(() => {
779
796
  this.notifySubscribers();
@@ -790,9 +807,9 @@ class pe extends y {
790
807
  /**
791
808
  * Register a plugin
792
809
  */
793
- registerPlugin(e) {
794
- var t;
795
- this.pluginRegistry.registerPlugin(e), (t = e.init) == null || t.call(e, {
810
+ registerPlugin(t) {
811
+ var e;
812
+ this.pluginRegistry.registerPlugin(t), (e = t.init) == null || e.call(t, {
796
813
  streamingEnabled: !0,
797
814
  feedbackEnabled: !1,
798
815
  detailPanelEnabled: !0
@@ -801,8 +818,8 @@ class pe extends y {
801
818
  /**
802
819
  * Unregister a plugin
803
820
  */
804
- unregisterPlugin(e) {
805
- return this.pluginRegistry.unregisterPlugin(e);
821
+ unregisterPlugin(t) {
822
+ return this.pluginRegistry.unregisterPlugin(t);
806
823
  }
807
824
  /**
808
825
  * Subscribe to the current main thread
@@ -813,20 +830,20 @@ class pe extends y {
813
830
  this.handleMessagesChange(this.thread.messages), this.notifySubscribers();
814
831
  });
815
832
  }
816
- handleMessagesChange(e) {
817
- if (e.length === 0) return;
818
- const t = e[e.length - 1];
819
- t.role === "assistant" && t.status.type === "complete" && this.autoFocusLastContent(e);
833
+ handleMessagesChange(t) {
834
+ if (t.length === 0) return;
835
+ const e = t[t.length - 1];
836
+ e.role === "assistant" && e.status.type === "complete" && this.autoFocusLastContent(t);
820
837
  }
821
- autoFocusLastContent(e) {
822
- var t;
823
- if (e.length !== 0 && !this._contentFocusRuntime.isActive)
824
- for (let n = e.length - 1; n >= 0; n--) {
825
- const r = e[n];
838
+ autoFocusLastContent(t) {
839
+ var e;
840
+ if (t.length !== 0 && !this._contentFocusRuntime.isActive)
841
+ for (let n = t.length - 1; n >= 0; n--) {
842
+ const r = t[n];
826
843
  if (r.role === "assistant")
827
844
  for (let a = r.content.length - 1; a >= 0; a--) {
828
845
  const o = r.content[a], u = this.pluginRegistry.getRenderersByType(o.type);
829
- if (u.length > 0 && ((t = u[0].capabilities) != null && t.supportsFocus)) {
846
+ if (u.length > 0 && ((e = u[0].capabilities) != null && e.supportsFocus)) {
830
847
  this._contentFocusRuntime.focus(o, r, a, "detail");
831
848
  return;
832
849
  }
@@ -834,18 +851,18 @@ class pe extends y {
834
851
  }
835
852
  }
836
853
  }
837
- var I = { exports: {} }, _ = {};
854
+ var C = { exports: {} }, _ = {};
838
855
  /*
839
856
  object-assign
840
857
  (c) Sindre Sorhus
841
858
  @license MIT
842
859
  */
843
- var M, L;
844
- function ee() {
845
- if (L) return M;
860
+ var E, L;
861
+ function tt() {
862
+ if (L) return E;
846
863
  L = 1;
847
- var i = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, e = Object.prototype.propertyIsEnumerable;
848
- function t(r) {
864
+ var i = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
865
+ function e(r) {
849
866
  if (r == null)
850
867
  throw new TypeError("Object.assign cannot be called with null or undefined");
851
868
  return Object(r);
@@ -872,19 +889,19 @@ function ee() {
872
889
  return !1;
873
890
  }
874
891
  }
875
- return M = n() ? Object.assign : function(r, a) {
876
- for (var o, u = t(r), p, l = 1; l < arguments.length; l++) {
892
+ return E = n() ? Object.assign : function(r, a) {
893
+ for (var o, u = e(r), p, l = 1; l < arguments.length; l++) {
877
894
  o = Object(arguments[l]);
878
895
  for (var h in o)
879
896
  s.call(o, h) && (u[h] = o[h]);
880
897
  if (i) {
881
898
  p = i(o);
882
899
  for (var d = 0; d < p.length; d++)
883
- e.call(o, p[d]) && (u[p[d]] = o[p[d]]);
900
+ t.call(o, p[d]) && (u[p[d]] = o[p[d]]);
884
901
  }
885
902
  }
886
903
  return u;
887
- }, M;
904
+ }, E;
888
905
  }
889
906
  /** @license React v17.0.2
890
907
  * react-jsx-runtime.production.min.js
@@ -895,71 +912,71 @@ function ee() {
895
912
  * LICENSE file in the root directory of this source tree.
896
913
  */
897
914
  var j;
898
- function te() {
915
+ function et() {
899
916
  if (j) return _;
900
- j = 1, ee();
917
+ j = 1, tt();
901
918
  var i = B, s = 60103;
902
919
  if (_.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
903
- var e = Symbol.for;
904
- s = e("react.element"), _.Fragment = e("react.fragment");
920
+ var t = Symbol.for;
921
+ s = t("react.element"), _.Fragment = t("react.fragment");
905
922
  }
906
- var t = 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 };
923
+ 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 };
907
924
  function a(o, u, p) {
908
925
  var l, h = {}, d = null, f = null;
909
926
  p !== void 0 && (d = "" + p), u.key !== void 0 && (d = "" + u.key), u.ref !== void 0 && (f = u.ref);
910
927
  for (l in u) n.call(u, l) && !r.hasOwnProperty(l) && (h[l] = u[l]);
911
928
  if (o && o.defaultProps) for (l in u = o.defaultProps, u) h[l] === void 0 && (h[l] = u[l]);
912
- return { $$typeof: s, type: o, key: d, ref: f, props: h, _owner: t.current };
929
+ return { $$typeof: s, type: o, key: d, ref: f, props: h, _owner: e.current };
913
930
  }
914
931
  return _.jsx = a, _.jsxs = a, _;
915
932
  }
916
933
  var O;
917
- function se() {
918
- return O || (O = 1, I.exports = te()), I.exports;
934
+ function st() {
935
+ return O || (O = 1, C.exports = et()), C.exports;
919
936
  }
920
- var S = se();
937
+ var S = st();
921
938
  const k = H(null);
922
- function fe({ runtime: i, children: s }) {
939
+ function ft({ runtime: i, children: s }) {
923
940
  return /* @__PURE__ */ S.jsx(k.Provider, { value: i, children: s });
924
941
  }
925
- function re() {
942
+ function rt() {
926
943
  const i = Q(k);
927
944
  if (!i)
928
945
  throw new Error("useAssistantRuntimeContext must be used within AssistantRuntimeProvider");
929
946
  return i;
930
947
  }
931
948
  function g() {
932
- return re();
949
+ return rt();
933
950
  }
934
- function ge() {
951
+ function gt() {
935
952
  const i = g();
936
953
  return {
937
954
  switchToThread: (s) => i.threads.switchToThread(s),
938
955
  switchToNewThread: () => i.threads.switchToNewThread(),
939
956
  loadThreads: () => {
940
- var s, e;
941
- return (e = (s = i.threads).loadThreads) == null ? void 0 : e.call(s);
957
+ var s, t;
958
+ return (t = (s = i.threads).loadThreads) == null ? void 0 : t.call(s);
942
959
  },
943
- renameThread: (s, e) => {
944
- var t, n;
945
- return (n = (t = i.threads).renameThread) == null ? void 0 : n.call(t, s, e);
960
+ renameThread: (s, t) => {
961
+ var e, n;
962
+ return (n = (e = i.threads).renameThread) == null ? void 0 : n.call(e, s, t);
946
963
  },
947
964
  deleteThread: (s) => {
948
- var e, t;
949
- return (t = (e = i.threads).deleteThread) == null ? void 0 : t.call(e, s);
965
+ var t, e;
966
+ return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, s);
950
967
  }
951
968
  };
952
969
  }
953
- function be() {
954
- const i = g(), [s, e] = x(i.threads.getState());
970
+ function bt() {
971
+ const i = g(), [s, t] = x(i.threads.getState());
955
972
  return w(() => i.threads.subscribe(() => {
956
- e(i.threads.getState());
973
+ t(i.threads.getState());
957
974
  }), [i]), s;
958
975
  }
959
- function ne() {
976
+ function nt() {
960
977
  return g().threads.getMainThread();
961
978
  }
962
- var v = { exports: {} }, A = {};
979
+ var M = { exports: {} }, A = {};
963
980
  /**
964
981
  * @license React
965
982
  * use-sync-external-store-shim.production.js
@@ -970,16 +987,16 @@ var v = { exports: {} }, A = {};
970
987
  * LICENSE file in the root directory of this source tree.
971
988
  */
972
989
  var N;
973
- function ie() {
990
+ function it() {
974
991
  if (N) return A;
975
992
  N = 1;
976
993
  var i = B;
977
994
  function s(h, d) {
978
995
  return h === d && (h !== 0 || 1 / h === 1 / d) || h !== h && d !== d;
979
996
  }
980
- var e = typeof Object.is == "function" ? Object.is : s, t = i.useState, n = i.useEffect, r = i.useLayoutEffect, a = i.useDebugValue;
997
+ var t = typeof Object.is == "function" ? Object.is : s, e = i.useState, n = i.useEffect, r = i.useLayoutEffect, a = i.useDebugValue;
981
998
  function o(h, d) {
982
- var f = d(), m = t({ inst: { value: f, getSnapshot: d } }), b = m[0].inst, T = m[1];
999
+ var f = d(), m = e({ inst: { value: f, getSnapshot: d } }), b = m[0].inst, T = m[1];
983
1000
  return r(
984
1001
  function() {
985
1002
  b.value = f, b.getSnapshot = d, u(b) && T({ inst: b });
@@ -999,7 +1016,7 @@ function ie() {
999
1016
  h = h.value;
1000
1017
  try {
1001
1018
  var f = d();
1002
- return !e(h, f);
1019
+ return !t(h, f);
1003
1020
  } catch {
1004
1021
  return !0;
1005
1022
  }
@@ -1011,13 +1028,13 @@ function ie() {
1011
1028
  return A.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : l, A;
1012
1029
  }
1013
1030
  var D;
1014
- function ae() {
1015
- return D || (D = 1, v.exports = ie()), v.exports;
1031
+ function at() {
1032
+ return D || (D = 1, M.exports = it()), M.exports;
1016
1033
  }
1017
- var oe = ae();
1018
- function ye() {
1034
+ var ot = at();
1035
+ function yt() {
1019
1036
  const i = g();
1020
- return oe.useSyncExternalStore(
1037
+ return ot.useSyncExternalStore(
1021
1038
  (s) => i.subscribe(() => {
1022
1039
  s();
1023
1040
  }),
@@ -1025,32 +1042,32 @@ function ye() {
1025
1042
  () => i.thread.messages
1026
1043
  );
1027
1044
  }
1028
- function me() {
1029
- const i = ne(), [s, e] = x(""), [t, n] = x(!1);
1045
+ function mt() {
1046
+ const i = nt(), [s, t] = x(""), [e, n] = x(!1);
1030
1047
  return {
1031
1048
  text: s,
1032
- setText: e,
1033
- isSubmitting: t,
1049
+ setText: t,
1050
+ isSubmitting: e,
1034
1051
  send: async (a) => {
1035
- if (a == null || a.preventDefault(), !s.trim() || t) return;
1052
+ if (a == null || a.preventDefault(), !s.trim() || e) return;
1036
1053
  const o = s;
1037
- e(""), n(!0);
1054
+ t(""), n(!0);
1038
1055
  try {
1039
1056
  await i.send(o);
1040
1057
  } catch (u) {
1041
- console.error("Failed to send message:", u), e(o);
1058
+ console.error("Failed to send message:", u), t(o);
1042
1059
  } finally {
1043
1060
  n(!1);
1044
1061
  }
1045
1062
  },
1046
- clear: () => e(""),
1047
- append: (a) => e((o) => o + a)
1063
+ clear: () => t(""),
1064
+ append: (a) => t((o) => o + a)
1048
1065
  };
1049
1066
  }
1050
1067
  function q(i, s) {
1051
1068
  var r, a, o, u;
1052
- const t = g().pluginRegistry.getBestRendererForType(i);
1053
- if (!t)
1069
+ const e = g().pluginRegistry.getBestRendererForType(i);
1070
+ if (!e)
1054
1071
  return {
1055
1072
  component: null,
1056
1073
  auxiliaryComponent: null,
@@ -1058,30 +1075,30 @@ function q(i, s) {
1058
1075
  supportsPreview: !1,
1059
1076
  supportsFullscreen: !1
1060
1077
  };
1061
- const n = s ? (r = t.auxiliary) == null ? void 0 : r[s] : null;
1078
+ const n = s ? (r = e.auxiliary) == null ? void 0 : r[s] : null;
1062
1079
  return {
1063
- component: t.component,
1080
+ component: e.component,
1064
1081
  auxiliaryComponent: n,
1065
- supportsFocus: ((a = t.capabilities) == null ? void 0 : a.supportsFocus) ?? !1,
1066
- supportsPreview: ((o = t.capabilities) == null ? void 0 : o.supportsPreview) ?? !1,
1067
- supportsFullscreen: ((u = t.capabilities) == null ? void 0 : u.supportsFullscreen) ?? !1
1082
+ supportsFocus: ((a = e.capabilities) == null ? void 0 : a.supportsFocus) ?? !1,
1083
+ supportsPreview: ((o = e.capabilities) == null ? void 0 : o.supportsPreview) ?? !1,
1084
+ supportsFullscreen: ((u = e.capabilities) == null ? void 0 : u.supportsFullscreen) ?? !1
1068
1085
  };
1069
1086
  }
1070
- function _e() {
1071
- const i = g(), [s, e] = x(i.contentFocus.state);
1087
+ function _t() {
1088
+ const i = g(), [s, t] = x(i.contentFocus.state);
1072
1089
  return w(() => i.contentFocus.subscribe(() => {
1073
- e(i.contentFocus.state);
1090
+ t(i.contentFocus.state);
1074
1091
  }), [i]), {
1075
1092
  ...s,
1076
- focus: (t, n, r, a) => i.contentFocus.focus(t, n, r, a),
1093
+ focus: (e, n, r, a) => i.contentFocus.focus(e, n, r, a),
1077
1094
  blur: () => i.contentFocus.blur(),
1078
- toggle: (t, n, r, a) => i.contentFocus.toggle(t, n, r, a),
1079
- switchContext: (t) => i.contentFocus.switchContext(t),
1095
+ toggle: (e, n, r, a) => i.contentFocus.toggle(e, n, r, a),
1096
+ switchContext: (e) => i.contentFocus.switchContext(e),
1080
1097
  focusNext: () => i.contentFocus.focusNext(i.thread.messages),
1081
1098
  focusPrevious: () => i.contentFocus.focusPrevious(i.thread.messages)
1082
1099
  };
1083
1100
  }
1084
- function ue(i) {
1101
+ function ut(i) {
1085
1102
  const s = g();
1086
1103
  w(() => (i.execute && s.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && s.capabilityRegistry.registerRenderer(i.name, {
1087
1104
  component: i.render
@@ -1089,22 +1106,22 @@ function ue(i) {
1089
1106
  s.capabilityRegistry.unregister(i.name);
1090
1107
  }), [i.name, s]);
1091
1108
  }
1092
- function ce(i) {
1093
- const s = g(), [e, t] = x(
1109
+ function ct(i) {
1110
+ const s = g(), [t, e] = x(
1094
1111
  () => s.capabilityExecutionManager.getExecution(i)
1095
1112
  ), [, n] = J((r) => r + 1, 0);
1096
1113
  return w(() => {
1097
1114
  const r = s.capabilityExecutionManager.getExecution(i);
1098
- return t(r), s.capabilityExecutionManager.subscribe((o) => {
1115
+ return e(r), s.capabilityExecutionManager.subscribe((o) => {
1099
1116
  if (o === i) {
1100
1117
  const u = s.capabilityExecutionManager.getExecution(i);
1101
- t(u), n();
1118
+ e(u), n();
1102
1119
  }
1103
1120
  });
1104
- }, [i, s]), e;
1121
+ }, [i, s]), t;
1105
1122
  }
1106
- function he({ message: i, content: s }) {
1107
- const e = g(), t = s, n = ce(t.capabilityId), r = e.capabilityRegistry.getRenderer(t.capabilityName);
1123
+ function ht({ message: i, content: s }) {
1124
+ const t = g(), e = s, n = ct(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1108
1125
  if (!r || !n)
1109
1126
  return null;
1110
1127
  const a = r.component;
@@ -1120,24 +1137,24 @@ function he({ message: i, content: s }) {
1120
1137
  }
1121
1138
  );
1122
1139
  }
1123
- function xe({ message: i, content: s }) {
1124
- const { component: e } = q(s.type);
1140
+ function xt({ message: i, content: s }) {
1141
+ const { component: t } = q(s.type);
1125
1142
  if (s.type === "capability")
1126
- return /* @__PURE__ */ S.jsx(he, { message: i, content: s });
1127
- if (!e)
1143
+ return /* @__PURE__ */ S.jsx(ht, { message: i, content: s });
1144
+ if (!t)
1128
1145
  return null;
1129
- const t = e;
1130
- return /* @__PURE__ */ S.jsx(t, { content: s, message: i });
1146
+ const e = t;
1147
+ return /* @__PURE__ */ S.jsx(e, { content: s, message: i });
1131
1148
  }
1132
- function Se({
1149
+ function St({
1133
1150
  message: i,
1134
1151
  content: s,
1135
- context: e,
1136
- onClose: t,
1152
+ context: t,
1153
+ onClose: e,
1137
1154
  onNavigate: n,
1138
1155
  onSwitchContext: r
1139
1156
  }) {
1140
- const { auxiliaryComponent: a } = q(s.type, e);
1157
+ const { auxiliaryComponent: a } = q(s.type, t);
1141
1158
  if (!a)
1142
1159
  return null;
1143
1160
  const o = a;
@@ -1146,40 +1163,40 @@ function Se({
1146
1163
  {
1147
1164
  content: s,
1148
1165
  message: i,
1149
- context: e,
1150
- onClose: t,
1166
+ context: t,
1167
+ onClose: e,
1151
1168
  onNavigate: n,
1152
1169
  onSwitchContext: r
1153
1170
  }
1154
1171
  );
1155
1172
  }
1156
- function we(i) {
1157
- const s = () => (ue(i), null);
1173
+ function wt(i) {
1174
+ const s = () => (ut(i), null);
1158
1175
  return s.displayName = `Capability(${i.name})`, s;
1159
1176
  }
1160
- class Te {
1177
+ class Tt {
1161
1178
  getAllowedEvents() {
1162
1179
  return null;
1163
1180
  }
1164
1181
  shouldProcessEvent(s) {
1165
- const e = this.getAllowedEvents();
1166
- return e ? e.includes(s) : !0;
1182
+ const t = this.getAllowedEvents();
1183
+ return t ? t.includes(s) : !0;
1167
1184
  }
1168
1185
  async *stream(s) {
1169
- const { signal: e } = s, { url: t, options: n } = this.prepareRequest(s), r = await fetch(t, { ...n, signal: e });
1186
+ const { signal: t } = s, { url: e, options: n } = this.prepareRequest(s), r = await fetch(e, { ...n, signal: t });
1170
1187
  if (!r.ok)
1171
1188
  throw new Error(`HTTP error! status: ${r.status}`);
1172
1189
  if (!r.body)
1173
1190
  throw new Error("Response body is null");
1174
- yield* this.parseSSEStream(r.body, e);
1191
+ yield* this.parseSSEStream(r.body, t);
1175
1192
  }
1176
- async *parseSSEStream(s, e) {
1177
- const t = s.getReader(), n = new TextDecoder();
1193
+ async *parseSSEStream(s, t) {
1194
+ const e = s.getReader(), n = new TextDecoder();
1178
1195
  let r = "", a = null;
1179
1196
  try {
1180
1197
  for (; ; ) {
1181
- const { done: o, value: u } = await t.read();
1182
- if (o || e != null && e.aborted) break;
1198
+ const { done: o, value: u } = await e.read();
1199
+ if (o || t != null && t.aborted) break;
1183
1200
  r += n.decode(u, { stream: !0 });
1184
1201
  const p = r.split(`
1185
1202
  `);
@@ -1216,35 +1233,35 @@ class Te {
1216
1233
  }
1217
1234
  }
1218
1235
  } finally {
1219
- t.releaseLock();
1236
+ e.releaseLock();
1220
1237
  }
1221
1238
  }
1222
1239
  }
1223
1240
  export {
1224
- pe as AssistantRuntime,
1225
- fe as AssistantRuntimeProvider,
1226
- Se as AuxiliaryRenderer,
1227
- Te as BaseSSEStreamAdapter,
1241
+ pt as AssistantRuntime,
1242
+ ft as AssistantRuntimeProvider,
1243
+ St as AuxiliaryRenderer,
1244
+ Tt as BaseSSEStreamAdapter,
1228
1245
  V as CapabilityExecutionManager,
1229
1246
  z as CapabilityRegistry,
1230
- he as CapabilityRendererComp,
1247
+ ht as CapabilityRendererComp,
1231
1248
  X as ComposerRuntime,
1232
- xe as ContentRenderer,
1249
+ xt as ContentRenderer,
1233
1250
  W as PluginRegistry,
1234
- R as ThreadListItemRuntime,
1251
+ I as ThreadListItemRuntime,
1235
1252
  Z as ThreadListRuntime,
1236
- C as ThreadRuntime,
1237
- E as ThreadRuntimeCore,
1238
- we as makeCapability,
1253
+ R as ThreadRuntime,
1254
+ v as ThreadRuntimeCore,
1255
+ wt as makeCapability,
1239
1256
  g as useAssistantRuntime,
1240
- ue as useCapability,
1241
- ce as useCapabilityExecution,
1242
- me as useComposer,
1243
- _e as useContentFocus,
1257
+ ut as useCapability,
1258
+ ct as useCapabilityExecution,
1259
+ mt as useComposer,
1260
+ _t as useContentFocus,
1244
1261
  q as useContentRenderer,
1245
- ne as useCurrentThread,
1246
- ye as useMessages,
1247
- ge as useThreadList,
1248
- be as useThreadListState
1262
+ nt as useCurrentThread,
1263
+ yt as useMessages,
1264
+ gt as useThreadList,
1265
+ bt as useThreadListState
1249
1266
  };
1250
1267
  //# sourceMappingURL=index.js.map