@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface Project {
|
|
2
|
+
id?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
tag?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ProjectCreateRequest {
|
|
9
|
+
name: string;
|
|
10
|
+
tag?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ProjectUpdateRequest {
|
|
14
|
+
projectId: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
tag?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ProjectSubscription {
|
|
20
|
+
id?: string;
|
|
21
|
+
projectId?: string;
|
|
22
|
+
owner?: string;
|
|
23
|
+
planType?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
startDate?: string;
|
|
26
|
+
planCredits?: number;
|
|
27
|
+
extraCredits?: number;
|
|
28
|
+
keepCreditsOnRenew?: boolean;
|
|
29
|
+
endDate?: string;
|
|
30
|
+
createdAt?: string;
|
|
31
|
+
updatedAt?: string;
|
|
32
|
+
stripeCustomerId?: string;
|
|
33
|
+
stripeSubscriptionId?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ChangeProjectSubscriptionPlanRequest {
|
|
37
|
+
toPlanType: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AddProjectSubscriptionCreditsRequest {
|
|
41
|
+
credits: number;
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { ServicePrice } from './types';
|
|
5
|
+
|
|
6
|
+
export class ServicePricesApi 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): Promise<Paginated<ServicePrice>> {
|
|
12
|
+
const params: Record<string, unknown> = { page, size };
|
|
13
|
+
if (keyword) params.keyword = keyword;
|
|
14
|
+
return this.httpGet<Paginated<ServicePrice>>('/service-prices', params);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async get(id: string): Promise<ServicePrice> {
|
|
18
|
+
return this.httpGet<ServicePrice>('/service-prices/' + id);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async create(servicePrice: ServicePrice): Promise<ServicePrice> {
|
|
22
|
+
return this.httpPost<ServicePrice>('/service-prices', servicePrice);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async update(id: string, servicePrice: ServicePrice): Promise<ServicePrice> {
|
|
26
|
+
return this.httpPut<ServicePrice>('/service-prices/' + id, servicePrice);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async remove(id: string): Promise<void> {
|
|
30
|
+
await this.httpDelete('/service-prices/' + id);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -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
|
+
Session,
|
|
6
|
+
GenerationRequest,
|
|
7
|
+
GenerationResponse,
|
|
8
|
+
Message,
|
|
9
|
+
CommittedUsage,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
export class SessionsApi extends HttpApi {
|
|
13
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
14
|
+
super(baseUrl, auth);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async list(
|
|
18
|
+
keyword?: string | null,
|
|
19
|
+
status?: string | null,
|
|
20
|
+
agentId?: string | null,
|
|
21
|
+
userId?: string | null,
|
|
22
|
+
page?: number,
|
|
23
|
+
size?: number,
|
|
24
|
+
): Promise<Paginated<Session>> {
|
|
25
|
+
const params: Record<string, unknown> = { page, size };
|
|
26
|
+
if (keyword) params.keyword = keyword;
|
|
27
|
+
if (status) params.status = status;
|
|
28
|
+
if (agentId) params.agentId = agentId;
|
|
29
|
+
if (userId) params.userId = userId;
|
|
30
|
+
return this.httpGet<Paginated<Session>>('/sessions', params);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async get(sessionId: string): Promise<Session> {
|
|
34
|
+
return this.httpGet<Session>('/sessions/' + sessionId);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getUsage(sessionId: string): Promise<CommittedUsage[]> {
|
|
38
|
+
return this.httpGet<CommittedUsage[]>('/sessions/' + sessionId + '/usage');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async generateMessage(code: string, request: GenerationRequest): Promise<GenerationResponse> {
|
|
42
|
+
return this.httpPost<GenerationResponse>('/sessions/' + code + '/messages', request);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async findMessages(code: string, page?: number, size?: number): Promise<Paginated<Message>> {
|
|
46
|
+
const params: Record<string, unknown> = {};
|
|
47
|
+
if (page !== undefined) params.page = page;
|
|
48
|
+
if (size !== undefined) params.size = size;
|
|
49
|
+
return this.httpGet<Paginated<Message>>('/sessions/' + code + '/messages', params);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async remove(code: string): Promise<void> {
|
|
53
|
+
await this.httpDelete('/sessions/' + code);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export interface Image {
|
|
2
|
+
content?: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface SessionFile {
|
|
7
|
+
name?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
base64?: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FunctionCall {
|
|
14
|
+
name?: string;
|
|
15
|
+
args?: Record<string, unknown>;
|
|
16
|
+
id?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FunctionResponse {
|
|
20
|
+
name?: string;
|
|
21
|
+
result?: Record<string, unknown>;
|
|
22
|
+
functionCallId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SourceChunk {
|
|
26
|
+
start?: number;
|
|
27
|
+
end?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Source {
|
|
31
|
+
type?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
documentId?: string;
|
|
34
|
+
pageId?: string;
|
|
35
|
+
pageNumber?: number;
|
|
36
|
+
chunks?: SourceChunk[];
|
|
37
|
+
mostRelevant?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type CollaborationMode = 'delegate_and_return' | 'persistent_transfer' | 'consult_then_respond';
|
|
41
|
+
|
|
42
|
+
export interface TransferAction {
|
|
43
|
+
request?: string;
|
|
44
|
+
thought?: string;
|
|
45
|
+
agent?: string;
|
|
46
|
+
functionCallMessage?: Message;
|
|
47
|
+
functionResponseMessage?: Message;
|
|
48
|
+
collaborationMode?: CollaborationMode;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface Message {
|
|
52
|
+
id?: string;
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
text?: string;
|
|
55
|
+
image?: Image;
|
|
56
|
+
file?: SessionFile;
|
|
57
|
+
role?: string;
|
|
58
|
+
timestamp?: number;
|
|
59
|
+
createdAt?: string;
|
|
60
|
+
functionCalls?: FunctionCall[];
|
|
61
|
+
functionResponse?: FunctionResponse;
|
|
62
|
+
finishReason?: string;
|
|
63
|
+
sources?: Source[];
|
|
64
|
+
task?: Record<string, unknown>;
|
|
65
|
+
sender?: string;
|
|
66
|
+
thought?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface AgentResponse {
|
|
70
|
+
messages?: Message[];
|
|
71
|
+
transfer?: TransferAction;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface AgentContext {}
|
|
75
|
+
|
|
76
|
+
export interface UsageCost {
|
|
77
|
+
service?: string;
|
|
78
|
+
value?: number;
|
|
79
|
+
cost?: number;
|
|
80
|
+
price?: number;
|
|
81
|
+
credits?: number;
|
|
82
|
+
unit?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface CommittedUsage {
|
|
86
|
+
id?: string;
|
|
87
|
+
committedAt?: string;
|
|
88
|
+
projectId?: string;
|
|
89
|
+
sessionId?: string;
|
|
90
|
+
creditsUsed?: number;
|
|
91
|
+
totalCost?: number;
|
|
92
|
+
totalPrice?: number;
|
|
93
|
+
userId?: string;
|
|
94
|
+
details?: UsageCost[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface Session {
|
|
98
|
+
id?: string;
|
|
99
|
+
code?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
projectId?: string;
|
|
102
|
+
agentId?: string;
|
|
103
|
+
currentAgentId?: string;
|
|
104
|
+
userId?: string;
|
|
105
|
+
status?: string;
|
|
106
|
+
visibility?: string;
|
|
107
|
+
type?: string;
|
|
108
|
+
createdAt?: string;
|
|
109
|
+
finishedAt?: string;
|
|
110
|
+
parentSessionId?: string;
|
|
111
|
+
protocol?: string;
|
|
112
|
+
extras?: Record<string, unknown>;
|
|
113
|
+
isNew?: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface GenerationRequest {
|
|
117
|
+
agentId?: string;
|
|
118
|
+
userMessage?: unknown;
|
|
119
|
+
initialContext?: AgentContext;
|
|
120
|
+
responseSchema?: Record<string, unknown>;
|
|
121
|
+
parentSessionId?: string;
|
|
122
|
+
userId?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface GenerationResponse {
|
|
126
|
+
json?: unknown;
|
|
127
|
+
response?: AgentResponse;
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { TriggerExecutionResult } from './types';
|
|
5
|
+
|
|
6
|
+
export class TriggerExecutionsApi extends HttpApi {
|
|
7
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
8
|
+
super(baseUrl, auth);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async list(triggerId: string, page?: number, size?: number): Promise<Paginated<TriggerExecutionResult>> {
|
|
12
|
+
const params: Record<string, unknown> = { page, size };
|
|
13
|
+
return this.httpGet<Paginated<TriggerExecutionResult>>('/triggers/' + triggerId + '/executions', params);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async execute(triggerId: string, execution: TriggerExecutionResult): Promise<TriggerExecutionResult> {
|
|
17
|
+
return this.httpPost<TriggerExecutionResult>('/triggers/' + triggerId + '/executions', execution);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async get(executionId: string): Promise<TriggerExecutionResult> {
|
|
21
|
+
return this.httpGet<TriggerExecutionResult>('/triggers/executions/' + executionId);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async remove(executionId: string): Promise<void> {
|
|
25
|
+
await this.httpDelete('/triggers/executions/' + executionId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { Trigger } from './types';
|
|
5
|
+
import { TriggerExecutionsApi } from './trigger-executions-api';
|
|
6
|
+
|
|
7
|
+
export class TriggersApi 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<Trigger>> {
|
|
13
|
+
const params: Record<string, unknown> = { page, size };
|
|
14
|
+
if (keyword) params.keyword = keyword;
|
|
15
|
+
return this.httpGet<Paginated<Trigger>>('/triggers', params);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async create(trigger: Trigger): Promise<Trigger> {
|
|
19
|
+
return this.httpPost<Trigger>('/triggers', trigger);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async update(triggerId: string, trigger: Trigger): Promise<Trigger> {
|
|
23
|
+
return this.httpPut<Trigger>('/triggers/' + triggerId, trigger);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async remove(triggerId: string): Promise<void> {
|
|
27
|
+
await this.httpDelete('/triggers/' + triggerId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async get(triggerId: string): Promise<Trigger> {
|
|
31
|
+
return this.httpGet<Trigger>('/triggers/' + triggerId);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
executions(): TriggerExecutionsApi {
|
|
35
|
+
return new TriggerExecutionsApi(this.getBaseUrl(), this.getAuthProvider());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type TriggerSourceType = 'webhook' | 'schedule' | 'gmail' | 'imap';
|
|
2
|
+
|
|
3
|
+
export interface GmailTriggerSourceConfiguration {
|
|
4
|
+
event?: string;
|
|
5
|
+
query?: string;
|
|
6
|
+
credentialsId?: string;
|
|
7
|
+
userEmail?: string;
|
|
8
|
+
watchExpiration?: number;
|
|
9
|
+
lastHistoryId?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ImapTriggerSourceConfiguration {
|
|
13
|
+
event?: string;
|
|
14
|
+
credentialsId?: string;
|
|
15
|
+
mailbox?: string;
|
|
16
|
+
searchCriteria?: string;
|
|
17
|
+
processAttachments?: boolean;
|
|
18
|
+
allowedMimeTypes?: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TriggerSourceConfiguration = GmailTriggerSourceConfiguration | ImapTriggerSourceConfiguration | Record<string, unknown>;
|
|
22
|
+
|
|
23
|
+
export interface TriggerSource {
|
|
24
|
+
type?: TriggerSourceType;
|
|
25
|
+
configuration?: TriggerSourceConfiguration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TriggerDestination {
|
|
29
|
+
type?: string;
|
|
30
|
+
configuration?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Trigger {
|
|
34
|
+
id?: string;
|
|
35
|
+
projectId?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
source?: TriggerSource;
|
|
38
|
+
destination?: TriggerDestination;
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
createdAt?: string;
|
|
41
|
+
processedAt?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TriggerExecutionResult {
|
|
45
|
+
id?: string;
|
|
46
|
+
triggerId?: string;
|
|
47
|
+
success?: boolean;
|
|
48
|
+
message?: string;
|
|
49
|
+
processedAt?: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type NodeType =
|
|
2
|
+
| 'start'
|
|
3
|
+
| 'action'
|
|
4
|
+
| 'condition'
|
|
5
|
+
| 'loop'
|
|
6
|
+
| 'tool'
|
|
7
|
+
| 'agent'
|
|
8
|
+
| 'set_var'
|
|
9
|
+
| 'output'
|
|
10
|
+
| 'workflow'
|
|
11
|
+
| 'resource'
|
|
12
|
+
| 'script';
|
|
13
|
+
|
|
14
|
+
export type VariableType = 'string' | 'number' | 'boolean' | 'object' | 'file' | 'list';
|
|
15
|
+
|
|
16
|
+
export type VariableDirection = 'in' | 'out';
|
|
17
|
+
|
|
18
|
+
export type ExecutionStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
19
|
+
|
|
20
|
+
export interface Position {
|
|
21
|
+
x?: number;
|
|
22
|
+
y?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Handle {
|
|
26
|
+
name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface WorkflowVariable {
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
type?: VariableType;
|
|
35
|
+
direction?: VariableDirection;
|
|
36
|
+
defaultValue?: unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface WorkflowTrigger {
|
|
40
|
+
type?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Node {
|
|
44
|
+
id?: string;
|
|
45
|
+
type?: NodeType;
|
|
46
|
+
name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
position?: Position;
|
|
49
|
+
allowDynamicInputVariables?: boolean;
|
|
50
|
+
allowDynamicOutputVariables?: boolean;
|
|
51
|
+
allowDynamicHandles?: boolean;
|
|
52
|
+
staticVariables?: WorkflowVariable[];
|
|
53
|
+
variables?: WorkflowVariable[];
|
|
54
|
+
values?: Record<string, unknown>;
|
|
55
|
+
staticHandles?: Handle[];
|
|
56
|
+
handles?: Handle[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface StartNode extends Node {
|
|
60
|
+
trigger?: WorkflowTrigger;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface Connection {
|
|
64
|
+
id?: string;
|
|
65
|
+
sourceId?: string;
|
|
66
|
+
targetId?: string;
|
|
67
|
+
sourceHandle?: string;
|
|
68
|
+
targetHandle?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface Step {
|
|
72
|
+
id?: string;
|
|
73
|
+
nodeId?: string;
|
|
74
|
+
status?: string;
|
|
75
|
+
startedAt?: string;
|
|
76
|
+
endedAt?: string;
|
|
77
|
+
result?: Record<string, unknown>;
|
|
78
|
+
error?: string;
|
|
79
|
+
output?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface RunResult {
|
|
83
|
+
source?: Node;
|
|
84
|
+
success?: boolean;
|
|
85
|
+
message?: string;
|
|
86
|
+
nextNodes?: string[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface NodeExecutionResult {
|
|
90
|
+
nextNodes?: Node[];
|
|
91
|
+
output?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface Execution {
|
|
95
|
+
id?: string;
|
|
96
|
+
workflowId?: string;
|
|
97
|
+
status?: string;
|
|
98
|
+
userId?: string;
|
|
99
|
+
steps?: Step[];
|
|
100
|
+
startedAt?: string;
|
|
101
|
+
endedAt?: string;
|
|
102
|
+
output?: Record<string, unknown>;
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface WorkflowResult {
|
|
107
|
+
workflowId?: string;
|
|
108
|
+
steps?: RunResult[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface AgentValue {
|
|
112
|
+
agentId?: string;
|
|
113
|
+
initialContext?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ContentItemFile {
|
|
117
|
+
content?: string;
|
|
118
|
+
contentType?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface Ref {
|
|
122
|
+
nodeId?: string;
|
|
123
|
+
variableName?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ContentItem {
|
|
127
|
+
text?: string | Ref;
|
|
128
|
+
file?: ContentItemFile | Ref;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ContentValue {
|
|
132
|
+
content?: ContentItem[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ExecuteRequest {
|
|
136
|
+
userId?: string;
|
|
137
|
+
initialData?: Record<string, unknown>;
|
|
138
|
+
callbackUrl?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface Workflow {
|
|
142
|
+
id?: string;
|
|
143
|
+
projectId?: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
rootNode?: StartNode;
|
|
147
|
+
nodes?: Node[];
|
|
148
|
+
connections?: Connection[];
|
|
149
|
+
features?: import('../agents/types').Feature[];
|
|
150
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { Execution, ExecuteRequest } from './types';
|
|
5
|
+
|
|
6
|
+
export class WorkflowExecutionsApi extends HttpApi {
|
|
7
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
8
|
+
super(baseUrl, auth);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async list(workflowId: string, page?: number, size?: number): Promise<Paginated<Execution>> {
|
|
12
|
+
const params: Record<string, unknown> = { page, size };
|
|
13
|
+
return this.httpGet<Paginated<Execution>>('/workflows/' + workflowId + '/executions', params);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async get(workflowId: string, executionId: string): Promise<Execution> {
|
|
17
|
+
return this.httpGet<Execution>('/workflows/' + workflowId + '/executions/' + executionId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async run(workflowId: string, request: ExecuteRequest): Promise<Execution> {
|
|
21
|
+
return this.httpPost<Execution>('/workflows/' + workflowId + '/executions', request);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async queue(workflowId: string, request: ExecuteRequest): Promise<Execution> {
|
|
25
|
+
return this.httpPost<Execution>('/workflows/' + workflowId + '/executions/queue', request);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { Revision } from '../revisions/types';
|
|
5
|
+
import { Workflow } from './types';
|
|
6
|
+
import { WorkflowExecutionsApi } from './workflow-executions-api';
|
|
7
|
+
|
|
8
|
+
export class WorkflowsApi extends HttpApi {
|
|
9
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
10
|
+
super(baseUrl, auth);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async list(keyword?: string | null, page?: number, size?: number): Promise<Paginated<Workflow>> {
|
|
14
|
+
const params: Record<string, unknown> = { page, size };
|
|
15
|
+
if (keyword) params.keyword = keyword;
|
|
16
|
+
return this.httpGet<Paginated<Workflow>>('/workflows', params);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async create(workflow: Workflow): Promise<Workflow> {
|
|
20
|
+
return this.httpPost<Workflow>('/workflows', workflow);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async update(workflowId: string, workflow: Workflow): Promise<Workflow> {
|
|
24
|
+
workflow.id = workflowId;
|
|
25
|
+
return this.httpPut<Workflow>('/workflows/' + workflowId, workflow);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async remove(workflowId: string): Promise<void> {
|
|
29
|
+
await this.httpDelete('/workflows/' + workflowId);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async get(workflowId: string): Promise<Workflow> {
|
|
33
|
+
return this.httpGet<Workflow>('/workflows/' + workflowId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
executions(): WorkflowExecutionsApi {
|
|
37
|
+
return new WorkflowExecutionsApi(this.getBaseUrl(), this.getAuthProvider());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async listRevisions(workflowId: string): Promise<Revision[]> {
|
|
41
|
+
return this.httpGet<Revision[]>('/workflows/' + workflowId + '/revisions');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async getRevision(workflowId: string, revisionId: string): Promise<Revision> {
|
|
45
|
+
return this.httpGet<Revision>('/workflows/' + workflowId + '/revisions/' + revisionId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async rollback(workflowId: string, revisionId: string): Promise<Workflow> {
|
|
49
|
+
return this.httpPost<Workflow>('/workflows/' + workflowId + '/revisions/' + revisionId + '/rollback', {});
|
|
50
|
+
}
|
|
51
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
10
|
"isolatedModules": true,
|
|
11
|
+
"noEmit": true,
|
|
11
12
|
"jsx": "react-jsx",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noUnusedLocals": false,
|
|
15
|
+
"noUnusedParameters": false,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"declarationMap": true,
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"outDir": "./dist",
|
|
21
|
+
"baseUrl": ".",
|
|
19
22
|
"paths": {
|
|
20
|
-
"@/*": ["playground/src/*"],
|
|
21
23
|
"@applica-software-guru/persona-sdk": ["src/index.ts"]
|
|
22
|
-
},
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"skipLibCheck": true,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"target": "ESNext",
|
|
27
|
-
"typeRoots": ["node_modules/@types", "src/assets.d.ts", "src/index.d.ts", "src/types.d.ts"],
|
|
28
|
-
"useDefineForClassFields": true
|
|
29
|
-
},
|
|
30
|
-
"include": ["src", "playground/src"],
|
|
31
|
-
"references": [
|
|
32
|
-
{
|
|
33
|
-
"path": "./jsconfig.node.json"
|
|
34
24
|
}
|
|
35
|
-
|
|
25
|
+
},
|
|
26
|
+
"include": ["src"],
|
|
27
|
+
"exclude": ["node_modules", "dist"]
|
|
36
28
|
}
|