@opencx/widget-react-headless 5.8.0 → 5.9.0

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
@@ -3,14 +3,14 @@ var tr = (t) => {
3
3
  };
4
4
  var rr = (t, e, r) => e.has(t) || tr("Cannot " + r);
5
5
  var V = (t, e, r) => (rr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ge = (t, e, r) => e.has(t) ? tr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Q = (t, e, r, n) => (rr(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
6
- import Y, { useSyncExternalStore as zt, useRef as R, useMemo as X, useEffect as F, useState as J, useCallback as z, createContext as Ye, useContext as Fe, memo as jn, useLayoutEffect as kn } from "react";
7
- import { isAgentStreamKeepalive as $n, log as le, isRecord as Mr, genUuid as Rt, buildSendMessageBody as Fn, isAgentOrAiMessage as Un, resolveClientPresentation as qn, ConnectionRequestExpiredError as zn, ConnectionAttemptUnavailableError as Zn, PrimitiveState as _r, WidgetCtx as Vn, resolveSidebarMode as Bn, resolveSidebarSide as Wn, normalizeCompanionLayouts as Jn, resolveCompanionDefaultLayout as Yn } from "@opencx/widget-core";
8
- import { safeParseAsync as Kn, lazy as Hn, unknown as Gn, union as Qn, string as Xn, record as es, object as ts, number as rs, null as ns, never as ss, looseObject as as, literal as is, instanceof as os, enum as ls, discriminatedUnion as cs, custom as us, boolean as ds, array as ps } from "zod/v4";
6
+ import H, { useSyncExternalStore as zt, useRef as R, useMemo as X, useEffect as F, useState as J, useCallback as z, createContext as He, useContext as Fe, memo as jn, useLayoutEffect as kn } from "react";
7
+ import { isAgentStreamKeepalive as $n, log as le, isRecord as Mr, genUuid as Rt, buildSendMessageBody as Fn, isAgentOrAiMessage as Un, resolveClientPresentation as qn, ConnectionRequestExpiredError as zn, ConnectionAttemptUnavailableError as Zn, PrimitiveState as _r, WidgetCtx as Vn, resolveSidebarMode as Bn, resolveSidebarSide as Wn, normalizeCompanionLayouts as Jn, resolveCompanionDefaultLayout as Hn } from "@opencx/widget-core";
8
+ import { safeParseAsync as Yn, lazy as Kn, unknown as Gn, union as Qn, string as Xn, record as es, object as ts, number as rs, null as ns, never as ss, looseObject as as, literal as is, instanceof as os, enum as ls, discriminatedUnion as cs, custom as us, boolean as ds, array as ps } from "zod/v4";
9
9
  import { toJSONSchema as fs } from "zod/v4/core";
10
10
  import "react/jsx-runtime";
11
11
  import { z as L } from "zod";
12
- const Rr = "5.8.0";
13
- function H(t) {
12
+ const Rr = "5.9.0";
13
+ function K(t) {
14
14
  return zt(t.subscribe, t.get, t.get);
15
15
  }
16
16
  function ms({
@@ -500,9 +500,9 @@ function Jr(t, e) {
500
500
  return q(t.type._def, e);
501
501
  }
502
502
  const Fs = (t, e) => q(t.innerType._def, e);
503
- function Yr(t, e, r) {
503
+ function Hr(t, e, r) {
504
504
  const n = r ?? e.dateStrategy;
505
- if (Array.isArray(n)) return { anyOf: n.map((s) => Yr(t, e, s)) };
505
+ if (Array.isArray(n)) return { anyOf: n.map((s) => Hr(t, e, s)) };
506
506
  switch (n) {
507
507
  case "string":
508
508
  case "format:date-time":
@@ -627,7 +627,7 @@ const he = {
627
627
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
628
628
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
629
629
  };
630
- function Kr(t, e) {
630
+ function Yr(t, e) {
631
631
  const r = { type: "string" };
632
632
  if (t.checks) for (const n of t.checks) switch (n.kind) {
633
633
  case "min":
@@ -723,10 +723,10 @@ function Kr(t, e) {
723
723
  return r;
724
724
  }
725
725
  function Dt(t, e) {
726
- return e.patternStrategy === "escape" ? Ys(t) : t;
726
+ return e.patternStrategy === "escape" ? Hs(t) : t;
727
727
  }
728
728
  const Js = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
729
- function Ys(t) {
729
+ function Hs(t) {
730
730
  let e = "";
731
731
  for (let r = 0; r < t.length; r++)
732
732
  Js.has(t[r]) || (e += "\\"), e += t[r];
@@ -797,7 +797,7 @@ function cr(t, e) {
797
797
  }
798
798
  return s;
799
799
  }
800
- function Hr(t, e) {
800
+ function Kr(t, e) {
801
801
  var n, s, o, l, u;
802
802
  const r = {
803
803
  type: "object",
@@ -807,7 +807,7 @@ function Hr(t, e) {
807
807
  }) ?? e.allowedAdditionalProperties
808
808
  };
809
809
  if (((n = t.keyType) == null ? void 0 : n._def.typeName) === "ZodString" && ((s = t.keyType._def.checks) != null && s.length)) {
810
- const { type: y, ...g } = Kr(t.keyType._def, e);
810
+ const { type: y, ...g } = Yr(t.keyType._def, e);
811
811
  return {
812
812
  ...r,
813
813
  propertyNames: g
@@ -827,8 +827,8 @@ function Hr(t, e) {
827
827
  }
828
828
  return r;
829
829
  }
830
- function Ks(t, e) {
831
- return e.mapStrategy === "record" ? Hr(t, e) : {
830
+ function Ys(t, e) {
831
+ return e.mapStrategy === "record" ? Kr(t, e) : {
832
832
  type: "array",
833
833
  maxItems: 125,
834
834
  items: {
@@ -855,7 +855,7 @@ function Ks(t, e) {
855
855
  }
856
856
  };
857
857
  }
858
- function Hs(t) {
858
+ function Ks(t) {
859
859
  const e = t.values, r = Object.keys(t.values).filter((s) => typeof e[e[s]] != "number").map((s) => e[s]), n = Array.from(new Set(r.map((s) => typeof s)));
860
860
  return {
861
861
  type: n.length === 1 ? n[0] === "string" ? "string" : "number" : ["string", "number"],
@@ -1092,7 +1092,7 @@ function pa() {
1092
1092
  const fa = (t, e) => q(t.innerType._def, e), ma = (t, e, r) => {
1093
1093
  switch (e) {
1094
1094
  case "ZodString":
1095
- return Kr(t, r);
1095
+ return Yr(t, r);
1096
1096
  case "ZodNumber":
1097
1097
  return ra(t);
1098
1098
  case "ZodObject":
@@ -1102,7 +1102,7 @@ const fa = (t, e) => q(t.innerType._def, e), ma = (t, e, r) => {
1102
1102
  case "ZodBoolean":
1103
1103
  return $s();
1104
1104
  case "ZodDate":
1105
- return Yr(t, r);
1105
+ return Hr(t, r);
1106
1106
  case "ZodUndefined":
1107
1107
  return da();
1108
1108
  case "ZodNull":
@@ -1117,19 +1117,19 @@ const fa = (t, e) => q(t.innerType._def, e), ma = (t, e, r) => {
1117
1117
  case "ZodTuple":
1118
1118
  return ua(t, r);
1119
1119
  case "ZodRecord":
1120
- return Hr(t, r);
1120
+ return Kr(t, r);
1121
1121
  case "ZodLiteral":
1122
1122
  return Ws(t);
1123
1123
  case "ZodEnum":
1124
1124
  return Zs(t);
1125
1125
  case "ZodNativeEnum":
1126
- return Hs(t);
1126
+ return Ks(t);
1127
1127
  case "ZodNullable":
1128
1128
  return ta(t, r);
1129
1129
  case "ZodOptional":
1130
1130
  return ia(t, r);
1131
1131
  case "ZodMap":
1132
- return Ks(t, r);
1132
+ return Ys(t, r);
1133
1133
  case "ZodSet":
1134
1134
  return ca(t, r);
1135
1135
  case "ZodLazy":
@@ -1323,7 +1323,7 @@ function xa(t, e) {
1323
1323
  io: "input",
1324
1324
  reused: "inline"
1325
1325
  })), { validate: async (r) => {
1326
- const n = await Kn(t, r);
1326
+ const n = await Yn(t, r);
1327
1327
  return n.success ? {
1328
1328
  success: !0,
1329
1329
  value: n.data
@@ -1468,7 +1468,7 @@ const a = {
1468
1468
  discriminatedUnion: cs,
1469
1469
  enum: ls,
1470
1470
  instanceof: os,
1471
- lazy: Hn,
1471
+ lazy: Kn,
1472
1472
  literal: is,
1473
1473
  looseObject: as,
1474
1474
  never: ss,
@@ -1972,7 +1972,7 @@ const Ja = a.object({
1972
1972
  startIndex: a.number().int().nonnegative().optional(),
1973
1973
  endIndex: a.number().int().nonnegative().optional(),
1974
1974
  citedText: a.string().optional()
1975
- }), Ge = a.record(a.string(), $e.optional()), Ya = Sa(() => Gr(a.union([
1975
+ }), Ge = a.record(a.string(), $e.optional()), Ha = Sa(() => Gr(a.union([
1976
1976
  a.looseObject({
1977
1977
  type: a.literal("text-start"),
1978
1978
  id: a.string(),
@@ -2158,7 +2158,7 @@ const Ja = a.object({
2158
2158
  messageMetadata: a.unknown()
2159
2159
  })
2160
2160
  ])));
2161
- function Ka(t) {
2161
+ function Ya(t) {
2162
2162
  return t.type.startsWith("data-");
2163
2163
  }
2164
2164
  function Be() {
@@ -2176,7 +2176,7 @@ function pe(t) {
2176
2176
  function ht(t) {
2177
2177
  return t.type.split("-").slice(1).join("-");
2178
2178
  }
2179
- function Ha(t) {
2179
+ function Ka(t) {
2180
2180
  return cn(t) ? t.toolName : ht(t);
2181
2181
  }
2182
2182
  function un({ lastMessage: t, messageId: e }) {
@@ -2632,7 +2632,7 @@ function Ga({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2632
2632
  s == null || s(new Error(i.errorText));
2633
2633
  break;
2634
2634
  default:
2635
- if (Ka(i)) {
2635
+ if (Ya(i)) {
2636
2636
  if ((r == null ? void 0 : r[i.type]) != null) {
2637
2637
  const f = p.message.parts.findIndex((S) => "id" in S && "data" in S && S.id === i.id && S.type === i.type), h = f >= 0 ? f : p.message.parts.length;
2638
2638
  await ur({
@@ -2921,7 +2921,7 @@ var ni = class {
2921
2921
  processResponseStream(t) {
2922
2922
  return Ma({
2923
2923
  stream: t,
2924
- schema: Ya
2924
+ schema: Ha
2925
2925
  }).pipeThrough(new TransformStream({ async transform(e, r) {
2926
2926
  if (!e.success) throw e.error;
2927
2927
  r.enqueue(e.value);
@@ -3999,8 +3999,8 @@ function Vi({
3999
3999
  }, [p, f, o]);
4000
4000
  const $ = R("idle"), [Se, Ie] = J(!1), [ve, ae] = J(0), [G, de] = J(!1), fe = R(G);
4001
4001
  fe.current = G;
4002
- const [Ee, U] = J([]), [ie, Ce] = J([]), [me, Cn] = J(null), Ke = R(null), Re = z((v) => {
4003
- Ke.current = v, Cn(v);
4002
+ const [Ee, U] = J([]), [ie, Ce] = J([]), [me, Cn] = J(null), Ye = R(null), Re = z((v) => {
4003
+ Ye.current = v, Cn(v);
4004
4004
  }, []), Ue = R(null), we = R(null), Ae = R(null), Wt = R(r);
4005
4005
  Wt.current = r;
4006
4006
  const Jt = (v, E, T) => {
@@ -4024,25 +4024,25 @@ function Vi({
4024
4024
  bubbleId: T.userMessage.id
4025
4025
  } : E === "resume" && Ae.current === null && (Ae.current = { kind: "resume" }), Jt(v, E, !1);
4026
4026
  };
4027
- const Yt = R(!1);
4027
+ const Ht = R(!1);
4028
4028
  i.current = (v, E) => {
4029
- Yt.current || (Yt.current = !0, le.warn(
4029
+ Ht.current || (Ht.current = !0, le.warn(
4030
4030
  "the `streamingFetch` response has no readable body, so replies are read through the global fetch instead. Return the `expo/fetch` response unchanged to stream it directly."
4031
4031
  )), Jt(E, v, !0);
4032
4032
  };
4033
- const qe = R(m), He = I.current === r, Et = R(null), Ct = R(null), Kt = R(S), xe = R(m);
4033
+ const qe = R(m), Ke = I.current === r, Et = R(null), Ct = R(null), Yt = R(S), xe = R(m);
4034
4034
  xe.current = m;
4035
4035
  const tt = z((v, E) => {
4036
4036
  const T = Sr(v.parts);
4037
4037
  if (!T || T.rowIds.length === 0) return;
4038
4038
  const A = pt(v.parts);
4039
4039
  A.length !== 0 && U(
4040
- (k) => k.some((K) => K.turnId === T.turnId) ? k : [
4040
+ (k) => k.some((Y) => Y.turnId === T.turnId) ? k : [
4041
4041
  ...k,
4042
4042
  { key: E, turnId: T.turnId, rowIds: T.rowIds, items: A }
4043
4043
  ]
4044
4044
  );
4045
- }, []), Ht = z(
4045
+ }, []), Kt = z(
4046
4046
  (v) => Fn({
4047
4047
  config: l.current,
4048
4048
  input: v.input,
@@ -4055,8 +4055,8 @@ function Vi({
4055
4055
  [t]
4056
4056
  );
4057
4057
  F(() => {
4058
- const v = Kt.current;
4059
- Kt.current = S;
4058
+ const v = Yt.current;
4059
+ Yt.current = S;
4060
4060
  const E = I.current;
4061
4061
  if (E === r) return;
4062
4062
  if (I.current = r, E === null) {
@@ -4068,7 +4068,7 @@ function Vi({
4068
4068
  le.error("agent chat client stream cancel failed", A);
4069
4069
  });
4070
4070
  }, [r, m, S, D, Re]), F(() => {
4071
- var k, K;
4071
+ var k, Y;
4072
4072
  const v = Et.current;
4073
4073
  if (v !== null && m === v) {
4074
4074
  qe.current = "ready";
@@ -4076,7 +4076,7 @@ function Vi({
4076
4076
  }
4077
4077
  Et.current = null;
4078
4078
  const E = qe.current;
4079
- if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ke.current === null && Re(`turn-resumed-${Rt()}`), de(!0)), m === "streaming") {
4079
+ if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ye.current === null && Re(`turn-resumed-${Rt()}`), de(!0)), m === "streaming") {
4080
4080
  const Z = (k = we.current) == null ? void 0 : k.userMessage.id;
4081
4081
  Z && o.markUserMessageDelivered(Z);
4082
4082
  return;
@@ -4087,9 +4087,9 @@ function Vi({
4087
4087
  de(!0);
4088
4088
  const Z = $.current === "in-flight";
4089
4089
  Z && ($.current = "idle");
4090
- const re = W.current.at(-1), be = Ke.current;
4090
+ const re = W.current.at(-1), be = Ye.current;
4091
4091
  if (Ue.current = be, be !== null && re && re.role === "assistant" && tt(re, be), m === "ready") {
4092
- const Pe = (K = we.current) == null ? void 0 : K.userMessage.id;
4092
+ const Pe = (Y = we.current) == null ? void 0 : Y.userMessage.id;
4093
4093
  Pe && o.markUserMessageDelivered(Pe);
4094
4094
  } else Z && E !== "streaming" && we.current && o.releaseUnsentOptionPick(we.current.input);
4095
4095
  $.current === "stopping" || (r ? ($.current = "reconciling", t.reconcileAfterStream(r).catch((Pe) => {
@@ -4102,7 +4102,7 @@ function Vi({
4102
4102
  const A = j.current.dequeueNext();
4103
4103
  A && ($.current = "in-flight", Ie(!1), we.current = A, Ae.current = null, b(null), P.current = !1, Re(`turn-${A.userMessage.id}`), o.appendUserMessageIfAbsent(A.userMessage), ae((Z) => Z + 1), h(
4104
4104
  { text: A.userMessage.content },
4105
- { body: Ht(A) }
4105
+ { body: Kt(A) }
4106
4106
  ));
4107
4107
  }, [
4108
4108
  m,
@@ -4111,7 +4111,7 @@ function Vi({
4111
4111
  h,
4112
4112
  o,
4113
4113
  t,
4114
- Ht,
4114
+ Kt,
4115
4115
  tt,
4116
4116
  Re,
4117
4117
  p
@@ -4146,10 +4146,10 @@ function Vi({
4146
4146
  },
4147
4147
  [o]
4148
4148
  ), wn = z(() => {
4149
- var K;
4149
+ var Y;
4150
4150
  const v = we.current;
4151
4151
  if (!v) return;
4152
- const E = v.input.optionReply, T = E ? n.find((Z) => Z.id === E.messageId) : void 0, A = T && Un(T) ? (K = T.messageOptions) == null ? void 0 : K.pickedOptionId : null;
4152
+ const E = v.input.optionReply, T = E ? n.find((Z) => Z.id === E.messageId) : void 0, A = T && Un(T) ? (Y = T.messageOptions) == null ? void 0 : Y.pickedOptionId : null;
4153
4153
  if (E && A && A !== E.optionId) return;
4154
4154
  if (!j.current.enqueue({
4155
4155
  ...v,
@@ -4197,9 +4197,9 @@ function Vi({
4197
4197
  }, [o, Gt]);
4198
4198
  const rt = (Qt = e.presentation) == null ? void 0 : Qt.toolActivity, nt = (Xt = e.presentation) == null ? void 0 : Xt.reasoning;
4199
4199
  F(() => Ce([]), [r]), F(() => {
4200
- var k, K;
4200
+ var k, Y;
4201
4201
  if (!r) return;
4202
- const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current, T = (E == null ? void 0 : E.sessionId) === r && (((k = E.presentation) == null ? void 0 : k.toolActivity) !== rt || ((K = E.presentation) == null ? void 0 : K.reasoning) !== nt);
4202
+ const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current, T = (E == null ? void 0 : E.sessionId) === r && (((k = E.presentation) == null ? void 0 : k.toolActivity) !== rt || ((Y = E.presentation) == null ? void 0 : Y.reasoning) !== nt);
4203
4203
  Ct.current = { sessionId: r, presentation: v };
4204
4204
  let A = !1;
4205
4205
  return (async () => {
@@ -4224,7 +4224,7 @@ function Vi({
4224
4224
  const E = [];
4225
4225
  for (const T of v.parts) {
4226
4226
  if (!pe(T)) continue;
4227
- const A = Ha(T), k = A === zi ? "highlight-element" : A === Zi ? "act-on-page" : null;
4227
+ const A = Ka(T), k = A === zi ? "highlight-element" : A === Zi ? "act-on-page" : null;
4228
4228
  k && T.state === "input-available" && E.push({
4229
4229
  key: `${r ?? "pending"}:${T.toolCallId}`,
4230
4230
  type: k,
@@ -4250,12 +4250,12 @@ function Vi({
4250
4250
  const k = `${r}:${v}`;
4251
4251
  if (st.current.has(k)) return;
4252
4252
  At.current.delete(k);
4253
- const K = new Set(st.current);
4254
- if (K.add(k), K.size > 200) {
4255
- const Z = K.values().next().value;
4256
- Z !== void 0 && K.delete(Z);
4253
+ const Y = new Set(st.current);
4254
+ if (Y.add(k), Y.size > 200) {
4255
+ const Z = Y.values().next().value;
4256
+ Z !== void 0 && Y.delete(Z);
4257
4257
  }
4258
- st.current = K, Tn(K), s.sendPageReply(r, {
4258
+ st.current = Y, Tn(Y), s.sendPageReply(r, {
4259
4259
  callId: v,
4260
4260
  outcome: E,
4261
4261
  ...T ? { detail: T } : {},
@@ -4306,7 +4306,7 @@ function Vi({
4306
4306
  if (E === void 0) return;
4307
4307
  const T = new Set(n.map((re) => re.id));
4308
4308
  let A = !1, k;
4309
- const K = async (re) => {
4309
+ const Y = async (re) => {
4310
4310
  let be;
4311
4311
  try {
4312
4312
  be = await s.getAgentTurnMessages(r);
@@ -4322,9 +4322,9 @@ function Vi({
4322
4322
  return;
4323
4323
  }
4324
4324
  const [er, ...Dn] = re;
4325
- er !== void 0 && (k = setTimeout(() => void K(Dn), er));
4325
+ er !== void 0 && (k = setTimeout(() => void Y(Dn), er));
4326
4326
  };
4327
- return K(qi), () => {
4327
+ return Y(qi), () => {
4328
4328
  A = !0, k !== void 0 && clearTimeout(k);
4329
4329
  };
4330
4330
  }, [
@@ -4360,9 +4360,9 @@ function Vi({
4360
4360
  ), F(() => {
4361
4361
  if (oe || !G) return;
4362
4362
  const v = () => {
4363
- de(!1), ae((A) => A + 1), Ke.current === Ue.current && Re(null), Ue.current = null;
4363
+ de(!1), ae((A) => A + 1), Ye.current === Ue.current && Re(null), Ue.current = null;
4364
4364
  };
4365
- if (Ke.current === Ue.current && (p == null ? void 0 : p.messages) === f && !p.isError && !p.isDisconnect && (!p.isAbort || P.current) && !pt(p.message.parts).some(
4365
+ if (Ye.current === Ue.current && (p == null ? void 0 : p.messages) === f && !p.isError && !p.isDisconnect && (!p.isAbort || P.current) && !pt(p.message.parts).some(
4366
4366
  (A) => A.kind !== "steps"
4367
4367
  )) {
4368
4368
  const A = n.findLast((k) => k.type === "USER");
@@ -4400,7 +4400,7 @@ function Vi({
4400
4400
  t.agent.presentation,
4401
4401
  e.presentation
4402
4402
  ), it = ze == null ? void 0 : ze.toolActivity, ot = ze == null ? void 0 : ze.reasoning, Pn = X(() => {
4403
- if (!He || me === null || m === "submitted" || !oe && !G)
4403
+ if (!Ke || me === null || m === "submitted" || !oe && !G)
4404
4404
  return [];
4405
4405
  const v = f.at(-1);
4406
4406
  return !v || v.role !== "assistant" ? [] : gr(pt(v.parts), {
@@ -4414,17 +4414,17 @@ function Vi({
4414
4414
  G,
4415
4415
  it,
4416
4416
  ot,
4417
- He,
4417
+ Ke,
4418
4418
  me
4419
4419
  ]), On = X(
4420
- () => He ? Ee.flatMap((v) => {
4420
+ () => Ke ? Ee.flatMap((v) => {
4421
4421
  const E = gr(v.items, {
4422
4422
  toolActivity: it,
4423
4423
  reasoning: ot
4424
4424
  });
4425
4425
  return E.length === 0 ? [] : [E === v.items ? v : { ...v, items: E }];
4426
4426
  }) : [],
4427
- [Ee, it, ot, He]
4427
+ [Ee, it, ot, Ke]
4428
4428
  ), Nn = X(
4429
4429
  () => j.current.items.filter((v) => !v.input.background).map((v) => v.userMessage),
4430
4430
  // eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
@@ -4450,13 +4450,13 @@ function Vi({
4450
4450
  requestPageActionConsent: Rn,
4451
4451
  resolvePageAction: Mt,
4452
4452
  handledConnectionRequestIds: ie,
4453
- sourceSessionId: He ? r : null
4453
+ sourceSessionId: Ke ? r : null
4454
4454
  };
4455
4455
  }
4456
4456
  function Bi(t) {
4457
4457
  return t ? { ...t, initialMessages: [] } : null;
4458
4458
  }
4459
- const Cr = 2e3, wr = 6e5, Wi = 1e4, bt = Ye(null), Ji = (t, e) => e === "dismiss" ? {
4459
+ const Cr = 2e3, wr = 6e5, Wi = 1e4, bt = He(null), Ji = (t, e) => e === "dismiss" ? {
4460
4460
  content: `Continue without connecting ${t.name}.`,
4461
4461
  connectionRequestId: t.request_id
4462
4462
  } : e === "renew" ? {
@@ -4472,7 +4472,7 @@ const Cr = 2e3, wr = 6e5, Wi = 1e4, bt = Ye(null), Ji = (t, e) => e === "dismiss
4472
4472
  connectionRequestId: t.request_id,
4473
4473
  content: `The connection to ${t.name} is ready. Please use its tools to continue my previous request.`
4474
4474
  };
4475
- function Yi({
4475
+ function Hi({
4476
4476
  children: t,
4477
4477
  request: e,
4478
4478
  widgetCtx: r,
@@ -4665,7 +4665,7 @@ function Yi({
4665
4665
  m
4666
4666
  ]
4667
4667
  );
4668
- return Y.createElement(
4668
+ return H.createElement(
4669
4669
  bt.Provider,
4670
4670
  {
4671
4671
  value: N
@@ -4673,17 +4673,17 @@ function Yi({
4673
4673
  t
4674
4674
  );
4675
4675
  }
4676
- function Ki({
4676
+ function Yi({
4677
4677
  children: t,
4678
4678
  connection: e
4679
4679
  }) {
4680
- return Y.createElement(
4680
+ return H.createElement(
4681
4681
  bt.Provider,
4682
4682
  { value: e },
4683
4683
  t
4684
4684
  );
4685
4685
  }
4686
- function Hi() {
4686
+ function Ki() {
4687
4687
  return Fe(bt);
4688
4688
  }
4689
4689
  function To(t) {
@@ -4718,7 +4718,7 @@ const Bt = {
4718
4718
  },
4719
4719
  pendingClarification: null,
4720
4720
  pendingConnection: null
4721
- }, St = Ye(null);
4721
+ }, St = He(null);
4722
4722
  function pn() {
4723
4723
  return Fe(St) ?? Bt;
4724
4724
  }
@@ -4728,7 +4728,7 @@ function Gi({
4728
4728
  config: r
4729
4729
  }) {
4730
4730
  var ve, ae, G, de, fe, Ee;
4731
- const n = H(e.sessionCtx.sessionState), s = H(e.messageCtx.state), {
4731
+ const n = K(e.sessionCtx.sessionState), s = K(e.messageCtx.state), {
4732
4732
  isStreaming: o,
4733
4733
  liveItems: l,
4734
4734
  turnSources: u,
@@ -4825,9 +4825,9 @@ function Gi({
4825
4825
  m,
4826
4826
  j
4827
4827
  ]
4828
- ), Ie = /* @__PURE__ */ Y.createElement(St.Provider, { value: Se }, t);
4829
- return /* @__PURE__ */ Y.createElement(
4830
- Yi,
4828
+ ), Ie = /* @__PURE__ */ H.createElement(St.Provider, { value: Se }, t);
4829
+ return /* @__PURE__ */ H.createElement(
4830
+ Hi,
4831
4831
  {
4832
4832
  request: j,
4833
4833
  widgetCtx: e,
@@ -4841,7 +4841,7 @@ function fn({
4841
4841
  widgetCtx: e,
4842
4842
  config: r
4843
4843
  }) {
4844
- return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */ Y.createElement(Gi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ Y.createElement(St.Provider, { value: Bt }, t);
4844
+ return K(e.messageCtx.state), e.streaming ? /* @__PURE__ */ H.createElement(Gi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ H.createElement(St.Provider, { value: Bt }, t);
4845
4845
  }
4846
4846
  class Qi {
4847
4847
  constructor(e) {
@@ -4941,9 +4941,9 @@ class Qi {
4941
4941
  return !e.closed && !r && !this.isWorking(e) && !e.ctx.messageCtx.state.get().messages.length && !n && !s.length && !e.ctx.uploadCtx.state.get().length;
4942
4942
  }
4943
4943
  }
4944
- const mn = Ye(null), Xi = new _r({ chats: [], activeId: 0 });
4944
+ const mn = He(null), Xi = new _r({ chats: [], activeId: 0 });
4945
4945
  function gn() {
4946
- const t = Fe(mn), e = H((t == null ? void 0 : t.state) ?? Xi), r = e.chats.filter((s) => !s.closed), n = r.filter(
4946
+ const t = Fe(mn), e = K((t == null ? void 0 : t.state) ?? Xi), r = e.chats.filter((s) => !s.closed), n = r.filter(
4947
4947
  (s) => s.hasSession || s.working || s.hasDraft || s.title
4948
4948
  );
4949
4949
  return { workspace: t, chats: r, openChats: n, activeId: e.activeId };
@@ -4964,7 +4964,7 @@ function eo({
4964
4964
  ctx: e,
4965
4965
  workspace: r
4966
4966
  }) {
4967
- const n = pn(), s = Hi(), o = H(e.messageCtx.state), l = H(e.sessionCtx.sessionState), u = H(e.messageCtx.draftState), y = H(e.uploadCtx.state), g = o.messages.find(
4967
+ const n = pn(), s = Ki(), o = K(e.messageCtx.state), l = K(e.sessionCtx.sessionState), u = K(e.messageCtx.draftState), y = K(e.uploadCtx.state), g = o.messages.find(
4968
4968
  (P) => P.type === "USER"
4969
4969
  ), i = (g == null ? void 0 : g.type) === "USER" ? g.content.slice(0, 60) : "", d = n.isStreaming || o.isSendingMessage || l.isCreatingSession, p = !!l.session, b = !!u.text || u.mentions.length > 0 || y.length > 0;
4970
4970
  return F(
@@ -4985,7 +4985,7 @@ const to = jn(function({
4985
4985
  config: n,
4986
4986
  workspace: s
4987
4987
  }) {
4988
- return /* @__PURE__ */ Y.createElement(fn, { widgetCtx: r, config: n }, /* @__PURE__ */ Y.createElement(eo, { chatId: e, ctx: r, workspace: s }));
4988
+ return /* @__PURE__ */ H.createElement(fn, { widgetCtx: r, config: n }, /* @__PURE__ */ H.createElement(eo, { chatId: e, ctx: r, workspace: s }));
4989
4989
  });
4990
4990
  function ro({
4991
4991
  widgetCtx: t,
@@ -4997,8 +4997,8 @@ function ro({
4997
4997
  [t]
4998
4998
  );
4999
4999
  F(() => n.mount(), [n]);
5000
- const { chats: s, activeId: o } = H(n.state), l = s.find((y) => y.id === o), u = X(
5001
- () => s.map((y) => /* @__PURE__ */ Y.createElement(
5000
+ const { chats: s, activeId: o } = K(n.state), l = s.find((y) => y.id === o), u = X(
5001
+ () => s.map((y) => /* @__PURE__ */ H.createElement(
5002
5002
  to,
5003
5003
  {
5004
5004
  key: y.id,
@@ -5010,7 +5010,7 @@ function ro({
5010
5010
  )),
5011
5011
  [s, e, n]
5012
5012
  );
5013
- return /* @__PURE__ */ Y.createElement(mn.Provider, { value: n }, u, /* @__PURE__ */ Y.createElement(Ki, { connection: l.connection }, /* @__PURE__ */ Y.createElement(St.Provider, { value: l.ui }, r(l.ctx))));
5013
+ return /* @__PURE__ */ H.createElement(mn.Provider, { value: n }, u, /* @__PURE__ */ H.createElement(Yi, { connection: l.connection }, /* @__PURE__ */ H.createElement(St.Provider, { value: l.ui }, r(l.ctx))));
5014
5014
  }
5015
5015
  class no {
5016
5016
  constructor(e) {
@@ -5093,7 +5093,7 @@ const Ar = L.object({
5093
5093
  externalId: e.externalId ?? null,
5094
5094
  opaqueToken: r
5095
5095
  });
5096
- }, hn = Ye(null);
5096
+ }, hn = He(null);
5097
5097
  function _o({
5098
5098
  options: t,
5099
5099
  children: e,
@@ -5168,10 +5168,10 @@ function _o({
5168
5168
  var w;
5169
5169
  p.status !== "ready" || p.identity !== y || (w = t.user) != null && w.token && p.widgetCtx.api.setAuthToken(t.user.token);
5170
5170
  }, [(x = t.user) == null ? void 0 : x.token, y, p]), p.status === "loading" || "identity" in p && p.identity !== y)
5171
- return s ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, s) : null;
5171
+ return s ? /* @__PURE__ */ H.createElement(H.Fragment, null, s) : null;
5172
5172
  if (p.status === "error")
5173
- return o ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, o(p.error)) : null;
5174
- const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */ Y.createElement(
5173
+ return o ? /* @__PURE__ */ H.createElement(H.Fragment, null, o(p.error)) : null;
5174
+ const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */ H.createElement(
5175
5175
  hn.Provider,
5176
5176
  {
5177
5177
  value: {
@@ -5185,9 +5185,9 @@ function _o({
5185
5185
  },
5186
5186
  I
5187
5187
  );
5188
- return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */ Y.createElement(ro, { widgetCtx: M, config: t }, (w) => O(w, e)) : O(
5188
+ return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */ H.createElement(ro, { widgetCtx: M, config: t }, (w) => O(w, e)) : O(
5189
5189
  M,
5190
- /* @__PURE__ */ Y.createElement(fn, { key: y, widgetCtx: M, config: t }, e)
5190
+ /* @__PURE__ */ H.createElement(fn, { key: y, widgetCtx: M, config: t }, e)
5191
5191
  );
5192
5192
  }
5193
5193
  function se() {
@@ -5234,7 +5234,7 @@ function Oo() {
5234
5234
  function No() {
5235
5235
  const { widgetCtx: t } = se();
5236
5236
  return {
5237
- contactState: H(t.contactCtx.state),
5237
+ contactState: K(t.contactCtx.state),
5238
5238
  createUnverifiedContact: t.contactCtx.createUnverifiedContact
5239
5239
  };
5240
5240
  }
@@ -5291,7 +5291,7 @@ function Do() {
5291
5291
  return zt(co, uo, () => "");
5292
5292
  }
5293
5293
  function bn() {
5294
- const { widgetCtx: t } = se(), e = H(t.messageCtx.state), { isStreaming: r } = pn();
5294
+ const { widgetCtx: t } = se(), e = K(t.messageCtx.state), { isStreaming: r } = pn();
5295
5295
  return {
5296
5296
  messagesState: r ? { ...e, isSendingMessage: !0, isSendingMessageToAI: !0 } : e,
5297
5297
  sendMessage: t.messageCtx.sendMessage,
@@ -5303,7 +5303,7 @@ function bn() {
5303
5303
  }
5304
5304
  function Sn() {
5305
5305
  var y;
5306
- const { widgetCtx: t } = se(), { oneOpenSessionAllowed: e } = It(), r = H(t.sessionCtx.sessionState), n = H(t.sessionCtx.sessionsState), { openSessions: s, closedSessions: o } = X(() => ({
5306
+ const { widgetCtx: t } = se(), { oneOpenSessionAllowed: e } = It(), r = K(t.sessionCtx.sessionState), n = K(t.sessionCtx.sessionsState), { openSessions: s, closedSessions: o } = X(() => ({
5307
5307
  openSessions: n.data.filter((g) => g.isOpened === !0),
5308
5308
  closedSessions: n.data.filter((g) => g.isOpened === !1)
5309
5309
  }), [n.data]), { workspace: l } = gn(), u = l ? l.canCreateChat() : !e || s.length === 0 && !r.isCreatingSession && !((y = r.session) != null && y.isOpened);
@@ -5326,13 +5326,15 @@ function Lo() {
5326
5326
  function po() {
5327
5327
  const { widgetCtx: t } = se();
5328
5328
  return {
5329
- routerState: H(t.routerCtx.state),
5329
+ routerState: K(t.routerCtx.state),
5330
+ toHomeScreen: t.routerCtx.toHomeScreen,
5331
+ toLandingScreen: t.routerCtx.toLandingScreen,
5330
5332
  toSessionsScreen: t.routerCtx.toSessionsScreen,
5331
5333
  toChatScreen: t.routerCtx.toChatScreen
5332
5334
  };
5333
5335
  }
5334
5336
  function jo() {
5335
- const { widgetCtx: t } = se(), { unreadSessionIds: e, count: r } = H(
5337
+ const { widgetCtx: t } = se(), { unreadSessionIds: e, count: r } = K(
5336
5338
  t.unreadCtx.state
5337
5339
  ), n = z(
5338
5340
  (s) => e.includes(s),
@@ -5340,7 +5342,7 @@ function jo() {
5340
5342
  );
5341
5343
  return { count: r, hasUnread: r > 0, unreadSessionIds: e, isUnread: n };
5342
5344
  }
5343
- const In = Ye(null);
5345
+ const In = He(null);
5344
5346
  function ko({ children: t }) {
5345
5347
  const e = It(), [r, n] = J(() => e.inline ? !0 : e.isOpen ?? !1);
5346
5348
  return F(() => {
@@ -5351,7 +5353,7 @@ function ko({ children: t }) {
5351
5353
  return;
5352
5354
  const o = setTimeout(() => n(!0), s * 1e3);
5353
5355
  return () => clearTimeout(o);
5354
- }, [e.openAfterNSeconds]), /* @__PURE__ */ Y.createElement(In.Provider, { value: { isOpen: r, setIsOpen: n } }, t);
5356
+ }, [e.openAfterNSeconds]), /* @__PURE__ */ H.createElement(In.Provider, { value: { isOpen: r, setIsOpen: n } }, t);
5355
5357
  }
5356
5358
  function fo() {
5357
5359
  const t = Fe(In);
@@ -5365,7 +5367,7 @@ const mo = (t) => (document.addEventListener("visibilitychange", t), () => docum
5365
5367
  function $o({
5366
5368
  transcriptVisible: t = !0
5367
5369
  } = {}) {
5368
- const { widgetCtx: e } = se(), { isOpen: r } = fo(), { routerState: n } = po(), { session: s } = H(e.sessionCtx.sessionState), { isInitialFetchLoading: o } = H(
5370
+ const { widgetCtx: e } = se(), { isOpen: r } = fo(), { routerState: n } = po(), { session: s } = K(e.sessionCtx.sessionState), { isInitialFetchLoading: o } = K(
5369
5371
  e.messageCtx.state
5370
5372
  ), l = zt(
5371
5373
  mo,
@@ -5382,7 +5384,7 @@ function $o({
5382
5384
  function Fo() {
5383
5385
  const {
5384
5386
  widgetCtx: { uploadCtx: t }
5385
- } = se(), e = H(t.state), r = X(
5387
+ } = se(), e = K(t.state), r = X(
5386
5388
  () => e.filter((n) => n.status === "success" && n.fileUrl),
5387
5389
  [e]
5388
5390
  );
@@ -5408,11 +5410,11 @@ function Fo() {
5408
5410
  function ho(t) {
5409
5411
  return t !== "fullscreen";
5410
5412
  }
5411
- const En = Ye(null);
5413
+ const En = He(null);
5412
5414
  function Uo({ children: t }) {
5413
5415
  var s, o;
5414
5416
  const { companion: e } = It(), { dir: r } = oo(), { widgetCtx: n } = se();
5415
- return /* @__PURE__ */ Y.createElement(
5417
+ return /* @__PURE__ */ H.createElement(
5416
5418
  yo,
5417
5419
  {
5418
5420
  configuredDefaultLayout: e == null ? void 0 : e.defaultLayout,
@@ -5432,7 +5434,7 @@ function yo({
5432
5434
  storage: s,
5433
5435
  children: o
5434
5436
  }) {
5435
- const l = Jn(e), u = Yn(
5437
+ const l = Jn(e), u = Hn(
5436
5438
  t,
5437
5439
  l
5438
5440
  ), y = l.join("|"), [g, i] = J(u), [d, p] = J({
@@ -5486,7 +5488,7 @@ function yo({
5486
5488
  },
5487
5489
  [s]
5488
5490
  );
5489
- return /* @__PURE__ */ Y.createElement(
5491
+ return /* @__PURE__ */ H.createElement(
5490
5492
  En.Provider,
5491
5493
  {
5492
5494
  value: {
@@ -5568,7 +5570,7 @@ function Zo() {
5568
5570
  };
5569
5571
  }
5570
5572
  function Vo(t) {
5571
- const { widgetCtx: e } = se(), r = e.dictationCtx, n = H(r.state), s = R(t);
5573
+ const { widgetCtx: e } = se(), r = e.dictationCtx, n = K(r.state), s = R(t);
5572
5574
  s.current = t;
5573
5575
  const o = z(() => {
5574
5576
  r.start({
@@ -5596,7 +5598,7 @@ function Vo(t) {
5596
5598
  };
5597
5599
  }
5598
5600
  function Bo() {
5599
- const { widgetCtx: t } = se(), e = t.messageCtx.draftState, r = H(e), n = z(
5601
+ const { widgetCtx: t } = se(), e = t.messageCtx.draftState, r = K(e), n = z(
5600
5602
  (l) => {
5601
5603
  e.setPartial({
5602
5604
  text: typeof l == "function" ? l(e.get().text) : l
@@ -5639,7 +5641,7 @@ export {
5639
5641
  Lo as useIsAwaitingBotReply,
5640
5642
  bn as useMessages,
5641
5643
  zo as useModes,
5642
- H as usePrimitiveState,
5644
+ K as usePrimitiveState,
5643
5645
  Sn as useSessions,
5644
5646
  jo as useUnread,
5645
5647
  $o as useUnreadViewing,