lua-cli 2.5.7 → 3.0.0-alpha.1
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/dist/api/agent.api.service.d.ts +45 -0
- package/dist/api/agent.api.service.js +54 -0
- package/dist/api/job.api.service.d.ts +210 -0
- package/dist/api/job.api.service.js +200 -0
- package/dist/api/lazy-instances.d.ts +24 -0
- package/dist/api/lazy-instances.js +48 -0
- package/dist/api/postprocessor.api.service.d.ts +98 -0
- package/dist/api/postprocessor.api.service.js +76 -0
- package/dist/api/preprocessor.api.service.d.ts +98 -0
- package/dist/api/preprocessor.api.service.js +76 -0
- package/dist/api/user.data.api.service.d.ts +28 -0
- package/dist/api/user.data.api.service.js +51 -0
- package/dist/api/webhook.api.service.d.ts +151 -0
- package/dist/api/webhook.api.service.js +134 -0
- package/dist/api-exports.d.ts +156 -41
- package/dist/api-exports.js +182 -21
- package/dist/cli/command-definitions.js +149 -7
- package/dist/commands/compile.js +124 -5
- package/dist/commands/completion.d.ts +11 -0
- package/dist/commands/completion.js +209 -0
- package/dist/commands/env.d.ts +3 -2
- package/dist/commands/env.js +42 -17
- package/dist/commands/features.d.ts +16 -0
- package/dist/commands/features.js +352 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.js +7 -0
- package/dist/commands/init.js +53 -7
- package/dist/commands/jobs.d.ts +20 -0
- package/dist/commands/jobs.js +533 -0
- package/dist/commands/logs.js +2 -5
- package/dist/commands/persona.d.ts +3 -2
- package/dist/commands/persona.js +43 -18
- package/dist/commands/postprocessors.d.ts +8 -0
- package/dist/commands/postprocessors.js +431 -0
- package/dist/commands/preprocessors.d.ts +8 -0
- package/dist/commands/preprocessors.js +431 -0
- package/dist/commands/push.d.ts +9 -13
- package/dist/commands/push.js +937 -69
- package/dist/commands/skills.d.ts +16 -0
- package/dist/commands/skills.js +438 -0
- package/dist/commands/test.d.ts +9 -18
- package/dist/commands/test.js +558 -82
- package/dist/commands/webhooks.d.ts +18 -0
- package/dist/commands/webhooks.js +424 -0
- package/dist/common/data.entry.instance.d.ts +7 -0
- package/dist/common/data.entry.instance.js +15 -0
- package/dist/common/job.instance.d.ts +77 -0
- package/dist/common/job.instance.js +108 -0
- package/dist/common/order.instance.d.ts +6 -0
- package/dist/common/order.instance.js +14 -0
- package/dist/common/product.instance.d.ts +6 -0
- package/dist/common/product.instance.js +14 -0
- package/dist/common/user.instance.d.ts +15 -0
- package/dist/common/user.instance.js +38 -0
- package/dist/config/constants.d.ts +2 -2
- package/dist/config/constants.js +4 -4
- package/dist/index.js +14 -3
- package/dist/interfaces/agent.d.ts +33 -1
- package/dist/interfaces/chat.d.ts +22 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/jobs.d.ts +172 -0
- package/dist/interfaces/jobs.js +5 -0
- package/dist/interfaces/message.d.ts +18 -0
- package/dist/interfaces/message.js +1 -0
- package/dist/interfaces/postprocessors.d.ts +35 -0
- package/dist/interfaces/postprocessors.js +4 -0
- package/dist/interfaces/preprocessors.d.ts +35 -0
- package/dist/interfaces/preprocessors.js +4 -0
- package/dist/interfaces/webhooks.d.ts +104 -0
- package/dist/interfaces/webhooks.js +5 -0
- package/dist/types/api-contracts.d.ts +14 -0
- package/dist/types/api-contracts.js +0 -7
- package/dist/types/compile.types.d.ts +49 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/skill.d.ts +502 -0
- package/dist/types/skill.js +477 -0
- package/dist/utils/agent-management.d.ts +25 -0
- package/dist/utils/agent-management.js +67 -0
- package/dist/utils/bundling.d.ts +31 -1
- package/dist/utils/bundling.js +653 -10
- package/dist/utils/compile.d.ts +63 -0
- package/dist/utils/compile.js +691 -36
- package/dist/utils/deployment.d.ts +2 -1
- package/dist/utils/deployment.js +16 -2
- package/dist/utils/init-agent.d.ts +3 -1
- package/dist/utils/init-agent.js +6 -4
- package/dist/utils/init-prompts.d.ts +2 -1
- package/dist/utils/init-prompts.js +14 -9
- package/dist/utils/job-management.d.ts +24 -0
- package/dist/utils/job-management.js +264 -0
- package/dist/utils/postprocessor-management.d.ts +9 -0
- package/dist/utils/postprocessor-management.js +118 -0
- package/dist/utils/preprocessor-management.d.ts +9 -0
- package/dist/utils/preprocessor-management.js +118 -0
- package/dist/utils/sandbox.d.ts +61 -1
- package/dist/utils/sandbox.js +283 -72
- package/dist/utils/tool-detection.d.ts +3 -2
- package/dist/utils/tool-detection.js +18 -4
- package/dist/utils/webhook-management.d.ts +24 -0
- package/dist/utils/webhook-management.js +256 -0
- package/dist/web/app.css +152 -736
- package/dist/web/app.js +45 -45
- package/package.json +2 -2
- package/template/AGENT_CONFIGURATION.md +251 -0
- package/template/COMPLEX_JOB_EXAMPLES.md +795 -0
- package/template/DYNAMIC_JOB_CREATION.md +371 -0
- package/template/README.md +30 -2
- package/template/WEBHOOKS_JOBS_QUICKSTART.md +318 -0
- package/template/WEBHOOK_JOB_EXAMPLES.md +817 -0
- package/template/package.json +1 -1
- package/template/src/index-agent-example.ts +201 -0
- package/template/src/index.ts +39 -0
- package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
- package/template/src/jobs/DailyCleanupJob.ts +100 -0
- package/template/src/jobs/DataMigrationJob.ts +133 -0
- package/template/src/jobs/HealthCheckJob.ts +87 -0
- package/template/src/postprocessors/ResponseFormatter.ts +151 -0
- package/template/src/preprocessors/MessageFilter.ts +91 -0
- package/template/src/tools/GameScoreTrackerTool.ts +356 -0
- package/template/src/tools/SmartBasketTool.ts +188 -0
- package/template/src/webhooks/PaymentWebhook.ts +113 -0
- package/template/src/webhooks/UserEventWebhook.ts +77 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/common.js";
|
|
3
|
+
/**
|
|
4
|
+
* PostProcessor API Response Types
|
|
5
|
+
*/
|
|
6
|
+
export interface PostProcessorVersion {
|
|
7
|
+
version: string;
|
|
8
|
+
postprocessorId: string;
|
|
9
|
+
createdAt: string | number;
|
|
10
|
+
isActive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface GetPostProcessorsResponse {
|
|
13
|
+
postprocessors: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
context?: string;
|
|
18
|
+
versions: PostProcessorVersion[];
|
|
19
|
+
activeVersionId?: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface CreatePostProcessorResponse {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
agentId: string;
|
|
27
|
+
context?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PostProcessorVersionResponse {
|
|
30
|
+
versionId: string;
|
|
31
|
+
postprocessorId: string;
|
|
32
|
+
version: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface DeletePostProcessorResponse {
|
|
36
|
+
deleted: boolean;
|
|
37
|
+
deactivated?: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* PostProcessor API Service
|
|
42
|
+
* Handles all postprocessor-related API calls
|
|
43
|
+
*/
|
|
44
|
+
export default class PostProcessorApi extends HttpClient {
|
|
45
|
+
private apiKey;
|
|
46
|
+
private agentId;
|
|
47
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves all postprocessors for the agent
|
|
50
|
+
*/
|
|
51
|
+
getPostProcessors(): Promise<ApiResponse<GetPostProcessorsResponse>>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new postprocessor for the agent
|
|
54
|
+
*/
|
|
55
|
+
createPostProcessor(data: {
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
context?: string;
|
|
59
|
+
}): Promise<ApiResponse<CreatePostProcessorResponse>>;
|
|
60
|
+
/**
|
|
61
|
+
* Pushes a new version of a postprocessor
|
|
62
|
+
*/
|
|
63
|
+
pushPostProcessor(postprocessorId: string, versionData: any): Promise<ApiResponse<PostProcessorVersionResponse>>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all versions of a specific postprocessor
|
|
66
|
+
*/
|
|
67
|
+
getPostProcessorVersions(postprocessorId: string): Promise<ApiResponse<{
|
|
68
|
+
versions: PostProcessorVersion[];
|
|
69
|
+
activeVersionId?: string;
|
|
70
|
+
}>>;
|
|
71
|
+
/**
|
|
72
|
+
* Publishes a specific version of a postprocessor to production
|
|
73
|
+
*/
|
|
74
|
+
publishPostProcessorVersion(postprocessorId: string, version: string): Promise<ApiResponse<{
|
|
75
|
+
message: string;
|
|
76
|
+
postprocessorId: string;
|
|
77
|
+
activeVersionId: string;
|
|
78
|
+
publishedAt: string;
|
|
79
|
+
}>>;
|
|
80
|
+
/**
|
|
81
|
+
* Activates a postprocessor
|
|
82
|
+
*/
|
|
83
|
+
activatePostProcessor(postprocessorId: string): Promise<ApiResponse<{
|
|
84
|
+
message: string;
|
|
85
|
+
active: boolean;
|
|
86
|
+
}>>;
|
|
87
|
+
/**
|
|
88
|
+
* Deactivates a postprocessor
|
|
89
|
+
*/
|
|
90
|
+
deactivatePostProcessor(postprocessorId: string): Promise<ApiResponse<{
|
|
91
|
+
message: string;
|
|
92
|
+
active: boolean;
|
|
93
|
+
}>>;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a postprocessor
|
|
96
|
+
*/
|
|
97
|
+
deletePostProcessor(postprocessorId: string): Promise<ApiResponse<DeletePostProcessorResponse>>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* PostProcessor API Service
|
|
4
|
+
* Handles all postprocessor-related API calls
|
|
5
|
+
*/
|
|
6
|
+
export default class PostProcessorApi extends HttpClient {
|
|
7
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
8
|
+
super(baseUrl);
|
|
9
|
+
this.apiKey = apiKey;
|
|
10
|
+
this.agentId = agentId;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves all postprocessors for the agent
|
|
14
|
+
*/
|
|
15
|
+
async getPostProcessors() {
|
|
16
|
+
return this.httpGet(`/developer/postprocessors/${this.agentId}`, {
|
|
17
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new postprocessor for the agent
|
|
22
|
+
*/
|
|
23
|
+
async createPostProcessor(data) {
|
|
24
|
+
return this.httpPost(`/developer/postprocessors/${this.agentId}`, data, {
|
|
25
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pushes a new version of a postprocessor
|
|
30
|
+
*/
|
|
31
|
+
async pushPostProcessor(postprocessorId, versionData) {
|
|
32
|
+
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/version`, versionData, {
|
|
33
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves all versions of a specific postprocessor
|
|
38
|
+
*/
|
|
39
|
+
async getPostProcessorVersions(postprocessorId) {
|
|
40
|
+
return this.httpGet(`/developer/postprocessors/${this.agentId}/${postprocessorId}/versions`, {
|
|
41
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Publishes a specific version of a postprocessor to production
|
|
46
|
+
*/
|
|
47
|
+
async publishPostProcessorVersion(postprocessorId, version) {
|
|
48
|
+
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/${version}/publish`, {}, {
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Activates a postprocessor
|
|
54
|
+
*/
|
|
55
|
+
async activatePostProcessor(postprocessorId) {
|
|
56
|
+
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/activate`, {}, {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Deactivates a postprocessor
|
|
62
|
+
*/
|
|
63
|
+
async deactivatePostProcessor(postprocessorId) {
|
|
64
|
+
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/deactivate`, {}, {
|
|
65
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a postprocessor
|
|
70
|
+
*/
|
|
71
|
+
async deletePostProcessor(postprocessorId) {
|
|
72
|
+
return this.httpDelete(`/developer/postprocessors/${this.agentId}/${postprocessorId}`, {
|
|
73
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/common.js";
|
|
3
|
+
/**
|
|
4
|
+
* PreProcessor API Response Types
|
|
5
|
+
*/
|
|
6
|
+
export interface PreProcessorVersion {
|
|
7
|
+
version: string;
|
|
8
|
+
preprocessorId: string;
|
|
9
|
+
createdAt: string | number;
|
|
10
|
+
isActive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface GetPreProcessorsResponse {
|
|
13
|
+
preprocessors: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
context?: string;
|
|
18
|
+
versions: PreProcessorVersion[];
|
|
19
|
+
activeVersionId?: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface CreatePreProcessorResponse {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
agentId: string;
|
|
27
|
+
context?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PreProcessorVersionResponse {
|
|
30
|
+
versionId: string;
|
|
31
|
+
preprocessorId: string;
|
|
32
|
+
version: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface DeletePreProcessorResponse {
|
|
36
|
+
deleted: boolean;
|
|
37
|
+
deactivated?: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* PreProcessor API Service
|
|
42
|
+
* Handles all preprocessor-related API calls
|
|
43
|
+
*/
|
|
44
|
+
export default class PreProcessorApi extends HttpClient {
|
|
45
|
+
private apiKey;
|
|
46
|
+
private agentId;
|
|
47
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves all preprocessors for the agent
|
|
50
|
+
*/
|
|
51
|
+
getPreProcessors(): Promise<ApiResponse<GetPreProcessorsResponse>>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new preprocessor for the agent
|
|
54
|
+
*/
|
|
55
|
+
createPreProcessor(data: {
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
context?: string;
|
|
59
|
+
}): Promise<ApiResponse<CreatePreProcessorResponse>>;
|
|
60
|
+
/**
|
|
61
|
+
* Pushes a new version of a preprocessor
|
|
62
|
+
*/
|
|
63
|
+
pushPreProcessor(preprocessorId: string, versionData: any): Promise<ApiResponse<PreProcessorVersionResponse>>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all versions of a specific preprocessor
|
|
66
|
+
*/
|
|
67
|
+
getPreProcessorVersions(preprocessorId: string): Promise<ApiResponse<{
|
|
68
|
+
versions: PreProcessorVersion[];
|
|
69
|
+
activeVersionId?: string;
|
|
70
|
+
}>>;
|
|
71
|
+
/**
|
|
72
|
+
* Publishes a specific version of a preprocessor to production
|
|
73
|
+
*/
|
|
74
|
+
publishPreProcessorVersion(preprocessorId: string, version: string): Promise<ApiResponse<{
|
|
75
|
+
message: string;
|
|
76
|
+
preprocessorId: string;
|
|
77
|
+
activeVersionId: string;
|
|
78
|
+
publishedAt: string;
|
|
79
|
+
}>>;
|
|
80
|
+
/**
|
|
81
|
+
* Activates a preprocessor
|
|
82
|
+
*/
|
|
83
|
+
activatePreProcessor(preprocessorId: string): Promise<ApiResponse<{
|
|
84
|
+
message: string;
|
|
85
|
+
active: boolean;
|
|
86
|
+
}>>;
|
|
87
|
+
/**
|
|
88
|
+
* Deactivates a preprocessor
|
|
89
|
+
*/
|
|
90
|
+
deactivatePreProcessor(preprocessorId: string): Promise<ApiResponse<{
|
|
91
|
+
message: string;
|
|
92
|
+
active: boolean;
|
|
93
|
+
}>>;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a preprocessor
|
|
96
|
+
*/
|
|
97
|
+
deletePreProcessor(preprocessorId: string): Promise<ApiResponse<DeletePreProcessorResponse>>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* PreProcessor API Service
|
|
4
|
+
* Handles all preprocessor-related API calls
|
|
5
|
+
*/
|
|
6
|
+
export default class PreProcessorApi extends HttpClient {
|
|
7
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
8
|
+
super(baseUrl);
|
|
9
|
+
this.apiKey = apiKey;
|
|
10
|
+
this.agentId = agentId;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves all preprocessors for the agent
|
|
14
|
+
*/
|
|
15
|
+
async getPreProcessors() {
|
|
16
|
+
return this.httpGet(`/developer/preprocessors/${this.agentId}`, {
|
|
17
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new preprocessor for the agent
|
|
22
|
+
*/
|
|
23
|
+
async createPreProcessor(data) {
|
|
24
|
+
return this.httpPost(`/developer/preprocessors/${this.agentId}`, data, {
|
|
25
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pushes a new version of a preprocessor
|
|
30
|
+
*/
|
|
31
|
+
async pushPreProcessor(preprocessorId, versionData) {
|
|
32
|
+
return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/version`, versionData, {
|
|
33
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves all versions of a specific preprocessor
|
|
38
|
+
*/
|
|
39
|
+
async getPreProcessorVersions(preprocessorId) {
|
|
40
|
+
return this.httpGet(`/developer/preprocessors/${this.agentId}/${preprocessorId}/versions`, {
|
|
41
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Publishes a specific version of a preprocessor to production
|
|
46
|
+
*/
|
|
47
|
+
async publishPreProcessorVersion(preprocessorId, version) {
|
|
48
|
+
return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/${version}/publish`, {}, {
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Activates a preprocessor
|
|
54
|
+
*/
|
|
55
|
+
async activatePreProcessor(preprocessorId) {
|
|
56
|
+
return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/activate`, {}, {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Deactivates a preprocessor
|
|
62
|
+
*/
|
|
63
|
+
async deactivatePreProcessor(preprocessorId) {
|
|
64
|
+
return this.httpPost(`/developer/preprocessors/${this.agentId}/${preprocessorId}/deactivate`, {}, {
|
|
65
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a preprocessor
|
|
70
|
+
*/
|
|
71
|
+
async deletePreProcessor(preprocessorId) {
|
|
72
|
+
return this.httpDelete(`/developer/preprocessors/${this.agentId}/${preprocessorId}`, {
|
|
73
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
2
|
import UserDataInstance from "../common/user.instance.js";
|
|
3
|
+
import { Message } from "../interfaces/message.js";
|
|
3
4
|
import { UserDataAPI } from "../types/index.js";
|
|
5
|
+
import { ChatHistoryMessage } from "../interfaces/chat.js";
|
|
4
6
|
export default class UserDataApi extends HttpClient implements UserDataAPI {
|
|
5
7
|
private apiKey;
|
|
6
8
|
private agentId;
|
|
@@ -30,4 +32,30 @@ export default class UserDataApi extends HttpClient implements UserDataAPI {
|
|
|
30
32
|
* @throws Error if the clear operation fails or the request is unsuccessful
|
|
31
33
|
*/
|
|
32
34
|
clear(): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Sends a message to a specific user conversation for the agent
|
|
37
|
+
* @param userId - The unique identifier of the user to send the message to
|
|
38
|
+
* @param messages - An array of messages to send (can be text, image, or file types)
|
|
39
|
+
* @returns Promise resolving to the response data from the server
|
|
40
|
+
* @throws Error if the message sending fails or the request is unsuccessful
|
|
41
|
+
*/
|
|
42
|
+
sendMessage(messages: Message[]): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the admin user for the specific agent
|
|
45
|
+
* @returns Promise resolving to the admin user data
|
|
46
|
+
* @throws Error if the admin user cannot be retrieved or the request is unsuccessful
|
|
47
|
+
*/
|
|
48
|
+
getAdminUser(): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the chat history for the current user and agent
|
|
51
|
+
* @returns Promise resolving to an array of chat messages
|
|
52
|
+
* @throws Error if the chat history cannot be retrieved or the request is unsuccessful
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const history = await User.getChatHistory();
|
|
57
|
+
* // Returns: [{ role: 'user', content: [...], createdAt: '...' }, ...]
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
getChatHistory(): Promise<ChatHistoryMessage[]>;
|
|
33
61
|
}
|
|
@@ -56,4 +56,55 @@ export default class UserDataApi extends HttpClient {
|
|
|
56
56
|
}
|
|
57
57
|
return {};
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Sends a message to a specific user conversation for the agent
|
|
61
|
+
* @param userId - The unique identifier of the user to send the message to
|
|
62
|
+
* @param messages - An array of messages to send (can be text, image, or file types)
|
|
63
|
+
* @returns Promise resolving to the response data from the server
|
|
64
|
+
* @throws Error if the message sending fails or the request is unsuccessful
|
|
65
|
+
*/
|
|
66
|
+
async sendMessage(messages) {
|
|
67
|
+
const user = await this.getAdminUser();
|
|
68
|
+
const response = await this.httpPost(`/admin/agents/${this.agentId}/conversations/${user.uid}`, { messages }, {
|
|
69
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
70
|
+
});
|
|
71
|
+
if (!response.success) {
|
|
72
|
+
throw new Error(response.error?.message || 'Failed to send message');
|
|
73
|
+
}
|
|
74
|
+
return response.data;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the admin user for the specific agent
|
|
78
|
+
* @returns Promise resolving to the admin user data
|
|
79
|
+
* @throws Error if the admin user cannot be retrieved or the request is unsuccessful
|
|
80
|
+
*/
|
|
81
|
+
async getAdminUser() {
|
|
82
|
+
const response = await this.httpGet(`/admin`, {
|
|
83
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
84
|
+
});
|
|
85
|
+
if (!response.success) {
|
|
86
|
+
throw new Error(response.error?.message || 'Failed to get admin user');
|
|
87
|
+
}
|
|
88
|
+
return response.data;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets the chat history for the current user and agent
|
|
92
|
+
* @returns Promise resolving to an array of chat messages
|
|
93
|
+
* @throws Error if the chat history cannot be retrieved or the request is unsuccessful
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const history = await User.getChatHistory();
|
|
98
|
+
* // Returns: [{ role: 'user', content: [...], createdAt: '...' }, ...]
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
async getChatHistory() {
|
|
102
|
+
const response = await this.httpGet(`/chat/history/${this.agentId}`, {
|
|
103
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
104
|
+
});
|
|
105
|
+
if (!response.success) {
|
|
106
|
+
throw new Error(response.error?.message || 'Failed to get chat history');
|
|
107
|
+
}
|
|
108
|
+
return response.data || [];
|
|
109
|
+
}
|
|
59
110
|
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/common.js";
|
|
3
|
+
import { CreateWebhookDTO, PushWebhookVersionDTO, UpdateWebhookVersionDTO } from "../interfaces/webhooks.js";
|
|
4
|
+
/**
|
|
5
|
+
* Webhook API Response Types
|
|
6
|
+
*/
|
|
7
|
+
export interface WebhookVersion {
|
|
8
|
+
version: string;
|
|
9
|
+
webhookId: string;
|
|
10
|
+
createdAt: string | number;
|
|
11
|
+
isActive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface GetWebhooksResponse {
|
|
14
|
+
webhooks: Array<{
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
context?: string;
|
|
19
|
+
versions: WebhookVersion[];
|
|
20
|
+
activeVersionId?: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export interface CreateWebhookResponse {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
agentId: string;
|
|
28
|
+
context?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface WebhookVersionResponse {
|
|
31
|
+
versionId: string;
|
|
32
|
+
webhookId: string;
|
|
33
|
+
version: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface UpdateWebhookVersionResponse {
|
|
37
|
+
versionId: string;
|
|
38
|
+
webhookId: string;
|
|
39
|
+
version: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}
|
|
42
|
+
export interface DeleteWebhookResponse {
|
|
43
|
+
deleted: boolean;
|
|
44
|
+
deactivated?: boolean;
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Webhook API Service
|
|
49
|
+
* Handles all webhook-related API calls
|
|
50
|
+
*/
|
|
51
|
+
export default class WebhookApi extends HttpClient {
|
|
52
|
+
private apiKey;
|
|
53
|
+
private agentId;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an instance of WebhookApi
|
|
56
|
+
* @param baseUrl - The base URL for the API
|
|
57
|
+
* @param apiKey - The API key for authentication
|
|
58
|
+
* @param agentId - The unique identifier of the agent
|
|
59
|
+
*/
|
|
60
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves all webhooks for the agent
|
|
63
|
+
* @returns Promise resolving to an ApiResponse containing an array of webhooks with their versions
|
|
64
|
+
* @throws Error if the API request fails or the agent is not found
|
|
65
|
+
*/
|
|
66
|
+
getWebhooks(): Promise<ApiResponse<GetWebhooksResponse>>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new webhook for the agent
|
|
69
|
+
* @param webhookData - The webhook data including name, description, and optional context
|
|
70
|
+
* @returns Promise resolving to an ApiResponse containing the created webhook details
|
|
71
|
+
* @throws Error if the webhook creation fails or validation errors occur
|
|
72
|
+
*/
|
|
73
|
+
createWebhook(webhookData: CreateWebhookDTO): Promise<ApiResponse<CreateWebhookResponse>>;
|
|
74
|
+
/**
|
|
75
|
+
* Pushes a new version of a webhook to production
|
|
76
|
+
* @param webhookId - The unique identifier of the webhook
|
|
77
|
+
* @param versionData - The version data including code, configuration, and metadata
|
|
78
|
+
* @returns Promise resolving to an ApiResponse containing the created version details
|
|
79
|
+
* @throws Error if the webhook is not found or the push operation fails
|
|
80
|
+
*/
|
|
81
|
+
pushWebhook(webhookId: string, versionData: PushWebhookVersionDTO): Promise<ApiResponse<WebhookVersionResponse>>;
|
|
82
|
+
/**
|
|
83
|
+
* Pushes a new development/sandbox version of a webhook for testing
|
|
84
|
+
* @param webhookId - The unique identifier of the webhook
|
|
85
|
+
* @param versionData - The version data including code, configuration, and metadata
|
|
86
|
+
* @returns Promise resolving to an ApiResponse containing the development version details
|
|
87
|
+
* @throws Error if the webhook is not found or the push operation fails
|
|
88
|
+
*/
|
|
89
|
+
pushDevWebhook(webhookId: string, versionData: PushWebhookVersionDTO): Promise<ApiResponse<WebhookVersionResponse>>;
|
|
90
|
+
/**
|
|
91
|
+
* Updates an existing development/sandbox version of a webhook
|
|
92
|
+
* @param webhookId - The unique identifier of the webhook
|
|
93
|
+
* @param sandboxVersionId - The unique identifier of the sandbox version to update
|
|
94
|
+
* @param versionData - The updated version data including code, configuration, and metadata
|
|
95
|
+
* @returns Promise resolving to an ApiResponse containing the updated version details
|
|
96
|
+
* @throws Error if the webhook or version is not found or the update fails
|
|
97
|
+
*/
|
|
98
|
+
updateDevWebhook(webhookId: string, sandboxVersionId: string, versionData: UpdateWebhookVersionDTO): Promise<ApiResponse<UpdateWebhookVersionResponse>>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves all versions of a specific webhook
|
|
101
|
+
* @param webhookId - The unique identifier of the webhook
|
|
102
|
+
* @returns Promise resolving to an ApiResponse containing an array of webhook versions
|
|
103
|
+
* @throws Error if the webhook is not found or the request fails
|
|
104
|
+
*/
|
|
105
|
+
getWebhookVersions(webhookId: string): Promise<ApiResponse<{
|
|
106
|
+
versions: WebhookVersion[];
|
|
107
|
+
activeVersionId?: string;
|
|
108
|
+
}>>;
|
|
109
|
+
/**
|
|
110
|
+
* Publishes a specific version of a webhook to production
|
|
111
|
+
* @param webhookId - The unique identifier of the webhook
|
|
112
|
+
* @param version - The version identifier to publish
|
|
113
|
+
* @returns Promise resolving to an ApiResponse containing publication confirmation details
|
|
114
|
+
* @throws Error if the webhook or version is not found or the publish operation fails
|
|
115
|
+
*/
|
|
116
|
+
publishWebhookVersion(webhookId: string, version: string): Promise<ApiResponse<{
|
|
117
|
+
message: string;
|
|
118
|
+
webhookId: string;
|
|
119
|
+
activeVersionId: string;
|
|
120
|
+
publishedAt: string;
|
|
121
|
+
}>>;
|
|
122
|
+
/**
|
|
123
|
+
* Activates a webhook (enables it to receive requests)
|
|
124
|
+
* @param webhookId - The unique identifier of the webhook to activate
|
|
125
|
+
* @returns Promise resolving to an ApiResponse with activation status
|
|
126
|
+
* @throws Error if the webhook is not found or the operation fails
|
|
127
|
+
*/
|
|
128
|
+
activateWebhook(webhookId: string): Promise<ApiResponse<{
|
|
129
|
+
message: string;
|
|
130
|
+
active: boolean;
|
|
131
|
+
}>>;
|
|
132
|
+
/**
|
|
133
|
+
* Deactivates a webhook (stops it from receiving requests)
|
|
134
|
+
* @param webhookId - The unique identifier of the webhook to deactivate
|
|
135
|
+
* @returns Promise resolving to an ApiResponse with deactivation status
|
|
136
|
+
* @throws Error if the webhook is not found or the operation fails
|
|
137
|
+
*/
|
|
138
|
+
deactivateWebhook(webhookId: string): Promise<ApiResponse<{
|
|
139
|
+
message: string;
|
|
140
|
+
active: boolean;
|
|
141
|
+
}>>;
|
|
142
|
+
/**
|
|
143
|
+
* Deletes a webhook and all its versions, or deactivates it if it has versions
|
|
144
|
+
* @param webhookId - The unique identifier of the webhook to delete
|
|
145
|
+
* @returns Promise resolving to an ApiResponse with deletion status
|
|
146
|
+
* - If deleted is true: webhook was successfully deleted
|
|
147
|
+
* - If deleted is false and deactivated is true: webhook has versions and was deactivated instead
|
|
148
|
+
* @throws Error if the webhook is not found or the delete operation fails
|
|
149
|
+
*/
|
|
150
|
+
deleteWebhook(webhookId: string): Promise<ApiResponse<DeleteWebhookResponse>>;
|
|
151
|
+
}
|