lua-cli 3.1.0-alpha.3 → 3.1.0-alpha.5
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/README.md +0 -4
- package/dist/api/cdn.api.service.d.ts +18 -0
- package/dist/api/cdn.api.service.js +43 -0
- package/dist/api/custom.data.api.service.d.ts +4 -3
- package/dist/api/custom.data.api.service.js +4 -3
- package/dist/api/developer.api.service.d.ts +54 -1
- package/dist/api/developer.api.service.js +89 -0
- package/dist/api/job.api.service.d.ts +33 -100
- package/dist/api/job.api.service.js +27 -11
- package/dist/api/lazy-instances.d.ts +16 -0
- package/dist/api/lazy-instances.js +32 -0
- package/dist/api/postprocessor.api.service.d.ts +3 -13
- package/dist/api/postprocessor.api.service.js +2 -4
- package/dist/api/preprocessor.api.service.d.ts +1 -8
- package/dist/api/preprocessor.api.service.js +1 -2
- package/dist/api/webhook.api.service.d.ts +1 -3
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
- package/dist/api/whatsapp-templates.api.service.js +78 -0
- package/dist/api-exports.d.ts +153 -6
- package/dist/api-exports.js +177 -21
- package/dist/cli/command-definitions.js +34 -7
- package/dist/commands/admin.js +1 -1
- package/dist/commands/channels.js +1 -1
- package/dist/commands/chat.js +2 -4
- package/dist/commands/compile.js +23 -4
- package/dist/commands/evals.d.ts +8 -0
- package/dist/commands/evals.js +41 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.d.ts +10 -1
- package/dist/commands/init.js +23 -46
- package/dist/commands/jobs.js +5 -5
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.js +393 -0
- package/dist/commands/push.js +174 -23
- package/dist/common/data.entry.instance.d.ts +1 -1
- package/dist/common/data.entry.instance.js +4 -4
- package/dist/common/job.instance.d.ts +59 -7
- package/dist/common/job.instance.js +84 -19
- package/dist/config/constants.d.ts +1 -0
- package/dist/config/constants.js +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/agent.d.ts +0 -3
- package/dist/interfaces/cdn.d.ts +24 -0
- package/dist/interfaces/cdn.js +5 -0
- package/dist/interfaces/compile.d.ts +1 -0
- package/dist/interfaces/custom.data.d.ts +3 -3
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/init.d.ts +0 -1
- package/dist/interfaces/jobs.d.ts +88 -132
- package/dist/interfaces/jobs.js +1 -1
- package/dist/interfaces/mcp.d.ts +64 -0
- package/dist/interfaces/mcp.js +5 -0
- package/dist/interfaces/postprocessors.d.ts +0 -3
- package/dist/interfaces/preprocessors.d.ts +0 -3
- package/dist/interfaces/webhooks.d.ts +0 -5
- package/dist/interfaces/whatsapp-templates.d.ts +104 -0
- package/dist/interfaces/whatsapp-templates.js +5 -0
- package/dist/types/api-contracts.d.ts +68 -14
- package/dist/types/compile.types.d.ts +5 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -1
- package/dist/types/skill.d.ts +181 -103
- package/dist/types/skill.js +123 -91
- package/dist/utils/agent-management.d.ts +3 -5
- package/dist/utils/agent-management.js +6 -8
- package/dist/utils/bundling.d.ts +4 -11
- package/dist/utils/bundling.js +24 -33
- package/dist/utils/compile.d.ts +17 -9
- package/dist/utils/compile.js +72 -88
- package/dist/utils/deployment.js +13 -7
- package/dist/utils/dev-api.js +1 -4
- package/dist/utils/dev-server.js +1 -1
- package/dist/utils/files.d.ts +11 -4
- package/dist/utils/files.js +17 -14
- package/dist/utils/init-agent.d.ts +1 -2
- package/dist/utils/init-agent.js +4 -6
- package/dist/utils/init-helpers.d.ts +4 -4
- package/dist/utils/init-helpers.js +10 -11
- package/dist/utils/job-management.js +0 -2
- package/dist/utils/mcp-server-management.d.ts +23 -0
- package/dist/utils/mcp-server-management.js +212 -0
- package/dist/utils/postprocessor-management.js +2 -4
- package/dist/utils/preprocessor-management.js +2 -4
- package/dist/utils/sandbox.d.ts +4 -2
- package/dist/utils/sandbox.js +38 -9
- package/dist/utils/webhook-management.js +1 -3
- package/dist/web/app.css +1505 -14
- package/dist/web/app.js +79 -64
- package/package.json +2 -6
- package/template/QUICKSTART.md +57 -774
- package/template/README.md +80 -907
- package/template/examples/README.md +106 -0
- package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -14
- package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -3
- package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -3
- package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -3
- package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -4
- package/template/examples/preprocessors/messageMatching.ts +35 -0
- package/template/{src → examples}/skills/basket.skill.ts +0 -1
- package/template/{src → examples}/skills/product.skill.ts +0 -1
- package/template/{src → examples}/skills/tools/GameScoreTrackerTool.ts +11 -15
- package/template/{src → examples}/skills/tools/OrderTool.ts +25 -0
- package/template/examples/skills/tools/PremiumFeatureTool.ts +98 -0
- package/template/{src → examples}/skills/tools/UserDataTool.ts +34 -0
- package/template/{src → examples}/skills/user.skill.ts +0 -1
- package/template/examples/webhooks/FileUploadWebhook.ts +86 -0
- package/template/{src → examples}/webhooks/PaymentWebhook.ts +12 -9
- package/template/examples/webhooks/UserEventWebhook.ts +105 -0
- package/template/package-lock.json +7895 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +40 -22
- package/template/src/preprocessors/messageMatching.ts +0 -22
- package/template/src/webhooks/UserEventWebhook.ts +0 -77
- /package/template/{src → examples}/services/ApiService.ts +0 -0
- /package/template/{src → examples}/services/GetWeather.ts +0 -0
- /package/template/{src → examples}/skills/tools/BasketTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreateInlineJob.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreatePostTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CustomDataTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/GetWeatherTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/PaymentTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/ProductsTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/SmartBasketTool.ts +0 -0
package/README.md
CHANGED
|
@@ -105,7 +105,6 @@ import { LuaAgent, LuaSkill, LuaWebhook, LuaJob } from 'lua-cli';
|
|
|
105
105
|
export const agent = new LuaAgent({
|
|
106
106
|
name: 'my-assistant',
|
|
107
107
|
persona: 'You are a helpful AI assistant...',
|
|
108
|
-
welcomeMessage: 'Hello! How can I help you today?',
|
|
109
108
|
|
|
110
109
|
skills: [customerSupportSkill, productSkill],
|
|
111
110
|
webhooks: [paymentWebhook],
|
|
@@ -166,7 +165,6 @@ import { z } from 'zod';
|
|
|
166
165
|
|
|
167
166
|
export default new LuaWebhook({
|
|
168
167
|
name: 'payment-webhook',
|
|
169
|
-
version: '1.0.0',
|
|
170
168
|
description: 'Handle payment notifications',
|
|
171
169
|
|
|
172
170
|
bodySchema: z.object({
|
|
@@ -194,7 +192,6 @@ import { LuaJob } from 'lua-cli';
|
|
|
194
192
|
|
|
195
193
|
export default new LuaJob({
|
|
196
194
|
name: 'daily-cleanup',
|
|
197
|
-
version: '1.0.0',
|
|
198
195
|
description: 'Clean up old data daily',
|
|
199
196
|
|
|
200
197
|
schedule: {
|
|
@@ -564,7 +561,6 @@ agent:
|
|
|
564
561
|
orgId: your-org-id
|
|
565
562
|
persona: |
|
|
566
563
|
You are a helpful AI assistant...
|
|
567
|
-
welcomeMessage: Hello! How can I help you today?
|
|
568
564
|
|
|
569
565
|
skills:
|
|
570
566
|
- name: general-skill
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDN API Service
|
|
3
|
+
* Handles file upload and retrieval from the Lua CDN
|
|
4
|
+
*/
|
|
5
|
+
import { CdnAPI } from "../types/api-contracts.js";
|
|
6
|
+
export default class CdnApi implements CdnAPI {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private apiKey;
|
|
9
|
+
constructor(baseUrl: string, apiKey: string);
|
|
10
|
+
/**
|
|
11
|
+
* Uploads a file to the CDN
|
|
12
|
+
*/
|
|
13
|
+
upload(file: File): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetches a file from the CDN by its ID
|
|
16
|
+
*/
|
|
17
|
+
get(fileId: string): Promise<File>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDN API Service
|
|
3
|
+
* Handles file upload and retrieval from the Lua CDN
|
|
4
|
+
*/
|
|
5
|
+
export default class CdnApi {
|
|
6
|
+
constructor(baseUrl, apiKey) {
|
|
7
|
+
this.baseUrl = baseUrl;
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Uploads a file to the CDN
|
|
12
|
+
*/
|
|
13
|
+
async upload(file) {
|
|
14
|
+
const formData = new FormData();
|
|
15
|
+
formData.append('file', file, file.name);
|
|
16
|
+
const response = await fetch(`${this.baseUrl}/upload`, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: { 'Authorization': `Bearer ${this.apiKey}` },
|
|
19
|
+
body: formData,
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const error = await response.json().catch(() => ({}));
|
|
23
|
+
throw new Error(error.message || `Upload failed: ${response.status}`);
|
|
24
|
+
}
|
|
25
|
+
const data = await response.json();
|
|
26
|
+
return data.fileId;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fetches a file from the CDN by its ID
|
|
30
|
+
*/
|
|
31
|
+
async get(fileId) {
|
|
32
|
+
const response = await fetch(`${this.baseUrl}/${fileId}`);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`File not found: ${response.status}`);
|
|
35
|
+
}
|
|
36
|
+
const contentType = response.headers.get('content-type') || 'application/octet-stream';
|
|
37
|
+
const contentDisposition = response.headers.get('content-disposition') || '';
|
|
38
|
+
const filenameMatch = contentDisposition.match(/filename="?([^"]+)"?/);
|
|
39
|
+
const filename = filenameMatch?.[1] || fileId;
|
|
40
|
+
const blob = await response.blob();
|
|
41
|
+
return new File([blob], filename, { type: contentType });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
2
|
import { CustomDataAPI } from "../types/index.js";
|
|
3
|
-
import { GetCustomDataResponse,
|
|
3
|
+
import { GetCustomDataResponse, UpdateCustomDataResponse, DeleteCustomDataResponse } from "../interfaces/custom.data.js";
|
|
4
4
|
import DataEntryInstance from "../common/data.entry.instance.js";
|
|
5
5
|
export default class CustomDataApi extends HttpClient implements CustomDataAPI {
|
|
6
6
|
private apiKey;
|
|
@@ -43,11 +43,12 @@ export default class CustomDataApi extends HttpClient implements CustomDataAPI {
|
|
|
43
43
|
* Updates an existing custom data entry
|
|
44
44
|
* @param collectionName - The name of the collection containing the entry
|
|
45
45
|
* @param entryId - The unique identifier of the entry to update
|
|
46
|
-
* @param data - The
|
|
46
|
+
* @param data - The data object to update
|
|
47
|
+
* @param searchText - Optional text to be used for semantic search indexing
|
|
47
48
|
* @returns Promise resolving to an UpdateCustomDataResponse with the updated entry details
|
|
48
49
|
* @throws Error if the entry is not found or the update fails
|
|
49
50
|
*/
|
|
50
|
-
update(collectionName: string, entryId: string, data:
|
|
51
|
+
update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
|
|
51
52
|
/**
|
|
52
53
|
* Performs semantic search on custom data entries using text similarity
|
|
53
54
|
* @param collectionName - The name of the collection to search within
|
|
@@ -73,12 +73,13 @@ export default class CustomDataApi extends HttpClient {
|
|
|
73
73
|
* Updates an existing custom data entry
|
|
74
74
|
* @param collectionName - The name of the collection containing the entry
|
|
75
75
|
* @param entryId - The unique identifier of the entry to update
|
|
76
|
-
* @param data - The
|
|
76
|
+
* @param data - The data object to update
|
|
77
|
+
* @param searchText - Optional text to be used for semantic search indexing
|
|
77
78
|
* @returns Promise resolving to an UpdateCustomDataResponse with the updated entry details
|
|
78
79
|
* @throws Error if the entry is not found or the update fails
|
|
79
80
|
*/
|
|
80
|
-
async update(collectionName, entryId, data) {
|
|
81
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, data, {
|
|
81
|
+
async update(collectionName, entryId, data, searchText) {
|
|
82
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, { data, searchText }, {
|
|
82
83
|
Authorization: `Bearer ${this.apiKey}`,
|
|
83
84
|
});
|
|
84
85
|
if (response.success) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
|
-
import { ApiResponse } from "../interfaces/
|
|
2
|
+
import { ApiResponse, MCPServerResponse, CreateMCPServerRequest, UpdateMCPServerRequest } from "../interfaces/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Environment variables response structure from the API
|
|
5
5
|
* The actual environment variables are nested in the 'data' property
|
|
@@ -50,5 +50,58 @@ export default class DeveloperApi extends HttpClient {
|
|
|
50
50
|
message: string;
|
|
51
51
|
key: string;
|
|
52
52
|
}>>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves all MCP server configurations for the agent
|
|
55
|
+
* @returns Promise resolving to an ApiResponse containing MCP server configurations
|
|
56
|
+
*/
|
|
57
|
+
getMCPServers(): Promise<ApiResponse<MCPServerResponse[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves only active MCP server configurations for the agent
|
|
60
|
+
* @returns Promise resolving to an ApiResponse containing active MCP server configurations
|
|
61
|
+
*/
|
|
62
|
+
getActiveMCPServers(): Promise<ApiResponse<MCPServerResponse[]>>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets a single MCP server by ID
|
|
65
|
+
* @param mcpServerId - The ID of the MCP server
|
|
66
|
+
* @returns Promise resolving to an ApiResponse with the MCP server
|
|
67
|
+
*/
|
|
68
|
+
getMCPServer(mcpServerId: string): Promise<ApiResponse<MCPServerResponse>>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new MCP server
|
|
71
|
+
* @param mcpServerData - The MCP server configuration
|
|
72
|
+
* @returns Promise resolving to an ApiResponse with the created MCP server
|
|
73
|
+
*/
|
|
74
|
+
createMCPServer(mcpServerData: CreateMCPServerRequest): Promise<ApiResponse<MCPServerResponse>>;
|
|
75
|
+
/**
|
|
76
|
+
* Updates an existing MCP server
|
|
77
|
+
* @param mcpServerId - The ID of the MCP server to update
|
|
78
|
+
* @param mcpServerData - The updated MCP server configuration
|
|
79
|
+
* @returns Promise resolving to an ApiResponse with the updated MCP server
|
|
80
|
+
*/
|
|
81
|
+
updateMCPServer(mcpServerId: string, mcpServerData: UpdateMCPServerRequest): Promise<ApiResponse<MCPServerResponse>>;
|
|
82
|
+
/**
|
|
83
|
+
* Deletes an MCP server
|
|
84
|
+
* @param mcpServerId - The ID of the MCP server to delete
|
|
85
|
+
* @returns Promise resolving to an ApiResponse with confirmation
|
|
86
|
+
*/
|
|
87
|
+
deleteMCPServer(mcpServerId: string): Promise<ApiResponse<void>>;
|
|
88
|
+
/**
|
|
89
|
+
* Activates an MCP server
|
|
90
|
+
* @param mcpServerId - The ID of the MCP server to activate
|
|
91
|
+
* @returns Promise resolving to an ApiResponse with the activated MCP server
|
|
92
|
+
*/
|
|
93
|
+
activateMCPServer(mcpServerId: string): Promise<ApiResponse<MCPServerResponse>>;
|
|
94
|
+
/**
|
|
95
|
+
* Deactivates an MCP server
|
|
96
|
+
* @param mcpServerId - The ID of the MCP server to deactivate
|
|
97
|
+
* @returns Promise resolving to an ApiResponse with the deactivated MCP server
|
|
98
|
+
*/
|
|
99
|
+
deactivateMCPServer(mcpServerId: string): Promise<ApiResponse<MCPServerResponse>>;
|
|
100
|
+
/**
|
|
101
|
+
* Creates or updates an MCP server by name (upsert)
|
|
102
|
+
* @param mcpServerData - The MCP server configuration
|
|
103
|
+
* @returns Promise resolving to an ApiResponse with the created/updated MCP server
|
|
104
|
+
*/
|
|
105
|
+
upsertMCPServer(mcpServerData: CreateMCPServerRequest): Promise<ApiResponse<MCPServerResponse>>;
|
|
53
106
|
}
|
|
54
107
|
export {};
|
|
@@ -48,4 +48,93 @@ export default class DeveloperApi extends HttpClient {
|
|
|
48
48
|
Authorization: `Bearer ${this.apiKey}`,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all MCP server configurations for the agent
|
|
53
|
+
* @returns Promise resolving to an ApiResponse containing MCP server configurations
|
|
54
|
+
*/
|
|
55
|
+
async getMCPServers() {
|
|
56
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves only active MCP server configurations for the agent
|
|
62
|
+
* @returns Promise resolving to an ApiResponse containing active MCP server configurations
|
|
63
|
+
*/
|
|
64
|
+
async getActiveMCPServers() {
|
|
65
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {
|
|
66
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets a single MCP server by ID
|
|
71
|
+
* @param mcpServerId - The ID of the MCP server
|
|
72
|
+
* @returns Promise resolving to an ApiResponse with the MCP server
|
|
73
|
+
*/
|
|
74
|
+
async getMCPServer(mcpServerId) {
|
|
75
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
76
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new MCP server
|
|
81
|
+
* @param mcpServerData - The MCP server configuration
|
|
82
|
+
* @returns Promise resolving to an ApiResponse with the created MCP server
|
|
83
|
+
*/
|
|
84
|
+
async createMCPServer(mcpServerData) {
|
|
85
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {
|
|
86
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Updates an existing MCP server
|
|
91
|
+
* @param mcpServerId - The ID of the MCP server to update
|
|
92
|
+
* @param mcpServerData - The updated MCP server configuration
|
|
93
|
+
* @returns Promise resolving to an ApiResponse with the updated MCP server
|
|
94
|
+
*/
|
|
95
|
+
async updateMCPServer(mcpServerId, mcpServerData) {
|
|
96
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {
|
|
97
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Deletes an MCP server
|
|
102
|
+
* @param mcpServerId - The ID of the MCP server to delete
|
|
103
|
+
* @returns Promise resolving to an ApiResponse with confirmation
|
|
104
|
+
*/
|
|
105
|
+
async deleteMCPServer(mcpServerId) {
|
|
106
|
+
return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
107
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Activates an MCP server
|
|
112
|
+
* @param mcpServerId - The ID of the MCP server to activate
|
|
113
|
+
* @returns Promise resolving to an ApiResponse with the activated MCP server
|
|
114
|
+
*/
|
|
115
|
+
async activateMCPServer(mcpServerId) {
|
|
116
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {
|
|
117
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Deactivates an MCP server
|
|
122
|
+
* @param mcpServerId - The ID of the MCP server to deactivate
|
|
123
|
+
* @returns Promise resolving to an ApiResponse with the deactivated MCP server
|
|
124
|
+
*/
|
|
125
|
+
async deactivateMCPServer(mcpServerId) {
|
|
126
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {
|
|
127
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Creates or updates an MCP server by name (upsert)
|
|
132
|
+
* @param mcpServerData - The MCP server configuration
|
|
133
|
+
* @returns Promise resolving to an ApiResponse with the created/updated MCP server
|
|
134
|
+
*/
|
|
135
|
+
async upsertMCPServer(mcpServerData) {
|
|
136
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {
|
|
137
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
51
140
|
}
|
|
@@ -1,69 +1,7 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
2
|
import { ApiResponse } from "../interfaces/common.js";
|
|
3
|
-
import { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO } from "../interfaces/jobs.js";
|
|
3
|
+
import { CreateJobDTO, Job, JobVersion, JobExecution, PushJobVersionDTO, UpdateJobVersionDTO, GetJobsResponseData, GetJobExecutionsResponseData, DeleteJobResponseData, UpdateJobMetadataResponseData } from "../interfaces/jobs.js";
|
|
4
4
|
import { JobInstance } from "../common/job.instance.js";
|
|
5
|
-
/**
|
|
6
|
-
* Job API Response Types
|
|
7
|
-
*/
|
|
8
|
-
export interface JobVersion {
|
|
9
|
-
version: string;
|
|
10
|
-
jobId: string;
|
|
11
|
-
createdAt: string | number;
|
|
12
|
-
isActive?: boolean;
|
|
13
|
-
schedule?: any;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
retry?: {
|
|
16
|
-
maxAttempts: number;
|
|
17
|
-
backoffSeconds?: number;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export interface GetJobsResponse {
|
|
21
|
-
jobs: Array<{
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
description?: string;
|
|
25
|
-
context?: string;
|
|
26
|
-
versions: JobVersion[];
|
|
27
|
-
activeVersionId?: string;
|
|
28
|
-
lastRunAt?: string;
|
|
29
|
-
nextRunAt?: string;
|
|
30
|
-
status?: 'active' | 'paused' | 'failed';
|
|
31
|
-
}>;
|
|
32
|
-
}
|
|
33
|
-
export interface CreateJobResponse {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
agentId: string;
|
|
38
|
-
context?: string;
|
|
39
|
-
}
|
|
40
|
-
export interface JobVersionResponse {
|
|
41
|
-
versionId: string;
|
|
42
|
-
jobId: string;
|
|
43
|
-
version: string;
|
|
44
|
-
createdAt: string;
|
|
45
|
-
schedule: any;
|
|
46
|
-
}
|
|
47
|
-
export interface UpdateJobVersionResponse {
|
|
48
|
-
versionId: string;
|
|
49
|
-
jobId: string;
|
|
50
|
-
version: string;
|
|
51
|
-
updatedAt: string;
|
|
52
|
-
}
|
|
53
|
-
export interface DeleteJobResponse {
|
|
54
|
-
deleted: boolean;
|
|
55
|
-
deactivated?: boolean;
|
|
56
|
-
message: string;
|
|
57
|
-
}
|
|
58
|
-
export interface JobExecutionResponse {
|
|
59
|
-
executionId: string;
|
|
60
|
-
jobId: string;
|
|
61
|
-
startedAt: string;
|
|
62
|
-
completedAt?: string;
|
|
63
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
64
|
-
result?: any;
|
|
65
|
-
error?: string;
|
|
66
|
-
}
|
|
67
5
|
/**
|
|
68
6
|
* Job API Service
|
|
69
7
|
* Handles all job-related API calls
|
|
@@ -85,7 +23,17 @@ export default class JobApi extends HttpClient {
|
|
|
85
23
|
*/
|
|
86
24
|
getJobs(options?: {
|
|
87
25
|
includeDynamic?: boolean;
|
|
88
|
-
}): Promise<ApiResponse<
|
|
26
|
+
}): Promise<ApiResponse<GetJobsResponseData>>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves all jobs for the agent as JobInstance array
|
|
29
|
+
* @param options - Optional configuration
|
|
30
|
+
* @param options.includeDynamic - Include dynamically created jobs (default: false)
|
|
31
|
+
* @returns Promise resolving to an array of JobInstance
|
|
32
|
+
* @throws Error if the API request fails
|
|
33
|
+
*/
|
|
34
|
+
getAll(options?: {
|
|
35
|
+
includeDynamic?: boolean;
|
|
36
|
+
}): Promise<JobInstance[]>;
|
|
89
37
|
/**
|
|
90
38
|
* Retrieves a job by its unique identifier
|
|
91
39
|
* @param jobId - The unique identifier of the job to retrieve
|
|
@@ -100,10 +48,10 @@ export default class JobApi extends HttpClient {
|
|
|
100
48
|
* @param jobData - The job data including name, description, schedule, and optional version
|
|
101
49
|
* @param jobData.version - If provided, creates first version automatically
|
|
102
50
|
* @param jobData.activate - If true, activates the job immediately
|
|
103
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
51
|
+
* @returns Promise resolving to an ApiResponse containing the full job with versions
|
|
104
52
|
* @throws Error if the job creation fails or validation errors occur
|
|
105
53
|
*/
|
|
106
|
-
createJob(jobData: CreateJobDTO): Promise<ApiResponse<
|
|
54
|
+
createJob(jobData: CreateJobDTO): Promise<ApiResponse<Job>>;
|
|
107
55
|
/**
|
|
108
56
|
* Creates a new job for the agent and returns a JobInstance.
|
|
109
57
|
* Supports automatic version creation and activation.
|
|
@@ -120,50 +68,42 @@ export default class JobApi extends HttpClient {
|
|
|
120
68
|
* Pushes a new version of a job to production
|
|
121
69
|
* @param jobId - The unique identifier of the job
|
|
122
70
|
* @param versionData - The version data including code, configuration, and metadata
|
|
123
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
71
|
+
* @returns Promise resolving to an ApiResponse containing the full job version
|
|
124
72
|
* @throws Error if the job is not found or the push operation fails
|
|
125
73
|
*/
|
|
126
|
-
pushJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<
|
|
74
|
+
pushJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<JobVersion>>;
|
|
127
75
|
/**
|
|
128
76
|
* Pushes a new development/sandbox version of a job for testing
|
|
129
77
|
* @param jobId - The unique identifier of the job
|
|
130
78
|
* @param versionData - The version data including code, configuration, and metadata
|
|
131
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
79
|
+
* @returns Promise resolving to an ApiResponse containing the full job version
|
|
132
80
|
* @throws Error if the job is not found or the push operation fails
|
|
133
81
|
*/
|
|
134
|
-
pushDevJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<
|
|
82
|
+
pushDevJob(jobId: string, versionData: PushJobVersionDTO): Promise<ApiResponse<JobVersion>>;
|
|
135
83
|
/**
|
|
136
84
|
* Updates an existing development/sandbox version of a job
|
|
137
85
|
* @param jobId - The unique identifier of the job
|
|
138
86
|
* @param sandboxVersionId - The unique identifier of the sandbox version to update
|
|
139
87
|
* @param versionData - The updated version data including code, configuration, and metadata
|
|
140
|
-
* @returns Promise resolving to an ApiResponse containing the updated version
|
|
88
|
+
* @returns Promise resolving to an ApiResponse containing the full updated job version
|
|
141
89
|
* @throws Error if the job or version is not found or the update fails
|
|
142
90
|
*/
|
|
143
|
-
updateDevJob(jobId: string, sandboxVersionId: string, versionData: UpdateJobVersionDTO): Promise<ApiResponse<
|
|
91
|
+
updateDevJob(jobId: string, sandboxVersionId: string, versionData: UpdateJobVersionDTO): Promise<ApiResponse<JobVersion>>;
|
|
144
92
|
/**
|
|
145
93
|
* Retrieves all versions of a specific job
|
|
146
94
|
* @param jobId - The unique identifier of the job
|
|
147
95
|
* @returns Promise resolving to an ApiResponse containing an array of job versions
|
|
148
96
|
* @throws Error if the job is not found or the request fails
|
|
149
97
|
*/
|
|
150
|
-
getJobVersions(jobId: string): Promise<ApiResponse<
|
|
151
|
-
versions: JobVersion[];
|
|
152
|
-
activeVersionId?: string;
|
|
153
|
-
}>>;
|
|
98
|
+
getJobVersions(jobId: string): Promise<ApiResponse<JobVersion[]>>;
|
|
154
99
|
/**
|
|
155
100
|
* Publishes a specific version of a job to production
|
|
156
101
|
* @param jobId - The unique identifier of the job
|
|
157
102
|
* @param version - The version identifier to publish
|
|
158
|
-
* @returns Promise resolving to an ApiResponse containing
|
|
103
|
+
* @returns Promise resolving to an ApiResponse containing the full updated job
|
|
159
104
|
* @throws Error if the job or version is not found or the publish operation fails
|
|
160
105
|
*/
|
|
161
|
-
publishJobVersion(jobId: string, version: string): Promise<ApiResponse<
|
|
162
|
-
message: string;
|
|
163
|
-
jobId: string;
|
|
164
|
-
activeVersionId: string;
|
|
165
|
-
publishedAt: string;
|
|
166
|
-
}>>;
|
|
106
|
+
publishJobVersion(jobId: string, version: string): Promise<ApiResponse<Job>>;
|
|
167
107
|
/**
|
|
168
108
|
* Deletes a job and all its versions, or deactivates it if it has versions
|
|
169
109
|
* @param jobId - The unique identifier of the job to delete
|
|
@@ -172,34 +112,29 @@ export default class JobApi extends HttpClient {
|
|
|
172
112
|
* - If deleted is false and deactivated is true: job has versions and was deactivated instead
|
|
173
113
|
* @throws Error if the job is not found or the delete operation fails
|
|
174
114
|
*/
|
|
175
|
-
deleteJob(jobId: string): Promise<ApiResponse<
|
|
115
|
+
deleteJob(jobId: string): Promise<ApiResponse<DeleteJobResponseData>>;
|
|
176
116
|
/**
|
|
177
117
|
* Activates a job (enables it to run on schedule)
|
|
178
118
|
* @param jobId - The unique identifier of the job to activate
|
|
179
|
-
* @returns Promise resolving to an ApiResponse with
|
|
119
|
+
* @returns Promise resolving to an ApiResponse with the full updated job
|
|
180
120
|
* @throws Error if the job is not found or the operation fails
|
|
181
121
|
*/
|
|
182
|
-
activateJob(jobId: string): Promise<ApiResponse<
|
|
183
|
-
message: string;
|
|
184
|
-
active: boolean;
|
|
185
|
-
}>>;
|
|
122
|
+
activateJob(jobId: string): Promise<ApiResponse<Job>>;
|
|
186
123
|
/**
|
|
187
124
|
* Deactivates a job (disables it from running)
|
|
188
125
|
* @param jobId - The unique identifier of the job to deactivate
|
|
189
|
-
* @returns Promise resolving to an ApiResponse with
|
|
126
|
+
* @returns Promise resolving to an ApiResponse with the full updated job
|
|
190
127
|
* @throws Error if the job is not found or the operation fails
|
|
191
128
|
*/
|
|
192
|
-
deactivateJob(jobId: string): Promise<ApiResponse<
|
|
193
|
-
message: string;
|
|
194
|
-
active: boolean;
|
|
195
|
-
}>>;
|
|
129
|
+
deactivateJob(jobId: string): Promise<ApiResponse<Job>>;
|
|
196
130
|
/**
|
|
197
131
|
* Manually triggers a job execution (ignores schedule)
|
|
198
132
|
* @param jobId - The unique identifier of the job to trigger
|
|
199
|
-
* @
|
|
133
|
+
* @param versionId - The version identifier to execute (optional, defaults to activeVersionId)
|
|
134
|
+
* @returns Promise resolving to an ApiResponse with the execution record
|
|
200
135
|
* @throws Error if the job is not found or the operation fails
|
|
201
136
|
*/
|
|
202
|
-
triggerJob(jobId: string): Promise<ApiResponse<
|
|
137
|
+
triggerJob(jobId: string, versionId?: string): Promise<ApiResponse<JobExecution>>;
|
|
203
138
|
/**
|
|
204
139
|
* Retrieves execution history for a job
|
|
205
140
|
* @param jobId - The unique identifier of the job
|
|
@@ -207,9 +142,7 @@ export default class JobApi extends HttpClient {
|
|
|
207
142
|
* @returns Promise resolving to an ApiResponse with execution history
|
|
208
143
|
* @throws Error if the job is not found or the request fails
|
|
209
144
|
*/
|
|
210
|
-
getJobExecutions(jobId: string, limit?: number): Promise<ApiResponse<
|
|
211
|
-
executions: JobExecutionResponse[];
|
|
212
|
-
}>>;
|
|
145
|
+
getJobExecutions(jobId: string, limit?: number): Promise<ApiResponse<GetJobExecutionsResponseData>>;
|
|
213
146
|
/**
|
|
214
147
|
* Updates the metadata of a job
|
|
215
148
|
* @param jobId - The unique identifier of the job
|
|
@@ -217,5 +150,5 @@ export default class JobApi extends HttpClient {
|
|
|
217
150
|
* @returns Promise resolving to the updated metadata
|
|
218
151
|
* @throws Error if the job is not found or the metadata update fails
|
|
219
152
|
*/
|
|
220
|
-
updateMetadata(jobId: string, metadata: any): Promise<ApiResponse<
|
|
153
|
+
updateMetadata(jobId: string, metadata: Record<string, any>): Promise<ApiResponse<UpdateJobMetadataResponseData>>;
|
|
221
154
|
}
|
|
@@ -32,6 +32,20 @@ export default class JobApi extends HttpClient {
|
|
|
32
32
|
Authorization: `Bearer ${this.apiKey}`,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves all jobs for the agent as JobInstance array
|
|
37
|
+
* @param options - Optional configuration
|
|
38
|
+
* @param options.includeDynamic - Include dynamically created jobs (default: false)
|
|
39
|
+
* @returns Promise resolving to an array of JobInstance
|
|
40
|
+
* @throws Error if the API request fails
|
|
41
|
+
*/
|
|
42
|
+
async getAll(options = {}) {
|
|
43
|
+
const response = await this.getJobs(options);
|
|
44
|
+
if (response.success && response.data?.jobs) {
|
|
45
|
+
return response.data.jobs.map(job => new JobInstance(this, job));
|
|
46
|
+
}
|
|
47
|
+
throw new Error(response.error?.message || 'Failed to get all jobs');
|
|
48
|
+
}
|
|
35
49
|
/**
|
|
36
50
|
* Retrieves a job by its unique identifier
|
|
37
51
|
* @param jobId - The unique identifier of the job to retrieve
|
|
@@ -54,7 +68,7 @@ export default class JobApi extends HttpClient {
|
|
|
54
68
|
* @param jobData - The job data including name, description, schedule, and optional version
|
|
55
69
|
* @param jobData.version - If provided, creates first version automatically
|
|
56
70
|
* @param jobData.activate - If true, activates the job immediately
|
|
57
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
71
|
+
* @returns Promise resolving to an ApiResponse containing the full job with versions
|
|
58
72
|
* @throws Error if the job creation fails or validation errors occur
|
|
59
73
|
*/
|
|
60
74
|
async createJob(jobData) {
|
|
@@ -92,7 +106,7 @@ export default class JobApi extends HttpClient {
|
|
|
92
106
|
* Pushes a new version of a job to production
|
|
93
107
|
* @param jobId - The unique identifier of the job
|
|
94
108
|
* @param versionData - The version data including code, configuration, and metadata
|
|
95
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
109
|
+
* @returns Promise resolving to an ApiResponse containing the full job version
|
|
96
110
|
* @throws Error if the job is not found or the push operation fails
|
|
97
111
|
*/
|
|
98
112
|
async pushJob(jobId, versionData) {
|
|
@@ -104,7 +118,7 @@ export default class JobApi extends HttpClient {
|
|
|
104
118
|
* Pushes a new development/sandbox version of a job for testing
|
|
105
119
|
* @param jobId - The unique identifier of the job
|
|
106
120
|
* @param versionData - The version data including code, configuration, and metadata
|
|
107
|
-
* @returns Promise resolving to an ApiResponse containing the
|
|
121
|
+
* @returns Promise resolving to an ApiResponse containing the full job version
|
|
108
122
|
* @throws Error if the job is not found or the push operation fails
|
|
109
123
|
*/
|
|
110
124
|
async pushDevJob(jobId, versionData) {
|
|
@@ -117,7 +131,7 @@ export default class JobApi extends HttpClient {
|
|
|
117
131
|
* @param jobId - The unique identifier of the job
|
|
118
132
|
* @param sandboxVersionId - The unique identifier of the sandbox version to update
|
|
119
133
|
* @param versionData - The updated version data including code, configuration, and metadata
|
|
120
|
-
* @returns Promise resolving to an ApiResponse containing the updated version
|
|
134
|
+
* @returns Promise resolving to an ApiResponse containing the full updated job version
|
|
121
135
|
* @throws Error if the job or version is not found or the update fails
|
|
122
136
|
*/
|
|
123
137
|
async updateDevJob(jobId, sandboxVersionId, versionData) {
|
|
@@ -140,11 +154,11 @@ export default class JobApi extends HttpClient {
|
|
|
140
154
|
* Publishes a specific version of a job to production
|
|
141
155
|
* @param jobId - The unique identifier of the job
|
|
142
156
|
* @param version - The version identifier to publish
|
|
143
|
-
* @returns Promise resolving to an ApiResponse containing
|
|
157
|
+
* @returns Promise resolving to an ApiResponse containing the full updated job
|
|
144
158
|
* @throws Error if the job or version is not found or the publish operation fails
|
|
145
159
|
*/
|
|
146
160
|
async publishJobVersion(jobId, version) {
|
|
147
|
-
return this.
|
|
161
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {
|
|
148
162
|
Authorization: `Bearer ${this.apiKey}`,
|
|
149
163
|
});
|
|
150
164
|
}
|
|
@@ -164,7 +178,7 @@ export default class JobApi extends HttpClient {
|
|
|
164
178
|
/**
|
|
165
179
|
* Activates a job (enables it to run on schedule)
|
|
166
180
|
* @param jobId - The unique identifier of the job to activate
|
|
167
|
-
* @returns Promise resolving to an ApiResponse with
|
|
181
|
+
* @returns Promise resolving to an ApiResponse with the full updated job
|
|
168
182
|
* @throws Error if the job is not found or the operation fails
|
|
169
183
|
*/
|
|
170
184
|
async activateJob(jobId) {
|
|
@@ -175,7 +189,7 @@ export default class JobApi extends HttpClient {
|
|
|
175
189
|
/**
|
|
176
190
|
* Deactivates a job (disables it from running)
|
|
177
191
|
* @param jobId - The unique identifier of the job to deactivate
|
|
178
|
-
* @returns Promise resolving to an ApiResponse with
|
|
192
|
+
* @returns Promise resolving to an ApiResponse with the full updated job
|
|
179
193
|
* @throws Error if the job is not found or the operation fails
|
|
180
194
|
*/
|
|
181
195
|
async deactivateJob(jobId) {
|
|
@@ -186,11 +200,13 @@ export default class JobApi extends HttpClient {
|
|
|
186
200
|
/**
|
|
187
201
|
* Manually triggers a job execution (ignores schedule)
|
|
188
202
|
* @param jobId - The unique identifier of the job to trigger
|
|
189
|
-
* @
|
|
203
|
+
* @param versionId - The version identifier to execute (optional, defaults to activeVersionId)
|
|
204
|
+
* @returns Promise resolving to an ApiResponse with the execution record
|
|
190
205
|
* @throws Error if the job is not found or the operation fails
|
|
191
206
|
*/
|
|
192
|
-
async triggerJob(jobId) {
|
|
193
|
-
|
|
207
|
+
async triggerJob(jobId, versionId) {
|
|
208
|
+
const body = versionId ? { versionId } : {};
|
|
209
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {
|
|
194
210
|
Authorization: `Bearer ${this.apiKey}`,
|
|
195
211
|
});
|
|
196
212
|
}
|
|
@@ -10,6 +10,8 @@ import CustomDataApiService from "./custom.data.api.service.js";
|
|
|
10
10
|
import WebhookApi from "./webhook.api.service.js";
|
|
11
11
|
import JobApi from "./job.api.service.js";
|
|
12
12
|
import ChatApi from "./chat.api.service.js";
|
|
13
|
+
import WhatsAppTemplatesApiService from "./whatsapp-templates.api.service.js";
|
|
14
|
+
import CdnApi from "./cdn.api.service.js";
|
|
13
15
|
/**
|
|
14
16
|
* Gets or creates User Data API instance.
|
|
15
17
|
* Instance is created once and reused for subsequent calls.
|
|
@@ -66,6 +68,20 @@ export declare function getJobInstance(): Promise<JobApi>;
|
|
|
66
68
|
* @returns ChatApi instance
|
|
67
69
|
*/
|
|
68
70
|
export declare function getChatInstance(): Promise<ChatApi>;
|
|
71
|
+
/**
|
|
72
|
+
* Gets or creates Templates API instance.
|
|
73
|
+
* Instance is created once and reused for subsequent calls.
|
|
74
|
+
*
|
|
75
|
+
* @returns WhatsAppTemplatesApiService instance
|
|
76
|
+
*/
|
|
77
|
+
export declare function getWhatsAppTemplatesInstance(): Promise<WhatsAppTemplatesApiService>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets or creates CDN API instance.
|
|
80
|
+
* Instance is created once and reused for subsequent calls.
|
|
81
|
+
*
|
|
82
|
+
* @returns CdnApi instance
|
|
83
|
+
*/
|
|
84
|
+
export declare function getCdnInstance(): Promise<CdnApi>;
|
|
69
85
|
/**
|
|
70
86
|
* Clears all cached API instances.
|
|
71
87
|
* Useful for testing or when credentials change.
|