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 +17 -4
- package/dist/index.d.ts +11 -2
- package/dist/site-operator-react.es.js +163 -147
- package/dist/site-operator-react.umd.js +4 -4
- package/package.json +7 -7
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
|
-
|
|
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.
|
|
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):
|
|
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
|
|
2
|
-
import { chatPortalService as
|
|
3
|
-
var
|
|
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
|
|
15
|
-
if (D) return
|
|
14
|
+
function le() {
|
|
15
|
+
if (D) return p;
|
|
16
16
|
D = 1;
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
for (var
|
|
23
|
-
|
|
24
|
-
} else
|
|
25
|
-
return
|
|
26
|
-
$$typeof:
|
|
27
|
-
type:
|
|
28
|
-
key:
|
|
29
|
-
ref:
|
|
30
|
-
props:
|
|
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
|
|
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
|
|
46
|
+
function oe() {
|
|
47
47
|
return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
48
|
-
function
|
|
48
|
+
function c(e) {
|
|
49
49
|
if (e == null) return null;
|
|
50
50
|
if (typeof e == "function")
|
|
51
|
-
return e.$$typeof ===
|
|
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
|
|
54
|
+
case O:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case J:
|
|
57
57
|
return "Profiler";
|
|
58
|
-
case
|
|
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
|
|
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
|
|
71
|
+
case U:
|
|
72
72
|
return "Portal";
|
|
73
|
-
case
|
|
73
|
+
case z:
|
|
74
74
|
return e.displayName || "Context";
|
|
75
|
-
case
|
|
75
|
+
case V:
|
|
76
76
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
-
case
|
|
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
|
|
81
|
-
return r = e.displayName || null, r !== null ? r :
|
|
82
|
-
case
|
|
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
|
|
85
|
+
return c(e(r));
|
|
86
86
|
} catch {
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function i(e) {
|
|
92
92
|
return "" + e;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function m(e) {
|
|
95
95
|
try {
|
|
96
|
-
|
|
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,
|
|
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
|
-
|
|
108
|
-
),
|
|
107
|
+
n
|
|
108
|
+
), i(e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (e ===
|
|
113
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
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 =
|
|
116
|
+
var r = c(e);
|
|
117
117
|
return r ? "<" + r + ">" : "<...>";
|
|
118
118
|
} catch {
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
var e =
|
|
122
|
+
function a() {
|
|
123
|
+
var e = g.A;
|
|
124
124
|
return e === null ? null : e.getOwner();
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function u() {
|
|
127
127
|
return Error("react-stack-top-frame");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
if (
|
|
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
|
|
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
|
|
149
|
-
var e =
|
|
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
|
|
155
|
-
var
|
|
154
|
+
function _(e, r, t, n, S, j) {
|
|
155
|
+
var l = t.ref;
|
|
156
156
|
return e = {
|
|
157
|
-
$$typeof:
|
|
157
|
+
$$typeof: C,
|
|
158
158
|
type: e,
|
|
159
159
|
key: r,
|
|
160
160
|
props: t,
|
|
161
|
-
_owner:
|
|
162
|
-
}, (
|
|
161
|
+
_owner: n
|
|
162
|
+
}, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
|
|
163
163
|
enumerable: !1,
|
|
164
|
-
get:
|
|
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:
|
|
179
|
+
value: S
|
|
180
180
|
}), Object.defineProperty(e, "_debugTask", {
|
|
181
181
|
configurable: !1,
|
|
182
182
|
enumerable: !1,
|
|
183
183
|
writable: !0,
|
|
184
|
-
value:
|
|
184
|
+
value: j
|
|
185
185
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
186
186
|
}
|
|
187
|
-
function o(e, r, t,
|
|
188
|
-
var
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
192
|
-
for (
|
|
193
|
-
|
|
194
|
-
Object.freeze && Object.freeze(
|
|
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
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
l,
|
|
214
|
+
R,
|
|
215
|
+
l
|
|
216
|
+
), F[l + n] = !0);
|
|
217
217
|
}
|
|
218
|
-
if (
|
|
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
|
|
221
|
-
|
|
220
|
+
for (var h in r)
|
|
221
|
+
h !== "key" && (t[h] = r[h]);
|
|
222
222
|
} else t = r;
|
|
223
|
-
return
|
|
223
|
+
return l && s(
|
|
224
224
|
t,
|
|
225
225
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
226
|
-
),
|
|
226
|
+
), _(
|
|
227
227
|
e,
|
|
228
|
-
|
|
228
|
+
l,
|
|
229
229
|
t,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
a(),
|
|
231
|
+
S,
|
|
232
|
+
j
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
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
|
|
239
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
238
|
+
function E(e) {
|
|
239
|
+
return typeof e == "object" && e !== null && e.$$typeof === C;
|
|
240
240
|
}
|
|
241
|
-
var
|
|
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
|
-
|
|
244
|
+
k = {
|
|
245
245
|
react_stack_bottom_frame: function(e) {
|
|
246
246
|
return e();
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
-
var x, Y = {}, $ =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
)(), I =
|
|
253
|
-
b.Fragment =
|
|
254
|
-
var
|
|
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
|
-
|
|
261
|
-
|
|
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
|
|
264
|
+
var n = 1e4 > g.recentlyCreatedOwnerStacks++;
|
|
265
265
|
return o(
|
|
266
266
|
e,
|
|
267
267
|
r,
|
|
268
268
|
t,
|
|
269
269
|
!0,
|
|
270
|
-
|
|
271
|
-
|
|
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
|
|
278
|
-
return M || (M = 1, process.env.NODE_ENV === "production" ?
|
|
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
|
|
281
|
-
const ie = ({
|
|
282
|
-
backendUrl:
|
|
283
|
-
conversationUrl:
|
|
284
|
-
appName:
|
|
285
|
-
agentAvatar:
|
|
286
|
-
inspector:
|
|
287
|
-
interceptor:
|
|
288
|
-
className:
|
|
289
|
-
composer:
|
|
290
|
-
thread:
|
|
291
|
-
header:
|
|
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
|
|
295
|
-
return
|
|
296
|
-
|
|
297
|
-
}, [o == null ? void 0 : o.appContext]),
|
|
298
|
-
|
|
299
|
-
}, [o == null ? void 0 : o.appState]), /* @__PURE__ */
|
|
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:
|
|
303
|
-
backendUrl:
|
|
304
|
-
conversationUrl:
|
|
305
|
-
appName:
|
|
306
|
-
agentAvatar:
|
|
307
|
-
disclaimer:
|
|
308
|
-
placeholder:
|
|
309
|
-
emptyText:
|
|
310
|
-
headerTitle:
|
|
311
|
-
hideHeader:
|
|
312
|
-
inspector:
|
|
313
|
-
interceptor:
|
|
314
|
-
class:
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
341
|
+
de as useChatPortal
|
|
326
342
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
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
|
|
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
|
|
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} />`,
|
|
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
|
|
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
|
|
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
|
|
14
|
+
"url": "https://github.com/jostvian/site-operator/issues"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://github.com/jostvian
|
|
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.
|
|
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"
|