lua-cli 2.2.8-alpha.2 → 2.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API_REFERENCE.md +1408 -0
- package/CLI_REFERENCE.md +818 -0
- package/GETTING_STARTED.md +1040 -0
- package/README.md +738 -424
- package/TEMPLATE_GUIDE.md +1398 -0
- package/dist/api/agent.api.service.d.ts +33 -6
- package/dist/api/agent.api.service.js +27 -0
- package/dist/api/auth.api.service.d.ts +31 -2
- package/dist/api/auth.api.service.js +29 -0
- package/dist/api/basket.api.service.d.ts +53 -11
- package/dist/api/basket.api.service.js +63 -14
- package/dist/api/chat.api.service.d.ts +15 -3
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/credentials.d.ts +24 -0
- package/dist/api/credentials.js +46 -0
- package/dist/api/custom.data.api.service.d.ts +45 -9
- package/dist/api/custom.data.api.service.js +43 -9
- package/dist/api/lazy-instances.d.ts +49 -0
- package/dist/api/lazy-instances.js +95 -0
- package/dist/api/order.api.service.d.ts +34 -4
- package/dist/api/order.api.service.js +41 -3
- package/dist/api/products.api.service.d.ts +39 -9
- package/dist/api/products.api.service.js +43 -5
- package/dist/api/skills.api.service.d.ts +49 -2
- package/dist/api/skills.api.service.js +47 -1
- package/dist/api/tool.api.service.d.ts +39 -1
- package/dist/api/tool.api.service.js +38 -0
- package/dist/api/user.data.api.service.d.ts +23 -1
- package/dist/api/user.data.api.service.js +22 -0
- package/dist/api-exports.d.ts +236 -5
- package/dist/api-exports.js +264 -81
- package/dist/cli/command-definitions.d.ts +30 -0
- package/dist/cli/command-definitions.js +71 -0
- package/dist/commands/agents.d.ts +20 -0
- package/dist/commands/agents.js +24 -2
- package/dist/commands/apiKey.d.ts +23 -0
- package/dist/commands/apiKey.js +23 -0
- package/dist/commands/compile.d.ts +24 -0
- package/dist/commands/compile.js +67 -759
- package/dist/commands/configure.d.ts +24 -0
- package/dist/commands/configure.js +31 -96
- package/dist/commands/deploy.d.ts +31 -19
- package/dist/commands/deploy.js +45 -74
- package/dist/commands/destroy.d.ts +27 -0
- package/dist/commands/destroy.js +27 -1
- package/dist/commands/dev.d.ts +25 -62
- package/dist/commands/dev.js +58 -878
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +98 -260
- package/dist/commands/push.d.ts +24 -21
- package/dist/commands/push.js +39 -92
- package/dist/commands/test.d.ts +26 -0
- package/dist/commands/test.js +41 -188
- package/dist/common/basket.instance.d.ts +54 -3
- package/dist/common/basket.instance.js +56 -3
- package/dist/common/data.entry.instance.d.ts +25 -2
- package/dist/common/data.entry.instance.js +24 -0
- package/dist/common/http.client.d.ts +51 -1
- package/dist/common/http.client.js +50 -0
- package/dist/common/order.instance.d.ts +22 -0
- package/dist/common/order.instance.js +31 -4
- package/dist/common/product.instance.d.ts +22 -1
- package/dist/common/product.instance.js +24 -6
- package/dist/common/product.pagination.instance.d.ts +22 -2
- package/dist/common/product.pagination.instance.js +22 -1
- package/dist/common/product.search.instance.d.ts +13 -3
- package/dist/common/product.search.instance.js +12 -1
- package/dist/common/user.instance.d.ts +27 -3
- package/dist/common/user.instance.js +28 -7
- package/dist/config/auth.constants.d.ts +11 -0
- package/dist/config/auth.constants.js +11 -0
- package/dist/config/compile.constants.d.ts +67 -0
- package/dist/config/compile.constants.js +99 -0
- package/dist/config/constants.d.ts +5 -0
- package/dist/config/constants.js +5 -0
- package/dist/config/dev.constants.d.ts +65 -0
- package/dist/config/dev.constants.js +79 -0
- package/dist/config/init.constants.d.ts +23 -0
- package/dist/config/init.constants.js +41 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +28 -44
- package/dist/interfaces/admin.d.ts +56 -50
- package/dist/interfaces/admin.js +4 -0
- package/dist/interfaces/agent.d.ts +21 -0
- package/dist/interfaces/agent.js +4 -0
- package/dist/interfaces/baskets.d.ts +60 -0
- package/dist/interfaces/baskets.js +12 -0
- package/dist/interfaces/chat.d.ts +48 -4
- package/dist/interfaces/chat.js +4 -0
- package/dist/interfaces/common.d.ts +62 -0
- package/dist/interfaces/common.js +8 -0
- package/dist/interfaces/compile.d.ts +11 -0
- package/dist/interfaces/compile.js +4 -0
- package/dist/interfaces/custom.data.d.ts +49 -19
- package/dist/interfaces/custom.data.js +4 -0
- package/dist/interfaces/deploy.d.ts +29 -0
- package/dist/interfaces/deploy.js +4 -0
- package/dist/interfaces/dev.d.ts +53 -0
- package/dist/interfaces/dev.js +5 -0
- package/dist/interfaces/init.d.ts +60 -0
- package/dist/interfaces/init.js +4 -0
- package/dist/interfaces/orders.d.ts +37 -0
- package/dist/interfaces/orders.js +12 -0
- package/dist/interfaces/product.d.ts +38 -10
- package/dist/interfaces/product.js +4 -0
- package/dist/interfaces/push.d.ts +26 -0
- package/dist/interfaces/push.js +4 -0
- package/dist/interfaces/test.d.ts +36 -0
- package/dist/interfaces/test.js +4 -0
- package/dist/services/auth.d.ts +54 -99
- package/dist/services/auth.js +76 -12
- package/dist/types/api-contracts.d.ts +211 -0
- package/dist/types/api-contracts.js +8 -0
- package/dist/types/compile.types.d.ts +76 -0
- package/dist/types/compile.types.js +4 -0
- package/dist/types/index.d.ts +23 -121
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -17
- package/dist/types/tool-validation.d.ts +34 -0
- package/dist/types/tool-validation.js +42 -0
- package/dist/utils/auth-flows.d.ts +26 -0
- package/dist/utils/auth-flows.js +141 -0
- package/dist/utils/bundling.d.ts +36 -0
- package/dist/utils/bundling.js +137 -0
- package/dist/utils/compile.d.ts +37 -0
- package/dist/utils/compile.js +242 -0
- package/dist/utils/deploy-api.d.ts +26 -0
- package/dist/utils/deploy-api.js +53 -0
- package/dist/utils/deploy-helpers.d.ts +46 -0
- package/dist/utils/deploy-helpers.js +86 -0
- package/dist/utils/deployment.d.ts +25 -0
- package/dist/utils/deployment.js +161 -0
- package/dist/utils/dev-api.d.ts +61 -0
- package/dist/utils/dev-api.js +262 -0
- package/dist/utils/dev-helpers.d.ts +46 -0
- package/dist/utils/dev-helpers.js +83 -0
- package/dist/utils/dev-server.d.ts +24 -0
- package/dist/utils/dev-server.js +555 -0
- package/dist/utils/dev-watcher.d.ts +31 -0
- package/dist/utils/dev-watcher.js +110 -0
- package/dist/utils/files.js +0 -5
- package/dist/utils/init-agent.d.ts +34 -0
- package/dist/utils/init-agent.js +129 -0
- package/dist/utils/init-helpers.d.ts +41 -0
- package/dist/utils/init-helpers.js +73 -0
- package/dist/utils/init-prompts.d.ts +47 -0
- package/dist/utils/init-prompts.js +168 -0
- package/dist/utils/push-api.d.ts +15 -0
- package/dist/utils/push-api.js +48 -0
- package/dist/utils/push-helpers.d.ts +38 -0
- package/dist/utils/push-helpers.js +84 -0
- package/dist/utils/sandbox-storage.d.ts +27 -0
- package/dist/utils/sandbox-storage.js +71 -0
- package/dist/utils/sandbox.js +78 -114
- package/dist/utils/skill-management.d.ts +14 -0
- package/dist/utils/skill-management.js +148 -0
- package/dist/utils/test-helpers.d.ts +40 -0
- package/dist/utils/test-helpers.js +92 -0
- package/dist/utils/test-prompts.d.ts +23 -0
- package/dist/utils/test-prompts.js +186 -0
- package/dist/utils/tool-detection.d.ts +18 -0
- package/dist/utils/tool-detection.js +110 -0
- package/dist/web/app.css +941 -17
- package/dist/web/app.js +174 -22
- package/dist/web/index.html +7 -1
- package/package.json +13 -4
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +5 -5
- package/template/package.json +1 -1
- package/template/src/index.ts +147 -207
- package/template/src/tools/BasketTool.ts +128 -0
- package/template/src/tools/CustomDataTool.ts +7 -13
- package/template/src/tools/OrderTool.ts +54 -0
- package/template/src/tools/PaymentTool.ts +1 -1
- package/template/src/tools/ProductsTool.ts +56 -118
- package/template/src/tools/UserDataTool.ts +4 -26
- package/dist/common/config.d.ts +0 -5
- package/dist/common/config.js +0 -5
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -189
- package/dist/product-api.js +0 -141
- package/dist/services/api.d.ts +0 -549
- package/dist/services/api.js +0 -596
- package/dist/skill.d.ts +0 -50
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/user-data-api.d.ts +0 -39
- package/dist/user-data-api.js +0 -50
- package/template/API.md +0 -604
- package/template/DEVELOPER.md +0 -771
- package/template/lua.skill.yaml +0 -7
|
@@ -3,37 +3,83 @@ import { HttpClient } from "../common/http.client.js";
|
|
|
3
3
|
* Skill API calls
|
|
4
4
|
*/
|
|
5
5
|
export default class SkillApi extends HttpClient {
|
|
6
|
+
/**
|
|
7
|
+
* Creates an instance of SkillApi
|
|
8
|
+
* @param baseUrl - The base URL for the API
|
|
9
|
+
* @param apiKey - The API key for authentication
|
|
10
|
+
* @param agentId - The unique identifier of the agent
|
|
11
|
+
*/
|
|
6
12
|
constructor(baseUrl, apiKey, agentId) {
|
|
7
13
|
super(baseUrl);
|
|
8
14
|
this.apiKey = apiKey;
|
|
9
15
|
this.agentId = agentId;
|
|
10
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new skill for the agent
|
|
19
|
+
* @param skillData - The skill data including name, description, and optional context
|
|
20
|
+
* @returns Promise resolving to an ApiResponse containing the created skill details
|
|
21
|
+
* @throws Error if the skill creation fails or validation errors occur
|
|
22
|
+
*/
|
|
11
23
|
async createSkill(skillData) {
|
|
12
|
-
// console.log(`Skill data:`, skillData);
|
|
13
24
|
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {
|
|
14
25
|
Authorization: `Bearer ${this.apiKey}`,
|
|
15
26
|
});
|
|
16
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Pushes a new version of a skill to production
|
|
30
|
+
* @param skillId - The unique identifier of the skill
|
|
31
|
+
* @param versionData - The version data including code, configuration, and metadata
|
|
32
|
+
* @returns Promise resolving to an ApiResponse containing the created version details
|
|
33
|
+
* @throws Error if the skill is not found or the push operation fails
|
|
34
|
+
*/
|
|
17
35
|
async pushSkill(skillId, versionData) {
|
|
18
36
|
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {
|
|
19
37
|
Authorization: `Bearer ${this.apiKey}`,
|
|
20
38
|
});
|
|
21
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Pushes a new development/sandbox version of a skill for testing
|
|
42
|
+
* @param skillId - The unique identifier of the skill
|
|
43
|
+
* @param versionData - The version data including code, configuration, and metadata
|
|
44
|
+
* @returns Promise resolving to an ApiResponse containing the development version details
|
|
45
|
+
* @throws Error if the skill is not found or the push operation fails
|
|
46
|
+
*/
|
|
22
47
|
async pushDevSkill(skillId, versionData) {
|
|
23
48
|
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {
|
|
24
49
|
Authorization: `Bearer ${this.apiKey}`,
|
|
25
50
|
});
|
|
26
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Updates an existing development/sandbox version of a skill
|
|
54
|
+
* @param skillId - The unique identifier of the skill
|
|
55
|
+
* @param sandboxVersionId - The unique identifier of the sandbox version to update
|
|
56
|
+
* @param versionData - The updated version data including code, configuration, and metadata
|
|
57
|
+
* @returns Promise resolving to an ApiResponse containing the updated version details
|
|
58
|
+
* @throws Error if the skill or version is not found or the update fails
|
|
59
|
+
*/
|
|
27
60
|
async updateDevSkill(skillId, sandboxVersionId, versionData) {
|
|
28
61
|
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
29
62
|
Authorization: `Bearer ${this.apiKey}`,
|
|
30
63
|
});
|
|
31
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves all versions of a specific skill
|
|
67
|
+
* @param skillId - The unique identifier of the skill
|
|
68
|
+
* @returns Promise resolving to an ApiResponse containing an array of skill versions
|
|
69
|
+
* @throws Error if the skill is not found or the request fails
|
|
70
|
+
*/
|
|
32
71
|
async getSkillVersions(skillId) {
|
|
33
72
|
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {
|
|
34
73
|
Authorization: `Bearer ${this.apiKey}`,
|
|
35
74
|
});
|
|
36
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Publishes a specific version of a skill to production
|
|
78
|
+
* @param skillId - The unique identifier of the skill
|
|
79
|
+
* @param version - The version identifier to publish
|
|
80
|
+
* @returns Promise resolving to an ApiResponse containing publication confirmation details
|
|
81
|
+
* @throws Error if the skill or version is not found or the publish operation fails
|
|
82
|
+
*/
|
|
37
83
|
async publishSkillVersion(skillId, version) {
|
|
38
84
|
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, undefined, {
|
|
39
85
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -1,14 +1,52 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
|
-
import { ApiResponse } from "../interfaces/
|
|
2
|
+
import { ApiResponse } from "../interfaces/common.js";
|
|
3
3
|
/**
|
|
4
4
|
* Tool API calls (for compile command)
|
|
5
5
|
*/
|
|
6
6
|
export default class ToolApi extends HttpClient {
|
|
7
7
|
private apiKey;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of ToolApi
|
|
10
|
+
* @param baseUrl - The base URL for the API
|
|
11
|
+
* @param apiKey - The API key for authentication
|
|
12
|
+
*/
|
|
8
13
|
constructor(baseUrl: string, apiKey: string);
|
|
14
|
+
/**
|
|
15
|
+
* Performs a GET request to a tool endpoint
|
|
16
|
+
* @param url - The full or relative URL to request
|
|
17
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
18
|
+
* @throws Error if the request fails
|
|
19
|
+
*/
|
|
9
20
|
getTool(url: string): Promise<ApiResponse<any>>;
|
|
21
|
+
/**
|
|
22
|
+
* Performs a POST request to a tool endpoint
|
|
23
|
+
* @param url - The full or relative URL to request
|
|
24
|
+
* @param data - The data to send in the request body
|
|
25
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
26
|
+
* @throws Error if the request fails
|
|
27
|
+
*/
|
|
10
28
|
postTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
29
|
+
/**
|
|
30
|
+
* Performs a PUT request to a tool endpoint
|
|
31
|
+
* @param url - The full or relative URL to request
|
|
32
|
+
* @param data - The data to send in the request body
|
|
33
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
34
|
+
* @throws Error if the request fails
|
|
35
|
+
*/
|
|
11
36
|
putTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
37
|
+
/**
|
|
38
|
+
* Performs a DELETE request to a tool endpoint
|
|
39
|
+
* @param url - The full or relative URL to request
|
|
40
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
41
|
+
* @throws Error if the request fails
|
|
42
|
+
*/
|
|
12
43
|
deleteTool(url: string): Promise<ApiResponse<any>>;
|
|
44
|
+
/**
|
|
45
|
+
* Performs a PATCH request to a tool endpoint
|
|
46
|
+
* @param url - The full or relative URL to request
|
|
47
|
+
* @param data - The data to send in the request body
|
|
48
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
49
|
+
* @throws Error if the request fails
|
|
50
|
+
*/
|
|
13
51
|
patchTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
14
52
|
}
|
|
@@ -3,30 +3,68 @@ import { HttpClient } from "../common/http.client.js";
|
|
|
3
3
|
* Tool API calls (for compile command)
|
|
4
4
|
*/
|
|
5
5
|
export default class ToolApi extends HttpClient {
|
|
6
|
+
/**
|
|
7
|
+
* Creates an instance of ToolApi
|
|
8
|
+
* @param baseUrl - The base URL for the API
|
|
9
|
+
* @param apiKey - The API key for authentication
|
|
10
|
+
*/
|
|
6
11
|
constructor(baseUrl, apiKey) {
|
|
7
12
|
super(baseUrl);
|
|
8
13
|
this.apiKey = apiKey;
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Performs a GET request to a tool endpoint
|
|
17
|
+
* @param url - The full or relative URL to request
|
|
18
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
19
|
+
* @throws Error if the request fails
|
|
20
|
+
*/
|
|
10
21
|
async getTool(url) {
|
|
11
22
|
return this.httpGet(url, {
|
|
12
23
|
Authorization: `Bearer ${this.apiKey}`,
|
|
13
24
|
});
|
|
14
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Performs a POST request to a tool endpoint
|
|
28
|
+
* @param url - The full or relative URL to request
|
|
29
|
+
* @param data - The data to send in the request body
|
|
30
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
31
|
+
* @throws Error if the request fails
|
|
32
|
+
*/
|
|
15
33
|
async postTool(url, data) {
|
|
16
34
|
return this.httpPost(url, data, {
|
|
17
35
|
Authorization: `Bearer ${this.apiKey}`,
|
|
18
36
|
});
|
|
19
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Performs a PUT request to a tool endpoint
|
|
40
|
+
* @param url - The full or relative URL to request
|
|
41
|
+
* @param data - The data to send in the request body
|
|
42
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
43
|
+
* @throws Error if the request fails
|
|
44
|
+
*/
|
|
20
45
|
async putTool(url, data) {
|
|
21
46
|
return this.httpPut(url, data, {
|
|
22
47
|
Authorization: `Bearer ${this.apiKey}`,
|
|
23
48
|
});
|
|
24
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Performs a DELETE request to a tool endpoint
|
|
52
|
+
* @param url - The full or relative URL to request
|
|
53
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
54
|
+
* @throws Error if the request fails
|
|
55
|
+
*/
|
|
25
56
|
async deleteTool(url) {
|
|
26
57
|
return this.httpDelete(url, {
|
|
27
58
|
Authorization: `Bearer ${this.apiKey}`,
|
|
28
59
|
});
|
|
29
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Performs a PATCH request to a tool endpoint
|
|
63
|
+
* @param url - The full or relative URL to request
|
|
64
|
+
* @param data - The data to send in the request body
|
|
65
|
+
* @returns Promise resolving to an ApiResponse with the tool's response data
|
|
66
|
+
* @throws Error if the request fails
|
|
67
|
+
*/
|
|
30
68
|
async patchTool(url, data) {
|
|
31
69
|
return this.httpPatch(url, data, {
|
|
32
70
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import { HttpClient } from "../common/http.client.js";
|
|
2
2
|
import UserDataInstance from "../common/user.instance.js";
|
|
3
|
-
import { UserDataAPI } from "../types";
|
|
3
|
+
import { UserDataAPI } from "../types/index.js";
|
|
4
4
|
export default class UserDataApi extends HttpClient implements UserDataAPI {
|
|
5
5
|
private apiKey;
|
|
6
6
|
private agentId;
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of UserDataApi
|
|
9
|
+
* @param baseUrl - The base URL for the API
|
|
10
|
+
* @param apiKey - The API key for authentication
|
|
11
|
+
* @param agentId - The unique identifier of the agent
|
|
12
|
+
*/
|
|
7
13
|
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves the current user's data for the specific agent
|
|
16
|
+
* @returns Promise resolving to a UserDataInstance containing the user's data
|
|
17
|
+
* @throws Error if the user data cannot be retrieved or the request fails
|
|
18
|
+
*/
|
|
8
19
|
get(): Promise<UserDataInstance>;
|
|
20
|
+
/**
|
|
21
|
+
* Updates the current user's data for the specific agent
|
|
22
|
+
* @param data - The data object containing fields to update or add to user data
|
|
23
|
+
* @returns Promise resolving to the updated user data
|
|
24
|
+
* @throws Error if the update fails or the request is unsuccessful
|
|
25
|
+
*/
|
|
9
26
|
update(data: Record<string, any>): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Clears all user data for the current user and specific agent
|
|
29
|
+
* @returns Promise resolving to an empty object upon successful deletion
|
|
30
|
+
* @throws Error if the clear operation fails or the request is unsuccessful
|
|
31
|
+
*/
|
|
10
32
|
clear(): Promise<any>;
|
|
11
33
|
}
|
|
@@ -2,11 +2,22 @@ import { HttpClient } from "../common/http.client.js";
|
|
|
2
2
|
import UserDataInstance from "../common/user.instance.js";
|
|
3
3
|
// User Data API calls
|
|
4
4
|
export default class UserDataApi extends HttpClient {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of UserDataApi
|
|
7
|
+
* @param baseUrl - The base URL for the API
|
|
8
|
+
* @param apiKey - The API key for authentication
|
|
9
|
+
* @param agentId - The unique identifier of the agent
|
|
10
|
+
*/
|
|
5
11
|
constructor(baseUrl, apiKey, agentId) {
|
|
6
12
|
super(baseUrl);
|
|
7
13
|
this.apiKey = apiKey;
|
|
8
14
|
this.agentId = agentId;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the current user's data for the specific agent
|
|
18
|
+
* @returns Promise resolving to a UserDataInstance containing the user's data
|
|
19
|
+
* @throws Error if the user data cannot be retrieved or the request fails
|
|
20
|
+
*/
|
|
10
21
|
async get() {
|
|
11
22
|
const response = await this.httpGet(`/developer/user/data/agent/${this.agentId}`, {
|
|
12
23
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -16,6 +27,12 @@ export default class UserDataApi extends HttpClient {
|
|
|
16
27
|
}
|
|
17
28
|
return new UserDataInstance(this, response.data);
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Updates the current user's data for the specific agent
|
|
32
|
+
* @param data - The data object containing fields to update or add to user data
|
|
33
|
+
* @returns Promise resolving to the updated user data
|
|
34
|
+
* @throws Error if the update fails or the request is unsuccessful
|
|
35
|
+
*/
|
|
19
36
|
async update(data) {
|
|
20
37
|
const response = await this.httpPut(`/developer/user/data/agent/${this.agentId}`, data, {
|
|
21
38
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -25,6 +42,11 @@ export default class UserDataApi extends HttpClient {
|
|
|
25
42
|
}
|
|
26
43
|
return response.data;
|
|
27
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Clears all user data for the current user and specific agent
|
|
47
|
+
* @returns Promise resolving to an empty object upon successful deletion
|
|
48
|
+
* @throws Error if the clear operation fails or the request is unsuccessful
|
|
49
|
+
*/
|
|
28
50
|
async clear() {
|
|
29
51
|
const response = await this.httpDelete(`/developer/user/data/agent/${this.agentId}`, {
|
|
30
52
|
Authorization: `Bearer ${this.apiKey}`,
|
package/dist/api-exports.d.ts
CHANGED
|
@@ -1,40 +1,271 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lua Skill API Exports
|
|
3
|
+
*
|
|
4
|
+
* Public API surface for LuaSkill tools.
|
|
5
|
+
* This module provides simplified interfaces to Lua platform APIs
|
|
6
|
+
* for use within skill implementations.
|
|
7
|
+
*
|
|
8
|
+
* Available APIs:
|
|
9
|
+
* - User: User data management
|
|
10
|
+
* - Data: Custom data collections (vector search, CRUD)
|
|
11
|
+
* - Products: Product catalog management
|
|
12
|
+
* - Baskets: Shopping basket operations
|
|
13
|
+
* - Orders: Order management
|
|
14
|
+
*
|
|
15
|
+
* Usage in skills:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { User, Data, Products, Baskets, Orders } from 'lua-cli';
|
|
18
|
+
*
|
|
19
|
+
* // Get user data
|
|
20
|
+
* const user = await User.get();
|
|
21
|
+
*
|
|
22
|
+
* // Create custom data entry
|
|
23
|
+
* await Data.create('customers', { name: 'John' });
|
|
24
|
+
*
|
|
25
|
+
* // Search products
|
|
26
|
+
* const products = await Products.search('laptop');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { LuaSkill, LuaTool, env } from "./types/skill.js";
|
|
2
30
|
import { BasketStatus } from "./interfaces/baskets.js";
|
|
3
31
|
import { OrderStatus } from "./interfaces/orders.js";
|
|
32
|
+
/**
|
|
33
|
+
* User Data API
|
|
34
|
+
* Access user information and preferences
|
|
35
|
+
*/
|
|
4
36
|
export declare const User: {
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves current user data.
|
|
39
|
+
*
|
|
40
|
+
* @returns Promise resolving to user data
|
|
41
|
+
*/
|
|
5
42
|
get(): Promise<import("./common/user.instance.js").default>;
|
|
6
|
-
update(data: Record<string, any>): Promise<any>;
|
|
7
|
-
clear(): Promise<any>;
|
|
8
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Custom Data API
|
|
46
|
+
* Store and retrieve custom data with vector search capabilities
|
|
47
|
+
*/
|
|
9
48
|
export declare const Data: {
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new entry in a custom data collection.
|
|
51
|
+
*
|
|
52
|
+
* @param collectionName - Name of the collection
|
|
53
|
+
* @param data - Data to store
|
|
54
|
+
* @param searchText - Optional text for vector search indexing
|
|
55
|
+
* @returns Promise resolving to created entry
|
|
56
|
+
*/
|
|
10
57
|
create(collectionName: string, data: any, searchText?: string): Promise<import("./common/data.entry.instance.js").default>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves entries from a collection with optional filtering and pagination.
|
|
60
|
+
*
|
|
61
|
+
* @param collectionName - Name of the collection
|
|
62
|
+
* @param filter - Optional filter criteria
|
|
63
|
+
* @param page - Page number (default: 1)
|
|
64
|
+
* @param limit - Items per page (default: 10)
|
|
65
|
+
* @returns Promise resolving to array of entries
|
|
66
|
+
*/
|
|
11
67
|
get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<import("./interfaces/custom.data.js").GetCustomDataResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves a specific entry by ID.
|
|
70
|
+
*
|
|
71
|
+
* @param collectionName - Name of the collection
|
|
72
|
+
* @param entryId - ID of the entry
|
|
73
|
+
* @returns Promise resolving to entry data
|
|
74
|
+
*/
|
|
12
75
|
getEntry(collectionName: string, entryId: string): Promise<import("./common/data.entry.instance.js").default>;
|
|
76
|
+
/**
|
|
77
|
+
* Updates an existing entry.
|
|
78
|
+
*
|
|
79
|
+
* @param collectionName - Name of the collection
|
|
80
|
+
* @param entryId - ID of the entry to update
|
|
81
|
+
* @param data - Updated data
|
|
82
|
+
* @returns Promise resolving to updated entry
|
|
83
|
+
*/
|
|
13
84
|
update(collectionName: string, entryId: string, data: any): Promise<import("./interfaces/custom.data.js").UpdateCustomDataResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* Performs vector search on a collection.
|
|
87
|
+
*
|
|
88
|
+
* @param collectionName - Name of the collection
|
|
89
|
+
* @param searchText - Text to search for
|
|
90
|
+
* @param limit - Maximum results to return
|
|
91
|
+
* @param scoreThreshold - Minimum similarity score (0-1)
|
|
92
|
+
* @returns Promise resolving to search results
|
|
93
|
+
*/
|
|
14
94
|
search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<import("./common/data.entry.instance.js").default[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Deletes an entry from a collection.
|
|
97
|
+
*
|
|
98
|
+
* @param collectionName - Name of the collection
|
|
99
|
+
* @param entryId - ID of the entry to delete
|
|
100
|
+
* @returns Promise resolving when deletion is complete
|
|
101
|
+
*/
|
|
15
102
|
delete(collectionName: string, entryId: string): Promise<import("./interfaces/custom.data.js").DeleteCustomDataResponse>;
|
|
16
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Products API
|
|
106
|
+
* Manage product catalog
|
|
107
|
+
*/
|
|
17
108
|
export declare const Products: {
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves products with pagination.
|
|
111
|
+
*
|
|
112
|
+
* @param limit - Items per page
|
|
113
|
+
* @param page - Page number
|
|
114
|
+
* @returns Promise resolving to product list
|
|
115
|
+
*/
|
|
18
116
|
get(limit?: number, page?: number): Promise<import("./common/product.pagination.instance.js").default>;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new product.
|
|
119
|
+
*
|
|
120
|
+
* @param product - Product data
|
|
121
|
+
* @returns Promise resolving to created product
|
|
122
|
+
*/
|
|
19
123
|
create(product: any): Promise<import("./common/product.instance.js").default>;
|
|
124
|
+
/**
|
|
125
|
+
* Updates an existing product.
|
|
126
|
+
*
|
|
127
|
+
* @param data - Updated product data
|
|
128
|
+
* @param id - Product ID
|
|
129
|
+
* @returns Promise resolving to updated product
|
|
130
|
+
*/
|
|
20
131
|
update(data: any, id: string): Promise<import("./interfaces/product.js").UpdateProductResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* Deletes a product.
|
|
134
|
+
*
|
|
135
|
+
* @param id - Product ID
|
|
136
|
+
* @returns Promise resolving when deletion is complete
|
|
137
|
+
*/
|
|
21
138
|
delete(id: string): Promise<import("./interfaces/product.js").DeleteProductResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* Searches products by query string.
|
|
141
|
+
*
|
|
142
|
+
* @param query - Search query
|
|
143
|
+
* @returns Promise resolving to search results
|
|
144
|
+
*/
|
|
22
145
|
search(query: string): Promise<import("./common/product.search.instance.js").default>;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves a specific product by ID.
|
|
148
|
+
*
|
|
149
|
+
* @param id - Product ID
|
|
150
|
+
* @returns Promise resolving to product data
|
|
151
|
+
*/
|
|
152
|
+
getById(id: string): Promise<import("./common/product.instance.js").default>;
|
|
23
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Baskets API
|
|
156
|
+
* Manage shopping baskets
|
|
157
|
+
*/
|
|
24
158
|
export declare const Baskets: {
|
|
159
|
+
/**
|
|
160
|
+
* Creates a new basket.
|
|
161
|
+
*
|
|
162
|
+
* @param basketData - Basket initialization data
|
|
163
|
+
* @returns Promise resolving to created basket
|
|
164
|
+
*/
|
|
25
165
|
create(basketData: any): Promise<import("./common/basket.instance.js").default>;
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves baskets, optionally filtered by status.
|
|
168
|
+
*
|
|
169
|
+
* @param status - Optional basket status filter
|
|
170
|
+
* @returns Promise resolving to basket list
|
|
171
|
+
*/
|
|
26
172
|
get(status?: any): Promise<import("./common/basket.instance.js").default[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Adds an item to a basket.
|
|
175
|
+
*
|
|
176
|
+
* @param basketId - Basket ID
|
|
177
|
+
* @param itemData - Item data to add
|
|
178
|
+
* @returns Promise resolving to updated basket
|
|
179
|
+
*/
|
|
27
180
|
addItem(basketId: string, itemData: any): Promise<import("./interfaces/baskets.js").Basket>;
|
|
181
|
+
/**
|
|
182
|
+
* Removes an item from a basket.
|
|
183
|
+
*
|
|
184
|
+
* @param basketId - Basket ID
|
|
185
|
+
* @param itemId - Item ID to remove
|
|
186
|
+
* @returns Promise resolving to updated basket
|
|
187
|
+
*/
|
|
28
188
|
removeItem(basketId: string, itemId: string): Promise<import("./interfaces/baskets.js").Basket>;
|
|
189
|
+
/**
|
|
190
|
+
* Clears all items from a basket.
|
|
191
|
+
*
|
|
192
|
+
* @param basketId - Basket ID
|
|
193
|
+
* @returns Promise resolving to cleared basket
|
|
194
|
+
*/
|
|
29
195
|
clear(basketId: string): Promise<import("./interfaces/baskets.js").Basket>;
|
|
196
|
+
/**
|
|
197
|
+
* Updates basket status.
|
|
198
|
+
*
|
|
199
|
+
* @param basketId - Basket ID
|
|
200
|
+
* @param status - New basket status
|
|
201
|
+
* @returns Promise resolving to updated basket
|
|
202
|
+
*/
|
|
30
203
|
updateStatus(basketId: string, status: any): Promise<BasketStatus>;
|
|
31
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Updates basket metadata.
|
|
206
|
+
*
|
|
207
|
+
* @param basketId - Basket ID
|
|
208
|
+
* @param metadata - Metadata to update
|
|
209
|
+
* @returns Promise resolving to updated basket
|
|
210
|
+
*/
|
|
211
|
+
updateMetadata(basketId: string, metadata: any): Promise<import("./interfaces/baskets.js").UpdateBasketMetadataResponse>;
|
|
212
|
+
/**
|
|
213
|
+
* Converts basket to order.
|
|
214
|
+
*
|
|
215
|
+
* @param data - Order data
|
|
216
|
+
* @param basketId - Basket ID to convert
|
|
217
|
+
* @returns Promise resolving to created order
|
|
218
|
+
*/
|
|
32
219
|
placeOrder(data: Record<string, any>, basketId: string): Promise<import("./common/order.instance.js").default>;
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves a specific basket by ID.
|
|
222
|
+
*
|
|
223
|
+
* @param basketId - Basket ID
|
|
224
|
+
* @returns Promise resolving to basket data
|
|
225
|
+
*/
|
|
226
|
+
getById(basketId: string): Promise<import("./common/basket.instance.js").default>;
|
|
33
227
|
};
|
|
228
|
+
/**
|
|
229
|
+
* Orders API
|
|
230
|
+
* Manage orders
|
|
231
|
+
*/
|
|
34
232
|
export declare const Orders: {
|
|
233
|
+
/**
|
|
234
|
+
* Creates a new order.
|
|
235
|
+
*
|
|
236
|
+
* @param orderData - Order data
|
|
237
|
+
* @returns Promise resolving to created order
|
|
238
|
+
*/
|
|
35
239
|
create(orderData: any): Promise<import("./common/order.instance.js").default>;
|
|
240
|
+
/**
|
|
241
|
+
* Updates order status.
|
|
242
|
+
*
|
|
243
|
+
* @param status - New order status
|
|
244
|
+
* @param orderId - Order ID
|
|
245
|
+
* @returns Promise resolving to updated order
|
|
246
|
+
*/
|
|
36
247
|
updateStatus(status: any, orderId: string): Promise<import("./interfaces/orders.js").OrderResponse>;
|
|
248
|
+
/**
|
|
249
|
+
* Updates order data.
|
|
250
|
+
*
|
|
251
|
+
* @param data - Data to update
|
|
252
|
+
* @param orderId - Order ID
|
|
253
|
+
* @returns Promise resolving to updated order
|
|
254
|
+
*/
|
|
37
255
|
updateData(data: Record<string, any>, orderId: string): Promise<import("./interfaces/orders.js").OrderResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves orders, optionally filtered by status.
|
|
258
|
+
*
|
|
259
|
+
* @param status - Optional order status filter
|
|
260
|
+
* @returns Promise resolving to order list
|
|
261
|
+
*/
|
|
38
262
|
get(status?: any): Promise<import("./common/order.instance.js").default[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Retrieves a specific order by ID.
|
|
265
|
+
*
|
|
266
|
+
* @param orderId - Order ID
|
|
267
|
+
* @returns Promise resolving to order data
|
|
268
|
+
*/
|
|
269
|
+
getById(orderId: string): Promise<import("./common/order.instance.js").default>;
|
|
39
270
|
};
|
|
40
|
-
export { LuaSkill, LuaTool, BasketStatus, OrderStatus };
|
|
271
|
+
export { LuaSkill, LuaTool, BasketStatus, OrderStatus, env };
|