lua-cli 3.1.0-alpha.4 → 3.1.0
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/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 +10 -0
- package/dist/api/job.api.service.js +14 -0
- package/dist/api/lazy-instances.d.ts +8 -0
- package/dist/api/lazy-instances.js +16 -0
- package/dist/api/postprocessor.api.service.d.ts +3 -6
- package/dist/api/postprocessor.api.service.js +2 -3
- package/dist/api-exports.d.ts +74 -6
- package/dist/api-exports.js +87 -7
- 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/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 +13 -3
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.js +393 -0
- package/dist/commands/push.js +172 -14
- 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 +24 -0
- package/dist/common/job.instance.js +38 -0
- package/dist/config/constants.d.ts +1 -0
- package/dist/config/constants.js +1 -0
- package/dist/index.js +1 -0
- 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 +1 -0
- package/dist/interfaces/mcp.d.ts +64 -0
- package/dist/interfaces/mcp.js +5 -0
- package/dist/types/api-contracts.d.ts +36 -14
- package/dist/types/compile.types.d.ts +5 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -1
- package/dist/types/skill.d.ts +120 -13
- package/dist/types/skill.js +95 -5
- package/dist/utils/bundling.d.ts +4 -11
- package/dist/utils/bundling.js +19 -27
- package/dist/utils/compile.d.ts +17 -8
- package/dist/utils/compile.js +71 -37
- package/dist/utils/deployment.js +13 -6
- package/dist/utils/dev-api.js +1 -2
- package/dist/utils/dev-server.js +1 -1
- package/dist/utils/files.d.ts +8 -1
- package/dist/utils/files.js +13 -2
- package/dist/utils/init-helpers.d.ts +3 -1
- package/dist/utils/init-helpers.js +7 -2
- package/dist/utils/mcp-server-management.d.ts +23 -0
- package/dist/utils/mcp-server-management.js +212 -0
- package/dist/utils/sandbox.d.ts +4 -2
- package/dist/utils/sandbox.js +22 -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 -761
- package/template/README.md +80 -906
- package/template/examples/README.md +106 -0
- package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -11
- package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -3
- 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/examples/webhooks/FileUploadWebhook.ts +86 -0
- package/template/package-lock.json +7895 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +40 -22
- /package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -0
- /package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -0
- /package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -0
- /package/template/{src → examples}/preprocessors/messageMatching.ts +0 -0
- /package/template/{src → examples}/services/ApiService.ts +0 -0
- /package/template/{src → examples}/services/GetWeather.ts +0 -0
- /package/template/{src → examples}/skills/basket.skill.ts +0 -0
- /package/template/{src → examples}/skills/product.skill.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/template/{src → examples}/skills/user.skill.ts +0 -0
- /package/template/{src → examples}/webhooks/PaymentWebhook.ts +0 -0
- /package/template/{src → examples}/webhooks/UserEventWebhook.ts +0 -0
|
@@ -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
|
}
|
|
@@ -24,6 +24,16 @@ export default class JobApi extends HttpClient {
|
|
|
24
24
|
getJobs(options?: {
|
|
25
25
|
includeDynamic?: boolean;
|
|
26
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[]>;
|
|
27
37
|
/**
|
|
28
38
|
* Retrieves a job by its unique identifier
|
|
29
39
|
* @param jobId - The unique identifier of the job to retrieve
|
|
@@ -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
|
|
@@ -11,6 +11,7 @@ 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
13
|
import WhatsAppTemplatesApiService from "./whatsapp-templates.api.service.js";
|
|
14
|
+
import CdnApi from "./cdn.api.service.js";
|
|
14
15
|
/**
|
|
15
16
|
* Gets or creates User Data API instance.
|
|
16
17
|
* Instance is created once and reused for subsequent calls.
|
|
@@ -74,6 +75,13 @@ export declare function getChatInstance(): Promise<ChatApi>;
|
|
|
74
75
|
* @returns WhatsAppTemplatesApiService instance
|
|
75
76
|
*/
|
|
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>;
|
|
77
85
|
/**
|
|
78
86
|
* Clears all cached API instances.
|
|
79
87
|
* Useful for testing or when credentials change.
|
|
@@ -13,6 +13,7 @@ import WebhookApi from "./webhook.api.service.js";
|
|
|
13
13
|
import JobApi from "./job.api.service.js";
|
|
14
14
|
import ChatApi from "./chat.api.service.js";
|
|
15
15
|
import WhatsAppTemplatesApiService from "./whatsapp-templates.api.service.js";
|
|
16
|
+
import CdnApi from "./cdn.api.service.js";
|
|
16
17
|
/**
|
|
17
18
|
* Singleton instances (lazy-loaded)
|
|
18
19
|
*/
|
|
@@ -25,6 +26,7 @@ let _webhookInstance = null;
|
|
|
25
26
|
let _jobInstance = null;
|
|
26
27
|
let _chatInstance = null;
|
|
27
28
|
let _whatsAppTemplatesInstance = null;
|
|
29
|
+
let _cdnInstance = null;
|
|
28
30
|
/**
|
|
29
31
|
* Gets or creates User Data API instance.
|
|
30
32
|
* Instance is created once and reused for subsequent calls.
|
|
@@ -142,6 +144,19 @@ export async function getWhatsAppTemplatesInstance() {
|
|
|
142
144
|
}
|
|
143
145
|
return _whatsAppTemplatesInstance;
|
|
144
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Gets or creates CDN API instance.
|
|
149
|
+
* Instance is created once and reused for subsequent calls.
|
|
150
|
+
*
|
|
151
|
+
* @returns CdnApi instance
|
|
152
|
+
*/
|
|
153
|
+
export async function getCdnInstance() {
|
|
154
|
+
if (!_cdnInstance) {
|
|
155
|
+
const creds = await getCredentials();
|
|
156
|
+
_cdnInstance = new CdnApi(BASE_URLS.CDN, creds.apiKey);
|
|
157
|
+
}
|
|
158
|
+
return _cdnInstance;
|
|
159
|
+
}
|
|
145
160
|
/**
|
|
146
161
|
* Clears all cached API instances.
|
|
147
162
|
* Useful for testing or when credentials change.
|
|
@@ -156,4 +171,5 @@ export function clearAllInstances() {
|
|
|
156
171
|
_jobInstance = null;
|
|
157
172
|
_chatInstance = null;
|
|
158
173
|
_whatsAppTemplatesInstance = null;
|
|
174
|
+
_cdnInstance = null;
|
|
159
175
|
}
|
|
@@ -22,6 +22,7 @@ export interface CreatePostProcessorResponse {
|
|
|
22
22
|
id: string;
|
|
23
23
|
name: string;
|
|
24
24
|
description?: string;
|
|
25
|
+
priority: number;
|
|
25
26
|
agentId: string;
|
|
26
27
|
}
|
|
27
28
|
export interface PostProcessorVersionResponse {
|
|
@@ -58,12 +59,11 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
58
59
|
* Pushes a new version of a postprocessor
|
|
59
60
|
*
|
|
60
61
|
* @param postprocessorId - The postprocessor ID
|
|
61
|
-
* @param versionData - Version data including code
|
|
62
|
+
* @param versionData - Version data including code and description
|
|
62
63
|
* @param versionData.version - Version number
|
|
63
64
|
* @param versionData.code - Compressed execute function code
|
|
64
65
|
* @param versionData.executeFunction - Raw execute function code
|
|
65
66
|
* @param versionData.description - Postprocessor description
|
|
66
|
-
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
67
67
|
*/
|
|
68
68
|
pushPostProcessor(postprocessorId: string, versionData: {
|
|
69
69
|
name: string;
|
|
@@ -72,7 +72,6 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
72
72
|
postprocessorId: string;
|
|
73
73
|
code: string;
|
|
74
74
|
executeFunction: string;
|
|
75
|
-
async?: boolean;
|
|
76
75
|
}): Promise<ApiResponse<PostProcessorVersionResponse>>;
|
|
77
76
|
/**
|
|
78
77
|
* Retrieves all versions of a specific postprocessor
|
|
@@ -113,7 +112,7 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
113
112
|
* Creates a new sandbox version for testing without affecting production
|
|
114
113
|
*
|
|
115
114
|
* @param postprocessorId - The postprocessor ID
|
|
116
|
-
* @param versionData - Version data including code
|
|
115
|
+
* @param versionData - Version data including code
|
|
117
116
|
* @returns Sandbox version response with sandboxId
|
|
118
117
|
*/
|
|
119
118
|
pushDevPostProcessor(postprocessorId: string, versionData: {
|
|
@@ -122,7 +121,6 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
122
121
|
description?: string;
|
|
123
122
|
code: string;
|
|
124
123
|
executeFunction: string;
|
|
125
|
-
async?: boolean;
|
|
126
124
|
}): Promise<ApiResponse<{
|
|
127
125
|
versionId: string;
|
|
128
126
|
postprocessorId: string;
|
|
@@ -143,7 +141,6 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
143
141
|
description?: string;
|
|
144
142
|
code: string;
|
|
145
143
|
executeFunction: string;
|
|
146
|
-
async?: boolean;
|
|
147
144
|
}): Promise<ApiResponse<{
|
|
148
145
|
message: string;
|
|
149
146
|
versionId: string;
|
|
@@ -29,12 +29,11 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
29
29
|
* Pushes a new version of a postprocessor
|
|
30
30
|
*
|
|
31
31
|
* @param postprocessorId - The postprocessor ID
|
|
32
|
-
* @param versionData - Version data including code
|
|
32
|
+
* @param versionData - Version data including code and description
|
|
33
33
|
* @param versionData.version - Version number
|
|
34
34
|
* @param versionData.code - Compressed execute function code
|
|
35
35
|
* @param versionData.executeFunction - Raw execute function code
|
|
36
36
|
* @param versionData.description - Postprocessor description
|
|
37
|
-
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
38
37
|
*/
|
|
39
38
|
async pushPostProcessor(postprocessorId, versionData) {
|
|
40
39
|
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/version`, versionData, {
|
|
@@ -86,7 +85,7 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
86
85
|
* Creates a new sandbox version for testing without affecting production
|
|
87
86
|
*
|
|
88
87
|
* @param postprocessorId - The postprocessor ID
|
|
89
|
-
* @param versionData - Version data including code
|
|
88
|
+
* @param versionData - Version data including code
|
|
90
89
|
* @returns Sandbox version response with sandboxId
|
|
91
90
|
*/
|
|
92
91
|
async pushDevPostProcessor(postprocessorId, versionData) {
|
package/dist/api-exports.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* const products = await Products.search('laptop');
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
import { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PreProcessorAction, PreProcessorResult, PreProcessorBlockResponse, PreProcessorProceedResponse, PostProcessor, PostProcessorConfig, LuaAgent, LuaAgentConfig, env } from "./types/skill.js";
|
|
29
|
+
import { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PreProcessorAction, PreProcessorResult, PreProcessorBlockResponse, PreProcessorProceedResponse, PostProcessor, PostProcessorConfig, PostProcessorResponse, LuaAgent, LuaAgentConfig, LuaMCPServer, LuaMCPServerConfig, MCPStdioServerConfig, MCPSSEServerConfig, MCPTransport, MCPServerBaseConfig, env } from "./types/skill.js";
|
|
30
30
|
import { Basket, BasketStatus, UpdateBasketMetadataResponse } from "./interfaces/baskets.js";
|
|
31
31
|
import { OrderResponse, OrderStatus } from "./interfaces/orders.js";
|
|
32
32
|
import { ChatHistoryMessage, ChatHistoryContent, ChatMessage, TextMessage, ImageMessage, FileMessage, PreProcessorOverride, PostProcessorOverride } from "./interfaces/chat.js";
|
|
@@ -77,7 +77,7 @@ export declare const Data: {
|
|
|
77
77
|
* @param searchText - Optional text for vector search indexing
|
|
78
78
|
* @returns Promise resolving to created entry
|
|
79
79
|
*/
|
|
80
|
-
create(collectionName: string, data:
|
|
80
|
+
create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
|
|
81
81
|
/**
|
|
82
82
|
* Retrieves entries from a collection with optional filtering and pagination.
|
|
83
83
|
*
|
|
@@ -101,10 +101,11 @@ export declare const Data: {
|
|
|
101
101
|
*
|
|
102
102
|
* @param collectionName - Name of the collection
|
|
103
103
|
* @param entryId - ID of the entry to update
|
|
104
|
-
* @param data - Updated data
|
|
105
|
-
* @
|
|
104
|
+
* @param data - Updated data fields to merge with existing entry
|
|
105
|
+
* @param searchText - Optional new search text for vector search indexing
|
|
106
|
+
* @returns Promise resolving to update response
|
|
106
107
|
*/
|
|
107
|
-
update(collectionName: string, entryId: string, data: any): Promise<UpdateCustomDataResponse>;
|
|
108
|
+
update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
|
|
108
109
|
/**
|
|
109
110
|
* Performs vector search on a collection.
|
|
110
111
|
*
|
|
@@ -360,6 +361,24 @@ export declare const Jobs: {
|
|
|
360
361
|
* @throws Error if the job is not found or the request fails
|
|
361
362
|
*/
|
|
362
363
|
getJob(jobId: string): Promise<JobInstance>;
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves all jobs for the current agent
|
|
366
|
+
* @param options - Optional configuration
|
|
367
|
+
* @param options.includeDynamic - Include dynamically created jobs (default: false)
|
|
368
|
+
* @returns Promise resolving to an array of JobInstance
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* // Get all jobs including dynamically created ones
|
|
373
|
+
* const jobs = await Jobs.getAll({ includeDynamic: true });
|
|
374
|
+
* for (const job of jobs) {
|
|
375
|
+
* console.log(job.name, job.data.active ? 'active' : 'inactive');
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
getAll(options?: {
|
|
380
|
+
includeDynamic?: boolean;
|
|
381
|
+
}): Promise<JobInstance[]>;
|
|
363
382
|
};
|
|
364
383
|
/**
|
|
365
384
|
* AI API
|
|
@@ -479,7 +498,56 @@ export declare const Templates: {
|
|
|
479
498
|
send(channelId: string, templateId: string, data: SendTemplateData): Promise<SendTemplateResponse>;
|
|
480
499
|
};
|
|
481
500
|
};
|
|
482
|
-
|
|
501
|
+
/**
|
|
502
|
+
* CDN API
|
|
503
|
+
* Upload and retrieve files from the Lua CDN
|
|
504
|
+
*/
|
|
505
|
+
export declare const CDN: {
|
|
506
|
+
/**
|
|
507
|
+
* Uploads a file to the CDN.
|
|
508
|
+
*
|
|
509
|
+
* @param file - The File object to upload
|
|
510
|
+
* @returns Promise resolving to the file ID
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* import { CDN } from 'lua-cli';
|
|
515
|
+
* import { readFileSync } from 'fs';
|
|
516
|
+
*
|
|
517
|
+
* const buffer = readFileSync('image.png');
|
|
518
|
+
* const file = new File([buffer], 'image.png', { type: 'image/png' });
|
|
519
|
+
* const fileId = await CDN.upload(file);
|
|
520
|
+
* console.log('Uploaded file ID:', fileId);
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
upload(file: File): Promise<string>;
|
|
524
|
+
/**
|
|
525
|
+
* Retrieves a file from the CDN by its ID.
|
|
526
|
+
*
|
|
527
|
+
* @param fileId - The unique identifier of the file
|
|
528
|
+
* @returns Promise resolving to a File object
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* import { CDN, AI } from 'lua-cli';
|
|
533
|
+
*
|
|
534
|
+
* const file = await CDN.get('abc123-def456');
|
|
535
|
+
* console.log(file.name, file.type, file.size);
|
|
536
|
+
*
|
|
537
|
+
* // Use with AI API for image analysis
|
|
538
|
+
* const buffer = Buffer.from(await file.arrayBuffer());
|
|
539
|
+
* const response = await AI.generate(
|
|
540
|
+
* 'You are an image analysis expert.',
|
|
541
|
+
* [
|
|
542
|
+
* { type: 'text', text: 'What do you see in this image?' },
|
|
543
|
+
* { type: 'image', image: buffer, mediaType: file.type }
|
|
544
|
+
* ]
|
|
545
|
+
* );
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
get(fileId: string): Promise<File>;
|
|
549
|
+
};
|
|
550
|
+
export { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PreProcessorAction, PreProcessorResult, PreProcessorBlockResponse, PreProcessorProceedResponse, PostProcessor, PostProcessorConfig, PostProcessorResponse, LuaAgent, LuaAgentConfig, LuaMCPServer, LuaMCPServerConfig, MCPStdioServerConfig, MCPSSEServerConfig, MCPTransport, MCPServerBaseConfig, BasketStatus, OrderStatus, env };
|
|
483
551
|
export { JobInstance, UserDataInstance, DataEntryInstance, ProductInstance, BasketInstance, OrderInstance };
|
|
484
552
|
export { ChatHistoryMessage, ChatHistoryContent, ChatMessage, TextMessage, ImageMessage, FileMessage, PreProcessorOverride, PostProcessorOverride };
|
|
485
553
|
export { WhatsAppTemplate, PaginatedTemplatesResponse, ListTemplatesOptions, SendTemplateData, SendTemplateResponse, WhatsAppTemplateCategory, WhatsAppTemplateStatus, WhatsAppTemplateComponent, SendTemplateValues } from "./interfaces/whatsapp-templates.js";
|