@harnessio/ai-chat-core 0.0.23 → 0.0.25

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,7 +1,7 @@
1
1
  var H = Object.defineProperty;
2
2
  var J = (n, s, t) => s in n ? H(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
3
  var u = (n, s, t) => J(n, typeof s != "symbol" ? s + "" : s, t);
4
- import q, { createContext as U, useContext as B, useState as y, useEffect as m, useReducer as V, useCallback as C, useMemo as z } from "react";
4
+ import q, { createContext as B, useContext as U, useState as y, useEffect as b, useReducer as V, useCallback as C, useMemo as z } from "react";
5
5
  class G {
6
6
  constructor() {
7
7
  u(this, "plugins", /* @__PURE__ */ new Map());
@@ -414,10 +414,10 @@ let tt = 0, et = 0;
414
414
  function v() {
415
415
  return `msg-${Date.now()}-${++tt}`;
416
416
  }
417
- function k() {
417
+ function P() {
418
418
  return `thread-${Date.now()}-${++et}`;
419
419
  }
420
- class R extends _ {
420
+ class T extends _ {
421
421
  constructor(t) {
422
422
  super();
423
423
  u(this, "_state");
@@ -473,7 +473,7 @@ class st extends _ {
473
473
  this._isSubmitting = t, this.notifySubscribers();
474
474
  }
475
475
  }
476
- class T extends _ {
476
+ class R extends _ {
477
477
  constructor(t) {
478
478
  super();
479
479
  u(this, "composer");
@@ -553,6 +553,23 @@ class T extends _ {
553
553
  async sendSystemEvent(t) {
554
554
  await this._core.waitForIdle(), await this._core.startSystemEventRun(t);
555
555
  }
556
+ /**
557
+ * Registers a generic background task that keeps the thread reported as
558
+ * running for as long as it is active, even when no stream run is in
559
+ * flight. Use this for UI-driven async work (e.g. a card polling a status
560
+ * API) so the composer shows a running/stop affordance. The work is
561
+ * cancelled when the user presses stop (cancelRun), which invokes the
562
+ * provided onCancel callback. Returns an opaque id for stopBackgroundTask.
563
+ */
564
+ startBackgroundTask(t) {
565
+ return this._core.startBackgroundTask(t);
566
+ }
567
+ /**
568
+ * Removes a previously registered background task by its id.
569
+ */
570
+ stopBackgroundTask(t) {
571
+ this._core.stopBackgroundTask(t);
572
+ }
556
573
  cancelRun() {
557
574
  this._core.cancelRun();
558
575
  }
@@ -591,6 +608,13 @@ class M extends _ {
591
608
  // dispatch against an in-progress run instead of having their error
592
609
  // swallowed by the caller's try/catch.
593
610
  u(this, "_idleWaiters", []);
611
+ // Generic background tasks that hold the thread in a "running" state
612
+ // without an active stream run. Any UI-driven async work (e.g. a card
613
+ // that polls a status API) can register one to keep the composer
614
+ // showing a running/stop affordance, and is cancelled alongside the
615
+ // run when the user presses stop. Keyed by an opaque task id; the
616
+ // optional onCancel is invoked when the task is cancelled via cancelRun.
617
+ u(this, "_backgroundTasks", /* @__PURE__ */ new Map());
594
618
  // Track current part being accumulated
595
619
  u(this, "_currentPart", null);
596
620
  this.config = t, t.initialMessages && (this._messages = [...t.initialMessages]);
@@ -599,7 +623,7 @@ class M extends _ {
599
623
  return this._messages;
600
624
  }
601
625
  get isRunning() {
602
- return this._isRunning;
626
+ return this._isRunning || this._backgroundTasks.size > 0;
603
627
  }
604
628
  get isDisabled() {
605
629
  return this._isDisabled;
@@ -665,6 +689,40 @@ class M extends _ {
665
689
  } catch {
666
690
  }
667
691
  }
692
+ /**
693
+ * Registers a generic background task that keeps the thread reported as
694
+ * running (isRunning === true) for as long as it is active, even when no
695
+ * stream run is in flight. Use this for UI-driven async work — e.g. a card
696
+ * that polls a status API — so the composer shows a running/stop
697
+ * affordance and the work is cancelled when the user presses stop.
698
+ *
699
+ * Returns an opaque id to pass to stopBackgroundTask. The optional onCancel
700
+ * callback is invoked if the task is cancelled via cancelRun (stop button).
701
+ */
702
+ startBackgroundTask(t) {
703
+ const e = `bg-${Date.now()}-${Math.random().toString(36).slice(2)}`;
704
+ return this._backgroundTasks.set(e, { onCancel: t == null ? void 0 : t.onCancel }), this.notifySubscribers(), e;
705
+ }
706
+ /**
707
+ * Removes a previously registered background task. Once the last task is
708
+ * removed (and no run is in flight) any idle waiters are drained so queued
709
+ * dispatches can proceed.
710
+ */
711
+ stopBackgroundTask(t) {
712
+ this._backgroundTasks.delete(t) && (this.isRunning || this.drainIdleWaiters(), this.notifySubscribers());
713
+ }
714
+ cancelBackgroundTasks() {
715
+ var e;
716
+ if (this._backgroundTasks.size === 0) return;
717
+ const t = [...this._backgroundTasks.values()];
718
+ this._backgroundTasks.clear();
719
+ for (const i of t)
720
+ try {
721
+ (e = i.onCancel) == null || e.call(i);
722
+ } catch {
723
+ }
724
+ this.isRunning || this.drainIdleWaiters(), this.notifySubscribers();
725
+ }
668
726
  async startSystemEventRun(t) {
669
727
  if (this._isRunning)
670
728
  throw new Error("A run is already in progress");
@@ -912,7 +970,7 @@ class M extends _ {
912
970
  this.updateMessages([]);
913
971
  }
914
972
  cancelRun() {
915
- !this._isRunning || !this._abortController || this._abortController.abort();
973
+ this._isRunning && this._abortController && this._abortController.abort(), this.cancelBackgroundTasks();
916
974
  }
917
975
  reset(t = []) {
918
976
  this.updateMessages([...t]);
@@ -945,12 +1003,12 @@ class it extends _ {
945
1003
  u(this, "_searchQuery");
946
1004
  u(this, "_abortController", null);
947
1005
  u(this, "main");
948
- this.config = t, this._mainThreadId = k();
1006
+ this.config = t, this._mainThreadId = P();
949
1007
  const e = new M({
950
1008
  streamAdapter: t.streamAdapter,
951
1009
  capabilityExecutionManager: t.capabilityExecutionManager
952
1010
  });
953
- this.main = new T(e), this._threads.set(this._mainThreadId, this.main);
1011
+ this.main = new R(e), this._threads.set(this._mainThreadId, this.main);
954
1012
  const i = {
955
1013
  id: this._mainThreadId,
956
1014
  title: "New Chat",
@@ -960,7 +1018,7 @@ class it extends _ {
960
1018
  updatedAt: Date.now()
961
1019
  };
962
1020
  this._threadStates.set(this._mainThreadId, i);
963
- const r = new R({
1021
+ const r = new T({
964
1022
  state: i,
965
1023
  onSwitchTo: this.switchToThread.bind(this),
966
1024
  onRename: this.renameThread.bind(this),
@@ -1012,10 +1070,10 @@ class it extends _ {
1012
1070
  this.notifySubscribers();
1013
1071
  }
1014
1072
  async switchToNewThread() {
1015
- const t = k(), e = new M({
1073
+ const t = P(), e = new M({
1016
1074
  streamAdapter: this.config.streamAdapter,
1017
1075
  capabilityExecutionManager: this.config.capabilityExecutionManager
1018
- }), i = new T(e);
1076
+ }), i = new R(e);
1019
1077
  this._threads.set(t, i);
1020
1078
  const r = {
1021
1079
  id: t,
@@ -1026,7 +1084,7 @@ class it extends _ {
1026
1084
  updatedAt: Date.now()
1027
1085
  };
1028
1086
  this._threadStates.set(t, r);
1029
- const a = new R({
1087
+ const a = new T({
1030
1088
  state: r,
1031
1089
  onSwitchTo: this.switchToThread.bind(this),
1032
1090
  onRename: this.renameThread.bind(this),
@@ -1062,9 +1120,9 @@ class it extends _ {
1062
1120
  const r = new M({
1063
1121
  streamAdapter: this.config.streamAdapter,
1064
1122
  capabilityExecutionManager: this.config.capabilityExecutionManager
1065
- }), a = new T(r);
1123
+ }), a = new R(r);
1066
1124
  this._threads.set(i.id, a), this._threadStates.set(i.id, i);
1067
- const o = new R({
1125
+ const o = new T({
1068
1126
  state: i,
1069
1127
  onSwitchTo: this.switchToThread.bind(this),
1070
1128
  onRename: this.renameThread.bind(this),
@@ -1118,7 +1176,7 @@ class it extends _ {
1118
1176
  this.notifySubscribers();
1119
1177
  }
1120
1178
  }
1121
- class yt extends _ {
1179
+ class rt extends _ {
1122
1180
  constructor(t) {
1123
1181
  super();
1124
1182
  u(this, "threads");
@@ -1193,15 +1251,15 @@ class yt extends _ {
1193
1251
  }
1194
1252
  }
1195
1253
  }
1196
- var E = { exports: {} }, x = {};
1254
+ var A = { exports: {} }, x = {};
1197
1255
  /*
1198
1256
  object-assign
1199
1257
  (c) Sindre Sorhus
1200
1258
  @license MIT
1201
1259
  */
1202
- var A, D;
1203
- function rt() {
1204
- if (D) return A;
1260
+ var E, D;
1261
+ function nt() {
1262
+ if (D) return E;
1205
1263
  D = 1;
1206
1264
  var n = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
1207
1265
  function e(r) {
@@ -1231,19 +1289,19 @@ function rt() {
1231
1289
  return !1;
1232
1290
  }
1233
1291
  }
1234
- return A = i() ? Object.assign : function(r, a) {
1292
+ return E = i() ? Object.assign : function(r, a) {
1235
1293
  for (var o, c = e(r), h, l = 1; l < arguments.length; l++) {
1236
1294
  o = Object(arguments[l]);
1237
1295
  for (var d in o)
1238
1296
  s.call(o, d) && (c[d] = o[d]);
1239
1297
  if (n) {
1240
1298
  h = n(o);
1241
- for (var p = 0; p < h.length; p++)
1242
- t.call(o, h[p]) && (c[h[p]] = o[h[p]]);
1299
+ for (var g = 0; g < h.length; g++)
1300
+ t.call(o, h[g]) && (c[h[g]] = o[h[g]]);
1243
1301
  }
1244
1302
  }
1245
1303
  return c;
1246
- }, A;
1304
+ }, E;
1247
1305
  }
1248
1306
  /** @license React v17.0.2
1249
1307
  * react-jsx-runtime.production.min.js
@@ -1254,9 +1312,9 @@ function rt() {
1254
1312
  * LICENSE file in the root directory of this source tree.
1255
1313
  */
1256
1314
  var N;
1257
- function nt() {
1315
+ function at() {
1258
1316
  if (N) return x;
1259
- N = 1, rt();
1317
+ N = 1, nt();
1260
1318
  var n = q, s = 60103;
1261
1319
  if (x.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
1262
1320
  var t = Symbol.for;
@@ -1264,33 +1322,31 @@ function nt() {
1264
1322
  }
1265
1323
  var e = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = Object.prototype.hasOwnProperty, r = { key: !0, ref: !0, __self: !0, __source: !0 };
1266
1324
  function a(o, c, h) {
1267
- var l, d = {}, p = null, g = null;
1268
- h !== void 0 && (p = "" + h), c.key !== void 0 && (p = "" + c.key), c.ref !== void 0 && (g = c.ref);
1325
+ var l, d = {}, g = null, p = null;
1326
+ h !== void 0 && (g = "" + h), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (p = c.ref);
1269
1327
  for (l in c) i.call(c, l) && !r.hasOwnProperty(l) && (d[l] = c[l]);
1270
1328
  if (o && o.defaultProps) for (l in c = o.defaultProps, c) d[l] === void 0 && (d[l] = c[l]);
1271
- return { $$typeof: s, type: o, key: p, ref: g, props: d, _owner: e.current };
1329
+ return { $$typeof: s, type: o, key: g, ref: p, props: d, _owner: e.current };
1272
1330
  }
1273
1331
  return x.jsx = a, x.jsxs = a, x;
1274
1332
  }
1275
1333
  var O;
1276
- function at() {
1277
- return O || (O = 1, E.exports = nt()), E.exports;
1334
+ function ot() {
1335
+ return O || (O = 1, A.exports = at()), A.exports;
1278
1336
  }
1279
- var w = at();
1280
- const W = U(null);
1281
- function _t({ runtime: n, children: s }) {
1337
+ var w = ot();
1338
+ const ct = { stream: async function* () {
1339
+ } }, ut = new rt({ streamAdapter: ct }), W = B(ut);
1340
+ function wt({ runtime: n, children: s }) {
1282
1341
  return /* @__PURE__ */ w.jsx(W.Provider, { value: n, children: s });
1283
1342
  }
1284
- function ot() {
1285
- const n = B(W);
1286
- if (!n)
1287
- throw new Error("useAssistantRuntimeContext must be used within AssistantRuntimeProvider");
1288
- return n;
1343
+ function ht() {
1344
+ return U(W);
1289
1345
  }
1290
1346
  function f() {
1291
- return ot();
1347
+ return ht();
1292
1348
  }
1293
- function St() {
1349
+ function Ct() {
1294
1350
  const n = f();
1295
1351
  return {
1296
1352
  switchToThread: (s) => n.threads.switchToThread(s),
@@ -1306,19 +1362,19 @@ function St() {
1306
1362
  }
1307
1363
  };
1308
1364
  }
1309
- function xt() {
1365
+ function It() {
1310
1366
  const n = f(), [s, t] = y(n.threads.getState());
1311
- return m(() => n.threads.subscribe(() => {
1367
+ return b(() => n.threads.subscribe(() => {
1312
1368
  t(n.threads.getState());
1313
1369
  }), [n]), s;
1314
1370
  }
1315
- function ct() {
1371
+ function dt() {
1316
1372
  const s = f().threads.getMainThread(), [, t] = y({});
1317
- return m(() => s.subscribe(() => {
1373
+ return b(() => s.subscribe(() => {
1318
1374
  t({});
1319
1375
  }), [s]), s;
1320
1376
  }
1321
- var P = { exports: {} }, F = {};
1377
+ var k = { exports: {} }, F = {};
1322
1378
  /**
1323
1379
  * @license React
1324
1380
  * use-sync-external-store-shim.production.js
@@ -1329,54 +1385,54 @@ var P = { exports: {} }, F = {};
1329
1385
  * LICENSE file in the root directory of this source tree.
1330
1386
  */
1331
1387
  var j;
1332
- function ut() {
1388
+ function lt() {
1333
1389
  if (j) return F;
1334
1390
  j = 1;
1335
1391
  var n = q;
1336
- function s(d, p) {
1337
- return d === p && (d !== 0 || 1 / d === 1 / p) || d !== d && p !== p;
1392
+ function s(d, g) {
1393
+ return d === g && (d !== 0 || 1 / d === 1 / g) || d !== d && g !== g;
1338
1394
  }
1339
1395
  var t = typeof Object.is == "function" ? Object.is : s, e = n.useState, i = n.useEffect, r = n.useLayoutEffect, a = n.useDebugValue;
1340
- function o(d, p) {
1341
- var g = p(), S = e({ inst: { value: g, getSnapshot: p } }), b = S[0].inst, I = S[1];
1396
+ function o(d, g) {
1397
+ var p = g(), S = e({ inst: { value: p, getSnapshot: g } }), m = S[0].inst, I = S[1];
1342
1398
  return r(
1343
1399
  function() {
1344
- b.value = g, b.getSnapshot = p, c(b) && I({ inst: b });
1400
+ m.value = p, m.getSnapshot = g, c(m) && I({ inst: m });
1345
1401
  },
1346
- [d, g, p]
1402
+ [d, p, g]
1347
1403
  ), i(
1348
1404
  function() {
1349
- return c(b) && I({ inst: b }), d(function() {
1350
- c(b) && I({ inst: b });
1405
+ return c(m) && I({ inst: m }), d(function() {
1406
+ c(m) && I({ inst: m });
1351
1407
  });
1352
1408
  },
1353
1409
  [d]
1354
- ), a(g), g;
1410
+ ), a(p), p;
1355
1411
  }
1356
1412
  function c(d) {
1357
- var p = d.getSnapshot;
1413
+ var g = d.getSnapshot;
1358
1414
  d = d.value;
1359
1415
  try {
1360
- var g = p();
1361
- return !t(d, g);
1416
+ var p = g();
1417
+ return !t(d, p);
1362
1418
  } catch {
1363
1419
  return !0;
1364
1420
  }
1365
1421
  }
1366
- function h(d, p) {
1367
- return p();
1422
+ function h(d, g) {
1423
+ return g();
1368
1424
  }
1369
1425
  var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? h : o;
1370
1426
  return F.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : l, F;
1371
1427
  }
1372
1428
  var L;
1373
- function ht() {
1374
- return L || (L = 1, P.exports = ut()), P.exports;
1429
+ function gt() {
1430
+ return L || (L = 1, k.exports = lt()), k.exports;
1375
1431
  }
1376
- var dt = ht();
1377
- function wt() {
1432
+ var pt = gt();
1433
+ function vt() {
1378
1434
  const n = f();
1379
- return dt.useSyncExternalStore(
1435
+ return pt.useSyncExternalStore(
1380
1436
  (s) => n.subscribe(() => {
1381
1437
  s();
1382
1438
  }),
@@ -1384,8 +1440,8 @@ function wt() {
1384
1440
  () => n.thread.messages
1385
1441
  );
1386
1442
  }
1387
- function Ct() {
1388
- const n = ct(), [s, t] = y(""), [e, i] = y(!1);
1443
+ function Tt() {
1444
+ const n = dt(), [s, t] = y(""), [e, i] = y(!1);
1389
1445
  return {
1390
1446
  text: s,
1391
1447
  setText: t,
@@ -1406,7 +1462,7 @@ function Ct() {
1406
1462
  append: (a) => t((o) => o + a)
1407
1463
  };
1408
1464
  }
1409
- function Q(n, s) {
1465
+ function $(n, s) {
1410
1466
  var r, a, o, c;
1411
1467
  const e = f().pluginRegistry.getBestRendererForType(n);
1412
1468
  if (!e)
@@ -1426,9 +1482,9 @@ function Q(n, s) {
1426
1482
  supportsFullscreen: ((c = e.capabilities) == null ? void 0 : c.supportsFullscreen) ?? !1
1427
1483
  };
1428
1484
  }
1429
- function It() {
1485
+ function Rt() {
1430
1486
  const n = f(), [s, t] = y(n.contentFocus.state);
1431
- return m(() => n.contentFocus.subscribe(() => {
1487
+ return b(() => n.contentFocus.subscribe(() => {
1432
1488
  t(n.contentFocus.state);
1433
1489
  }), [n]), {
1434
1490
  ...s,
@@ -1440,9 +1496,9 @@ function It() {
1440
1496
  focusPrevious: () => n.contentFocus.focusPrevious(n.thread.messages)
1441
1497
  };
1442
1498
  }
1443
- function lt(n) {
1499
+ function ft(n) {
1444
1500
  const s = f();
1445
- m(() => {
1501
+ b(() => {
1446
1502
  const t = n.priority ?? 0;
1447
1503
  return n.execute && s.capabilityRegistry.registerHandler(n.name, { execute: n.execute }, t), n.render && s.capabilityRegistry.registerRenderer(
1448
1504
  n.name,
@@ -1455,11 +1511,11 @@ function lt(n) {
1455
1511
  };
1456
1512
  }, [n.name, s]);
1457
1513
  }
1458
- function pt(n) {
1514
+ function bt(n) {
1459
1515
  const s = f(), [t, e] = y(
1460
1516
  () => s.capabilityExecutionManager.getExecution(n)
1461
1517
  ), [, i] = V((r) => r + 1, 0);
1462
- return m(() => {
1518
+ return b(() => {
1463
1519
  const r = s.capabilityExecutionManager.getExecution(n);
1464
1520
  return e(r), s.capabilityExecutionManager.subscribe((o) => {
1465
1521
  if (o === n) {
@@ -1469,13 +1525,22 @@ function pt(n) {
1469
1525
  });
1470
1526
  }, [n, s]), t;
1471
1527
  }
1472
- const $ = U(void 0);
1473
- function vt({ children: n }) {
1528
+ const mt = {
1529
+ contexts: {},
1530
+ setContext: () => {
1531
+ },
1532
+ removeContext: () => {
1533
+ },
1534
+ getContextData: () => ({}),
1535
+ clearContexts: () => {
1536
+ }
1537
+ }, Q = B(mt);
1538
+ function Mt({ children: n }) {
1474
1539
  const [s, t] = y({}), e = C((c, h) => {
1475
1540
  t((l) => {
1476
1541
  if (h === null) {
1477
- const { [c]: d, ...p } = l;
1478
- return p;
1542
+ const { [c]: d, ...g } = l;
1543
+ return g;
1479
1544
  }
1480
1545
  return {
1481
1546
  ...l,
@@ -1490,9 +1555,9 @@ function vt({ children: n }) {
1490
1555
  }, []), r = C(() => Object.values(s).reduce(
1491
1556
  (c, h) => {
1492
1557
  const l = Object.entries(h.data).reduce(
1493
- (d, [p, g]) => ({
1558
+ (d, [g, p]) => ({
1494
1559
  ...d,
1495
- [p]: typeof g == "string" ? g : JSON.stringify(g)
1560
+ [g]: typeof p == "string" ? p : JSON.stringify(p)
1496
1561
  }),
1497
1562
  {}
1498
1563
  );
@@ -1511,29 +1576,26 @@ function vt({ children: n }) {
1511
1576
  }),
1512
1577
  [s, e, i, r, a]
1513
1578
  );
1514
- return /* @__PURE__ */ w.jsx($.Provider, { value: o, children: n });
1579
+ return /* @__PURE__ */ w.jsx(Q.Provider, { value: o, children: n });
1515
1580
  }
1516
- function gt() {
1517
- const n = B($);
1518
- if (!n)
1519
- throw new Error("useChatContext must be used within a ChatContextProvider");
1520
- return n;
1581
+ function yt() {
1582
+ return U(Q);
1521
1583
  }
1522
- function Rt(n) {
1523
- const { setContext: s, removeContext: t } = gt(), { id: e = "currentPage", ...i } = n;
1524
- m(() => (s(e, i), () => {
1584
+ function At(n) {
1585
+ const { setContext: s, removeContext: t } = yt(), { id: e = "currentPage", ...i } = n;
1586
+ b(() => (s(e, i), () => {
1525
1587
  t(e);
1526
1588
  }), [e, i.displayName, JSON.stringify(i.data), i.priority, i.icon]);
1527
1589
  }
1528
- function Tt(n, s = "merge") {
1590
+ function Et(n, s = "merge") {
1529
1591
  const t = f();
1530
- m(() => (t.quickActionRegistry.activateScope(n, s), () => {
1592
+ b(() => (t.quickActionRegistry.activateScope(n, s), () => {
1531
1593
  t.quickActionRegistry.deactivateScope(n);
1532
1594
  }), [n, s, t]);
1533
1595
  }
1534
- function Mt(n, s) {
1596
+ function kt(n, s) {
1535
1597
  const t = f();
1536
- m(() => {
1598
+ b(() => {
1537
1599
  const e = s || t.quickActionRegistry.getActiveScope();
1538
1600
  return t.quickActionRegistry.register(n, e), () => {
1539
1601
  t.quickActionRegistry.unregister(n.id, e);
@@ -1550,15 +1612,15 @@ function Mt(n, s) {
1550
1612
  t
1551
1613
  ]);
1552
1614
  }
1553
- function Et(n) {
1615
+ function Ft(n) {
1554
1616
  const s = f(), [t, e] = y([]);
1555
- return m(() => (s.quickActionRegistry.getVisible(n).then(e), s.subscribe(() => {
1617
+ return b(() => (s.quickActionRegistry.getVisible(n).then(e), s.subscribe(() => {
1556
1618
  s.quickActionRegistry.getVisible(n).then(e);
1557
1619
  })), [s, n == null ? void 0 : n.scope]), t;
1558
1620
  }
1559
- function At(n, s) {
1621
+ function Pt(n, s) {
1560
1622
  const t = f();
1561
- m(() => {
1623
+ b(() => {
1562
1624
  const e = s || t.quickActionRegistry.getActiveScope();
1563
1625
  return n.forEach((i) => {
1564
1626
  t.quickActionRegistry.register(i, e);
@@ -1569,8 +1631,8 @@ function At(n, s) {
1569
1631
  };
1570
1632
  }, [n, s, t]);
1571
1633
  }
1572
- function ft({ message: n, content: s }) {
1573
- const t = f(), e = s, i = pt(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1634
+ function _t({ message: n, content: s }) {
1635
+ const t = f(), e = s, i = bt(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1574
1636
  if (!r || !i)
1575
1637
  return null;
1576
1638
  const a = r.component;
@@ -1586,16 +1648,16 @@ function ft({ message: n, content: s }) {
1586
1648
  }
1587
1649
  );
1588
1650
  }
1589
- function Pt({ message: n, content: s }) {
1590
- const { component: t } = Q(s.type);
1651
+ function Dt({ message: n, content: s }) {
1652
+ const { component: t } = $(s.type);
1591
1653
  if (s.type === "capability")
1592
- return /* @__PURE__ */ w.jsx(ft, { message: n, content: s });
1654
+ return /* @__PURE__ */ w.jsx(_t, { message: n, content: s });
1593
1655
  if (!t)
1594
1656
  return null;
1595
1657
  const e = t;
1596
1658
  return /* @__PURE__ */ w.jsx(e, { content: s, message: n });
1597
1659
  }
1598
- function Ft({
1660
+ function Nt({
1599
1661
  message: n,
1600
1662
  content: s,
1601
1663
  context: t,
@@ -1603,7 +1665,7 @@ function Ft({
1603
1665
  onNavigate: i,
1604
1666
  onSwitchContext: r
1605
1667
  }) {
1606
- const { auxiliaryComponent: a } = Q(s.type, t);
1668
+ const { auxiliaryComponent: a } = $(s.type, t);
1607
1669
  if (!a)
1608
1670
  return null;
1609
1671
  const o = a;
@@ -1619,11 +1681,11 @@ function Ft({
1619
1681
  }
1620
1682
  );
1621
1683
  }
1622
- function kt(n) {
1623
- const s = () => (lt(n), null);
1684
+ function Ot(n) {
1685
+ const s = () => (ft(n), null);
1624
1686
  return s.displayName = `Capability(${n.name})`, s;
1625
1687
  }
1626
- class Dt {
1688
+ class jt {
1627
1689
  getAllowedEvents() {
1628
1690
  return null;
1629
1691
  }
@@ -1662,15 +1724,15 @@ class Dt {
1662
1724
  continue;
1663
1725
  }
1664
1726
  if (d.startsWith("data:")) {
1665
- const p = d.substring(5).trim();
1666
- if (p === "eof" || d === "eof")
1727
+ const g = d.substring(5).trim();
1728
+ if (g === "eof" || d === "eof")
1667
1729
  break;
1668
1730
  try {
1669
- const g = JSON.parse(p);
1731
+ const p = JSON.parse(g);
1670
1732
  if (a && this.shouldProcessEvent(a)) {
1671
1733
  const S = this.convertEvent({
1672
1734
  event: a,
1673
- data: g
1735
+ data: p
1674
1736
  });
1675
1737
  S && (yield S);
1676
1738
  }
@@ -1687,39 +1749,39 @@ class Dt {
1687
1749
  }
1688
1750
  }
1689
1751
  export {
1690
- yt as AssistantRuntime,
1691
- _t as AssistantRuntimeProvider,
1692
- Ft as AuxiliaryRenderer,
1693
- Dt as BaseSSEStreamAdapter,
1752
+ rt as AssistantRuntime,
1753
+ wt as AssistantRuntimeProvider,
1754
+ Nt as AuxiliaryRenderer,
1755
+ jt as BaseSSEStreamAdapter,
1694
1756
  K as CapabilityExecutionManager,
1695
1757
  Y as CapabilityRegistry,
1696
- ft as CapabilityRendererComp,
1697
- vt as ChatContextProvider,
1758
+ _t as CapabilityRendererComp,
1759
+ Mt as ChatContextProvider,
1698
1760
  st as ComposerRuntime,
1699
- Pt as ContentRenderer,
1761
+ Dt as ContentRenderer,
1700
1762
  G as PluginRegistry,
1701
1763
  X as QuickActionRegistry,
1702
- R as ThreadListItemRuntime,
1764
+ T as ThreadListItemRuntime,
1703
1765
  it as ThreadListRuntime,
1704
- T as ThreadRuntime,
1766
+ R as ThreadRuntime,
1705
1767
  M as ThreadRuntimeCore,
1706
1768
  v as generateMessageId,
1707
- kt as makeCapability,
1769
+ Ot as makeCapability,
1708
1770
  f as useAssistantRuntime,
1709
- lt as useCapability,
1710
- pt as useCapabilityExecution,
1711
- gt as useChatContext,
1712
- Ct as useComposer,
1713
- It as useContentFocus,
1714
- Q as useContentRenderer,
1715
- ct as useCurrentThread,
1716
- wt as useMessages,
1717
- Rt as usePageContext,
1718
- Mt as useQuickAction,
1719
- Tt as useQuickActionScope,
1720
- Et as useQuickActions,
1721
- At as useRegisterQuickActions,
1722
- St as useThreadList,
1723
- xt as useThreadListState
1771
+ ft as useCapability,
1772
+ bt as useCapabilityExecution,
1773
+ yt as useChatContext,
1774
+ Tt as useComposer,
1775
+ Rt as useContentFocus,
1776
+ $ as useContentRenderer,
1777
+ dt as useCurrentThread,
1778
+ vt as useMessages,
1779
+ At as usePageContext,
1780
+ kt as useQuickAction,
1781
+ Et as useQuickActionScope,
1782
+ Ft as useQuickActions,
1783
+ Pt as useRegisterQuickActions,
1784
+ Ct as useThreadList,
1785
+ It as useThreadListState
1724
1786
  };
1725
1787
  //# sourceMappingURL=index.js.map