@applica-software-guru/persona-sdk 0.1.113 → 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/README.md +86 -1
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +468 -315
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +339 -3
- package/package.json +1 -1
- package/src/agents/types.ts +6 -2
- package/src/billing/billing-client.ts +3 -0
- package/src/billing/types.ts +16 -0
- package/src/index.ts +27 -0
- package/src/model-aliases/model-aliases-api.ts +94 -0
- package/src/model-aliases/references.ts +20 -0
- package/src/model-aliases/types.ts +125 -0
- package/src/notifications/notifications-api.ts +42 -0
- package/src/notifications/types.ts +39 -0
- package/src/persona-sdk.ts +14 -0
- package/src/sessions/types.ts +2 -0
- package/src/workflows/channels-api.ts +61 -0
- package/src/workflows/types.ts +45 -0
- package/src/workflows/workflows-api.ts +5 -0
- package/tests/billing-aliases.test.mjs +71 -0
- package/tests/channels-api.test.mjs +55 -0
- package/tests/model-aliases-api.test.mjs +198 -0
- package/tests/notifications-api.test.mjs +88 -0
package/README.md
CHANGED
|
@@ -264,6 +264,81 @@ const mission = await missionsApi.create({ name: 'My Mission' });
|
|
|
264
264
|
await missionsApi.execute(mission.id);
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
+
### Model aliases
|
|
268
|
+
|
|
269
|
+
A model alias is a named indirection to a concrete model. An agent whose model is `alias:<name>` follows the alias:
|
|
270
|
+
editing it moves every agent that uses it, e.g. when a model is retired. An alias also lists ordered **fallbacks** that
|
|
271
|
+
the server uses at runtime when the target cannot serve a call.
|
|
272
|
+
|
|
273
|
+
Global aliases are managed by super admins; project aliases by super admins, project admins and the project API key
|
|
274
|
+
(not plain users, nor agent keys). Everyone in a project can read its aliases and the global ones.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import { aliasRef, ModelAliasesApi } from '@applica-software-guru/persona-sdk';
|
|
278
|
+
|
|
279
|
+
const aliases = sdk.modelAliases('your-api-key');
|
|
280
|
+
|
|
281
|
+
// Create a project alias (non-super-admins always create in their own project)
|
|
282
|
+
const alias = await aliases.create({
|
|
283
|
+
name: 'smart',
|
|
284
|
+
target: 'openai/gpt-5',
|
|
285
|
+
fallbacks: ['anthropic/claude-sonnet-4'],
|
|
286
|
+
defaults: { reasoningEffort: 'high' }, // only fills what the agent leaves empty
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Point an agent at it
|
|
290
|
+
const agentsApi = sdk.agents('your-api-key');
|
|
291
|
+
const agent = await agentsApi.get('agent-id');
|
|
292
|
+
await agentsApi.update({
|
|
293
|
+
id: agent.id,
|
|
294
|
+
model: { ...agent.model, modelName: aliasRef('smart') }, // "alias:smart"
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Which agents use it, before changing it
|
|
298
|
+
const impact = await aliases.impact(alias.id);
|
|
299
|
+
|
|
300
|
+
// The target is being retired: ask for candidates (a proposal only, nothing is applied)...
|
|
301
|
+
const { replacements, fallbacks } = await aliases.suggestions(alias.id);
|
|
302
|
+
// ...and apply the one you choose, by hand
|
|
303
|
+
await aliases.update(alias.id, { ...alias, target: replacements[0].model });
|
|
304
|
+
|
|
305
|
+
// Run the health check now (the server also runs it nightly)
|
|
306
|
+
const checked = await aliases.check(alias.id);
|
|
307
|
+
console.log(checked.health.status, checked.health.issues);
|
|
308
|
+
|
|
309
|
+
// Deleting is refused while agents reference the alias
|
|
310
|
+
try {
|
|
311
|
+
await aliases.remove(alias.id);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
const blocking = ModelAliasesApi.inUse(error); // the agents, or null for any other error
|
|
314
|
+
if (!blocking) throw error;
|
|
315
|
+
console.warn(`Used by ${blocking.total} agent(s)`, blocking.usages);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
`name` and the scope (`projectId`) are immutable. The server keeps the `health` and the last 50 changes (`history`).
|
|
320
|
+
The cost of what ran through an alias is in [Billing](#billing) (`byAlias`).
|
|
321
|
+
|
|
322
|
+
### Notifications
|
|
323
|
+
|
|
324
|
+
In-platform notifications (badge and banner), e.g. a model alias whose target is being retired, or that is being served
|
|
325
|
+
by a fallback.
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
const notifications = sdk.notifications('your-api-key');
|
|
329
|
+
|
|
330
|
+
const badge = await notifications.unreadCount();
|
|
331
|
+
const { items } = await notifications.list({ unreadOnly: true });
|
|
332
|
+
for (const n of items) {
|
|
333
|
+
// `title` and `message` are an English fallback: localize from `code` and `data`
|
|
334
|
+
console.log(n.severity, n.code, n.title);
|
|
335
|
+
}
|
|
336
|
+
await notifications.markRead(items[0].id);
|
|
337
|
+
await notifications.markAllRead();
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
A project sees its own notifications; platform-wide ones are for super admins. Agent API keys have no access.
|
|
341
|
+
|
|
267
342
|
### Billing
|
|
268
343
|
|
|
269
344
|
The `BillingClient` manages customers, subscriptions, credits and invoices.
|
|
@@ -312,6 +387,14 @@ const invoices = await billing.listInvoices('user-123', '2026-01-01', '2026-12-3
|
|
|
312
387
|
const projectSub = await billing.getProjectSubscription('project-id');
|
|
313
388
|
await billing.changeProjectSubscriptionPlan('project-id', { toPlanType: 'pro' });
|
|
314
389
|
await billing.addProjectSubscriptionCredits('project-id', { credits: 50 });
|
|
390
|
+
|
|
391
|
+
// Usage statistics: per model and per model alias (the cost of an alias is the sum over the
|
|
392
|
+
// concrete models it served; credits and prices follow the visibility of the caller)
|
|
393
|
+
const stats = await billing.getUsageStats('project-id', '2026-11-01', '2026-11-30');
|
|
394
|
+
console.log(stats.byModel, stats.byAlias);
|
|
395
|
+
|
|
396
|
+
// Usages that went through an alias (the last parameter)
|
|
397
|
+
const usages = await billing.listUsages('project-id', undefined, undefined, undefined, undefined, 0, 20, ['smart']);
|
|
315
398
|
```
|
|
316
399
|
|
|
317
400
|
## Server-side Filtering
|
|
@@ -365,7 +448,9 @@ try {
|
|
|
365
448
|
| **FeatureTemplatesApi** | `list`, `get`, `create`, `update`, `patch`, `remove`, `getMcpAvailableTools` |
|
|
366
449
|
| **MissionsApi** | `list`, `get`, `create`, `update`, `remove`, `generate`, `execute`, `retry`, `replan`, `sendInstruction`, `stop`, `resume` |
|
|
367
450
|
| **ServicePricesApi** | `list`, `get`, `create`, `update`, `remove` |
|
|
368
|
-
| **
|
|
451
|
+
| **ModelAliasesApi** | `list`, `get`, `create`, `update`, `remove`, `impact`, `check`, `suggestions`, `ModelAliasesApi.inUse` |
|
|
452
|
+
| **NotificationsApi** | `list`, `unreadCount`, `markRead`, `markAllRead` |
|
|
453
|
+
| **BillingClient** | `createCustomer`, `updateCustomer`, `getCustomer`, `saveCustomer`, `deleteCustomer`, `createSubscription`, `getSubscription`, `cancelSubscription`, `beginUpgrade`, `downgrade`, `mentorize`, `addCredits`, `useCredits`, `getCredits`, `isValid`, `listInvoices`, `getProjectSubscription`, `changeProjectSubscriptionPlan`, `addProjectSubscriptionCredits`, `getUsageStats`, `listUsages` |
|
|
369
454
|
|
|
370
455
|
## Compatibility
|
|
371
456
|
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var j=(o,t,e)=>t in o?I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var u=(o,t,e)=>j(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l extends Error{constructor(e,s){super(`API Error: ${e} - ${s}`);u(this,"statusCode");u(this,"body");this.statusCode=e,this.body=s}}class d{constructor(t){this.apiKey=t}applyHeaders(t){t.set("x-persona-apikey",this.apiKey)}getCredentials(){return this.apiKey}}class c{constructor(t,e){u(this,"baseUrl");u(this,"authProvider");this.baseUrl=t,this.authProvider=typeof e=="string"?new d(e):e}getBaseUrl(){return this.baseUrl}getAuthProvider(){return this.authProvider}normalizePageParams(t,e){return{page:t===void 0||t<1?1:t,size:e===void 0||e<1?20:e}}buildHeaders(){const t=new Headers;return t.set("Content-Type","application/json"),this.authProvider.applyHeaders(t),t}buildUrl(t,e){const s=new URL(this.baseUrl+t);return e&&Object.entries(e).forEach(([r,n])=>{n!=null&&s.searchParams.set(r,String(n))}),s.toString()}async handleResponse(t){if(!t.ok){const s=await t.text();throw new l(t.status,s)}const e=await t.text();return e?JSON.parse(e):void 0}async httpGet(t,e){const s=await fetch(this.buildUrl(t,e),{method:"GET",headers:this.buildHeaders()});return this.handleResponse(s)}async httpPost(t,e,s){const r=await fetch(this.buildUrl(t,s),{method:"POST",headers:this.buildHeaders(),body:e?JSON.stringify(e):void 0});return this.handleResponse(r)}async httpPut(t,e){const s=await fetch(this.baseUrl+t,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify(e)});return this.handleResponse(s)}async httpPatch(t,e){const s=await fetch(this.baseUrl+t,{method:"PATCH",headers:this.buildHeaders(),body:JSON.stringify(e)});return this.handleResponse(s)}async httpDelete(t){const e=await fetch(this.baseUrl+t,{method:"DELETE",headers:this.buildHeaders()});if(!e.ok){const s=await e.text();throw new l(e.status,s)}}}class g extends c{constructor(e,s,r){super(e,s);u(this,"billingBaseUrl");this.billingBaseUrl=(r||e).replace(/\/$/,"")}async list(e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return e&&(i.keyword=e),this.httpGet("/projects",i)}async get(e){return this.httpGet("/projects/"+e)}async getMine(){return this.httpGet("/projects/mine")}async create(e){return this.httpPost("/projects",e)}async update(e){return this.httpPut("/projects/"+e.projectId,e)}async remove(e){await this.httpDelete("/projects/"+e)}async duplicate(e,s){return this.httpPost("/projects/"+e+"/actions/duplicate",s)}async getSubscription(e){return this.billingRequest("/projects/"+e+"/subscription","GET")}async changeSubscriptionPlan(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/change-plan","POST",s)}async addSubscriptionCredits(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/add-credits","POST",s)}async setInfiniteCredits(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/set-infinite-credits","POST",s)}async billingRequest(e,s,r){const n=new Headers;n.set("Content-Type","application/json"),this.getAuthProvider().applyHeaders(n);const a=await fetch(this.billingBaseUrl+e,{method:s,headers:n,body:r?JSON.stringify(r):void 0});if(!a.ok){const h=await a.text();throw new l(a.status,h)}const i=await a.text();return i?JSON.parse(i):void 0}}class y extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/agents",i)}async get(t){return this.httpGet("/agents/"+t)}async create(t){return this.httpPost("/agents",t)}async update(t){return this.httpPut("/agents/"+t.id,t)}async remove(t){await this.httpDelete("/agents/"+t)}async getSynthesizerSupportedVoices(t){return this.httpGet("/values/synthesizers/"+t+"/voices")}async listRevisions(t){return this.httpGet("/agents/"+t+"/revisions")}async getRevision(t,e){return this.httpGet("/agents/"+t+"/revisions/"+e)}async rollback(t,e){return this.httpPost("/agents/"+t+"/revisions/"+e+"/rollback",{})}async generateSystemInstructions(t,e){const s={prompt:t};return e&&(s.sessionId=e),(await this.httpPost("/agents/system-instructions",s)).instructions}async getArchitect(){return this.httpGet("/agents/architect")}}class m extends c{constructor(e,s,r){super(e,s);u(this,"knowledgeBaseId");this.knowledgeBaseId=r}async list(e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return e&&(i.keyword=e),this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents",i)}async upload(e){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",e)}async get(e){return this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+e)}async reprocess(e){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",{document_id:e})}async remove(e){await this.httpDelete("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+e)}}class P extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/knowledge-bases",i)}async get(t){return this.httpGet("/knowledge-bases/"+t)}async create(t){return this.httpPost("/knowledge-bases",t)}async update(t){return this.httpPut("/knowledge-bases/"+t.id,t)}async remove(t){await this.httpDelete("/knowledge-bases/"+t)}documents(t){return new m(this.getBaseUrl(),this.getAuthProvider(),t)}async searchChunks(t,e){return this.httpPost("/knowledge-bases/"+t+"/search",e)}}class w extends c{constructor(t,e){super(t,e)}async list(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/workflows/"+t+"/executions",a)}async get(t,e){return this.httpGet("/workflows/"+t+"/executions/"+e)}async run(t,e){return this.httpPost("/workflows/"+t+"/executions",e)}async queue(t,e){return this.httpPost("/workflows/"+t+"/executions/queue",e)}async listRuns(t={}){const{page:e,size:s}=this.normalizePageParams(t.page,t.size),r={page:e,size:s};return t.status&&(r.status=t.status),t.workflowId&&(r.workflowId=t.workflowId),t.dateFrom&&(r.dateFrom=t.dateFrom),t.dateTo&&(r.dateTo=t.dateTo),this.httpGet("/executions",r)}async cancel(t,e){return this.httpPost("/workflows/"+t+"/executions/"+e+"/cancel",{})}async rerun(t,e,s,r="reuse_outputs"){return this.httpPost("/workflows/"+t+"/executions/"+e+"/rerun",{fromNodeId:s,mode:r})}async dryRunNode(t,e,s={}){return this.httpPost("/workflows/"+t+"/nodes/"+e+"/dry-run",{inputs:s})}async stepTrace(t,e,s,r,n){const{page:a,size:i}=this.normalizePageParams(r,n??200);return this.httpGet("/workflows/"+t+"/executions/"+e+"/steps/"+s+"/trace",{page:a,size:i})}}class b extends c{constructor(t,e){super(t,e)}async list(t={}){const{page:e,size:s}=this.normalizePageParams(t.page,t.size??50),r={page:e,size:s};return(t.status??"pending")&&(r.status=t.status??"pending"),t.assignee&&(r.assignee=t.assignee),t.workflowId&&(r.workflowId=t.workflowId),t.executionId&&(r.executionId=t.executionId),this.httpGet("/human-tasks",r)}async respond(t,e,s){return this.httpPost("/human-tasks/"+t+"/respond",{response:e,respondedBy:s})}}class v extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/workflows",i)}async create(t){return this.httpPost("/workflows",t)}async update(t,e){return e.id=t,this.httpPut("/workflows/"+t,e)}async remove(t){await this.httpDelete("/workflows/"+t)}async get(t){return this.httpGet("/workflows/"+t)}executions(){return new w(this.getBaseUrl(),this.getAuthProvider())}humanTasks(){return new b(this.getBaseUrl(),this.getAuthProvider())}async listRevisions(t){return this.httpGet("/workflows/"+t+"/revisions")}async getRevision(t,e){return this.httpGet("/workflows/"+t+"/revisions/"+e)}async rollback(t,e){return this.httpPost("/workflows/"+t+"/revisions/"+e+"/rollback",{})}}class f extends c{constructor(t,e){super(t,e)}async authorize(t,e){return this.httpPost("/credentials/"+t+"/authorize",e)}async handleOAuth2Callback(t,e,s,r){const n={code:e,state:s};return r&&(n.scope=r),this.httpGet("/credentials/"+t+"/oauth2/callback",n)}async list(){return this.httpGet("/credentials")}async getByProvider(t){return this.httpGet("/credentials/"+t)}async getById(t){return this.httpGet("/credentials/all/"+t)}async remove(t){await this.httpDelete("/credentials/all/"+t)}}class k extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/features/templates",i)}async get(t){return this.httpGet("/features/templates/"+t)}async create(t){return this.httpPost("/features/templates",t)}async update(t,e){return this.httpPut("/features/templates/"+t,e)}async patch(t,e){return this.httpPatch("/features/templates/"+t,e)}async remove(t){await this.httpDelete("/features/templates/"+t)}async getMcpAvailableTools(t,e){const s=e?{credentialsId:e}:void 0;return this.httpPost("/features/templates/mcp/available-tools",t,s)}}class G{constructor(t,e){u(this,"baseUrl");u(this,"auth");this.baseUrl=t,this.auth=e}templates(){return new k(this.baseUrl,this.auth)}}class z extends c{constructor(t,e){super(t,e)}async list(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/triggers/"+t+"/executions",a)}async execute(t,e){return this.httpPost("/triggers/"+t+"/executions",e)}async get(t){return this.httpGet("/triggers/executions/"+t)}async remove(t){await this.httpDelete("/triggers/executions/"+t)}}class U extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/triggers",i)}async create(t){return this.httpPost("/triggers",t)}async update(t,e){return this.httpPut("/triggers/"+t,e)}async remove(t){await this.httpDelete("/triggers/"+t)}async get(t){return this.httpGet("/triggers/"+t)}executions(){return new z(this.getBaseUrl(),this.getAuthProvider())}}class x extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/service-prices",i)}async getStats(t={}){return this.httpGet("/service-prices/stats",{...t})}async get(t){return this.httpGet("/service-prices/"+t)}async create(t){return this.httpPost("/service-prices",t)}async update(t,e){return this.httpPut("/service-prices/"+t,e)}async remove(t){await this.httpDelete("/service-prices/"+t)}}class A extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return t&&(i.projectId=t),e&&(i.keyword=e),this.httpGet("/markup-rules",i)}async get(t){return this.httpGet("/markup-rules/"+t)}async create(t){return this.httpPost("/markup-rules",t)}async update(t,e){return this.httpPut("/markup-rules/"+t,e)}async remove(t){await this.httpDelete("/markup-rules/"+t)}}class S extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return t&&(i.projectId=t),e&&(i.keyword=e),this.httpGet("/providers",i)}async get(t){return this.httpGet("/providers/"+t)}async create(t){return this.httpPost("/providers",t)}async update(t,e){return this.httpPut("/providers/"+t,e)}async remove(t){await this.httpDelete("/providers/"+t)}async available(){return this.httpGet("/providers/available")}async names(){return this.httpGet("/provider-names")}async models(t){return this.httpGet("/provider-models",{provider:t})}}class T extends c{constructor(t,e){super(t,e)}async list(t,e,s,r,n,a){const{page:i,size:h}=this.normalizePageParams(n,a),p={page:i,size:h};return t&&(p.keyword=t),e&&(p.status=e),s&&(p.agentId=s),r&&(p.userId=r),this.httpGet("/sessions",p)}async get(t){return this.httpGet("/sessions/"+t)}async getUsage(t){return this.httpGet("/sessions/"+t+"/usage")}async generateMessage(t,e){return this.httpPost("/sessions/"+t+"/messages",e)}async findMessages(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/sessions/"+t+"/messages",a)}async remove(t){await this.httpDelete("/sessions/"+t)}async rename(t,e){return this.httpPut("/sessions/"+t+"/name",{name:e})}async getAgentState(t){return this.httpGet("/sessions/"+encodeURIComponent(t)+"/agent-state")}async cancelExecution(t){return this.httpPost("/sessions/"+encodeURIComponent(t)+"/cancel",{})}async steerExecution(t,e){return this.httpPost("/sessions/"+encodeURIComponent(t)+"/steer",{text:e})}}class C extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a};return t&&(i.keyword=t),r&&(i.status=r),this.httpGet("/missions",i)}async get(t){return this.httpGet("/missions/"+t)}async create(t){return this.httpPost("/missions",t)}async update(t,e){return this.httpPut("/missions/"+t,e)}async remove(t){await this.httpDelete("/missions/"+t)}async generate(t){return this.httpPost("/missions/"+t+"/generate")}async execute(t){return this.httpPost("/missions/"+t+"/execute")}async retry(t){return this.httpPost("/missions/"+t+"/retry")}async replan(t){return this.httpPost("/missions/"+t+"/replan")}async sendInstruction(t,e){return this.httpPost("/missions/"+t+"/instructions",{instruction:e})}async stop(t){return this.httpPost("/missions/"+t+"/stop")}async resume(t){return this.httpPost("/missions/"+t+"/continue")}}class B{constructor(t,e){u(this,"baseUrl");u(this,"authProvider");this.baseUrl=(t||"https://persona.applica.guru/billing").replace(/\/$/,""),this.authProvider=e??null}buildHeaders(){const t=new Headers;return t.set("Content-Type","application/json"),this.authProvider&&(typeof this.authProvider=="string"?t.set("x-persona-apikey",this.authProvider):this.authProvider.applyHeaders(t)),t}async request(t,e,s){const r=await fetch(this.baseUrl+t,{method:e,headers:this.buildHeaders(),body:s?JSON.stringify(s):void 0});if(!r.ok){const a=await r.text();throw new l(r.status,a)}const n=await r.text();return n?JSON.parse(n):void 0}async createCustomer(t){return this.request("/customers","POST",t)}async updateCustomer(t,e){return this.request("/customers/"+t,"PUT",e)}async getCustomer(t){return this.request("/customers/"+t,"GET")}async saveCustomer(t){return this.request("/customers","POST",t)}async deleteCustomer(t){await this.request("/customers/"+t,"DELETE")}async createSubscription(t){return this.request("/customers/"+t.owner+"/subscription","POST",t)}async getSubscription(t){return this.request("/customers/"+t+"/subscription","GET")}async getProjectSubscription(t){return this.request("/projects/"+t+"/subscription","GET")}async changeProjectSubscriptionPlan(t,e){return this.request("/projects/"+t+"/subscription/actions/change-plan","POST",e)}async addProjectSubscriptionCredits(t,e){return this.request("/projects/"+t+"/subscription/actions/add-credits","POST",e)}async beginUpgrade(t,e){return this.request("/customers/"+t+"/subscription/actions/upgrade","POST",e)}async downgrade(t,e){return this.request("/customers/"+t+"/subscription/actions/downgrade","POST",e)}async mentorize(t,e){return this.request("/customers/"+t+"/subscription/actions/mentorize","POST",e)}async addCredits(t,e){return this.request("/customers/"+t+"/subscription/credits","POST",{credits:e})}async useCredits(t,e,s,r,n,a){const i={credits:e,services:s};return r&&(i.referenceId=r),n!==void 0&&(i.totalCost=n),a!==void 0&&(i.totalPrice=a),this.request("/customers/"+t+"/subscription/credits","DELETE",i)}async getCredits(t){try{return(await this.request("/customers/"+t+"/subscription/credits","GET")).credits??0}catch{return 0}}async isValid(t){try{return(await this.request("/customers/"+t+"/subscription/valid","GET")).valid??!1}catch{return!1}}async listInvoices(t,e,s){const r=[];e&&r.push("date_from="+e),s&&r.push("date_to="+s);const n=r.length>0?"?"+r.join("&"):"";return this.request("/customers/"+t+"/invoices"+n,"GET")}async cancelSubscription(t){return this.request("/customers/"+t+"/subscription/actions/cancel","POST",{})}async getUsageStats(t,e,s,r){const n=[];e&&n.push("date_from="+encodeURIComponent(e)),s&&n.push("date_to="+encodeURIComponent(s)),r!=null&&r.length&&r.forEach(i=>n.push("model="+encodeURIComponent(i)));const a=n.length>0?"?"+n.join("&"):"";return this.request("/projects/"+t+"/subscription/usage-stats"+a,"GET")}async listUsages(t,e,s,r,n,a,i){const h=[];e&&h.push("date_from="+encodeURIComponent(e)),s&&h.push("date_to="+encodeURIComponent(s)),r!=null&&r.length&&r.forEach(R=>h.push("model="+encodeURIComponent(R))),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)));const p=h.length>0?"?"+h.join("&"):"";return this.request("/projects/"+t+"/subscription/usages"+p,"GET")}}class E extends c{constructor(t,e){super(t,e)}async get(t){return this.httpGet("/values/"+t)}async getLanguageCodes(){return this.httpGet("/values/language-codes")}async getModelNames(){return this.httpGet("/values/model-names")}async getModelProviders(){return this.httpGet("/values/model-providers")}async getKnowledgeTypes(){return this.httpGet("/values/knowledge-types")}async getCollaborationModes(){return this.httpGet("/values/collaboration-modes")}async getTranscriberNames(){return this.httpGet("/values/transcriber-names")}async getSynthesizerNames(){return this.httpGet("/values/synthesizer-names")}async getSynthesizerVoices(t){return this.httpGet("/values/synthesizers/"+t+"/voices")}async getDocumentExtractors(){return this.httpGet("/values/document-extractors")}async getEmbeddingModels(){return this.httpGet("/values/embedding-models")}async getQualityOptions(){return this.httpGet("/values/quality")}async getChunkSizeOptions(){return this.httpGet("/values/chunk-size")}async getFeatureTypes(){return this.httpGet("/values/feature-types")}async getRoles(){return this.httpGet("/values/roles")}async getServiceUnits(){return this.httpGet("/values/service-units")}async getTriggerSourceTypes(){return this.httpGet("/values/trigger-source-types")}async getTriggerDestinationTypes(){return this.httpGet("/values/trigger-destination-types")}}class q{constructor(t,e,s){u(this,"baseUrl");u(this,"workflowsBaseUrl");u(this,"billingBaseUrl");this.baseUrl=t,this.workflowsBaseUrl=e,this.billingBaseUrl=s||"https://persona.applica.guru/billing"}projects(t){return new g(this.baseUrl,t,this.billingBaseUrl)}agents(t){return new y(this.baseUrl,t)}knowledgeBases(t){return new P(this.baseUrl,t)}workflows(t){return new v(this.workflowsBaseUrl,t)}credentials(t){return new f(this.baseUrl,t)}features(t){return new G(this.baseUrl,t)}triggers(t){return new U(this.baseUrl,t)}servicePrices(t){return new x(this.baseUrl,t)}markupRules(t){return new A(this.baseUrl,t)}providers(t){return new S(this.baseUrl,t)}sessions(t){return new T(this.baseUrl,t)}missions(t){return new C(this.baseUrl,t)}billing(t){return new B(this.billingBaseUrl,t)}values(t){return new E(this.baseUrl,t)}}class O{constructor(t){this.token=t}applyHeaders(t){t.set("Authorization",`Bearer ${this.token}`)}getCredentials(){return this.token}}exports.AgentsApi=y;exports.ApiException=l;exports.ApiKeyAuthenticationProvider=d;exports.BearerTokenAuthenticationProvider=O;exports.BillingClient=B;exports.CredentialsApi=f;exports.FeatureTemplatesApi=k;exports.FeaturesApi=G;exports.HumanTasksApi=b;exports.KnowledgeBaseDocumentsApi=m;exports.KnowledgeBasesApi=P;exports.MarkupRulesApi=A;exports.MissionsApi=C;exports.PersonaSdk=q;exports.ProjectsApi=g;exports.ProvidersApi=S;exports.ServicePricesApi=x;exports.SessionsApi=T;exports.TriggerExecutionsApi=z;exports.TriggersApi=U;exports.ValuesApi=E;exports.WorkflowExecutionsApi=w;exports.WorkflowsApi=v;
|
|
1
|
+
"use strict";var N=Object.defineProperty;var M=(o,t,e)=>t in o?N(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var h=(o,t,e)=>M(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l extends Error{constructor(e,s){super(`API Error: ${e} - ${s}`);h(this,"statusCode");h(this,"body");this.statusCode=e,this.body=s}}class y{constructor(t){this.apiKey=t}applyHeaders(t){t.set("x-persona-apikey",this.apiKey)}getCredentials(){return this.apiKey}}class c{constructor(t,e){h(this,"baseUrl");h(this,"authProvider");this.baseUrl=t,this.authProvider=typeof e=="string"?new y(e):e}getBaseUrl(){return this.baseUrl}getAuthProvider(){return this.authProvider}normalizePageParams(t,e){return{page:t===void 0||t<1?1:t,size:e===void 0||e<1?20:e}}buildHeaders(){const t=new Headers;return t.set("Content-Type","application/json"),this.authProvider.applyHeaders(t),t}buildUrl(t,e){const s=new URL(this.baseUrl+t);return e&&Object.entries(e).forEach(([r,n])=>{n!=null&&s.searchParams.set(r,String(n))}),s.toString()}async handleResponse(t){if(!t.ok){const s=await t.text();throw new l(t.status,s)}const e=await t.text();return e?JSON.parse(e):void 0}async httpGet(t,e){const s=await fetch(this.buildUrl(t,e),{method:"GET",headers:this.buildHeaders()});return this.handleResponse(s)}async httpPost(t,e,s){const r=await fetch(this.buildUrl(t,s),{method:"POST",headers:this.buildHeaders(),body:e?JSON.stringify(e):void 0});return this.handleResponse(r)}async httpPut(t,e){const s=await fetch(this.baseUrl+t,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify(e)});return this.handleResponse(s)}async httpPatch(t,e){const s=await fetch(this.baseUrl+t,{method:"PATCH",headers:this.buildHeaders(),body:JSON.stringify(e)});return this.handleResponse(s)}async httpDelete(t){const e=await fetch(this.baseUrl+t,{method:"DELETE",headers:this.buildHeaders()});if(!e.ok){const s=await e.text();throw new l(e.status,s)}}}class m extends c{constructor(e,s,r){super(e,s);h(this,"billingBaseUrl");this.billingBaseUrl=(r||e).replace(/\/$/,"")}async list(e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return e&&(i.keyword=e),this.httpGet("/projects",i)}async get(e){return this.httpGet("/projects/"+e)}async getMine(){return this.httpGet("/projects/mine")}async create(e){return this.httpPost("/projects",e)}async update(e){return this.httpPut("/projects/"+e.projectId,e)}async remove(e){await this.httpDelete("/projects/"+e)}async duplicate(e,s){return this.httpPost("/projects/"+e+"/actions/duplicate",s)}async getSubscription(e){return this.billingRequest("/projects/"+e+"/subscription","GET")}async changeSubscriptionPlan(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/change-plan","POST",s)}async addSubscriptionCredits(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/add-credits","POST",s)}async setInfiniteCredits(e,s){return this.billingRequest("/projects/"+e+"/subscription/actions/set-infinite-credits","POST",s)}async billingRequest(e,s,r){const n=new Headers;n.set("Content-Type","application/json"),this.getAuthProvider().applyHeaders(n);const a=await fetch(this.billingBaseUrl+e,{method:s,headers:n,body:r?JSON.stringify(r):void 0});if(!a.ok){const p=await a.text();throw new l(a.status,p)}const i=await a.text();return i?JSON.parse(i):void 0}}class P extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/agents",i)}async get(t){return this.httpGet("/agents/"+t)}async create(t){return this.httpPost("/agents",t)}async update(t){return this.httpPut("/agents/"+t.id,t)}async remove(t){await this.httpDelete("/agents/"+t)}async getSynthesizerSupportedVoices(t){return this.httpGet("/values/synthesizers/"+t+"/voices")}async listRevisions(t){return this.httpGet("/agents/"+t+"/revisions")}async getRevision(t,e){return this.httpGet("/agents/"+t+"/revisions/"+e)}async rollback(t,e){return this.httpPost("/agents/"+t+"/revisions/"+e+"/rollback",{})}async generateSystemInstructions(t,e){const s={prompt:t};return e&&(s.sessionId=e),(await this.httpPost("/agents/system-instructions",s)).instructions}async getArchitect(){return this.httpGet("/agents/architect")}}class w extends c{constructor(e,s,r){super(e,s);h(this,"knowledgeBaseId");this.knowledgeBaseId=r}async list(e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return e&&(i.keyword=e),this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents",i)}async upload(e){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",e)}async get(e){return this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+e)}async reprocess(e){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",{document_id:e})}async remove(e){await this.httpDelete("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+e)}}class f extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/knowledge-bases",i)}async get(t){return this.httpGet("/knowledge-bases/"+t)}async create(t){return this.httpPost("/knowledge-bases",t)}async update(t){return this.httpPut("/knowledge-bases/"+t.id,t)}async remove(t){await this.httpDelete("/knowledge-bases/"+t)}documents(t){return new w(this.getBaseUrl(),this.getAuthProvider(),t)}async searchChunks(t,e){return this.httpPost("/knowledge-bases/"+t+"/search",e)}}class v extends c{constructor(t,e){super(t,e)}async list(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/workflows/"+t+"/executions",a)}async get(t,e){return this.httpGet("/workflows/"+t+"/executions/"+e)}async run(t,e){return this.httpPost("/workflows/"+t+"/executions",e)}async queue(t,e){return this.httpPost("/workflows/"+t+"/executions/queue",e)}async listRuns(t={}){const{page:e,size:s}=this.normalizePageParams(t.page,t.size),r={page:e,size:s};return t.status&&(r.status=t.status),t.workflowId&&(r.workflowId=t.workflowId),t.dateFrom&&(r.dateFrom=t.dateFrom),t.dateTo&&(r.dateTo=t.dateTo),this.httpGet("/executions",r)}async cancel(t,e){return this.httpPost("/workflows/"+t+"/executions/"+e+"/cancel",{})}async rerun(t,e,s,r="reuse_outputs"){return this.httpPost("/workflows/"+t+"/executions/"+e+"/rerun",{fromNodeId:s,mode:r})}async dryRunNode(t,e,s={}){return this.httpPost("/workflows/"+t+"/nodes/"+e+"/dry-run",{inputs:s})}async stepTrace(t,e,s,r,n){const{page:a,size:i}=this.normalizePageParams(r,n??200);return this.httpGet("/workflows/"+t+"/executions/"+e+"/steps/"+s+"/trace",{page:a,size:i})}}class b extends c{constructor(t,e){super(t,e)}async list(t={}){const{page:e,size:s}=this.normalizePageParams(t.page,t.size??50),r={page:e,size:s};return(t.status??"pending")&&(r.status=t.status??"pending"),t.assignee&&(r.assignee=t.assignee),t.workflowId&&(r.workflowId=t.workflowId),t.executionId&&(r.executionId=t.executionId),this.httpGet("/human-tasks",r)}async respond(t,e,s){return this.httpPost("/human-tasks/"+t+"/respond",{response:e,respondedBy:s})}}class k extends c{constructor(t,e){super(t,e)}async providers(){return this.httpGet("/channels/providers")}async list(){return this.httpGet("/channels")}async createLink(t="telegram"){return this.httpPost("/channels/"+t+"/link-token")}async update(t,e){return this.httpPatch("/channels/"+t,e)}async verify(t){return this.httpPost("/channels/"+t+"/verify")}async unlink(t){await this.httpDelete("/channels/"+t)}async myIdentities(){return this.httpGet("/channels/identities/me")}async createIdentityLink(t="telegram"){return this.httpPost("/channels/identities/"+t+"/link-token")}async unlinkIdentity(t="telegram"){await this.httpDelete("/channels/identities/me/"+t)}}class G extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/workflows",i)}async create(t){return this.httpPost("/workflows",t)}async update(t,e){return e.id=t,this.httpPut("/workflows/"+t,e)}async remove(t){await this.httpDelete("/workflows/"+t)}async get(t){return this.httpGet("/workflows/"+t)}executions(){return new v(this.getBaseUrl(),this.getAuthProvider())}humanTasks(){return new b(this.getBaseUrl(),this.getAuthProvider())}channels(){return new k(this.getBaseUrl(),this.getAuthProvider())}async listRevisions(t){return this.httpGet("/workflows/"+t+"/revisions")}async getRevision(t,e){return this.httpGet("/workflows/"+t+"/revisions/"+e)}async rollback(t,e){return this.httpPost("/workflows/"+t+"/revisions/"+e+"/rollback",{})}}class A extends c{constructor(t,e){super(t,e)}async authorize(t,e){return this.httpPost("/credentials/"+t+"/authorize",e)}async handleOAuth2Callback(t,e,s,r){const n={code:e,state:s};return r&&(n.scope=r),this.httpGet("/credentials/"+t+"/oauth2/callback",n)}async list(){return this.httpGet("/credentials")}async getByProvider(t){return this.httpGet("/credentials/"+t)}async getById(t){return this.httpGet("/credentials/all/"+t)}async remove(t){await this.httpDelete("/credentials/all/"+t)}}class z extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/features/templates",i)}async get(t){return this.httpGet("/features/templates/"+t)}async create(t){return this.httpPost("/features/templates",t)}async update(t,e){return this.httpPut("/features/templates/"+t,e)}async patch(t,e){return this.httpPatch("/features/templates/"+t,e)}async remove(t){await this.httpDelete("/features/templates/"+t)}async getMcpAvailableTools(t,e){const s=e?{credentialsId:e}:void 0;return this.httpPost("/features/templates/mcp/available-tools",t,s)}}class U{constructor(t,e){h(this,"baseUrl");h(this,"auth");this.baseUrl=t,this.auth=e}templates(){return new z(this.baseUrl,this.auth)}}class x extends c{constructor(t,e){super(t,e)}async list(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/triggers/"+t+"/executions",a)}async execute(t,e){return this.httpPost("/triggers/"+t+"/executions",e)}async get(t){return this.httpGet("/triggers/executions/"+t)}async remove(t){await this.httpDelete("/triggers/executions/"+t)}}class S extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/triggers",i)}async create(t){return this.httpPost("/triggers",t)}async update(t,e){return this.httpPut("/triggers/"+t,e)}async remove(t){await this.httpDelete("/triggers/"+t)}async get(t){return this.httpGet("/triggers/"+t)}executions(){return new x(this.getBaseUrl(),this.getAuthProvider())}}class T extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a,...r};return t&&(i.keyword=t),this.httpGet("/service-prices",i)}async getStats(t={}){return this.httpGet("/service-prices/stats",{...t})}async get(t){return this.httpGet("/service-prices/"+t)}async create(t){return this.httpPost("/service-prices",t)}async update(t,e){return this.httpPut("/service-prices/"+t,e)}async remove(t){await this.httpDelete("/service-prices/"+t)}}class R extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return t&&(i.projectId=t),e&&(i.keyword=e),this.httpGet("/markup-rules",i)}async get(t){return this.httpGet("/markup-rules/"+t)}async create(t){return this.httpPost("/markup-rules",t)}async update(t,e){return this.httpPut("/markup-rules/"+t,e)}async remove(t){await this.httpDelete("/markup-rules/"+t)}}class C extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return t&&(i.projectId=t),e&&(i.keyword=e),this.httpGet("/providers",i)}async get(t){return this.httpGet("/providers/"+t)}async create(t){return this.httpPost("/providers",t)}async update(t,e){return this.httpPut("/providers/"+t,e)}async remove(t){await this.httpDelete("/providers/"+t)}async available(){return this.httpGet("/providers/available")}async names(){return this.httpGet("/provider-names")}async models(t){return this.httpGet("/provider-models",{provider:t})}}class I extends c{constructor(t,e){super(t,e)}async list(t,e,s,r,n,a){const{page:i,size:p}=this.normalizePageParams(n,a),u={page:i,size:p};return t&&(u.keyword=t),e&&(u.status=e),s&&(u.agentId=s),r&&(u.userId=r),this.httpGet("/sessions",u)}async get(t){return this.httpGet("/sessions/"+t)}async getUsage(t){return this.httpGet("/sessions/"+t+"/usage")}async generateMessage(t,e){return this.httpPost("/sessions/"+t+"/messages",e)}async findMessages(t,e,s){const{page:r,size:n}=this.normalizePageParams(e,s),a={page:r,size:n};return this.httpGet("/sessions/"+t+"/messages",a)}async remove(t){await this.httpDelete("/sessions/"+t)}async rename(t,e){return this.httpPut("/sessions/"+t+"/name",{name:e})}async getAgentState(t){return this.httpGet("/sessions/"+encodeURIComponent(t)+"/agent-state")}async cancelExecution(t){return this.httpPost("/sessions/"+encodeURIComponent(t)+"/cancel",{})}async steerExecution(t,e){return this.httpPost("/sessions/"+encodeURIComponent(t)+"/steer",{text:e})}}class E extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(e,s),i={page:n,size:a};return t&&(i.keyword=t),r&&(i.status=r),this.httpGet("/missions",i)}async get(t){return this.httpGet("/missions/"+t)}async create(t){return this.httpPost("/missions",t)}async update(t,e){return this.httpPut("/missions/"+t,e)}async remove(t){await this.httpDelete("/missions/"+t)}async generate(t){return this.httpPost("/missions/"+t+"/generate")}async execute(t){return this.httpPost("/missions/"+t+"/execute")}async retry(t){return this.httpPost("/missions/"+t+"/retry")}async replan(t){return this.httpPost("/missions/"+t+"/replan")}async sendInstruction(t,e){return this.httpPost("/missions/"+t+"/instructions",{instruction:e})}async stop(t){return this.httpPost("/missions/"+t+"/stop")}async resume(t){return this.httpPost("/missions/"+t+"/continue")}}class B{constructor(t,e){h(this,"baseUrl");h(this,"authProvider");this.baseUrl=(t||"https://persona.applica.guru/billing").replace(/\/$/,""),this.authProvider=e??null}buildHeaders(){const t=new Headers;return t.set("Content-Type","application/json"),this.authProvider&&(typeof this.authProvider=="string"?t.set("x-persona-apikey",this.authProvider):this.authProvider.applyHeaders(t)),t}async request(t,e,s){const r=await fetch(this.baseUrl+t,{method:e,headers:this.buildHeaders(),body:s?JSON.stringify(s):void 0});if(!r.ok){const a=await r.text();throw new l(r.status,a)}const n=await r.text();return n?JSON.parse(n):void 0}async createCustomer(t){return this.request("/customers","POST",t)}async updateCustomer(t,e){return this.request("/customers/"+t,"PUT",e)}async getCustomer(t){return this.request("/customers/"+t,"GET")}async saveCustomer(t){return this.request("/customers","POST",t)}async deleteCustomer(t){await this.request("/customers/"+t,"DELETE")}async createSubscription(t){return this.request("/customers/"+t.owner+"/subscription","POST",t)}async getSubscription(t){return this.request("/customers/"+t+"/subscription","GET")}async getProjectSubscription(t){return this.request("/projects/"+t+"/subscription","GET")}async changeProjectSubscriptionPlan(t,e){return this.request("/projects/"+t+"/subscription/actions/change-plan","POST",e)}async addProjectSubscriptionCredits(t,e){return this.request("/projects/"+t+"/subscription/actions/add-credits","POST",e)}async beginUpgrade(t,e){return this.request("/customers/"+t+"/subscription/actions/upgrade","POST",e)}async downgrade(t,e){return this.request("/customers/"+t+"/subscription/actions/downgrade","POST",e)}async mentorize(t,e){return this.request("/customers/"+t+"/subscription/actions/mentorize","POST",e)}async addCredits(t,e){return this.request("/customers/"+t+"/subscription/credits","POST",{credits:e})}async useCredits(t,e,s,r,n,a){const i={credits:e,services:s};return r&&(i.referenceId=r),n!==void 0&&(i.totalCost=n),a!==void 0&&(i.totalPrice=a),this.request("/customers/"+t+"/subscription/credits","DELETE",i)}async getCredits(t){try{return(await this.request("/customers/"+t+"/subscription/credits","GET")).credits??0}catch{return 0}}async isValid(t){try{return(await this.request("/customers/"+t+"/subscription/valid","GET")).valid??!1}catch{return!1}}async listInvoices(t,e,s){const r=[];e&&r.push("date_from="+e),s&&r.push("date_to="+s);const n=r.length>0?"?"+r.join("&"):"";return this.request("/customers/"+t+"/invoices"+n,"GET")}async cancelSubscription(t){return this.request("/customers/"+t+"/subscription/actions/cancel","POST",{})}async getUsageStats(t,e,s,r){const n=[];e&&n.push("date_from="+encodeURIComponent(e)),s&&n.push("date_to="+encodeURIComponent(s)),r!=null&&r.length&&r.forEach(i=>n.push("model="+encodeURIComponent(i)));const a=n.length>0?"?"+n.join("&"):"";return this.request("/projects/"+t+"/subscription/usage-stats"+a,"GET")}async listUsages(t,e,s,r,n,a,i,p){const u=[];e&&u.push("date_from="+encodeURIComponent(e)),s&&u.push("date_to="+encodeURIComponent(s)),r!=null&&r.length&&r.forEach(g=>u.push("model="+encodeURIComponent(g))),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(g=>u.push("alias="+encodeURIComponent(g)));const H=u.length>0?"?"+u.join("&"):"";return this.request("/projects/"+t+"/subscription/usages"+H,"GET")}}class j extends c{constructor(t,e){super(t,e)}async get(t){return this.httpGet("/values/"+t)}async getLanguageCodes(){return this.httpGet("/values/language-codes")}async getModelNames(){return this.httpGet("/values/model-names")}async getModelProviders(){return this.httpGet("/values/model-providers")}async getKnowledgeTypes(){return this.httpGet("/values/knowledge-types")}async getCollaborationModes(){return this.httpGet("/values/collaboration-modes")}async getTranscriberNames(){return this.httpGet("/values/transcriber-names")}async getSynthesizerNames(){return this.httpGet("/values/synthesizer-names")}async getSynthesizerVoices(t){return this.httpGet("/values/synthesizers/"+t+"/voices")}async getDocumentExtractors(){return this.httpGet("/values/document-extractors")}async getEmbeddingModels(){return this.httpGet("/values/embedding-models")}async getQualityOptions(){return this.httpGet("/values/quality")}async getChunkSizeOptions(){return this.httpGet("/values/chunk-size")}async getFeatureTypes(){return this.httpGet("/values/feature-types")}async getRoles(){return this.httpGet("/values/roles")}async getServiceUnits(){return this.httpGet("/values/service-units")}async getTriggerSourceTypes(){return this.httpGet("/values/trigger-source-types")}async getTriggerDestinationTypes(){return this.httpGet("/values/trigger-destination-types")}}class O extends c{constructor(t,e){super(t,e)}async list(t,e,s,r){const{page:n,size:a}=this.normalizePageParams(s,r),i={page:n,size:a};return t&&(i.projectId=t),e&&(i.keyword=e),this.httpGet("/model-aliases",i)}async get(t){return this.httpGet("/model-aliases/"+t)}async create(t){return this.httpPost("/model-aliases",t)}async update(t,e){return this.httpPut("/model-aliases/"+t,e)}async remove(t){await this.httpDelete("/model-aliases/"+t)}async impact(t){return this.httpGet("/model-aliases/"+t+"/impact")}async check(t){return this.httpPost("/model-aliases/"+t+"/check")}async suggestions(t,e,s){const r={};return e&&(r.model=e),s!==void 0&&(r.limit=s),this.httpGet("/model-aliases/"+t+"/suggestions",r)}static inUse(t){var e,s;if(!(t instanceof l)||t.statusCode!==409)return null;try{const r=(s=(e=JSON.parse(t.body))==null?void 0:e.detail)==null?void 0:s.impact;return r&&typeof r.total=="number"?r:null}catch{return null}}}class q extends c{constructor(t,e){super(t,e)}async list(t={}){const{page:e,size:s}=this.normalizePageParams(t.page,t.size),r={page:e,size:s};return t.unreadOnly&&(r.unreadOnly=!0),t.includeResolved&&(r.includeResolved=!0),t.projectId&&(r.projectId=t.projectId),this.httpGet("/notifications",r)}async unreadCount(t){return(await this.httpGet("/notifications/unread-count",t?{projectId:t}:void 0)).count}async markRead(t){return this.httpPost("/notifications/"+t+"/read")}async markAllRead(t){await this.httpPost("/notifications/read-all",void 0,t?{projectId:t}:void 0)}}class _{constructor(t,e,s){h(this,"baseUrl");h(this,"workflowsBaseUrl");h(this,"billingBaseUrl");this.baseUrl=t,this.workflowsBaseUrl=e,this.billingBaseUrl=s||"https://persona.applica.guru/billing"}projects(t){return new m(this.baseUrl,t,this.billingBaseUrl)}agents(t){return new P(this.baseUrl,t)}knowledgeBases(t){return new f(this.baseUrl,t)}workflows(t){return new G(this.workflowsBaseUrl,t)}credentials(t){return new A(this.baseUrl,t)}features(t){return new U(this.baseUrl,t)}triggers(t){return new S(this.baseUrl,t)}servicePrices(t){return new T(this.baseUrl,t)}markupRules(t){return new R(this.baseUrl,t)}providers(t){return new C(this.baseUrl,t)}sessions(t){return new I(this.baseUrl,t)}missions(t){return new E(this.baseUrl,t)}billing(t){return new B(this.billingBaseUrl,t)}modelAliases(t){return new O(this.baseUrl,t)}notifications(t){return new q(this.baseUrl,t)}values(t){return new j(this.baseUrl,t)}}class J{constructor(t){this.token=t}applyHeaders(t){t.set("Authorization",`Bearer ${this.token}`)}getCredentials(){return this.token}}const d="alias:";function D(o){return!!o&&o.trim().toLowerCase().startsWith(d)}function L(o){if(!D(o))throw new Error(`Not a model alias reference: ${JSON.stringify(o)}`);return o.trim().slice(d.length).trim()}function F(o){return d+o.trim()}exports.ALIAS_PREFIX=d;exports.AgentsApi=P;exports.ApiException=l;exports.ApiKeyAuthenticationProvider=y;exports.BearerTokenAuthenticationProvider=J;exports.BillingClient=B;exports.ChannelsApi=k;exports.CredentialsApi=A;exports.FeatureTemplatesApi=z;exports.FeaturesApi=U;exports.HumanTasksApi=b;exports.KnowledgeBaseDocumentsApi=w;exports.KnowledgeBasesApi=f;exports.MarkupRulesApi=R;exports.MissionsApi=E;exports.ModelAliasesApi=O;exports.NotificationsApi=q;exports.PersonaSdk=_;exports.ProjectsApi=m;exports.ProvidersApi=C;exports.ServicePricesApi=T;exports.SessionsApi=I;exports.TriggerExecutionsApi=x;exports.TriggersApi=S;exports.ValuesApi=j;exports.WorkflowExecutionsApi=v;exports.WorkflowsApi=G;exports.aliasNameFromRef=L;exports.aliasRef=F;exports.isAliasRef=D;
|
|
2
2
|
//# sourceMappingURL=bundle.cjs.js.map
|