@applica-software-guru/persona-sdk 0.1.64 → 0.1.65
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 +157 -116
- 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/rest.d.ts.map +1 -1
- package/dist/protocol/webrtc.d.ts +3 -0
- package/dist/protocol/webrtc.d.ts.map +1 -1
- package/dist/protocol/websocket.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/protocol/rest.ts +34 -17
- package/src/protocol/webrtc.ts +24 -1
- package/src/protocol/websocket.ts +14 -6
package/dist/bundle.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
2
|
var V = (o, t, e) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
3
|
var r = (o, t, e) => V(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { createContext as Y, useContext as
|
|
4
|
+
import { createContext as Y, useContext as A, useState as E, useRef as G, useMemo as H, useEffect as Q, useCallback as M } from "react";
|
|
5
5
|
import { useExternalStoreRuntime as X, CompositeAttachmentAdapter as Z, SimpleImageAttachmentAdapter as ee, AssistantRuntimeProvider as te } from "@assistant-ui/react";
|
|
6
|
-
var
|
|
6
|
+
var F = { exports: {} }, k = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -13,10 +13,10 @@ var U = { exports: {} }, k = {};
|
|
|
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 j;
|
|
17
17
|
function se() {
|
|
18
|
-
if (
|
|
19
|
-
|
|
18
|
+
if (j) return k;
|
|
19
|
+
j = 1;
|
|
20
20
|
var o = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
21
21
|
function e(s, n, a) {
|
|
22
22
|
var i = null;
|
|
@@ -35,15 +35,15 @@ function se() {
|
|
|
35
35
|
}
|
|
36
36
|
return k.Fragment = t, k.jsx = e, k.jsxs = e, k;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
var
|
|
38
|
+
F.exports = se();
|
|
39
|
+
var N = F.exports;
|
|
40
40
|
function ne(o) {
|
|
41
41
|
return o.filter((t) => {
|
|
42
42
|
var e;
|
|
43
43
|
return t.finishReason === "stop" ? t.text !== null && ((e = t.text) == null ? void 0 : e.trim()) !== "" : !0;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function q(o) {
|
|
47
47
|
const t = [];
|
|
48
48
|
let e = null;
|
|
49
49
|
for (const n of o)
|
|
@@ -84,7 +84,7 @@ function oe(o) {
|
|
|
84
84
|
content: o.type === "reasoning" ? [{ type: "reasoning", text: o.text }, ...t] : [{ type: "text", text: o.text }, ...t]
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
class
|
|
87
|
+
class v {
|
|
88
88
|
constructor() {
|
|
89
89
|
r(this, "statusChangeCallbacks", []);
|
|
90
90
|
r(this, "messageCallbacks", []);
|
|
@@ -119,7 +119,7 @@ class M {
|
|
|
119
119
|
onTransaction(t) {
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
class _ extends
|
|
122
|
+
class _ extends v {
|
|
123
123
|
constructor(e) {
|
|
124
124
|
super();
|
|
125
125
|
r(this, "status");
|
|
@@ -147,33 +147,51 @@ class _ extends M {
|
|
|
147
147
|
this.session = e;
|
|
148
148
|
}
|
|
149
149
|
async sendPacket(e) {
|
|
150
|
-
var
|
|
150
|
+
var u, p, g, w;
|
|
151
151
|
const { apiUrl: s, apiKey: n, agentId: a } = this.config, i = this.session ?? "new";
|
|
152
|
-
if (e.type === "command" && ((
|
|
153
|
-
this.context = (
|
|
152
|
+
if (e.type === "command" && ((u = e == null ? void 0 : e.payload) == null ? void 0 : u.command) == "set_initial_context") {
|
|
153
|
+
this.context = (p = e == null ? void 0 : e.payload) == null ? void 0 : p.arguments;
|
|
154
154
|
return;
|
|
155
|
-
} else if (e.type === "command" && ((
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
} else if (e.type === "command" && ((g = e == null ? void 0 : e.payload) == null ? void 0 : g.command) == "set_local_tools") {
|
|
156
|
+
this.notifyPacket({
|
|
157
|
+
type: "message",
|
|
158
|
+
payload: {
|
|
159
|
+
type: "text",
|
|
160
|
+
role: "assistant",
|
|
161
|
+
text: "Local tools with rest protocol are not supported."
|
|
162
|
+
}
|
|
163
|
+
});
|
|
158
164
|
return;
|
|
159
165
|
}
|
|
160
|
-
const l = e.payload
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
const l = e.payload;
|
|
167
|
+
try {
|
|
168
|
+
const b = await (await fetch(`${s}/sessions/${i}/messages`, {
|
|
169
|
+
body: JSON.stringify({ agentId: a, userMessage: l, initialContext: this.context, tools: this.tools }),
|
|
170
|
+
method: "POST",
|
|
171
|
+
headers: {
|
|
172
|
+
"Content-Type": "application/json",
|
|
173
|
+
"x-persona-apikey": n
|
|
174
|
+
}
|
|
175
|
+
})).json();
|
|
176
|
+
this.notifyPackets(
|
|
177
|
+
b.response.messages.map(($) => ({
|
|
178
|
+
type: "message",
|
|
179
|
+
payload: $
|
|
180
|
+
}))
|
|
181
|
+
);
|
|
182
|
+
} catch (R) {
|
|
183
|
+
this.notifyPacket({
|
|
170
184
|
type: "message",
|
|
171
|
-
payload:
|
|
172
|
-
|
|
173
|
-
|
|
185
|
+
payload: {
|
|
186
|
+
role: "assistant",
|
|
187
|
+
type: "text",
|
|
188
|
+
text: "An error occurred while processing your request. Please try again later."
|
|
189
|
+
}
|
|
190
|
+
}), (w = this.config.logger) == null || w.error("Error sending packet:", R);
|
|
191
|
+
}
|
|
174
192
|
}
|
|
175
193
|
}
|
|
176
|
-
class
|
|
194
|
+
class W extends v {
|
|
177
195
|
constructor(e) {
|
|
178
196
|
super();
|
|
179
197
|
r(this, "status");
|
|
@@ -203,14 +221,21 @@ class z extends M {
|
|
|
203
221
|
return this.setStatus("connecting"), this.webSocket = new WebSocket(i), this.webSocket.addEventListener("open", () => {
|
|
204
222
|
this.setStatus("connected");
|
|
205
223
|
}), this.webSocket.addEventListener("message", (u) => {
|
|
206
|
-
const
|
|
207
|
-
this.notifyPacket(
|
|
208
|
-
}), this.webSocket.addEventListener("close", () => {
|
|
224
|
+
const p = JSON.parse(u.data);
|
|
225
|
+
this.notifyPacket(p);
|
|
226
|
+
}), this.webSocket.addEventListener("close", (u) => {
|
|
227
|
+
var p;
|
|
228
|
+
this.setStatus("disconnected"), this.webSocket = null, u.code !== 1e3 && (this.notifyPacket({
|
|
229
|
+
type: "message",
|
|
230
|
+
payload: {
|
|
231
|
+
role: "assistant",
|
|
232
|
+
type: "text",
|
|
233
|
+
text: "Oops! The connection to the server was lost. Please try again later."
|
|
234
|
+
}
|
|
235
|
+
}), (p = this.config.logger) == null || p.warn("WebSocket connection closed"));
|
|
236
|
+
}), this.webSocket.addEventListener("error", () => {
|
|
209
237
|
var u;
|
|
210
|
-
this.setStatus("disconnected"), this.webSocket = null, (u = this.config.logger) == null || u.
|
|
211
|
-
}), this.webSocket.addEventListener("error", (u) => {
|
|
212
|
-
var f;
|
|
213
|
-
this.setStatus("disconnected"), this.webSocket = null, (f = this.config.logger) == null || f.error("WebSocket error", u);
|
|
238
|
+
this.setStatus("disconnected"), this.webSocket = null, (u = this.config.logger) == null || u.error("WebSocket connection error");
|
|
214
239
|
}), Promise.resolve(s);
|
|
215
240
|
}
|
|
216
241
|
disconnect() {
|
|
@@ -236,6 +261,7 @@ class ae {
|
|
|
236
261
|
r(this, "isConnected", !1);
|
|
237
262
|
r(this, "visualizerCallbacks", []);
|
|
238
263
|
r(this, "messageCallbacks", []);
|
|
264
|
+
r(this, "errorCallbacks", []);
|
|
239
265
|
r(this, "queuedMessages", []);
|
|
240
266
|
this.config = t;
|
|
241
267
|
}
|
|
@@ -329,8 +355,10 @@ class ae {
|
|
|
329
355
|
} catch (l) {
|
|
330
356
|
(i = this.config.logger) == null || i.error("Error adding ICE candidate:", l);
|
|
331
357
|
}
|
|
332
|
-
}, this.ws.onclose = () => {
|
|
333
|
-
this.
|
|
358
|
+
}, this.ws.onclose = (n) => {
|
|
359
|
+
n.code !== 1e3 && this.errorCallbacks.forEach((a) => {
|
|
360
|
+
a("Oops! The connection to the server was lost. Please try again later.");
|
|
361
|
+
}), this._stopAnalyzers();
|
|
334
362
|
};
|
|
335
363
|
}
|
|
336
364
|
async disconnect() {
|
|
@@ -343,6 +371,9 @@ class ae {
|
|
|
343
371
|
addMessageCallback(t) {
|
|
344
372
|
this.messageCallbacks.push(t);
|
|
345
373
|
}
|
|
374
|
+
addErrorCallback(t) {
|
|
375
|
+
this.errorCallbacks.push(t);
|
|
376
|
+
}
|
|
346
377
|
createDataChannel(t = "messages") {
|
|
347
378
|
this.pc && (this.dataChannel = this.pc.createDataChannel(t), this.dataChannel.onopen = () => {
|
|
348
379
|
var e, s;
|
|
@@ -375,7 +406,7 @@ class ae {
|
|
|
375
406
|
return;
|
|
376
407
|
const n = new Uint8Array(this.localAnalyser.frequencyBinCount), a = new Uint8Array(this.remoteAnalyser.frequencyBinCount);
|
|
377
408
|
this.localAnalyser.getByteFrequencyData(n), this.remoteAnalyser.getByteFrequencyData(a);
|
|
378
|
-
const i = n.reduce((u,
|
|
409
|
+
const i = n.reduce((u, p) => u + p, 0) / n.length, l = a.reduce((u, p) => u + p, 0) / a.length;
|
|
379
410
|
this.visualizerCallbacks.length > 0 && this.visualizerCallbacks.forEach((u) => {
|
|
380
411
|
u({
|
|
381
412
|
localAmplitude: i,
|
|
@@ -389,7 +420,7 @@ class ae {
|
|
|
389
420
|
this.analyzerFrame && (cancelAnimationFrame(this.analyzerFrame), this.analyzerFrame = null), this.localAnalyser = null, this.remoteAnalyser = null;
|
|
390
421
|
}
|
|
391
422
|
}
|
|
392
|
-
class
|
|
423
|
+
class z extends v {
|
|
393
424
|
constructor(e) {
|
|
394
425
|
super();
|
|
395
426
|
r(this, "status");
|
|
@@ -400,6 +431,16 @@ class F extends M {
|
|
|
400
431
|
this.config = e, this.status = "disconnected", this.session = null, this.autostart = (e == null ? void 0 : e.autostart) ?? !1, this.webRTCClient = new ae(e), this.webRTCClient.addMessageCallback((s) => {
|
|
401
432
|
const n = JSON.parse(s.data);
|
|
402
433
|
this.notifyPacket(n);
|
|
434
|
+
}), this.webRTCClient.addErrorCallback((s) => {
|
|
435
|
+
var n;
|
|
436
|
+
(n = this.config.logger) == null || n.error("WebRTC error:", s), this.notifyPacket({
|
|
437
|
+
type: "message",
|
|
438
|
+
payload: {
|
|
439
|
+
type: "text",
|
|
440
|
+
role: "assistant",
|
|
441
|
+
text: s
|
|
442
|
+
}
|
|
443
|
+
});
|
|
403
444
|
});
|
|
404
445
|
}
|
|
405
446
|
getName() {
|
|
@@ -484,7 +525,7 @@ class re {
|
|
|
484
525
|
await this.manager.fail(this.transaction, { success: !1, output: null, error: t });
|
|
485
526
|
}
|
|
486
527
|
}
|
|
487
|
-
class ce extends
|
|
528
|
+
class ce extends v {
|
|
488
529
|
constructor(e) {
|
|
489
530
|
super();
|
|
490
531
|
r(this, "status");
|
|
@@ -526,7 +567,7 @@ class ce extends M {
|
|
|
526
567
|
return this._tools;
|
|
527
568
|
}
|
|
528
569
|
}
|
|
529
|
-
const
|
|
570
|
+
const x = Y(void 0);
|
|
530
571
|
function le(o) {
|
|
531
572
|
return new Promise((t, e) => {
|
|
532
573
|
const s = new FileReader();
|
|
@@ -547,61 +588,61 @@ function ue({
|
|
|
547
588
|
session: a = "new",
|
|
548
589
|
...i
|
|
549
590
|
}) {
|
|
550
|
-
const [l, u] =
|
|
591
|
+
const [l, u] = E(!1), [p, g] = E([]), [w, R] = E(a), [b, $] = E(/* @__PURE__ */ new Map()), O = G(!1), C = H(() => {
|
|
551
592
|
if (Array.isArray(e))
|
|
552
593
|
return e;
|
|
553
594
|
if (typeof e == "object" && e !== null) {
|
|
554
|
-
const c = o ? "localhost:8000" : t || "persona.applica.guru/api",
|
|
555
|
-
let
|
|
556
|
-
switch (
|
|
595
|
+
const c = o ? "localhost:8000" : t || "persona.applica.guru/api", f = o ? "http" : "https", h = o ? "ws" : "wss";
|
|
596
|
+
let m = Object.keys(e).map((y) => {
|
|
597
|
+
switch (y) {
|
|
557
598
|
case "rest":
|
|
558
|
-
const d = e[
|
|
599
|
+
const d = e[y];
|
|
559
600
|
return d === !0 ? new _({
|
|
560
|
-
apiUrl: `${
|
|
601
|
+
apiUrl: `${f}://${c}`,
|
|
561
602
|
apiKey: i.apiKey,
|
|
562
603
|
agentId: i.agentId,
|
|
563
604
|
logger: s
|
|
564
605
|
}) : typeof d == "object" && d !== null ? new _(d) : null;
|
|
565
606
|
case "webrtc":
|
|
566
|
-
const
|
|
567
|
-
return
|
|
607
|
+
const S = e[y];
|
|
608
|
+
return S === !0 ? new z({
|
|
568
609
|
webrtcUrl: `${h}://${c}/webrtc`,
|
|
569
610
|
apiKey: i.apiKey,
|
|
570
611
|
agentId: i.agentId,
|
|
571
612
|
logger: s
|
|
572
|
-
}) : typeof
|
|
613
|
+
}) : typeof S == "object" && S !== null ? new z(S) : null;
|
|
573
614
|
case "websocket":
|
|
574
|
-
const
|
|
575
|
-
return
|
|
615
|
+
const T = e[y];
|
|
616
|
+
return T === !0 ? new W({
|
|
576
617
|
webSocketUrl: `${h}://${c}/websocket`,
|
|
577
618
|
apiKey: i.apiKey,
|
|
578
619
|
agentId: i.agentId,
|
|
579
620
|
logger: s
|
|
580
|
-
}) : typeof
|
|
621
|
+
}) : typeof T == "object" && T !== null ? new W(T) : null;
|
|
581
622
|
default:
|
|
582
|
-
throw new Error(`Unknown protocol: ${
|
|
623
|
+
throw new Error(`Unknown protocol: ${y}`);
|
|
583
624
|
}
|
|
584
|
-
}).filter((
|
|
585
|
-
return i.tools &&
|
|
625
|
+
}).filter((y) => y !== null);
|
|
626
|
+
return i.tools && m.push(
|
|
586
627
|
new ce({
|
|
587
|
-
apiUrl: `${
|
|
628
|
+
apiUrl: `${f}://${c}`,
|
|
588
629
|
apiKey: i.apiKey,
|
|
589
630
|
agentId: i.agentId,
|
|
590
631
|
tools: i.tools,
|
|
591
632
|
// Pass raw tools
|
|
592
633
|
logger: s
|
|
593
634
|
})
|
|
594
|
-
),
|
|
635
|
+
), m;
|
|
595
636
|
}
|
|
596
637
|
throw new Error("Invalid protocols configuration");
|
|
597
638
|
}, []);
|
|
598
639
|
Q(() => {
|
|
599
|
-
|
|
640
|
+
O.current || (O.current = !0, s == null || s.debug(
|
|
600
641
|
"Initializing protocols: ",
|
|
601
|
-
|
|
602
|
-
),
|
|
603
|
-
c.setSession(
|
|
604
|
-
s == null || s.debug(`${c.getName()} has notified new status: ${
|
|
642
|
+
C.map((c) => c.getName())
|
|
643
|
+
), C.forEach((c) => {
|
|
644
|
+
c.setSession(w), c.clearListeners(), c.addStatusChangeListener((f) => {
|
|
645
|
+
s == null || s.debug(`${c.getName()} has notified new status: ${f}`), b.set(c.getName(), f), f === "connected" && (i.context && c.sendPacket({
|
|
605
646
|
type: "command",
|
|
606
647
|
payload: {
|
|
607
648
|
command: "set_initial_context",
|
|
@@ -615,36 +656,36 @@ function ue({
|
|
|
615
656
|
tools: i.tools.map((h) => h.schema)
|
|
616
657
|
}
|
|
617
658
|
}
|
|
618
|
-
})),
|
|
619
|
-
}), c.addPacketListener((
|
|
620
|
-
if (
|
|
621
|
-
const h =
|
|
622
|
-
|
|
623
|
-
(
|
|
659
|
+
})), $(new Map(b));
|
|
660
|
+
}), c.addPacketListener((f) => {
|
|
661
|
+
if (f.type === "message") {
|
|
662
|
+
const h = f.payload;
|
|
663
|
+
g(
|
|
664
|
+
(m) => q([...m, { ...h, protocol: c.getName() }])
|
|
624
665
|
);
|
|
625
|
-
} else if (
|
|
626
|
-
const h =
|
|
627
|
-
let
|
|
628
|
-
h.imageUrl && (
|
|
666
|
+
} else if (f.type === "reasoning") {
|
|
667
|
+
const h = f.payload;
|
|
668
|
+
let m = h.thought;
|
|
669
|
+
h.imageUrl && (m += `
|
|
629
670
|
|
|
630
671
|
`);
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
(d) =>
|
|
672
|
+
const y = { type: "reasoning", text: m, role: "assistant", finishReason: "stop" };
|
|
673
|
+
g(
|
|
674
|
+
(d) => q([...d, { ...y, protocol: c.getName() }])
|
|
634
675
|
);
|
|
635
|
-
} else
|
|
636
|
-
}), c.autostart && c.status === "disconnected" && (s == null || s.debug(`Connecting to protocol: ${c.getName()}`), c.connect(
|
|
676
|
+
} else f.type === "transaction" && C.filter((h) => h !== c).forEach((h) => h.onTransaction(f.payload));
|
|
677
|
+
}), c.autostart && c.status === "disconnected" && (s == null || s.debug(`Connecting to protocol: ${c.getName()}`), c.connect(w));
|
|
637
678
|
}));
|
|
638
|
-
}, [
|
|
639
|
-
const
|
|
640
|
-
var
|
|
641
|
-
if (((
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
const h =
|
|
679
|
+
}, [w, C, s, b]);
|
|
680
|
+
const U = async (c) => {
|
|
681
|
+
var y;
|
|
682
|
+
if (((y = c.content[0]) == null ? void 0 : y.type) !== "text") throw new Error("Only text messages are supported");
|
|
683
|
+
const f = c.content[0].text;
|
|
684
|
+
g((d) => [...d, { role: "user", type: "text", text: f }]), u(!0);
|
|
685
|
+
const h = C.sort((d, S) => S.getPriority() - d.getPriority()).find((d) => d.status === "connected"), m = [];
|
|
645
686
|
if (c.attachments)
|
|
646
687
|
for (const d of c.attachments)
|
|
647
|
-
d.contentType.startsWith("image/") && d.file &&
|
|
688
|
+
d.contentType.startsWith("image/") && d.file && m.push({
|
|
648
689
|
role: "user",
|
|
649
690
|
image: {
|
|
650
691
|
contentType: d.contentType,
|
|
@@ -653,35 +694,35 @@ function ue({
|
|
|
653
694
|
text: "",
|
|
654
695
|
type: "text"
|
|
655
696
|
});
|
|
656
|
-
c.content &&
|
|
697
|
+
c.content && m.push({
|
|
657
698
|
role: "user",
|
|
658
699
|
text: c.content[0].text,
|
|
659
700
|
type: "text"
|
|
660
|
-
}), s == null || s.debug("Sending message:",
|
|
661
|
-
}, D =
|
|
701
|
+
}), s == null || s.debug("Sending message:", m), await (h == null ? void 0 : h.sendPacket({ type: "request", payload: m })), u(!1);
|
|
702
|
+
}, D = M(() => (u(!1), g([]), R("new"), Promise.resolve()), []), L = M(() => Promise.resolve(), []), J = M(() => p, [p]), K = X({
|
|
662
703
|
isRunning: l,
|
|
663
|
-
messages:
|
|
704
|
+
messages: p,
|
|
664
705
|
convertMessage: oe,
|
|
665
|
-
onNew:
|
|
706
|
+
onNew: U,
|
|
666
707
|
onCancel: D,
|
|
667
708
|
onReload: L,
|
|
668
709
|
adapters: {
|
|
669
710
|
attachments: new Z([new ee()])
|
|
670
711
|
}
|
|
671
712
|
});
|
|
672
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ N.jsx(x.Provider, { value: { protocols: C, protocolsStatus: b, getMessages: J }, children: /* @__PURE__ */ N.jsx(te, { runtime: K, children: n }) });
|
|
673
714
|
}
|
|
674
715
|
function ge({ children: o, ...t }) {
|
|
675
|
-
return /* @__PURE__ */
|
|
716
|
+
return /* @__PURE__ */ N.jsx(ue, { ...t, children: o });
|
|
676
717
|
}
|
|
677
718
|
function we() {
|
|
678
|
-
const o =
|
|
719
|
+
const o = A(x);
|
|
679
720
|
if (!o)
|
|
680
721
|
throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");
|
|
681
722
|
return o;
|
|
682
723
|
}
|
|
683
724
|
function he(o) {
|
|
684
|
-
const t =
|
|
725
|
+
const t = A(x);
|
|
685
726
|
if (!t)
|
|
686
727
|
throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");
|
|
687
728
|
const e = t.protocols.find((n) => n.getName() === o);
|
|
@@ -702,7 +743,7 @@ function he(o) {
|
|
|
702
743
|
};
|
|
703
744
|
}
|
|
704
745
|
function be() {
|
|
705
|
-
const o =
|
|
746
|
+
const o = A(x);
|
|
706
747
|
if (!o)
|
|
707
748
|
throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");
|
|
708
749
|
for (const t of o.protocols)
|
|
@@ -710,11 +751,11 @@ function be() {
|
|
|
710
751
|
return t.config.apiUrl;
|
|
711
752
|
throw new Error("REST protocol not found");
|
|
712
753
|
}
|
|
713
|
-
function
|
|
754
|
+
function Ce() {
|
|
714
755
|
return he("webrtc");
|
|
715
756
|
}
|
|
716
|
-
function
|
|
717
|
-
const o =
|
|
757
|
+
function Se() {
|
|
758
|
+
const o = A(x);
|
|
718
759
|
if (!o)
|
|
719
760
|
throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");
|
|
720
761
|
return o.getMessages();
|
|
@@ -768,13 +809,13 @@ function de(o) {
|
|
|
768
809
|
}
|
|
769
810
|
};
|
|
770
811
|
}
|
|
771
|
-
function
|
|
812
|
+
function I(o) {
|
|
772
813
|
return {
|
|
773
814
|
schema: de(o),
|
|
774
815
|
implementation: o.implementation
|
|
775
816
|
};
|
|
776
817
|
}
|
|
777
|
-
function
|
|
818
|
+
function pe(o, t, e, s, n, a) {
|
|
778
819
|
const i = {
|
|
779
820
|
name: o,
|
|
780
821
|
description: t,
|
|
@@ -784,9 +825,9 @@ function me(o, t, e, s, n, a) {
|
|
|
784
825
|
output: n,
|
|
785
826
|
implementation: e
|
|
786
827
|
};
|
|
787
|
-
return
|
|
828
|
+
return I(i);
|
|
788
829
|
}
|
|
789
|
-
const
|
|
830
|
+
const ke = pe(
|
|
790
831
|
"sum",
|
|
791
832
|
"Sum two numbers",
|
|
792
833
|
function(t, e) {
|
|
@@ -799,7 +840,7 @@ const xe = me(
|
|
|
799
840
|
{
|
|
800
841
|
result: P("number", "Sum of two numbers")
|
|
801
842
|
}
|
|
802
|
-
),
|
|
843
|
+
), xe = I({
|
|
803
844
|
name: "navigate_to",
|
|
804
845
|
description: "Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",
|
|
805
846
|
title: "Sum two numbers",
|
|
@@ -820,7 +861,7 @@ const xe = me(
|
|
|
820
861
|
function Re(o) {
|
|
821
862
|
const t = [], e = {};
|
|
822
863
|
return o.forEach((s) => {
|
|
823
|
-
const { schema: n, implementation: a } =
|
|
864
|
+
const { schema: n, implementation: a } = I(s);
|
|
824
865
|
t.push(n), e[s.name] = a;
|
|
825
866
|
}), { schemas: t, implementations: e };
|
|
826
867
|
}
|
|
@@ -844,24 +885,24 @@ function Te(o, t) {
|
|
|
844
885
|
}
|
|
845
886
|
export {
|
|
846
887
|
Pe as PersonaConsoleLogger,
|
|
847
|
-
|
|
888
|
+
v as PersonaProtocolBase,
|
|
848
889
|
_ as PersonaRESTProtocol,
|
|
849
890
|
ge as PersonaRuntimeProvider,
|
|
850
891
|
ce as PersonaTransactionProtocol,
|
|
851
|
-
|
|
852
|
-
|
|
892
|
+
z as PersonaWebRTCProtocol,
|
|
893
|
+
W as PersonaWebSocketProtocol,
|
|
853
894
|
P as createParameter,
|
|
854
|
-
|
|
855
|
-
|
|
895
|
+
I as createTool,
|
|
896
|
+
pe as createToolFromFunction,
|
|
856
897
|
Re as createToolRegistry,
|
|
857
898
|
de as generateToolSchema,
|
|
858
|
-
|
|
859
|
-
|
|
899
|
+
xe as navigateToToolExample,
|
|
900
|
+
ke as sumTool,
|
|
860
901
|
we as usePersonaRuntime,
|
|
861
902
|
be as usePersonaRuntimeEndpoint,
|
|
862
|
-
|
|
903
|
+
Se as usePersonaRuntimeMessages,
|
|
863
904
|
he as usePersonaRuntimeProtocol,
|
|
864
|
-
|
|
905
|
+
Ce as usePersonaRuntimeWebRTCProtocol,
|
|
865
906
|
Te as validateToolParameters
|
|
866
907
|
};
|
|
867
908
|
//# sourceMappingURL=bundle.es.js.map
|