@applica-software-guru/persona-sdk 0.1.96 → 0.1.101
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 +360 -20
- package/bitbucket-pipelines.yml +6 -5
- package/dist/bundle.cjs.js +1 -27
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +703 -5053
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1442 -7
- package/package.json +9 -51
- package/src/agents/agents-api.ts +66 -0
- package/src/agents/types.ts +349 -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/billing/billing-client.ts +182 -0
- package/src/billing/types.ts +166 -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 +43 -0
- package/src/features/features-api.ts +16 -0
- package/src/features/types.ts +25 -0
- package/src/http-api.ts +102 -0
- package/src/index.ts +179 -6
- package/src/knowledges/knowledge-base-documents-api.ts +39 -0
- package/src/knowledges/knowledge-bases-api.ts +48 -0
- package/src/knowledges/types.ts +70 -0
- package/src/known-models/known-models-api.ts +33 -0
- package/src/known-models/types.ts +7 -0
- package/src/missions/missions-api.ts +62 -0
- package/src/missions/types.ts +25 -0
- package/src/paginated.ts +6 -0
- package/src/persona-sdk.ts +104 -0
- package/src/projects/projects-api.ts +90 -0
- package/src/projects/types.ts +52 -0
- package/src/revisions/types.ts +9 -0
- package/src/service-prices/service-prices-api.ts +33 -0
- package/src/service-prices/types.ts +8 -0
- package/src/sessions/sessions-api.ts +90 -0
- package/src/sessions/types.ts +150 -0
- package/src/triggers/trigger-executions-api.ts +28 -0
- package/src/triggers/triggers-api.ts +38 -0
- package/src/triggers/types.ts +50 -0
- package/src/values/values-api.ts +84 -0
- package/src/workflows/types.ts +150 -0
- package/src/workflows/workflow-executions-api.ts +28 -0
- package/src/workflows/workflows-api.ts +52 -0
- package/tsconfig.json +20 -28
- package/vite.config.ts +20 -67
- package/.github/copilot-instructions.md +0 -3
- package/CLAUDE.md +0 -3
- package/GEMINI.md +0 -3
- package/components.json +0 -24
- package/dist/bundle.iife.js +0 -28
- package/dist/bundle.iife.js.map +0 -1
- package/dist/bundle.umd.js +0 -28
- 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 -9
- package/dist/messages.d.ts.map +0 -1
- package/dist/protocol/base.d.ts +0 -25
- package/dist/protocol/base.d.ts.map +0 -1
- package/dist/protocol/index.d.ts +0 -6
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/rest.d.ts +0 -25
- package/dist/protocol/rest.d.ts.map +0 -1
- package/dist/protocol/transaction.d.ts +0 -56
- package/dist/protocol/transaction.d.ts.map +0 -1
- package/dist/protocol/webrtc.d.ts +0 -60
- 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/context.d.ts +0 -34
- package/dist/runtime/context.d.ts.map +0 -1
- package/dist/runtime/file-attachment-adapter.d.ts +0 -15
- package/dist/runtime/file-attachment-adapter.d.ts.map +0 -1
- package/dist/runtime/handlers.d.ts +0 -21
- package/dist/runtime/handlers.d.ts.map +0 -1
- package/dist/runtime/listeners.d.ts +0 -6
- package/dist/runtime/listeners.d.ts.map +0 -1
- package/dist/runtime/protocols.d.ts +0 -17
- package/dist/runtime/protocols.d.ts.map +0 -1
- package/dist/runtime/threads.d.ts +0 -34
- package/dist/runtime/threads.d.ts.map +0 -1
- package/dist/runtime/utils.d.ts +0 -10
- package/dist/runtime/utils.d.ts.map +0 -1
- package/dist/runtime.d.ts +0 -6
- package/dist/runtime.d.ts.map +0 -1
- package/dist/storage/base.d.ts +0 -9
- package/dist/storage/base.d.ts.map +0 -1
- package/dist/storage/index.d.ts +0 -3
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/persona.d.ts +0 -29
- package/dist/storage/persona.d.ts.map +0 -1
- package/dist/tools.d.ts +0 -72
- package/dist/tools.d.ts.map +0 -1
- package/dist/types.d.ts +0 -221
- package/dist/types.d.ts.map +0 -1
- package/docs/README.md +0 -13
- package/docs/api-reference.md +0 -16
- package/docs/contributing.md +0 -21
- package/docs/customization.md +0 -74
- package/docs/features.md +0 -7
- package/docs/installation.md +0 -9
- package/docs/messages.md +0 -214
- package/docs/protocols.md +0 -39
- package/docs/transactions.md +0 -121
- package/docs/usage.md +0 -40
- 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 -117
- package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
- package/playground/src/components/assistant-ui/attachment.tsx +0 -197
- package/playground/src/components/assistant-ui/markdown-text.tsx +0 -228
- package/playground/src/components/assistant-ui/thread-list.tsx +0 -91
- package/playground/src/components/assistant-ui/thread.tsx +0 -302
- package/playground/src/components/assistant-ui/threadlist-sidebar.tsx +0 -59
- package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -93
- package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -42
- package/playground/src/components/chat/logging.tsx +0 -53
- package/playground/src/components/ui/avatar.tsx +0 -51
- package/playground/src/components/ui/button.tsx +0 -60
- package/playground/src/components/ui/dialog.tsx +0 -141
- package/playground/src/components/ui/input.tsx +0 -21
- package/playground/src/components/ui/separator.tsx +0 -26
- package/playground/src/components/ui/sheet.tsx +0 -139
- package/playground/src/components/ui/sidebar.tsx +0 -619
- package/playground/src/components/ui/skeleton.tsx +0 -13
- package/playground/src/components/ui/tooltip.tsx +0 -59
- package/playground/src/hooks/theme.ts +0 -70
- package/playground/src/hooks/use-mobile.ts +0 -19
- package/playground/src/lib/utils.ts +0 -6
- package/playground/src/main.tsx +0 -10
- package/playground/src/styles.css +0 -120
- package/playground/src/tools.ts +0 -149
- package/playground/src/vite-env.d.ts +0 -1
- package/preview-build.sh +0 -23
- package/src/logging.ts +0 -34
- package/src/messages.ts +0 -202
- package/src/protocol/base.ts +0 -73
- package/src/protocol/index.ts +0 -5
- package/src/protocol/rest.ts +0 -107
- package/src/protocol/transaction.ts +0 -182
- package/src/protocol/webrtc.ts +0 -379
- package/src/protocol/websocket.ts +0 -111
- package/src/runtime/context.ts +0 -88
- package/src/runtime/file-attachment-adapter.ts +0 -48
- package/src/runtime/handlers.ts +0 -322
- package/src/runtime/index.ts +0 -6
- package/src/runtime/listeners.ts +0 -79
- package/src/runtime/protocols.ts +0 -169
- package/src/runtime/threads.ts +0 -105
- package/src/runtime/utils.ts +0 -46
- package/src/runtime.tsx +0 -334
- package/src/storage/base.ts +0 -13
- package/src/storage/index.ts +0 -2
- package/src/storage/persona.ts +0 -138
- package/src/tools.ts +0 -211
- package/src/types.ts +0 -267
- 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
|
-
22
|
|
1
|
+
22
|
package/.prettierignore
CHANGED
package/.prettierrc
CHANGED
package/README.md
CHANGED
|
@@ -1,33 +1,373 @@
|
|
|
1
|
-
# Persona SDK
|
|
1
|
+
# Persona SDK
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@applica-software-guru/persona-sdk)
|
|
4
|
-
[](#)
|
|
5
|
-
[](docs/README.md)
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Official TypeScript SDK for the Persona API. Manage agents, sessions, projects, knowledge bases, workflows, triggers, missions and more from any JavaScript/TypeScript application.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
## Install
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @applica-software-guru/persona-sdk
|
|
11
|
+
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- [Installation](docs/installation.md)
|
|
15
|
-
- [Usage](docs/usage.md)
|
|
16
|
-
- [Messages and Storage](docs/messages.md)
|
|
17
|
-
- [Protocols Overview](docs/protocols.md)
|
|
18
|
-
- [API Reference](docs/api-reference.md)
|
|
19
|
-
- [Transactions and Tools](docs/transactions.md)
|
|
20
|
-
- [Customization](docs/customization.md)
|
|
21
|
-
- [Contributing](docs/contributing.md)
|
|
13
|
+
## Quick Start
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
```typescript
|
|
16
|
+
import { PersonaSdk } from '@applica-software-guru/persona-sdk';
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
const sdk = new PersonaSdk(
|
|
19
|
+
'https://persona.applica.guru/api', // persona-core base URL
|
|
20
|
+
'https://persona.applica.guru/workflows', // workflows service base URL
|
|
21
|
+
'https://persona.applica.guru/billing' // billing service base URL (optional)
|
|
22
|
+
);
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
// Authenticate with a project API key
|
|
25
|
+
const agents = await sdk.agents('prs_your_project_api_key').list(null, 1, 20);
|
|
26
|
+
console.log(`Total agents: ${agents.total}`);
|
|
27
|
+
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The `PersonaSdk` constructor accepts:
|
|
30
|
+
1. **`baseUrl`** — persona-core API base URL (required)
|
|
31
|
+
2. **`workflowsBaseUrl`** — workflows service base URL (required)
|
|
32
|
+
3. **`billingBaseUrl`** — billing service base URL (optional, defaults to `https://persona.applica.guru/billing`)
|
|
33
|
+
|
|
34
|
+
Each resource is exposed as a factory method that requires authentication credentials.
|
|
35
|
+
|
|
36
|
+
## Authentication
|
|
37
|
+
|
|
38
|
+
The SDK supports two authentication methods. Pass either a string (API key) or
|
|
39
|
+
an `AuthenticationProvider` instance to any resource factory.
|
|
40
|
+
|
|
41
|
+
### API Key
|
|
42
|
+
|
|
43
|
+
The simplest method — pass the API key string directly. The SDK wraps it in an
|
|
44
|
+
`ApiKeyAuthenticationProvider` and sends it as the `x-persona-apikey` header.
|
|
45
|
+
|
|
46
|
+
Accepts:
|
|
47
|
+
|
|
48
|
+
- **Master key** — full admin access (server-to-server only)
|
|
49
|
+
- **Project API key** (`prs_...`) — scoped to a single project
|
|
50
|
+
- **Agent API key** (`prs_ag_...`) — scoped to a single agent
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const projects = await sdk.projects('prs_your_project_api_key').getMine();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### IAM Bearer Token
|
|
57
|
+
|
|
58
|
+
For applications that authenticate end users via IAM, pass a
|
|
59
|
+
`BearerTokenAuthenticationProvider` with a valid JWT:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { BearerTokenAuthenticationProvider } from '@applica-software-guru/persona-sdk';
|
|
63
|
+
|
|
64
|
+
const auth = new BearerTokenAuthenticationProvider(iamJwtToken);
|
|
65
|
+
const projects = await sdk.projects(auth).getMine();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The token is sent as the `Authorization: Bearer <token>` header. The server
|
|
69
|
+
validates it via the IAM service and resolves the user's project automatically.
|
|
70
|
+
Use this method when building user-facing apps (e.g. control panels) where the
|
|
71
|
+
user logs in through IAM.
|
|
72
|
+
|
|
73
|
+
### Custom provider
|
|
74
|
+
|
|
75
|
+
Implement your own provider via the `AuthenticationProvider` interface:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { AuthenticationProvider } from '@applica-software-guru/persona-sdk';
|
|
79
|
+
|
|
80
|
+
class MyProvider implements AuthenticationProvider {
|
|
81
|
+
applyHeaders(headers: Headers): void {
|
|
82
|
+
headers.set('x-custom-header', 'value');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getCredentials(): string {
|
|
86
|
+
return 'my-credentials';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Usage Examples
|
|
92
|
+
|
|
93
|
+
### Agents
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const agentsApi = sdk.agents('your-api-key');
|
|
97
|
+
|
|
98
|
+
// List agents (with optional server-side filters)
|
|
99
|
+
const { items, total } = await agentsApi.list('search-term', 1, 20);
|
|
100
|
+
|
|
101
|
+
// Filter by project
|
|
102
|
+
const projectAgents = await agentsApi.list(null, 1, 20, { projectId: 'my-project-id' });
|
|
103
|
+
|
|
104
|
+
// Get a single agent
|
|
105
|
+
const agent = await agentsApi.get('agent-id');
|
|
106
|
+
|
|
107
|
+
// Create an agent
|
|
108
|
+
const agent = await agentsApi.create({
|
|
109
|
+
name: 'My Agent',
|
|
110
|
+
description: 'A helpful assistant',
|
|
111
|
+
systemInstructions: 'You are a helpful assistant.',
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Update an agent
|
|
115
|
+
const updated = await agentsApi.update({
|
|
116
|
+
id: 'agent-id',
|
|
117
|
+
name: 'Updated Name',
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Delete an agent
|
|
121
|
+
await agentsApi.remove('agent-id');
|
|
122
|
+
|
|
123
|
+
// Generate system instructions with AI (project-scoped architect)
|
|
124
|
+
const instructions = await agentsApi.generateSystemInstructions(
|
|
125
|
+
'Create a customer support agent that handles billing inquiries',
|
|
126
|
+
'optional-session-id', // for multi-turn refinement
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Get the project's architect agent configuration
|
|
130
|
+
const architect = await agentsApi.getArchitect();
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Sessions
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const sessionsApi = sdk.sessions('your-api-key');
|
|
137
|
+
|
|
138
|
+
// List sessions
|
|
139
|
+
const sessions = await sessionsApi.list(null, null, null, null, 1, 20);
|
|
140
|
+
|
|
141
|
+
// Generate a message
|
|
142
|
+
const response = await sessionsApi.generateMessage('session-code', {
|
|
143
|
+
userMessage: 'Hello, how are you?',
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Get session messages
|
|
147
|
+
const messages = await sessionsApi.findMessages('session-code', 1, 50);
|
|
148
|
+
|
|
149
|
+
// Get usage info
|
|
150
|
+
const usage = await sessionsApi.getUsage('session-id');
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Projects
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const projectsApi = sdk.projects('your-api-key');
|
|
157
|
+
|
|
158
|
+
// Get current project
|
|
159
|
+
const project = await projectsApi.getMine();
|
|
160
|
+
|
|
161
|
+
// Create a project
|
|
162
|
+
const project = await projectsApi.create({ name: 'My Project' });
|
|
163
|
+
|
|
164
|
+
// Get subscription info
|
|
165
|
+
const subscription = await projectsApi.getSubscription('project-id');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Knowledge Bases
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const kbApi = sdk.knowledgeBases('your-api-key');
|
|
172
|
+
|
|
173
|
+
// List knowledge bases
|
|
174
|
+
const knowledgeBases = await kbApi.list(null, 1, 20);
|
|
175
|
+
|
|
176
|
+
// Create a knowledge base
|
|
177
|
+
const kb = await kbApi.create({ name: 'My Knowledge Base' });
|
|
178
|
+
|
|
179
|
+
// Upload a document
|
|
180
|
+
const doc = await kbApi.documents(kb.id).upload({
|
|
181
|
+
name: 'document.pdf',
|
|
182
|
+
uri: 'https://example.com/document.pdf',
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Search chunks
|
|
186
|
+
const chunks = await kbApi.searchChunks(kb.id, { query: 'search term', limit: 5 });
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Workflows
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const workflowsApi = sdk.workflows('your-api-key');
|
|
193
|
+
|
|
194
|
+
// List workflows
|
|
195
|
+
const workflows = await workflowsApi.list(null, 1, 20);
|
|
196
|
+
|
|
197
|
+
// Execute a workflow
|
|
198
|
+
const execution = await workflowsApi.executions().run('workflow-id', {
|
|
199
|
+
userId: 'user-123',
|
|
200
|
+
initialData: { key: 'value' },
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Credentials
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const credentialsApi = sdk.credentials('your-api-key');
|
|
208
|
+
|
|
209
|
+
// List credentials
|
|
210
|
+
const creds = await credentialsApi.list();
|
|
211
|
+
|
|
212
|
+
// Authorize OAuth2
|
|
213
|
+
const result = await credentialsApi.authorize('google', {
|
|
214
|
+
name: 'My Google Account',
|
|
215
|
+
clientId: '...',
|
|
216
|
+
clientSecret: '...',
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Triggers
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const triggersApi = sdk.triggers('your-api-key');
|
|
224
|
+
|
|
225
|
+
// List triggers
|
|
226
|
+
const triggers = await triggersApi.list(null, 1, 20);
|
|
227
|
+
|
|
228
|
+
// Execute a trigger
|
|
229
|
+
const result = await triggersApi.executions().execute('trigger-id', {});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Features
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
const featuresApi = sdk.features('your-api-key');
|
|
236
|
+
|
|
237
|
+
// List feature templates
|
|
238
|
+
const templates = await featuresApi.templates().list(null, 1, 20);
|
|
239
|
+
|
|
240
|
+
// Get MCP available tools
|
|
241
|
+
const tools = await featuresApi.templates().getMcpAvailableTools({
|
|
242
|
+
type: 'mcp',
|
|
243
|
+
name: 'my-server',
|
|
244
|
+
transport: { url: 'https://mcp.example.com' },
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Missions
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const missionsApi = sdk.missions('your-api-key');
|
|
252
|
+
|
|
253
|
+
// List missions
|
|
254
|
+
const missions = await missionsApi.list(null, null, 1, 20);
|
|
255
|
+
|
|
256
|
+
// Create and execute
|
|
257
|
+
const mission = await missionsApi.create({ name: 'My Mission' });
|
|
258
|
+
await missionsApi.execute(mission.id);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Billing
|
|
262
|
+
|
|
263
|
+
The `BillingClient` manages customers, subscriptions, credits and invoices.
|
|
264
|
+
When using `PersonaSdk`, the billing base URL is configured in the constructor
|
|
265
|
+
and `billing()` follows the same authentication pattern as all other APIs.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// Via PersonaSdk (recommended) — uses billingBaseUrl from constructor
|
|
269
|
+
const billing = sdk.billing('your-api-key');
|
|
270
|
+
const billing = sdk.billing(new BearerTokenAuthenticationProvider(token));
|
|
271
|
+
|
|
272
|
+
// Standalone usage with explicit base URL
|
|
273
|
+
import { BillingClient } from '@applica-software-guru/persona-sdk';
|
|
274
|
+
const billing = new BillingClient('https://persona.applica.guru/billing', 'your-api-key');
|
|
275
|
+
|
|
276
|
+
// Customer management
|
|
277
|
+
const customer = await billing.createCustomer({
|
|
278
|
+
owner: 'user-123',
|
|
279
|
+
name: 'Acme Corp',
|
|
280
|
+
email: 'billing@acme.com',
|
|
281
|
+
});
|
|
282
|
+
const existing = await billing.getCustomer('user-123');
|
|
283
|
+
await billing.updateCustomer('user-123', { name: 'Acme Inc.' });
|
|
284
|
+
await billing.deleteCustomer('user-123');
|
|
285
|
+
|
|
286
|
+
// Subscription management
|
|
287
|
+
const subscription = await billing.createSubscription({ owner: 'user-123' });
|
|
288
|
+
const current = await billing.getSubscription('user-123');
|
|
289
|
+
await billing.cancelSubscription('user-123');
|
|
290
|
+
|
|
291
|
+
// Plan changes
|
|
292
|
+
await billing.beginUpgrade('user-123', { toPlanType: 'pro' });
|
|
293
|
+
await billing.downgrade('user-123', { toPlanType: 'starter' });
|
|
294
|
+
await billing.mentorize('user-123', { endDate: '2026-12-31' });
|
|
295
|
+
|
|
296
|
+
// Credits
|
|
297
|
+
await billing.addCredits('user-123', 100);
|
|
298
|
+
await billing.useCredits('user-123', 10, ['chat', 'voice'], 'reference-id');
|
|
299
|
+
const credits = await billing.getCredits('user-123');
|
|
300
|
+
const valid = await billing.isValid('user-123');
|
|
301
|
+
|
|
302
|
+
// Invoices
|
|
303
|
+
const invoices = await billing.listInvoices('user-123', '2026-01-01', '2026-12-31');
|
|
304
|
+
|
|
305
|
+
// Project-level billing
|
|
306
|
+
const projectSub = await billing.getProjectSubscription('project-id');
|
|
307
|
+
await billing.changeProjectSubscriptionPlan('project-id', { toPlanType: 'pro' });
|
|
308
|
+
await billing.addProjectSubscriptionCredits('project-id', { credits: 50 });
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Server-side Filtering
|
|
312
|
+
|
|
313
|
+
All paginated `list` methods accept an optional `extraParams` argument as the
|
|
314
|
+
last parameter. These key-value pairs are appended to the query string, enabling
|
|
315
|
+
server-side filters such as `projectId`:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// Filter agents by project
|
|
319
|
+
const agents = await sdk.agents(auth).list(null, 1, 20, { projectId: 'abc123' });
|
|
320
|
+
|
|
321
|
+
// Combine keyword search with project filter
|
|
322
|
+
const results = await sdk.knowledgeBases(auth).list('my-kb', 1, 20, { projectId: 'abc123' });
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Supported on: `AgentsApi`, `KnowledgeBasesApi`, `WorkflowsApi`, `TriggersApi`,
|
|
326
|
+
`FeatureTemplatesApi`, `ServicePricesApi`.
|
|
327
|
+
|
|
328
|
+
## Error Handling
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import { ApiException } from '@applica-software-guru/persona-sdk';
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
const agent = await sdk.agents('api-key').get('invalid-id');
|
|
335
|
+
} catch (error) {
|
|
336
|
+
if (error instanceof ApiException) {
|
|
337
|
+
console.error(`API Error ${error.statusCode}: ${error.body}`);
|
|
338
|
+
} else {
|
|
339
|
+
throw error;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## API Reference
|
|
345
|
+
|
|
346
|
+
| Resource | Methods |
|
|
347
|
+
|---|---|
|
|
348
|
+
| **ProjectsApi** | `list`, `get`, `getMine`, `create`, `update`, `remove`, `getSubscription`, `changeSubscriptionPlan`, `addSubscriptionCredits` |
|
|
349
|
+
| **AgentsApi** | `list`, `get`, `create`, `update`, `remove`, `getSynthesizerSupportedVoices`, `listRevisions`, `getRevision`, `rollback`, `generateSystemInstructions`, `getArchitect` |
|
|
350
|
+
| **SessionsApi** | `list`, `get`, `getUsage`, `generateMessage`, `findMessages`, `remove` |
|
|
351
|
+
| **KnowledgeBasesApi** | `list`, `get`, `create`, `update`, `remove`, `documents()`, `searchChunks` |
|
|
352
|
+
| **KnowledgeBaseDocumentsApi** | `list`, `upload`, `get`, `reprocess`, `remove` |
|
|
353
|
+
| **WorkflowsApi** | `list`, `create`, `update`, `remove`, `get`, `executions()`, `listRevisions`, `getRevision`, `rollback` |
|
|
354
|
+
| **WorkflowExecutionsApi** | `list`, `get`, `run`, `queue` |
|
|
355
|
+
| **CredentialsApi** | `authorize`, `handleOAuth2Callback`, `list`, `getByProvider`, `getById`, `remove` |
|
|
356
|
+
| **TriggersApi** | `list`, `create`, `update`, `remove`, `get`, `executions()` |
|
|
357
|
+
| **TriggerExecutionsApi** | `list`, `execute`, `get`, `remove` |
|
|
358
|
+
| **FeaturesApi** | `templates()` |
|
|
359
|
+
| **FeatureTemplatesApi** | `list`, `get`, `create`, `update`, `patch`, `remove`, `getMcpAvailableTools` |
|
|
360
|
+
| **MissionsApi** | `list`, `get`, `create`, `update`, `remove`, `generate`, `execute`, `retry`, `replan`, `sendInstruction`, `stop`, `resume` |
|
|
361
|
+
| **ServicePricesApi** | `list`, `get`, `create`, `update`, `remove` |
|
|
362
|
+
| **BillingClient** | `createCustomer`, `updateCustomer`, `getCustomer`, `saveCustomer`, `deleteCustomer`, `createSubscription`, `getSubscription`, `cancelSubscription`, `beginUpgrade`, `downgrade`, `mentorize`, `addCredits`, `useCredits`, `getCredits`, `isValid`, `listInvoices`, `getProjectSubscription`, `changeProjectSubscriptionPlan`, `addProjectSubscriptionCredits` |
|
|
363
|
+
|
|
364
|
+
## Compatibility
|
|
365
|
+
|
|
366
|
+
- **Runtime**: Browser (Chrome, Firefox, Safari, Edge), Node.js 18+
|
|
367
|
+
- **Frameworks**: React, Vue, Angular, Svelte, Next.js, Vite, Webpack
|
|
368
|
+
- **Module systems**: ESM, CommonJS
|
|
369
|
+
- **TypeScript**: Full type definitions included
|
|
30
370
|
|
|
31
371
|
## License
|
|
32
372
|
|
|
33
|
-
|
|
373
|
+
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,13 +7,14 @@ pipelines:
|
|
|
7
7
|
name: Deploy
|
|
8
8
|
deployment: Production
|
|
9
9
|
script:
|
|
10
|
-
- export
|
|
11
|
-
- npm
|
|
10
|
+
- export VERSION_PREFIX=0.1
|
|
11
|
+
- export PACKAGE_VERSION=$(npm view @applica-software-guru/persona-sdk versions --json | node -e "const versions = JSON.parse(require('fs').readFileSync(0, 'utf8')); const prefix = process.env.VERSION_PREFIX + '.'; const patches = versions.filter(v => v.startsWith(prefix) && !v.includes('-')).map(v => Number(v.slice(prefix.length))).filter(Number.isFinite); console.log(process.env.VERSION_PREFIX + '.' + (Math.max(...patches, 0) + 1));")
|
|
12
|
+
- npm --no-git-tag-version version "$PACKAGE_VERSION" -m "Upgrade to new version"
|
|
12
13
|
- npm install
|
|
13
14
|
- npm run build
|
|
14
15
|
- pipe: atlassian/npm-publish:0.3.2
|
|
15
16
|
variables:
|
|
16
17
|
NPM_TOKEN: $NPM_TOKEN
|
|
17
18
|
EXTRA_ARGS: '--access public'
|
|
18
|
-
- git tag -a "$
|
|
19
|
-
- git push origin "$
|
|
19
|
+
- git tag -a "$PACKAGE_VERSION" -m "Version $PACKAGE_VERSION"
|
|
20
|
+
- git push origin "$PACKAGE_VERSION"
|