@applica-software-guru/persona-sdk 0.1.1 → 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/README.md +248 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Persona SDK
|
|
2
|
+
|
|
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@applica-software-guru/persona-sdk",
|
|
3
3
|
"description": "Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite",
|