@applica-software-guru/persona-sdk 0.1.61 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +3 -3
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +318 -308
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +3 -3
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +3 -3
- package/dist/bundle.umd.js.map +1 -1
- package/dist/protocol/base.d.ts +5 -5
- package/dist/protocol/base.d.ts.map +1 -1
- package/dist/protocol/rest.d.ts +3 -2
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/protocol/transaction.d.ts +2 -2
- package/dist/protocol/transaction.d.ts.map +1 -1
- package/dist/protocol/webrtc.d.ts +3 -3
- package/dist/protocol/webrtc.d.ts.map +1 -1
- package/dist/protocol/websocket.d.ts +2 -2
- package/dist/protocol/websocket.d.ts.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/types.d.ts +18 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/playground/src/chat.tsx +8 -3
- package/src/protocol/base.ts +5 -6
- package/src/protocol/rest.ts +19 -8
- package/src/protocol/transaction.ts +2 -5
- package/src/protocol/webrtc.ts +8 -8
- package/src/protocol/websocket.ts +5 -5
- package/src/runtime.tsx +14 -5
- package/src/types.ts +22 -12
package/dist/bundle.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
import { createContext as
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var K = (a, e, t) => e in a ? J(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var o = (a, e, t) => K(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { createContext as q, useContext as A, useState as R, useRef as B, useMemo as Y, useEffect as G, useCallback as T } from "react";
|
|
5
5
|
import { useExternalStoreRuntime as V, CompositeAttachmentAdapter as H, SimpleImageAttachmentAdapter as Q, AssistantRuntimeProvider as X } from "@assistant-ui/react";
|
|
6
|
-
var
|
|
6
|
+
var U = { exports: {} }, S = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -13,121 +13,122 @@ var D = { exports: {} }, C = {};
|
|
|
13
13
|
* This source code is licensed under the MIT license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
|
-
var
|
|
16
|
+
var N;
|
|
17
17
|
function Z() {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
function
|
|
18
|
+
if (N) return S;
|
|
19
|
+
N = 1;
|
|
20
|
+
var a = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
21
|
+
function t(n, s, i) {
|
|
22
22
|
var c = null;
|
|
23
|
-
if (
|
|
24
|
-
|
|
23
|
+
if (i !== void 0 && (c = "" + i), s.key !== void 0 && (c = "" + s.key), "key" in s) {
|
|
24
|
+
i = {};
|
|
25
25
|
for (var l in s)
|
|
26
|
-
l !== "key" && (
|
|
27
|
-
} else
|
|
28
|
-
return s =
|
|
29
|
-
$$typeof:
|
|
26
|
+
l !== "key" && (i[l] = s[l]);
|
|
27
|
+
} else i = s;
|
|
28
|
+
return s = i.ref, {
|
|
29
|
+
$$typeof: a,
|
|
30
30
|
type: n,
|
|
31
31
|
key: c,
|
|
32
32
|
ref: s !== void 0 ? s : null,
|
|
33
|
-
props:
|
|
33
|
+
props: i
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return S.Fragment = e, S.jsx = t, S.jsxs = t, S;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
function
|
|
41
|
-
return
|
|
42
|
-
var
|
|
43
|
-
return
|
|
38
|
+
U.exports = Z();
|
|
39
|
+
var v = U.exports;
|
|
40
|
+
function tt(a) {
|
|
41
|
+
return a.filter((e) => {
|
|
42
|
+
var t;
|
|
43
|
+
return e.finishReason === "stop" ? e.text !== null && ((t = e.text) == null ? void 0 : t.trim()) !== "" : !0;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
for (const s of
|
|
50
|
-
s.type !== "transaction" && (s.type === "reasoning" ? (
|
|
51
|
-
...
|
|
46
|
+
function I(a) {
|
|
47
|
+
const e = [];
|
|
48
|
+
let t = null;
|
|
49
|
+
for (const s of a)
|
|
50
|
+
s.type !== "transaction" && (s.type === "reasoning" ? (t != null && (e.push(t), t = null), e.push(s)) : s.functionCalls ? (t && e.push(t), e.push(s), t = null) : s.functionResponse ? e[e.length - 1] = {
|
|
51
|
+
...e[e.length - 1],
|
|
52
52
|
functionResponse: s.functionResponse
|
|
53
|
-
} :
|
|
53
|
+
} : t && s.protocol === t.protocol && (t.role === s.role || s.finishReason === "stop") ? (t.text += s.text, t.files = [...t.files ?? [], ...s.files ?? []]) : (t && e.push(t), t = {
|
|
54
54
|
...s
|
|
55
55
|
}));
|
|
56
|
-
return
|
|
56
|
+
return t && e.push(t), tt(e);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
var
|
|
60
|
-
const
|
|
58
|
+
function et(a) {
|
|
59
|
+
var t, n;
|
|
60
|
+
const e = ((t = a.files) == null ? void 0 : t.map(
|
|
61
61
|
(s) => ({
|
|
62
62
|
type: "file",
|
|
63
63
|
data: s.url,
|
|
64
64
|
mimeType: s.contentType
|
|
65
65
|
})
|
|
66
66
|
)) ?? [];
|
|
67
|
-
return
|
|
68
|
-
id:
|
|
67
|
+
return a.role === "function" ? {
|
|
68
|
+
id: a.id,
|
|
69
69
|
role: "assistant",
|
|
70
|
-
status: (
|
|
71
|
-
content: ((n =
|
|
72
|
-
var
|
|
70
|
+
status: (a == null ? void 0 : a.functionResponse) === null ? { type: "running" } : { type: "complete", reason: "stop" },
|
|
71
|
+
content: ((n = a.functionCalls) == null ? void 0 : n.map((s) => {
|
|
72
|
+
var i;
|
|
73
73
|
return {
|
|
74
74
|
type: "tool-call",
|
|
75
75
|
toolName: s.name,
|
|
76
76
|
toolCallId: s.id,
|
|
77
77
|
args: s.args,
|
|
78
|
-
result: (
|
|
78
|
+
result: (i = a.functionResponse) == null ? void 0 : i.result
|
|
79
79
|
};
|
|
80
80
|
})) ?? []
|
|
81
81
|
} : {
|
|
82
|
-
id:
|
|
83
|
-
role:
|
|
84
|
-
content:
|
|
82
|
+
id: a.id,
|
|
83
|
+
role: a.role,
|
|
84
|
+
content: a.type === "reasoning" ? [{ type: "reasoning", text: a.text }, ...e] : [{ type: "text", text: a.text }, ...e]
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
class
|
|
87
|
+
class E {
|
|
88
88
|
constructor() {
|
|
89
89
|
o(this, "statusChangeCallbacks", []);
|
|
90
90
|
o(this, "messageCallbacks", []);
|
|
91
91
|
}
|
|
92
|
-
addStatusChangeListener(
|
|
93
|
-
this.statusChangeCallbacks.push(
|
|
92
|
+
addStatusChangeListener(e) {
|
|
93
|
+
this.statusChangeCallbacks.push(e);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
this.messageCallbacks.push(
|
|
95
|
+
addPacketListener(e) {
|
|
96
|
+
this.messageCallbacks.push(e);
|
|
97
97
|
}
|
|
98
|
-
async syncSession(
|
|
99
|
-
this.session =
|
|
98
|
+
async syncSession(e) {
|
|
99
|
+
this.session = e;
|
|
100
100
|
}
|
|
101
|
-
async
|
|
102
|
-
this.messageCallbacks.forEach((
|
|
101
|
+
async notifyPacket(e) {
|
|
102
|
+
this.messageCallbacks.forEach((t) => t(e));
|
|
103
103
|
}
|
|
104
|
-
async
|
|
105
|
-
|
|
106
|
-
this.messageCallbacks.forEach((n) => n(
|
|
104
|
+
async notifyPackets(e) {
|
|
105
|
+
e.forEach((t) => {
|
|
106
|
+
this.messageCallbacks.forEach((n) => n(t));
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
async setSession(
|
|
110
|
-
this.session =
|
|
109
|
+
async setSession(e) {
|
|
110
|
+
this.session = e;
|
|
111
111
|
}
|
|
112
|
-
async setStatus(
|
|
113
|
-
const
|
|
114
|
-
this.status =
|
|
112
|
+
async setStatus(e) {
|
|
113
|
+
const t = this.status !== e;
|
|
114
|
+
this.status = e, t && this.statusChangeCallbacks.forEach((n) => n(e));
|
|
115
115
|
}
|
|
116
116
|
clearListeners() {
|
|
117
117
|
this.statusChangeCallbacks = [], this.messageCallbacks = [];
|
|
118
118
|
}
|
|
119
|
-
onTransaction(
|
|
119
|
+
onTransaction(e) {
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
class
|
|
123
|
-
constructor(
|
|
122
|
+
class M extends E {
|
|
123
|
+
constructor(t) {
|
|
124
124
|
super();
|
|
125
125
|
o(this, "status");
|
|
126
126
|
o(this, "autostart");
|
|
127
127
|
o(this, "session");
|
|
128
128
|
o(this, "config");
|
|
129
129
|
o(this, "notify", !0);
|
|
130
|
-
this
|
|
130
|
+
o(this, "context", {});
|
|
131
|
+
this.config = t, this.status = "disconnected", this.autostart = !0;
|
|
131
132
|
}
|
|
132
133
|
getName() {
|
|
133
134
|
return "rest";
|
|
@@ -135,42 +136,47 @@ class N extends A {
|
|
|
135
136
|
getPriority() {
|
|
136
137
|
return 100;
|
|
137
138
|
}
|
|
138
|
-
async connect(
|
|
139
|
-
return this.setStatus("connected"),
|
|
139
|
+
async connect(t) {
|
|
140
|
+
return this.setStatus("connected"), t;
|
|
140
141
|
}
|
|
141
142
|
async disconnect() {
|
|
142
143
|
this.setStatus("disconnected"), this.session = null;
|
|
143
144
|
}
|
|
144
|
-
async syncSession(
|
|
145
|
-
this.session =
|
|
145
|
+
async syncSession(t) {
|
|
146
|
+
this.session = t;
|
|
146
147
|
}
|
|
147
|
-
async
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
async sendPacket(t) {
|
|
149
|
+
var g, k;
|
|
150
|
+
const { apiUrl: n, apiKey: s, agentId: i } = this.config, c = this.session ?? "new";
|
|
151
|
+
if (t.type === "command" && ((g = t == null ? void 0 : t.payload) == null ? void 0 : g.command) == "set_initial_context") {
|
|
152
|
+
this.context = (k = t == null ? void 0 : t.payload) == null ? void 0 : k.arguments;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const l = t.payload, f = await (await fetch(`${n}/sessions/${c}/messages`, {
|
|
156
|
+
body: JSON.stringify({ agentId: i, userMessage: l, initial_context: this.context }),
|
|
150
157
|
method: "POST",
|
|
151
158
|
headers: {
|
|
152
159
|
"Content-Type": "application/json",
|
|
153
|
-
"x-fox-apikey": s,
|
|
154
160
|
"x-persona-apikey": s
|
|
155
161
|
}
|
|
156
162
|
})).json();
|
|
157
|
-
this.
|
|
158
|
-
f.response.messages.map((
|
|
163
|
+
this.notifyPackets(
|
|
164
|
+
f.response.messages.map((w) => ({
|
|
159
165
|
type: "message",
|
|
160
|
-
payload:
|
|
166
|
+
payload: w
|
|
161
167
|
}))
|
|
162
168
|
);
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
|
-
class
|
|
166
|
-
constructor(
|
|
171
|
+
class z extends E {
|
|
172
|
+
constructor(t) {
|
|
167
173
|
super();
|
|
168
174
|
o(this, "status");
|
|
169
175
|
o(this, "autostart");
|
|
170
176
|
o(this, "session");
|
|
171
177
|
o(this, "config");
|
|
172
178
|
o(this, "webSocket");
|
|
173
|
-
this.config =
|
|
179
|
+
this.config = t, this.status = "disconnected", this.autostart = !0, this.session = null, this.webSocket = null;
|
|
174
180
|
}
|
|
175
181
|
getName() {
|
|
176
182
|
return "websocket";
|
|
@@ -178,22 +184,22 @@ class I extends A {
|
|
|
178
184
|
getPriority() {
|
|
179
185
|
return 500;
|
|
180
186
|
}
|
|
181
|
-
async syncSession(
|
|
187
|
+
async syncSession(t) {
|
|
182
188
|
var n;
|
|
183
|
-
(n = this.config.logger) == null || n.debug("Syncing session with WebSocket protocol:",
|
|
189
|
+
(n = this.config.logger) == null || n.debug("Syncing session with WebSocket protocol:", t), this.session = t, this.webSocket && this.status === "connected" && (this.disconnect(), this.connect(t));
|
|
184
190
|
}
|
|
185
|
-
connect(
|
|
191
|
+
connect(t) {
|
|
186
192
|
var l;
|
|
187
193
|
if (this.webSocket !== null && this.status === "connected")
|
|
188
194
|
return Promise.resolve(this.session);
|
|
189
|
-
const n =
|
|
195
|
+
const n = t || this.session || "new";
|
|
190
196
|
(l = this.config.logger) == null || l.debug("Connecting to WebSocket with sessionId:", n);
|
|
191
|
-
const s = encodeURIComponent(this.config.apiKey),
|
|
197
|
+
const s = encodeURIComponent(this.config.apiKey), i = this.config.agentId, c = `${this.config.webSocketUrl}?sessionCode=${n}&agentId=${i}&apiKey=${s}`;
|
|
192
198
|
return this.setStatus("connecting"), this.webSocket = new WebSocket(c), this.webSocket.addEventListener("open", () => {
|
|
193
199
|
this.setStatus("connected");
|
|
194
200
|
}), this.webSocket.addEventListener("message", (u) => {
|
|
195
201
|
const f = JSON.parse(u.data);
|
|
196
|
-
this.
|
|
202
|
+
this.notifyPacket(f);
|
|
197
203
|
}), this.webSocket.addEventListener("close", () => {
|
|
198
204
|
var u;
|
|
199
205
|
this.setStatus("disconnected"), this.webSocket = null, (u = this.config.logger) == null || u.warn("WebSocket connection closed");
|
|
@@ -203,15 +209,15 @@ class I extends A {
|
|
|
203
209
|
}), Promise.resolve(n);
|
|
204
210
|
}
|
|
205
211
|
disconnect() {
|
|
206
|
-
var
|
|
207
|
-
return (
|
|
212
|
+
var t;
|
|
213
|
+
return (t = this.config.logger) == null || t.debug("Disconnecting WebSocket"), this.webSocket && this.status === "connected" && (this.webSocket.close(), this.setStatus("disconnected"), this.webSocket = null), Promise.resolve();
|
|
208
214
|
}
|
|
209
|
-
|
|
210
|
-
return this.webSocket && this.status === "connected" ? (this.webSocket.send(JSON.stringify(
|
|
215
|
+
sendPacket(t) {
|
|
216
|
+
return this.webSocket && this.status === "connected" ? (this.webSocket.send(JSON.stringify(t)), Promise.resolve()) : Promise.reject(new Error("WebSocket is not connected"));
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
|
-
class
|
|
214
|
-
constructor(
|
|
219
|
+
class st {
|
|
220
|
+
constructor(e) {
|
|
215
221
|
o(this, "config");
|
|
216
222
|
o(this, "pc", null);
|
|
217
223
|
o(this, "ws", null);
|
|
@@ -225,9 +231,9 @@ class se {
|
|
|
225
231
|
o(this, "isConnected", !1);
|
|
226
232
|
o(this, "visualizerCallbacks", []);
|
|
227
233
|
o(this, "messageCallbacks", []);
|
|
228
|
-
this.config =
|
|
234
|
+
this.config = e;
|
|
229
235
|
}
|
|
230
|
-
async connect(
|
|
236
|
+
async connect(e) {
|
|
231
237
|
var n;
|
|
232
238
|
if (this.isConnected) return;
|
|
233
239
|
this.isConnected = !0;
|
|
@@ -254,14 +260,14 @@ class se {
|
|
|
254
260
|
s.streams[0].getTracks().forEach((c) => {
|
|
255
261
|
this.remoteStream.addTrack(c);
|
|
256
262
|
}), this.audioCtx || this._startAnalyzers();
|
|
257
|
-
const
|
|
258
|
-
|
|
263
|
+
const i = new Audio();
|
|
264
|
+
i.srcObject = this.remoteStream, i.play().catch((c) => {
|
|
259
265
|
var l;
|
|
260
266
|
(l = this.config.logger) == null || l.error("Error playing remote audio:", c);
|
|
261
267
|
});
|
|
262
268
|
}, this.pc.onicecandidate = (s) => {
|
|
263
|
-
var
|
|
264
|
-
s.candidate && ((
|
|
269
|
+
var i;
|
|
270
|
+
s.candidate && ((i = this.ws) == null ? void 0 : i.readyState) === WebSocket.OPEN && this.ws.send(
|
|
265
271
|
JSON.stringify({
|
|
266
272
|
type: "CANDIDATE",
|
|
267
273
|
src: "client",
|
|
@@ -269,24 +275,24 @@ class se {
|
|
|
269
275
|
})
|
|
270
276
|
);
|
|
271
277
|
}, this.pc.ondatachannel = (s) => {
|
|
272
|
-
const
|
|
273
|
-
|
|
278
|
+
const i = s.channel;
|
|
279
|
+
i.onmessage = (c) => {
|
|
274
280
|
this.messageCallbacks.forEach((l) => {
|
|
275
281
|
l(c);
|
|
276
282
|
});
|
|
277
283
|
};
|
|
278
284
|
};
|
|
279
|
-
const
|
|
280
|
-
this.ws = new WebSocket(`${
|
|
285
|
+
const t = this.config.webrtcUrl || "wss://persona.applica.guru/api/webrtc";
|
|
286
|
+
this.ws = new WebSocket(`${t}?apiKey=${encodeURIComponent(this.config.apiKey)}`), this.ws.onopen = async () => {
|
|
281
287
|
var l, u;
|
|
282
288
|
const s = await this.pc.createOffer();
|
|
283
289
|
await this.pc.setLocalDescription(s);
|
|
284
|
-
const
|
|
290
|
+
const i = {
|
|
285
291
|
apiKey: this.config.apiKey,
|
|
286
292
|
agentId: this.config.agentId,
|
|
287
|
-
sessionCode:
|
|
293
|
+
sessionCode: e
|
|
288
294
|
};
|
|
289
|
-
(l = this.config.logger) == null || l.debug("Opening connection to WebRTC server: ",
|
|
295
|
+
(l = this.config.logger) == null || l.debug("Opening connection to WebRTC server: ", i);
|
|
290
296
|
const c = {
|
|
291
297
|
type: "OFFER",
|
|
292
298
|
src: ((u = crypto.randomUUID) == null ? void 0 : u.call(crypto)) || "client_" + Date.now(),
|
|
@@ -296,18 +302,18 @@ class se {
|
|
|
296
302
|
type: s.type
|
|
297
303
|
},
|
|
298
304
|
connectionId: (Date.now() % 1e6).toString(),
|
|
299
|
-
metadata:
|
|
305
|
+
metadata: i
|
|
300
306
|
}
|
|
301
307
|
};
|
|
302
308
|
this.ws.send(JSON.stringify(c));
|
|
303
309
|
}, this.ws.onmessage = async (s) => {
|
|
304
310
|
var c;
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
await this.pc.setRemoteDescription(new RTCSessionDescription(
|
|
308
|
-
else if (
|
|
311
|
+
const i = JSON.parse(s.data);
|
|
312
|
+
if (i.type === "ANSWER")
|
|
313
|
+
await this.pc.setRemoteDescription(new RTCSessionDescription(i.payload.sdp));
|
|
314
|
+
else if (i.type === "CANDIDATE")
|
|
309
315
|
try {
|
|
310
|
-
await this.pc.addIceCandidate(new RTCIceCandidate(
|
|
316
|
+
await this.pc.addIceCandidate(new RTCIceCandidate(i.payload.candidate));
|
|
311
317
|
} catch (l) {
|
|
312
318
|
(c = this.config.logger) == null || c.error("Error adding ICE candidate:", l);
|
|
313
319
|
}
|
|
@@ -316,45 +322,45 @@ class se {
|
|
|
316
322
|
};
|
|
317
323
|
}
|
|
318
324
|
async disconnect() {
|
|
319
|
-
var
|
|
320
|
-
this.isConnected && (this.isConnected = !1, ((
|
|
325
|
+
var e;
|
|
326
|
+
this.isConnected && (this.isConnected = !1, ((e = this.ws) == null ? void 0 : e.readyState) === WebSocket.OPEN && this.ws.close(), this.pc && this.pc.close(), this.localStream && this.localStream.getTracks().forEach((t) => t.stop()), this.remoteStream = new MediaStream(), this.audioCtx && (await this.audioCtx.close(), this.audioCtx = null), this._stopAnalyzers());
|
|
321
327
|
}
|
|
322
|
-
addVisualizerCallback(
|
|
323
|
-
this.visualizerCallbacks.push(
|
|
328
|
+
addVisualizerCallback(e) {
|
|
329
|
+
this.visualizerCallbacks.push(e);
|
|
324
330
|
}
|
|
325
|
-
addMessageCallback(
|
|
326
|
-
this.messageCallbacks.push(
|
|
331
|
+
addMessageCallback(e) {
|
|
332
|
+
this.messageCallbacks.push(e);
|
|
327
333
|
}
|
|
328
|
-
createDataChannel(
|
|
329
|
-
this.pc && (this.dataChannel = this.pc.createDataChannel(
|
|
330
|
-
var
|
|
331
|
-
return (
|
|
332
|
-
}, this.dataChannel.onmessage = (
|
|
334
|
+
createDataChannel(e = "messages") {
|
|
335
|
+
this.pc && (this.dataChannel = this.pc.createDataChannel(e), this.dataChannel.onopen = () => {
|
|
336
|
+
var t;
|
|
337
|
+
return (t = this.config.logger) == null ? void 0 : t.info("Data channel opened");
|
|
338
|
+
}, this.dataChannel.onmessage = (t) => {
|
|
333
339
|
this.messageCallbacks.forEach((n) => {
|
|
334
|
-
n(
|
|
340
|
+
n(t);
|
|
335
341
|
});
|
|
336
342
|
});
|
|
337
343
|
}
|
|
338
|
-
|
|
339
|
-
var
|
|
344
|
+
sendPacket(e) {
|
|
345
|
+
var t, n;
|
|
340
346
|
if (!this.dataChannel) {
|
|
341
|
-
(
|
|
347
|
+
(t = this.config.logger) == null || t.warn("Data channel is not open, cannot send message");
|
|
342
348
|
return;
|
|
343
349
|
}
|
|
344
|
-
this.dataChannel.send(JSON.stringify(
|
|
350
|
+
this.dataChannel.send(JSON.stringify(e)), (n = this.config.logger) == null || n.info("Sent message:", e);
|
|
345
351
|
}
|
|
346
352
|
_startAnalyzers() {
|
|
347
353
|
if (!this.localStream || !this.remoteStream || this.visualizerCallbacks.length === 0)
|
|
348
354
|
return;
|
|
349
355
|
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
350
|
-
const
|
|
351
|
-
this.localAnalyser = this.audioCtx.createAnalyser(), this.remoteAnalyser = this.audioCtx.createAnalyser(), this.localAnalyser.fftSize = 256, this.remoteAnalyser.fftSize = 256,
|
|
356
|
+
const e = this.audioCtx.createMediaStreamSource(this.localStream), t = this.audioCtx.createMediaStreamSource(this.remoteStream);
|
|
357
|
+
this.localAnalyser = this.audioCtx.createAnalyser(), this.remoteAnalyser = this.audioCtx.createAnalyser(), this.localAnalyser.fftSize = 256, this.remoteAnalyser.fftSize = 256, e.connect(this.localAnalyser), t.connect(this.remoteAnalyser);
|
|
352
358
|
const n = () => {
|
|
353
359
|
if (!this.localAnalyser || !this.remoteAnalyser || this.visualizerCallbacks.length === 0)
|
|
354
360
|
return;
|
|
355
|
-
const s = new Uint8Array(this.localAnalyser.frequencyBinCount),
|
|
356
|
-
this.localAnalyser.getByteFrequencyData(s), this.remoteAnalyser.getByteFrequencyData(
|
|
357
|
-
const c = s.reduce((u, f) => u + f, 0) / s.length, l =
|
|
361
|
+
const s = new Uint8Array(this.localAnalyser.frequencyBinCount), i = new Uint8Array(this.remoteAnalyser.frequencyBinCount);
|
|
362
|
+
this.localAnalyser.getByteFrequencyData(s), this.remoteAnalyser.getByteFrequencyData(i);
|
|
363
|
+
const c = s.reduce((u, f) => u + f, 0) / s.length, l = i.reduce((u, f) => u + f, 0) / i.length;
|
|
358
364
|
this.visualizerCallbacks.length > 0 && this.visualizerCallbacks.forEach((u) => {
|
|
359
365
|
u({
|
|
360
366
|
localAmplitude: c,
|
|
@@ -368,17 +374,17 @@ class se {
|
|
|
368
374
|
this.analyzerFrame && (cancelAnimationFrame(this.analyzerFrame), this.analyzerFrame = null), this.localAnalyser = null, this.remoteAnalyser = null;
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
|
-
class
|
|
372
|
-
constructor(
|
|
377
|
+
class D extends E {
|
|
378
|
+
constructor(t) {
|
|
373
379
|
super();
|
|
374
380
|
o(this, "status");
|
|
375
381
|
o(this, "session");
|
|
376
382
|
o(this, "autostart");
|
|
377
383
|
o(this, "config");
|
|
378
384
|
o(this, "webRTCClient");
|
|
379
|
-
this.config =
|
|
385
|
+
this.config = t, this.status = "disconnected", this.session = null, this.autostart = (t == null ? void 0 : t.autostart) ?? !1, this.webRTCClient = new st(t), this.webRTCClient.addMessageCallback((n) => {
|
|
380
386
|
const s = JSON.parse(n.data);
|
|
381
|
-
this.
|
|
387
|
+
this.notifyPacket(s);
|
|
382
388
|
});
|
|
383
389
|
}
|
|
384
390
|
getName() {
|
|
@@ -387,39 +393,39 @@ class z extends A {
|
|
|
387
393
|
getPriority() {
|
|
388
394
|
return 1e3;
|
|
389
395
|
}
|
|
390
|
-
async syncSession(
|
|
391
|
-
super.syncSession(
|
|
396
|
+
async syncSession(t) {
|
|
397
|
+
super.syncSession(t), this.status === "connected" && (await this.disconnect(), await this.connect(t));
|
|
392
398
|
}
|
|
393
|
-
async connect(
|
|
399
|
+
async connect(t) {
|
|
394
400
|
var n;
|
|
395
|
-
return this.status === "connected" ? Promise.resolve(this.session) : (this.session =
|
|
401
|
+
return this.status === "connected" ? Promise.resolve(this.session) : (this.session = t || this.session || "new", this.setStatus("connecting"), (n = this.config.logger) == null || n.debug("Connecting to WebRTC with sessionId:", this.session), await this.webRTCClient.connect(this.session), this.setStatus("connected"), await this.webRTCClient.createDataChannel(), this.session);
|
|
396
402
|
}
|
|
397
403
|
async disconnect() {
|
|
398
|
-
var
|
|
404
|
+
var t, n, s;
|
|
399
405
|
if (this.status === "disconnected")
|
|
400
|
-
return (
|
|
406
|
+
return (t = this.config.logger) == null || t.warn("Already disconnected"), Promise.resolve();
|
|
401
407
|
await this.webRTCClient.disconnect(), this.setStatus("disconnected"), (s = (n = this.config) == null ? void 0 : n.logger) == null || s.debug("Disconnected from WebRTC");
|
|
402
408
|
}
|
|
403
|
-
|
|
404
|
-
return this.status !== "connected" ? Promise.reject(new Error("Not connected")) : (this.webRTCClient.
|
|
409
|
+
sendPacket(t) {
|
|
410
|
+
return this.status !== "connected" ? Promise.reject(new Error("Not connected")) : (this.webRTCClient.sendPacket(t), Promise.resolve());
|
|
405
411
|
}
|
|
406
412
|
}
|
|
407
|
-
class
|
|
408
|
-
constructor(
|
|
413
|
+
class nt {
|
|
414
|
+
constructor(e) {
|
|
409
415
|
o(this, "config");
|
|
410
|
-
this.config =
|
|
416
|
+
this.config = e;
|
|
411
417
|
}
|
|
412
|
-
async complete(
|
|
418
|
+
async complete(e, t) {
|
|
413
419
|
var n;
|
|
414
|
-
await this.persist(
|
|
420
|
+
await this.persist(e, { ...t, success: !0 }), (n = this.config.logger) == null || n.debug("Transaction completed:", e);
|
|
415
421
|
}
|
|
416
|
-
async fail(
|
|
422
|
+
async fail(e, t) {
|
|
417
423
|
var n;
|
|
418
|
-
await this.persist(
|
|
424
|
+
await this.persist(e, { ...t, success: !1 }), (n = this.config.logger) == null || n.debug("Transaction failed:", { ...e, ...t });
|
|
419
425
|
}
|
|
420
|
-
async persist(
|
|
421
|
-
await fetch(`${this.config.apiUrl}/transactions/${
|
|
422
|
-
body: JSON.stringify(
|
|
426
|
+
async persist(e, t) {
|
|
427
|
+
await fetch(`${this.config.apiUrl}/transactions/${e.id}`, {
|
|
428
|
+
body: JSON.stringify(t),
|
|
423
429
|
method: "POST",
|
|
424
430
|
headers: {
|
|
425
431
|
"Content-Type": "application/json",
|
|
@@ -429,49 +435,49 @@ class ne {
|
|
|
429
435
|
});
|
|
430
436
|
}
|
|
431
437
|
}
|
|
432
|
-
class
|
|
433
|
-
constructor(
|
|
438
|
+
class it {
|
|
439
|
+
constructor(e, t) {
|
|
434
440
|
o(this, "transaction");
|
|
435
441
|
o(this, "manager");
|
|
436
|
-
this.transaction =
|
|
442
|
+
this.transaction = e, this.manager = t;
|
|
437
443
|
}
|
|
438
444
|
getFunctionCall() {
|
|
439
445
|
return this.transaction.functionCall;
|
|
440
446
|
}
|
|
441
|
-
async invoke(
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
447
|
+
async invoke(e) {
|
|
448
|
+
const t = this.transaction.functionCall;
|
|
449
|
+
if (!t) {
|
|
444
450
|
await this.fail("No function call found");
|
|
445
451
|
return;
|
|
446
452
|
}
|
|
447
|
-
const n =
|
|
448
|
-
if (!
|
|
453
|
+
const n = t.name, s = t.args, i = e[n];
|
|
454
|
+
if (!i) {
|
|
449
455
|
await this.fail(`Tool ${n} not found`);
|
|
450
456
|
return;
|
|
451
457
|
}
|
|
452
458
|
try {
|
|
453
|
-
const c = await
|
|
459
|
+
const c = await i(s);
|
|
454
460
|
await this.complete(c);
|
|
455
461
|
} catch (c) {
|
|
456
462
|
await this.fail(`Error executing tool ${n}: ${c}`);
|
|
457
463
|
}
|
|
458
464
|
}
|
|
459
|
-
async complete(
|
|
460
|
-
await this.manager.complete(this.transaction, { success: !0, output:
|
|
465
|
+
async complete(e) {
|
|
466
|
+
await this.manager.complete(this.transaction, { success: !0, output: e, error: null });
|
|
461
467
|
}
|
|
462
|
-
async fail(
|
|
463
|
-
await this.manager.fail(this.transaction, { success: !1, output: null, error:
|
|
468
|
+
async fail(e) {
|
|
469
|
+
await this.manager.fail(this.transaction, { success: !1, output: null, error: e });
|
|
464
470
|
}
|
|
465
471
|
}
|
|
466
|
-
class
|
|
467
|
-
constructor(
|
|
472
|
+
class at extends E {
|
|
473
|
+
constructor(t) {
|
|
468
474
|
super();
|
|
469
475
|
o(this, "status");
|
|
470
476
|
o(this, "autostart");
|
|
471
477
|
o(this, "session");
|
|
472
478
|
o(this, "config");
|
|
473
479
|
o(this, "notify", !0);
|
|
474
|
-
this.config =
|
|
480
|
+
this.config = t, this.status = "disconnected", this.autostart = !0;
|
|
475
481
|
}
|
|
476
482
|
getName() {
|
|
477
483
|
return "transaction";
|
|
@@ -479,151 +485,155 @@ class ae extends A {
|
|
|
479
485
|
getPriority() {
|
|
480
486
|
return 0;
|
|
481
487
|
}
|
|
482
|
-
async connect(
|
|
483
|
-
return this.setStatus("connected"),
|
|
488
|
+
async connect(t) {
|
|
489
|
+
return this.setStatus("connected"), t;
|
|
484
490
|
}
|
|
485
491
|
async disconnect() {
|
|
486
492
|
this.setStatus("disconnected"), this.session = null;
|
|
487
493
|
}
|
|
488
|
-
async syncSession(
|
|
489
|
-
this.session =
|
|
494
|
+
async syncSession(t) {
|
|
495
|
+
this.session = t;
|
|
490
496
|
}
|
|
491
|
-
async
|
|
492
|
-
var n;
|
|
493
|
-
throw (n = this.config.logger) == null || n.debug("Sending message:", e), new Error("Not implemented");
|
|
497
|
+
async sendPacket(t) {
|
|
494
498
|
}
|
|
495
|
-
onTransaction(
|
|
496
|
-
var
|
|
499
|
+
onTransaction(t) {
|
|
500
|
+
var i;
|
|
497
501
|
if (!this.config.onTransaction) {
|
|
498
|
-
(
|
|
502
|
+
(i = this.config.logger) == null || i.error("Transaction protocol config is not set");
|
|
499
503
|
return;
|
|
500
504
|
}
|
|
501
|
-
const n = new
|
|
505
|
+
const n = new nt(this.config), s = new it(t, n);
|
|
502
506
|
this.config.onTransaction(s);
|
|
503
507
|
}
|
|
504
508
|
}
|
|
505
|
-
const
|
|
506
|
-
function
|
|
507
|
-
return new Promise((
|
|
509
|
+
const P = q(void 0);
|
|
510
|
+
function ot(a) {
|
|
511
|
+
return new Promise((e, t) => {
|
|
508
512
|
const n = new FileReader();
|
|
509
|
-
n.readAsDataURL(
|
|
510
|
-
const
|
|
511
|
-
|
|
513
|
+
n.readAsDataURL(a), n.onload = () => {
|
|
514
|
+
const i = n.result.split(";base64,")[1];
|
|
515
|
+
e(i);
|
|
512
516
|
}, n.onerror = (s) => {
|
|
513
|
-
|
|
517
|
+
t(s);
|
|
514
518
|
};
|
|
515
519
|
});
|
|
516
520
|
}
|
|
517
|
-
function
|
|
518
|
-
dev:
|
|
519
|
-
protocols:
|
|
520
|
-
logger:
|
|
521
|
+
function rt({
|
|
522
|
+
dev: a = !1,
|
|
523
|
+
protocols: e,
|
|
524
|
+
logger: t,
|
|
521
525
|
children: n,
|
|
522
526
|
session: s = "new",
|
|
523
|
-
...
|
|
527
|
+
...i
|
|
524
528
|
}) {
|
|
525
|
-
const [c, l] =
|
|
526
|
-
if (Array.isArray(
|
|
527
|
-
return
|
|
528
|
-
if (typeof
|
|
529
|
-
const r =
|
|
530
|
-
let
|
|
531
|
-
switch (
|
|
529
|
+
const [c, l] = R(!1), [u, f] = R([]), [g, k] = R(s), [w, W] = R(/* @__PURE__ */ new Map()), $ = B(!1), b = Y(() => {
|
|
530
|
+
if (Array.isArray(e))
|
|
531
|
+
return e;
|
|
532
|
+
if (typeof e == "object" && e !== null) {
|
|
533
|
+
const r = a ? "localhost:8000" : "persona.applica.guru/api", p = a ? "http" : "https", d = a ? "ws" : "wss";
|
|
534
|
+
let m = Object.keys(e).map((y) => {
|
|
535
|
+
switch (y) {
|
|
532
536
|
case "rest":
|
|
533
|
-
const h =
|
|
534
|
-
return h === !0 ? new
|
|
537
|
+
const h = e[y];
|
|
538
|
+
return h === !0 ? new M({
|
|
535
539
|
apiUrl: `${p}://${r}`,
|
|
536
|
-
apiKey:
|
|
537
|
-
agentId:
|
|
538
|
-
logger:
|
|
539
|
-
}) : typeof h == "object" && h !== null ? new
|
|
540
|
+
apiKey: i.apiKey,
|
|
541
|
+
agentId: i.agentId,
|
|
542
|
+
logger: t
|
|
543
|
+
}) : typeof h == "object" && h !== null ? new M(h) : null;
|
|
540
544
|
case "webrtc":
|
|
541
|
-
const
|
|
542
|
-
return
|
|
545
|
+
const C = e[y];
|
|
546
|
+
return C === !0 ? new D({
|
|
543
547
|
webrtcUrl: `${d}://${r}/webrtc`,
|
|
544
|
-
apiKey:
|
|
545
|
-
agentId:
|
|
546
|
-
logger:
|
|
547
|
-
}) : typeof
|
|
548
|
+
apiKey: i.apiKey,
|
|
549
|
+
agentId: i.agentId,
|
|
550
|
+
logger: t
|
|
551
|
+
}) : typeof C == "object" && C !== null ? new D(C) : null;
|
|
548
552
|
case "websocket":
|
|
549
|
-
const
|
|
550
|
-
return
|
|
553
|
+
const x = e[y];
|
|
554
|
+
return x === !0 ? new z({
|
|
551
555
|
webSocketUrl: `${d}://${r}/websocket`,
|
|
552
|
-
apiKey:
|
|
553
|
-
agentId:
|
|
554
|
-
logger:
|
|
555
|
-
}) : typeof
|
|
556
|
+
apiKey: i.apiKey,
|
|
557
|
+
agentId: i.agentId,
|
|
558
|
+
logger: t
|
|
559
|
+
}) : typeof x == "object" && x !== null ? new z(x) : null;
|
|
556
560
|
default:
|
|
557
|
-
throw new Error(`Unknown protocol: ${
|
|
561
|
+
throw new Error(`Unknown protocol: ${y}`);
|
|
558
562
|
}
|
|
559
|
-
}).filter((
|
|
560
|
-
return
|
|
561
|
-
new
|
|
563
|
+
}).filter((y) => y !== null);
|
|
564
|
+
return i.tools && m.push(
|
|
565
|
+
new at({
|
|
562
566
|
apiUrl: `${p}://${r}`,
|
|
563
|
-
apiKey:
|
|
564
|
-
agentId:
|
|
565
|
-
onTransaction: async (
|
|
566
|
-
await
|
|
567
|
+
apiKey: i.apiKey,
|
|
568
|
+
agentId: i.agentId,
|
|
569
|
+
onTransaction: async (y) => {
|
|
570
|
+
await y.invoke(i.tools);
|
|
567
571
|
},
|
|
568
|
-
logger:
|
|
572
|
+
logger: t
|
|
569
573
|
})
|
|
570
|
-
),
|
|
574
|
+
), m;
|
|
571
575
|
}
|
|
572
576
|
throw new Error("Invalid protocols configuration");
|
|
573
577
|
}, []);
|
|
574
578
|
G(() => {
|
|
575
|
-
|
|
579
|
+
$.current || ($.current = !0, t == null || t.debug(
|
|
576
580
|
"Initializing protocols: ",
|
|
577
|
-
|
|
578
|
-
),
|
|
579
|
-
r.setSession(
|
|
580
|
-
|
|
581
|
-
|
|
581
|
+
b.map((r) => r.getName())
|
|
582
|
+
), b.forEach((r) => {
|
|
583
|
+
r.setSession(g), r.clearListeners(), r.addStatusChangeListener((p) => {
|
|
584
|
+
t == null || t.debug(`${r.getName()} has notified new status: ${p}`), w.set(r.getName(), p), p === "connected" && i.context && r.sendPacket({
|
|
585
|
+
type: "command",
|
|
586
|
+
payload: {
|
|
587
|
+
command: "set_initial_context",
|
|
588
|
+
arguments: i.context
|
|
589
|
+
}
|
|
590
|
+
}), W(new Map(w));
|
|
591
|
+
}), r.addPacketListener((p) => {
|
|
582
592
|
if (p.type === "message") {
|
|
583
593
|
const d = p.payload;
|
|
584
594
|
f(
|
|
585
|
-
(
|
|
595
|
+
(m) => I([...m, { ...d, protocol: r.getName() }])
|
|
586
596
|
);
|
|
587
597
|
} else if (p.type === "reasoning") {
|
|
588
598
|
const d = p.payload;
|
|
589
|
-
let
|
|
590
|
-
d.imageUrl && (
|
|
599
|
+
let m = d.thought;
|
|
600
|
+
d.imageUrl && (m += `
|
|
591
601
|
|
|
592
602
|
`);
|
|
593
|
-
const
|
|
603
|
+
const y = { type: "reasoning", text: m, role: "assistant", finishReason: "stop" };
|
|
594
604
|
f(
|
|
595
|
-
(h) =>
|
|
605
|
+
(h) => I([...h, { ...y, protocol: r.getName() }])
|
|
596
606
|
);
|
|
597
|
-
} else p.type === "transaction" &&
|
|
598
|
-
}), r.autostart && r.status === "disconnected" && (
|
|
607
|
+
} else p.type === "transaction" && b.filter((d) => d !== r).forEach((d) => d.onTransaction(p.payload));
|
|
608
|
+
}), r.autostart && r.status === "disconnected" && (t == null || t.debug(`Connecting to protocol: ${r.getName()}`), r.connect(g));
|
|
599
609
|
}));
|
|
600
|
-
}, [
|
|
610
|
+
}, [g, b, t, w]);
|
|
601
611
|
const j = async (r) => {
|
|
602
|
-
var
|
|
603
|
-
if (((
|
|
612
|
+
var y;
|
|
613
|
+
if (((y = r.content[0]) == null ? void 0 : y.type) !== "text") throw new Error("Only text messages are supported");
|
|
604
614
|
const p = r.content[0].text;
|
|
605
615
|
f((h) => [...h, { role: "user", type: "text", text: p }]), l(!0);
|
|
606
|
-
const d =
|
|
616
|
+
const d = b.sort((h, C) => C.getPriority() - h.getPriority()).find((h) => h.status === "connected"), m = [];
|
|
607
617
|
if (r.attachments)
|
|
608
618
|
for (const h of r.attachments)
|
|
609
|
-
h.contentType.startsWith("image/") && h.file &&
|
|
619
|
+
h.contentType.startsWith("image/") && h.file && m.push({
|
|
610
620
|
role: "user",
|
|
611
621
|
image: {
|
|
612
622
|
contentType: h.contentType,
|
|
613
|
-
content: await
|
|
623
|
+
content: await ot(h.file)
|
|
614
624
|
},
|
|
615
625
|
text: "",
|
|
616
626
|
type: "text"
|
|
617
627
|
});
|
|
618
|
-
r.content &&
|
|
628
|
+
r.content && m.push({
|
|
619
629
|
role: "user",
|
|
620
630
|
text: r.content[0].text,
|
|
621
631
|
type: "text"
|
|
622
|
-
}),
|
|
623
|
-
}, O =
|
|
632
|
+
}), t == null || t.debug("Sending message:", m), await (d == null ? void 0 : d.sendPacket({ type: "request", payload: m })), l(!1);
|
|
633
|
+
}, O = T(() => (l(!1), f([]), k("new"), Promise.resolve()), []), L = T(() => Promise.resolve(), []), F = T(() => u, [u]), _ = V({
|
|
624
634
|
isRunning: c,
|
|
625
635
|
messages: u,
|
|
626
|
-
convertMessage:
|
|
636
|
+
convertMessage: et,
|
|
627
637
|
onNew: j,
|
|
628
638
|
onCancel: O,
|
|
629
639
|
onReload: L,
|
|
@@ -631,88 +641,88 @@ function re({
|
|
|
631
641
|
attachments: new H([new Q()])
|
|
632
642
|
}
|
|
633
643
|
});
|
|
634
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ v.jsx(P.Provider, { value: { protocols: b, protocolsStatus: w, getMessages: F }, children: /* @__PURE__ */ v.jsx(X, { runtime: _, children: n }) });
|
|
635
645
|
}
|
|
636
|
-
function
|
|
637
|
-
return /* @__PURE__ */
|
|
646
|
+
function dt({ children: a, ...e }) {
|
|
647
|
+
return /* @__PURE__ */ v.jsx(rt, { ...e, children: a });
|
|
638
648
|
}
|
|
639
|
-
function
|
|
640
|
-
const
|
|
641
|
-
if (!
|
|
649
|
+
function ft() {
|
|
650
|
+
const a = A(P);
|
|
651
|
+
if (!a)
|
|
642
652
|
throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");
|
|
643
|
-
return
|
|
653
|
+
return a;
|
|
644
654
|
}
|
|
645
|
-
function
|
|
646
|
-
const
|
|
647
|
-
if (!t)
|
|
648
|
-
throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");
|
|
649
|
-
const e = t.protocols.find((s) => s.getName() === i);
|
|
655
|
+
function ct(a) {
|
|
656
|
+
const e = A(P);
|
|
650
657
|
if (!e)
|
|
658
|
+
throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");
|
|
659
|
+
const t = e.protocols.find((s) => s.getName() === a);
|
|
660
|
+
if (!t)
|
|
651
661
|
return null;
|
|
652
|
-
const n =
|
|
662
|
+
const n = e.protocolsStatus.get(t.getName());
|
|
653
663
|
return {
|
|
654
|
-
...
|
|
655
|
-
connect:
|
|
656
|
-
disconnect:
|
|
657
|
-
|
|
658
|
-
setSession:
|
|
659
|
-
addStatusChangeListener:
|
|
660
|
-
|
|
661
|
-
getName:
|
|
662
|
-
getPriority:
|
|
663
|
-
status: n ||
|
|
664
|
+
...t,
|
|
665
|
+
connect: t.connect.bind(t),
|
|
666
|
+
disconnect: t.disconnect.bind(t),
|
|
667
|
+
sendPacket: t.sendPacket.bind(t),
|
|
668
|
+
setSession: t.setSession.bind(t),
|
|
669
|
+
addStatusChangeListener: t.addStatusChangeListener.bind(t),
|
|
670
|
+
addPacketListener: t.addPacketListener.bind(t),
|
|
671
|
+
getName: t.getName.bind(t),
|
|
672
|
+
getPriority: t.getPriority.bind(t),
|
|
673
|
+
status: n || t.status
|
|
664
674
|
};
|
|
665
675
|
}
|
|
666
|
-
function
|
|
667
|
-
const
|
|
668
|
-
if (!
|
|
676
|
+
function pt() {
|
|
677
|
+
const a = A(P);
|
|
678
|
+
if (!a)
|
|
669
679
|
throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");
|
|
670
|
-
for (const
|
|
671
|
-
if (
|
|
672
|
-
return
|
|
680
|
+
for (const e of a.protocols)
|
|
681
|
+
if (e.getName() === "rest")
|
|
682
|
+
return e.config.apiUrl;
|
|
673
683
|
throw new Error("REST protocol not found");
|
|
674
684
|
}
|
|
675
|
-
function
|
|
676
|
-
return
|
|
685
|
+
function yt() {
|
|
686
|
+
return ct("webrtc");
|
|
677
687
|
}
|
|
678
|
-
function
|
|
679
|
-
const
|
|
680
|
-
if (!
|
|
688
|
+
function mt() {
|
|
689
|
+
const a = A(P);
|
|
690
|
+
if (!a)
|
|
681
691
|
throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");
|
|
682
|
-
return
|
|
692
|
+
return a.getMessages();
|
|
683
693
|
}
|
|
684
|
-
class
|
|
694
|
+
class gt {
|
|
685
695
|
constructor() {
|
|
686
696
|
o(this, "prefix", "[Persona]");
|
|
687
697
|
}
|
|
688
|
-
log(
|
|
689
|
-
console.log(`${this.prefix} - ${
|
|
698
|
+
log(e, ...t) {
|
|
699
|
+
console.log(`${this.prefix} - ${e}`, ...t);
|
|
690
700
|
}
|
|
691
|
-
info(
|
|
692
|
-
console.info(`${this.prefix} - ${
|
|
701
|
+
info(e, ...t) {
|
|
702
|
+
console.info(`${this.prefix} - ${e}`, ...t);
|
|
693
703
|
}
|
|
694
|
-
warn(
|
|
695
|
-
console.warn(`${this.prefix} - ${
|
|
704
|
+
warn(e, ...t) {
|
|
705
|
+
console.warn(`${this.prefix} - ${e}`, ...t);
|
|
696
706
|
}
|
|
697
|
-
error(
|
|
698
|
-
console.error(`${this.prefix} - ${
|
|
707
|
+
error(e, ...t) {
|
|
708
|
+
console.error(`${this.prefix} - ${e}`, ...t);
|
|
699
709
|
}
|
|
700
|
-
debug(
|
|
701
|
-
console.debug(`${this.prefix} - ${
|
|
710
|
+
debug(e, ...t) {
|
|
711
|
+
console.debug(`${this.prefix} - ${e}`, ...t);
|
|
702
712
|
}
|
|
703
713
|
}
|
|
704
714
|
export {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
gt as PersonaConsoleLogger,
|
|
716
|
+
E as PersonaProtocolBase,
|
|
717
|
+
M as PersonaRESTProtocol,
|
|
718
|
+
dt as PersonaRuntimeProvider,
|
|
719
|
+
at as PersonaTransactionProtocol,
|
|
720
|
+
D as PersonaWebRTCProtocol,
|
|
721
|
+
z as PersonaWebSocketProtocol,
|
|
722
|
+
ft as usePersonaRuntime,
|
|
723
|
+
pt as usePersonaRuntimeEndpoint,
|
|
724
|
+
mt as usePersonaRuntimeMessages,
|
|
725
|
+
ct as usePersonaRuntimeProtocol,
|
|
726
|
+
yt as usePersonaRuntimeWebRTCProtocol
|
|
717
727
|
};
|
|
718
728
|
//# sourceMappingURL=bundle.es.js.map
|