@applica-software-guru/persona-sdk 0.0.1-preview6 → 0.1.2

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.
Files changed (99) hide show
  1. package/.eslintrc.cjs +6 -5
  2. package/.nvmrc +1 -1
  3. package/.prettierignore +3 -5
  4. package/.prettierrc +3 -5
  5. package/README.md +247 -2
  6. package/bitbucket-pipelines.yml +2 -12
  7. package/dist/bundle.cjs.js +1 -14
  8. package/dist/bundle.cjs.js.map +1 -1
  9. package/dist/bundle.es.js +472 -699
  10. package/dist/bundle.es.js.map +1 -1
  11. package/dist/index.d.ts +1089 -5
  12. package/package.json +9 -39
  13. package/src/agents/agents-api.ts +54 -0
  14. package/src/agents/types.ts +346 -0
  15. package/src/auth/api-key-auth.ts +13 -0
  16. package/src/auth/authentication-provider.ts +4 -0
  17. package/src/auth/bearer-token-auth.ts +13 -0
  18. package/src/auth/index.ts +3 -0
  19. package/src/credentials/credentials-api.ts +40 -0
  20. package/src/credentials/types.ts +67 -0
  21. package/src/exceptions.ts +10 -0
  22. package/src/features/feature-templates-api.ts +41 -0
  23. package/src/features/features-api.ts +16 -0
  24. package/src/features/types.ts +25 -0
  25. package/src/http-api.ts +95 -0
  26. package/src/index.ts +153 -4
  27. package/src/knowledges/knowledge-base-documents-api.ts +38 -0
  28. package/src/knowledges/knowledge-bases-api.ts +47 -0
  29. package/src/knowledges/types.ts +70 -0
  30. package/src/missions/missions-api.ts +60 -0
  31. package/src/missions/types.ts +25 -0
  32. package/src/paginated.ts +6 -0
  33. package/src/persona-sdk.ts +81 -0
  34. package/src/projects/projects-api.ts +55 -0
  35. package/src/projects/types.ts +42 -0
  36. package/src/revisions/types.ts +9 -0
  37. package/src/service-prices/service-prices-api.ts +32 -0
  38. package/src/service-prices/types.ts +8 -0
  39. package/src/sessions/sessions-api.ts +55 -0
  40. package/src/sessions/types.ts +129 -0
  41. package/src/triggers/trigger-executions-api.ts +27 -0
  42. package/src/triggers/triggers-api.ts +37 -0
  43. package/src/triggers/types.ts +50 -0
  44. package/src/workflows/types.ts +150 -0
  45. package/src/workflows/workflow-executions-api.ts +27 -0
  46. package/src/workflows/workflows-api.ts +51 -0
  47. package/tsconfig.json +20 -28
  48. package/vite.config.ts +20 -62
  49. package/dist/bundle.iife.js +0 -15
  50. package/dist/bundle.iife.js.map +0 -1
  51. package/dist/bundle.umd.js +0 -15
  52. package/dist/bundle.umd.js.map +0 -1
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/logging.d.ts +0 -18
  55. package/dist/logging.d.ts.map +0 -1
  56. package/dist/messages.d.ts +0 -7
  57. package/dist/messages.d.ts.map +0 -1
  58. package/dist/protocol/base.d.ts +0 -23
  59. package/dist/protocol/base.d.ts.map +0 -1
  60. package/dist/protocol/index.d.ts +0 -5
  61. package/dist/protocol/index.d.ts.map +0 -1
  62. package/dist/protocol/rest.d.ts +0 -22
  63. package/dist/protocol/rest.d.ts.map +0 -1
  64. package/dist/protocol/webrtc.d.ts +0 -56
  65. package/dist/protocol/webrtc.d.ts.map +0 -1
  66. package/dist/protocol/websocket.d.ts +0 -22
  67. package/dist/protocol/websocket.d.ts.map +0 -1
  68. package/dist/runtime.d.ts +0 -21
  69. package/dist/runtime.d.ts.map +0 -1
  70. package/dist/types.d.ts +0 -79
  71. package/dist/types.d.ts.map +0 -1
  72. package/jsconfig.node.json +0 -10
  73. package/playground/index.html +0 -14
  74. package/playground/src/app.tsx +0 -10
  75. package/playground/src/chat.tsx +0 -52
  76. package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
  77. package/playground/src/components/assistant-ui/markdown-text.tsx +0 -119
  78. package/playground/src/components/assistant-ui/thread-list.tsx +0 -62
  79. package/playground/src/components/assistant-ui/thread.tsx +0 -249
  80. package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -33
  81. package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -38
  82. package/playground/src/components/ui/avatar.tsx +0 -35
  83. package/playground/src/components/ui/button.tsx +0 -43
  84. package/playground/src/components/ui/tooltip.tsx +0 -32
  85. package/playground/src/lib/utils.ts +0 -6
  86. package/playground/src/main.tsx +0 -10
  87. package/playground/src/styles.css +0 -1
  88. package/playground/src/vite-env.d.ts +0 -1
  89. package/preview.sh +0 -13
  90. package/src/logging.ts +0 -34
  91. package/src/messages.ts +0 -79
  92. package/src/protocol/base.ts +0 -55
  93. package/src/protocol/index.ts +0 -4
  94. package/src/protocol/rest.ts +0 -66
  95. package/src/protocol/webrtc.ts +0 -339
  96. package/src/protocol/websocket.ts +0 -108
  97. package/src/runtime.tsx +0 -217
  98. package/src/types.ts +0 -98
  99. package/tsconfig.node.json +0 -15
package/dist/bundle.es.js CHANGED
@@ -1,748 +1,521 @@
1
- var ie = Object.defineProperty;
2
- var ce = (r, t, e) => t in r ? ie(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var i = (r, t, e) => ce(r, typeof t != "symbol" ? t + "" : t, e);
4
- import le, { createContext as ue, useContext as ne, useState as j, useRef as de, useMemo as he, useEffect as fe, useCallback as Z } from "react";
5
- import { useExternalStoreRuntime as me, AssistantRuntimeProvider as pe } from "@assistant-ui/react";
6
- var re = { exports: {} }, x = {}, Q;
7
- function ge() {
8
- if (Q) return x;
9
- Q = 1;
10
- /**
11
- * @license React
12
- * react-jsx-runtime.development.js
13
- *
14
- * Copyright (c) Meta Platforms, Inc. and affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */
19
- return function() {
20
- function r(s) {
21
- if (s == null) return null;
22
- if (typeof s == "function")
23
- return s.$$typeof === I ? null : s.displayName || s.name || null;
24
- if (typeof s == "string") return s;
25
- switch (s) {
26
- case R:
27
- return "Fragment";
28
- case M:
29
- return "Profiler";
30
- case $:
31
- return "StrictMode";
32
- case y:
33
- return "Suspense";
34
- case S:
35
- return "SuspenseList";
36
- case P:
37
- return "Activity";
38
- }
39
- if (typeof s == "object")
40
- switch (typeof s.tag == "number" && console.error(
41
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
42
- ), s.$$typeof) {
43
- case _:
44
- return "Portal";
45
- case W:
46
- return (s.displayName || "Context") + ".Provider";
47
- case D:
48
- return (s._context.displayName || "Context") + ".Consumer";
49
- case u:
50
- var a = s.render;
51
- return s = s.displayName, s || (s = a.displayName || a.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
52
- case T:
53
- return a = s.displayName || null, a !== null ? a : r(s.type) || "Memo";
54
- case b:
55
- a = s._payload, s = s._init;
56
- try {
57
- return r(s(a));
58
- } catch {
59
- }
60
- }
61
- return null;
62
- }
63
- function t(s) {
64
- return "" + s;
65
- }
66
- function e(s) {
67
- try {
68
- t(s);
69
- var a = !1;
70
- } catch {
71
- a = !0;
72
- }
73
- if (a) {
74
- a = console;
75
- var l = a.error, m = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
76
- return l.call(
77
- a,
78
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
79
- m
80
- ), t(s);
81
- }
82
- }
83
- function n(s) {
84
- if (s === R) return "<>";
85
- if (typeof s == "object" && s !== null && s.$$typeof === b)
86
- return "<...>";
87
- try {
88
- var a = r(s);
89
- return a ? "<" + a + ">" : "<...>";
90
- } catch {
91
- return "<...>";
92
- }
93
- }
94
- function o() {
95
- var s = A.A;
96
- return s === null ? null : s.getOwner();
97
- }
98
- function c() {
99
- return Error("react-stack-top-frame");
100
- }
101
- function d(s) {
102
- if (J.call(s, "key")) {
103
- var a = Object.getOwnPropertyDescriptor(s, "key").get;
104
- if (a && a.isReactWarning) return !1;
105
- }
106
- return s.key !== void 0;
107
- }
108
- function g(s, a) {
109
- function l() {
110
- B || (B = !0, console.error(
111
- "%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)",
112
- a
113
- ));
114
- }
115
- l.isReactWarning = !0, Object.defineProperty(s, "key", {
116
- get: l,
117
- configurable: !0
118
- });
119
- }
120
- function h() {
121
- var s = r(this.type);
122
- return V[s] || (V[s] = !0, console.error(
123
- "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."
124
- )), s = this.props.ref, s !== void 0 ? s : null;
125
- }
126
- function f(s, a, l, m, E, C, L, F) {
127
- return l = C.ref, s = {
128
- $$typeof: N,
129
- type: s,
130
- key: a,
131
- props: C,
132
- _owner: E
133
- }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(s, "ref", {
134
- enumerable: !1,
135
- get: h
136
- }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
137
- configurable: !1,
138
- enumerable: !1,
139
- writable: !0,
140
- value: 0
141
- }), Object.defineProperty(s, "_debugInfo", {
142
- configurable: !1,
143
- enumerable: !1,
144
- writable: !0,
145
- value: null
146
- }), Object.defineProperty(s, "_debugStack", {
147
- configurable: !1,
148
- enumerable: !1,
149
- writable: !0,
150
- value: L
151
- }), Object.defineProperty(s, "_debugTask", {
152
- configurable: !1,
153
- enumerable: !1,
154
- writable: !0,
155
- value: F
156
- }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
157
- }
158
- function w(s, a, l, m, E, C, L, F) {
159
- var p = a.children;
160
- if (p !== void 0)
161
- if (m)
162
- if (ae(p)) {
163
- for (m = 0; m < p.length; m++)
164
- O(p[m]);
165
- Object.freeze && Object.freeze(p);
166
- } else
167
- console.error(
168
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
169
- );
170
- else O(p);
171
- if (J.call(a, "key")) {
172
- p = r(s);
173
- var v = Object.keys(a).filter(function(oe) {
174
- return oe !== "key";
175
- });
176
- m = 0 < v.length ? "{key: someKey, " + v.join(": ..., ") + ": ...}" : "{key: someKey}", H[p + m] || (v = 0 < v.length ? "{" + v.join(": ..., ") + ": ...}" : "{}", console.error(
177
- `A props object containing a "key" prop is being spread into JSX:
178
- let props = %s;
179
- <%s {...props} />
180
- React keys must be passed directly to JSX without using spread:
181
- let props = %s;
182
- <%s key={someKey} {...props} />`,
183
- m,
184
- p,
185
- v,
186
- p
187
- ), H[p + m] = !0);
188
- }
189
- if (p = null, l !== void 0 && (e(l), p = "" + l), d(a) && (e(a.key), p = "" + a.key), "key" in a) {
190
- l = {};
191
- for (var U in a)
192
- U !== "key" && (l[U] = a[U]);
193
- } else l = a;
194
- return p && g(
195
- l,
196
- typeof s == "function" ? s.displayName || s.name || "Unknown" : s
197
- ), f(
198
- s,
199
- p,
200
- C,
201
- E,
202
- o(),
203
- l,
204
- L,
205
- F
206
- );
207
- }
208
- function O(s) {
209
- typeof s == "object" && s !== null && s.$$typeof === N && s._store && (s._store.validated = 1);
210
- }
211
- var k = le, N = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), M = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), W = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), S = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), P = Symbol.for("react.activity"), I = Symbol.for("react.client.reference"), A = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ae = Array.isArray, z = console.createTask ? console.createTask : function() {
212
- return null;
213
- };
214
- k = {
215
- "react-stack-bottom-frame": function(s) {
216
- return s();
217
- }
218
- };
219
- var B, V = {}, G = k["react-stack-bottom-frame"].bind(
220
- k,
221
- c
222
- )(), X = z(n(c)), H = {};
223
- x.Fragment = R, x.jsx = function(s, a, l, m, E) {
224
- var C = 1e4 > A.recentlyCreatedOwnerStacks++;
225
- return w(
226
- s,
227
- a,
228
- l,
229
- !1,
230
- m,
231
- E,
232
- C ? Error("react-stack-top-frame") : G,
233
- C ? z(n(s)) : X
234
- );
235
- }, x.jsxs = function(s, a, l, m, E) {
236
- var C = 1e4 > A.recentlyCreatedOwnerStacks++;
237
- return w(
238
- s,
239
- a,
240
- l,
241
- !0,
242
- m,
243
- E,
244
- C ? Error("react-stack-top-frame") : G,
245
- C ? z(n(s)) : X
246
- );
247
- };
248
- }(), x;
1
+ var p = Object.defineProperty;
2
+ var l = (n, t, s) => t in n ? p(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s;
3
+ var o = (n, t, s) => l(n, typeof t != "symbol" ? t + "" : t, s);
4
+ class c extends Error {
5
+ constructor(s, e) {
6
+ super(`API Error: ${s} - ${e}`);
7
+ o(this, "statusCode");
8
+ o(this, "body");
9
+ this.statusCode = s, this.body = e;
10
+ }
249
11
  }
250
- re.exports = ge();
251
- var Y = re.exports;
252
- function be(r) {
253
- return r.filter((t) => {
254
- var e;
255
- return t.finishReason === "stop" ? t.text !== null && ((e = t.text) == null ? void 0 : e.trim()) !== "" : !0;
256
- });
12
+ class d {
13
+ constructor(t) {
14
+ this.apiKey = t;
15
+ }
16
+ applyHeaders(t) {
17
+ t.set("x-persona-apikey", this.apiKey);
18
+ }
19
+ getCredentials() {
20
+ return this.apiKey;
21
+ }
257
22
  }
258
- function we(r) {
259
- const t = [];
260
- let e = null;
261
- for (const n of r)
262
- n.type === "reasoning" ? (e != null && (t.push(e), e = null), t.push(n)) : n.functionCalls ? (e && t.push(e), t.push(n), e = null) : n.functionResponse ? t[t.length - 1] = {
263
- ...t[t.length - 1],
264
- functionResponse: n.functionResponse
265
- } : e && n.protocol === e.protocol && (e.role === n.role || n.finishReason === "stop") ? e.text += n.text : (e && t.push(e), e = {
266
- ...n
23
+ class a {
24
+ constructor(t, s) {
25
+ o(this, "baseUrl");
26
+ o(this, "authProvider");
27
+ this.baseUrl = t, this.authProvider = typeof s == "string" ? new d(s) : s;
28
+ }
29
+ getBaseUrl() {
30
+ return this.baseUrl;
31
+ }
32
+ getAuthProvider() {
33
+ return this.authProvider;
34
+ }
35
+ buildHeaders() {
36
+ const t = new Headers();
37
+ return t.set("Content-Type", "application/json"), this.authProvider.applyHeaders(t), t;
38
+ }
39
+ buildUrl(t, s) {
40
+ const e = new URL(this.baseUrl + t);
41
+ return s && Object.entries(s).forEach(([r, i]) => {
42
+ i != null && e.searchParams.set(r, String(i));
43
+ }), e.toString();
44
+ }
45
+ async handleResponse(t) {
46
+ if (!t.ok) {
47
+ const e = await t.text();
48
+ throw new c(t.status, e);
49
+ }
50
+ const s = await t.text();
51
+ return s ? JSON.parse(s) : void 0;
52
+ }
53
+ async httpGet(t, s) {
54
+ const e = await fetch(this.buildUrl(t, s), {
55
+ method: "GET",
56
+ headers: this.buildHeaders()
57
+ });
58
+ return this.handleResponse(e);
59
+ }
60
+ async httpPost(t, s) {
61
+ const e = await fetch(this.baseUrl + t, {
62
+ method: "POST",
63
+ headers: this.buildHeaders(),
64
+ body: s ? JSON.stringify(s) : void 0
65
+ });
66
+ return this.handleResponse(e);
67
+ }
68
+ async httpPut(t, s) {
69
+ const e = await fetch(this.baseUrl + t, {
70
+ method: "PUT",
71
+ headers: this.buildHeaders(),
72
+ body: JSON.stringify(s)
73
+ });
74
+ return this.handleResponse(e);
75
+ }
76
+ async httpPatch(t, s) {
77
+ const e = await fetch(this.baseUrl + t, {
78
+ method: "PATCH",
79
+ headers: this.buildHeaders(),
80
+ body: JSON.stringify(s)
81
+ });
82
+ return this.handleResponse(e);
83
+ }
84
+ async httpDelete(t) {
85
+ const s = await fetch(this.baseUrl + t, {
86
+ method: "DELETE",
87
+ headers: this.buildHeaders()
267
88
  });
268
- return e && t.push(e), be(t);
89
+ if (!s.ok) {
90
+ const e = await s.text();
91
+ throw new c(s.status, e);
92
+ }
93
+ }
269
94
  }
270
- function ye(r) {
271
- var t;
272
- return r.role === "function" ? {
273
- id: r.id,
274
- role: "assistant",
275
- status: (r == null ? void 0 : r.functionResponse) === null ? { type: "running" } : { type: "complete", reason: "stop" },
276
- content: ((t = r.functionCalls) == null ? void 0 : t.map((e) => {
277
- var n;
278
- return {
279
- type: "tool-call",
280
- toolName: e.name,
281
- toolCallId: e.id,
282
- args: e.args,
283
- result: (n = r.functionResponse) == null ? void 0 : n.result
284
- };
285
- })) ?? []
286
- } : {
287
- id: r.id,
288
- role: r.role,
289
- content: r.type === "reasoning" ? [{ type: "reasoning", text: r.text }] : [{ type: "text", text: r.text }]
290
- };
95
+ class y extends a {
96
+ constructor(t, s) {
97
+ super(t, s);
98
+ }
99
+ async list(t, s, e) {
100
+ const r = { page: s, size: e };
101
+ return t && (r.keyword = t), this.httpGet("/projects", r);
102
+ }
103
+ async get(t) {
104
+ return this.httpGet("/projects/" + t);
105
+ }
106
+ async getMine() {
107
+ return this.httpGet("/projects/mine");
108
+ }
109
+ async create(t) {
110
+ return this.httpPost("/projects", t);
111
+ }
112
+ async update(t) {
113
+ return this.httpPut("/projects/" + t.projectId, t);
114
+ }
115
+ async remove(t) {
116
+ await this.httpDelete("/projects/" + t);
117
+ }
118
+ async getSubscription(t) {
119
+ return this.httpGet("/projects/" + t + "/subscription");
120
+ }
121
+ async changeSubscriptionPlan(t, s) {
122
+ return this.httpPost("/projects/" + t + "/subscription/plan", s);
123
+ }
124
+ async addSubscriptionCredits(t, s) {
125
+ return this.httpPost("/projects/" + t + "/subscription/credits", s);
126
+ }
291
127
  }
292
- class K {
293
- constructor() {
294
- i(this, "statusChangeCallbacks", []);
295
- i(this, "messageCallbacks", []);
128
+ class g extends a {
129
+ constructor(t, s) {
130
+ super(t, s);
296
131
  }
297
- addStatusChangeListener(t) {
298
- this.statusChangeCallbacks.push(t);
132
+ async list(t, s, e) {
133
+ const r = { page: s, size: e };
134
+ return t && (r.keyword = t), this.httpGet("/agents", r);
299
135
  }
300
- addMessageListener(t) {
301
- this.messageCallbacks.push(t);
136
+ async get(t) {
137
+ return this.httpGet("/agents/" + t);
302
138
  }
303
- async syncSession(t) {
304
- this.session = t;
139
+ async create(t) {
140
+ return this.httpPost("/agents", t);
305
141
  }
306
- async notifyMessage(t) {
307
- this.messageCallbacks.forEach((e) => e(t));
142
+ async update(t) {
143
+ return this.httpPut("/agents/" + t.id, t);
308
144
  }
309
- async notifyMessages(t) {
310
- t.forEach((e) => {
311
- this.messageCallbacks.forEach((n) => n(e));
312
- });
145
+ async remove(t) {
146
+ await this.httpDelete("/agents/" + t);
147
+ }
148
+ async getSynthesizerSupportedVoices(t) {
149
+ return this.httpGet("/values/synthesizers/" + t + "/voices");
313
150
  }
314
- async setSession(t) {
315
- this.session = t;
151
+ async listRevisions(t) {
152
+ return this.httpGet("/agents/" + t + "/revisions");
316
153
  }
317
- async setStatus(t) {
318
- const e = this.status !== t;
319
- this.status = t, e && this.statusChangeCallbacks.forEach((n) => n(t));
154
+ async getRevision(t, s) {
155
+ return this.httpGet("/agents/" + t + "/revisions/" + s);
320
156
  }
321
- clearListeners() {
322
- this.statusChangeCallbacks = [], this.messageCallbacks = [];
157
+ async rollback(t, s) {
158
+ return this.httpPost("/agents/" + t + "/revisions/" + s + "/rollback", {});
323
159
  }
324
160
  }
325
- class ee extends K {
326
- constructor(e) {
327
- super();
328
- i(this, "status");
329
- i(this, "autostart");
330
- i(this, "session");
331
- i(this, "config");
332
- i(this, "notify", !0);
333
- this.config = e, this.status = "disconnected", this.autostart = !0;
334
- }
335
- getName() {
336
- return "rest";
337
- }
338
- getPriority() {
339
- return 0;
340
- }
341
- async connect(e) {
342
- return this.setStatus("connected"), e;
343
- }
344
- async disconnect() {
345
- this.setStatus("disconnected"), this.session = null;
346
- }
347
- async syncSession(e) {
348
- this.session = e;
349
- }
350
- async send(e) {
351
- const { apiUrl: n, apiKey: o, agentId: c } = this.config, d = this.session ?? "new", g = e, f = await (await fetch(`${n}/agents/${c}/sessions/${d}/messages`, {
352
- body: JSON.stringify({ userMessage: g }),
353
- method: "POST",
354
- headers: {
355
- "Content-Type": "application/json",
356
- "x-fox-apikey": o,
357
- "x-persona-apikey": o
358
- }
359
- })).json();
360
- this.notifyMessages(f.response.messages);
161
+ class w extends a {
162
+ constructor(s, e, r) {
163
+ super(s, e);
164
+ o(this, "knowledgeBaseId");
165
+ this.knowledgeBaseId = r;
166
+ }
167
+ async list(s, e, r) {
168
+ const i = { page: e, size: r };
169
+ return s && (i.keyword = s), this.httpGet("/knowledge-bases/" + this.knowledgeBaseId + "/documents", i);
170
+ }
171
+ async upload(s) {
172
+ return this.httpPost("/knowledge-bases/" + this.knowledgeBaseId + "/documents", s);
173
+ }
174
+ async get(s) {
175
+ return this.httpGet("/knowledge-bases/" + this.knowledgeBaseId + "/documents/" + s);
176
+ }
177
+ async reprocess(s) {
178
+ return this.httpPost("/knowledge-bases/" + this.knowledgeBaseId + "/documents", { document_id: s });
179
+ }
180
+ async remove(s) {
181
+ await this.httpDelete("/knowledge-bases/" + this.knowledgeBaseId + "/documents/" + s);
361
182
  }
362
183
  }
363
- class te extends K {
364
- constructor(e) {
365
- super();
366
- i(this, "status");
367
- i(this, "autostart");
368
- i(this, "session");
369
- i(this, "config");
370
- i(this, "webSocket");
371
- this.config = e, this.status = "disconnected", this.autostart = !0, this.session = null, this.webSocket = null;
372
- }
373
- getName() {
374
- return "websocket";
375
- }
376
- getPriority() {
377
- return 1;
378
- }
379
- async syncSession(e) {
380
- var n;
381
- (n = this.config.logger) == null || n.debug("Syncing session with WebSocket protocol:", e), this.session = e, this.webSocket && this.status === "connected" && (this.disconnect(), this.connect(e));
382
- }
383
- connect(e) {
384
- var g;
385
- if (this.webSocket !== null && this.status === "connected")
386
- return Promise.resolve(this.session);
387
- const n = e || this.session || "new";
388
- (g = this.config.logger) == null || g.debug("Connecting to WebSocket with sessionId:", n);
389
- const o = encodeURIComponent(this.config.apiKey), c = this.config.agentId, d = `${this.config.webSocketUrl}?sessionCode=${n}&agentId=${c}&apiKey=${o}`;
390
- return this.setStatus("connecting"), this.webSocket = new WebSocket(d), this.webSocket.addEventListener("open", () => {
391
- this.setStatus("connected");
392
- }), this.webSocket.addEventListener("message", (h) => {
393
- const f = JSON.parse(h.data);
394
- if (f.type !== "message")
395
- return;
396
- const w = f.payload;
397
- this.notifyMessage(w != null && w.thought ? { role: "assistant", type: "reasoning", text: w.thought } : w);
398
- }), this.webSocket.addEventListener("close", () => {
399
- var h;
400
- this.setStatus("disconnected"), this.webSocket = null, (h = this.config.logger) == null || h.warn("WebSocket connection closed");
401
- }), this.webSocket.addEventListener("error", (h) => {
402
- var f;
403
- this.setStatus("disconnected"), this.webSocket = null, (f = this.config.logger) == null || f.error("WebSocket error", h);
404
- }), Promise.resolve(n);
405
- }
406
- disconnect() {
407
- var e;
408
- return (e = this.config.logger) == null || e.debug("Disconnecting WebSocket"), this.webSocket && this.status === "connected" && (this.webSocket.close(), this.setStatus("disconnected"), this.webSocket = null), Promise.resolve();
409
- }
410
- send(e) {
411
- 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"));
184
+ class m extends a {
185
+ constructor(t, s) {
186
+ super(t, s);
187
+ }
188
+ async list(t, s, e) {
189
+ const r = { page: s, size: e };
190
+ return t && (r.keyword = t), this.httpGet("/knowledge-bases", r);
191
+ }
192
+ async get(t) {
193
+ return this.httpGet("/knowledge-bases/" + t);
194
+ }
195
+ async create(t) {
196
+ return this.httpPost("/knowledge-bases", t);
197
+ }
198
+ async update(t) {
199
+ return this.httpPut("/knowledge-bases/" + t.id, t);
200
+ }
201
+ async remove(t) {
202
+ await this.httpDelete("/knowledge-bases/" + t);
203
+ }
204
+ documents(t) {
205
+ return new w(this.getBaseUrl(), this.getAuthProvider(), t);
206
+ }
207
+ async searchChunks(t, s) {
208
+ return this.httpPost("/knowledge-bases/" + t + "/search", s);
412
209
  }
413
210
  }
414
- class Se {
415
- constructor(t) {
416
- i(this, "config");
417
- i(this, "pc", null);
418
- i(this, "ws", null);
419
- i(this, "localStream", null);
420
- i(this, "remoteStream", new MediaStream());
421
- i(this, "audioCtx", null);
422
- i(this, "localAnalyser", null);
423
- i(this, "remoteAnalyser", null);
424
- i(this, "analyzerFrame", null);
425
- i(this, "dataChannel", null);
426
- i(this, "isConnected", !1);
427
- i(this, "visualizerCallbacks", []);
428
- i(this, "messageCallbacks", []);
429
- this.config = t;
430
- }
431
- async connect(t) {
432
- var e;
433
- if (!this.isConnected) {
434
- this.isConnected = !0;
435
- try {
436
- this.localStream = await navigator.mediaDevices.getUserMedia({ audio: !0 });
437
- } catch (n) {
438
- (e = this.config.logger) == null || e.error("Error accessing microphone:", n);
439
- return;
440
- }
441
- this.pc = new RTCPeerConnection({
442
- iceServers: this.config.iceServers || [
443
- {
444
- urls: "stun:34.38.108.251:3478"
445
- },
446
- {
447
- urls: "turn:34.38.108.251:3478",
448
- username: "webrtc",
449
- credential: "webrtc"
450
- }
451
- ]
452
- }), this.localStream.getTracks().forEach((n) => {
453
- this.pc.addTrack(n, this.localStream);
454
- }), this.pc.ontrack = (n) => {
455
- n.streams[0].getTracks().forEach((c) => {
456
- this.remoteStream.addTrack(c);
457
- }), this.audioCtx || this._startAnalyzers();
458
- const o = new Audio();
459
- o.srcObject = this.remoteStream, o.play().catch((c) => {
460
- var d;
461
- (d = this.config.logger) == null || d.error("Error playing remote audio:", c);
462
- });
463
- }, this.pc.onicecandidate = (n) => {
464
- var o;
465
- n.candidate && ((o = this.ws) == null ? void 0 : o.readyState) === WebSocket.OPEN && this.ws.send(
466
- JSON.stringify({
467
- type: "CANDIDATE",
468
- src: "client",
469
- payload: { candidate: n.candidate }
470
- })
471
- );
472
- }, this.pc.ondatachannel = (n) => {
473
- const o = n.channel;
474
- o.onmessage = (c) => {
475
- this.messageCallbacks.forEach((d) => {
476
- d(c);
477
- });
478
- };
479
- }, this.ws = new WebSocket(this.config.webrtcUrl || "wss://persona.applica.guru/api/webrtc"), this.ws.onopen = async () => {
480
- var d, g;
481
- const n = await this.pc.createOffer();
482
- await this.pc.setLocalDescription(n);
483
- const o = {
484
- agentId: this.config.agentId,
485
- sessionCode: t
486
- };
487
- (d = this.config.logger) == null || d.debug("Opening connection to WebRTC server: ", o);
488
- const c = {
489
- type: "OFFER",
490
- src: ((g = crypto.randomUUID) == null ? void 0 : g.call(crypto)) || "client_" + Date.now(),
491
- payload: {
492
- sdp: {
493
- sdp: n.sdp,
494
- type: n.type
495
- },
496
- connectionId: (Date.now() % 1e6).toString(),
497
- metadata: o
498
- }
499
- };
500
- this.ws.send(JSON.stringify(c));
501
- }, this.ws.onmessage = async (n) => {
502
- var c;
503
- const o = JSON.parse(n.data);
504
- if (o.type === "ANSWER")
505
- await this.pc.setRemoteDescription(new RTCSessionDescription(o.payload.sdp));
506
- else if (o.type === "CANDIDATE")
507
- try {
508
- await this.pc.addIceCandidate(new RTCIceCandidate(o.payload.candidate));
509
- } catch (d) {
510
- (c = this.config.logger) == null || c.error("Error adding ICE candidate:", d);
511
- }
512
- }, this.ws.onclose = () => {
513
- this._stopAnalyzers();
514
- };
515
- }
211
+ class b extends a {
212
+ constructor(t, s) {
213
+ super(t, s);
516
214
  }
517
- async disconnect() {
518
- var t;
519
- this.isConnected && (this.isConnected = !1, ((t = this.ws) == null ? void 0 : t.readyState) === WebSocket.OPEN && this.ws.close(), this.pc && this.pc.close(), this.localStream && this.localStream.getTracks().forEach((e) => e.stop()), this.remoteStream = new MediaStream(), this.audioCtx && (await this.audioCtx.close(), this.audioCtx = null), this._stopAnalyzers());
215
+ async list(t, s, e) {
216
+ const r = { page: s, size: e };
217
+ return this.httpGet("/workflows/" + t + "/executions", r);
520
218
  }
521
- addVisualizerCallback(t) {
522
- this.visualizerCallbacks.push(t);
219
+ async get(t, s) {
220
+ return this.httpGet("/workflows/" + t + "/executions/" + s);
523
221
  }
524
- addMessageCallback(t) {
525
- this.messageCallbacks.push(t);
222
+ async run(t, s) {
223
+ return this.httpPost("/workflows/" + t + "/executions", s);
526
224
  }
527
- createDataChannel(t = "messages") {
528
- this.pc && (this.dataChannel = this.pc.createDataChannel(t), this.dataChannel.onopen = () => {
529
- var e;
530
- return (e = this.config.logger) == null ? void 0 : e.info("Data channel opened");
531
- }, this.dataChannel.onmessage = (e) => {
532
- this.messageCallbacks.forEach((n) => {
533
- n(e);
534
- });
535
- });
225
+ async queue(t, s) {
226
+ return this.httpPost("/workflows/" + t + "/executions/queue", s);
536
227
  }
537
- sendMessage(t) {
538
- var e, n;
539
- if (!this.dataChannel) {
540
- (e = this.config.logger) == null || e.warn("Data channel is not open, cannot send message");
541
- return;
542
- }
543
- this.dataChannel.send(t), (n = this.config.logger) == null || n.info("Sent message:", t);
544
- }
545
- _startAnalyzers() {
546
- if (!this.localStream || !this.remoteStream || this.visualizerCallbacks.length === 0)
547
- return;
548
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
549
- const t = this.audioCtx.createMediaStreamSource(this.localStream), e = this.audioCtx.createMediaStreamSource(this.remoteStream);
550
- this.localAnalyser = this.audioCtx.createAnalyser(), this.remoteAnalyser = this.audioCtx.createAnalyser(), this.localAnalyser.fftSize = 256, this.remoteAnalyser.fftSize = 256, t.connect(this.localAnalyser), e.connect(this.remoteAnalyser);
551
- const n = () => {
552
- if (!this.localAnalyser || !this.remoteAnalyser || this.visualizerCallbacks.length === 0)
553
- return;
554
- const o = new Uint8Array(this.localAnalyser.frequencyBinCount), c = new Uint8Array(this.remoteAnalyser.frequencyBinCount);
555
- this.localAnalyser.getByteFrequencyData(o), this.remoteAnalyser.getByteFrequencyData(c);
556
- const d = o.reduce((h, f) => h + f, 0) / o.length, g = c.reduce((h, f) => h + f, 0) / c.length;
557
- this.visualizerCallbacks.length > 0 && this.visualizerCallbacks.forEach((h) => {
558
- h({
559
- localAmplitude: d,
560
- remoteAmplitude: g
561
- });
562
- }), this.analyzerFrame = requestAnimationFrame(n);
563
- };
564
- this.analyzerFrame = requestAnimationFrame(n);
565
- }
566
- _stopAnalyzers() {
567
- this.analyzerFrame && (cancelAnimationFrame(this.analyzerFrame), this.analyzerFrame = null), this.localAnalyser = null, this.remoteAnalyser = null;
228
+ }
229
+ class P extends a {
230
+ constructor(t, s) {
231
+ super(t, s);
232
+ }
233
+ async list(t, s, e) {
234
+ const r = { page: s, size: e };
235
+ return t && (r.keyword = t), this.httpGet("/workflows", r);
236
+ }
237
+ async create(t) {
238
+ return this.httpPost("/workflows", t);
239
+ }
240
+ async update(t, s) {
241
+ return s.id = t, this.httpPut("/workflows/" + t, s);
242
+ }
243
+ async remove(t) {
244
+ await this.httpDelete("/workflows/" + t);
245
+ }
246
+ async get(t) {
247
+ return this.httpGet("/workflows/" + t);
248
+ }
249
+ executions() {
250
+ return new b(this.getBaseUrl(), this.getAuthProvider());
251
+ }
252
+ async listRevisions(t) {
253
+ return this.httpGet("/workflows/" + t + "/revisions");
254
+ }
255
+ async getRevision(t, s) {
256
+ return this.httpGet("/workflows/" + t + "/revisions/" + s);
257
+ }
258
+ async rollback(t, s) {
259
+ return this.httpPost("/workflows/" + t + "/revisions/" + s + "/rollback", {});
568
260
  }
569
261
  }
570
- class se extends K {
571
- constructor(e) {
572
- super();
573
- i(this, "status");
574
- i(this, "session");
575
- i(this, "autostart");
576
- i(this, "config");
577
- i(this, "webRTCClient");
578
- 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) => {
579
- var c;
580
- (c = e.logger) == null || c.debug("Received data message:", n.data);
581
- const o = JSON.parse(n.data);
582
- o.type === "message" && this.notifyMessage(o.payload);
583
- });
262
+ class f extends a {
263
+ constructor(t, s) {
264
+ super(t, s);
584
265
  }
585
- getName() {
586
- return "webrtc";
266
+ async authorize(t, s) {
267
+ return this.httpPost("/credentials/" + t + "/authorize", s);
587
268
  }
588
- getPriority() {
589
- return 10;
269
+ async handleOAuth2Callback(t, s, e, r) {
270
+ const i = { code: s, state: e };
271
+ return r && (i.scope = r), this.httpGet("/credentials/" + t + "/oauth2/callback", i);
590
272
  }
591
- async syncSession(e) {
592
- super.syncSession(e), this.status === "connected" && (await this.disconnect(), await this.connect(e));
273
+ async list() {
274
+ return this.httpGet("/credentials");
593
275
  }
594
- async connect(e) {
595
- var n;
596
- return this.status === "connected" ? Promise.resolve(this.session) : (this.session = e || 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);
276
+ async getByProvider(t) {
277
+ return this.httpGet("/credentials/" + t);
597
278
  }
598
- async disconnect() {
599
- var e, n, o;
600
- if (this.status === "disconnected")
601
- return (e = this.config.logger) == null || e.warn("Already disconnected"), Promise.resolve();
602
- await this.webRTCClient.disconnect(), this.setStatus("disconnected"), (o = (n = this.config) == null ? void 0 : n.logger) == null || o.debug("Disconnected from WebRTC");
279
+ async getById(t) {
280
+ return this.httpGet("/credentials/all/" + t);
603
281
  }
604
- send(e) {
605
- return this.status !== "connected" ? Promise.reject(new Error("Not connected")) : (this.webRTCClient.sendMessage(e), Promise.resolve());
282
+ async remove(t) {
283
+ await this.httpDelete("/credentials/all/" + t);
606
284
  }
607
285
  }
608
- const q = ue(void 0);
609
- function Ce({
610
- dev: r = !1,
611
- protocols: t,
612
- logger: e,
613
- children: n,
614
- session: o = "new",
615
- ...c
616
- }) {
617
- const [d, g] = j(!1), [h, f] = j([]), [w, O] = j(o), [k, N] = j(/* @__PURE__ */ new Map()), _ = de(!1), R = he(() => {
618
- if (Array.isArray(t))
619
- return t;
620
- if (typeof t == "object" && t !== null) {
621
- const u = r ? "localhost:8000" : "persona.applica.guru/api", y = r ? "http" : "https", S = r ? "ws" : "wss";
622
- return Object.keys(t).map((b) => {
623
- switch (b) {
624
- case "rest":
625
- const P = t[b];
626
- return P === !0 ? new ee({
627
- apiUrl: `${y}://${u}`,
628
- apiKey: c.apiKey,
629
- agentId: c.agentId,
630
- logger: e
631
- }) : new ee(P);
632
- case "webrtc":
633
- const I = t[b];
634
- return I === !0 ? new se({
635
- webrtcUrl: `${S}://${u}/webrtc`,
636
- apiKey: c.apiKey,
637
- agentId: c.agentId,
638
- logger: e
639
- }) : new se(I);
640
- case "websocket":
641
- const A = t[b];
642
- return A === !0 ? new te({
643
- webSocketUrl: `${S}://${u}/websocket`,
644
- apiKey: c.apiKey,
645
- agentId: c.agentId,
646
- logger: e
647
- }) : new te(A);
648
- default:
649
- throw new Error(`Unknown protocol: ${b}`);
650
- }
651
- });
652
- }
653
- throw new Error("Invalid protocols configuration");
654
- }, []);
655
- fe(() => {
656
- _.current || (_.current = !0, e == null || e.debug(
657
- "Initializing protocols: ",
658
- R.map((u) => u.getName())
659
- ), R.forEach((u) => {
660
- u.setSession(w), u.clearListeners(), u.addStatusChangeListener((y) => {
661
- e == null || e.debug(`${u.getName()} has notified new status: ${y}`), k.set(u.getName(), y), N(new Map(k));
662
- }), u.addMessageListener((y) => {
663
- f((S) => we([...S, { ...y, protocol: u.getName() }]));
664
- }), u.autostart && u.status === "disconnected" && (e == null || e.debug(`Connecting to protocol: ${u.getName()}`), u.connect(w));
665
- }));
666
- }, [w, R, e, k]);
667
- const $ = async (u) => {
668
- var T;
669
- if (((T = u.content[0]) == null ? void 0 : T.type) !== "text") throw new Error("Only text messages are supported");
670
- const y = u.content[0].text;
671
- f((b) => [...b, { role: "user", type: "text", text: y }]), g(!0);
672
- const S = R.sort((b, P) => P.getPriority() - b.getPriority()).find((b) => b.status === "connected");
673
- await (S == null ? void 0 : S.send(y)), g(!1);
674
- }, M = Z(() => (g(!1), f([]), O("new"), Promise.resolve()), []), D = Z(() => Promise.resolve(), []), W = me({
675
- isRunning: d,
676
- messages: h,
677
- convertMessage: ye,
678
- onNew: $,
679
- onCancel: M,
680
- onReload: D
681
- });
682
- return /* @__PURE__ */ Y.jsx(q.Provider, { value: { protocols: R, protocolsStatus: k }, children: /* @__PURE__ */ Y.jsx(pe, { runtime: W, children: n }) });
286
+ class k extends a {
287
+ constructor(t, s) {
288
+ super(t, s);
289
+ }
290
+ async list(t, s, e) {
291
+ const r = { page: s, size: e };
292
+ return t && (r.keyword = t), this.httpGet("/features/templates", r);
293
+ }
294
+ async get(t) {
295
+ return this.httpGet("/features/templates/" + t);
296
+ }
297
+ async create(t) {
298
+ return this.httpPost("/features/templates", t);
299
+ }
300
+ async update(t, s) {
301
+ return this.httpPut("/features/templates/" + t, s);
302
+ }
303
+ async patch(t, s) {
304
+ return this.httpPatch("/features/templates/" + t, s);
305
+ }
306
+ async remove(t) {
307
+ await this.httpDelete("/features/templates/" + t);
308
+ }
309
+ async getMcpAvailableTools(t) {
310
+ return this.httpPost("/features/templates/mcp/available-tools", t);
311
+ }
683
312
  }
684
- function Ae({ children: r, ...t }) {
685
- return /* @__PURE__ */ Y.jsx(Ce, { ...t, children: r });
313
+ class v {
314
+ constructor(t, s) {
315
+ o(this, "baseUrl");
316
+ o(this, "auth");
317
+ this.baseUrl = t, this.auth = s;
318
+ }
319
+ templates() {
320
+ return new k(this.baseUrl, this.auth);
321
+ }
686
322
  }
687
- function ve() {
688
- const r = ne(q);
689
- if (!r)
690
- throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");
691
- return r;
323
+ class G extends a {
324
+ constructor(t, s) {
325
+ super(t, s);
326
+ }
327
+ async list(t, s, e) {
328
+ const r = { page: s, size: e };
329
+ return this.httpGet("/triggers/" + t + "/executions", r);
330
+ }
331
+ async execute(t, s) {
332
+ return this.httpPost("/triggers/" + t + "/executions", s);
333
+ }
334
+ async get(t) {
335
+ return this.httpGet("/triggers/executions/" + t);
336
+ }
337
+ async remove(t) {
338
+ await this.httpDelete("/triggers/executions/" + t);
339
+ }
692
340
  }
693
- function ke(r) {
694
- const t = ne(q);
695
- if (!t)
696
- throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");
697
- const e = t.protocols.find((o) => o.getName() === r);
698
- if (!e)
699
- return null;
700
- const n = t.protocolsStatus.get(e.getName());
701
- return {
702
- ...e,
703
- connect: e.connect.bind(e),
704
- disconnect: e.disconnect.bind(e),
705
- send: e.send.bind(e),
706
- setSession: e.setSession.bind(e),
707
- addStatusChangeListener: e.addStatusChangeListener.bind(e),
708
- addMessageListener: e.addMessageListener.bind(e),
709
- getName: e.getName.bind(e),
710
- getPriority: e.getPriority.bind(e),
711
- status: n || e.status
712
- };
341
+ class x extends a {
342
+ constructor(t, s) {
343
+ super(t, s);
344
+ }
345
+ async list(t, s, e) {
346
+ const r = { page: s, size: e };
347
+ return t && (r.keyword = t), this.httpGet("/triggers", r);
348
+ }
349
+ async create(t) {
350
+ return this.httpPost("/triggers", t);
351
+ }
352
+ async update(t, s) {
353
+ return this.httpPut("/triggers/" + t, s);
354
+ }
355
+ async remove(t) {
356
+ await this.httpDelete("/triggers/" + t);
357
+ }
358
+ async get(t) {
359
+ return this.httpGet("/triggers/" + t);
360
+ }
361
+ executions() {
362
+ return new G(this.getBaseUrl(), this.getAuthProvider());
363
+ }
713
364
  }
714
- function Te() {
715
- return ke("webrtc");
365
+ class U extends a {
366
+ constructor(t, s) {
367
+ super(t, s);
368
+ }
369
+ async list(t, s, e) {
370
+ const r = { page: s, size: e };
371
+ return t && (r.keyword = t), this.httpGet("/service-prices", r);
372
+ }
373
+ async get(t) {
374
+ return this.httpGet("/service-prices/" + t);
375
+ }
376
+ async create(t) {
377
+ return this.httpPost("/service-prices", t);
378
+ }
379
+ async update(t, s) {
380
+ return this.httpPut("/service-prices/" + t, s);
381
+ }
382
+ async remove(t) {
383
+ await this.httpDelete("/service-prices/" + t);
384
+ }
716
385
  }
717
- class xe {
718
- constructor() {
719
- i(this, "prefix", "[Persona]");
386
+ class A extends a {
387
+ constructor(t, s) {
388
+ super(t, s);
720
389
  }
721
- log(t, ...e) {
722
- console.log(`${this.prefix} - ${t}`, ...e);
390
+ async list(t, s, e, r, i, u) {
391
+ const h = { page: i, size: u };
392
+ return t && (h.keyword = t), s && (h.status = s), e && (h.agentId = e), r && (h.userId = r), this.httpGet("/sessions", h);
723
393
  }
724
- info(t, ...e) {
725
- console.info(`${this.prefix} - ${t}`, ...e);
394
+ async get(t) {
395
+ return this.httpGet("/sessions/" + t);
726
396
  }
727
- warn(t, ...e) {
728
- console.warn(`${this.prefix} - ${t}`, ...e);
397
+ async getUsage(t) {
398
+ return this.httpGet("/sessions/" + t + "/usage");
399
+ }
400
+ async generateMessage(t, s) {
401
+ return this.httpPost("/sessions/" + t + "/messages", s);
402
+ }
403
+ async findMessages(t, s, e) {
404
+ const r = {};
405
+ return s !== void 0 && (r.page = s), e !== void 0 && (r.size = e), this.httpGet("/sessions/" + t + "/messages", r);
406
+ }
407
+ async remove(t) {
408
+ await this.httpDelete("/sessions/" + t);
409
+ }
410
+ }
411
+ class B extends a {
412
+ constructor(t, s) {
413
+ super(t, s);
414
+ }
415
+ async list(t, s, e, r) {
416
+ const i = { page: e, size: r };
417
+ return t && (i.projectId = t), s && (i.status = s), this.httpGet("/missions", i);
418
+ }
419
+ async get(t) {
420
+ return this.httpGet("/missions/" + t);
421
+ }
422
+ async create(t) {
423
+ return this.httpPost("/missions", t);
424
+ }
425
+ async update(t, s) {
426
+ return this.httpPut("/missions/" + t, s);
427
+ }
428
+ async remove(t) {
429
+ await this.httpDelete("/missions/" + t);
430
+ }
431
+ async generate(t) {
432
+ return this.httpPost("/missions/" + t + "/generate");
433
+ }
434
+ async execute(t) {
435
+ return this.httpPost("/missions/" + t + "/execute");
436
+ }
437
+ async retry(t) {
438
+ return this.httpPost("/missions/" + t + "/retry");
439
+ }
440
+ async replan(t) {
441
+ return this.httpPost("/missions/" + t + "/replan");
442
+ }
443
+ async sendInstruction(t, s) {
444
+ return this.httpPost("/missions/" + t + "/instructions", { instruction: s });
445
+ }
446
+ async stop(t) {
447
+ return this.httpPost("/missions/" + t + "/stop");
448
+ }
449
+ async resume(t) {
450
+ return this.httpPost("/missions/" + t + "/continue");
451
+ }
452
+ }
453
+ class S {
454
+ constructor(t, s) {
455
+ o(this, "baseUrl");
456
+ o(this, "workflowsBaseUrl");
457
+ this.baseUrl = t, this.workflowsBaseUrl = s;
458
+ }
459
+ projects(t) {
460
+ return new y(this.baseUrl, t);
461
+ }
462
+ agents(t) {
463
+ return new g(this.baseUrl, t);
464
+ }
465
+ knowledgeBases(t) {
466
+ return new m(this.baseUrl, t);
467
+ }
468
+ workflows(t) {
469
+ return new P(this.workflowsBaseUrl, t);
470
+ }
471
+ credentials(t) {
472
+ return new f(this.baseUrl, t);
473
+ }
474
+ features(t) {
475
+ return new v(this.baseUrl, t);
476
+ }
477
+ triggers(t) {
478
+ return new x(this.baseUrl, t);
479
+ }
480
+ servicePrices(t) {
481
+ return new U(this.baseUrl, t);
482
+ }
483
+ sessions(t) {
484
+ return new A(this.baseUrl, t);
485
+ }
486
+ missions(t) {
487
+ return new B(this.baseUrl, t);
488
+ }
489
+ }
490
+ class j {
491
+ constructor(t) {
492
+ this.token = t;
729
493
  }
730
- error(t, ...e) {
731
- console.error(`${this.prefix} - ${t}`, ...e);
494
+ applyHeaders(t) {
495
+ t.set("Authorization", `Bearer ${this.token}`);
732
496
  }
733
- debug(t, ...e) {
734
- console.debug(`${this.prefix} - ${t}`, ...e);
497
+ getCredentials() {
498
+ return this.token;
735
499
  }
736
500
  }
737
501
  export {
738
- xe as PersonaConsoleLogger,
739
- K as PersonaProtocolBase,
740
- ee as PersonaRESTProtocol,
741
- Ae as PersonaRuntimeProvider,
742
- se as PersonaWebRTCProtocol,
743
- te as PersonaWebSocketProtocol,
744
- ve as usePersonaRuntime,
745
- ke as usePersonaRuntimeProtocol,
746
- Te as usePersonaRuntimeWebRTCProtocol
502
+ g as AgentsApi,
503
+ c as ApiException,
504
+ d as ApiKeyAuthenticationProvider,
505
+ j as BearerTokenAuthenticationProvider,
506
+ f as CredentialsApi,
507
+ k as FeatureTemplatesApi,
508
+ v as FeaturesApi,
509
+ w as KnowledgeBaseDocumentsApi,
510
+ m as KnowledgeBasesApi,
511
+ B as MissionsApi,
512
+ S as PersonaSdk,
513
+ y as ProjectsApi,
514
+ U as ServicePricesApi,
515
+ A as SessionsApi,
516
+ G as TriggerExecutionsApi,
517
+ x as TriggersApi,
518
+ b as WorkflowExecutionsApi,
519
+ P as WorkflowsApi
747
520
  };
748
521
  //# sourceMappingURL=bundle.es.js.map