@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.
- package/.eslintrc.cjs +6 -5
- package/.nvmrc +1 -1
- package/.prettierignore +3 -5
- package/.prettierrc +3 -5
- package/README.md +247 -2
- package/bitbucket-pipelines.yml +2 -12
- package/dist/bundle.cjs.js +1 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +472 -699
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1089 -5
- package/package.json +9 -39
- package/src/agents/agents-api.ts +54 -0
- package/src/agents/types.ts +346 -0
- package/src/auth/api-key-auth.ts +13 -0
- package/src/auth/authentication-provider.ts +4 -0
- package/src/auth/bearer-token-auth.ts +13 -0
- package/src/auth/index.ts +3 -0
- package/src/credentials/credentials-api.ts +40 -0
- package/src/credentials/types.ts +67 -0
- package/src/exceptions.ts +10 -0
- package/src/features/feature-templates-api.ts +41 -0
- package/src/features/features-api.ts +16 -0
- package/src/features/types.ts +25 -0
- package/src/http-api.ts +95 -0
- package/src/index.ts +153 -4
- package/src/knowledges/knowledge-base-documents-api.ts +38 -0
- package/src/knowledges/knowledge-bases-api.ts +47 -0
- package/src/knowledges/types.ts +70 -0
- package/src/missions/missions-api.ts +60 -0
- package/src/missions/types.ts +25 -0
- package/src/paginated.ts +6 -0
- package/src/persona-sdk.ts +81 -0
- package/src/projects/projects-api.ts +55 -0
- package/src/projects/types.ts +42 -0
- package/src/revisions/types.ts +9 -0
- package/src/service-prices/service-prices-api.ts +32 -0
- package/src/service-prices/types.ts +8 -0
- package/src/sessions/sessions-api.ts +55 -0
- package/src/sessions/types.ts +129 -0
- package/src/triggers/trigger-executions-api.ts +27 -0
- package/src/triggers/triggers-api.ts +37 -0
- package/src/triggers/types.ts +50 -0
- package/src/workflows/types.ts +150 -0
- package/src/workflows/workflow-executions-api.ts +27 -0
- package/src/workflows/workflows-api.ts +51 -0
- package/tsconfig.json +20 -28
- package/vite.config.ts +20 -62
- package/dist/bundle.iife.js +0 -15
- package/dist/bundle.iife.js.map +0 -1
- package/dist/bundle.umd.js +0 -15
- package/dist/bundle.umd.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging.d.ts +0 -18
- package/dist/logging.d.ts.map +0 -1
- package/dist/messages.d.ts +0 -7
- package/dist/messages.d.ts.map +0 -1
- package/dist/protocol/base.d.ts +0 -23
- package/dist/protocol/base.d.ts.map +0 -1
- package/dist/protocol/index.d.ts +0 -5
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/rest.d.ts +0 -22
- package/dist/protocol/rest.d.ts.map +0 -1
- package/dist/protocol/webrtc.d.ts +0 -56
- package/dist/protocol/webrtc.d.ts.map +0 -1
- package/dist/protocol/websocket.d.ts +0 -22
- package/dist/protocol/websocket.d.ts.map +0 -1
- package/dist/runtime.d.ts +0 -21
- package/dist/runtime.d.ts.map +0 -1
- package/dist/types.d.ts +0 -79
- package/dist/types.d.ts.map +0 -1
- package/jsconfig.node.json +0 -10
- package/playground/index.html +0 -14
- package/playground/src/app.tsx +0 -10
- package/playground/src/chat.tsx +0 -52
- package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
- package/playground/src/components/assistant-ui/markdown-text.tsx +0 -119
- package/playground/src/components/assistant-ui/thread-list.tsx +0 -62
- package/playground/src/components/assistant-ui/thread.tsx +0 -249
- package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -33
- package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -38
- package/playground/src/components/ui/avatar.tsx +0 -35
- package/playground/src/components/ui/button.tsx +0 -43
- package/playground/src/components/ui/tooltip.tsx +0 -32
- package/playground/src/lib/utils.ts +0 -6
- package/playground/src/main.tsx +0 -10
- package/playground/src/styles.css +0 -1
- package/playground/src/vite-env.d.ts +0 -1
- package/preview.sh +0 -13
- package/src/logging.ts +0 -34
- package/src/messages.ts +0 -79
- package/src/protocol/base.ts +0 -55
- package/src/protocol/index.ts +0 -4
- package/src/protocol/rest.ts +0 -66
- package/src/protocol/webrtc.ts +0 -339
- package/src/protocol/websocket.ts +0 -108
- package/src/runtime.tsx +0 -217
- package/src/types.ts +0 -98
- package/tsconfig.node.json +0 -15
package/.eslintrc.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
|
-
env: { browser: true,
|
|
4
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
|
|
5
|
-
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
3
|
+
env: { node: true, browser: true, es2022: true },
|
|
6
4
|
parser: '@typescript-eslint/parser',
|
|
7
|
-
|
|
5
|
+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
6
|
+
plugins: ['@typescript-eslint', 'prettier'],
|
|
7
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
|
8
8
|
rules: {
|
|
9
|
-
'
|
|
9
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
10
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
10
11
|
},
|
|
11
12
|
};
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
22
|
package/.prettierignore
CHANGED
package/.prettierrc
CHANGED
package/README.md
CHANGED
|
@@ -1,3 +1,248 @@
|
|
|
1
|
-
# Persona SDK
|
|
1
|
+
# Persona SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@applica-software-guru/persona-sdk)
|
|
4
|
+
|
|
5
|
+
Official TypeScript SDK for the Persona API. Manage agents, sessions, projects, knowledge bases, workflows, triggers, missions and more from any JavaScript/TypeScript application.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @applica-software-guru/persona-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { PersonaSdk } from '@applica-software-guru/persona-sdk';
|
|
17
|
+
|
|
18
|
+
const sdk = new PersonaSdk(
|
|
19
|
+
'https://persona.applica.guru/api',
|
|
20
|
+
'https://persona.applica.guru/workflows'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Authenticate with API key
|
|
24
|
+
const agents = await sdk.agents('your-api-key').list(null, 1, 20);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Authentication
|
|
28
|
+
|
|
29
|
+
The SDK supports two authentication methods:
|
|
30
|
+
|
|
31
|
+
### API Key (default)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const projects = await sdk.projects('your-api-key').getMine();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Bearer Token (IAM)
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { BearerTokenAuthenticationProvider } from '@applica-software-guru/persona-sdk';
|
|
41
|
+
|
|
42
|
+
const auth = new BearerTokenAuthenticationProvider('your-iam-token');
|
|
43
|
+
const projects = await sdk.projects(auth).getMine();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage Examples
|
|
47
|
+
|
|
48
|
+
### Agents
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const agentsApi = sdk.agents('your-api-key');
|
|
52
|
+
|
|
53
|
+
// List agents
|
|
54
|
+
const { items, total } = await agentsApi.list('search-term', 1, 20);
|
|
55
|
+
|
|
56
|
+
// Get a single agent
|
|
57
|
+
const agent = await agentsApi.get('agent-id');
|
|
58
|
+
|
|
59
|
+
// Create an agent
|
|
60
|
+
const agent = await agentsApi.create({
|
|
61
|
+
name: 'My Agent',
|
|
62
|
+
description: 'A helpful assistant',
|
|
63
|
+
systemInstructions: 'You are a helpful assistant.',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Update an agent
|
|
67
|
+
const updated = await agentsApi.update({
|
|
68
|
+
id: 'agent-id',
|
|
69
|
+
name: 'Updated Name',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Delete an agent
|
|
73
|
+
await agentsApi.remove('agent-id');
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Sessions
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const sessionsApi = sdk.sessions('your-api-key');
|
|
80
|
+
|
|
81
|
+
// List sessions
|
|
82
|
+
const sessions = await sessionsApi.list(null, null, null, null, 1, 20);
|
|
83
|
+
|
|
84
|
+
// Generate a message
|
|
85
|
+
const response = await sessionsApi.generateMessage('session-code', {
|
|
86
|
+
userMessage: 'Hello, how are you?',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Get session messages
|
|
90
|
+
const messages = await sessionsApi.findMessages('session-code', 1, 50);
|
|
91
|
+
|
|
92
|
+
// Get usage info
|
|
93
|
+
const usage = await sessionsApi.getUsage('session-id');
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Projects
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const projectsApi = sdk.projects('your-api-key');
|
|
100
|
+
|
|
101
|
+
// Get current project
|
|
102
|
+
const project = await projectsApi.getMine();
|
|
103
|
+
|
|
104
|
+
// Create a project
|
|
105
|
+
const project = await projectsApi.create({ name: 'My Project' });
|
|
106
|
+
|
|
107
|
+
// Get subscription info
|
|
108
|
+
const subscription = await projectsApi.getSubscription('project-id');
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Knowledge Bases
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const kbApi = sdk.knowledgeBases('your-api-key');
|
|
115
|
+
|
|
116
|
+
// List knowledge bases
|
|
117
|
+
const knowledgeBases = await kbApi.list(null, 1, 20);
|
|
118
|
+
|
|
119
|
+
// Create a knowledge base
|
|
120
|
+
const kb = await kbApi.create({ name: 'My Knowledge Base' });
|
|
121
|
+
|
|
122
|
+
// Upload a document
|
|
123
|
+
const doc = await kbApi.documents(kb.id).upload({
|
|
124
|
+
name: 'document.pdf',
|
|
125
|
+
uri: 'https://example.com/document.pdf',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Search chunks
|
|
129
|
+
const chunks = await kbApi.searchChunks(kb.id, { query: 'search term', limit: 5 });
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Workflows
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const workflowsApi = sdk.workflows('your-api-key');
|
|
136
|
+
|
|
137
|
+
// List workflows
|
|
138
|
+
const workflows = await workflowsApi.list(null, 1, 20);
|
|
139
|
+
|
|
140
|
+
// Execute a workflow
|
|
141
|
+
const execution = await workflowsApi.executions().run('workflow-id', {
|
|
142
|
+
userId: 'user-123',
|
|
143
|
+
initialData: { key: 'value' },
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Credentials
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const credentialsApi = sdk.credentials('your-api-key');
|
|
151
|
+
|
|
152
|
+
// List credentials
|
|
153
|
+
const creds = await credentialsApi.list();
|
|
154
|
+
|
|
155
|
+
// Authorize OAuth2
|
|
156
|
+
const result = await credentialsApi.authorize('google', {
|
|
157
|
+
name: 'My Google Account',
|
|
158
|
+
clientId: '...',
|
|
159
|
+
clientSecret: '...',
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Triggers
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const triggersApi = sdk.triggers('your-api-key');
|
|
167
|
+
|
|
168
|
+
// List triggers
|
|
169
|
+
const triggers = await triggersApi.list(null, 1, 20);
|
|
170
|
+
|
|
171
|
+
// Execute a trigger
|
|
172
|
+
const result = await triggersApi.executions().execute('trigger-id', {});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Features
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
const featuresApi = sdk.features('your-api-key');
|
|
179
|
+
|
|
180
|
+
// List feature templates
|
|
181
|
+
const templates = await featuresApi.templates().list(null, 1, 20);
|
|
182
|
+
|
|
183
|
+
// Get MCP available tools
|
|
184
|
+
const tools = await featuresApi.templates().getMcpAvailableTools({
|
|
185
|
+
type: 'mcp',
|
|
186
|
+
name: 'my-server',
|
|
187
|
+
transport: { url: 'https://mcp.example.com' },
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Missions
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
const missionsApi = sdk.missions('your-api-key');
|
|
195
|
+
|
|
196
|
+
// List missions
|
|
197
|
+
const missions = await missionsApi.list(null, null, 1, 20);
|
|
198
|
+
|
|
199
|
+
// Create and execute
|
|
200
|
+
const mission = await missionsApi.create({ name: 'My Mission' });
|
|
201
|
+
await missionsApi.execute(mission.id);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Error Handling
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { ApiException } from '@applica-software-guru/persona-sdk';
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const agent = await sdk.agents('api-key').get('invalid-id');
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (error instanceof ApiException) {
|
|
213
|
+
console.error(`API Error ${error.statusCode}: ${error.body}`);
|
|
214
|
+
} else {
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## API Reference
|
|
221
|
+
|
|
222
|
+
| Resource | Methods |
|
|
223
|
+
|---|---|
|
|
224
|
+
| **ProjectsApi** | `list`, `get`, `getMine`, `create`, `update`, `remove`, `getSubscription`, `changeSubscriptionPlan`, `addSubscriptionCredits` |
|
|
225
|
+
| **AgentsApi** | `list`, `get`, `create`, `update`, `remove`, `getSynthesizerSupportedVoices`, `listRevisions`, `getRevision`, `rollback` |
|
|
226
|
+
| **SessionsApi** | `list`, `get`, `getUsage`, `generateMessage`, `findMessages`, `remove` |
|
|
227
|
+
| **KnowledgeBasesApi** | `list`, `get`, `create`, `update`, `remove`, `documents()`, `searchChunks` |
|
|
228
|
+
| **KnowledgeBaseDocumentsApi** | `list`, `upload`, `get`, `reprocess`, `remove` |
|
|
229
|
+
| **WorkflowsApi** | `list`, `create`, `update`, `remove`, `get`, `executions()`, `listRevisions`, `getRevision`, `rollback` |
|
|
230
|
+
| **WorkflowExecutionsApi** | `list`, `get`, `run`, `queue` |
|
|
231
|
+
| **CredentialsApi** | `authorize`, `handleOAuth2Callback`, `list`, `getByProvider`, `getById`, `remove` |
|
|
232
|
+
| **TriggersApi** | `list`, `create`, `update`, `remove`, `get`, `executions()` |
|
|
233
|
+
| **TriggerExecutionsApi** | `list`, `execute`, `get`, `remove` |
|
|
234
|
+
| **FeaturesApi** | `templates()` |
|
|
235
|
+
| **FeatureTemplatesApi** | `list`, `get`, `create`, `update`, `patch`, `remove`, `getMcpAvailableTools` |
|
|
236
|
+
| **MissionsApi** | `list`, `get`, `create`, `update`, `remove`, `generate`, `execute`, `retry`, `replan`, `sendInstruction`, `stop`, `resume` |
|
|
237
|
+
| **ServicePricesApi** | `list`, `get`, `create`, `update`, `remove` |
|
|
238
|
+
|
|
239
|
+
## Compatibility
|
|
240
|
+
|
|
241
|
+
- **Runtime**: Browser (Chrome, Firefox, Safari, Edge), Node.js 18+
|
|
242
|
+
- **Frameworks**: React, Vue, Angular, Svelte, Next.js, Vite, Webpack
|
|
243
|
+
- **Module systems**: ESM, CommonJS
|
|
244
|
+
- **TypeScript**: Full type definitions included
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT
|
package/bitbucket-pipelines.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
image: node:
|
|
1
|
+
image: node:22
|
|
2
2
|
|
|
3
3
|
pipelines:
|
|
4
4
|
branches:
|
|
@@ -7,7 +7,7 @@ pipelines:
|
|
|
7
7
|
name: Deploy
|
|
8
8
|
deployment: Production
|
|
9
9
|
script:
|
|
10
|
-
- export VERSION=1
|
|
10
|
+
- export VERSION=0.1
|
|
11
11
|
- npm --no-git-tag-version version "$VERSION.$BITBUCKET_BUILD_NUMBER" -m "Upgrade to new version"
|
|
12
12
|
- npm install
|
|
13
13
|
- npm run build
|
|
@@ -15,15 +15,5 @@ pipelines:
|
|
|
15
15
|
variables:
|
|
16
16
|
NPM_TOKEN: $NPM_TOKEN
|
|
17
17
|
EXTRA_ARGS: '--access public'
|
|
18
|
-
- echo $SERVICE_ACCOUNT > key.json
|
|
19
|
-
- curl -sSL https://sdk.cloud.google.com | bash > /dev/null
|
|
20
|
-
- export PATH=$PATH:/root/google-cloud-sdk/bin
|
|
21
|
-
- gcloud auth activate-service-account --key-file=key.json
|
|
22
|
-
- rm key.json
|
|
23
|
-
- gcloud config set project persona-ai-1
|
|
24
|
-
- gsutil rm -r gs://persona-cdn/sdk/latest/*
|
|
25
|
-
- gsutil cp -r dist/* gs://persona-cdn/sdk/$VERSION.$BITBUCKET_BUILD_NUMBER
|
|
26
|
-
- gsutil cp -r dist/* gs://persona-cdn/sdk/latest
|
|
27
|
-
- gsutil cp -r dist/* gs://persona-cdn/sdk/$VERSION.$BITBUCKET_BUILD_NUMBER
|
|
28
18
|
- git tag -a "$VERSION.$BITBUCKET_BUILD_NUMBER" -m "Version $VERSION.$BITBUCKET_BUILD_NUMBER"
|
|
29
19
|
- git push origin "$VERSION.$BITBUCKET_BUILD_NUMBER"
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
"use strict";var ie=Object.defineProperty;var ce=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var i=(r,t,e)=>ce(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),te=require("@assistant-ui/react");var ne={exports:{}},O={},se;function le(){if(se)return O;se=1;/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.development.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/return function(){function r(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===j?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case k:return"Fragment";case W:return"Profiler";case $:return"StrictMode";case S:return"Suspense";case C:return"SuspenseList";case v:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case I:return"Portal";case z:return(s.displayName||"Context")+".Provider";case D:return(s._context.displayName||"Context")+".Consumer";case u:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case x:return a=s.displayName||null,a!==null?a:r(s.type)||"Memo";case p:a=s._payload,s=s._init;try{return r(s(a))}catch{}}return null}function t(s){return""+s}function e(s){try{t(s);var a=!1}catch{a=!0}if(a){a=console;var l=a.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return l.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),t(s)}}function n(s){if(s===k)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===p)return"<...>";try{var a=r(s);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function o(){var s=A.A;return s===null?null:s.getOwner()}function c(){return Error("react-stack-top-frame")}function d(s){if(G.call(s,"key")){var a=Object.getOwnPropertyDescriptor(s,"key").get;if(a&&a.isReactWarning)return!1}return s.key!==void 0}function b(s,a){function l(){X||(X=!0,console.error("%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)",a))}l.isReactWarning=!0,Object.defineProperty(s,"key",{get:l,configurable:!0})}function h(){var s=r(this.type);return H[s]||(H[s]=!0,console.error("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.")),s=this.props.ref,s!==void 0?s:null}function f(s,a,l,m,E,P,F,U){return l=P.ref,s={$$typeof:_,type:s,key:a,props:P,_owner:E},(l!==void 0?l:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:h}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:F}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function w(s,a,l,m,E,P,F,U){var g=a.children;if(g!==void 0)if(m)if(ae(g)){for(m=0;m<g.length;m++)N(g[m]);Object.freeze&&Object.freeze(g)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(g);if(G.call(a,"key")){g=r(s);var T=Object.keys(a).filter(function(oe){return oe!=="key"});m=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",ee[g+m]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
10
|
-
let props = %s;
|
|
11
|
-
<%s {...props} />
|
|
12
|
-
React keys must be passed directly to JSX without using spread:
|
|
13
|
-
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,m,g,T,g),ee[g+m]=!0)}if(g=null,l!==void 0&&(e(l),g=""+l),d(a)&&(e(a.key),g=""+a.key),"key"in a){l={};for(var Y in a)Y!=="key"&&(l[Y]=a[Y])}else l=a;return g&&b(l,typeof s=="function"?s.displayName||s.name||"Unknown":s),f(s,g,P,E,o(),l,F,U)}function N(s){typeof s=="object"&&s!==null&&s.$$typeof===_&&s._store&&(s._store.validated=1)}var R=y,_=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),z=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),A=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,ae=Array.isArray,L=console.createTask?console.createTask:function(){return null};R={"react-stack-bottom-frame":function(s){return s()}};var X,H={},Z=R["react-stack-bottom-frame"].bind(R,c)(),Q=L(n(c)),ee={};O.Fragment=k,O.jsx=function(s,a,l,m,E){var P=1e4>A.recentlyCreatedOwnerStacks++;return w(s,a,l,!1,m,E,P?Error("react-stack-top-frame"):Z,P?L(n(s)):Q)},O.jsxs=function(s,a,l,m,E){var P=1e4>A.recentlyCreatedOwnerStacks++;return w(s,a,l,!0,m,E,P?Error("react-stack-top-frame"):Z,P?L(n(s)):Q)}}(),O}ne.exports=le();var K=ne.exports;function ue(r){return r.filter(t=>{var e;return t.finishReason==="stop"?t.text!==null&&((e=t.text)==null?void 0:e.trim())!=="":!0})}function de(r){const t=[];let e=null;for(const n of r)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]={...t[t.length-1],functionResponse:n.functionResponse}:e&&n.protocol===e.protocol&&(e.role===n.role||n.finishReason==="stop")?e.text+=n.text:(e&&t.push(e),e={...n});return e&&t.push(e),ue(t)}function he(r){var t;return r.role==="function"?{id:r.id,role:"assistant",status:(r==null?void 0:r.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((t=r.functionCalls)==null?void 0:t.map(e=>{var n;return{type:"tool-call",toolName:e.name,toolCallId:e.id,args:e.args,result:(n=r.functionResponse)==null?void 0:n.result}}))??[]}:{id:r.id,role:r.role,content:r.type==="reasoning"?[{type:"reasoning",text:r.text}]:[{type:"text",text:r.text}]}}class M{constructor(){i(this,"statusChangeCallbacks",[]);i(this,"messageCallbacks",[])}addStatusChangeListener(t){this.statusChangeCallbacks.push(t)}addMessageListener(t){this.messageCallbacks.push(t)}async syncSession(t){this.session=t}async notifyMessage(t){this.messageCallbacks.forEach(e=>e(t))}async notifyMessages(t){t.forEach(e=>{this.messageCallbacks.forEach(n=>n(e))})}async setSession(t){this.session=t}async setStatus(t){const e=this.status!==t;this.status=t,e&&this.statusChangeCallbacks.forEach(n=>n(t))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}}class q extends M{constructor(e){super();i(this,"status");i(this,"autostart");i(this,"session");i(this,"config");i(this,"notify",!0);this.config=e,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 0}async connect(e){return this.setStatus("connected"),e}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(e){this.session=e}async send(e){const{apiUrl:n,apiKey:o,agentId:c}=this.config,d=this.session??"new",b=e,f=await(await fetch(`${n}/agents/${c}/sessions/${d}/messages`,{body:JSON.stringify({userMessage:b}),method:"POST",headers:{"Content-Type":"application/json","x-fox-apikey":o,"x-persona-apikey":o}})).json();this.notifyMessages(f.response.messages)}}class J extends M{constructor(e){super();i(this,"status");i(this,"autostart");i(this,"session");i(this,"config");i(this,"webSocket");this.config=e,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 1}async syncSession(e){var n;(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))}connect(e){var b;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const n=e||this.session||"new";(b=this.config.logger)==null||b.debug("Connecting to WebSocket with sessionId:",n);const o=encodeURIComponent(this.config.apiKey),c=this.config.agentId,d=`${this.config.webSocketUrl}?sessionCode=${n}&agentId=${c}&apiKey=${o}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(d),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",h=>{const f=JSON.parse(h.data);if(f.type!=="message")return;const w=f.payload;this.notifyMessage(w!=null&&w.thought?{role:"assistant",type:"reasoning",text:w.thought}:w)}),this.webSocket.addEventListener("close",()=>{var h;this.setStatus("disconnected"),this.webSocket=null,(h=this.config.logger)==null||h.warn("WebSocket connection closed")}),this.webSocket.addEventListener("error",h=>{var f;this.setStatus("disconnected"),this.webSocket=null,(f=this.config.logger)==null||f.error("WebSocket error",h)}),Promise.resolve(n)}disconnect(){var e;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()}send(e){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"))}}class fe{constructor(t){i(this,"config");i(this,"pc",null);i(this,"ws",null);i(this,"localStream",null);i(this,"remoteStream",new MediaStream);i(this,"audioCtx",null);i(this,"localAnalyser",null);i(this,"remoteAnalyser",null);i(this,"analyzerFrame",null);i(this,"dataChannel",null);i(this,"isConnected",!1);i(this,"visualizerCallbacks",[]);i(this,"messageCallbacks",[]);this.config=t}async connect(t){var e;if(!this.isConnected){this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(n){(e=this.config.logger)==null||e.error("Error accessing microphone:",n);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(n=>{this.pc.addTrack(n,this.localStream)}),this.pc.ontrack=n=>{n.streams[0].getTracks().forEach(c=>{this.remoteStream.addTrack(c)}),this.audioCtx||this._startAnalyzers();const o=new Audio;o.srcObject=this.remoteStream,o.play().catch(c=>{var d;(d=this.config.logger)==null||d.error("Error playing remote audio:",c)})},this.pc.onicecandidate=n=>{var o;n.candidate&&((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:n.candidate}}))},this.pc.ondatachannel=n=>{const o=n.channel;o.onmessage=c=>{this.messageCallbacks.forEach(d=>{d(c)})}},this.ws=new WebSocket(this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc"),this.ws.onopen=async()=>{var d,b;const n=await this.pc.createOffer();await this.pc.setLocalDescription(n);const o={agentId:this.config.agentId,sessionCode:t};(d=this.config.logger)==null||d.debug("Opening connection to WebRTC server: ",o);const c={type:"OFFER",src:((b=crypto.randomUUID)==null?void 0:b.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:n.sdp,type:n.type},connectionId:(Date.now()%1e6).toString(),metadata:o}};this.ws.send(JSON.stringify(c))},this.ws.onmessage=async n=>{var c;const o=JSON.parse(n.data);if(o.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(o.payload.sdp));else if(o.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(o.payload.candidate))}catch(d){(c=this.config.logger)==null||c.error("Error adding ICE candidate:",d)}},this.ws.onclose=()=>{this._stopAnalyzers()}}}async disconnect(){var t;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())}addVisualizerCallback(t){this.visualizerCallbacks.push(t)}addMessageCallback(t){this.messageCallbacks.push(t)}createDataChannel(t="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(t),this.dataChannel.onopen=()=>{var e;return(e=this.config.logger)==null?void 0:e.info("Data channel opened")},this.dataChannel.onmessage=e=>{this.messageCallbacks.forEach(n=>{n(e)})})}sendMessage(t){var e,n;if(!this.dataChannel){(e=this.config.logger)==null||e.warn("Data channel is not open, cannot send message");return}this.dataChannel.send(t),(n=this.config.logger)==null||n.info("Sent message:",t)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const t=this.audioCtx.createMediaStreamSource(this.localStream),e=this.audioCtx.createMediaStreamSource(this.remoteStream);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);const n=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const o=new Uint8Array(this.localAnalyser.frequencyBinCount),c=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(o),this.remoteAnalyser.getByteFrequencyData(c);const d=o.reduce((h,f)=>h+f,0)/o.length,b=c.reduce((h,f)=>h+f,0)/c.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(h=>{h({localAmplitude:d,remoteAmplitude:b})}),this.analyzerFrame=requestAnimationFrame(n)};this.analyzerFrame=requestAnimationFrame(n)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class B extends M{constructor(e){super();i(this,"status");i(this,"session");i(this,"autostart");i(this,"config");i(this,"webRTCClient");this.config=e,this.status="disconnected",this.session=null,this.autostart=(e==null?void 0:e.autostart)??!1,this.webRTCClient=new fe(e),this.webRTCClient.addMessageCallback(n=>{var c;(c=e.logger)==null||c.debug("Received data message:",n.data);const o=JSON.parse(n.data);o.type==="message"&&this.notifyMessage(o.payload)})}getName(){return"webrtc"}getPriority(){return 10}async syncSession(e){super.syncSession(e),this.status==="connected"&&(await this.disconnect(),await this.connect(e))}async connect(e){var n;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)}async disconnect(){var e,n,o;if(this.status==="disconnected")return(e=this.config.logger)==null||e.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(o=(n=this.config)==null?void 0:n.logger)==null||o.debug("Disconnected from WebRTC")}send(e){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendMessage(e),Promise.resolve())}}const V=y.createContext(void 0);function me({dev:r=!1,protocols:t,logger:e,children:n,session:o="new",...c}){const[d,b]=y.useState(!1),[h,f]=y.useState([]),[w,N]=y.useState(o),[R,_]=y.useState(new Map),I=y.useRef(!1),k=y.useMemo(()=>{if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null){const u=r?"localhost:8000":"persona.applica.guru/api",S=r?"http":"https",C=r?"ws":"wss";return Object.keys(t).map(p=>{switch(p){case"rest":const v=t[p];return v===!0?new q({apiUrl:`${S}://${u}`,apiKey:c.apiKey,agentId:c.agentId,logger:e}):new q(v);case"webrtc":const j=t[p];return j===!0?new B({webrtcUrl:`${C}://${u}/webrtc`,apiKey:c.apiKey,agentId:c.agentId,logger:e}):new B(j);case"websocket":const A=t[p];return A===!0?new J({webSocketUrl:`${C}://${u}/websocket`,apiKey:c.apiKey,agentId:c.agentId,logger:e}):new J(A);default:throw new Error(`Unknown protocol: ${p}`)}})}throw new Error("Invalid protocols configuration")},[]);y.useEffect(()=>{I.current||(I.current=!0,e==null||e.debug("Initializing protocols: ",k.map(u=>u.getName())),k.forEach(u=>{u.setSession(w),u.clearListeners(),u.addStatusChangeListener(S=>{e==null||e.debug(`${u.getName()} has notified new status: ${S}`),R.set(u.getName(),S),_(new Map(R))}),u.addMessageListener(S=>{f(C=>de([...C,{...S,protocol:u.getName()}]))}),u.autostart&&u.status==="disconnected"&&(e==null||e.debug(`Connecting to protocol: ${u.getName()}`),u.connect(w))}))},[w,k,e,R]);const $=async u=>{var x;if(((x=u.content[0])==null?void 0:x.type)!=="text")throw new Error("Only text messages are supported");const S=u.content[0].text;f(p=>[...p,{role:"user",type:"text",text:S}]),b(!0);const C=k.sort((p,v)=>v.getPriority()-p.getPriority()).find(p=>p.status==="connected");await(C==null?void 0:C.send(S)),b(!1)},W=y.useCallback(()=>(b(!1),f([]),N("new"),Promise.resolve()),[]),D=y.useCallback(()=>Promise.resolve(),[]),z=te.useExternalStoreRuntime({isRunning:d,messages:h,convertMessage:he,onNew:$,onCancel:W,onReload:D});return K.jsx(V.Provider,{value:{protocols:k,protocolsStatus:R},children:K.jsx(te.AssistantRuntimeProvider,{runtime:z,children:n})})}function ge({children:r,...t}){return K.jsx(me,{...t,children:r})}function be(){const r=y.useContext(V);if(!r)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return r}function re(r){const t=y.useContext(V);if(!t)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const e=t.protocols.find(o=>o.getName()===r);if(!e)return null;const n=t.protocolsStatus.get(e.getName());return{...e,connect:e.connect.bind(e),disconnect:e.disconnect.bind(e),send:e.send.bind(e),setSession:e.setSession.bind(e),addStatusChangeListener:e.addStatusChangeListener.bind(e),addMessageListener:e.addMessageListener.bind(e),getName:e.getName.bind(e),getPriority:e.getPriority.bind(e),status:n||e.status}}function pe(){return re("webrtc")}class ye{constructor(){i(this,"prefix","[Persona]")}log(t,...e){console.log(`${this.prefix} - ${t}`,...e)}info(t,...e){console.info(`${this.prefix} - ${t}`,...e)}warn(t,...e){console.warn(`${this.prefix} - ${t}`,...e)}error(t,...e){console.error(`${this.prefix} - ${t}`,...e)}debug(t,...e){console.debug(`${this.prefix} - ${t}`,...e)}}exports.PersonaConsoleLogger=ye;exports.PersonaProtocolBase=M;exports.PersonaRESTProtocol=q;exports.PersonaRuntimeProvider=ge;exports.PersonaWebRTCProtocol=B;exports.PersonaWebSocketProtocol=J;exports.usePersonaRuntime=be;exports.usePersonaRuntimeProtocol=re;exports.usePersonaRuntimeWebRTCProtocol=pe;
|
|
1
|
+
"use strict";var U=Object.defineProperty;var B=(n,t,s)=>t in n?U(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var o=(n,t,s)=>B(n,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class h extends Error{constructor(s,e){super(`API Error: ${s} - ${e}`);o(this,"statusCode");o(this,"body");this.statusCode=s,this.body=e}}class u{constructor(t){this.apiKey=t}applyHeaders(t){t.set("x-persona-apikey",this.apiKey)}getCredentials(){return this.apiKey}}class a{constructor(t,s){o(this,"baseUrl");o(this,"authProvider");this.baseUrl=t,this.authProvider=typeof s=="string"?new u(s):s}getBaseUrl(){return this.baseUrl}getAuthProvider(){return this.authProvider}buildHeaders(){const t=new Headers;return t.set("Content-Type","application/json"),this.authProvider.applyHeaders(t),t}buildUrl(t,s){const e=new URL(this.baseUrl+t);return s&&Object.entries(s).forEach(([r,i])=>{i!=null&&e.searchParams.set(r,String(i))}),e.toString()}async handleResponse(t){if(!t.ok){const e=await t.text();throw new h(t.status,e)}const s=await t.text();return s?JSON.parse(s):void 0}async httpGet(t,s){const e=await fetch(this.buildUrl(t,s),{method:"GET",headers:this.buildHeaders()});return this.handleResponse(e)}async httpPost(t,s){const e=await fetch(this.baseUrl+t,{method:"POST",headers:this.buildHeaders(),body:s?JSON.stringify(s):void 0});return this.handleResponse(e)}async httpPut(t,s){const e=await fetch(this.baseUrl+t,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify(s)});return this.handleResponse(e)}async httpPatch(t,s){const e=await fetch(this.baseUrl+t,{method:"PATCH",headers:this.buildHeaders(),body:JSON.stringify(s)});return this.handleResponse(e)}async httpDelete(t){const s=await fetch(this.baseUrl+t,{method:"DELETE",headers:this.buildHeaders()});if(!s.ok){const e=await s.text();throw new h(s.status,e)}}}class p extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/projects",r)}async get(t){return this.httpGet("/projects/"+t)}async getMine(){return this.httpGet("/projects/mine")}async create(t){return this.httpPost("/projects",t)}async update(t){return this.httpPut("/projects/"+t.projectId,t)}async remove(t){await this.httpDelete("/projects/"+t)}async getSubscription(t){return this.httpGet("/projects/"+t+"/subscription")}async changeSubscriptionPlan(t,s){return this.httpPost("/projects/"+t+"/subscription/plan",s)}async addSubscriptionCredits(t,s){return this.httpPost("/projects/"+t+"/subscription/credits",s)}}class l extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/agents",r)}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,s){return this.httpGet("/agents/"+t+"/revisions/"+s)}async rollback(t,s){return this.httpPost("/agents/"+t+"/revisions/"+s+"/rollback",{})}}class d extends a{constructor(s,e,r){super(s,e);o(this,"knowledgeBaseId");this.knowledgeBaseId=r}async list(s,e,r){const i={page:e,size:r};return s&&(i.keyword=s),this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents",i)}async upload(s){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",s)}async get(s){return this.httpGet("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+s)}async reprocess(s){return this.httpPost("/knowledge-bases/"+this.knowledgeBaseId+"/documents",{document_id:s})}async remove(s){await this.httpDelete("/knowledge-bases/"+this.knowledgeBaseId+"/documents/"+s)}}class y extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/knowledge-bases",r)}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 d(this.getBaseUrl(),this.getAuthProvider(),t)}async searchChunks(t,s){return this.httpPost("/knowledge-bases/"+t+"/search",s)}}class g extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return this.httpGet("/workflows/"+t+"/executions",r)}async get(t,s){return this.httpGet("/workflows/"+t+"/executions/"+s)}async run(t,s){return this.httpPost("/workflows/"+t+"/executions",s)}async queue(t,s){return this.httpPost("/workflows/"+t+"/executions/queue",s)}}class w extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/workflows",r)}async create(t){return this.httpPost("/workflows",t)}async update(t,s){return s.id=t,this.httpPut("/workflows/"+t,s)}async remove(t){await this.httpDelete("/workflows/"+t)}async get(t){return this.httpGet("/workflows/"+t)}executions(){return new g(this.getBaseUrl(),this.getAuthProvider())}async listRevisions(t){return this.httpGet("/workflows/"+t+"/revisions")}async getRevision(t,s){return this.httpGet("/workflows/"+t+"/revisions/"+s)}async rollback(t,s){return this.httpPost("/workflows/"+t+"/revisions/"+s+"/rollback",{})}}class m extends a{constructor(t,s){super(t,s)}async authorize(t,s){return this.httpPost("/credentials/"+t+"/authorize",s)}async handleOAuth2Callback(t,s,e,r){const i={code:s,state:e};return r&&(i.scope=r),this.httpGet("/credentials/"+t+"/oauth2/callback",i)}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 P extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/features/templates",r)}async get(t){return this.httpGet("/features/templates/"+t)}async create(t){return this.httpPost("/features/templates",t)}async update(t,s){return this.httpPut("/features/templates/"+t,s)}async patch(t,s){return this.httpPatch("/features/templates/"+t,s)}async remove(t){await this.httpDelete("/features/templates/"+t)}async getMcpAvailableTools(t){return this.httpPost("/features/templates/mcp/available-tools",t)}}class b{constructor(t,s){o(this,"baseUrl");o(this,"auth");this.baseUrl=t,this.auth=s}templates(){return new P(this.baseUrl,this.auth)}}class f extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return this.httpGet("/triggers/"+t+"/executions",r)}async execute(t,s){return this.httpPost("/triggers/"+t+"/executions",s)}async get(t){return this.httpGet("/triggers/executions/"+t)}async remove(t){await this.httpDelete("/triggers/executions/"+t)}}class k extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/triggers",r)}async create(t){return this.httpPost("/triggers",t)}async update(t,s){return this.httpPut("/triggers/"+t,s)}async remove(t){await this.httpDelete("/triggers/"+t)}async get(t){return this.httpGet("/triggers/"+t)}executions(){return new f(this.getBaseUrl(),this.getAuthProvider())}}class v extends a{constructor(t,s){super(t,s)}async list(t,s,e){const r={page:s,size:e};return t&&(r.keyword=t),this.httpGet("/service-prices",r)}async get(t){return this.httpGet("/service-prices/"+t)}async create(t){return this.httpPost("/service-prices",t)}async update(t,s){return this.httpPut("/service-prices/"+t,s)}async remove(t){await this.httpDelete("/service-prices/"+t)}}class A extends a{constructor(t,s){super(t,s)}async list(t,s,e,r,i,x){const c={page:i,size:x};return t&&(c.keyword=t),s&&(c.status=s),e&&(c.agentId=e),r&&(c.userId=r),this.httpGet("/sessions",c)}async get(t){return this.httpGet("/sessions/"+t)}async getUsage(t){return this.httpGet("/sessions/"+t+"/usage")}async generateMessage(t,s){return this.httpPost("/sessions/"+t+"/messages",s)}async findMessages(t,s,e){const r={};return s!==void 0&&(r.page=s),e!==void 0&&(r.size=e),this.httpGet("/sessions/"+t+"/messages",r)}async remove(t){await this.httpDelete("/sessions/"+t)}}class G extends a{constructor(t,s){super(t,s)}async list(t,s,e,r){const i={page:e,size:r};return t&&(i.projectId=t),s&&(i.status=s),this.httpGet("/missions",i)}async get(t){return this.httpGet("/missions/"+t)}async create(t){return this.httpPost("/missions",t)}async update(t,s){return this.httpPut("/missions/"+t,s)}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,s){return this.httpPost("/missions/"+t+"/instructions",{instruction:s})}async stop(t){return this.httpPost("/missions/"+t+"/stop")}async resume(t){return this.httpPost("/missions/"+t+"/continue")}}class S{constructor(t,s){o(this,"baseUrl");o(this,"workflowsBaseUrl");this.baseUrl=t,this.workflowsBaseUrl=s}projects(t){return new p(this.baseUrl,t)}agents(t){return new l(this.baseUrl,t)}knowledgeBases(t){return new y(this.baseUrl,t)}workflows(t){return new w(this.workflowsBaseUrl,t)}credentials(t){return new m(this.baseUrl,t)}features(t){return new b(this.baseUrl,t)}triggers(t){return new k(this.baseUrl,t)}servicePrices(t){return new v(this.baseUrl,t)}sessions(t){return new A(this.baseUrl,t)}missions(t){return new G(this.baseUrl,t)}}class j{constructor(t){this.token=t}applyHeaders(t){t.set("Authorization",`Bearer ${this.token}`)}getCredentials(){return this.token}}exports.AgentsApi=l;exports.ApiException=h;exports.ApiKeyAuthenticationProvider=u;exports.BearerTokenAuthenticationProvider=j;exports.CredentialsApi=m;exports.FeatureTemplatesApi=P;exports.FeaturesApi=b;exports.KnowledgeBaseDocumentsApi=d;exports.KnowledgeBasesApi=y;exports.MissionsApi=G;exports.PersonaSdk=S;exports.ProjectsApi=p;exports.ServicePricesApi=v;exports.SessionsApi=A;exports.TriggerExecutionsApi=f;exports.TriggersApi=k;exports.WorkflowExecutionsApi=g;exports.WorkflowsApi=w;
|
|
15
2
|
//# sourceMappingURL=bundle.cjs.js.map
|