@applica-software-guru/persona-sdk 0.1.58 → 0.1.59

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.es.js CHANGED
@@ -1,8 +1,8 @@
1
- var J = Object.defineProperty;
2
- var K = (a, t, e) => t in a ? J(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var o = (a, t, e) => K(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { createContext as q, useContext as E, useState as x, useRef as _, useMemo as B, useEffect as Y, useCallback as v } from "react";
5
- import { useExternalStoreRuntime as G, CompositeAttachmentAdapter as V, SimpleImageAttachmentAdapter as H, AssistantRuntimeProvider as Q } from "@assistant-ui/react";
1
+ var K = Object.defineProperty;
2
+ var q = (i, t, e) => t in i ? K(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var o = (i, t, e) => q(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { createContext as _, useContext as R, useState as x, useRef as B, useMemo as Y, useEffect as G, useCallback as E } from "react";
5
+ import { useExternalStoreRuntime as V, CompositeAttachmentAdapter as H, SimpleImageAttachmentAdapter as Q, AssistantRuntimeProvider as X } from "@assistant-ui/react";
6
6
  var D = { exports: {} }, C = {};
7
7
  /**
8
8
  * @license React
@@ -13,78 +13,78 @@ 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 $;
17
- function X() {
18
- if ($) return C;
19
- $ = 1;
20
- var a = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
21
- function e(n, s, i) {
16
+ var M;
17
+ function Z() {
18
+ if (M) return C;
19
+ M = 1;
20
+ var i = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
21
+ function e(n, s, a) {
22
22
  var c = null;
23
- if (i !== void 0 && (c = "" + i), s.key !== void 0 && (c = "" + s.key), "key" in s) {
24
- i = {};
23
+ if (a !== void 0 && (c = "" + a), s.key !== void 0 && (c = "" + s.key), "key" in s) {
24
+ a = {};
25
25
  for (var l in s)
26
- l !== "key" && (i[l] = s[l]);
27
- } else i = s;
28
- return s = i.ref, {
29
- $$typeof: a,
26
+ l !== "key" && (a[l] = s[l]);
27
+ } else a = s;
28
+ return s = a.ref, {
29
+ $$typeof: i,
30
30
  type: n,
31
31
  key: c,
32
32
  ref: s !== void 0 ? s : null,
33
- props: i
33
+ props: a
34
34
  };
35
35
  }
36
36
  return C.Fragment = t, C.jsx = e, C.jsxs = e, C;
37
37
  }
38
- D.exports = X();
39
- var A = D.exports;
40
- function Z(a) {
41
- return a.filter((t) => {
38
+ D.exports = Z();
39
+ var T = D.exports;
40
+ function ee(i) {
41
+ return i.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 M(a) {
46
+ function $(i) {
47
47
  const t = [];
48
48
  let e = null;
49
- for (const s of a)
49
+ for (const s of i)
50
50
  s.type !== "transaction" && (s.type === "reasoning" ? (e != null && (t.push(e), e = null), t.push(s)) : s.functionCalls ? (e && t.push(e), t.push(s), e = null) : s.functionResponse ? t[t.length - 1] = {
51
51
  ...t[t.length - 1],
52
52
  functionResponse: s.functionResponse
53
53
  } : e && s.protocol === e.protocol && (e.role === s.role || s.finishReason === "stop") ? (e.text += s.text, e.files = [...e.files ?? [], ...s.files ?? []]) : (e && t.push(e), e = {
54
54
  ...s
55
55
  }));
56
- return e && t.push(e), Z(t);
56
+ return e && t.push(e), ee(t);
57
57
  }
58
- function ee(a) {
58
+ function te(i) {
59
59
  var e, n;
60
- const t = ((e = a.files) == null ? void 0 : e.map(
60
+ const t = ((e = i.files) == null ? void 0 : e.map(
61
61
  (s) => ({
62
62
  type: "file",
63
63
  data: s.url,
64
64
  mimeType: s.contentType
65
65
  })
66
66
  )) ?? [];
67
- return a.role === "function" ? {
68
- id: a.id,
67
+ return i.role === "function" ? {
68
+ id: i.id,
69
69
  role: "assistant",
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;
70
+ status: (i == null ? void 0 : i.functionResponse) === null ? { type: "running" } : { type: "complete", reason: "stop" },
71
+ content: ((n = i.functionCalls) == null ? void 0 : n.map((s) => {
72
+ var a;
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: (i = a.functionResponse) == null ? void 0 : i.result
78
+ result: (a = i.functionResponse) == null ? void 0 : a.result
79
79
  };
80
80
  })) ?? []
81
81
  } : {
82
- id: a.id,
83
- role: a.role,
84
- content: a.type === "reasoning" ? [{ type: "reasoning", text: a.text }, ...t] : [{ type: "text", text: a.text }, ...t]
82
+ id: i.id,
83
+ role: i.role,
84
+ content: i.type === "reasoning" ? [{ type: "reasoning", text: i.text }, ...t] : [{ type: "text", text: i.text }, ...t]
85
85
  };
86
86
  }
87
- class P {
87
+ class A {
88
88
  constructor() {
89
89
  o(this, "statusChangeCallbacks", []);
90
90
  o(this, "messageCallbacks", []);
@@ -119,7 +119,7 @@ class P {
119
119
  onTransaction(t) {
120
120
  }
121
121
  }
122
- class N extends P {
122
+ class N extends A {
123
123
  constructor(e) {
124
124
  super();
125
125
  o(this, "status");
@@ -145,7 +145,7 @@ class N extends P {
145
145
  this.session = e;
146
146
  }
147
147
  async send(e) {
148
- const { apiUrl: n, apiKey: s, agentId: i } = this.config, c = this.session ?? "new", l = e, f = await (await fetch(`${n}/agents/${i}/sessions/${c}/messages`, {
148
+ const { apiUrl: n, apiKey: s, agentId: a } = this.config, c = this.session ?? "new", l = e, f = await (await fetch(`${n}/agents/${a}/sessions/${c}/messages`, {
149
149
  body: JSON.stringify({ userMessage: l }),
150
150
  method: "POST",
151
151
  headers: {
@@ -162,7 +162,7 @@ class N extends P {
162
162
  );
163
163
  }
164
164
  }
165
- class I extends P {
165
+ class I extends A {
166
166
  constructor(e) {
167
167
  super();
168
168
  o(this, "status");
@@ -188,7 +188,7 @@ class I extends P {
188
188
  return Promise.resolve(this.session);
189
189
  const n = e || this.session || "new";
190
190
  (l = this.config.logger) == null || l.debug("Connecting to WebSocket with sessionId:", n);
191
- const s = encodeURIComponent(this.config.apiKey), i = this.config.agentId, c = `${this.config.webSocketUrl}?sessionCode=${n}&agentId=${i}&apiKey=${s}`;
191
+ const s = encodeURIComponent(this.config.apiKey), a = this.config.agentId, c = `${this.config.webSocketUrl}?sessionCode=${n}&agentId=${a}&apiKey=${s}`;
192
192
  return this.setStatus("connecting"), this.webSocket = new WebSocket(c), this.webSocket.addEventListener("open", () => {
193
193
  this.setStatus("connected");
194
194
  }), this.webSocket.addEventListener("message", (u) => {
@@ -210,7 +210,7 @@ class I extends P {
210
210
  return this.webSocket && this.status === "connected" ? (this.webSocket.send(JSON.stringify({ type: "request", payload: e })), Promise.resolve()) : Promise.reject(new Error("WebSocket is not connected"));
211
211
  }
212
212
  }
213
- class te {
213
+ class se {
214
214
  constructor(t) {
215
215
  o(this, "config");
216
216
  o(this, "pc", null);
@@ -254,14 +254,14 @@ class te {
254
254
  s.streams[0].getTracks().forEach((c) => {
255
255
  this.remoteStream.addTrack(c);
256
256
  }), this.audioCtx || this._startAnalyzers();
257
- const i = new Audio();
258
- i.srcObject = this.remoteStream, i.play().catch((c) => {
257
+ const a = new Audio();
258
+ a.srcObject = this.remoteStream, a.play().catch((c) => {
259
259
  var l;
260
260
  (l = this.config.logger) == null || l.error("Error playing remote audio:", c);
261
261
  });
262
262
  }, this.pc.onicecandidate = (s) => {
263
- var i;
264
- s.candidate && ((i = this.ws) == null ? void 0 : i.readyState) === WebSocket.OPEN && this.ws.send(
263
+ var a;
264
+ s.candidate && ((a = this.ws) == null ? void 0 : a.readyState) === WebSocket.OPEN && this.ws.send(
265
265
  JSON.stringify({
266
266
  type: "CANDIDATE",
267
267
  src: "client",
@@ -269,8 +269,8 @@ class te {
269
269
  })
270
270
  );
271
271
  }, this.pc.ondatachannel = (s) => {
272
- const i = s.channel;
273
- i.onmessage = (c) => {
272
+ const a = s.channel;
273
+ a.onmessage = (c) => {
274
274
  this.messageCallbacks.forEach((l) => {
275
275
  l(c);
276
276
  });
@@ -281,12 +281,12 @@ class te {
281
281
  var l, u;
282
282
  const s = await this.pc.createOffer();
283
283
  await this.pc.setLocalDescription(s);
284
- const i = {
284
+ const a = {
285
285
  apiKey: this.config.apiKey,
286
286
  agentId: this.config.agentId,
287
287
  sessionCode: t
288
288
  };
289
- (l = this.config.logger) == null || l.debug("Opening connection to WebRTC server: ", i);
289
+ (l = this.config.logger) == null || l.debug("Opening connection to WebRTC server: ", a);
290
290
  const c = {
291
291
  type: "OFFER",
292
292
  src: ((u = crypto.randomUUID) == null ? void 0 : u.call(crypto)) || "client_" + Date.now(),
@@ -296,18 +296,18 @@ class te {
296
296
  type: s.type
297
297
  },
298
298
  connectionId: (Date.now() % 1e6).toString(),
299
- metadata: i
299
+ metadata: a
300
300
  }
301
301
  };
302
302
  this.ws.send(JSON.stringify(c));
303
303
  }, this.ws.onmessage = async (s) => {
304
304
  var c;
305
- const i = JSON.parse(s.data);
306
- if (i.type === "ANSWER")
307
- await this.pc.setRemoteDescription(new RTCSessionDescription(i.payload.sdp));
308
- else if (i.type === "CANDIDATE")
305
+ const a = JSON.parse(s.data);
306
+ if (a.type === "ANSWER")
307
+ await this.pc.setRemoteDescription(new RTCSessionDescription(a.payload.sdp));
308
+ else if (a.type === "CANDIDATE")
309
309
  try {
310
- await this.pc.addIceCandidate(new RTCIceCandidate(i.payload.candidate));
310
+ await this.pc.addIceCandidate(new RTCIceCandidate(a.payload.candidate));
311
311
  } catch (l) {
312
312
  (c = this.config.logger) == null || c.error("Error adding ICE candidate:", l);
313
313
  }
@@ -352,9 +352,9 @@ class te {
352
352
  const n = () => {
353
353
  if (!this.localAnalyser || !this.remoteAnalyser || this.visualizerCallbacks.length === 0)
354
354
  return;
355
- const s = new Uint8Array(this.localAnalyser.frequencyBinCount), i = new Uint8Array(this.remoteAnalyser.frequencyBinCount);
356
- this.localAnalyser.getByteFrequencyData(s), this.remoteAnalyser.getByteFrequencyData(i);
357
- const c = s.reduce((u, f) => u + f, 0) / s.length, l = i.reduce((u, f) => u + f, 0) / i.length;
355
+ const s = new Uint8Array(this.localAnalyser.frequencyBinCount), a = new Uint8Array(this.remoteAnalyser.frequencyBinCount);
356
+ this.localAnalyser.getByteFrequencyData(s), this.remoteAnalyser.getByteFrequencyData(a);
357
+ const c = s.reduce((u, f) => u + f, 0) / s.length, l = a.reduce((u, f) => u + f, 0) / a.length;
358
358
  this.visualizerCallbacks.length > 0 && this.visualizerCallbacks.forEach((u) => {
359
359
  u({
360
360
  localAmplitude: c,
@@ -368,7 +368,7 @@ class te {
368
368
  this.analyzerFrame && (cancelAnimationFrame(this.analyzerFrame), this.analyzerFrame = null), this.localAnalyser = null, this.remoteAnalyser = null;
369
369
  }
370
370
  }
371
- class z extends P {
371
+ class z extends A {
372
372
  constructor(e) {
373
373
  super();
374
374
  o(this, "status");
@@ -376,7 +376,7 @@ class z extends P {
376
376
  o(this, "autostart");
377
377
  o(this, "config");
378
378
  o(this, "webRTCClient");
379
- this.config = e, this.status = "disconnected", this.session = null, this.autostart = (e == null ? void 0 : e.autostart) ?? !1, this.webRTCClient = new te(e), this.webRTCClient.addMessageCallback((n) => {
379
+ this.config = e, this.status = "disconnected", this.session = null, this.autostart = (e == null ? void 0 : e.autostart) ?? !1, this.webRTCClient = new se(e), this.webRTCClient.addMessageCallback((n) => {
380
380
  const s = JSON.parse(n.data);
381
381
  this.notifyMessage(s);
382
382
  });
@@ -404,7 +404,7 @@ class z extends P {
404
404
  return this.status !== "connected" ? Promise.reject(new Error("Not connected")) : (this.webRTCClient.sendMessage(e), Promise.resolve());
405
405
  }
406
406
  }
407
- class se {
407
+ class ne {
408
408
  constructor(t) {
409
409
  o(this, "config");
410
410
  this.config = t;
@@ -429,7 +429,7 @@ class se {
429
429
  });
430
430
  }
431
431
  }
432
- class ne {
432
+ class ie {
433
433
  constructor(t, e) {
434
434
  o(this, "transaction");
435
435
  o(this, "manager");
@@ -444,13 +444,13 @@ class ne {
444
444
  await this.fail("No function call found");
445
445
  return;
446
446
  }
447
- const n = e.name, s = e.args, i = t[n];
448
- if (!i) {
447
+ const n = e.name, s = e.args, a = t[n];
448
+ if (!a) {
449
449
  await this.fail(`Tool ${n} not found`);
450
450
  return;
451
451
  }
452
452
  try {
453
- const c = await i(s);
453
+ const c = await a(s);
454
454
  await this.complete(c);
455
455
  } catch (c) {
456
456
  await this.fail(`Error executing tool ${n}: ${c}`);
@@ -463,7 +463,7 @@ class ne {
463
463
  await this.manager.fail(this.transaction, { success: !1, output: null, error: t });
464
464
  }
465
465
  }
466
- class ie extends P {
466
+ class ae extends A {
467
467
  constructor(e) {
468
468
  super();
469
469
  o(this, "status");
@@ -493,77 +493,77 @@ class ie extends P {
493
493
  throw (n = this.config.logger) == null || n.debug("Sending message:", e), new Error("Not implemented");
494
494
  }
495
495
  onTransaction(e) {
496
- var i;
496
+ var a;
497
497
  if (!this.config.onTransaction) {
498
- (i = this.config.logger) == null || i.error("Transaction protocol config is not set");
498
+ (a = this.config.logger) == null || a.error("Transaction protocol config is not set");
499
499
  return;
500
500
  }
501
- const n = new se(this.config), s = new ne(e, n);
501
+ const n = new ne(this.config), s = new ie(e, n);
502
502
  this.config.onTransaction(s);
503
503
  }
504
504
  }
505
- const R = q(void 0);
506
- function ae(a) {
505
+ const S = _(void 0);
506
+ function oe(i) {
507
507
  return new Promise((t, e) => {
508
508
  const n = new FileReader();
509
- n.readAsDataURL(a), n.onload = () => {
510
- const i = n.result.split(";base64,")[1];
511
- t(i);
509
+ n.readAsDataURL(i), n.onload = () => {
510
+ const a = n.result.split(";base64,")[1];
511
+ t(a);
512
512
  }, n.onerror = (s) => {
513
513
  e(s);
514
514
  };
515
515
  });
516
516
  }
517
- function oe({
518
- dev: a = !1,
517
+ function re({
518
+ dev: i = !1,
519
519
  protocols: t,
520
520
  logger: e,
521
521
  children: n,
522
522
  session: s = "new",
523
- ...i
523
+ ...a
524
524
  }) {
525
- const [c, l] = x(!1), [u, f] = x([]), [b, U] = x(s), [S, W] = x(/* @__PURE__ */ new Map()), T = _(!1), m = B(() => {
525
+ const [c, l] = x(!1), [u, f] = x([]), [b, U] = x(s), [P, W] = x(/* @__PURE__ */ new Map()), v = B(!1), m = Y(() => {
526
526
  if (Array.isArray(t))
527
527
  return t;
528
528
  if (typeof t == "object" && t !== null) {
529
- const r = a ? "localhost:8000" : "persona.applica.guru/api", p = a ? "http" : "https", d = a ? "ws" : "wss";
529
+ const r = i ? "localhost:8000" : "persona.applica.guru/api", p = i ? "http" : "https", d = i ? "ws" : "wss";
530
530
  let y = Object.keys(t).map((g) => {
531
531
  switch (g) {
532
532
  case "rest":
533
533
  const h = t[g];
534
534
  return h === !0 ? new N({
535
535
  apiUrl: `${p}://${r}`,
536
- apiKey: i.apiKey,
537
- agentId: i.agentId,
536
+ apiKey: a.apiKey,
537
+ agentId: a.agentId,
538
538
  logger: e
539
539
  }) : typeof h == "object" && h !== null ? new N(h) : null;
540
540
  case "webrtc":
541
541
  const w = t[g];
542
542
  return w === !0 ? new z({
543
543
  webrtcUrl: `${d}://${r}/webrtc`,
544
- apiKey: i.apiKey,
545
- agentId: i.agentId,
544
+ apiKey: a.apiKey,
545
+ agentId: a.agentId,
546
546
  logger: e
547
547
  }) : typeof w == "object" && w !== null ? new z(w) : null;
548
548
  case "websocket":
549
549
  const k = t[g];
550
550
  return k === !0 ? new I({
551
551
  webSocketUrl: `${d}://${r}/websocket`,
552
- apiKey: i.apiKey,
553
- agentId: i.agentId,
552
+ apiKey: a.apiKey,
553
+ agentId: a.agentId,
554
554
  logger: e
555
555
  }) : typeof k == "object" && k !== null ? new I(k) : null;
556
556
  default:
557
557
  throw new Error(`Unknown protocol: ${g}`);
558
558
  }
559
559
  }).filter((g) => g !== null);
560
- return i.tools && y.push(
561
- new ie({
560
+ return a.tools && y.push(
561
+ new ae({
562
562
  apiUrl: `${p}://${r}`,
563
- apiKey: i.apiKey,
564
- agentId: i.agentId,
563
+ apiKey: a.apiKey,
564
+ agentId: a.agentId,
565
565
  onTransaction: async (g) => {
566
- await g.invoke(i.tools);
566
+ await g.invoke(a.tools);
567
567
  },
568
568
  logger: e
569
569
  })
@@ -571,18 +571,18 @@ function oe({
571
571
  }
572
572
  throw new Error("Invalid protocols configuration");
573
573
  }, []);
574
- Y(() => {
575
- T.current || (T.current = !0, e == null || e.debug(
574
+ G(() => {
575
+ v.current || (v.current = !0, e == null || e.debug(
576
576
  "Initializing protocols: ",
577
577
  m.map((r) => r.getName())
578
578
  ), m.forEach((r) => {
579
579
  r.setSession(b), r.clearListeners(), r.addStatusChangeListener((p) => {
580
- e == null || e.debug(`${r.getName()} has notified new status: ${p}`), S.set(r.getName(), p), W(new Map(S));
580
+ e == null || e.debug(`${r.getName()} has notified new status: ${p}`), P.set(r.getName(), p), W(new Map(P));
581
581
  }), r.addMessageListener((p) => {
582
582
  if (p.type === "message") {
583
583
  const d = p.payload;
584
584
  f(
585
- (y) => M([...y, { ...d, protocol: r.getName() }])
585
+ (y) => $([...y, { ...d, protocol: r.getName() }])
586
586
  );
587
587
  } else if (p.type === "reasoning") {
588
588
  const d = p.payload;
@@ -592,12 +592,12 @@ function oe({
592
592
  ![image](https://persona.applica.guru/api/files/${d.imageUrl})`);
593
593
  const g = { type: "reasoning", text: y, role: "assistant", finishReason: "stop" };
594
594
  f(
595
- (h) => M([...h, { ...g, protocol: r.getName() }])
595
+ (h) => $([...h, { ...g, protocol: r.getName() }])
596
596
  );
597
597
  } else p.type === "transaction" && m.filter((d) => d !== r).forEach((d) => d.onTransaction(p.payload));
598
598
  }), r.autostart && r.status === "disconnected" && (e == null || e.debug(`Connecting to protocol: ${r.getName()}`), r.connect(b));
599
599
  }));
600
- }, [b, m, e, S]);
600
+ }, [b, m, e, P]);
601
601
  const j = async (r) => {
602
602
  var g;
603
603
  if (((g = r.content[0]) == null ? void 0 : g.type) !== "text") throw new Error("Only text messages are supported");
@@ -610,7 +610,7 @@ function oe({
610
610
  role: "user",
611
611
  image: {
612
612
  contentType: h.contentType,
613
- content: await ae(h.file)
613
+ content: await oe(h.file)
614
614
  },
615
615
  text: "",
616
616
  type: "text"
@@ -620,33 +620,33 @@ function oe({
620
620
  text: r.content[0].text,
621
621
  type: "text"
622
622
  }), e == null || e.debug("Sending message:", y), await (d == null ? void 0 : d.send(y)), l(!1);
623
- }, O = v(() => (l(!1), f([]), U("new"), Promise.resolve()), []), L = v(() => Promise.resolve(), []), F = G({
623
+ }, O = E(() => (l(!1), f([]), U("new"), Promise.resolve()), []), L = E(() => Promise.resolve(), []), F = E(() => u, [u]), J = V({
624
624
  isRunning: c,
625
625
  messages: u,
626
- convertMessage: ee,
626
+ convertMessage: te,
627
627
  onNew: j,
628
628
  onCancel: O,
629
629
  onReload: L,
630
630
  adapters: {
631
- attachments: new V([new H()])
631
+ attachments: new H([new Q()])
632
632
  }
633
633
  });
634
- return /* @__PURE__ */ A.jsx(R.Provider, { value: { protocols: m, protocolsStatus: S }, children: /* @__PURE__ */ A.jsx(Q, { runtime: F, children: n }) });
634
+ return /* @__PURE__ */ T.jsx(S.Provider, { value: { protocols: m, protocolsStatus: P, getMessages: F }, children: /* @__PURE__ */ T.jsx(X, { runtime: J, children: n }) });
635
635
  }
636
- function he({ children: a, ...t }) {
637
- return /* @__PURE__ */ A.jsx(oe, { ...t, children: a });
636
+ function de({ children: i, ...t }) {
637
+ return /* @__PURE__ */ T.jsx(re, { ...t, children: i });
638
638
  }
639
- function de() {
640
- const a = E(R);
641
- if (!a)
639
+ function fe() {
640
+ const i = R(S);
641
+ if (!i)
642
642
  throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");
643
- return a;
643
+ return i;
644
644
  }
645
- function re(a) {
646
- const t = E(R);
645
+ function ce(i) {
646
+ const t = R(S);
647
647
  if (!t)
648
648
  throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");
649
- const e = t.protocols.find((s) => s.getName() === a);
649
+ const e = t.protocols.find((s) => s.getName() === i);
650
650
  if (!e)
651
651
  return null;
652
652
  const n = t.protocolsStatus.get(e.getName());
@@ -663,19 +663,25 @@ function re(a) {
663
663
  status: n || e.status
664
664
  };
665
665
  }
666
- function fe() {
667
- const a = E(R);
668
- if (!a)
666
+ function pe() {
667
+ const i = R(S);
668
+ if (!i)
669
669
  throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");
670
- for (const t of a.protocols)
670
+ for (const t of i.protocols)
671
671
  if (t.getName() === "rest")
672
672
  return t.config.apiUrl;
673
673
  throw new Error("REST protocol not found");
674
674
  }
675
- function pe() {
676
- return re("webrtc");
675
+ function ge() {
676
+ return ce("webrtc");
677
+ }
678
+ function ye() {
679
+ const i = R(S);
680
+ if (!i)
681
+ throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");
682
+ return i.getMessages();
677
683
  }
678
- class ge {
684
+ class me {
679
685
  constructor() {
680
686
  o(this, "prefix", "[Persona]");
681
687
  }
@@ -696,16 +702,17 @@ class ge {
696
702
  }
697
703
  }
698
704
  export {
699
- ge as PersonaConsoleLogger,
700
- P as PersonaProtocolBase,
705
+ me as PersonaConsoleLogger,
706
+ A as PersonaProtocolBase,
701
707
  N as PersonaRESTProtocol,
702
- he as PersonaRuntimeProvider,
703
- ie as PersonaTransactionProtocol,
708
+ de as PersonaRuntimeProvider,
709
+ ae as PersonaTransactionProtocol,
704
710
  z as PersonaWebRTCProtocol,
705
711
  I as PersonaWebSocketProtocol,
706
- de as usePersonaRuntime,
707
- fe as usePersonaRuntimeEndpoint,
708
- re as usePersonaRuntimeProtocol,
709
- pe as usePersonaRuntimeWebRTCProtocol
712
+ fe as usePersonaRuntime,
713
+ pe as usePersonaRuntimeEndpoint,
714
+ ye as usePersonaRuntimeMessages,
715
+ ce as usePersonaRuntimeProtocol,
716
+ ge as usePersonaRuntimeWebRTCProtocol
710
717
  };
711
718
  //# sourceMappingURL=bundle.es.js.map