@applica-software-guru/persona-sdk 0.1.114 → 0.1.115

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,15 +1,15 @@
1
- var g = Object.defineProperty;
2
- var y = (o, t, e) => t in o ? g(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var u = (o, t, e) => y(o, typeof t != "symbol" ? t + "" : t, e);
1
+ var m = Object.defineProperty;
2
+ var P = (o, t, e) => t in o ? m(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var h = (o, t, e) => P(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  class l extends Error {
5
5
  constructor(e, s) {
6
6
  super(`API Error: ${e} - ${s}`);
7
- u(this, "statusCode");
8
- u(this, "body");
7
+ h(this, "statusCode");
8
+ h(this, "body");
9
9
  this.statusCode = e, this.body = s;
10
10
  }
11
11
  }
12
- class m {
12
+ class w {
13
13
  constructor(t) {
14
14
  this.apiKey = t;
15
15
  }
@@ -22,9 +22,9 @@ class m {
22
22
  }
23
23
  class c {
24
24
  constructor(t, e) {
25
- u(this, "baseUrl");
26
- u(this, "authProvider");
27
- this.baseUrl = t, this.authProvider = typeof e == "string" ? new m(e) : e;
25
+ h(this, "baseUrl");
26
+ h(this, "authProvider");
27
+ this.baseUrl = t, this.authProvider = typeof e == "string" ? new w(e) : e;
28
28
  }
29
29
  getBaseUrl() {
30
30
  return this.baseUrl;
@@ -98,10 +98,10 @@ class c {
98
98
  }
99
99
  }
100
100
  }
101
- class w extends c {
101
+ class f extends c {
102
102
  constructor(e, s, r) {
103
103
  super(e, s);
104
- u(this, "billingBaseUrl");
104
+ h(this, "billingBaseUrl");
105
105
  this.billingBaseUrl = (r || e).replace(/\/$/, "");
106
106
  }
107
107
  async list(e, s, r) {
@@ -147,14 +147,14 @@ class w extends c {
147
147
  body: r ? JSON.stringify(r) : void 0
148
148
  });
149
149
  if (!a.ok) {
150
- const h = await a.text();
151
- throw new l(a.status, h);
150
+ const p = await a.text();
151
+ throw new l(a.status, p);
152
152
  }
153
153
  const i = await a.text();
154
154
  return i ? JSON.parse(i) : void 0;
155
155
  }
156
156
  }
157
- class P extends c {
157
+ class b extends c {
158
158
  constructor(t, e) {
159
159
  super(t, e);
160
160
  }
@@ -194,10 +194,10 @@ class P extends c {
194
194
  return this.httpGet("/agents/architect");
195
195
  }
196
196
  }
197
- class b extends c {
197
+ class v extends c {
198
198
  constructor(e, s, r) {
199
199
  super(e, s);
200
- u(this, "knowledgeBaseId");
200
+ h(this, "knowledgeBaseId");
201
201
  this.knowledgeBaseId = r;
202
202
  }
203
203
  async list(e, s, r) {
@@ -217,7 +217,7 @@ class b extends c {
217
217
  await this.httpDelete("/knowledge-bases/" + this.knowledgeBaseId + "/documents/" + e);
218
218
  }
219
219
  }
220
- class v extends c {
220
+ class k extends c {
221
221
  constructor(t, e) {
222
222
  super(t, e);
223
223
  }
@@ -238,13 +238,13 @@ class v extends c {
238
238
  await this.httpDelete("/knowledge-bases/" + t);
239
239
  }
240
240
  documents(t) {
241
- return new b(this.getBaseUrl(), this.getAuthProvider(), t);
241
+ return new v(this.getBaseUrl(), this.getAuthProvider(), t);
242
242
  }
243
243
  async searchChunks(t, e) {
244
244
  return this.httpPost("/knowledge-bases/" + t + "/search", e);
245
245
  }
246
246
  }
247
- class f extends c {
247
+ class G extends c {
248
248
  constructor(t, e) {
249
249
  super(t, e);
250
250
  }
@@ -296,7 +296,7 @@ class f extends c {
296
296
  );
297
297
  }
298
298
  }
299
- class k extends c {
299
+ class z extends c {
300
300
  constructor(t, e) {
301
301
  super(t, e);
302
302
  }
@@ -313,7 +313,7 @@ class k extends c {
313
313
  });
314
314
  }
315
315
  }
316
- class G extends c {
316
+ class U extends c {
317
317
  constructor(t, e) {
318
318
  super(t, e);
319
319
  }
@@ -351,7 +351,7 @@ class G extends c {
351
351
  await this.httpDelete("/channels/identities/me/" + t);
352
352
  }
353
353
  }
354
- class z extends c {
354
+ class x extends c {
355
355
  constructor(t, e) {
356
356
  super(t, e);
357
357
  }
@@ -372,13 +372,13 @@ class z extends c {
372
372
  return this.httpGet("/workflows/" + t);
373
373
  }
374
374
  executions() {
375
- return new f(this.getBaseUrl(), this.getAuthProvider());
375
+ return new G(this.getBaseUrl(), this.getAuthProvider());
376
376
  }
377
377
  humanTasks() {
378
- return new k(this.getBaseUrl(), this.getAuthProvider());
378
+ return new z(this.getBaseUrl(), this.getAuthProvider());
379
379
  }
380
380
  channels() {
381
- return new G(this.getBaseUrl(), this.getAuthProvider());
381
+ return new U(this.getBaseUrl(), this.getAuthProvider());
382
382
  }
383
383
  async listRevisions(t) {
384
384
  return this.httpGet("/workflows/" + t + "/revisions");
@@ -390,7 +390,7 @@ class z extends c {
390
390
  return this.httpPost("/workflows/" + t + "/revisions/" + e + "/rollback", {});
391
391
  }
392
392
  }
393
- class U extends c {
393
+ class S extends c {
394
394
  constructor(t, e) {
395
395
  super(t, e);
396
396
  }
@@ -414,7 +414,7 @@ class U extends c {
414
414
  await this.httpDelete("/credentials/all/" + t);
415
415
  }
416
416
  }
417
- class x extends c {
417
+ class T extends c {
418
418
  constructor(t, e) {
419
419
  super(t, e);
420
420
  }
@@ -442,17 +442,17 @@ class x extends c {
442
442
  return this.httpPost("/features/templates/mcp/available-tools", t, s);
443
443
  }
444
444
  }
445
- class S {
445
+ class A {
446
446
  constructor(t, e) {
447
- u(this, "baseUrl");
448
- u(this, "auth");
447
+ h(this, "baseUrl");
448
+ h(this, "auth");
449
449
  this.baseUrl = t, this.auth = e;
450
450
  }
451
451
  templates() {
452
- return new x(this.baseUrl, this.auth);
452
+ return new T(this.baseUrl, this.auth);
453
453
  }
454
454
  }
455
- class T extends c {
455
+ class C extends c {
456
456
  constructor(t, e) {
457
457
  super(t, e);
458
458
  }
@@ -470,7 +470,7 @@ class T extends c {
470
470
  await this.httpDelete("/triggers/executions/" + t);
471
471
  }
472
472
  }
473
- class A extends c {
473
+ class R extends c {
474
474
  constructor(t, e) {
475
475
  super(t, e);
476
476
  }
@@ -491,10 +491,10 @@ class A extends c {
491
491
  return this.httpGet("/triggers/" + t);
492
492
  }
493
493
  executions() {
494
- return new T(this.getBaseUrl(), this.getAuthProvider());
494
+ return new C(this.getBaseUrl(), this.getAuthProvider());
495
495
  }
496
496
  }
497
- class C extends c {
497
+ class I extends c {
498
498
  constructor(t, e) {
499
499
  super(t, e);
500
500
  }
@@ -518,7 +518,7 @@ class C extends c {
518
518
  await this.httpDelete("/service-prices/" + t);
519
519
  }
520
520
  }
521
- class I extends c {
521
+ class E extends c {
522
522
  constructor(t, e) {
523
523
  super(t, e);
524
524
  }
@@ -539,7 +539,7 @@ class I extends c {
539
539
  await this.httpDelete("/markup-rules/" + t);
540
540
  }
541
541
  }
542
- class R extends c {
542
+ class B extends c {
543
543
  constructor(t, e) {
544
544
  super(t, e);
545
545
  }
@@ -573,13 +573,13 @@ class R extends c {
573
573
  return this.httpGet("/provider-models", { provider: t });
574
574
  }
575
575
  }
576
- class B extends c {
576
+ class j extends c {
577
577
  constructor(t, e) {
578
578
  super(t, e);
579
579
  }
580
580
  async list(t, e, s, r, n, a) {
581
- const { page: i, size: h } = this.normalizePageParams(n, a), p = { page: i, size: h };
582
- return t && (p.keyword = t), e && (p.status = e), s && (p.agentId = s), r && (p.userId = r), this.httpGet("/sessions", p);
581
+ const { page: i, size: p } = this.normalizePageParams(n, a), u = { page: i, size: p };
582
+ return t && (u.keyword = t), e && (u.status = e), s && (u.agentId = s), r && (u.userId = r), this.httpGet("/sessions", u);
583
583
  }
584
584
  async get(t) {
585
585
  return this.httpGet("/sessions/" + t);
@@ -626,7 +626,7 @@ class B extends c {
626
626
  );
627
627
  }
628
628
  }
629
- class E extends c {
629
+ class q extends c {
630
630
  constructor(t, e) {
631
631
  super(t, e);
632
632
  }
@@ -668,10 +668,10 @@ class E extends c {
668
668
  return this.httpPost("/missions/" + t + "/continue");
669
669
  }
670
670
  }
671
- class j {
671
+ class O {
672
672
  constructor(t, e) {
673
- u(this, "baseUrl");
674
- u(this, "authProvider");
673
+ h(this, "baseUrl");
674
+ h(this, "authProvider");
675
675
  this.baseUrl = (t || "https://persona.applica.guru/billing").replace(/\/$/, ""), this.authProvider = e ?? null;
676
676
  }
677
677
  buildHeaders() {
@@ -766,14 +766,14 @@ class j {
766
766
  const a = n.length > 0 ? "?" + n.join("&") : "";
767
767
  return this.request("/projects/" + t + "/subscription/usage-stats" + a, "GET");
768
768
  }
769
- async listUsages(t, e, s, r, n, a, i) {
770
- const h = [];
771
- e && h.push("date_from=" + encodeURIComponent(e)), s && h.push("date_to=" + encodeURIComponent(s)), r != null && r.length && r.forEach((d) => h.push("model=" + encodeURIComponent(d))), n && h.push("session_id=" + encodeURIComponent(n)), a !== void 0 && h.push("page=" + encodeURIComponent(String(a))), i !== void 0 && h.push("size=" + encodeURIComponent(String(i)));
772
- const p = h.length > 0 ? "?" + h.join("&") : "";
773
- return this.request("/projects/" + t + "/subscription/usages" + p, "GET");
769
+ async listUsages(t, e, s, r, n, a, i, p) {
770
+ const u = [];
771
+ e && u.push("date_from=" + encodeURIComponent(e)), s && u.push("date_to=" + encodeURIComponent(s)), r != null && r.length && r.forEach((d) => u.push("model=" + encodeURIComponent(d))), n && u.push("session_id=" + encodeURIComponent(n)), a !== void 0 && u.push("page=" + encodeURIComponent(String(a))), i !== void 0 && u.push("size=" + encodeURIComponent(String(i))), p != null && p.length && p.forEach((d) => u.push("alias=" + encodeURIComponent(d)));
772
+ const y = u.length > 0 ? "?" + u.join("&") : "";
773
+ return this.request("/projects/" + t + "/subscription/usages" + y, "GET");
774
774
  }
775
775
  }
776
- class q extends c {
776
+ class D extends c {
777
777
  constructor(t, e) {
778
778
  super(t, e);
779
779
  }
@@ -832,57 +832,150 @@ class q extends c {
832
832
  return this.httpGet("/values/trigger-destination-types");
833
833
  }
834
834
  }
835
- class D {
835
+ class H extends c {
836
+ constructor(t, e) {
837
+ super(t, e);
838
+ }
839
+ /**
840
+ * Aliases visible to the caller (their project's and the global ones). Super admins
841
+ * can pass `projectId` to see another project's view.
842
+ */
843
+ async list(t, e, s, r) {
844
+ const { page: n, size: a } = this.normalizePageParams(s, r), i = { page: n, size: a };
845
+ return t && (i.projectId = t), e && (i.keyword = e), this.httpGet("/model-aliases", i);
846
+ }
847
+ async get(t) {
848
+ return this.httpGet("/model-aliases/" + t);
849
+ }
850
+ /** Create an alias. Non-super-admins always create in their own project. */
851
+ async create(t) {
852
+ return this.httpPost("/model-aliases", t);
853
+ }
854
+ /** Change target, fallbacks, defaults and description. `name` and the scope are immutable. */
855
+ async update(t, e) {
856
+ return this.httpPut("/model-aliases/" + t, e);
857
+ }
858
+ /**
859
+ * Delete an alias. Refused with a 409 while agents still reference it: use
860
+ * {@link ModelAliasesApi.inUse} on the error to read which ones.
861
+ */
862
+ async remove(t) {
863
+ await this.httpDelete("/model-aliases/" + t);
864
+ }
865
+ /** Agents that reference the alias, and in which model slot. */
866
+ async impact(t) {
867
+ return this.httpGet("/model-aliases/" + t + "/impact");
868
+ }
869
+ /**
870
+ * Run the health check now (registry, announced retirements, credentials). Stores the
871
+ * result in `health` and updates the notifications; it never changes the alias.
872
+ */
873
+ async check(t) {
874
+ return this.httpPost("/model-aliases/" + t + "/check");
875
+ }
876
+ /**
877
+ * Replacement and fallback candidates for the alias' target, or for `model` (e.g. a
878
+ * fallback that went missing). A proposal only: nothing is applied.
879
+ */
880
+ async suggestions(t, e, s) {
881
+ const r = {};
882
+ return e && (r.model = e), s !== void 0 && (r.limit = s), this.httpGet("/model-aliases/" + t + "/suggestions", r);
883
+ }
884
+ /**
885
+ * The agents blocking a delete, when `error` is the 409 of {@link ModelAliasesApi.remove};
886
+ * `null` for any other error.
887
+ */
888
+ static inUse(t) {
889
+ var e, s;
890
+ if (!(t instanceof l) || t.statusCode !== 409) return null;
891
+ try {
892
+ const r = (s = (e = JSON.parse(t.body)) == null ? void 0 : e.detail) == null ? void 0 : s.impact;
893
+ return r && typeof r.total == "number" ? r : null;
894
+ } catch {
895
+ return null;
896
+ }
897
+ }
898
+ }
899
+ class N extends c {
900
+ constructor(t, e) {
901
+ super(t, e);
902
+ }
903
+ async list(t = {}) {
904
+ const { page: e, size: s } = this.normalizePageParams(t.page, t.size), r = { page: e, size: s };
905
+ return t.unreadOnly && (r.unreadOnly = !0), t.includeResolved && (r.includeResolved = !0), t.projectId && (r.projectId = t.projectId), this.httpGet("/notifications", r);
906
+ }
907
+ /** Open, unread notifications: the value of the badge. */
908
+ async unreadCount(t) {
909
+ return (await this.httpGet(
910
+ "/notifications/unread-count",
911
+ t ? { projectId: t } : void 0
912
+ )).count;
913
+ }
914
+ async markRead(t) {
915
+ return this.httpPost("/notifications/" + t + "/read");
916
+ }
917
+ /** Mark as read everything the caller can see. */
918
+ async markAllRead(t) {
919
+ await this.httpPost("/notifications/read-all", void 0, t ? { projectId: t } : void 0);
920
+ }
921
+ }
922
+ class _ {
836
923
  constructor(t, e, s) {
837
- u(this, "baseUrl");
838
- u(this, "workflowsBaseUrl");
839
- u(this, "billingBaseUrl");
924
+ h(this, "baseUrl");
925
+ h(this, "workflowsBaseUrl");
926
+ h(this, "billingBaseUrl");
840
927
  this.baseUrl = t, this.workflowsBaseUrl = e, this.billingBaseUrl = s || "https://persona.applica.guru/billing";
841
928
  }
842
929
  projects(t) {
843
- return new w(this.baseUrl, t, this.billingBaseUrl);
930
+ return new f(this.baseUrl, t, this.billingBaseUrl);
844
931
  }
845
932
  agents(t) {
846
- return new P(this.baseUrl, t);
933
+ return new b(this.baseUrl, t);
847
934
  }
848
935
  knowledgeBases(t) {
849
- return new v(this.baseUrl, t);
936
+ return new k(this.baseUrl, t);
850
937
  }
851
938
  workflows(t) {
852
- return new z(this.workflowsBaseUrl, t);
939
+ return new x(this.workflowsBaseUrl, t);
853
940
  }
854
941
  credentials(t) {
855
- return new U(this.baseUrl, t);
942
+ return new S(this.baseUrl, t);
856
943
  }
857
944
  features(t) {
858
- return new S(this.baseUrl, t);
945
+ return new A(this.baseUrl, t);
859
946
  }
860
947
  triggers(t) {
861
- return new A(this.baseUrl, t);
948
+ return new R(this.baseUrl, t);
862
949
  }
863
950
  servicePrices(t) {
864
- return new C(this.baseUrl, t);
951
+ return new I(this.baseUrl, t);
865
952
  }
866
953
  markupRules(t) {
867
- return new I(this.baseUrl, t);
954
+ return new E(this.baseUrl, t);
868
955
  }
869
956
  providers(t) {
870
- return new R(this.baseUrl, t);
957
+ return new B(this.baseUrl, t);
871
958
  }
872
959
  sessions(t) {
873
- return new B(this.baseUrl, t);
960
+ return new j(this.baseUrl, t);
874
961
  }
875
962
  missions(t) {
876
- return new E(this.baseUrl, t);
963
+ return new q(this.baseUrl, t);
877
964
  }
878
965
  billing(t) {
879
- return new j(this.billingBaseUrl, t);
966
+ return new O(this.billingBaseUrl, t);
967
+ }
968
+ modelAliases(t) {
969
+ return new H(this.baseUrl, t);
970
+ }
971
+ notifications(t) {
972
+ return new N(this.baseUrl, t);
880
973
  }
881
974
  values(t) {
882
- return new q(this.baseUrl, t);
975
+ return new D(this.baseUrl, t);
883
976
  }
884
977
  }
885
- class H {
978
+ class L {
886
979
  constructor(t) {
887
980
  this.token = t;
888
981
  }
@@ -893,30 +986,48 @@ class H {
893
986
  return this.token;
894
987
  }
895
988
  }
989
+ const g = "alias:";
990
+ function M(o) {
991
+ return !!o && o.trim().toLowerCase().startsWith(g);
992
+ }
993
+ function $(o) {
994
+ if (!M(o))
995
+ throw new Error(`Not a model alias reference: ${JSON.stringify(o)}`);
996
+ return o.trim().slice(g.length).trim();
997
+ }
998
+ function F(o) {
999
+ return g + o.trim();
1000
+ }
896
1001
  export {
897
- P as AgentsApi,
1002
+ g as ALIAS_PREFIX,
1003
+ b as AgentsApi,
898
1004
  l as ApiException,
899
- m as ApiKeyAuthenticationProvider,
900
- H as BearerTokenAuthenticationProvider,
901
- j as BillingClient,
902
- G as ChannelsApi,
903
- U as CredentialsApi,
904
- x as FeatureTemplatesApi,
905
- S as FeaturesApi,
906
- k as HumanTasksApi,
907
- b as KnowledgeBaseDocumentsApi,
908
- v as KnowledgeBasesApi,
909
- I as MarkupRulesApi,
910
- E as MissionsApi,
911
- D as PersonaSdk,
912
- w as ProjectsApi,
913
- R as ProvidersApi,
914
- C as ServicePricesApi,
915
- B as SessionsApi,
916
- T as TriggerExecutionsApi,
917
- A as TriggersApi,
918
- q as ValuesApi,
919
- f as WorkflowExecutionsApi,
920
- z as WorkflowsApi
1005
+ w as ApiKeyAuthenticationProvider,
1006
+ L as BearerTokenAuthenticationProvider,
1007
+ O as BillingClient,
1008
+ U as ChannelsApi,
1009
+ S as CredentialsApi,
1010
+ T as FeatureTemplatesApi,
1011
+ A as FeaturesApi,
1012
+ z as HumanTasksApi,
1013
+ v as KnowledgeBaseDocumentsApi,
1014
+ k as KnowledgeBasesApi,
1015
+ E as MarkupRulesApi,
1016
+ q as MissionsApi,
1017
+ H as ModelAliasesApi,
1018
+ N as NotificationsApi,
1019
+ _ as PersonaSdk,
1020
+ f as ProjectsApi,
1021
+ B as ProvidersApi,
1022
+ I as ServicePricesApi,
1023
+ j as SessionsApi,
1024
+ C as TriggerExecutionsApi,
1025
+ R as TriggersApi,
1026
+ D as ValuesApi,
1027
+ G as WorkflowExecutionsApi,
1028
+ x as WorkflowsApi,
1029
+ $ as aliasNameFromRef,
1030
+ F as aliasRef,
1031
+ M as isAliasRef
921
1032
  };
922
1033
  //# sourceMappingURL=bundle.es.js.map