lua-cli 2.2.8-alpha.1 → 2.2.8-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/dist/api/agent.api.service.d.ts +18 -0
- package/dist/api/agent.api.service.js +30 -0
- package/dist/api/auth.api.service.d.ts +19 -0
- package/dist/api/auth.api.service.js +25 -0
- package/dist/api/basket.api.service.d.ts +43 -0
- package/dist/api/basket.api.service.js +115 -0
- package/dist/api/chat.api.service.d.ts +9 -0
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/custom.data.api.service.d.ts +33 -0
- package/dist/api/custom.data.api.service.js +91 -0
- package/dist/api/order.api.service.d.ts +23 -0
- package/dist/api/order.api.service.js +57 -0
- package/dist/api/products.api.service.d.ts +36 -0
- package/dist/api/products.api.service.js +74 -0
- package/dist/api/skills.api.service.d.ts +30 -0
- package/dist/api/skills.api.service.js +42 -0
- package/dist/api/tool.api.service.d.ts +14 -0
- package/dist/api/tool.api.service.js +35 -0
- package/dist/api/user.data.api.service.d.ts +11 -0
- package/dist/api/user.data.api.service.js +37 -0
- package/dist/api-exports.d.ts +40 -0
- package/dist/api-exports.js +189 -0
- package/dist/commands/dev.js +22 -17
- package/dist/common/basket.instance.d.ts +27 -0
- package/dist/common/basket.instance.js +79 -0
- package/dist/common/config.d.ts +5 -0
- package/dist/common/config.js +5 -0
- package/dist/common/data.entry.instance.d.ts +16 -0
- package/dist/common/data.entry.instance.js +52 -0
- package/dist/common/http.client.d.ts +14 -0
- package/dist/common/http.client.js +83 -0
- package/dist/common/order.instance.d.ts +18 -0
- package/dist/common/order.instance.js +52 -0
- package/dist/common/product.instance.d.ts +12 -0
- package/dist/common/product.instance.js +45 -0
- package/dist/common/product.pagination.instance.d.ts +23 -0
- package/dist/common/product.pagination.instance.js +53 -0
- package/dist/common/product.search.instance.d.ts +12 -0
- package/dist/common/product.search.instance.js +29 -0
- package/dist/common/user.instance.d.ts +17 -0
- package/dist/common/user.instance.js +63 -0
- package/dist/interfaces/admin.d.ts +95 -0
- package/dist/interfaces/admin.js +1 -0
- package/dist/interfaces/agent.d.ts +86 -0
- package/dist/interfaces/agent.js +1 -0
- package/dist/interfaces/baskets.d.ts +75 -0
- package/dist/interfaces/baskets.js +7 -0
- package/dist/interfaces/chat.d.ts +17 -0
- package/dist/interfaces/chat.js +1 -0
- package/dist/interfaces/custom.data.d.ts +52 -0
- package/dist/interfaces/custom.data.js +1 -0
- package/dist/interfaces/orders.d.ts +54 -0
- package/dist/interfaces/orders.js +7 -0
- package/dist/interfaces/product.d.ts +37 -0
- package/dist/interfaces/product.js +1 -0
- package/dist/product-api.d.ts +2 -10
- package/dist/product-api.js +3 -14
- package/dist/services/api.d.ts +3 -23
- package/dist/services/api.js +4 -33
- package/dist/services/auth.d.ts +1 -1
- package/dist/skill.js +2 -4
- package/dist/types/index.d.ts +36 -0
- package/dist/utils/sandbox.js +3 -7
- package/package.json +8 -12
- package/template/lua.skill.yaml +3 -12
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +200 -99
- package/template/src/tools/UserDataTool.ts +6 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
3
|
+
/**
|
|
4
|
+
* Tool API calls (for compile command)
|
|
5
|
+
*/
|
|
6
|
+
export default class ToolApi extends HttpClient {
|
|
7
|
+
private apiKey;
|
|
8
|
+
constructor(baseUrl: string, apiKey: string);
|
|
9
|
+
getTool(url: string): Promise<ApiResponse<any>>;
|
|
10
|
+
postTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
11
|
+
putTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
12
|
+
deleteTool(url: string): Promise<ApiResponse<any>>;
|
|
13
|
+
patchTool(url: string, data: any): Promise<ApiResponse<any>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tool API calls (for compile command)
|
|
4
|
+
*/
|
|
5
|
+
export default class ToolApi extends HttpClient {
|
|
6
|
+
constructor(baseUrl, apiKey) {
|
|
7
|
+
super(baseUrl);
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
}
|
|
10
|
+
async getTool(url) {
|
|
11
|
+
return this.httpGet(url, {
|
|
12
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async postTool(url, data) {
|
|
16
|
+
return this.httpPost(url, data, {
|
|
17
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async putTool(url, data) {
|
|
21
|
+
return this.httpPut(url, data, {
|
|
22
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async deleteTool(url) {
|
|
26
|
+
return this.httpDelete(url, {
|
|
27
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async patchTool(url, data) {
|
|
31
|
+
return this.httpPatch(url, data, {
|
|
32
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import UserDataInstance from "../common/user.instance.js";
|
|
3
|
+
import { UserDataAPI } from "../types";
|
|
4
|
+
export default class UserDataApi extends HttpClient implements UserDataAPI {
|
|
5
|
+
private apiKey;
|
|
6
|
+
private agentId;
|
|
7
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
8
|
+
get(): Promise<UserDataInstance>;
|
|
9
|
+
update(data: Record<string, any>): Promise<any>;
|
|
10
|
+
clear(): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import UserDataInstance from "../common/user.instance.js";
|
|
3
|
+
// User Data API calls
|
|
4
|
+
export default class UserDataApi extends HttpClient {
|
|
5
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
6
|
+
super(baseUrl);
|
|
7
|
+
this.apiKey = apiKey;
|
|
8
|
+
this.agentId = agentId;
|
|
9
|
+
}
|
|
10
|
+
async get() {
|
|
11
|
+
const response = await this.httpGet(`/developer/user/data/agent/${this.agentId}`, {
|
|
12
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
13
|
+
});
|
|
14
|
+
if (!response.success) {
|
|
15
|
+
throw new Error(response.error?.message || 'Failed to get user data');
|
|
16
|
+
}
|
|
17
|
+
return new UserDataInstance(this, response.data);
|
|
18
|
+
}
|
|
19
|
+
async update(data) {
|
|
20
|
+
const response = await this.httpPut(`/developer/user/data/agent/${this.agentId}`, data, {
|
|
21
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
22
|
+
});
|
|
23
|
+
if (!response.success) {
|
|
24
|
+
throw new Error(response.error?.message || 'Failed to update user data');
|
|
25
|
+
}
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
async clear() {
|
|
29
|
+
const response = await this.httpDelete(`/developer/user/data/agent/${this.agentId}`, {
|
|
30
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
31
|
+
});
|
|
32
|
+
if (!response.success) {
|
|
33
|
+
throw new Error(response.error?.message || 'Failed to clear user data');
|
|
34
|
+
}
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LuaSkill, LuaTool } from "./skill.js";
|
|
2
|
+
import { BasketStatus } from "./interfaces/baskets.js";
|
|
3
|
+
import { OrderStatus } from "./interfaces/orders.js";
|
|
4
|
+
export declare const User: {
|
|
5
|
+
get(): Promise<import("./common/user.instance.js").default>;
|
|
6
|
+
update(data: Record<string, any>): Promise<any>;
|
|
7
|
+
clear(): Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
export declare const Data: {
|
|
10
|
+
create(collectionName: string, data: any, searchText?: string): Promise<import("./common/data.entry.instance.js").default>;
|
|
11
|
+
get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<import("./interfaces/custom.data.js").GetCustomDataResponse>;
|
|
12
|
+
getEntry(collectionName: string, entryId: string): Promise<import("./common/data.entry.instance.js").default>;
|
|
13
|
+
update(collectionName: string, entryId: string, data: any): Promise<import("./interfaces/custom.data.js").UpdateCustomDataResponse>;
|
|
14
|
+
search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<import("./common/data.entry.instance.js").default[]>;
|
|
15
|
+
delete(collectionName: string, entryId: string): Promise<import("./interfaces/custom.data.js").DeleteCustomDataResponse>;
|
|
16
|
+
};
|
|
17
|
+
export declare const Products: {
|
|
18
|
+
get(limit?: number, page?: number): Promise<import("./common/product.pagination.instance.js").default>;
|
|
19
|
+
create(product: any): Promise<import("./common/product.instance.js").default>;
|
|
20
|
+
update(data: any, id: string): Promise<import("./interfaces/product.js").UpdateProductResponse>;
|
|
21
|
+
delete(id: string): Promise<import("./interfaces/product.js").DeleteProductResponse>;
|
|
22
|
+
search(query: string): Promise<import("./common/product.search.instance.js").default>;
|
|
23
|
+
};
|
|
24
|
+
export declare const Baskets: {
|
|
25
|
+
create(basketData: any): Promise<import("./common/basket.instance.js").default>;
|
|
26
|
+
get(status?: any): Promise<import("./common/basket.instance.js").default[]>;
|
|
27
|
+
addItem(basketId: string, itemData: any): Promise<import("./interfaces/baskets.js").Basket>;
|
|
28
|
+
removeItem(basketId: string, itemId: string): Promise<import("./interfaces/baskets.js").Basket>;
|
|
29
|
+
clear(basketId: string): Promise<import("./interfaces/baskets.js").Basket>;
|
|
30
|
+
updateStatus(basketId: string, status: any): Promise<BasketStatus>;
|
|
31
|
+
updateMetadata(basketId: string, metadata: any): Promise<import("./interfaces/custom.data.js").UpdateBasketMetadataResponse>;
|
|
32
|
+
placeOrder(data: Record<string, any>, basketId: string): Promise<import("./common/order.instance.js").default>;
|
|
33
|
+
};
|
|
34
|
+
export declare const Orders: {
|
|
35
|
+
create(orderData: any): Promise<import("./common/order.instance.js").default>;
|
|
36
|
+
updateStatus(status: any, orderId: string): Promise<import("./interfaces/orders.js").OrderResponse>;
|
|
37
|
+
updateData(data: Record<string, any>, orderId: string): Promise<import("./interfaces/orders.js").OrderResponse>;
|
|
38
|
+
get(status?: any): Promise<import("./common/order.instance.js").default[]>;
|
|
39
|
+
};
|
|
40
|
+
export { LuaSkill, LuaTool, BasketStatus, OrderStatus };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// API exports for use in LuaSkills - separate from CLI
|
|
2
|
+
import { LuaSkill } from "./skill.js";
|
|
3
|
+
import { BasketStatus } from "./interfaces/baskets.js";
|
|
4
|
+
import { OrderStatus } from "./interfaces/orders.js";
|
|
5
|
+
import { loadApiKey } from "./services/auth.js";
|
|
6
|
+
import { readSkillConfig } from "./utils/files.js";
|
|
7
|
+
import { BASE_URLS } from "./common/config.js";
|
|
8
|
+
// Import the actual API service classes for proper instantiation
|
|
9
|
+
import ProductApiService from "./api/products.api.service.js";
|
|
10
|
+
import BasketApiService from "./api/basket.api.service.js";
|
|
11
|
+
import OrderApiService from "./api/order.api.service.js";
|
|
12
|
+
import UserDataApiService from "./api/user.data.api.service.js";
|
|
13
|
+
import CustomDataApiService from "./api/custom.data.api.service.js";
|
|
14
|
+
async function getCredentials() {
|
|
15
|
+
// Load API key from keystore
|
|
16
|
+
const apiKey = await loadApiKey();
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
throw new Error('No API key found. Please run "lua auth configure" first.');
|
|
19
|
+
}
|
|
20
|
+
// Load agent ID from YAML file
|
|
21
|
+
const config = readSkillConfig();
|
|
22
|
+
if (!config?.agent?.agentId) {
|
|
23
|
+
throw new Error('No agent ID found in lua.skill.yaml. Please run "lua init" first.');
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
apiKey,
|
|
27
|
+
agentId: config.agent.agentId
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Lazy-loaded API instances to avoid top-level await
|
|
31
|
+
let _userInstance = null;
|
|
32
|
+
let _dataInstance = null;
|
|
33
|
+
let _productsInstance = null;
|
|
34
|
+
let _basketsInstance = null;
|
|
35
|
+
let _orderInstance = null;
|
|
36
|
+
async function getUserInstance() {
|
|
37
|
+
if (!_userInstance) {
|
|
38
|
+
const creds = await getCredentials();
|
|
39
|
+
_userInstance = new UserDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
40
|
+
}
|
|
41
|
+
return _userInstance;
|
|
42
|
+
}
|
|
43
|
+
async function getDataInstance() {
|
|
44
|
+
if (!_dataInstance) {
|
|
45
|
+
const creds = await getCredentials();
|
|
46
|
+
_dataInstance = new CustomDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
47
|
+
}
|
|
48
|
+
return _dataInstance;
|
|
49
|
+
}
|
|
50
|
+
async function getProductsInstance() {
|
|
51
|
+
if (!_productsInstance) {
|
|
52
|
+
const creds = await getCredentials();
|
|
53
|
+
_productsInstance = new ProductApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
54
|
+
}
|
|
55
|
+
return _productsInstance;
|
|
56
|
+
}
|
|
57
|
+
async function getBasketsInstance() {
|
|
58
|
+
if (!_basketsInstance) {
|
|
59
|
+
const creds = await getCredentials();
|
|
60
|
+
_basketsInstance = new BasketApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
61
|
+
}
|
|
62
|
+
return _basketsInstance;
|
|
63
|
+
}
|
|
64
|
+
async function getOrderInstance() {
|
|
65
|
+
if (!_orderInstance) {
|
|
66
|
+
const creds = await getCredentials();
|
|
67
|
+
_orderInstance = new OrderApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
68
|
+
}
|
|
69
|
+
return _orderInstance;
|
|
70
|
+
}
|
|
71
|
+
export const User = {
|
|
72
|
+
async get() {
|
|
73
|
+
const instance = await getUserInstance();
|
|
74
|
+
return instance.get();
|
|
75
|
+
},
|
|
76
|
+
async update(data) {
|
|
77
|
+
const instance = await getUserInstance();
|
|
78
|
+
return instance.update(data);
|
|
79
|
+
},
|
|
80
|
+
async clear() {
|
|
81
|
+
const instance = await getUserInstance();
|
|
82
|
+
return instance.clear();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export const Data = {
|
|
86
|
+
async create(collectionName, data, searchText) {
|
|
87
|
+
const instance = await getDataInstance();
|
|
88
|
+
console.log('collectionName', collectionName);
|
|
89
|
+
console.log('data', data);
|
|
90
|
+
console.log('searchText', searchText);
|
|
91
|
+
return instance.create(collectionName, data, searchText);
|
|
92
|
+
},
|
|
93
|
+
async get(collectionName, filter, page, limit) {
|
|
94
|
+
const instance = await getDataInstance();
|
|
95
|
+
return instance.get(collectionName, filter, page, limit);
|
|
96
|
+
},
|
|
97
|
+
async getEntry(collectionName, entryId) {
|
|
98
|
+
const instance = await getDataInstance();
|
|
99
|
+
return instance.getEntry(collectionName, entryId);
|
|
100
|
+
},
|
|
101
|
+
async update(collectionName, entryId, data) {
|
|
102
|
+
const instance = await getDataInstance();
|
|
103
|
+
return instance.update(collectionName, entryId, data);
|
|
104
|
+
},
|
|
105
|
+
async search(collectionName, searchText, limit, scoreThreshold) {
|
|
106
|
+
const instance = await getDataInstance();
|
|
107
|
+
return instance.search(collectionName, searchText, limit, scoreThreshold);
|
|
108
|
+
},
|
|
109
|
+
async delete(collectionName, entryId) {
|
|
110
|
+
const instance = await getDataInstance();
|
|
111
|
+
return instance.delete(collectionName, entryId);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
export const Products = {
|
|
115
|
+
async get(limit, page) {
|
|
116
|
+
const instance = await getProductsInstance();
|
|
117
|
+
return instance.get(limit, page);
|
|
118
|
+
},
|
|
119
|
+
async create(product) {
|
|
120
|
+
const instance = await getProductsInstance();
|
|
121
|
+
return instance.create(product);
|
|
122
|
+
},
|
|
123
|
+
async update(data, id) {
|
|
124
|
+
const instance = await getProductsInstance();
|
|
125
|
+
return instance.update(data, id);
|
|
126
|
+
},
|
|
127
|
+
async delete(id) {
|
|
128
|
+
const instance = await getProductsInstance();
|
|
129
|
+
return instance.delete(id);
|
|
130
|
+
},
|
|
131
|
+
async search(query) {
|
|
132
|
+
const instance = await getProductsInstance();
|
|
133
|
+
return instance.search(query);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
export const Baskets = {
|
|
137
|
+
async create(basketData) {
|
|
138
|
+
const instance = await getBasketsInstance();
|
|
139
|
+
return instance.create(basketData);
|
|
140
|
+
},
|
|
141
|
+
async get(status) {
|
|
142
|
+
const instance = await getBasketsInstance();
|
|
143
|
+
return instance.get(status);
|
|
144
|
+
},
|
|
145
|
+
async addItem(basketId, itemData) {
|
|
146
|
+
const instance = await getBasketsInstance();
|
|
147
|
+
return instance.addItem(basketId, itemData);
|
|
148
|
+
},
|
|
149
|
+
async removeItem(basketId, itemId) {
|
|
150
|
+
const instance = await getBasketsInstance();
|
|
151
|
+
return instance.removeItem(basketId, itemId);
|
|
152
|
+
},
|
|
153
|
+
async clear(basketId) {
|
|
154
|
+
const instance = await getBasketsInstance();
|
|
155
|
+
return instance.clear(basketId);
|
|
156
|
+
},
|
|
157
|
+
async updateStatus(basketId, status) {
|
|
158
|
+
const instance = await getBasketsInstance();
|
|
159
|
+
return instance.updateStatus(basketId, status);
|
|
160
|
+
},
|
|
161
|
+
async updateMetadata(basketId, metadata) {
|
|
162
|
+
const instance = await getBasketsInstance();
|
|
163
|
+
return instance.updateMetadata(basketId, metadata);
|
|
164
|
+
},
|
|
165
|
+
async placeOrder(data, basketId) {
|
|
166
|
+
const instance = await getBasketsInstance();
|
|
167
|
+
return instance.placeOrder(data, basketId);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
export const Orders = {
|
|
171
|
+
async create(orderData) {
|
|
172
|
+
const instance = await getOrderInstance();
|
|
173
|
+
return instance.create(orderData);
|
|
174
|
+
},
|
|
175
|
+
async updateStatus(status, orderId) {
|
|
176
|
+
const instance = await getOrderInstance();
|
|
177
|
+
return instance.updateStatus(status, orderId);
|
|
178
|
+
},
|
|
179
|
+
async updateData(data, orderId) {
|
|
180
|
+
const instance = await getOrderInstance();
|
|
181
|
+
return instance.updateData(data, orderId);
|
|
182
|
+
},
|
|
183
|
+
async get(status) {
|
|
184
|
+
const instance = await getOrderInstance();
|
|
185
|
+
return instance.get(status);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
// Export classes and utilities
|
|
189
|
+
export { LuaSkill, BasketStatus, OrderStatus };
|
package/dist/commands/dev.js
CHANGED
|
@@ -708,12 +708,15 @@ async function pushSingleSkillToSandbox(apiKey, agentId, skillId, skillData, isI
|
|
|
708
708
|
return true;
|
|
709
709
|
}
|
|
710
710
|
else if (updateResult.error) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
711
|
+
writeProgress("⚠️ Failed to update existing sandbox, creating new one...");
|
|
712
|
+
console.error(`❌ Sandbox update failed: ${updateResult.error.message}`);
|
|
713
|
+
if (updateResult.error.error) {
|
|
714
|
+
console.error(` Details: ${updateResult.error.error}`);
|
|
715
|
+
}
|
|
716
|
+
// If skill not found during update, give helpful guidance before trying to create
|
|
717
|
+
if (updateResult.error.message.includes('Skill not found') || updateResult.error.statusCode === 400 || updateResult.error.statusCode === 404) {
|
|
718
|
+
console.error('\n💡 The skill doesn\'t exist on the server.');
|
|
719
|
+
console.error(' Please run "lua push" first to deploy your skill, then try "lua dev" again.\n');
|
|
717
720
|
}
|
|
718
721
|
// Fall through to create new sandbox
|
|
719
722
|
}
|
|
@@ -733,21 +736,22 @@ async function pushSingleSkillToSandbox(apiKey, agentId, skillId, skillData, isI
|
|
|
733
736
|
return true;
|
|
734
737
|
}
|
|
735
738
|
else if (result.error) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
739
|
+
console.error(`❌ Sandbox creation failed: ${result.error.message}`);
|
|
740
|
+
if (result.error.error) {
|
|
741
|
+
console.error(` Details: ${result.error.error}`);
|
|
742
|
+
}
|
|
743
|
+
if (result.error.statusCode) {
|
|
744
|
+
console.error(` Status Code: ${result.error.statusCode}`);
|
|
745
|
+
}
|
|
746
|
+
// If skill not found, give helpful guidance
|
|
747
|
+
if (result.error.message.includes('Skill not found') || result.error.statusCode === 400 || result.error.statusCode === 404) {
|
|
748
|
+
console.error('\n💡 The skill hasn\'t been deployed to the server yet.');
|
|
749
|
+
console.error(' Please run "lua push" first to deploy your skill, then try "lua dev" again.');
|
|
744
750
|
}
|
|
745
751
|
return false;
|
|
746
752
|
}
|
|
747
753
|
else {
|
|
748
|
-
|
|
749
|
-
console.error("❌ Failed to push version to sandbox. Please try again.");
|
|
750
|
-
}
|
|
754
|
+
console.error("❌ Failed to push version to sandbox. Please try again.");
|
|
751
755
|
return false;
|
|
752
756
|
}
|
|
753
757
|
}
|
|
@@ -814,6 +818,7 @@ export async function devCommand() {
|
|
|
814
818
|
}
|
|
815
819
|
// Initial push to sandbox
|
|
816
820
|
writeProgress("🔄 Pushing skills to sandbox...");
|
|
821
|
+
console.log('deployData', deployData);
|
|
817
822
|
const sandboxIds = await pushSkillsToSandbox(apiKey, agentId, deployData, true);
|
|
818
823
|
// console.log(sandboxIds);
|
|
819
824
|
if (Object.keys(sandboxIds).length === 0) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Basket, BasketItem, BasketStatus } from "../interfaces/baskets";
|
|
2
|
+
import { BasketAPI } from "../types";
|
|
3
|
+
import OrderInstance from "./order.instance";
|
|
4
|
+
export default class BasketInstance {
|
|
5
|
+
private id;
|
|
6
|
+
private userId;
|
|
7
|
+
private agentId;
|
|
8
|
+
private data;
|
|
9
|
+
private common;
|
|
10
|
+
metadata: any;
|
|
11
|
+
totalAmount: string | number;
|
|
12
|
+
itemCount: number;
|
|
13
|
+
status: BasketStatus;
|
|
14
|
+
private basketAPI;
|
|
15
|
+
constructor(api: BasketAPI, basket: Basket);
|
|
16
|
+
/**
|
|
17
|
+
* Custom toJSON method to control what gets serialized when logging
|
|
18
|
+
*/
|
|
19
|
+
toJSON(): Record<string, any>;
|
|
20
|
+
updateMetadata(metadata: any): Promise<any>;
|
|
21
|
+
updateStatus(status: BasketStatus): Promise<any>;
|
|
22
|
+
private updateBasket;
|
|
23
|
+
addItem(item: BasketItem): Promise<any>;
|
|
24
|
+
removeItem(itemId: string): Promise<any>;
|
|
25
|
+
clear(): Promise<any>;
|
|
26
|
+
placeOrder(data: Record<string, any>): Promise<OrderInstance>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BasketStatus } from "../interfaces/baskets";
|
|
2
|
+
export default class BasketInstance {
|
|
3
|
+
constructor(api, basket) {
|
|
4
|
+
this.data = basket.data;
|
|
5
|
+
this.common = basket.common;
|
|
6
|
+
this.id = basket.id;
|
|
7
|
+
this.userId = basket.userId;
|
|
8
|
+
this.agentId = basket.agentId;
|
|
9
|
+
this.metadata = basket.data.metadata;
|
|
10
|
+
this.totalAmount = basket.common.totalAmount;
|
|
11
|
+
this.itemCount = basket.common.itemCount;
|
|
12
|
+
this.status = basket.common.status;
|
|
13
|
+
// Make basketAPI non-enumerable so it doesn't show up in console.log
|
|
14
|
+
Object.defineProperty(this, 'basketAPI', {
|
|
15
|
+
value: api,
|
|
16
|
+
writable: true,
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Custom toJSON method to control what gets serialized when logging
|
|
23
|
+
*/
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
...this.data,
|
|
27
|
+
...this.common
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Custom inspect method for Node.js console.log
|
|
32
|
+
*/
|
|
33
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
34
|
+
return {
|
|
35
|
+
...this.data,
|
|
36
|
+
...this.common,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async updateMetadata(metadata) {
|
|
40
|
+
await this.basketAPI.updateMetadata(this.id, metadata);
|
|
41
|
+
this.data.metadata = { ...this.data.metadata, ...metadata };
|
|
42
|
+
return { ...this.data, ...this.common };
|
|
43
|
+
}
|
|
44
|
+
async updateStatus(status) {
|
|
45
|
+
await this.basketAPI.updateStatus(this.id, status);
|
|
46
|
+
this.common.status = status;
|
|
47
|
+
return { ...this.data, ...this.common };
|
|
48
|
+
}
|
|
49
|
+
updateBasket(basket) {
|
|
50
|
+
this.data = basket.data;
|
|
51
|
+
this.common = basket.common;
|
|
52
|
+
this.id = basket.id;
|
|
53
|
+
this.userId = basket.userId;
|
|
54
|
+
this.agentId = basket.agentId;
|
|
55
|
+
this.metadata = basket.data.metadata;
|
|
56
|
+
this.totalAmount = basket.common.totalAmount;
|
|
57
|
+
this.itemCount = basket.common.itemCount;
|
|
58
|
+
this.status = basket.common.status;
|
|
59
|
+
return { ...this.data, ...this.common };
|
|
60
|
+
}
|
|
61
|
+
async addItem(item) {
|
|
62
|
+
const basket = await this.basketAPI.addItem(this.id, item);
|
|
63
|
+
return this.updateBasket(basket);
|
|
64
|
+
}
|
|
65
|
+
async removeItem(itemId) {
|
|
66
|
+
const basket = await this.basketAPI.removeItem(this.id, itemId);
|
|
67
|
+
return this.updateBasket(basket);
|
|
68
|
+
}
|
|
69
|
+
async clear() {
|
|
70
|
+
const basket = await this.basketAPI.clear(this.id);
|
|
71
|
+
return this.updateBasket(basket);
|
|
72
|
+
}
|
|
73
|
+
async placeOrder(data) {
|
|
74
|
+
const order = await this.basketAPI.placeOrder(data, this.id);
|
|
75
|
+
console.log('order', order);
|
|
76
|
+
await this.updateStatus(BasketStatus.CHECKED_OUT);
|
|
77
|
+
return order;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CustomDataAPI } from "../types";
|
|
2
|
+
import { CreateCustomDataResponse } from "../interfaces/custom.data";
|
|
3
|
+
export default class DataEntryInstance {
|
|
4
|
+
data: Record<string, any>;
|
|
5
|
+
id: string;
|
|
6
|
+
collectionName: string;
|
|
7
|
+
score?: number;
|
|
8
|
+
private customDataAPI;
|
|
9
|
+
constructor(api: CustomDataAPI, entry: CreateCustomDataResponse, collectionName: string);
|
|
10
|
+
/**
|
|
11
|
+
* Custom toJSON method to control what gets serialized when logging
|
|
12
|
+
*/
|
|
13
|
+
toJSON(): Record<string, any>;
|
|
14
|
+
update(data: Record<string, any>, searchText?: string): Promise<any>;
|
|
15
|
+
delete(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export default class DataEntryInstance {
|
|
2
|
+
constructor(api, entry, collectionName) {
|
|
3
|
+
this.data = entry.data;
|
|
4
|
+
this.id = entry.id;
|
|
5
|
+
this.collectionName = collectionName;
|
|
6
|
+
this.score = entry.score;
|
|
7
|
+
// Make userAPI non-enumerable so it doesn't show up in console.log
|
|
8
|
+
Object.defineProperty(this, 'customDataAPI', {
|
|
9
|
+
value: api,
|
|
10
|
+
writable: true,
|
|
11
|
+
enumerable: false,
|
|
12
|
+
configurable: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Custom toJSON method to control what gets serialized when logging
|
|
17
|
+
*/
|
|
18
|
+
toJSON() {
|
|
19
|
+
return {
|
|
20
|
+
...this.data,
|
|
21
|
+
score: this.score
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Custom inspect method for Node.js console.log
|
|
26
|
+
*/
|
|
27
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
28
|
+
return {
|
|
29
|
+
...this.data,
|
|
30
|
+
score: this.score
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async update(data, searchText) {
|
|
34
|
+
try {
|
|
35
|
+
const response = await this.customDataAPI.update(this.collectionName, this.id, { data, searchText });
|
|
36
|
+
this.data = { ...this.data, ...data };
|
|
37
|
+
return this.data;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error('Failed to update user data');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async delete() {
|
|
44
|
+
try {
|
|
45
|
+
await this.customDataAPI.delete(this.collectionName, this.id);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error('Failed to clear user data');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
2
|
+
/**
|
|
3
|
+
* Generic HTTP client with common error handling
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class HttpClient {
|
|
6
|
+
protected baseUrl: string;
|
|
7
|
+
constructor(baseUrl: string);
|
|
8
|
+
private request;
|
|
9
|
+
protected httpGet<T>(url: string, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
10
|
+
protected httpPost<T>(url: string, data?: any, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
11
|
+
protected httpPut<T>(url: string, data?: any, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
12
|
+
protected httpDelete<T>(url: string, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
13
|
+
protected httpPatch<T>(url: string, data?: any, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
14
|
+
}
|