site-operator-react 0.1.13 → 0.2.1

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/README.md CHANGED
@@ -8,6 +8,8 @@ npm install site-operator-react
8
8
 
9
9
  ```tsx
10
10
  import { AgentChat, type AppContext, type AppState } from 'site-operator-react';
11
+ import type { AgentChat as AgentChatElement } from 'site-operator';
12
+ import { useRef } from 'react';
11
13
 
12
14
  const context: AppContext = {
13
15
  v: "1.1",
@@ -67,9 +69,12 @@ const state: AppState = {
67
69
  };
68
70
 
69
71
  function App() {
72
+ const chatRef = useRef<AgentChatElement>(null);
73
+
70
74
  return (
71
75
  <div className="App">
72
76
  <AgentChat
77
+ ref={chatRef}
73
78
  backendUrl="http://localhost:8001/ag_ui"
74
79
  appName="My React App"
75
80
  context={{ appContext: context, appState: state }}
@@ -82,10 +87,12 @@ function App() {
82
87
 
83
88
  ### useChatPortal Hook
84
89
 
85
- The `useChatPortal` hook allows you to register the "Copilot" capabilities (`AppContext`) for your application. This lets the agent understand the app structure and available targets.
90
+ The `useChatPortal` hook allows you to register the "Copilot" capabilities (`AppContext`) for your application. This lets the agent understand the app structure and available targets. It can also return the live `ChatController` from `AgentChat` when you pass a `chatRef`.
86
91
 
87
92
  ```tsx
88
93
  import { useChatPortal, type AppContext } from 'site-operator-react';
94
+ import type { AgentChat as AgentChatElement } from 'site-operator';
95
+ import { useRef } from 'react';
89
96
 
90
97
  const context: AppContext = {
91
98
  v: "1.1",
@@ -98,11 +105,17 @@ const context: AppContext = {
98
105
  };
99
106
 
100
107
  function App() {
101
- useChatPortal(context);
108
+ const chatRef = useRef<AgentChatElement>(null);
109
+ const controller = useChatPortal(context, { chatRef });
102
110
 
103
111
  return (
104
- // ...
112
+ <AgentChat ref={chatRef} context={{ appContext: context }} />
105
113
  );
106
114
  }
107
- ```
108
115
 
116
+ // How chatRef works:
117
+ // - pass it to <AgentChat /> so React forwards it to the web component
118
+ // - useChatPortal listens for the "controller-ready" event
119
+ // - once ready, it returns the live ChatController instance
120
+ // controller?.sendMessage('Hola');
121
+ ```
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
+ import { AgentChat as AgentChat_2 } from 'site-operator';
1
2
  import { AgentState } from 'site-operator';
2
3
  import { AppContext } from 'site-operator';
3
4
  import { AppState } from 'site-operator';
5
+ import { ChatController } from 'site-operator';
4
6
  import { ClickTarget } from 'site-operator';
5
7
  import { default as default_2 } from 'react';
8
+ import { RefObject } from 'react';
6
9
 
7
- export declare const AgentChat: default_2.FC<AgentChatProps>;
10
+ export declare const AgentChat: default_2.ForwardRefExoticComponent<AgentChatProps & default_2.RefAttributes<AgentChat_2 | null>>;
8
11
 
9
12
  export declare interface AgentChatProps {
10
13
  backendUrl?: string;
@@ -51,7 +54,13 @@ export declare interface ThreadViewProps {
51
54
  * A hook to register a Chat Portal specification for the agent.
52
55
  * This allows the agent to navigate and control the host application.
53
56
  * @param context The AppContext defining site, user and navigation.
57
+ * @param options Optional refs for accessing the AgentChat controller.
58
+ * @returns ChatController instance if an AgentChat ref is provided.
54
59
  */
55
- export declare function useChatPortal(context: AppContext): void;
60
+ export declare function useChatPortal(context: AppContext, options?: UseChatPortalOptions): ChatController | null;
61
+
62
+ export declare type UseChatPortalOptions = {
63
+ chatRef?: RefObject<AgentChat_2>;
64
+ };
56
65
 
57
66
  export { }
@@ -1,6 +1,6 @@
1
- import ee, { useRef as re, useEffect as j } from "react";
2
- import { chatPortalService as te } from "site-operator";
3
- var S = { exports: {} }, v = {};
1
+ import W, { useRef as re, useImperativeHandle as te, useEffect as y, useState as ae } from "react";
2
+ import { chatPortalService as ne } from "site-operator";
3
+ var A = { exports: {} }, p = {};
4
4
  /**
5
5
  * @license React
6
6
  * react-jsx-runtime.production.js
@@ -11,26 +11,26 @@ var S = { exports: {} }, v = {};
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
13
  var D;
14
- function ae() {
15
- if (D) return v;
14
+ function le() {
15
+ if (D) return p;
16
16
  D = 1;
17
- var u = Symbol.for("react.transitional.element"), _ = Symbol.for("react.fragment");
18
- function d(m, l, s) {
19
- var E = null;
20
- if (s !== void 0 && (E = "" + s), l.key !== void 0 && (E = "" + l.key), "key" in l) {
21
- s = {};
22
- for (var i in l)
23
- i !== "key" && (s[i] = l[i]);
24
- } else s = l;
25
- return l = s.ref, {
26
- $$typeof: u,
27
- type: m,
28
- key: E,
29
- ref: l !== void 0 ? l : null,
30
- props: s
17
+ var c = Symbol.for("react.transitional.element"), i = Symbol.for("react.fragment");
18
+ function m(f, a, u) {
19
+ var d = null;
20
+ if (u !== void 0 && (d = "" + u), a.key !== void 0 && (d = "" + a.key), "key" in a) {
21
+ u = {};
22
+ for (var s in a)
23
+ s !== "key" && (u[s] = a[s]);
24
+ } else u = a;
25
+ return a = u.ref, {
26
+ $$typeof: c,
27
+ type: f,
28
+ key: d,
29
+ ref: a !== void 0 ? a : null,
30
+ props: u
31
31
  };
32
32
  }
33
- return v.Fragment = _, v.jsx = d, v.jsxs = d, v;
33
+ return p.Fragment = i, p.jsx = m, p.jsxs = m, p;
34
34
  }
35
35
  var b = {};
36
36
  /**
@@ -43,97 +43,97 @@ var b = {};
43
43
  * LICENSE file in the root directory of this source tree.
44
44
  */
45
45
  var L;
46
- function ne() {
46
+ function oe() {
47
47
  return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
48
- function u(e) {
48
+ function c(e) {
49
49
  if (e == null) return null;
50
50
  if (typeof e == "function")
51
- return e.$$typeof === Z ? null : e.displayName || e.name || null;
51
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
52
52
  if (typeof e == "string") return e;
53
53
  switch (e) {
54
- case A:
54
+ case O:
55
55
  return "Fragment";
56
- case q:
56
+ case J:
57
57
  return "Profiler";
58
- case U:
58
+ case q:
59
59
  return "StrictMode";
60
- case G:
61
- return "Suspense";
62
60
  case X:
61
+ return "Suspense";
62
+ case H:
63
63
  return "SuspenseList";
64
- case B:
64
+ case Z:
65
65
  return "Activity";
66
66
  }
67
67
  if (typeof e == "object")
68
68
  switch (typeof e.tag == "number" && console.error(
69
69
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
70
70
  ), e.$$typeof) {
71
- case W:
71
+ case U:
72
72
  return "Portal";
73
- case V:
73
+ case z:
74
74
  return e.displayName || "Context";
75
- case J:
75
+ case V:
76
76
  return (e._context.displayName || "Context") + ".Consumer";
77
- case z:
77
+ case G:
78
78
  var r = e.render;
79
79
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
80
- case H:
81
- return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
82
- case O:
80
+ case B:
81
+ return r = e.displayName || null, r !== null ? r : c(e.type) || "Memo";
82
+ case P:
83
83
  r = e._payload, e = e._init;
84
84
  try {
85
- return u(e(r));
85
+ return c(e(r));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function _(e) {
91
+ function i(e) {
92
92
  return "" + e;
93
93
  }
94
- function d(e) {
94
+ function m(e) {
95
95
  try {
96
- _(e);
96
+ i(e);
97
97
  var r = !1;
98
98
  } catch {
99
99
  r = !0;
100
100
  }
101
101
  if (r) {
102
102
  r = console;
103
- var t = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
104
104
  return t.call(
105
105
  r,
106
106
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
107
- a
108
- ), _(e);
107
+ n
108
+ ), i(e);
109
109
  }
110
110
  }
111
- function m(e) {
112
- if (e === A) return "<>";
113
- if (typeof e == "object" && e !== null && e.$$typeof === O)
111
+ function f(e) {
112
+ if (e === O) return "<>";
113
+ if (typeof e == "object" && e !== null && e.$$typeof === P)
114
114
  return "<...>";
115
115
  try {
116
- var r = u(e);
116
+ var r = c(e);
117
117
  return r ? "<" + r + ">" : "<...>";
118
118
  } catch {
119
119
  return "<...>";
120
120
  }
121
121
  }
122
- function l() {
123
- var e = P.A;
122
+ function a() {
123
+ var e = g.A;
124
124
  return e === null ? null : e.getOwner();
125
125
  }
126
- function s() {
126
+ function u() {
127
127
  return Error("react-stack-top-frame");
128
128
  }
129
- function E(e) {
130
- if (h.call(e, "key")) {
129
+ function d(e) {
130
+ if (N.call(e, "key")) {
131
131
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
132
132
  if (r && r.isReactWarning) return !1;
133
133
  }
134
134
  return e.key !== void 0;
135
135
  }
136
- function i(e, r) {
136
+ function s(e, r) {
137
137
  function t() {
138
138
  x || (x = !0, console.error(
139
139
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
@@ -145,23 +145,23 @@ function ne() {
145
145
  configurable: !0
146
146
  });
147
147
  }
148
- function R() {
149
- var e = u(this.type);
148
+ function v() {
149
+ var e = c(this.type);
150
150
  return Y[e] || (Y[e] = !0, console.error(
151
151
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
152
152
  )), e = this.props.ref, e !== void 0 ? e : null;
153
153
  }
154
- function c(e, r, t, a, k, g) {
155
- var n = t.ref;
154
+ function _(e, r, t, n, S, j) {
155
+ var l = t.ref;
156
156
  return e = {
157
- $$typeof: N,
157
+ $$typeof: C,
158
158
  type: e,
159
159
  key: r,
160
160
  props: t,
161
- _owner: a
162
- }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
161
+ _owner: n
162
+ }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
163
163
  enumerable: !1,
164
- get: R
164
+ get: v
165
165
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
166
166
  configurable: !1,
167
167
  enumerable: !1,
@@ -176,151 +176,167 @@ function ne() {
176
176
  configurable: !1,
177
177
  enumerable: !1,
178
178
  writable: !0,
179
- value: k
179
+ value: S
180
180
  }), Object.defineProperty(e, "_debugTask", {
181
181
  configurable: !1,
182
182
  enumerable: !1,
183
183
  writable: !0,
184
- value: g
184
+ value: j
185
185
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
186
186
  }
187
- function o(e, r, t, a, k, g) {
188
- var n = r.children;
189
- if (n !== void 0)
190
- if (a)
191
- if (Q(n)) {
192
- for (a = 0; a < n.length; a++)
193
- f(n[a]);
194
- Object.freeze && Object.freeze(n);
187
+ function o(e, r, t, n, S, j) {
188
+ var l = r.children;
189
+ if (l !== void 0)
190
+ if (n)
191
+ if (K(l)) {
192
+ for (n = 0; n < l.length; n++)
193
+ T(l[n]);
194
+ Object.freeze && Object.freeze(l);
195
195
  } else
196
196
  console.error(
197
197
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
198
198
  );
199
- else f(n);
200
- if (h.call(r, "key")) {
201
- n = u(e);
202
- var p = Object.keys(r).filter(function(K) {
203
- return K !== "key";
199
+ else T(l);
200
+ if (N.call(r, "key")) {
201
+ l = c(e);
202
+ var R = Object.keys(r).filter(function(ee) {
203
+ return ee !== "key";
204
204
  });
205
- a = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", F[n + a] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
205
+ n = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", F[l + n] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
206
206
  `A props object containing a "key" prop is being spread into JSX:
207
207
  let props = %s;
208
208
  <%s {...props} />
209
209
  React keys must be passed directly to JSX without using spread:
210
210
  let props = %s;
211
211
  <%s key={someKey} {...props} />`,
212
- a,
213
212
  n,
214
- p,
215
- n
216
- ), F[n + a] = !0);
213
+ l,
214
+ R,
215
+ l
216
+ ), F[l + n] = !0);
217
217
  }
218
- if (n = null, t !== void 0 && (d(t), n = "" + t), E(r) && (d(r.key), n = "" + r.key), "key" in r) {
218
+ if (l = null, t !== void 0 && (m(t), l = "" + t), d(r) && (m(r.key), l = "" + r.key), "key" in r) {
219
219
  t = {};
220
- for (var w in r)
221
- w !== "key" && (t[w] = r[w]);
220
+ for (var h in r)
221
+ h !== "key" && (t[h] = r[h]);
222
222
  } else t = r;
223
- return n && i(
223
+ return l && s(
224
224
  t,
225
225
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
226
- ), c(
226
+ ), _(
227
227
  e,
228
- n,
228
+ l,
229
229
  t,
230
- l(),
231
- k,
232
- g
230
+ a(),
231
+ S,
232
+ j
233
233
  );
234
234
  }
235
- function f(e) {
236
- C(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? C(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
235
+ function T(e) {
236
+ E(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? E(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
237
237
  }
238
- function C(e) {
239
- return typeof e == "object" && e !== null && e.$$typeof === N;
238
+ function E(e) {
239
+ return typeof e == "object" && e !== null && e.$$typeof === C;
240
240
  }
241
- var T = ee, N = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), U = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), V = Symbol.for("react.context"), z = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), B = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), P = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, h = Object.prototype.hasOwnProperty, Q = Array.isArray, y = console.createTask ? console.createTask : function() {
241
+ var k = W, C = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), q = Symbol.for("react.strict_mode"), J = Symbol.for("react.profiler"), V = Symbol.for("react.consumer"), z = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), Q = Symbol.for("react.client.reference"), g = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, K = Array.isArray, w = console.createTask ? console.createTask : function() {
242
242
  return null;
243
243
  };
244
- T = {
244
+ k = {
245
245
  react_stack_bottom_frame: function(e) {
246
246
  return e();
247
247
  }
248
248
  };
249
- var x, Y = {}, $ = T.react_stack_bottom_frame.bind(
250
- T,
251
- s
252
- )(), I = y(m(s)), F = {};
253
- b.Fragment = A, b.jsx = function(e, r, t) {
254
- var a = 1e4 > P.recentlyCreatedOwnerStacks++;
249
+ var x, Y = {}, $ = k.react_stack_bottom_frame.bind(
250
+ k,
251
+ u
252
+ )(), I = w(f(u)), F = {};
253
+ b.Fragment = O, b.jsx = function(e, r, t) {
254
+ var n = 1e4 > g.recentlyCreatedOwnerStacks++;
255
255
  return o(
256
256
  e,
257
257
  r,
258
258
  t,
259
259
  !1,
260
- a ? Error("react-stack-top-frame") : $,
261
- a ? y(m(e)) : I
260
+ n ? Error("react-stack-top-frame") : $,
261
+ n ? w(f(e)) : I
262
262
  );
263
263
  }, b.jsxs = function(e, r, t) {
264
- var a = 1e4 > P.recentlyCreatedOwnerStacks++;
264
+ var n = 1e4 > g.recentlyCreatedOwnerStacks++;
265
265
  return o(
266
266
  e,
267
267
  r,
268
268
  t,
269
269
  !0,
270
- a ? Error("react-stack-top-frame") : $,
271
- a ? y(m(e)) : I
270
+ n ? Error("react-stack-top-frame") : $,
271
+ n ? w(f(e)) : I
272
272
  );
273
273
  };
274
274
  })()), b;
275
275
  }
276
276
  var M;
277
- function oe() {
278
- return M || (M = 1, process.env.NODE_ENV === "production" ? S.exports = ae() : S.exports = ne()), S.exports;
277
+ function ue() {
278
+ return M || (M = 1, process.env.NODE_ENV === "production" ? A.exports = le() : A.exports = oe()), A.exports;
279
279
  }
280
- var le = oe();
281
- const ie = ({
282
- backendUrl: u,
283
- conversationUrl: _,
284
- appName: d,
285
- agentAvatar: m,
286
- inspector: l,
287
- interceptor: s,
288
- className: E,
289
- composer: i,
290
- thread: R,
291
- header: c,
280
+ var se = ue();
281
+ const ie = W.forwardRef(({
282
+ backendUrl: c,
283
+ conversationUrl: i,
284
+ appName: m,
285
+ agentAvatar: f,
286
+ inspector: a,
287
+ interceptor: u,
288
+ className: d,
289
+ composer: s,
290
+ thread: v,
291
+ header: _,
292
292
  context: o
293
- }) => {
294
- const f = re(null);
295
- return j(() => {
296
- f.current && (o != null && o.appContext) && f.current.setAppContext(o.appContext);
297
- }, [o == null ? void 0 : o.appContext]), j(() => {
298
- f.current && (o != null && o.appState) && f.current.setAppState(o.appState);
299
- }, [o == null ? void 0 : o.appState]), /* @__PURE__ */ le.jsx(
293
+ }, T) => {
294
+ const E = re(null);
295
+ return te(T, () => E.current), y(() => {
296
+ E.current && (o != null && o.appContext) && E.current.setAppContext(o.appContext);
297
+ }, [o == null ? void 0 : o.appContext]), y(() => {
298
+ E.current && (o != null && o.appState) && E.current.setAppState(o.appState);
299
+ }, [o == null ? void 0 : o.appState]), /* @__PURE__ */ se.jsx(
300
300
  "agent-chat",
301
301
  {
302
- ref: f,
303
- backendUrl: u,
304
- conversationUrl: _,
305
- appName: d,
306
- agentAvatar: m,
307
- disclaimer: i == null ? void 0 : i.disclaimer,
308
- placeholder: i == null ? void 0 : i.placeholder,
309
- emptyText: R == null ? void 0 : R.emptyText,
310
- headerTitle: c == null ? void 0 : c.title,
311
- hideHeader: c == null ? void 0 : c.hide,
312
- inspector: l ? "true" : void 0,
313
- interceptor: s ? !0 : void 0,
314
- class: E
302
+ ref: E,
303
+ backendUrl: c,
304
+ conversationUrl: i,
305
+ appName: m,
306
+ agentAvatar: f,
307
+ disclaimer: s == null ? void 0 : s.disclaimer,
308
+ placeholder: s == null ? void 0 : s.placeholder,
309
+ emptyText: v == null ? void 0 : v.emptyText,
310
+ headerTitle: _ == null ? void 0 : _.title,
311
+ hideHeader: _ == null ? void 0 : _.hide,
312
+ inspector: a ? "true" : void 0,
313
+ interceptor: u ? !0 : void 0,
314
+ class: d
315
315
  }
316
316
  );
317
- };
318
- function ce(u) {
319
- j(() => {
320
- te.registerPortal(u);
321
- }, [u]);
317
+ });
318
+ ie.displayName = "AgentChat";
319
+ function de(c, i) {
320
+ const [m, f] = ae(null);
321
+ return y(() => {
322
+ ne.registerPortal(c);
323
+ }, [c]), y(() => {
324
+ var d;
325
+ const a = (d = i == null ? void 0 : i.chatRef) == null ? void 0 : d.current;
326
+ if (!a) return;
327
+ if (a.controller) {
328
+ f(a.controller);
329
+ return;
330
+ }
331
+ const u = (s) => {
332
+ f(s.detail ?? null);
333
+ };
334
+ return a.addEventListener("controller-ready", u), () => {
335
+ a.removeEventListener("controller-ready", u);
336
+ };
337
+ }, [i == null ? void 0 : i.chatRef]), m;
322
338
  }
323
339
  export {
324
340
  ie as AgentChat,
325
- ce as useChatPortal
341
+ de as useChatPortal
326
342
  };
@@ -1,4 +1,4 @@
1
- (function(c,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("site-operator")):typeof define=="function"&&define.amd?define(["exports","react","site-operator"],f):(c=typeof globalThis<"u"?globalThis:c||self,f(c.SiteOperatorReact={},c.React,c.SiteOperator))})(this,(function(c,f,J){"use strict";var k={exports:{}},b={};/**
1
+ (function(m,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("site-operator")):typeof define=="function"&&define.amd?define(["exports","react","site-operator"],i):(m=typeof globalThis<"u"?globalThis:m||self,i(m.SiteOperatorReact={},m.React,m.SiteOperator))})(this,(function(m,i,V){"use strict";var k={exports:{}},b={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var C;function V(){if(C)return b;C=1;var u=Symbol.for("react.transitional.element"),R=Symbol.for("react.fragment");function E(_,s,l){var m=null;if(l!==void 0&&(m=""+l),s.key!==void 0&&(m=""+s.key),"key"in s){l={};for(var i in s)i!=="key"&&(l[i]=s[i])}else l=s;return s=l.ref,{$$typeof:u,type:_,key:m,ref:s!==void 0?s:null,props:l}}return b.Fragment=R,b.jsx=E,b.jsxs=E,b}var T={};/**
9
+ */var N;function z(){if(N)return b;N=1;var f=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function _(d,a,u){var E=null;if(u!==void 0&&(E=""+u),a.key!==void 0&&(E=""+a.key),"key"in a){u={};for(var s in a)s!=="key"&&(u[s]=a[s])}else u=a;return a=u.ref,{$$typeof:f,type:d,key:E,ref:a!==void 0?a:null,props:u}}return b.Fragment=c,b.jsx=_,b.jsxs=_,b}var T={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var N;function z(){return N||(N=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case Z:return"Profiler";case B:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList";case ne:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case H:return"Portal";case K:return e.displayName||"Context";case Q:return(e._context.displayName||"Context")+".Consumer";case ee:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case y:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function R(e){return""+e}function E(e){try{R(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),R(e)}}function _(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=g.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function m(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function i(e,r){function t(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function S(){var e=u(this.type);return M[e]||(M[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function d(e,r,t,a,A,w){var n=t.ref;return e={$$typeof:I,type:e,key:r,props:t,_owner:a},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:S}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function o(e,r,t,a,A,w){var n=r.children;if(n!==void 0)if(a)if(se(n)){for(a=0;a<n.length;a++)p(n[a]);Object.freeze&&Object.freeze(n)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(n);if(F.call(r,"key")){n=u(e);var v=Object.keys(r).filter(function(ue){return ue!=="key"});a=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",U[n+a]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var x;function G(){return x||(x=1,process.env.NODE_ENV!=="production"&&(function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case Q:return"Profiler";case q:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList";case ne:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Z:return"Portal";case K:return e.displayName||"Context";case $:return(e._context.displayName||"Context")+".Consumer";case ee:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return r=e.displayName||null,r!==null?r:f(e.type)||"Memo";case g:r=e._payload,e=e._init;try{return f(e(r))}catch{}}return null}function c(e){return""+e}function _(e){try{c(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),c(e)}}function d(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var r=f(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function a(){var e=h.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function E(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function s(e,r){function t(){L||(L=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function S(){var e=f(this.type);return M[e]||(M[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,r,t,n,O,w){var o=t.ref;return e={$$typeof:F,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:S}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:O}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function l(e,r,t,n,O,w){var o=r.children;if(o!==void 0)if(n)if(le(o)){for(n=0;n<o.length;n++)y(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(o);if(D.call(r,"key")){o=f(e);var v=Object.keys(r).filter(function(ue){return ue!=="key"});n=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",J[o+n]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,a,n,v,n),U[n+a]=!0)}if(n=null,t!==void 0&&(E(t),n=""+t),m(r)&&(E(r.key),n=""+r.key),"key"in r){t={};for(var h in r)h!=="key"&&(t[h]=r[h])}else t=r;return n&&i(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,n,t,s(),A,w)}function p(e){Y(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?Y(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===I}var O=f,I=Symbol.for("react.transitional.element"),H=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),g=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,se=Array.isArray,j=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var D,M={},L=O.react_stack_bottom_frame.bind(O,l)(),W=j(_(l)),U={};T.Fragment=P,T.jsx=function(e,r,t){var a=1e4>g.recentlyCreatedOwnerStacks++;return o(e,r,t,!1,a?Error("react-stack-top-frame"):L,a?j(_(e)):W)},T.jsxs=function(e,r,t){var a=1e4>g.recentlyCreatedOwnerStacks++;return o(e,r,t,!0,a?Error("react-stack-top-frame"):L,a?j(_(e)):W)}})()),T}var x;function $(){return x||(x=1,process.env.NODE_ENV==="production"?k.exports=V():k.exports=z()),k.exports}var G=$();const q=({backendUrl:u,conversationUrl:R,appName:E,agentAvatar:_,inspector:s,interceptor:l,className:m,composer:i,thread:S,header:d,context:o})=>{const p=f.useRef(null);return f.useEffect(()=>{p.current&&(o!=null&&o.appContext)&&p.current.setAppContext(o.appContext)},[o==null?void 0:o.appContext]),f.useEffect(()=>{p.current&&(o!=null&&o.appState)&&p.current.setAppState(o.appState)},[o==null?void 0:o.appState]),G.jsx("agent-chat",{ref:p,backendUrl:u,conversationUrl:R,appName:E,agentAvatar:_,disclaimer:i==null?void 0:i.disclaimer,placeholder:i==null?void 0:i.placeholder,emptyText:S==null?void 0:S.emptyText,headerTitle:d==null?void 0:d.title,hideHeader:d==null?void 0:d.hide,inspector:s?"true":void 0,interceptor:l?!0:void 0,class:m})};function X(u){f.useEffect(()=>{J.chatPortalService.registerPortal(u)},[u])}c.AgentChat=q,c.useChatPortal=X,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
22
+ <%s key={someKey} {...props} />`,n,o,v,o),J[o+n]=!0)}if(o=null,t!==void 0&&(_(t),o=""+t),E(r)&&(_(r.key),o=""+r.key),"key"in r){t={};for(var C in r)C!=="key"&&(t[C]=r[C])}else t=r;return o&&s(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,o,t,a(),O,w)}function y(e){p(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e=="object"&&e!==null&&e.$$typeof===F}var A=i,F=Symbol.for("react.transitional.element"),Z=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),h=A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,le=Array.isArray,j=console.createTask?console.createTask:function(){return null};A={react_stack_bottom_frame:function(e){return e()}};var L,M={},W=A.react_stack_bottom_frame.bind(A,u)(),U=j(d(u)),J={};T.Fragment=P,T.jsx=function(e,r,t){var n=1e4>h.recentlyCreatedOwnerStacks++;return l(e,r,t,!1,n?Error("react-stack-top-frame"):W,n?j(d(e)):U)},T.jsxs=function(e,r,t){var n=1e4>h.recentlyCreatedOwnerStacks++;return l(e,r,t,!0,n?Error("react-stack-top-frame"):W,n?j(d(e)):U)}})()),T}var Y;function X(){return Y||(Y=1,process.env.NODE_ENV==="production"?k.exports=z():k.exports=G()),k.exports}var H=X();const I=i.forwardRef(({backendUrl:f,conversationUrl:c,appName:_,agentAvatar:d,inspector:a,interceptor:u,className:E,composer:s,thread:S,header:R,context:l},y)=>{const p=i.useRef(null);return i.useImperativeHandle(y,()=>p.current),i.useEffect(()=>{p.current&&(l!=null&&l.appContext)&&p.current.setAppContext(l.appContext)},[l==null?void 0:l.appContext]),i.useEffect(()=>{p.current&&(l!=null&&l.appState)&&p.current.setAppState(l.appState)},[l==null?void 0:l.appState]),H.jsx("agent-chat",{ref:p,backendUrl:f,conversationUrl:c,appName:_,agentAvatar:d,disclaimer:s==null?void 0:s.disclaimer,placeholder:s==null?void 0:s.placeholder,emptyText:S==null?void 0:S.emptyText,headerTitle:R==null?void 0:R.title,hideHeader:R==null?void 0:R.hide,inspector:a?"true":void 0,interceptor:u?!0:void 0,class:E})});I.displayName="AgentChat";function B(f,c){const[_,d]=i.useState(null);return i.useEffect(()=>{V.chatPortalService.registerPortal(f)},[f]),i.useEffect(()=>{var E;const a=(E=c==null?void 0:c.chatRef)==null?void 0:E.current;if(!a)return;if(a.controller){d(a.controller);return}const u=s=>{d(s.detail??null)};return a.addEventListener("controller-ready",u),()=>{a.removeEventListener("controller-ready",u)}},[c==null?void 0:c.chatRef]),_}m.AgentChat=I,m.useChatPortal=B,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "site-operator-react",
3
- "version": "0.1.13",
3
+ "version": "0.2.1",
4
4
  "description": "React wrapper for site-operator, providing AgentChat component and hooks.",
5
5
  "type": "module",
6
6
  "author": "jostvian",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/jostvian-agent/site-operator.git",
10
+ "url": "git+https://github.com/jostvian/site-operator.git",
11
11
  "directory": "packages/react"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/jostvian-agent/site-operator/issues"
14
+ "url": "https://github.com/jostvian/site-operator/issues"
15
15
  },
16
- "homepage": "https://github.com/jostvian-agent/site-operator#readme",
16
+ "homepage": "https://github.com/jostvian/site-operator#readme",
17
17
  "main": "./dist/site-operator-react.umd.js",
18
18
  "module": "./dist/site-operator-react.es.js",
19
19
  "types": "./dist/index.d.ts",
@@ -32,17 +32,17 @@
32
32
  "dev": "vite build --watch"
33
33
  },
34
34
  "dependencies": {
35
- "site-operator": "^0.1.13"
35
+ "site-operator": "^0.1.14"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^19.0.0",
39
39
  "react-dom": "^19.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "react": "^19.0.0",
43
- "react-dom": "^19.0.0",
44
42
  "@types/react": "^19.0.0",
45
43
  "@types/react-dom": "^19.0.0",
44
+ "react": "^19.0.0",
45
+ "react-dom": "^19.0.0",
46
46
  "typescript": "^5.7.0",
47
47
  "vite": "^6.0.0",
48
48
  "vite-plugin-dts": "^4.5.0"