site-operator-react 0.1.12 → 0.1.13

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
@@ -4,67 +4,105 @@ The React 19 wrapper for Site Operator. It provides a seamless integration of th
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
7
  npm install site-operator-react
9
- ```
10
-
11
- *Note: You must also have `react` and `react-dom` installed.*
12
8
 
13
- ## Usage
9
+ ```tsx
10
+ import { AgentChat, type AppContext, type AppState } from 'site-operator-react';
14
11
 
15
- ### AgentChat Component
12
+ const context: AppContext = {
13
+ v: "1.1",
14
+ site: {
15
+ name: "My Portal",
16
+ description: "Main customer management portal",
17
+ deployment: "prod",
18
+ baseUrl: "https://myportal.com",
19
+ locale: "en-US"
20
+ },
21
+ user: { id: "u-123", displayName: "Jost" },
22
+ nav: {
23
+ globalClickTargets: [
24
+ {
25
+ id: "lnk.nav.clients",
26
+ name: "ClientsLink",
27
+ kind: "link",
28
+ label: "Clients",
29
+ locator: { testId: "nav-clients" },
30
+ action: { "type": "navigate", "toRouteId": "clients.list", "toPath": "/clients" }
31
+ }
32
+ ],
33
+ routes: [
34
+ {
35
+ id: "clients.list",
36
+ path: "/clients",
37
+ title: "Client Directory",
38
+ description: "List of all active customers in the system",
39
+ clickTargets: [
40
+ {
41
+ id: "btn.createClient",
42
+ name: "CreateClient",
43
+ kind: "button",
44
+ label: "Add Client",
45
+ description: "Opens the registration form for new customers",
46
+ locator: { testId: "clients-create" },
47
+ action: { "type": "navigate", "toRouteId": "clients.create", "toPath": "/clients/new" }
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ }
53
+ };
16
54
 
17
- The `<AgentChat />` component renders the chat widget. It wraps the underlying Web Component and handles prop syncing.
18
-
19
- ```tsx
20
- import { AgentChat } from 'site-operator-react';
55
+ const state: AppState = {
56
+ v: "1.1",
57
+ location: {
58
+ routeId: "clients.list",
59
+ path: "/clients?status=active",
60
+ params: { "status": "active" },
61
+ title: "Clientes"
62
+ },
63
+ ui: {
64
+ visibleClickTargetIds: ["lnk.nav.clients", "btn.createClient"]
65
+ },
66
+ focus: { "type": "client", "id": "c-77", "label": "ACME S.A." }
67
+ };
21
68
 
22
69
  function App() {
23
70
  return (
24
71
  <div className="App">
25
72
  <AgentChat
26
73
  backendUrl="http://localhost:8001/ag_ui"
27
- conversationUrl="http://localhost:8003"
28
74
  appName="My React App"
29
- agentAvatar="/avatar.png"
30
- header={{
31
- title: "Mi Asistente",
32
- hide: false
33
- }}
34
- composer={{
35
- disclaimer: "Agent puede cometer errores. Verifica la información importante",
36
- placeholder: "Enviar un mensaje a Agent"
37
- }}
38
- thread={{
39
- emptyText: "¿Cómo puedo ayudarte hoy?"
40
- }}
75
+ context={{ appContext: context, appState: state }}
41
76
  />
42
77
  </div>
43
78
  );
44
79
  }
45
80
  ```
46
81
 
82
+
47
83
  ### useChatPortal Hook
48
84
 
49
- The `useChatPortal` hook allows you to register the "Copilot" capabilities (Portal Spec) for your application. This lets the agent control the app (e.g., navigate, perform actions).
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.
50
86
 
51
87
  ```tsx
52
- import { useChatPortal } from 'site-operator-react';
88
+ import { useChatPortal, type AppContext } from 'site-operator-react';
89
+
90
+ const context: AppContext = {
91
+ v: "1.1",
92
+ // ... configuration ...
93
+ site: { name: "Mi Portal" },
94
+ user: { id: "u-123" },
95
+ nav: {
96
+ routes: []
97
+ }
98
+ };
53
99
 
54
100
  function App() {
55
- useChatPortal({
56
- actions: {
57
- openSettings: () => {
58
- // Your logic to open settings
59
- },
60
- navigate: ({ path }) => {
61
- // Your router logic
62
- }
63
- }
64
- });
101
+ useChatPortal(context);
65
102
 
66
103
  return (
67
104
  // ...
68
105
  );
69
106
  }
70
107
  ```
108
+
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AgentState } from 'site-operator';
2
+ import { AppContext } from 'site-operator';
3
+ import { AppState } from 'site-operator';
4
+ import { ClickTarget } from 'site-operator';
2
5
  import { default as default_2 } from 'react';
3
- import { NavGraph } from 'site-operator';
4
- import { NavNode } from 'site-operator';
5
- import { PortalSpec } from 'site-operator';
6
6
 
7
7
  export declare const AgentChat: default_2.FC<AgentChatProps>;
8
8
 
@@ -22,13 +22,20 @@ export declare interface AgentChatProps {
22
22
 
23
23
  export { AgentState }
24
24
 
25
+ export { AppContext }
26
+
27
+ export { AppState }
28
+
29
+ export { ClickTarget }
30
+
25
31
  export declare interface ComposerProps {
26
32
  disclaimer?: string;
27
33
  placeholder?: string;
28
34
  }
29
35
 
30
36
  export declare interface ContextProps {
31
- appContext?: AgentState;
37
+ appContext?: AppContext;
38
+ appState?: AppState;
32
39
  }
33
40
 
34
41
  export declare interface HeaderProps {
@@ -36,12 +43,6 @@ export declare interface HeaderProps {
36
43
  hide?: boolean;
37
44
  }
38
45
 
39
- export { NavGraph }
40
-
41
- export { NavNode }
42
-
43
- export { PortalSpec }
44
-
45
46
  export declare interface ThreadViewProps {
46
47
  emptyText?: string;
47
48
  }
@@ -49,8 +50,8 @@ export declare interface ThreadViewProps {
49
50
  /**
50
51
  * A hook to register a Chat Portal specification for the agent.
51
52
  * This allows the agent to navigate and control the host application.
52
- * @param spec The PortalSpec defining navigation graph and actions.
53
+ * @param context The AppContext defining site, user and navigation.
53
54
  */
54
- export declare function useChatPortal(spec: PortalSpec): void;
55
+ export declare function useChatPortal(context: AppContext): void;
55
56
 
56
57
  export { }
@@ -1,6 +1,6 @@
1
- import ee, { useRef as re, useEffect as M } from "react";
1
+ import ee, { useRef as re, useEffect as j } from "react";
2
2
  import { chatPortalService as te } from "site-operator";
3
- var A = { exports: {} }, p = {};
3
+ var S = { exports: {} }, v = {};
4
4
  /**
5
5
  * @license React
6
6
  * react-jsx-runtime.production.js
@@ -10,27 +10,27 @@ var A = { exports: {} }, p = {};
10
10
  * This source code is licensed under the MIT license found in the
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
- var F;
14
- function ne() {
15
- if (F) return p;
16
- F = 1;
17
- var l = Symbol.for("react.transitional.element"), E = Symbol.for("react.fragment");
18
- function f(d, o, u) {
19
- var m = null;
20
- if (u !== void 0 && (m = "" + u), o.key !== void 0 && (m = "" + o.key), "key" in o) {
21
- u = {};
22
- for (var s in o)
23
- s !== "key" && (u[s] = o[s]);
24
- } else u = o;
25
- return o = u.ref, {
26
- $$typeof: l,
27
- type: d,
28
- key: m,
29
- ref: o !== void 0 ? o : null,
30
- props: u
13
+ var D;
14
+ function ae() {
15
+ if (D) return v;
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
31
31
  };
32
32
  }
33
- return p.Fragment = E, p.jsx = f, p.jsxs = f, p;
33
+ return v.Fragment = _, v.jsx = d, v.jsxs = d, v;
34
34
  }
35
35
  var b = {};
36
36
  /**
@@ -42,16 +42,16 @@ var b = {};
42
42
  * This source code is licensed under the MIT license found in the
43
43
  * LICENSE file in the root directory of this source tree.
44
44
  */
45
- var D;
46
- function ae() {
47
- return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
48
- function l(e) {
45
+ var L;
46
+ function ne() {
47
+ return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
48
+ function u(e) {
49
49
  if (e == null) return null;
50
50
  if (typeof e == "function")
51
51
  return e.$$typeof === Z ? null : e.displayName || e.name || null;
52
52
  if (typeof e == "string") return e;
53
53
  switch (e) {
54
- case O:
54
+ case A:
55
55
  return "Fragment";
56
56
  case q:
57
57
  return "Profiler";
@@ -78,64 +78,64 @@ function ae() {
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
80
  case H:
81
- return r = e.displayName || null, r !== null ? r : l(e.type) || "Memo";
82
- case P:
81
+ return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
82
+ case O:
83
83
  r = e._payload, e = e._init;
84
84
  try {
85
- return l(e(r));
85
+ return u(e(r));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function E(e) {
91
+ function _(e) {
92
92
  return "" + e;
93
93
  }
94
- function f(e) {
94
+ function d(e) {
95
95
  try {
96
- E(e);
96
+ _(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, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
+ var t = r.error, a = 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
- n
108
- ), E(e);
107
+ a
108
+ ), _(e);
109
109
  }
110
110
  }
111
- function d(e) {
112
- if (e === O) return "<>";
113
- if (typeof e == "object" && e !== null && e.$$typeof === P)
111
+ function m(e) {
112
+ if (e === A) return "<>";
113
+ if (typeof e == "object" && e !== null && e.$$typeof === O)
114
114
  return "<...>";
115
115
  try {
116
- var r = l(e);
116
+ var r = u(e);
117
117
  return r ? "<" + r + ">" : "<...>";
118
118
  } catch {
119
119
  return "<...>";
120
120
  }
121
121
  }
122
- function o() {
123
- var e = S.A;
122
+ function l() {
123
+ var e = P.A;
124
124
  return e === null ? null : e.getOwner();
125
125
  }
126
- function u() {
126
+ function s() {
127
127
  return Error("react-stack-top-frame");
128
128
  }
129
- function m(e) {
130
- if (C.call(e, "key")) {
129
+ function E(e) {
130
+ if (h.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 s(e, r) {
136
+ function i(e, r) {
137
137
  function t() {
138
- N || (N = !0, console.error(
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)",
140
140
  r
141
141
  ));
@@ -145,23 +145,23 @@ function ae() {
145
145
  configurable: !0
146
146
  });
147
147
  }
148
- function v() {
149
- var e = l(this.type);
150
- return h[e] || (h[e] = !0, console.error(
148
+ function R() {
149
+ var e = u(this.type);
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, n, k, g) {
155
- var a = t.ref;
154
+ function c(e, r, t, a, k, g) {
155
+ var n = t.ref;
156
156
  return e = {
157
- $$typeof: x,
157
+ $$typeof: N,
158
158
  type: e,
159
159
  key: r,
160
160
  props: t,
161
- _owner: n
162
- }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
161
+ _owner: a
162
+ }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
163
163
  enumerable: !1,
164
- get: v
164
+ get: R
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,
@@ -184,61 +184,61 @@ function ae() {
184
184
  value: g
185
185
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
186
186
  }
187
- function i(e, r, t, n, k, g) {
188
- var a = r.children;
189
- if (a !== void 0)
190
- if (n)
191
- if (Q(a)) {
192
- for (n = 0; n < a.length; n++)
193
- _(a[n]);
194
- Object.freeze && Object.freeze(a);
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);
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 _(a);
200
- if (C.call(r, "key")) {
201
- a = l(e);
202
- var R = Object.keys(r).filter(function(K) {
199
+ else f(n);
200
+ if (h.call(r, "key")) {
201
+ n = u(e);
202
+ var p = Object.keys(r).filter(function(K) {
203
203
  return K !== "key";
204
204
  });
205
- n = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", I[a + n] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
205
+ a = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", F[n + a] || (p = 0 < p.length ? "{" + p.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
- n,
213
212
  a,
214
- R,
215
- a
216
- ), I[a + n] = !0);
213
+ n,
214
+ p,
215
+ n
216
+ ), F[n + a] = !0);
217
217
  }
218
- if (a = null, t !== void 0 && (f(t), a = "" + t), m(r) && (f(r.key), a = "" + r.key), "key" in r) {
218
+ if (n = null, t !== void 0 && (d(t), n = "" + t), E(r) && (d(r.key), n = "" + r.key), "key" in r) {
219
219
  t = {};
220
220
  for (var w in r)
221
221
  w !== "key" && (t[w] = r[w]);
222
222
  } else t = r;
223
- return a && s(
223
+ return n && i(
224
224
  t,
225
225
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
226
226
  ), c(
227
227
  e,
228
- a,
228
+ n,
229
229
  t,
230
- o(),
230
+ l(),
231
231
  k,
232
232
  g
233
233
  );
234
234
  }
235
- function _(e) {
236
- j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
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));
237
237
  }
238
- function j(e) {
239
- return typeof e == "object" && e !== null && e.$$typeof === x;
238
+ function C(e) {
239
+ return typeof e == "object" && e !== null && e.$$typeof === N;
240
240
  }
241
- var T = ee, x = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), O = 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"), P = Symbol.for("react.lazy"), B = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), S = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, Q = Array.isArray, y = console.createTask ? console.createTask : function() {
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() {
242
242
  return null;
243
243
  };
244
244
  T = {
@@ -246,77 +246,79 @@ React keys must be passed directly to JSX without using spread:
246
246
  return e();
247
247
  }
248
248
  };
249
- var N, h = {}, Y = T.react_stack_bottom_frame.bind(
249
+ var x, Y = {}, $ = T.react_stack_bottom_frame.bind(
250
250
  T,
251
- u
252
- )(), $ = y(d(u)), I = {};
253
- b.Fragment = O, b.jsx = function(e, r, t) {
254
- var n = 1e4 > S.recentlyCreatedOwnerStacks++;
255
- return i(
251
+ s
252
+ )(), I = y(m(s)), F = {};
253
+ b.Fragment = A, b.jsx = function(e, r, t) {
254
+ var a = 1e4 > P.recentlyCreatedOwnerStacks++;
255
+ return o(
256
256
  e,
257
257
  r,
258
258
  t,
259
259
  !1,
260
- n ? Error("react-stack-top-frame") : Y,
261
- n ? y(d(e)) : $
260
+ a ? Error("react-stack-top-frame") : $,
261
+ a ? y(m(e)) : I
262
262
  );
263
263
  }, b.jsxs = function(e, r, t) {
264
- var n = 1e4 > S.recentlyCreatedOwnerStacks++;
265
- return i(
264
+ var a = 1e4 > P.recentlyCreatedOwnerStacks++;
265
+ return o(
266
266
  e,
267
267
  r,
268
268
  t,
269
269
  !0,
270
- n ? Error("react-stack-top-frame") : Y,
271
- n ? y(d(e)) : $
270
+ a ? Error("react-stack-top-frame") : $,
271
+ a ? y(m(e)) : I
272
272
  );
273
273
  };
274
274
  })()), b;
275
275
  }
276
- var L;
276
+ var M;
277
277
  function oe() {
278
- return L || (L = 1, process.env.NODE_ENV === "production" ? A.exports = ne() : A.exports = ae()), A.exports;
278
+ return M || (M = 1, process.env.NODE_ENV === "production" ? S.exports = ae() : S.exports = ne()), S.exports;
279
279
  }
280
280
  var le = oe();
281
281
  const ie = ({
282
- backendUrl: l,
283
- conversationUrl: E,
284
- appName: f,
285
- agentAvatar: d,
286
- inspector: o,
287
- interceptor: u,
288
- className: m,
289
- composer: s,
290
- thread: v,
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
291
  header: c,
292
- context: i
292
+ context: o
293
293
  }) => {
294
- const _ = re(null);
295
- return M(() => {
296
- _.current && (i != null && i.appContext) && _.current.setAppContext(i.appContext);
297
- }, [i == null ? void 0 : i.appContext]), /* @__PURE__ */ le.jsx(
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(
298
300
  "agent-chat",
299
301
  {
300
- ref: _,
301
- backendUrl: l,
302
- conversationUrl: E,
303
- appName: f,
304
- agentAvatar: d,
305
- disclaimer: s == null ? void 0 : s.disclaimer,
306
- placeholder: s == null ? void 0 : s.placeholder,
307
- emptyText: v == null ? void 0 : v.emptyText,
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,
308
310
  headerTitle: c == null ? void 0 : c.title,
309
311
  hideHeader: c == null ? void 0 : c.hide,
310
- inspector: o ? "true" : void 0,
311
- interceptor: u ? !0 : void 0,
312
- class: m
312
+ inspector: l ? "true" : void 0,
313
+ interceptor: s ? !0 : void 0,
314
+ class: E
313
315
  }
314
316
  );
315
317
  };
316
- function ce(l) {
317
- M(() => {
318
- te.registerPortal(l);
319
- }, [l]);
318
+ function ce(u) {
319
+ j(() => {
320
+ te.registerPortal(u);
321
+ }, [u]);
320
322
  }
321
323
  export {
322
324
  ie as AgentChat,
@@ -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,$){"use strict";var O={exports:{}},b={};/**
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={};/**
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 x;function J(){if(x)return b;x=1;var s=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function E(_,o,u){var m=null;if(u!==void 0&&(m=""+u),o.key!==void 0&&(m=""+o.key),"key"in o){u={};for(var l in o)l!=="key"&&(u[l]=o[l])}else u=o;return o=u.ref,{$$typeof:s,type:_,key:m,ref:o!==void 0?o:null,props:u}}return b.Fragment=p,b.jsx=E,b.jsxs=E,b}var T={};/**
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={};/**
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 C;function V(){return C||(C=1,process.env.NODE_ENV!=="production"&&(function(){function s(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 ae: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 ne:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case y:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function p(e){return""+e}function E(e){try{p(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),p(e)}}function _(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=g.A;return e===null?null:e.getOwner()}function u(){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 l(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 k(){var e=s(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,n,A,w){var a=t.ref;return e={$$typeof:I,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:k}):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 i(e,r,t,n,A,w){var a=r.children;if(a!==void 0)if(n)if(se(a)){for(n=0;n<a.length;n++)R(a[n]);Object.freeze&&Object.freeze(a)}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 R(a);if(F.call(r,"key")){a=s(e);var v=Object.keys(r).filter(function(ue){return ue!=="key"});n=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",U[a+n]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
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:
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} />`,n,a,v,a),U[a+n]=!0)}if(a=null,t!==void 0&&(E(t),a=""+t),m(r)&&(E(r.key),a=""+r.key),"key"in r){t={};for(var h in r)h!=="key"&&(t[h]=r[h])}else t=r;return a&&l(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,a,t,o(),A,w)}function R(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 S=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"),ne=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),g=S.__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};S={react_stack_bottom_frame:function(e){return e()}};var D,M={},L=S.react_stack_bottom_frame.bind(S,u)(),W=j(_(u)),U={};T.Fragment=P,T.jsx=function(e,r,t){var n=1e4>g.recentlyCreatedOwnerStacks++;return i(e,r,t,!1,n?Error("react-stack-top-frame"):L,n?j(_(e)):W)},T.jsxs=function(e,r,t){var n=1e4>g.recentlyCreatedOwnerStacks++;return i(e,r,t,!0,n?Error("react-stack-top-frame"):L,n?j(_(e)):W)}})()),T}var N;function z(){return N||(N=1,process.env.NODE_ENV==="production"?O.exports=J():O.exports=V()),O.exports}var q=z();const G=({backendUrl:s,conversationUrl:p,appName:E,agentAvatar:_,inspector:o,interceptor:u,className:m,composer:l,thread:k,header:d,context:i})=>{const R=f.useRef(null);return f.useEffect(()=>{R.current&&(i!=null&&i.appContext)&&R.current.setAppContext(i.appContext)},[i==null?void 0:i.appContext]),q.jsx("agent-chat",{ref:R,backendUrl:s,conversationUrl:p,appName:E,agentAvatar:_,disclaimer:l==null?void 0:l.disclaimer,placeholder:l==null?void 0:l.placeholder,emptyText:k==null?void 0:k.emptyText,headerTitle:d==null?void 0:d.title,hideHeader:d==null?void 0:d.hide,inspector:o?"true":void 0,interceptor:u?!0:void 0,class:m})};function X(s){f.useEffect(()=>{$.chatPortalService.registerPortal(s)},[s])}c.AgentChat=G,c.useChatPortal=X,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "site-operator-react",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "React wrapper for site-operator, providing AgentChat component and hooks.",
5
5
  "type": "module",
6
6
  "author": "jostvian",
@@ -32,7 +32,7 @@
32
32
  "dev": "vite build --watch"
33
33
  },
34
34
  "dependencies": {
35
- "site-operator": "^0.1.11"
35
+ "site-operator": "^0.1.13"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^19.0.0",