lua-cli 2.2.8-alpha.1 → 2.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +45 -0
- package/dist/api/agent.api.service.js +57 -0
- package/dist/api/auth.api.service.d.ts +48 -0
- package/dist/api/auth.api.service.js +54 -0
- package/dist/api/basket.api.service.d.ts +85 -0
- package/dist/api/basket.api.service.js +164 -0
- package/dist/api/chat.api.service.d.ts +21 -0
- package/dist/api/chat.api.service.js +24 -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 +69 -0
- package/dist/api/custom.data.api.service.js +125 -0
- 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 +53 -0
- package/dist/api/order.api.service.js +95 -0
- package/dist/api/products.api.service.d.ts +66 -0
- package/dist/api/products.api.service.js +112 -0
- package/dist/api/skills.api.service.d.ts +77 -0
- package/dist/api/skills.api.service.js +88 -0
- package/dist/api/tool.api.service.d.ts +52 -0
- package/dist/api/tool.api.service.js +73 -0
- package/dist/api/user.data.api.service.d.ts +33 -0
- package/dist/api/user.data.api.service.js +59 -0
- package/dist/api-exports.d.ts +271 -0
- package/dist/api-exports.js +372 -0
- 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 -873
- 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 +78 -0
- package/dist/common/basket.instance.js +132 -0
- package/dist/common/data.entry.instance.d.ts +39 -0
- package/dist/common/data.entry.instance.js +76 -0
- package/dist/common/http.client.d.ts +64 -0
- package/dist/common/http.client.js +133 -0
- package/dist/common/order.instance.d.ts +40 -0
- package/dist/common/order.instance.js +79 -0
- package/dist/common/product.instance.d.ts +33 -0
- package/dist/common/product.instance.js +63 -0
- package/dist/common/product.pagination.instance.d.ts +43 -0
- package/dist/common/product.pagination.instance.js +74 -0
- package/dist/common/product.search.instance.d.ts +22 -0
- package/dist/common/product.search.instance.js +40 -0
- package/dist/common/user.instance.d.ts +41 -0
- package/dist/common/user.instance.js +84 -0
- 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 +101 -0
- package/dist/interfaces/admin.js +5 -0
- package/dist/interfaces/agent.d.ts +107 -0
- package/dist/interfaces/agent.js +5 -0
- package/dist/interfaces/baskets.d.ts +135 -0
- package/dist/interfaces/baskets.js +19 -0
- package/dist/interfaces/chat.d.ts +61 -0
- package/dist/interfaces/chat.js +5 -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 +82 -0
- package/dist/interfaces/custom.data.js +5 -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 +91 -0
- package/dist/interfaces/orders.js +19 -0
- package/dist/interfaces/product.d.ts +65 -0
- package/dist/interfaces/product.js +5 -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 -85
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -19
- 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 -118
- 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 +14 -9
- package/package.json +11 -12
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +81 -40
- 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 -27
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -197
- package/dist/product-api.js +0 -152
- package/dist/services/api.d.ts +0 -569
- package/dist/services/api.js +0 -625
- 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 -16
package/dist/services/api.js
DELETED
|
@@ -1,625 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized API service for all Lua CLI API calls
|
|
3
|
-
* This service handles all HTTP requests to various Lua endpoints
|
|
4
|
-
*/
|
|
5
|
-
// Base URLs for different environments
|
|
6
|
-
const BASE_URLS = {
|
|
7
|
-
LOCAL: 'https://api.heylua.ai',
|
|
8
|
-
API: 'https://api.heylua.ai',
|
|
9
|
-
AUTH: 'https://auth.heylua.ai',
|
|
10
|
-
CHAT: 'https://api.heylua.ai'
|
|
11
|
-
};
|
|
12
|
-
export var BasketStatus;
|
|
13
|
-
(function (BasketStatus) {
|
|
14
|
-
BasketStatus["ACTIVE"] = "active";
|
|
15
|
-
BasketStatus["CHECKED_OUT"] = "checked_out";
|
|
16
|
-
BasketStatus["ABANDONED"] = "abandoned";
|
|
17
|
-
BasketStatus["EXPIRED"] = "expired";
|
|
18
|
-
})(BasketStatus || (BasketStatus = {}));
|
|
19
|
-
export var OrderStatus;
|
|
20
|
-
(function (OrderStatus) {
|
|
21
|
-
OrderStatus["PENDING"] = "pending";
|
|
22
|
-
OrderStatus["CONFIRMED"] = "confirmed";
|
|
23
|
-
OrderStatus["FULFILLED"] = "fulfilled";
|
|
24
|
-
OrderStatus["CANCELLED"] = "cancelled";
|
|
25
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
26
|
-
/**
|
|
27
|
-
* Generic HTTP client with common error handling
|
|
28
|
-
*/
|
|
29
|
-
class HttpClient {
|
|
30
|
-
async request(url, options = {}) {
|
|
31
|
-
try {
|
|
32
|
-
const response = await fetch(url, {
|
|
33
|
-
...options,
|
|
34
|
-
headers: {
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
...options.headers,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
const data = await response.json();
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
return {
|
|
42
|
-
success: false,
|
|
43
|
-
error: {
|
|
44
|
-
message: data.message || data.error || `HTTP ${response.status}`,
|
|
45
|
-
statusCode: response.status,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
success: true,
|
|
51
|
-
data,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return {
|
|
56
|
-
success: false,
|
|
57
|
-
error: {
|
|
58
|
-
message: error instanceof Error ? error.message : 'Network error',
|
|
59
|
-
statusCode: 500,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async get(url, headers) {
|
|
65
|
-
return this.request(url, { method: 'GET', headers });
|
|
66
|
-
}
|
|
67
|
-
async post(url, data, headers) {
|
|
68
|
-
return this.request(url, {
|
|
69
|
-
method: 'POST',
|
|
70
|
-
body: data ? JSON.stringify(data) : undefined,
|
|
71
|
-
headers,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
async put(url, data, headers) {
|
|
75
|
-
return this.request(url, {
|
|
76
|
-
method: 'PUT',
|
|
77
|
-
body: data ? JSON.stringify(data) : undefined,
|
|
78
|
-
headers,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async delete(url, headers) {
|
|
82
|
-
return this.request(url, { method: 'DELETE', headers });
|
|
83
|
-
}
|
|
84
|
-
async patch(url, data, headers) {
|
|
85
|
-
return this.request(url, {
|
|
86
|
-
method: 'PATCH',
|
|
87
|
-
body: data ? JSON.stringify(data) : undefined,
|
|
88
|
-
headers,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const httpClient = new HttpClient();
|
|
93
|
-
/**
|
|
94
|
-
* Authentication API calls
|
|
95
|
-
*/
|
|
96
|
-
export class AuthApi {
|
|
97
|
-
static async checkApiKey(apiKey) {
|
|
98
|
-
return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
|
|
99
|
-
Authorization: `Bearer ${apiKey}`,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
static async sendOtp(email) {
|
|
103
|
-
return httpClient.post(`${BASE_URLS.AUTH}/otp`, { email, type: 'email' });
|
|
104
|
-
}
|
|
105
|
-
static async verifyOtp(email, otp) {
|
|
106
|
-
return httpClient.post(`${BASE_URLS.AUTH}/otp/verify`, { email, pin: otp, type: 'email' });
|
|
107
|
-
}
|
|
108
|
-
static async getApiKey(signInToken) {
|
|
109
|
-
return httpClient.post(`${BASE_URLS.AUTH}/profile/apiKey`, undefined, {
|
|
110
|
-
Authorization: `Bearer ${signInToken}`,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Agent API calls
|
|
116
|
-
*/
|
|
117
|
-
export class AgentApi {
|
|
118
|
-
static async getOrganizations(apiKey) {
|
|
119
|
-
return httpClient.get(`${BASE_URLS.LOCAL}/admin`, {
|
|
120
|
-
Authorization: `Bearer ${apiKey}`,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
static async getAgentTypes(apiKey) {
|
|
124
|
-
return httpClient.get(`${BASE_URLS.API}/agents/self-serve/types`, {
|
|
125
|
-
Authorization: `Bearer ${apiKey}`,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
static async createAgent(apiKey, agentData) {
|
|
129
|
-
return httpClient.post(`${BASE_URLS.API}/agents/self-serve/create`, agentData, {
|
|
130
|
-
Authorization: `Bearer ${apiKey}`,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
static async getAgent(apiKey, agentId) {
|
|
134
|
-
return httpClient.get(`${BASE_URLS.API}/admin/agents/${agentId}`, {
|
|
135
|
-
Authorization: `Bearer ${apiKey}`,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Skill API calls
|
|
141
|
-
*/
|
|
142
|
-
export class SkillApi {
|
|
143
|
-
static async createSkill(apiKey, agentId, skillData) {
|
|
144
|
-
// console.log(`Skill data:`, skillData);
|
|
145
|
-
return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}`, skillData, {
|
|
146
|
-
Authorization: `Bearer ${apiKey}`,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
static async pushSkill(apiKey, agentId, skillId, versionData) {
|
|
150
|
-
return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version`, versionData, {
|
|
151
|
-
Authorization: `Bearer ${apiKey}`,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
static async pushDevSkill(apiKey, agentId, skillId, versionData) {
|
|
155
|
-
return httpClient.post(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox`, versionData, {
|
|
156
|
-
Authorization: `Bearer ${apiKey}`,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
static async updateDevSkill(apiKey, agentId, skillId, sandboxVersionId, versionData) {
|
|
160
|
-
return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
161
|
-
Authorization: `Bearer ${apiKey}`,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
static async getSkillVersions(apiKey, agentId, skillId) {
|
|
165
|
-
return httpClient.get(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/versions`, {
|
|
166
|
-
Authorization: `Bearer ${apiKey}`,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
static async publishSkillVersion(apiKey, agentId, skillId, version) {
|
|
170
|
-
return httpClient.put(`${BASE_URLS.LOCAL}/developer/skills/${agentId}/${skillId}/${version}/publish`, undefined, {
|
|
171
|
-
Authorization: `Bearer ${apiKey}`,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Chat API calls
|
|
177
|
-
*/
|
|
178
|
-
export class ChatApi {
|
|
179
|
-
static async sendMessage(agentId, chatData, apiKey) {
|
|
180
|
-
return httpClient.post(`${BASE_URLS.CHAT}/chat/generate/${agentId}?channel=dev`, chatData, {
|
|
181
|
-
Authorization: `Bearer ${apiKey}`,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Product API calls
|
|
187
|
-
*/
|
|
188
|
-
export class ProductApi {
|
|
189
|
-
/**
|
|
190
|
-
* Get all products for an agent with pagination
|
|
191
|
-
*/
|
|
192
|
-
static async getProducts(apiKey, agentId, page = 1, limit = 10) {
|
|
193
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products?page=${page}&limit=${limit}`, {
|
|
194
|
-
Authorization: `Bearer ${apiKey}`,
|
|
195
|
-
});
|
|
196
|
-
if (response.success) {
|
|
197
|
-
return response.data;
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
return {
|
|
201
|
-
success: false,
|
|
202
|
-
message: response.error?.message || 'Failed to get products'
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Create a new product
|
|
208
|
-
*/
|
|
209
|
-
static async createProduct(apiKey, agentId, productData) {
|
|
210
|
-
const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
|
|
211
|
-
Authorization: `Bearer ${apiKey}`,
|
|
212
|
-
});
|
|
213
|
-
if (response.success) {
|
|
214
|
-
return response.data;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
return {
|
|
218
|
-
success: false,
|
|
219
|
-
message: response.error?.message || 'Failed to create product'
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Update an existing product
|
|
225
|
-
*/
|
|
226
|
-
static async updateProduct(apiKey, agentId, productData) {
|
|
227
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products`, productData, {
|
|
228
|
-
Authorization: `Bearer ${apiKey}`,
|
|
229
|
-
});
|
|
230
|
-
if (response.success) {
|
|
231
|
-
return response.data;
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
return {
|
|
235
|
-
success: false,
|
|
236
|
-
message: response.error?.message || 'Failed to update product'
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Delete a product
|
|
242
|
-
*/
|
|
243
|
-
static async deleteProduct(apiKey, agentId, productId) {
|
|
244
|
-
const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/${productId}`, {
|
|
245
|
-
Authorization: `Bearer ${apiKey}`,
|
|
246
|
-
});
|
|
247
|
-
if (response.success) {
|
|
248
|
-
return response.data;
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
return {
|
|
252
|
-
success: false,
|
|
253
|
-
message: response.error?.message || 'Failed to delete product'
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Search products by text query
|
|
259
|
-
*/
|
|
260
|
-
static async searchProducts(apiKey, agentId, searchQuery) {
|
|
261
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
|
|
262
|
-
Authorization: `Bearer ${apiKey}`,
|
|
263
|
-
});
|
|
264
|
-
if (response.success) {
|
|
265
|
-
return response.data;
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
return {
|
|
269
|
-
success: false,
|
|
270
|
-
message: response.error?.message || 'Failed to search products'
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Create a new user basket
|
|
276
|
-
*/
|
|
277
|
-
static async createBasket(apiKey, agentId, basketData) {
|
|
278
|
-
const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket`, basketData, {
|
|
279
|
-
Authorization: `Bearer ${apiKey}`,
|
|
280
|
-
});
|
|
281
|
-
if (response.success) {
|
|
282
|
-
return response.data;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
return {
|
|
286
|
-
success: false,
|
|
287
|
-
message: response.error?.message || 'Failed to create basket'
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Get all user baskets with optional status filter
|
|
293
|
-
*/
|
|
294
|
-
static async getUserBaskets(apiKey, agentId, status) {
|
|
295
|
-
const statusParam = status ? `?status=${status}` : '';
|
|
296
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/user${statusParam}`, {
|
|
297
|
-
Authorization: `Bearer ${apiKey}`,
|
|
298
|
-
});
|
|
299
|
-
if (response.success) {
|
|
300
|
-
return response.data;
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
return {
|
|
304
|
-
success: false,
|
|
305
|
-
message: response.error?.message || 'Failed to get user baskets'
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Add item to basket
|
|
311
|
-
*/
|
|
312
|
-
static async addItemToBasket(apiKey, agentId, basketId, itemData) {
|
|
313
|
-
const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/item`, itemData, {
|
|
314
|
-
Authorization: `Bearer ${apiKey}`,
|
|
315
|
-
});
|
|
316
|
-
if (response.success) {
|
|
317
|
-
return response.data;
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
return {
|
|
321
|
-
success: false,
|
|
322
|
-
message: response.error?.message || 'Failed to add item to basket'
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Remove item from basket
|
|
328
|
-
*/
|
|
329
|
-
static async removeItemFromBasket(apiKey, agentId, basketId, itemId) {
|
|
330
|
-
const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/item/${itemId}`, {
|
|
331
|
-
Authorization: `Bearer ${apiKey}`,
|
|
332
|
-
});
|
|
333
|
-
if (response.success) {
|
|
334
|
-
return response.data;
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
return {
|
|
338
|
-
success: false,
|
|
339
|
-
message: response.error?.message || 'Failed to remove item from basket'
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Clear basket (remove all items)
|
|
345
|
-
*/
|
|
346
|
-
static async clearBasket(apiKey, agentId, basketId) {
|
|
347
|
-
const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/clear`, {
|
|
348
|
-
Authorization: `Bearer ${apiKey}`,
|
|
349
|
-
});
|
|
350
|
-
if (response.success) {
|
|
351
|
-
return response.data;
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
return {
|
|
355
|
-
success: false,
|
|
356
|
-
message: response.error?.message || 'Failed to clear basket'
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Update basket status
|
|
362
|
-
*/
|
|
363
|
-
static async updateBasketStatus(apiKey, agentId, basketId, status) {
|
|
364
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/${status}`, undefined, {
|
|
365
|
-
Authorization: `Bearer ${apiKey}`,
|
|
366
|
-
});
|
|
367
|
-
if (response.success) {
|
|
368
|
-
return response.data;
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
return {
|
|
372
|
-
success: false,
|
|
373
|
-
message: response.error?.message || 'Failed to update basket status'
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
//update basket metadata
|
|
378
|
-
static async updateBasketMetadata(apiKey, agentId, basketId, metadata) {
|
|
379
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/basket/${basketId}/metadata`, metadata, {
|
|
380
|
-
Authorization: `Bearer ${apiKey}`,
|
|
381
|
-
});
|
|
382
|
-
if (response.success) {
|
|
383
|
-
return response.data;
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
return {
|
|
387
|
-
success: false,
|
|
388
|
-
message: response.error?.message || 'Failed to update basket metadata'
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Create order from basket
|
|
394
|
-
*/
|
|
395
|
-
static async createOrder(apiKey, agentId, orderData) {
|
|
396
|
-
const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order`, orderData, {
|
|
397
|
-
Authorization: `Bearer ${apiKey}`,
|
|
398
|
-
});
|
|
399
|
-
if (response.success) {
|
|
400
|
-
return response.data;
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
return {
|
|
404
|
-
success: false,
|
|
405
|
-
message: response.error?.message || 'Failed to create order'
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Update order status
|
|
411
|
-
*/
|
|
412
|
-
static async updateOrderStatus(apiKey, agentId, orderId, status) {
|
|
413
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order/${orderId}/${status}`, undefined, {
|
|
414
|
-
Authorization: `Bearer ${apiKey}`,
|
|
415
|
-
});
|
|
416
|
-
if (response.success) {
|
|
417
|
-
return response.data;
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
return {
|
|
421
|
-
success: false,
|
|
422
|
-
message: response.error?.message || 'Failed to update order status'
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Get user orders with optional status filter
|
|
428
|
-
*/
|
|
429
|
-
static async getUserOrders(apiKey, agentId, status) {
|
|
430
|
-
const statusParam = status ? `?status=${status}` : '';
|
|
431
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/order/user${statusParam}`, {
|
|
432
|
-
Authorization: `Bearer ${apiKey}`,
|
|
433
|
-
});
|
|
434
|
-
if (response.success) {
|
|
435
|
-
return response.data;
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
return {
|
|
439
|
-
success: false,
|
|
440
|
-
message: response.error?.message || 'Failed to get user orders'
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Tool API calls (for compile command)
|
|
447
|
-
*/
|
|
448
|
-
export class ToolApi {
|
|
449
|
-
static async getTool(url, apiKey) {
|
|
450
|
-
return httpClient.get(url, {
|
|
451
|
-
Authorization: `Bearer ${apiKey}`,
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
static async postTool(url, data, apiKey) {
|
|
455
|
-
return httpClient.post(url, data, {
|
|
456
|
-
Authorization: `Bearer ${apiKey}`,
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
static async putTool(url, data, apiKey) {
|
|
460
|
-
return httpClient.put(url, data, {
|
|
461
|
-
Authorization: `Bearer ${apiKey}`,
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
static async deleteTool(url, apiKey) {
|
|
465
|
-
return httpClient.delete(url, {
|
|
466
|
-
Authorization: `Bearer ${apiKey}`,
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
static async patchTool(url, data, apiKey) {
|
|
470
|
-
return httpClient.patch(url, data, {
|
|
471
|
-
Authorization: `Bearer ${apiKey}`,
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
// User Data API calls
|
|
476
|
-
export class UserDataApi {
|
|
477
|
-
static async getUserData(apiKey, agentId) {
|
|
478
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, {
|
|
479
|
-
Authorization: `Bearer ${apiKey}`,
|
|
480
|
-
});
|
|
481
|
-
return response;
|
|
482
|
-
}
|
|
483
|
-
static async createUserData(apiKey, agentId, data) {
|
|
484
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, data, {
|
|
485
|
-
Authorization: `Bearer ${apiKey}`,
|
|
486
|
-
});
|
|
487
|
-
return response.data;
|
|
488
|
-
}
|
|
489
|
-
static async updateUserData(apiKey, agentId, data) {
|
|
490
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, data, {
|
|
491
|
-
Authorization: `Bearer ${apiKey}`,
|
|
492
|
-
});
|
|
493
|
-
return response.data;
|
|
494
|
-
}
|
|
495
|
-
static async deleteUserData(apiKey, agentId) {
|
|
496
|
-
const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/user/data/agent/${agentId}`, {
|
|
497
|
-
Authorization: `Bearer ${apiKey}`,
|
|
498
|
-
});
|
|
499
|
-
return response;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
// Custom Data API calls
|
|
503
|
-
export class CustomDataApi {
|
|
504
|
-
/**
|
|
505
|
-
* Create a new custom data entry
|
|
506
|
-
*/
|
|
507
|
-
static async createCustomData(apiKey, agentId, collectionName, data) {
|
|
508
|
-
const response = await httpClient.post(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}`, data, {
|
|
509
|
-
Authorization: `Bearer ${apiKey}`,
|
|
510
|
-
});
|
|
511
|
-
if (response.success) {
|
|
512
|
-
return response.data;
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
return {
|
|
516
|
-
success: false,
|
|
517
|
-
message: response.error?.message || 'Failed to create custom data entry'
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Get custom data entries with optional filtering and pagination
|
|
523
|
-
*/
|
|
524
|
-
static async getCustomData(apiKey, agentId, collectionName, filter, page = 1, limit = 10) {
|
|
525
|
-
let url = `${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}?page=${page}&limit=${limit}`;
|
|
526
|
-
if (filter) {
|
|
527
|
-
const encodedFilter = encodeURIComponent(JSON.stringify(filter));
|
|
528
|
-
url += `&filter=${encodedFilter}`;
|
|
529
|
-
}
|
|
530
|
-
const response = await httpClient.get(url, {
|
|
531
|
-
Authorization: `Bearer ${apiKey}`,
|
|
532
|
-
});
|
|
533
|
-
if (response.success) {
|
|
534
|
-
return response.data;
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
return {
|
|
538
|
-
success: false,
|
|
539
|
-
message: response.error?.message || 'Failed to get custom data entries'
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Get a single custom data entry by ID
|
|
545
|
-
*/
|
|
546
|
-
static async getCustomDataEntry(apiKey, agentId, collectionName, entryId) {
|
|
547
|
-
const response = await httpClient.get(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
548
|
-
Authorization: `Bearer ${apiKey}`,
|
|
549
|
-
});
|
|
550
|
-
if (response.success) {
|
|
551
|
-
return response.data;
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
return {
|
|
555
|
-
success: false,
|
|
556
|
-
message: response.error?.message || 'Failed to get custom data entry'
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* Update a custom data entry
|
|
562
|
-
*/
|
|
563
|
-
static async updateCustomData(apiKey, agentId, collectionName, entryId, data) {
|
|
564
|
-
const response = await httpClient.put(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, data, {
|
|
565
|
-
Authorization: `Bearer ${apiKey}`,
|
|
566
|
-
});
|
|
567
|
-
if (response.success) {
|
|
568
|
-
return response.data;
|
|
569
|
-
}
|
|
570
|
-
else {
|
|
571
|
-
return {
|
|
572
|
-
success: false,
|
|
573
|
-
message: response.error?.message || 'Failed to update custom data entry'
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Search custom data entries by text
|
|
579
|
-
*/
|
|
580
|
-
static async searchCustomData(apiKey, agentId, collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
|
|
581
|
-
const url = `${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
|
|
582
|
-
const response = await httpClient.get(url, {
|
|
583
|
-
Authorization: `Bearer ${apiKey}`,
|
|
584
|
-
});
|
|
585
|
-
if (response.success) {
|
|
586
|
-
return response.data;
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
return {
|
|
590
|
-
success: false,
|
|
591
|
-
message: response.error?.message || 'Failed to search custom data entries'
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Delete a custom data entry
|
|
597
|
-
*/
|
|
598
|
-
static async deleteCustomData(apiKey, agentId, collectionName, entryId) {
|
|
599
|
-
const response = await httpClient.delete(`${BASE_URLS.LOCAL}/developer/agents/${agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
600
|
-
Authorization: `Bearer ${apiKey}`,
|
|
601
|
-
});
|
|
602
|
-
if (response.success) {
|
|
603
|
-
return response.data;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
return {
|
|
607
|
-
success: false,
|
|
608
|
-
message: response.error?.message || 'Failed to delete custom data entry'
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Main API service that exports all API classes
|
|
615
|
-
*/
|
|
616
|
-
export const ApiService = {
|
|
617
|
-
Auth: AuthApi,
|
|
618
|
-
Agent: AgentApi,
|
|
619
|
-
Skill: SkillApi,
|
|
620
|
-
Chat: ChatApi,
|
|
621
|
-
Product: ProductApi,
|
|
622
|
-
Tool: ToolApi,
|
|
623
|
-
UserData: UserDataApi,
|
|
624
|
-
CustomData: CustomDataApi,
|
|
625
|
-
};
|
package/dist/skill.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ZodType } from "zod";
|
|
2
|
-
import { LuaTool } from "./types/index.js";
|
|
3
|
-
export { LuaTool };
|
|
4
|
-
/**
|
|
5
|
-
* Safe environment variable access function
|
|
6
|
-
* Gets injected at runtime with skill-specific environment variables
|
|
7
|
-
*
|
|
8
|
-
* @param key - The environment variable key to retrieve
|
|
9
|
-
* @returns The environment variable value or undefined if not found
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const baseUrl = env('BASE_URL');
|
|
14
|
-
* const apiKey = env('API_KEY');
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const env: (key: string) => string | undefined;
|
|
18
|
-
export interface LuaSkillConfig {
|
|
19
|
-
name?: string;
|
|
20
|
-
version?: string;
|
|
21
|
-
description: string;
|
|
22
|
-
context: string;
|
|
23
|
-
tools?: LuaTool<any>[];
|
|
24
|
-
}
|
|
25
|
-
export declare class LuaSkill {
|
|
26
|
-
private readonly tools;
|
|
27
|
-
private readonly name;
|
|
28
|
-
private readonly version;
|
|
29
|
-
private readonly description;
|
|
30
|
-
private readonly context;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new LuaSkill instance
|
|
33
|
-
*
|
|
34
|
-
* @param config - Configuration object containing skill metadata
|
|
35
|
-
* @param config.description - Short description of what the skill does (1-2 sentences)
|
|
36
|
-
* @param config.context - Detailed explanation of how the agent should use the tools
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const skill = new LuaSkill({
|
|
41
|
-
* description: "Weather and calculator utilities",
|
|
42
|
-
* context: "This skill provides weather information for any city and basic mathematical operations. Use get_weather for current conditions and calculator for arithmetic operations."
|
|
43
|
-
* });
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
constructor(config: LuaSkillConfig);
|
|
47
|
-
addTool<TInput extends ZodType>(tool: LuaTool<TInput>): void;
|
|
48
|
-
addTools(tools: LuaTool<any>[]): void;
|
|
49
|
-
run(input: Record<string, any>): Promise<any>;
|
|
50
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./types/index.js";
|
package/dist/types.js
DELETED