@applica-software-guru/persona-sdk 0.1.100 → 0.1.102
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 +753 -5084
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1504 -8
- 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 +181 -7
- 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/human-tasks-api.ts +44 -0
- package/src/workflows/types.ts +173 -0
- package/src/workflows/workflow-executions-api.ts +94 -0
- package/src/workflows/workflows-api.ts +57 -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/projects.d.ts +0 -17
- package/dist/projects.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 -237
- 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/projects.ts +0 -57
- 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 -284
- package/tsconfig.node.json +0 -15
package/src/index.ts
CHANGED
|
@@ -1,7 +1,181 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
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, ProjectDuplicateRequest, 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
|
+
NetworkConfiguration,
|
|
30
|
+
OrchestrationConfiguration,
|
|
31
|
+
OrchestrationAgent,
|
|
32
|
+
SynthesizerConfiguration,
|
|
33
|
+
SynthesizerName,
|
|
34
|
+
SynthesizerVoice,
|
|
35
|
+
TranscriberConfiguration,
|
|
36
|
+
TranscriberName,
|
|
37
|
+
TelegramConfiguration,
|
|
38
|
+
TwilioConfiguration,
|
|
39
|
+
Variable,
|
|
40
|
+
VariableSource,
|
|
41
|
+
WakeupConfiguration,
|
|
42
|
+
WhatsAppConfiguration,
|
|
43
|
+
Tool,
|
|
44
|
+
ToolType,
|
|
45
|
+
ToolConfig,
|
|
46
|
+
ToolLocalConfig,
|
|
47
|
+
ToolRemoteConfig,
|
|
48
|
+
ToolDefinition,
|
|
49
|
+
ToolkitConfiguration,
|
|
50
|
+
StmConfiguration,
|
|
51
|
+
StmType,
|
|
52
|
+
Revision,
|
|
53
|
+
AgentType,
|
|
54
|
+
ReasoningEffort,
|
|
55
|
+
ModelProvider,
|
|
56
|
+
CollaborationMode,
|
|
57
|
+
ContextManagementConfiguration,
|
|
58
|
+
AttachmentsPreprocessorConfiguration,
|
|
59
|
+
AttachmentsPreprocessorImageHandling,
|
|
60
|
+
} from './agents/types';
|
|
61
|
+
export { SessionsApi } from './sessions/sessions-api';
|
|
62
|
+
export type {
|
|
63
|
+
Session,
|
|
64
|
+
GenerationRequest,
|
|
65
|
+
GenerationResponse,
|
|
66
|
+
Message,
|
|
67
|
+
AgentResponse,
|
|
68
|
+
AgentContext,
|
|
69
|
+
CommittedUsage,
|
|
70
|
+
UsageCost,
|
|
71
|
+
SessionFile,
|
|
72
|
+
FunctionCall,
|
|
73
|
+
FunctionResponse,
|
|
74
|
+
Image,
|
|
75
|
+
Source,
|
|
76
|
+
SourceChunk,
|
|
77
|
+
TransferAction,
|
|
78
|
+
CollaborationMode as SessionCollaborationMode,
|
|
79
|
+
} from './sessions/types';
|
|
80
|
+
export { KnowledgeBasesApi } from './knowledges/knowledge-bases-api';
|
|
81
|
+
export { KnowledgeBaseDocumentsApi } from './knowledges/knowledge-base-documents-api';
|
|
82
|
+
export type {
|
|
83
|
+
KnowledgeBase,
|
|
84
|
+
KnowledgeBaseCreateRequest,
|
|
85
|
+
KnowledgeBaseUpdateRequest,
|
|
86
|
+
KnowledgeBaseDocument,
|
|
87
|
+
KnowledgeBaseDocumentUploadRequest,
|
|
88
|
+
KnowledgeBaseDocumentStatus,
|
|
89
|
+
KnowledgeBaseQuality,
|
|
90
|
+
KnowledgeBaseChunkSize,
|
|
91
|
+
EmbeddingModelName,
|
|
92
|
+
DocumentExtractorName,
|
|
93
|
+
ChunkResult,
|
|
94
|
+
SearchChunksRequest,
|
|
95
|
+
} from './knowledges/types';
|
|
96
|
+
export { WorkflowsApi } from './workflows/workflows-api';
|
|
97
|
+
export { WorkflowExecutionsApi } from './workflows/workflow-executions-api';
|
|
98
|
+
export { HumanTasksApi } from './workflows/human-tasks-api';
|
|
99
|
+
export type {
|
|
100
|
+
Workflow,
|
|
101
|
+
Node,
|
|
102
|
+
NodeType,
|
|
103
|
+
StartNode,
|
|
104
|
+
Connection,
|
|
105
|
+
Handle,
|
|
106
|
+
Position,
|
|
107
|
+
Execution,
|
|
108
|
+
ExecutionStatus,
|
|
109
|
+
Step,
|
|
110
|
+
RunResult,
|
|
111
|
+
NodeExecutionResult,
|
|
112
|
+
WorkflowTrigger,
|
|
113
|
+
WorkflowVariable,
|
|
114
|
+
VariableType,
|
|
115
|
+
VariableDirection,
|
|
116
|
+
WorkflowResult,
|
|
117
|
+
ExecuteRequest,
|
|
118
|
+
HumanTask,
|
|
119
|
+
AgentValue,
|
|
120
|
+
ContentItem,
|
|
121
|
+
ContentItemFile,
|
|
122
|
+
ContentValue,
|
|
123
|
+
Ref,
|
|
124
|
+
} from './workflows/types';
|
|
125
|
+
export { CredentialsApi } from './credentials/credentials-api';
|
|
126
|
+
export type {
|
|
127
|
+
Credentials,
|
|
128
|
+
AuthorizeRequest,
|
|
129
|
+
AuthorizeResponse,
|
|
130
|
+
OAuth2CallbackResponse,
|
|
131
|
+
OAuth2State,
|
|
132
|
+
} from './credentials/types';
|
|
133
|
+
export { TriggersApi } from './triggers/triggers-api';
|
|
134
|
+
export { TriggerExecutionsApi } from './triggers/trigger-executions-api';
|
|
135
|
+
export type {
|
|
136
|
+
Trigger,
|
|
137
|
+
TriggerSource,
|
|
138
|
+
TriggerSourceType,
|
|
139
|
+
TriggerSourceConfiguration,
|
|
140
|
+
GmailTriggerSourceConfiguration,
|
|
141
|
+
ImapTriggerSourceConfiguration,
|
|
142
|
+
TriggerDestination,
|
|
143
|
+
TriggerExecutionResult,
|
|
144
|
+
} from './triggers/types';
|
|
145
|
+
export { FeaturesApi } from './features/features-api';
|
|
146
|
+
export { FeatureTemplatesApi } from './features/feature-templates-api';
|
|
147
|
+
export type {
|
|
148
|
+
FeatureTemplate,
|
|
149
|
+
FeatureType,
|
|
150
|
+
FeatureCredentialsConfiguration,
|
|
151
|
+
McpToolsResponse,
|
|
152
|
+
} from './features/types';
|
|
153
|
+
export { MissionsApi } from './missions/missions-api';
|
|
154
|
+
export type { Mission, MissionStatus } from './missions/types';
|
|
155
|
+
export { ServicePricesApi } from './service-prices/service-prices-api';
|
|
156
|
+
export type { ServicePrice } from './service-prices/types';
|
|
157
|
+
export { KnownModelsApi } from './known-models/known-models-api';
|
|
158
|
+
export type { KnownModel } from './known-models/types';
|
|
159
|
+
export type { Revision as RevisionType } from './revisions/types';
|
|
160
|
+
export { BillingClient } from './billing/billing-client';
|
|
161
|
+
export { ValuesApi } from './values/values-api';
|
|
162
|
+
export type {
|
|
163
|
+
Customer,
|
|
164
|
+
Subscription,
|
|
165
|
+
Invoice,
|
|
166
|
+
LineItem,
|
|
167
|
+
Usage as BillingUsage,
|
|
168
|
+
Payment,
|
|
169
|
+
CreateCustomerRequest,
|
|
170
|
+
UpdateCustomerRequest,
|
|
171
|
+
CreateSubscriptionRequest,
|
|
172
|
+
UpgradeSubscriptionRequest,
|
|
173
|
+
DowngradeSubscriptionRequest,
|
|
174
|
+
MentorizeSubscriptionRequest,
|
|
175
|
+
UsageStats,
|
|
176
|
+
UsageTotals,
|
|
177
|
+
UsageDailyEntry,
|
|
178
|
+
UsageModelEntry,
|
|
179
|
+
UsageDetail,
|
|
180
|
+
UsagePage,
|
|
181
|
+
} from './billing/types';
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { page: p, size: s } = this.normalizePageParams(page, size);
|
|
19
|
+
const params: Record<string, unknown> = { page: p, size: s };
|
|
20
|
+
if (keyword) params.keyword = keyword;
|
|
21
|
+
return this.httpGet<Paginated<KnowledgeBaseDocument>>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async upload(request: KnowledgeBaseDocumentUploadRequest): Promise<KnowledgeBaseDocument> {
|
|
25
|
+
return this.httpPost<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', request);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async get(documentId: string): Promise<KnowledgeBaseDocument> {
|
|
29
|
+
return this.httpGet<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents/' + documentId);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async reprocess(documentId: string): Promise<KnowledgeBaseDocument> {
|
|
33
|
+
return this.httpPost<KnowledgeBaseDocument>('/knowledge-bases/' + this.knowledgeBaseId + '/documents', { document_id: documentId });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async remove(documentId: string): Promise<void> {
|
|
37
|
+
await this.httpDelete('/knowledge-bases/' + this.knowledgeBaseId + '/documents/' + documentId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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, extraParams?: Record<string, string>): Promise<Paginated<KnowledgeBase>> {
|
|
19
|
+
const { page: p, size: s } = this.normalizePageParams(page, size);
|
|
20
|
+
const params: Record<string, unknown> = { page: p, size: s, ...extraParams };
|
|
21
|
+
if (keyword) params.keyword = keyword;
|
|
22
|
+
return this.httpGet<Paginated<KnowledgeBase>>('/knowledge-bases', params);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async get(id: string): Promise<KnowledgeBase> {
|
|
26
|
+
return this.httpGet<KnowledgeBase>('/knowledge-bases/' + id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async create(request: KnowledgeBaseCreateRequest): Promise<KnowledgeBase> {
|
|
30
|
+
return this.httpPost<KnowledgeBase>('/knowledge-bases', request);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async update(request: KnowledgeBaseUpdateRequest): Promise<KnowledgeBase> {
|
|
34
|
+
return this.httpPut<KnowledgeBase>('/knowledge-bases/' + request.id, request);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async remove(id: string): Promise<void> {
|
|
38
|
+
await this.httpDelete('/knowledge-bases/' + id);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
documents(knowledgeBaseId: string): KnowledgeBaseDocumentsApi {
|
|
42
|
+
return new KnowledgeBaseDocumentsApi(this.getBaseUrl(), this.getAuthProvider(), knowledgeBaseId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async searchChunks(id: string, request: SearchChunksRequest): Promise<ChunkResult[]> {
|
|
46
|
+
return this.httpPost<ChunkResult[]>('/knowledge-bases/' + id + '/search', request);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -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,33 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { KnownModel } from './types';
|
|
5
|
+
|
|
6
|
+
export class KnownModelsApi extends HttpApi {
|
|
7
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
8
|
+
super(baseUrl, auth);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async list(keyword?: string | null, page?: number, size?: number, extraParams?: Record<string, string>): Promise<Paginated<KnownModel>> {
|
|
12
|
+
const { page: p, size: s } = this.normalizePageParams(page, size);
|
|
13
|
+
const params: Record<string, unknown> = { page: p, size: s, ...extraParams };
|
|
14
|
+
if (keyword) params.keyword = keyword;
|
|
15
|
+
return this.httpGet<Paginated<KnownModel>>('/known-models', params);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async get(id: string): Promise<KnownModel> {
|
|
19
|
+
return this.httpGet<KnownModel>('/known-models/' + id);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async create(knownModel: KnownModel): Promise<KnownModel> {
|
|
23
|
+
return this.httpPost<KnownModel>('/known-models', knownModel);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async update(id: string, knownModel: KnownModel): Promise<KnownModel> {
|
|
27
|
+
return this.httpPut<KnownModel>('/known-models/' + id, knownModel);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async remove(id: string): Promise<void> {
|
|
31
|
+
await this.httpDelete('/known-models/' + id);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
3
|
+
import { Paginated } from '../paginated';
|
|
4
|
+
import { Mission } from './types';
|
|
5
|
+
|
|
6
|
+
export class MissionsApi extends HttpApi {
|
|
7
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
8
|
+
super(baseUrl, auth);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async list(keyword?: string | null, page?: number, size?: number, status?: string | null): Promise<Paginated<Mission>> {
|
|
12
|
+
const { page: p, size: s } = this.normalizePageParams(page, size);
|
|
13
|
+
const params: Record<string, unknown> = { page: p, size: s };
|
|
14
|
+
if (keyword) params.keyword = keyword;
|
|
15
|
+
if (status) params.status = status;
|
|
16
|
+
return this.httpGet<Paginated<Mission>>('/missions', params);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async get(missionId: string): Promise<Mission> {
|
|
20
|
+
return this.httpGet<Mission>('/missions/' + missionId);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async create(mission: Mission): Promise<Mission> {
|
|
24
|
+
return this.httpPost<Mission>('/missions', mission);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async update(missionId: string, mission: Mission): Promise<Mission> {
|
|
28
|
+
return this.httpPut<Mission>('/missions/' + missionId, mission);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async remove(missionId: string): Promise<void> {
|
|
32
|
+
await this.httpDelete('/missions/' + missionId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async generate(missionId: string): Promise<Mission> {
|
|
36
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/generate');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async execute(missionId: string): Promise<Mission> {
|
|
40
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/execute');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async retry(missionId: string): Promise<Mission> {
|
|
44
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/retry');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async replan(missionId: string): Promise<Mission> {
|
|
48
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/replan');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async sendInstruction(missionId: string, instruction: string): Promise<Mission> {
|
|
52
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/instructions', { instruction });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async stop(missionId: string): Promise<Mission> {
|
|
56
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/stop');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async resume(missionId: string): Promise<Mission> {
|
|
60
|
+
return this.httpPost<Mission>('/missions/' + missionId + '/continue');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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
|
+
}
|
package/src/paginated.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 { KnownModelsApi } from './known-models/known-models-api';
|
|
11
|
+
import { SessionsApi } from './sessions/sessions-api';
|
|
12
|
+
import { MissionsApi } from './missions/missions-api';
|
|
13
|
+
import { BillingClient } from './billing/billing-client';
|
|
14
|
+
import { ValuesApi } from './values/values-api';
|
|
15
|
+
|
|
16
|
+
export class PersonaSdk {
|
|
17
|
+
private readonly baseUrl: string;
|
|
18
|
+
private readonly workflowsBaseUrl: string;
|
|
19
|
+
private readonly billingBaseUrl: string;
|
|
20
|
+
|
|
21
|
+
constructor(baseUrl: string, workflowsBaseUrl: string, billingBaseUrl?: string) {
|
|
22
|
+
this.baseUrl = baseUrl;
|
|
23
|
+
this.workflowsBaseUrl = workflowsBaseUrl;
|
|
24
|
+
this.billingBaseUrl = billingBaseUrl || 'https://persona.applica.guru/billing';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
projects(apiKey: string): ProjectsApi;
|
|
28
|
+
projects(authProvider: AuthenticationProvider): ProjectsApi;
|
|
29
|
+
projects(auth: string | AuthenticationProvider): ProjectsApi {
|
|
30
|
+
return new ProjectsApi(this.baseUrl, auth, this.billingBaseUrl);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
agents(apiKey: string): AgentsApi;
|
|
34
|
+
agents(authProvider: AuthenticationProvider): AgentsApi;
|
|
35
|
+
agents(auth: string | AuthenticationProvider): AgentsApi {
|
|
36
|
+
return new AgentsApi(this.baseUrl, auth);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
knowledgeBases(apiKey: string): KnowledgeBasesApi;
|
|
40
|
+
knowledgeBases(authProvider: AuthenticationProvider): KnowledgeBasesApi;
|
|
41
|
+
knowledgeBases(auth: string | AuthenticationProvider): KnowledgeBasesApi {
|
|
42
|
+
return new KnowledgeBasesApi(this.baseUrl, auth);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
workflows(apiKey: string): WorkflowsApi;
|
|
46
|
+
workflows(authProvider: AuthenticationProvider): WorkflowsApi;
|
|
47
|
+
workflows(auth: string | AuthenticationProvider): WorkflowsApi {
|
|
48
|
+
return new WorkflowsApi(this.workflowsBaseUrl, auth);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
credentials(apiKey: string): CredentialsApi;
|
|
52
|
+
credentials(authProvider: AuthenticationProvider): CredentialsApi;
|
|
53
|
+
credentials(auth: string | AuthenticationProvider): CredentialsApi {
|
|
54
|
+
return new CredentialsApi(this.baseUrl, auth);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
features(apiKey: string): FeaturesApi;
|
|
58
|
+
features(authProvider: AuthenticationProvider): FeaturesApi;
|
|
59
|
+
features(auth: string | AuthenticationProvider): FeaturesApi {
|
|
60
|
+
return new FeaturesApi(this.baseUrl, auth);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
triggers(apiKey: string): TriggersApi;
|
|
64
|
+
triggers(authProvider: AuthenticationProvider): TriggersApi;
|
|
65
|
+
triggers(auth: string | AuthenticationProvider): TriggersApi {
|
|
66
|
+
return new TriggersApi(this.baseUrl, auth);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
servicePrices(apiKey: string): ServicePricesApi;
|
|
70
|
+
servicePrices(authProvider: AuthenticationProvider): ServicePricesApi;
|
|
71
|
+
servicePrices(auth: string | AuthenticationProvider): ServicePricesApi {
|
|
72
|
+
return new ServicePricesApi(this.baseUrl, auth);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
knownModels(apiKey: string): KnownModelsApi;
|
|
76
|
+
knownModels(authProvider: AuthenticationProvider): KnownModelsApi;
|
|
77
|
+
knownModels(auth: string | AuthenticationProvider): KnownModelsApi {
|
|
78
|
+
return new KnownModelsApi(this.baseUrl, auth);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
sessions(apiKey: string): SessionsApi;
|
|
82
|
+
sessions(authProvider: AuthenticationProvider): SessionsApi;
|
|
83
|
+
sessions(auth: string | AuthenticationProvider): SessionsApi {
|
|
84
|
+
return new SessionsApi(this.baseUrl, auth);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
missions(apiKey: string): MissionsApi;
|
|
88
|
+
missions(authProvider: AuthenticationProvider): MissionsApi;
|
|
89
|
+
missions(auth: string | AuthenticationProvider): MissionsApi {
|
|
90
|
+
return new MissionsApi(this.baseUrl, auth);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
billing(apiKey: string): BillingClient;
|
|
94
|
+
billing(authProvider: AuthenticationProvider): BillingClient;
|
|
95
|
+
billing(auth: string | AuthenticationProvider): BillingClient {
|
|
96
|
+
return new BillingClient(this.billingBaseUrl, auth);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
values(apiKey: string): ValuesApi;
|
|
100
|
+
values(authProvider: AuthenticationProvider): ValuesApi;
|
|
101
|
+
values(auth: string | AuthenticationProvider): ValuesApi {
|
|
102
|
+
return new ValuesApi(this.baseUrl, auth);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { ApiException } from '../exceptions';
|
|
3
|
+
import { Paginated } from '../paginated';
|
|
4
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
5
|
+
import {
|
|
6
|
+
Project,
|
|
7
|
+
ProjectCreateRequest,
|
|
8
|
+
ProjectUpdateRequest,
|
|
9
|
+
ProjectDuplicateRequest,
|
|
10
|
+
ProjectSubscription,
|
|
11
|
+
ChangeProjectSubscriptionPlanRequest,
|
|
12
|
+
AddProjectSubscriptionCreditsRequest,
|
|
13
|
+
SetProjectSubscriptionInfiniteCreditsRequest,
|
|
14
|
+
} from './types';
|
|
15
|
+
|
|
16
|
+
export class ProjectsApi extends HttpApi {
|
|
17
|
+
private readonly billingBaseUrl: string;
|
|
18
|
+
|
|
19
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider, billingBaseUrl?: string) {
|
|
20
|
+
super(baseUrl, auth);
|
|
21
|
+
this.billingBaseUrl = (billingBaseUrl || baseUrl).replace(/\/$/, '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async list(keyword: string | null, page: number, size: number): Promise<Paginated<Project>> {
|
|
25
|
+
const { page: p, size: s } = this.normalizePageParams(page, size);
|
|
26
|
+
const params: Record<string, unknown> = { page: p, size: s };
|
|
27
|
+
if (keyword) params.keyword = keyword;
|
|
28
|
+
return this.httpGet<Paginated<Project>>('/projects', params);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async get(projectId: string): Promise<Project> {
|
|
32
|
+
return this.httpGet<Project>('/projects/' + projectId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getMine(): Promise<Project> {
|
|
36
|
+
return this.httpGet<Project>('/projects/mine');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async create(request: ProjectCreateRequest): Promise<Project> {
|
|
40
|
+
return this.httpPost<Project>('/projects', request);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async update(request: ProjectUpdateRequest): Promise<Project> {
|
|
44
|
+
return this.httpPut<Project>('/projects/' + request.projectId, request);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async remove(projectId: string): Promise<void> {
|
|
48
|
+
await this.httpDelete('/projects/' + projectId);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async duplicate(projectId: string, request: ProjectDuplicateRequest): Promise<Project> {
|
|
52
|
+
return this.httpPost<Project>('/projects/' + projectId + '/actions/duplicate', request);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async getSubscription(projectId: string): Promise<ProjectSubscription> {
|
|
56
|
+
return this.billingRequest<ProjectSubscription>('/projects/' + projectId + '/subscription', 'GET');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async changeSubscriptionPlan(projectId: string, request: ChangeProjectSubscriptionPlanRequest): Promise<ProjectSubscription> {
|
|
60
|
+
return this.billingRequest<ProjectSubscription>('/projects/' + projectId + '/subscription/actions/change-plan', 'POST', request);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async addSubscriptionCredits(projectId: string, request: AddProjectSubscriptionCreditsRequest): Promise<ProjectSubscription> {
|
|
64
|
+
return this.billingRequest<ProjectSubscription>('/projects/' + projectId + '/subscription/actions/add-credits', 'POST', request);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async setInfiniteCredits(projectId: string, request: SetProjectSubscriptionInfiniteCreditsRequest): Promise<ProjectSubscription> {
|
|
68
|
+
return this.billingRequest<ProjectSubscription>('/projects/' + projectId + '/subscription/actions/set-infinite-credits', 'POST', request);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private async billingRequest<T>(path: string, method: string, body?: unknown): Promise<T> {
|
|
72
|
+
const headers = new Headers();
|
|
73
|
+
headers.set('Content-Type', 'application/json');
|
|
74
|
+
this.getAuthProvider().applyHeaders(headers);
|
|
75
|
+
|
|
76
|
+
const response = await fetch(this.billingBaseUrl + path, {
|
|
77
|
+
method,
|
|
78
|
+
headers,
|
|
79
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
const text = await response.text();
|
|
84
|
+
throw new ApiException(response.status, text);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const text = await response.text();
|
|
88
|
+
return text ? JSON.parse(text) : (undefined as T);
|
|
89
|
+
}
|
|
90
|
+
}
|