@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/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applica-software-guru/persona-sdk",
|
|
3
|
+
"description": "Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.",
|
|
3
4
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
5
|
+
"version": "0.1.2",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"dev": "vite",
|
|
@@ -12,56 +13,25 @@
|
|
|
12
13
|
"format": "prettier --write ."
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@assistant-ui/react": "0.8.17",
|
|
16
|
-
"@assistant-ui/react-markdown": "0.8.0",
|
|
17
|
-
"@radix-ui/react-avatar": "^1.1.3",
|
|
18
|
-
"@radix-ui/react-tooltip": "^1.1.8",
|
|
19
|
-
"@tailwindcss/vite": "^4.0.17",
|
|
20
|
-
"@types/inflection": "^1.13.2",
|
|
21
|
-
"@types/lodash": "^4.17.15",
|
|
22
16
|
"@types/node": "^20.12.13",
|
|
23
|
-
"@types/react-dom": "^19.1.1",
|
|
24
17
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
25
18
|
"@typescript-eslint/parser": "^7.18.0",
|
|
26
19
|
"@vitejs/plugin-react": "^4.3.0",
|
|
27
|
-
"class-variance-authority": "^0.7.1",
|
|
28
|
-
"clsx": "^2.1.1",
|
|
29
20
|
"eslint": "^8.25.0",
|
|
30
21
|
"eslint-config-prettier": "^8.10.0",
|
|
31
|
-
"eslint-config-react-app": "7.0.1",
|
|
32
|
-
"eslint-plugin-export": "^0.1.2",
|
|
33
|
-
"eslint-plugin-filenames": "^1.3.2",
|
|
34
|
-
"eslint-plugin-import": "^2.26.0",
|
|
35
|
-
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
36
22
|
"eslint-plugin-prettier": "^4.2.1",
|
|
37
|
-
"eslint-plugin-react": "^7.31.10",
|
|
38
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
39
|
-
"eslint-plugin-react-refresh": "^0.4.19",
|
|
40
|
-
"eslint-plugin-sort-exports": "^0.9.1",
|
|
41
|
-
"husky": "^9.0.11",
|
|
42
|
-
"jsdom": "^22.1.0",
|
|
43
|
-
"lodash": "^4.17.21",
|
|
44
|
-
"lucide-react": "^0.485.0",
|
|
45
23
|
"prettier": "^2.8.8",
|
|
46
|
-
"react": "^19",
|
|
47
|
-
"react-dom": "^19",
|
|
48
|
-
"react-markdown": "^10.0.1",
|
|
49
|
-
"remark-gfm": "^4.0.1",
|
|
50
|
-
"tailwind-merge": "^3.0.2",
|
|
51
|
-
"tailwindcss": "^4.0.17",
|
|
52
24
|
"typescript": "^5.4.5",
|
|
53
25
|
"vite": "^5.2.12",
|
|
54
|
-
"vite-plugin-
|
|
55
|
-
"vite-plugin-dts": "^2.3.0",
|
|
56
|
-
"vite-plugin-linter": "^2.0.2",
|
|
57
|
-
"vitest": "^1.6.0"
|
|
58
|
-
},
|
|
59
|
-
"peerDependencies": {
|
|
60
|
-
"@assistant-ui/react": "0.8.17",
|
|
61
|
-
"react": "^18 || ^19 || ^19.0.0-rc"
|
|
26
|
+
"vite-plugin-dts": "^4.5.4"
|
|
62
27
|
},
|
|
63
28
|
"keywords": [
|
|
64
|
-
"persona-sdk"
|
|
29
|
+
"persona-sdk",
|
|
30
|
+
"persona",
|
|
31
|
+
"ai",
|
|
32
|
+
"sdk",
|
|
33
|
+
"chatbot",
|
|
34
|
+
"agents"
|
|
65
35
|
],
|
|
66
36
|
"main": "dist/bundle.cjs.js",
|
|
67
37
|
"module": "dist/bundle.es.js",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import {
|
|
5
|
+
Agent,
|
|
6
|
+
AgentCreateRequest,
|
|
7
|
+
AgentUpdateRequest,
|
|
8
|
+
SynthesizerVoice,
|
|
9
|
+
Revision,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
export class AgentsApi extends HttpApi {
|
|
13
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
14
|
+
super(baseUrl, auth);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async list(keyword?: string | null, page?: number, size?: number): Promise<Paginated<Agent>> {
|
|
18
|
+
const params: Record<string, unknown> = { page, size };
|
|
19
|
+
if (keyword) params.keyword = keyword;
|
|
20
|
+
return this.httpGet<Paginated<Agent>>('/agents', params);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async get(agentId: string): Promise<Agent> {
|
|
24
|
+
return this.httpGet<Agent>('/agents/' + agentId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async create(request: AgentCreateRequest): Promise<Agent> {
|
|
28
|
+
return this.httpPost<Agent>('/agents', request);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async update(request: AgentUpdateRequest): Promise<Agent> {
|
|
32
|
+
return this.httpPut<Agent>('/agents/' + request.id, request);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async remove(agentId: string): Promise<void> {
|
|
36
|
+
await this.httpDelete('/agents/' + agentId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async getSynthesizerSupportedVoices(synthesizerName: string): Promise<SynthesizerVoice[]> {
|
|
40
|
+
return this.httpGet<SynthesizerVoice[]>('/values/synthesizers/' + synthesizerName + '/voices');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async listRevisions(agentId: string): Promise<Revision[]> {
|
|
44
|
+
return this.httpGet<Revision[]>('/agents/' + agentId + '/revisions');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getRevision(agentId: string, revisionId: string): Promise<Revision> {
|
|
48
|
+
return this.httpGet<Revision>('/agents/' + agentId + '/revisions/' + revisionId);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async rollback(agentId: string, revisionId: string): Promise<Agent> {
|
|
52
|
+
return this.httpPost<Agent>('/agents/' + agentId + '/revisions/' + revisionId + '/rollback', {});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
export type AgentProtocol = 'webrtc' | 'twilio' | 'rest' | 'websocket' | 'telegram';
|
|
2
|
+
|
|
3
|
+
export type KnowledgeType = 'multi_hop' | 'simple';
|
|
4
|
+
|
|
5
|
+
export type LanguageCode = 'en-US' | 'it-IT' | 'es-ES' | 'fr-FR' | 'de-DE' | 'pt-BR';
|
|
6
|
+
|
|
7
|
+
export type ModelName =
|
|
8
|
+
| 'gemini-3-pro'
|
|
9
|
+
| 'gemini-2.5-pro'
|
|
10
|
+
| 'gemini-2.5-flash'
|
|
11
|
+
| 'gemini-2.5-flash-lite'
|
|
12
|
+
| 'gemini-2.0-flash'
|
|
13
|
+
| 'gemini-1.5-flash'
|
|
14
|
+
| 'gemini-1.5-pro'
|
|
15
|
+
| 'gemini-2.5-pro-exp-03-25'
|
|
16
|
+
| 'gemini-2.0-flash-001'
|
|
17
|
+
| 'gemini-2.0-flash-lite'
|
|
18
|
+
| 'gemini-2.0-flash-lite-001'
|
|
19
|
+
| 'gemini-1.5-flash-latest'
|
|
20
|
+
| 'gemini-1.5-flash-001'
|
|
21
|
+
| 'gemini-1.5-flash-002'
|
|
22
|
+
| 'gemini-1.5-pro-latest'
|
|
23
|
+
| 'gemini-1.5-pro-001'
|
|
24
|
+
| 'gemini-1.5-pro-002'
|
|
25
|
+
| 'gpt-5.2'
|
|
26
|
+
| 'gpt-5'
|
|
27
|
+
| 'gpt-5-mini'
|
|
28
|
+
| 'gpt-5-nano'
|
|
29
|
+
| 'gpt-4.1'
|
|
30
|
+
| 'gpt-4.1-mini'
|
|
31
|
+
| 'gpt-4.1-nano'
|
|
32
|
+
| 'gpt-4o'
|
|
33
|
+
| 'gpt-4o-mini'
|
|
34
|
+
| 'gpt-4.5'
|
|
35
|
+
| 'o1'
|
|
36
|
+
| 'o1-mini'
|
|
37
|
+
| 'o3-mini'
|
|
38
|
+
| 'o4-mini'
|
|
39
|
+
| 'o4-mini-high'
|
|
40
|
+
| 'gpt-3.5-turbo'
|
|
41
|
+
| 'gpt-3.5-turbo-16k'
|
|
42
|
+
| 'accounts/fireworks/models/minimax-m2p5'
|
|
43
|
+
| 'accounts/fireworks/models/deepseek-v3p2'
|
|
44
|
+
| 'accounts/fireworks/models/kimi-k2p5'
|
|
45
|
+
| 'accounts/fireworks/models/glm-5'
|
|
46
|
+
| 'grok-4-1-fast-reasoning'
|
|
47
|
+
| 'grok-4-1-fast-non-reasoning'
|
|
48
|
+
| 'grok-code-fast-1'
|
|
49
|
+
| 'grok-4-fast-reasoning'
|
|
50
|
+
| 'grok-4-fast-non-reasoning'
|
|
51
|
+
| 'grok-4-0709'
|
|
52
|
+
| 'grok-3-mini'
|
|
53
|
+
| 'grok-3'
|
|
54
|
+
| 'grok-2-vision-1212'
|
|
55
|
+
| 'ollama'
|
|
56
|
+
| 'openai-compatible';
|
|
57
|
+
|
|
58
|
+
export type SynthesizerName = 'gcloud' | 'elevenlabs' | 'gtts' | 'openai';
|
|
59
|
+
|
|
60
|
+
export type TranscriberName = 'gcloud' | 'deepgram' | 'vosk';
|
|
61
|
+
|
|
62
|
+
export type StmType = 'simple' | 'summary';
|
|
63
|
+
|
|
64
|
+
export type ToolType = 'remote' | 'local';
|
|
65
|
+
|
|
66
|
+
export type CollaborationMode = 'delegate_and_return' | 'persistent_transfer' | 'consult_then_respond';
|
|
67
|
+
|
|
68
|
+
export type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
|
|
69
|
+
|
|
70
|
+
export type ModelProvider = 'google' | 'openai' | 'grok' | 'fireworks' | 'ollama' | 'openai_compatible';
|
|
71
|
+
|
|
72
|
+
export type AgentType = 'agent';
|
|
73
|
+
|
|
74
|
+
export interface VariableSource {
|
|
75
|
+
type?: string;
|
|
76
|
+
tool?: string;
|
|
77
|
+
args?: Record<string, unknown>;
|
|
78
|
+
property?: string;
|
|
79
|
+
mcpServer?: string;
|
|
80
|
+
resourceUri?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface Variable {
|
|
84
|
+
name?: string;
|
|
85
|
+
source?: VariableSource;
|
|
86
|
+
defaultValue?: unknown;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ModelConfiguration {
|
|
90
|
+
modelName?: ModelName;
|
|
91
|
+
temperature?: number;
|
|
92
|
+
reasoningEffort?: ReasoningEffort;
|
|
93
|
+
url?: string;
|
|
94
|
+
ollamaModelName?: string;
|
|
95
|
+
openaiCompatibleModelName?: string;
|
|
96
|
+
openaiCompatibleApiKey?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface SynthesizerVoice {
|
|
100
|
+
id?: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
languageCodes?: string[];
|
|
103
|
+
gender?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface SynthesizerConfiguration {
|
|
107
|
+
enabled?: boolean;
|
|
108
|
+
synthesizerName?: SynthesizerName;
|
|
109
|
+
languageCode?: LanguageCode;
|
|
110
|
+
voice?: string;
|
|
111
|
+
sampleRateHertz?: number;
|
|
112
|
+
speed?: number;
|
|
113
|
+
similarityBoost?: number;
|
|
114
|
+
stability?: number;
|
|
115
|
+
style?: number;
|
|
116
|
+
voiceInstructions?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface TranscriberConfiguration {
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
transcriberName?: TranscriberName;
|
|
122
|
+
languageCode?: LanguageCode;
|
|
123
|
+
sampleRateHertz?: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface KnowledgeConfiguration {
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
knowledgeType?: KnowledgeType;
|
|
129
|
+
namespace?: string[];
|
|
130
|
+
numberOfEntries?: number;
|
|
131
|
+
args?: Record<string, unknown>;
|
|
132
|
+
knowledgeBaseId?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface CollaborationConfiguration {
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
collaborators?: Collaborator[];
|
|
138
|
+
mode?: CollaborationMode;
|
|
139
|
+
maxNumberOfIterations?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface Collaborator {
|
|
143
|
+
name?: string;
|
|
144
|
+
agent?: string;
|
|
145
|
+
scope?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface OrchestrationAgent {
|
|
149
|
+
name?: string;
|
|
150
|
+
agent?: string;
|
|
151
|
+
scope?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface OrchestrationConfiguration {
|
|
155
|
+
enabled?: boolean;
|
|
156
|
+
agents?: OrchestrationAgent[];
|
|
157
|
+
maxParallelCalls?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface NetworkConfiguration {
|
|
161
|
+
allowedWebsites?: string[];
|
|
162
|
+
allowedIps?: string[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface WakeupConfiguration {
|
|
166
|
+
enabled?: boolean;
|
|
167
|
+
wakeupWords?: string[];
|
|
168
|
+
sleepWords?: string[];
|
|
169
|
+
sleepInEachRequest?: boolean;
|
|
170
|
+
sleepDelaySeconds?: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface TelegramConfiguration {
|
|
174
|
+
enabled?: boolean;
|
|
175
|
+
botToken?: string;
|
|
176
|
+
enabledUsers?: string[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface TwilioConfiguration {
|
|
180
|
+
phoneNumber?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface WhatsAppConfiguration {
|
|
184
|
+
phoneNumberId?: string;
|
|
185
|
+
enabledUsers?: string[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface SkillResource {
|
|
189
|
+
path?: string;
|
|
190
|
+
content?: string;
|
|
191
|
+
contentType?: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface SkillConfiguration {
|
|
195
|
+
name?: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
instructions?: string;
|
|
198
|
+
allowedTools?: string[];
|
|
199
|
+
metadata?: Record<string, unknown>;
|
|
200
|
+
resources?: SkillResource[];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface McpServerConfiguration {
|
|
204
|
+
type?: string;
|
|
205
|
+
name?: string;
|
|
206
|
+
transport?: Transport;
|
|
207
|
+
enabledTools?: string[];
|
|
208
|
+
disabledTools?: string[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface FlagConfiguration {
|
|
212
|
+
type?: string;
|
|
213
|
+
flag?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type FeatureConfiguration = McpServerConfiguration | FlagConfiguration | SkillConfiguration;
|
|
217
|
+
|
|
218
|
+
export interface HttpTransport {
|
|
219
|
+
url?: string;
|
|
220
|
+
enablePersonaAuth?: boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface StdioTransport {
|
|
224
|
+
command?: string;
|
|
225
|
+
args?: string[];
|
|
226
|
+
env?: Record<string, string>;
|
|
227
|
+
cwd?: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type Transport = HttpTransport | StdioTransport;
|
|
231
|
+
|
|
232
|
+
export interface Feature {
|
|
233
|
+
id?: string;
|
|
234
|
+
templateId?: string;
|
|
235
|
+
credentialsId?: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface ToolLocalConfig {
|
|
239
|
+
parameters?: Record<string, unknown>;
|
|
240
|
+
output?: Record<string, unknown>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface ToolRemoteConfig {
|
|
244
|
+
serviceUrl?: string;
|
|
245
|
+
secret?: string;
|
|
246
|
+
timeout?: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export type ToolConfig = ToolLocalConfig | ToolRemoteConfig;
|
|
250
|
+
|
|
251
|
+
export interface ToolDefinition {
|
|
252
|
+
name?: string;
|
|
253
|
+
description?: string;
|
|
254
|
+
parameters?: Record<string, unknown>;
|
|
255
|
+
output?: Record<string, unknown>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface Tool {
|
|
259
|
+
type?: ToolType;
|
|
260
|
+
name?: string;
|
|
261
|
+
description?: string;
|
|
262
|
+
config?: ToolConfig;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface ToolkitConfiguration {
|
|
266
|
+
tools?: Tool[];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface StmConfiguration {
|
|
270
|
+
type?: StmType;
|
|
271
|
+
maxMessages?: number;
|
|
272
|
+
includeToolCalls?: boolean;
|
|
273
|
+
model?: ModelConfiguration;
|
|
274
|
+
maxNumberOfWords?: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface Revision {
|
|
278
|
+
id?: string;
|
|
279
|
+
entityId?: string;
|
|
280
|
+
projectId?: string;
|
|
281
|
+
revisionNumber?: number;
|
|
282
|
+
createdAt?: string;
|
|
283
|
+
snapshot?: Record<string, unknown>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface Agent {
|
|
287
|
+
id?: string;
|
|
288
|
+
projectId?: string;
|
|
289
|
+
apiKey?: string;
|
|
290
|
+
code?: string;
|
|
291
|
+
name?: string;
|
|
292
|
+
description?: string;
|
|
293
|
+
type?: AgentType;
|
|
294
|
+
synthesizer?: SynthesizerConfiguration;
|
|
295
|
+
transcriber?: TranscriberConfiguration;
|
|
296
|
+
model?: ModelConfiguration;
|
|
297
|
+
systemInstructions?: string;
|
|
298
|
+
variables?: Variable[];
|
|
299
|
+
enabledProtocols?: AgentProtocol[];
|
|
300
|
+
twilio?: TwilioConfiguration;
|
|
301
|
+
languageCode?: LanguageCode;
|
|
302
|
+
initialMessage?: string;
|
|
303
|
+
knowledge?: KnowledgeConfiguration;
|
|
304
|
+
wakeup?: WakeupConfiguration;
|
|
305
|
+
telegram?: TelegramConfiguration;
|
|
306
|
+
whatsapp?: WhatsAppConfiguration;
|
|
307
|
+
collaboration?: CollaborationConfiguration;
|
|
308
|
+
orchestration?: OrchestrationConfiguration;
|
|
309
|
+
network?: NetworkConfiguration;
|
|
310
|
+
features?: Feature[];
|
|
311
|
+
toolkit?: ToolkitConfiguration;
|
|
312
|
+
shortTermMemory?: StmConfiguration;
|
|
313
|
+
responseSchema?: Record<string, unknown>;
|
|
314
|
+
verboseErrors?: boolean;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface AgentCreateRequest {
|
|
318
|
+
projectId?: string;
|
|
319
|
+
code?: string;
|
|
320
|
+
name?: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
type?: AgentType;
|
|
323
|
+
synthesizer?: SynthesizerConfiguration;
|
|
324
|
+
transcriber?: TranscriberConfiguration;
|
|
325
|
+
model?: ModelConfiguration;
|
|
326
|
+
systemInstructions?: string;
|
|
327
|
+
variables?: Variable[];
|
|
328
|
+
enabledProtocols?: AgentProtocol[];
|
|
329
|
+
twilio?: TwilioConfiguration;
|
|
330
|
+
languageCode?: LanguageCode;
|
|
331
|
+
initialMessage?: string;
|
|
332
|
+
knowledge?: KnowledgeConfiguration;
|
|
333
|
+
wakeup?: WakeupConfiguration;
|
|
334
|
+
telegram?: TelegramConfiguration;
|
|
335
|
+
whatsapp?: WhatsAppConfiguration;
|
|
336
|
+
collaboration?: CollaborationConfiguration;
|
|
337
|
+
orchestration?: OrchestrationConfiguration;
|
|
338
|
+
network?: NetworkConfiguration;
|
|
339
|
+
features?: Feature[];
|
|
340
|
+
toolkit?: ToolkitConfiguration;
|
|
341
|
+
shortTermMemory?: StmConfiguration;
|
|
342
|
+
responseSchema?: Record<string, unknown>;
|
|
343
|
+
verboseErrors?: boolean;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface AgentUpdateRequest extends Agent {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticationProvider } from './authentication-provider';
|
|
2
|
+
|
|
3
|
+
export class ApiKeyAuthenticationProvider implements AuthenticationProvider {
|
|
4
|
+
constructor(private readonly apiKey: string) {}
|
|
5
|
+
|
|
6
|
+
applyHeaders(headers: Headers): void {
|
|
7
|
+
headers.set('x-persona-apikey', this.apiKey);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getCredentials(): string {
|
|
11
|
+
return this.apiKey;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticationProvider } from './authentication-provider';
|
|
2
|
+
|
|
3
|
+
export class BearerTokenAuthenticationProvider implements AuthenticationProvider {
|
|
4
|
+
constructor(private readonly token: string) {}
|
|
5
|
+
|
|
6
|
+
applyHeaders(headers: Headers): void {
|
|
7
|
+
headers.set('Authorization', `Bearer ${this.token}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getCredentials(): string {
|
|
11
|
+
return this.token;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
3
|
+
import {
|
|
4
|
+
Credentials,
|
|
5
|
+
AuthorizeRequest,
|
|
6
|
+
AuthorizeResponse,
|
|
7
|
+
OAuth2CallbackResponse,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
export class CredentialsApi extends HttpApi {
|
|
11
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
12
|
+
super(baseUrl, auth);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async authorize(provider: string, request: AuthorizeRequest): Promise<AuthorizeResponse> {
|
|
16
|
+
return this.httpPost<AuthorizeResponse>('/credentials/' + provider + '/authorize', request);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async handleOAuth2Callback(provider: string, code: string, state: string, scope?: string): Promise<OAuth2CallbackResponse> {
|
|
20
|
+
const params: Record<string, unknown> = { code, state };
|
|
21
|
+
if (scope) params.scope = scope;
|
|
22
|
+
return this.httpGet<OAuth2CallbackResponse>('/credentials/' + provider + '/oauth2/callback', params);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async list(): Promise<Credentials[]> {
|
|
26
|
+
return this.httpGet<Credentials[]>('/credentials');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getByProvider(provider: string): Promise<Credentials[]> {
|
|
30
|
+
return this.httpGet<Credentials[]>('/credentials/' + provider);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getById(credentialsId: string): Promise<Credentials> {
|
|
34
|
+
return this.httpGet<Credentials>('/credentials/all/' + credentialsId);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async remove(credentialsId: string): Promise<void> {
|
|
38
|
+
await this.httpDelete('/credentials/all/' + credentialsId);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface Credentials {
|
|
2
|
+
id?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
projectId?: string;
|
|
5
|
+
provider?: string;
|
|
6
|
+
obtainedAt?: string;
|
|
7
|
+
validUntil?: string;
|
|
8
|
+
data?: unknown;
|
|
9
|
+
clientId?: string;
|
|
10
|
+
clientSecret?: string;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
apiSecret?: string;
|
|
13
|
+
token?: string;
|
|
14
|
+
successUrl?: string;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
server?: string;
|
|
17
|
+
port?: number;
|
|
18
|
+
useSsl?: boolean;
|
|
19
|
+
username?: string;
|
|
20
|
+
password?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AuthorizeRequest {
|
|
24
|
+
name?: string;
|
|
25
|
+
provider?: string;
|
|
26
|
+
clientId?: string;
|
|
27
|
+
clientSecret?: string;
|
|
28
|
+
scope?: string;
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
apiSecret?: string;
|
|
31
|
+
token?: string;
|
|
32
|
+
successUrl?: string;
|
|
33
|
+
server?: string;
|
|
34
|
+
port?: number;
|
|
35
|
+
useSsl?: boolean;
|
|
36
|
+
username?: string;
|
|
37
|
+
password?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface OAuth2State {
|
|
41
|
+
id?: string;
|
|
42
|
+
credentialsName?: string;
|
|
43
|
+
projectId?: string;
|
|
44
|
+
provider?: string;
|
|
45
|
+
status?: string;
|
|
46
|
+
code?: string;
|
|
47
|
+
scope?: string;
|
|
48
|
+
clientId?: string;
|
|
49
|
+
clientSecret?: string;
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
apiSecret?: string;
|
|
52
|
+
token?: string;
|
|
53
|
+
successUrl?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface AuthorizeResponse {
|
|
57
|
+
credentials?: Credentials;
|
|
58
|
+
state?: OAuth2State;
|
|
59
|
+
redirectUrl?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OAuth2CallbackResponse {
|
|
63
|
+
id?: string;
|
|
64
|
+
successUrl?: string;
|
|
65
|
+
success?: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class ApiException extends Error {
|
|
2
|
+
public readonly statusCode: number;
|
|
3
|
+
public readonly body: string;
|
|
4
|
+
|
|
5
|
+
constructor(statusCode: number, body: string) {
|
|
6
|
+
super(`API Error: ${statusCode} - ${body}`);
|
|
7
|
+
this.statusCode = statusCode;
|
|
8
|
+
this.body = body;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { FeatureTemplate, McpToolsResponse } from './types';
|
|
5
|
+
import { McpServerConfiguration } from '../agents/types';
|
|
6
|
+
|
|
7
|
+
export class FeatureTemplatesApi extends HttpApi {
|
|
8
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
9
|
+
super(baseUrl, auth);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async list(keyword?: string | null, page?: number, size?: number): Promise<Paginated<FeatureTemplate>> {
|
|
13
|
+
const params: Record<string, unknown> = { page, size };
|
|
14
|
+
if (keyword) params.keyword = keyword;
|
|
15
|
+
return this.httpGet<Paginated<FeatureTemplate>>('/features/templates', params);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async get(templateId: string): Promise<FeatureTemplate> {
|
|
19
|
+
return this.httpGet<FeatureTemplate>('/features/templates/' + templateId);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async create(template: FeatureTemplate): Promise<FeatureTemplate> {
|
|
23
|
+
return this.httpPost<FeatureTemplate>('/features/templates', template);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async update(templateId: string, template: FeatureTemplate): Promise<FeatureTemplate> {
|
|
27
|
+
return this.httpPut<FeatureTemplate>('/features/templates/' + templateId, template);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async patch(templateId: string, template: FeatureTemplate): Promise<FeatureTemplate> {
|
|
31
|
+
return this.httpPatch<FeatureTemplate>('/features/templates/' + templateId, template);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async remove(templateId: string): Promise<void> {
|
|
35
|
+
await this.httpDelete('/features/templates/' + templateId);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getMcpAvailableTools(configuration: McpServerConfiguration): Promise<McpToolsResponse> {
|
|
39
|
+
return this.httpPost<McpToolsResponse>('/features/templates/mcp/available-tools', configuration);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
2
|
+
import { FeatureTemplatesApi } from './feature-templates-api';
|
|
3
|
+
|
|
4
|
+
export class FeaturesApi {
|
|
5
|
+
private readonly baseUrl: string;
|
|
6
|
+
private readonly auth: string | AuthenticationProvider;
|
|
7
|
+
|
|
8
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
9
|
+
this.baseUrl = baseUrl;
|
|
10
|
+
this.auth = auth;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
templates(): FeatureTemplatesApi {
|
|
14
|
+
return new FeatureTemplatesApi(this.baseUrl, this.auth);
|
|
15
|
+
}
|
|
16
|
+
}
|