@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.
Files changed (99) hide show
  1. package/.eslintrc.cjs +6 -5
  2. package/.nvmrc +1 -1
  3. package/.prettierignore +3 -5
  4. package/.prettierrc +3 -5
  5. package/README.md +247 -2
  6. package/bitbucket-pipelines.yml +2 -12
  7. package/dist/bundle.cjs.js +1 -14
  8. package/dist/bundle.cjs.js.map +1 -1
  9. package/dist/bundle.es.js +472 -699
  10. package/dist/bundle.es.js.map +1 -1
  11. package/dist/index.d.ts +1089 -5
  12. package/package.json +9 -39
  13. package/src/agents/agents-api.ts +54 -0
  14. package/src/agents/types.ts +346 -0
  15. package/src/auth/api-key-auth.ts +13 -0
  16. package/src/auth/authentication-provider.ts +4 -0
  17. package/src/auth/bearer-token-auth.ts +13 -0
  18. package/src/auth/index.ts +3 -0
  19. package/src/credentials/credentials-api.ts +40 -0
  20. package/src/credentials/types.ts +67 -0
  21. package/src/exceptions.ts +10 -0
  22. package/src/features/feature-templates-api.ts +41 -0
  23. package/src/features/features-api.ts +16 -0
  24. package/src/features/types.ts +25 -0
  25. package/src/http-api.ts +95 -0
  26. package/src/index.ts +153 -4
  27. package/src/knowledges/knowledge-base-documents-api.ts +38 -0
  28. package/src/knowledges/knowledge-bases-api.ts +47 -0
  29. package/src/knowledges/types.ts +70 -0
  30. package/src/missions/missions-api.ts +60 -0
  31. package/src/missions/types.ts +25 -0
  32. package/src/paginated.ts +6 -0
  33. package/src/persona-sdk.ts +81 -0
  34. package/src/projects/projects-api.ts +55 -0
  35. package/src/projects/types.ts +42 -0
  36. package/src/revisions/types.ts +9 -0
  37. package/src/service-prices/service-prices-api.ts +32 -0
  38. package/src/service-prices/types.ts +8 -0
  39. package/src/sessions/sessions-api.ts +55 -0
  40. package/src/sessions/types.ts +129 -0
  41. package/src/triggers/trigger-executions-api.ts +27 -0
  42. package/src/triggers/triggers-api.ts +37 -0
  43. package/src/triggers/types.ts +50 -0
  44. package/src/workflows/types.ts +150 -0
  45. package/src/workflows/workflow-executions-api.ts +27 -0
  46. package/src/workflows/workflows-api.ts +51 -0
  47. package/tsconfig.json +20 -28
  48. package/vite.config.ts +20 -62
  49. package/dist/bundle.iife.js +0 -15
  50. package/dist/bundle.iife.js.map +0 -1
  51. package/dist/bundle.umd.js +0 -15
  52. package/dist/bundle.umd.js.map +0 -1
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/logging.d.ts +0 -18
  55. package/dist/logging.d.ts.map +0 -1
  56. package/dist/messages.d.ts +0 -7
  57. package/dist/messages.d.ts.map +0 -1
  58. package/dist/protocol/base.d.ts +0 -23
  59. package/dist/protocol/base.d.ts.map +0 -1
  60. package/dist/protocol/index.d.ts +0 -5
  61. package/dist/protocol/index.d.ts.map +0 -1
  62. package/dist/protocol/rest.d.ts +0 -22
  63. package/dist/protocol/rest.d.ts.map +0 -1
  64. package/dist/protocol/webrtc.d.ts +0 -56
  65. package/dist/protocol/webrtc.d.ts.map +0 -1
  66. package/dist/protocol/websocket.d.ts +0 -22
  67. package/dist/protocol/websocket.d.ts.map +0 -1
  68. package/dist/runtime.d.ts +0 -21
  69. package/dist/runtime.d.ts.map +0 -1
  70. package/dist/types.d.ts +0 -79
  71. package/dist/types.d.ts.map +0 -1
  72. package/jsconfig.node.json +0 -10
  73. package/playground/index.html +0 -14
  74. package/playground/src/app.tsx +0 -10
  75. package/playground/src/chat.tsx +0 -52
  76. package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
  77. package/playground/src/components/assistant-ui/markdown-text.tsx +0 -119
  78. package/playground/src/components/assistant-ui/thread-list.tsx +0 -62
  79. package/playground/src/components/assistant-ui/thread.tsx +0 -249
  80. package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -33
  81. package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -38
  82. package/playground/src/components/ui/avatar.tsx +0 -35
  83. package/playground/src/components/ui/button.tsx +0 -43
  84. package/playground/src/components/ui/tooltip.tsx +0 -32
  85. package/playground/src/lib/utils.ts +0 -6
  86. package/playground/src/main.tsx +0 -10
  87. package/playground/src/styles.css +0 -1
  88. package/playground/src/vite-env.d.ts +0 -1
  89. package/preview.sh +0 -13
  90. package/src/logging.ts +0 -34
  91. package/src/messages.ts +0 -79
  92. package/src/protocol/base.ts +0 -55
  93. package/src/protocol/index.ts +0 -4
  94. package/src/protocol/rest.ts +0 -66
  95. package/src/protocol/webrtc.ts +0 -339
  96. package/src/protocol/websocket.ts +0 -108
  97. package/src/runtime.tsx +0 -217
  98. package/src/types.ts +0 -98
  99. package/tsconfig.node.json +0 -15
@@ -0,0 +1,25 @@
1
+ import { FeatureConfiguration, McpServerConfiguration } from '../agents/types';
2
+ import { ToolDefinition } from '../agents/types';
3
+
4
+ export type FeatureType = 'mcp' | 'flag' | 'skill';
5
+
6
+ export interface FeatureCredentialsConfiguration {
7
+ requireCredentials?: boolean;
8
+ credentialsType?: string;
9
+ }
10
+
11
+ export interface FeatureTemplate {
12
+ id?: string;
13
+ projectId?: string;
14
+ type?: FeatureType;
15
+ name?: string;
16
+ description?: string;
17
+ logoUrl?: string;
18
+ configuration?: FeatureConfiguration;
19
+ credentialsConfiguration?: FeatureCredentialsConfiguration;
20
+ }
21
+
22
+ export interface McpToolsResponse {
23
+ tools?: ToolDefinition[];
24
+ error?: string;
25
+ }
@@ -0,0 +1,95 @@
1
+ import { ApiException } from './exceptions';
2
+ import { AuthenticationProvider } from './auth/authentication-provider';
3
+ import { ApiKeyAuthenticationProvider } from './auth/api-key-auth';
4
+
5
+ export abstract class HttpApi {
6
+ private readonly baseUrl: string;
7
+ private readonly authProvider: AuthenticationProvider;
8
+
9
+ constructor(baseUrl: string, apiKey: string | AuthenticationProvider) {
10
+ this.baseUrl = baseUrl;
11
+ this.authProvider = typeof apiKey === 'string' ? new ApiKeyAuthenticationProvider(apiKey) : apiKey;
12
+ }
13
+
14
+ protected getBaseUrl(): string {
15
+ return this.baseUrl;
16
+ }
17
+
18
+ protected getAuthProvider(): AuthenticationProvider {
19
+ return this.authProvider;
20
+ }
21
+
22
+ private buildHeaders(): Headers {
23
+ const headers = new Headers();
24
+ headers.set('Content-Type', 'application/json');
25
+ this.authProvider.applyHeaders(headers);
26
+ return headers;
27
+ }
28
+
29
+ private buildUrl(path: string, params?: Record<string, unknown>): string {
30
+ const url = new URL(this.baseUrl + path);
31
+ if (params) {
32
+ Object.entries(params).forEach(([key, value]) => {
33
+ if (value !== null && value !== undefined) {
34
+ url.searchParams.set(key, String(value));
35
+ }
36
+ });
37
+ }
38
+ return url.toString();
39
+ }
40
+
41
+ private async handleResponse<T>(response: Response): Promise<T> {
42
+ if (!response.ok) {
43
+ const body = await response.text();
44
+ throw new ApiException(response.status, body);
45
+ }
46
+ const text = await response.text();
47
+ return text ? JSON.parse(text) : (undefined as T);
48
+ }
49
+
50
+ protected async httpGet<T>(path: string, params?: Record<string, unknown>): Promise<T> {
51
+ const response = await fetch(this.buildUrl(path, params), {
52
+ method: 'GET',
53
+ headers: this.buildHeaders(),
54
+ });
55
+ return this.handleResponse<T>(response);
56
+ }
57
+
58
+ protected async httpPost<T>(path: string, body?: unknown): Promise<T> {
59
+ const response = await fetch(this.baseUrl + path, {
60
+ method: 'POST',
61
+ headers: this.buildHeaders(),
62
+ body: body ? JSON.stringify(body) : undefined,
63
+ });
64
+ return this.handleResponse<T>(response);
65
+ }
66
+
67
+ protected async httpPut<T>(path: string, body: unknown): Promise<T> {
68
+ const response = await fetch(this.baseUrl + path, {
69
+ method: 'PUT',
70
+ headers: this.buildHeaders(),
71
+ body: JSON.stringify(body),
72
+ });
73
+ return this.handleResponse<T>(response);
74
+ }
75
+
76
+ protected async httpPatch<T>(path: string, body: unknown): Promise<T> {
77
+ const response = await fetch(this.baseUrl + path, {
78
+ method: 'PATCH',
79
+ headers: this.buildHeaders(),
80
+ body: JSON.stringify(body),
81
+ });
82
+ return this.handleResponse<T>(response);
83
+ }
84
+
85
+ protected async httpDelete(path: string): Promise<void> {
86
+ const response = await fetch(this.baseUrl + path, {
87
+ method: 'DELETE',
88
+ headers: this.buildHeaders(),
89
+ });
90
+ if (!response.ok) {
91
+ const body = await response.text();
92
+ throw new ApiException(response.status, body);
93
+ }
94
+ }
95
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,153 @@
1
- export * from './runtime';
2
- export * from './logging';
3
- export * from './protocol';
4
- export * from './types';
1
+ export { PersonaSdk } from './persona-sdk';
2
+ export { ApiException } from './exceptions';
3
+ export type { Paginated } from './paginated';
4
+ export { ApiKeyAuthenticationProvider, BearerTokenAuthenticationProvider } from './auth';
5
+ export type { AuthenticationProvider } from './auth';
6
+ export { ProjectsApi } from './projects/projects-api';
7
+ export type { Project, ProjectCreateRequest, ProjectUpdateRequest, ProjectSubscription, ChangeProjectSubscriptionPlanRequest, AddProjectSubscriptionCreditsRequest } from './projects/types';
8
+ export { AgentsApi } from './agents/agents-api';
9
+ export type {
10
+ Agent,
11
+ AgentCreateRequest,
12
+ AgentUpdateRequest,
13
+ AgentProtocol,
14
+ CollaborationConfiguration,
15
+ Collaborator,
16
+ Feature,
17
+ FeatureConfiguration,
18
+ McpServerConfiguration,
19
+ FlagConfiguration,
20
+ SkillConfiguration,
21
+ SkillResource,
22
+ HttpTransport,
23
+ StdioTransport,
24
+ Transport,
25
+ KnowledgeConfiguration,
26
+ KnowledgeType,
27
+ LanguageCode,
28
+ ModelConfiguration,
29
+ ModelName,
30
+ NetworkConfiguration,
31
+ OrchestrationConfiguration,
32
+ OrchestrationAgent,
33
+ SynthesizerConfiguration,
34
+ SynthesizerName,
35
+ SynthesizerVoice,
36
+ TranscriberConfiguration,
37
+ TranscriberName,
38
+ TelegramConfiguration,
39
+ TwilioConfiguration,
40
+ Variable,
41
+ VariableSource,
42
+ WakeupConfiguration,
43
+ WhatsAppConfiguration,
44
+ Tool,
45
+ ToolType,
46
+ ToolConfig,
47
+ ToolLocalConfig,
48
+ ToolRemoteConfig,
49
+ ToolDefinition,
50
+ ToolkitConfiguration,
51
+ StmConfiguration,
52
+ StmType,
53
+ Revision,
54
+ AgentType,
55
+ ReasoningEffort,
56
+ ModelProvider,
57
+ CollaborationMode,
58
+ } from './agents/types';
59
+ export { SessionsApi } from './sessions/sessions-api';
60
+ export type {
61
+ Session,
62
+ GenerationRequest,
63
+ GenerationResponse,
64
+ Message,
65
+ AgentResponse,
66
+ AgentContext,
67
+ CommittedUsage,
68
+ UsageCost,
69
+ SessionFile,
70
+ FunctionCall,
71
+ FunctionResponse,
72
+ Image,
73
+ Source,
74
+ SourceChunk,
75
+ TransferAction,
76
+ CollaborationMode as SessionCollaborationMode,
77
+ } from './sessions/types';
78
+ export { KnowledgeBasesApi } from './knowledges/knowledge-bases-api';
79
+ export { KnowledgeBaseDocumentsApi } from './knowledges/knowledge-base-documents-api';
80
+ export type {
81
+ KnowledgeBase,
82
+ KnowledgeBaseCreateRequest,
83
+ KnowledgeBaseUpdateRequest,
84
+ KnowledgeBaseDocument,
85
+ KnowledgeBaseDocumentUploadRequest,
86
+ KnowledgeBaseDocumentStatus,
87
+ KnowledgeBaseQuality,
88
+ KnowledgeBaseChunkSize,
89
+ EmbeddingModelName,
90
+ DocumentExtractorName,
91
+ ChunkResult,
92
+ SearchChunksRequest,
93
+ } from './knowledges/types';
94
+ export { WorkflowsApi } from './workflows/workflows-api';
95
+ export { WorkflowExecutionsApi } from './workflows/workflow-executions-api';
96
+ export type {
97
+ Workflow,
98
+ Node,
99
+ NodeType,
100
+ StartNode,
101
+ Connection,
102
+ Handle,
103
+ Position,
104
+ Execution,
105
+ ExecutionStatus,
106
+ Step,
107
+ RunResult,
108
+ NodeExecutionResult,
109
+ WorkflowTrigger,
110
+ WorkflowVariable,
111
+ VariableType,
112
+ VariableDirection,
113
+ WorkflowResult,
114
+ ExecuteRequest,
115
+ AgentValue,
116
+ ContentItem,
117
+ ContentItemFile,
118
+ ContentValue,
119
+ Ref,
120
+ } from './workflows/types';
121
+ export { CredentialsApi } from './credentials/credentials-api';
122
+ export type {
123
+ Credentials,
124
+ AuthorizeRequest,
125
+ AuthorizeResponse,
126
+ OAuth2CallbackResponse,
127
+ OAuth2State,
128
+ } from './credentials/types';
129
+ export { TriggersApi } from './triggers/triggers-api';
130
+ export { TriggerExecutionsApi } from './triggers/trigger-executions-api';
131
+ export type {
132
+ Trigger,
133
+ TriggerSource,
134
+ TriggerSourceType,
135
+ TriggerSourceConfiguration,
136
+ GmailTriggerSourceConfiguration,
137
+ ImapTriggerSourceConfiguration,
138
+ TriggerDestination,
139
+ TriggerExecutionResult,
140
+ } from './triggers/types';
141
+ export { FeaturesApi } from './features/features-api';
142
+ export { FeatureTemplatesApi } from './features/feature-templates-api';
143
+ export type {
144
+ FeatureTemplate,
145
+ FeatureType,
146
+ FeatureCredentialsConfiguration,
147
+ McpToolsResponse,
148
+ } from './features/types';
149
+ export { MissionsApi } from './missions/missions-api';
150
+ export type { Mission, MissionStatus } from './missions/types';
151
+ export { ServicePricesApi } from './service-prices/service-prices-api';
152
+ export type { ServicePrice } from './service-prices/types';
153
+ export type { Revision as RevisionType } from './revisions/types';
@@ -0,0 +1,38 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { Paginated } from '../paginated';
3
+ import { AuthenticationProvider } from '../auth/authentication-provider';
4
+ import {
5
+ KnowledgeBaseDocument,
6
+ KnowledgeBaseDocumentUploadRequest,
7
+ } from './types';
8
+
9
+ export class KnowledgeBaseDocumentsApi extends HttpApi {
10
+ private readonly knowledgeBaseId: string;
11
+
12
+ constructor(baseUrl: string, auth: string | AuthenticationProvider, knowledgeBaseId: string) {
13
+ super(baseUrl, auth);
14
+ this.knowledgeBaseId = knowledgeBaseId;
15
+ }
16
+
17
+ async list(keyword?: string | null, page?: number, size?: number): Promise<Paginated<KnowledgeBaseDocument>> {
18
+ const params: Record<string, unknown> = { page, size };
19
+ if (keyword) params.keyword = keyword;
20
+ return this.httpGet<Paginated<KnowledgeBaseDocument>>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', params);
21
+ }
22
+
23
+ async upload(request: KnowledgeBaseDocumentUploadRequest): Promise<KnowledgeBaseDocument> {
24
+ return this.httpPost<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', request);
25
+ }
26
+
27
+ async get(documentId: string): Promise<KnowledgeBaseDocument> {
28
+ return this.httpGet<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents/' + documentId);
29
+ }
30
+
31
+ async reprocess(documentId: string): Promise<KnowledgeBaseDocument> {
32
+ return this.httpPost<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', { document_id: documentId });
33
+ }
34
+
35
+ async remove(documentId: string): Promise<void> {
36
+ await this.httpDelete('/knowledge-bases/' + this.knowledgeBaseId + '/documents/' + documentId);
37
+ }
38
+ }
@@ -0,0 +1,47 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { Paginated } from '../paginated';
3
+ import { AuthenticationProvider } from '../auth/authentication-provider';
4
+ import {
5
+ KnowledgeBase,
6
+ KnowledgeBaseCreateRequest,
7
+ KnowledgeBaseUpdateRequest,
8
+ ChunkResult,
9
+ SearchChunksRequest,
10
+ } from './types';
11
+ import { KnowledgeBaseDocumentsApi } from './knowledge-base-documents-api';
12
+
13
+ export class KnowledgeBasesApi extends HttpApi {
14
+ constructor(baseUrl: string, auth: string | AuthenticationProvider) {
15
+ super(baseUrl, auth);
16
+ }
17
+
18
+ async list(keyword?: string | null, page?: number, size?: number): Promise<Paginated<KnowledgeBase>> {
19
+ const params: Record<string, unknown> = { page, size };
20
+ if (keyword) params.keyword = keyword;
21
+ return this.httpGet<Paginated<KnowledgeBase>>('/knowledge-bases', params);
22
+ }
23
+
24
+ async get(id: string): Promise<KnowledgeBase> {
25
+ return this.httpGet<KnowledgeBase>('/knowledge-bases/' + id);
26
+ }
27
+
28
+ async create(request: KnowledgeBaseCreateRequest): Promise<KnowledgeBase> {
29
+ return this.httpPost<KnowledgeBase>('/knowledge-bases', request);
30
+ }
31
+
32
+ async update(request: KnowledgeBaseUpdateRequest): Promise<KnowledgeBase> {
33
+ return this.httpPut<KnowledgeBase>('/knowledge-bases/' + request.id, request);
34
+ }
35
+
36
+ async remove(id: string): Promise<void> {
37
+ await this.httpDelete('/knowledge-bases/' + id);
38
+ }
39
+
40
+ documents(knowledgeBaseId: string): KnowledgeBaseDocumentsApi {
41
+ return new KnowledgeBaseDocumentsApi(this.getBaseUrl(), this.getAuthProvider(), knowledgeBaseId);
42
+ }
43
+
44
+ async searchChunks(id: string, request: SearchChunksRequest): Promise<ChunkResult[]> {
45
+ return this.httpPost<ChunkResult[]>('/knowledge-bases/' + id + '/search', request);
46
+ }
47
+ }
@@ -0,0 +1,70 @@
1
+ export type KnowledgeBaseQuality = 'extremely_high' | 'very_high' | 'high' | 'medium' | 'low';
2
+
3
+ export type KnowledgeBaseChunkSize = 'small' | 'medium' | 'large';
4
+
5
+ export type EmbeddingModelName = 'text-multilingual-embedding-002' | 'gemini-embedding-001';
6
+
7
+ export type DocumentExtractorName = 'fitz' | 'document-ai' | 'gemini' | 'markdown';
8
+
9
+ export type KnowledgeBaseDocumentStatus = 'pending' | 'processing' | 'completed' | 'failed';
10
+
11
+ export interface KnowledgeBase {
12
+ id?: string;
13
+ projectId?: string;
14
+ name?: string;
15
+ description?: string;
16
+ quality?: KnowledgeBaseQuality;
17
+ chunkSize?: KnowledgeBaseChunkSize;
18
+ embeddingModel?: EmbeddingModelName;
19
+ }
20
+
21
+ export interface KnowledgeBaseCreateRequest {
22
+ name?: string;
23
+ description?: string;
24
+ quality?: KnowledgeBaseQuality;
25
+ chunkSize?: KnowledgeBaseChunkSize;
26
+ embeddingModel?: EmbeddingModelName;
27
+ }
28
+
29
+ export interface KnowledgeBaseUpdateRequest {
30
+ id?: string;
31
+ name?: string;
32
+ description?: string;
33
+ }
34
+
35
+ export interface KnowledgeBaseDocument {
36
+ id?: string;
37
+ knowledgeBaseId?: string;
38
+ path?: string;
39
+ name?: string;
40
+ size?: number;
41
+ contentType?: string;
42
+ status?: KnowledgeBaseDocumentStatus;
43
+ progress?: number;
44
+ extractor?: DocumentExtractorName;
45
+ error?: string;
46
+ metadata?: Record<string, unknown>;
47
+ totalPages?: number;
48
+ callbackUrl?: string;
49
+ }
50
+
51
+ export interface KnowledgeBaseDocumentUploadRequest {
52
+ uri?: string;
53
+ base64?: string;
54
+ name?: string;
55
+ extractor?: DocumentExtractorName;
56
+ callbackUrl?: string;
57
+ }
58
+
59
+ export interface ChunkResult {
60
+ id?: string;
61
+ text?: string;
62
+ score?: number;
63
+ metadata?: Record<string, unknown>;
64
+ documentId?: string;
65
+ }
66
+
67
+ export interface SearchChunksRequest {
68
+ query?: string;
69
+ limit?: number;
70
+ }
@@ -0,0 +1,60 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { AuthenticationProvider } from '../auth/authentication-provider';
3
+ import { Mission } from './types';
4
+
5
+ export class MissionsApi extends HttpApi {
6
+ constructor(baseUrl: string, auth: string | AuthenticationProvider) {
7
+ super(baseUrl, auth);
8
+ }
9
+
10
+ async list(projectId?: string | null, status?: string | null, page?: number, size?: number): Promise<Mission[]> {
11
+ const params: Record<string, unknown> = { page, size };
12
+ if (projectId) params.projectId = projectId;
13
+ if (status) params.status = status;
14
+ return this.httpGet<Mission[]>('/missions', params);
15
+ }
16
+
17
+ async get(missionId: string): Promise<Mission> {
18
+ return this.httpGet<Mission>('/missions/' + missionId);
19
+ }
20
+
21
+ async create(mission: Mission): Promise<Mission> {
22
+ return this.httpPost<Mission>('/missions', mission);
23
+ }
24
+
25
+ async update(missionId: string, mission: Mission): Promise<Mission> {
26
+ return this.httpPut<Mission>('/missions/' + missionId, mission);
27
+ }
28
+
29
+ async remove(missionId: string): Promise<void> {
30
+ await this.httpDelete('/missions/' + missionId);
31
+ }
32
+
33
+ async generate(missionId: string): Promise<Mission> {
34
+ return this.httpPost<Mission>('/missions/' + missionId + '/generate');
35
+ }
36
+
37
+ async execute(missionId: string): Promise<Mission> {
38
+ return this.httpPost<Mission>('/missions/' + missionId + '/execute');
39
+ }
40
+
41
+ async retry(missionId: string): Promise<Mission> {
42
+ return this.httpPost<Mission>('/missions/' + missionId + '/retry');
43
+ }
44
+
45
+ async replan(missionId: string): Promise<Mission> {
46
+ return this.httpPost<Mission>('/missions/' + missionId + '/replan');
47
+ }
48
+
49
+ async sendInstruction(missionId: string, instruction: string): Promise<Mission> {
50
+ return this.httpPost<Mission>('/missions/' + missionId + '/instructions', { instruction });
51
+ }
52
+
53
+ async stop(missionId: string): Promise<Mission> {
54
+ return this.httpPost<Mission>('/missions/' + missionId + '/stop');
55
+ }
56
+
57
+ async resume(missionId: string): Promise<Mission> {
58
+ return this.httpPost<Mission>('/missions/' + missionId + '/continue');
59
+ }
60
+ }
@@ -0,0 +1,25 @@
1
+ export type MissionStatus =
2
+ | 'draft'
3
+ | 'planned'
4
+ | 'active'
5
+ | 'review'
6
+ | 'paused'
7
+ | 'completed'
8
+ | 'failed'
9
+ | 'cancelled';
10
+
11
+ export interface Mission {
12
+ id?: string;
13
+ projectId?: string;
14
+ name?: string;
15
+ goal?: string;
16
+ status?: MissionStatus;
17
+ plannerAgentId?: string;
18
+ workerAgents?: Record<string, unknown>[];
19
+ steps?: Record<string, unknown>[];
20
+ currentStepId?: string;
21
+ version?: number;
22
+ userInstructions?: string[];
23
+ createdAt?: string;
24
+ updatedAt?: string;
25
+ }
@@ -0,0 +1,6 @@
1
+ export interface Paginated<T> {
2
+ items: T[];
3
+ total: number;
4
+ page: number;
5
+ size: number;
6
+ }
@@ -0,0 +1,81 @@
1
+ import { AuthenticationProvider } from './auth/authentication-provider';
2
+ import { ProjectsApi } from './projects/projects-api';
3
+ import { AgentsApi } from './agents/agents-api';
4
+ import { KnowledgeBasesApi } from './knowledges/knowledge-bases-api';
5
+ import { WorkflowsApi } from './workflows/workflows-api';
6
+ import { CredentialsApi } from './credentials/credentials-api';
7
+ import { FeaturesApi } from './features/features-api';
8
+ import { TriggersApi } from './triggers/triggers-api';
9
+ import { ServicePricesApi } from './service-prices/service-prices-api';
10
+ import { SessionsApi } from './sessions/sessions-api';
11
+ import { MissionsApi } from './missions/missions-api';
12
+
13
+ export class PersonaSdk {
14
+ private readonly baseUrl: string;
15
+ private readonly workflowsBaseUrl: string;
16
+
17
+ constructor(baseUrl: string, workflowsBaseUrl: string) {
18
+ this.baseUrl = baseUrl;
19
+ this.workflowsBaseUrl = workflowsBaseUrl;
20
+ }
21
+
22
+ projects(apiKey: string): ProjectsApi;
23
+ projects(authProvider: AuthenticationProvider): ProjectsApi;
24
+ projects(auth: string | AuthenticationProvider): ProjectsApi {
25
+ return new ProjectsApi(this.baseUrl, auth);
26
+ }
27
+
28
+ agents(apiKey: string): AgentsApi;
29
+ agents(authProvider: AuthenticationProvider): AgentsApi;
30
+ agents(auth: string | AuthenticationProvider): AgentsApi {
31
+ return new AgentsApi(this.baseUrl, auth);
32
+ }
33
+
34
+ knowledgeBases(apiKey: string): KnowledgeBasesApi;
35
+ knowledgeBases(authProvider: AuthenticationProvider): KnowledgeBasesApi;
36
+ knowledgeBases(auth: string | AuthenticationProvider): KnowledgeBasesApi {
37
+ return new KnowledgeBasesApi(this.baseUrl, auth);
38
+ }
39
+
40
+ workflows(apiKey: string): WorkflowsApi;
41
+ workflows(authProvider: AuthenticationProvider): WorkflowsApi;
42
+ workflows(auth: string | AuthenticationProvider): WorkflowsApi {
43
+ return new WorkflowsApi(this.workflowsBaseUrl, auth);
44
+ }
45
+
46
+ credentials(apiKey: string): CredentialsApi;
47
+ credentials(authProvider: AuthenticationProvider): CredentialsApi;
48
+ credentials(auth: string | AuthenticationProvider): CredentialsApi {
49
+ return new CredentialsApi(this.baseUrl, auth);
50
+ }
51
+
52
+ features(apiKey: string): FeaturesApi;
53
+ features(authProvider: AuthenticationProvider): FeaturesApi;
54
+ features(auth: string | AuthenticationProvider): FeaturesApi {
55
+ return new FeaturesApi(this.baseUrl, auth);
56
+ }
57
+
58
+ triggers(apiKey: string): TriggersApi;
59
+ triggers(authProvider: AuthenticationProvider): TriggersApi;
60
+ triggers(auth: string | AuthenticationProvider): TriggersApi {
61
+ return new TriggersApi(this.baseUrl, auth);
62
+ }
63
+
64
+ servicePrices(apiKey: string): ServicePricesApi;
65
+ servicePrices(authProvider: AuthenticationProvider): ServicePricesApi;
66
+ servicePrices(auth: string | AuthenticationProvider): ServicePricesApi {
67
+ return new ServicePricesApi(this.baseUrl, auth);
68
+ }
69
+
70
+ sessions(apiKey: string): SessionsApi;
71
+ sessions(authProvider: AuthenticationProvider): SessionsApi;
72
+ sessions(auth: string | AuthenticationProvider): SessionsApi {
73
+ return new SessionsApi(this.baseUrl, auth);
74
+ }
75
+
76
+ missions(apiKey: string): MissionsApi;
77
+ missions(authProvider: AuthenticationProvider): MissionsApi;
78
+ missions(auth: string | AuthenticationProvider): MissionsApi {
79
+ return new MissionsApi(this.baseUrl, auth);
80
+ }
81
+ }
@@ -0,0 +1,55 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { Paginated } from '../paginated';
3
+ import { AuthenticationProvider } from '../auth/authentication-provider';
4
+ import {
5
+ Project,
6
+ ProjectCreateRequest,
7
+ ProjectUpdateRequest,
8
+ ProjectSubscription,
9
+ ChangeProjectSubscriptionPlanRequest,
10
+ AddProjectSubscriptionCreditsRequest,
11
+ } from './types';
12
+
13
+ export class ProjectsApi extends HttpApi {
14
+ constructor(baseUrl: string, auth: string | AuthenticationProvider) {
15
+ super(baseUrl, auth);
16
+ }
17
+
18
+ async list(keyword: string | null, page: number, size: number): Promise<Paginated<Project>> {
19
+ const params: Record<string, unknown> = { page, size };
20
+ if (keyword) params.keyword = keyword;
21
+ return this.httpGet<Paginated<Project>>('/projects', params);
22
+ }
23
+
24
+ async get(projectId: string): Promise<Project> {
25
+ return this.httpGet<Project>('/projects/' + projectId);
26
+ }
27
+
28
+ async getMine(): Promise<Project> {
29
+ return this.httpGet<Project>('/projects/mine');
30
+ }
31
+
32
+ async create(request: ProjectCreateRequest): Promise<Project> {
33
+ return this.httpPost<Project>('/projects', request);
34
+ }
35
+
36
+ async update(request: ProjectUpdateRequest): Promise<Project> {
37
+ return this.httpPut<Project>('/projects/' + request.projectId, request);
38
+ }
39
+
40
+ async remove(projectId: string): Promise<void> {
41
+ await this.httpDelete('/projects/' + projectId);
42
+ }
43
+
44
+ async getSubscription(projectId: string): Promise<ProjectSubscription> {
45
+ return this.httpGet<ProjectSubscription>('/projects/' + projectId + '/subscription');
46
+ }
47
+
48
+ async changeSubscriptionPlan(projectId: string, request: ChangeProjectSubscriptionPlanRequest): Promise<ProjectSubscription> {
49
+ return this.httpPost<ProjectSubscription>('/projects/' + projectId + '/subscription/plan', request);
50
+ }
51
+
52
+ async addSubscriptionCredits(projectId: string, request: AddProjectSubscriptionCreditsRequest): Promise<ProjectSubscription> {
53
+ return this.httpPost<ProjectSubscription>('/projects/' + projectId + '/subscription/credits', request);
54
+ }
55
+ }