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.
Files changed (191) hide show
  1. package/API_REFERENCE.md +1408 -0
  2. package/CLI_REFERENCE.md +818 -0
  3. package/GETTING_STARTED.md +1040 -0
  4. package/README.md +738 -424
  5. package/TEMPLATE_GUIDE.md +1398 -0
  6. package/dist/api/agent.api.service.d.ts +45 -0
  7. package/dist/api/agent.api.service.js +57 -0
  8. package/dist/api/auth.api.service.d.ts +48 -0
  9. package/dist/api/auth.api.service.js +54 -0
  10. package/dist/api/basket.api.service.d.ts +85 -0
  11. package/dist/api/basket.api.service.js +164 -0
  12. package/dist/api/chat.api.service.d.ts +21 -0
  13. package/dist/api/chat.api.service.js +24 -0
  14. package/dist/api/credentials.d.ts +24 -0
  15. package/dist/api/credentials.js +46 -0
  16. package/dist/api/custom.data.api.service.d.ts +69 -0
  17. package/dist/api/custom.data.api.service.js +125 -0
  18. package/dist/api/lazy-instances.d.ts +49 -0
  19. package/dist/api/lazy-instances.js +95 -0
  20. package/dist/api/order.api.service.d.ts +53 -0
  21. package/dist/api/order.api.service.js +95 -0
  22. package/dist/api/products.api.service.d.ts +66 -0
  23. package/dist/api/products.api.service.js +112 -0
  24. package/dist/api/skills.api.service.d.ts +77 -0
  25. package/dist/api/skills.api.service.js +88 -0
  26. package/dist/api/tool.api.service.d.ts +52 -0
  27. package/dist/api/tool.api.service.js +73 -0
  28. package/dist/api/user.data.api.service.d.ts +33 -0
  29. package/dist/api/user.data.api.service.js +59 -0
  30. package/dist/api-exports.d.ts +271 -0
  31. package/dist/api-exports.js +372 -0
  32. package/dist/cli/command-definitions.d.ts +30 -0
  33. package/dist/cli/command-definitions.js +71 -0
  34. package/dist/commands/agents.d.ts +20 -0
  35. package/dist/commands/agents.js +24 -2
  36. package/dist/commands/apiKey.d.ts +23 -0
  37. package/dist/commands/apiKey.js +23 -0
  38. package/dist/commands/compile.d.ts +24 -0
  39. package/dist/commands/compile.js +67 -759
  40. package/dist/commands/configure.d.ts +24 -0
  41. package/dist/commands/configure.js +31 -96
  42. package/dist/commands/deploy.d.ts +31 -19
  43. package/dist/commands/deploy.js +45 -74
  44. package/dist/commands/destroy.d.ts +27 -0
  45. package/dist/commands/destroy.js +27 -1
  46. package/dist/commands/dev.d.ts +25 -62
  47. package/dist/commands/dev.js +58 -873
  48. package/dist/commands/init.d.ts +27 -0
  49. package/dist/commands/init.js +98 -260
  50. package/dist/commands/push.d.ts +24 -21
  51. package/dist/commands/push.js +39 -92
  52. package/dist/commands/test.d.ts +26 -0
  53. package/dist/commands/test.js +41 -188
  54. package/dist/common/basket.instance.d.ts +78 -0
  55. package/dist/common/basket.instance.js +132 -0
  56. package/dist/common/data.entry.instance.d.ts +39 -0
  57. package/dist/common/data.entry.instance.js +76 -0
  58. package/dist/common/http.client.d.ts +64 -0
  59. package/dist/common/http.client.js +133 -0
  60. package/dist/common/order.instance.d.ts +40 -0
  61. package/dist/common/order.instance.js +79 -0
  62. package/dist/common/product.instance.d.ts +33 -0
  63. package/dist/common/product.instance.js +63 -0
  64. package/dist/common/product.pagination.instance.d.ts +43 -0
  65. package/dist/common/product.pagination.instance.js +74 -0
  66. package/dist/common/product.search.instance.d.ts +22 -0
  67. package/dist/common/product.search.instance.js +40 -0
  68. package/dist/common/user.instance.d.ts +41 -0
  69. package/dist/common/user.instance.js +84 -0
  70. package/dist/config/auth.constants.d.ts +11 -0
  71. package/dist/config/auth.constants.js +11 -0
  72. package/dist/config/compile.constants.d.ts +67 -0
  73. package/dist/config/compile.constants.js +99 -0
  74. package/dist/config/constants.d.ts +5 -0
  75. package/dist/config/constants.js +5 -0
  76. package/dist/config/dev.constants.d.ts +65 -0
  77. package/dist/config/dev.constants.js +79 -0
  78. package/dist/config/init.constants.d.ts +23 -0
  79. package/dist/config/init.constants.js +41 -0
  80. package/dist/index.d.ts +19 -3
  81. package/dist/index.js +28 -44
  82. package/dist/interfaces/admin.d.ts +101 -0
  83. package/dist/interfaces/admin.js +5 -0
  84. package/dist/interfaces/agent.d.ts +107 -0
  85. package/dist/interfaces/agent.js +5 -0
  86. package/dist/interfaces/baskets.d.ts +135 -0
  87. package/dist/interfaces/baskets.js +19 -0
  88. package/dist/interfaces/chat.d.ts +61 -0
  89. package/dist/interfaces/chat.js +5 -0
  90. package/dist/interfaces/common.d.ts +62 -0
  91. package/dist/interfaces/common.js +8 -0
  92. package/dist/interfaces/compile.d.ts +11 -0
  93. package/dist/interfaces/compile.js +4 -0
  94. package/dist/interfaces/custom.data.d.ts +82 -0
  95. package/dist/interfaces/custom.data.js +5 -0
  96. package/dist/interfaces/deploy.d.ts +29 -0
  97. package/dist/interfaces/deploy.js +4 -0
  98. package/dist/interfaces/dev.d.ts +53 -0
  99. package/dist/interfaces/dev.js +5 -0
  100. package/dist/interfaces/init.d.ts +60 -0
  101. package/dist/interfaces/init.js +4 -0
  102. package/dist/interfaces/orders.d.ts +91 -0
  103. package/dist/interfaces/orders.js +19 -0
  104. package/dist/interfaces/product.d.ts +65 -0
  105. package/dist/interfaces/product.js +5 -0
  106. package/dist/interfaces/push.d.ts +26 -0
  107. package/dist/interfaces/push.js +4 -0
  108. package/dist/interfaces/test.d.ts +36 -0
  109. package/dist/interfaces/test.js +4 -0
  110. package/dist/services/auth.d.ts +54 -99
  111. package/dist/services/auth.js +76 -12
  112. package/dist/types/api-contracts.d.ts +211 -0
  113. package/dist/types/api-contracts.js +8 -0
  114. package/dist/types/compile.types.d.ts +76 -0
  115. package/dist/types/compile.types.js +4 -0
  116. package/dist/types/index.d.ts +23 -85
  117. package/dist/types/index.js +25 -14
  118. package/dist/types/skill.d.ts +142 -0
  119. package/dist/{skill.js → types/skill.js} +66 -19
  120. package/dist/types/tool-validation.d.ts +34 -0
  121. package/dist/types/tool-validation.js +42 -0
  122. package/dist/utils/auth-flows.d.ts +26 -0
  123. package/dist/utils/auth-flows.js +141 -0
  124. package/dist/utils/bundling.d.ts +36 -0
  125. package/dist/utils/bundling.js +137 -0
  126. package/dist/utils/compile.d.ts +37 -0
  127. package/dist/utils/compile.js +242 -0
  128. package/dist/utils/deploy-api.d.ts +26 -0
  129. package/dist/utils/deploy-api.js +53 -0
  130. package/dist/utils/deploy-helpers.d.ts +46 -0
  131. package/dist/utils/deploy-helpers.js +86 -0
  132. package/dist/utils/deployment.d.ts +25 -0
  133. package/dist/utils/deployment.js +161 -0
  134. package/dist/utils/dev-api.d.ts +61 -0
  135. package/dist/utils/dev-api.js +262 -0
  136. package/dist/utils/dev-helpers.d.ts +46 -0
  137. package/dist/utils/dev-helpers.js +83 -0
  138. package/dist/utils/dev-server.d.ts +24 -0
  139. package/dist/utils/dev-server.js +555 -0
  140. package/dist/utils/dev-watcher.d.ts +31 -0
  141. package/dist/utils/dev-watcher.js +110 -0
  142. package/dist/utils/files.js +0 -5
  143. package/dist/utils/init-agent.d.ts +34 -0
  144. package/dist/utils/init-agent.js +129 -0
  145. package/dist/utils/init-helpers.d.ts +41 -0
  146. package/dist/utils/init-helpers.js +73 -0
  147. package/dist/utils/init-prompts.d.ts +47 -0
  148. package/dist/utils/init-prompts.js +168 -0
  149. package/dist/utils/push-api.d.ts +15 -0
  150. package/dist/utils/push-api.js +48 -0
  151. package/dist/utils/push-helpers.d.ts +38 -0
  152. package/dist/utils/push-helpers.js +84 -0
  153. package/dist/utils/sandbox-storage.d.ts +27 -0
  154. package/dist/utils/sandbox-storage.js +71 -0
  155. package/dist/utils/sandbox.js +78 -118
  156. package/dist/utils/skill-management.d.ts +14 -0
  157. package/dist/utils/skill-management.js +148 -0
  158. package/dist/utils/test-helpers.d.ts +40 -0
  159. package/dist/utils/test-helpers.js +92 -0
  160. package/dist/utils/test-prompts.d.ts +23 -0
  161. package/dist/utils/test-prompts.js +186 -0
  162. package/dist/utils/tool-detection.d.ts +18 -0
  163. package/dist/utils/tool-detection.js +110 -0
  164. package/dist/web/app.css +14 -9
  165. package/package.json +11 -12
  166. package/template/QUICKSTART.md +299 -144
  167. package/template/README.md +928 -349
  168. package/template/TOOL_EXAMPLES.md +655 -0
  169. package/template/package-lock.json +3781 -0
  170. package/template/package.json +1 -1
  171. package/template/src/index.ts +81 -40
  172. package/template/src/tools/BasketTool.ts +128 -0
  173. package/template/src/tools/CustomDataTool.ts +7 -13
  174. package/template/src/tools/OrderTool.ts +54 -0
  175. package/template/src/tools/PaymentTool.ts +1 -1
  176. package/template/src/tools/ProductsTool.ts +56 -118
  177. package/template/src/tools/UserDataTool.ts +4 -27
  178. package/dist/custom-data-api.d.ts +0 -72
  179. package/dist/custom-data-api.js +0 -174
  180. package/dist/product-api.d.ts +0 -197
  181. package/dist/product-api.js +0 -152
  182. package/dist/services/api.d.ts +0 -569
  183. package/dist/services/api.js +0 -625
  184. package/dist/skill.d.ts +0 -50
  185. package/dist/types.d.ts +0 -1
  186. package/dist/types.js +0 -2
  187. package/dist/user-data-api.d.ts +0 -39
  188. package/dist/user-data-api.js +0 -50
  189. package/template/API.md +0 -604
  190. package/template/DEVELOPER.md +0 -771
  191. package/template/lua.skill.yaml +0 -16
@@ -0,0 +1,211 @@
1
+ /**
2
+ * API Contract Interfaces
3
+ * TypeScript interfaces that API service classes must implement
4
+ *
5
+ * These interfaces define the contract that API services must fulfill.
6
+ * They ensure consistent method signatures across all API implementations.
7
+ */
8
+ /**
9
+ * User Data API contract.
10
+ * Defines operations for managing user data.
11
+ */
12
+ export interface UserDataAPI {
13
+ /**
14
+ * Retrieves current user data.
15
+ * @returns Promise resolving to user data
16
+ */
17
+ get(): Promise<any>;
18
+ /**
19
+ * Updates user data.
20
+ * @param data - Data to update
21
+ * @returns Promise resolving to updated user data
22
+ */
23
+ update(data: Record<string, any>): Promise<any>;
24
+ /**
25
+ * Clears user data.
26
+ * @returns Promise resolving when data is cleared
27
+ */
28
+ clear(): Promise<any>;
29
+ }
30
+ /**
31
+ * Product API contract.
32
+ * Defines operations for managing products.
33
+ */
34
+ export interface ProductAPI {
35
+ /**
36
+ * Gets products with pagination.
37
+ * @param limit - Items per page
38
+ * @param page - Page number
39
+ * @returns Promise resolving to product list
40
+ */
41
+ get(limit?: number, page?: number): Promise<any>;
42
+ /**
43
+ * Creates a new product.
44
+ * @param product - Product data
45
+ * @returns Promise resolving to created product
46
+ */
47
+ create(product: any): Promise<any>;
48
+ /**
49
+ * Updates an existing product.
50
+ * @param data - Updated product data
51
+ * @param id - Product ID
52
+ * @returns Promise resolving to updated product
53
+ */
54
+ update(data: any, id: string): Promise<any>;
55
+ /**
56
+ * Deletes a product.
57
+ * @param id - Product ID
58
+ * @returns Promise resolving when deletion is complete
59
+ */
60
+ delete(id: string): Promise<any>;
61
+ /**
62
+ * Searches products.
63
+ * @param query - Search query
64
+ * @returns Promise resolving to search results
65
+ */
66
+ search(query: string): Promise<any>;
67
+ }
68
+ /**
69
+ * Basket API contract.
70
+ * Defines operations for managing shopping baskets.
71
+ */
72
+ export interface BasketAPI {
73
+ /**
74
+ * Creates a new basket.
75
+ * @param basketData - Basket initialization data
76
+ * @returns Promise resolving to created basket
77
+ */
78
+ create(basketData: any): Promise<any>;
79
+ /**
80
+ * Gets baskets, optionally filtered by status.
81
+ * @param status - Optional status filter
82
+ * @returns Promise resolving to basket list
83
+ */
84
+ get(status?: any): Promise<any>;
85
+ /**
86
+ * Adds an item to a basket.
87
+ * @param basketId - Basket ID
88
+ * @param itemData - Item data to add
89
+ * @returns Promise resolving to updated basket
90
+ */
91
+ addItem(basketId: string, itemData: any): Promise<any>;
92
+ /**
93
+ * Removes an item from a basket.
94
+ * @param basketId - Basket ID
95
+ * @param itemId - Item ID to remove
96
+ * @returns Promise resolving to updated basket
97
+ */
98
+ removeItem(basketId: string, itemId: string): Promise<any>;
99
+ /**
100
+ * Clears all items from a basket.
101
+ * @param basketId - Basket ID
102
+ * @returns Promise resolving to cleared basket
103
+ */
104
+ clear(basketId: string): Promise<any>;
105
+ /**
106
+ * Updates basket status.
107
+ * @param basketId - Basket ID
108
+ * @param status - New status
109
+ * @returns Promise resolving to updated basket
110
+ */
111
+ updateStatus(basketId: string, status: any): Promise<any>;
112
+ /**
113
+ * Updates basket metadata.
114
+ * @param basketId - Basket ID
115
+ * @param metadata - Metadata to update
116
+ * @returns Promise resolving to updated basket
117
+ */
118
+ updateMetadata(basketId: string, metadata: any): Promise<any>;
119
+ /**
120
+ * Converts basket to order.
121
+ * @param data - Order data
122
+ * @param basketId - Basket ID
123
+ * @returns Promise resolving to created order
124
+ */
125
+ placeOrder(data: Record<string, any>, basketId: string): Promise<any>;
126
+ }
127
+ /**
128
+ * Order API contract.
129
+ * Defines operations for managing orders.
130
+ */
131
+ export interface OrderAPI {
132
+ /**
133
+ * Creates a new order.
134
+ * @param orderData - Order data
135
+ * @returns Promise resolving to created order
136
+ */
137
+ create(orderData: any): Promise<any>;
138
+ /**
139
+ * Updates order status.
140
+ * @param status - New status
141
+ * @param orderId - Order ID
142
+ * @returns Promise resolving to updated order
143
+ */
144
+ updateStatus(status: any, orderId: string): Promise<any>;
145
+ /**
146
+ * Updates order data.
147
+ * @param data - Data to update
148
+ * @param orderId - Order ID
149
+ * @returns Promise resolving to updated order
150
+ */
151
+ updateData(data: Record<string, any>, orderId: string): Promise<any>;
152
+ /**
153
+ * Gets orders, optionally filtered by status.
154
+ * @param status - Optional status filter
155
+ * @returns Promise resolving to order list
156
+ */
157
+ get(status?: any): Promise<any>;
158
+ }
159
+ /**
160
+ * Custom Data API contract.
161
+ * Defines operations for managing custom data collections with vector search.
162
+ */
163
+ export interface CustomDataAPI {
164
+ /**
165
+ * Creates a new entry in a custom data collection.
166
+ * @param collectionName - Collection name
167
+ * @param data - Data to store
168
+ * @returns Promise resolving to created entry
169
+ */
170
+ create(collectionName: string, data: any): Promise<any>;
171
+ /**
172
+ * Gets entries from a collection with filtering and pagination.
173
+ * @param collectionName - Collection name
174
+ * @param filter - Optional filter criteria
175
+ * @param page - Page number
176
+ * @param limit - Items per page
177
+ * @returns Promise resolving to entries
178
+ */
179
+ get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<any>;
180
+ /**
181
+ * Gets a specific entry by ID.
182
+ * @param collectionName - Collection name
183
+ * @param entryId - Entry ID
184
+ * @returns Promise resolving to entry data
185
+ */
186
+ getEntry(collectionName: string, entryId: string): Promise<any>;
187
+ /**
188
+ * Updates an existing entry.
189
+ * @param collectionName - Collection name
190
+ * @param entryId - Entry ID
191
+ * @param data - Updated data
192
+ * @returns Promise resolving to updated entry
193
+ */
194
+ update(collectionName: string, entryId: string, data: any): Promise<any>;
195
+ /**
196
+ * Performs vector search on a collection.
197
+ * @param collectionName - Collection name
198
+ * @param searchText - Text to search for
199
+ * @param limit - Maximum results
200
+ * @param scoreThreshold - Minimum similarity score
201
+ * @returns Promise resolving to search results
202
+ */
203
+ search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<any>;
204
+ /**
205
+ * Deletes an entry from a collection.
206
+ * @param collectionName - Collection name
207
+ * @param entryId - Entry ID to delete
208
+ * @returns Promise resolving when deletion is complete
209
+ */
210
+ delete(collectionName: string, entryId: string): Promise<any>;
211
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * API Contract Interfaces
3
+ * TypeScript interfaces that API service classes must implement
4
+ *
5
+ * These interfaces define the contract that API services must fulfill.
6
+ * They ensure consistent method signatures across all API implementations.
7
+ */
8
+ export {};
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Type definitions for compile command
3
+ */
4
+ import { SourceFile } from "ts-morph";
5
+ /**
6
+ * Represents a TypeScript source file from ts-morph
7
+ */
8
+ export type TypeScriptSourceFile = SourceFile;
9
+ /**
10
+ * Represents an AST node from ts-morph
11
+ */
12
+ export type ASTNode = any;
13
+ /**
14
+ * Skill metadata extracted from source code
15
+ */
16
+ export interface SkillMetadata {
17
+ name: string;
18
+ version: string;
19
+ description: string;
20
+ context: string;
21
+ constructorTools: string[];
22
+ }
23
+ /**
24
+ * Configuration from lua.skill.yaml
25
+ */
26
+ export interface SkillConfig {
27
+ skill?: {
28
+ name?: string;
29
+ version?: string;
30
+ skillId?: string;
31
+ description?: string;
32
+ context?: string;
33
+ };
34
+ agent?: {
35
+ agentId?: string;
36
+ };
37
+ skills?: Array<{
38
+ name: string;
39
+ version: string;
40
+ skillId: string;
41
+ }>;
42
+ }
43
+ /**
44
+ * Deployment data format for new deployment system
45
+ */
46
+ export interface DeploymentData {
47
+ name: string;
48
+ version: string;
49
+ skillId: string;
50
+ description: string;
51
+ context: string;
52
+ tools: Array<{
53
+ name: string;
54
+ className: string;
55
+ description: string;
56
+ filePath: string;
57
+ }>;
58
+ }
59
+ /**
60
+ * Legacy deployment data format
61
+ */
62
+ export interface LegacyDeployData {
63
+ skills: Array<{
64
+ name: string;
65
+ version: string;
66
+ description: string;
67
+ context: string;
68
+ skillId?: string;
69
+ tools: Array<{
70
+ name: string;
71
+ description: string;
72
+ inputSchema: any;
73
+ execute: string;
74
+ }>;
75
+ }>;
76
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Type definitions for compile command
3
+ */
4
+ export {};
@@ -1,87 +1,25 @@
1
- export interface UserData {
2
- uid: string;
3
- email: string;
4
- emailVerified: boolean;
5
- fullName: string;
6
- mobileNumbers: any[];
7
- emailAddresses: EmailAddress[];
8
- country: Country;
9
- admin: Admin;
10
- channels: Record<string, any>;
11
- rights: Record<string, any>;
12
- setupPersona: Record<string, any>;
13
- notifications: Record<string, any>;
14
- }
15
- export interface EmailAddress {
16
- address: string;
17
- validated: boolean;
18
- validatedAt: number;
19
- _id: string;
20
- }
21
- export interface Country {
22
- code: string;
23
- name: string;
24
- }
25
- export interface Admin {
26
- userId: string;
27
- orgs: Organization[];
28
- id: string;
29
- createdAt: number;
30
- __v: number;
31
- }
32
- export interface Organization {
33
- id: string;
34
- rights?: string[];
35
- agents: Agent[];
36
- registeredName: string;
37
- country: string;
38
- phoneNumber?: string | null;
39
- type: string;
40
- }
41
- export interface Agent {
42
- agentId: string;
43
- rights: string[];
44
- name: string;
45
- }
46
- export interface OTPResponse {
47
- signInToken: string;
48
- }
49
- export interface ApiKeyResponse {
50
- message: string;
51
- userId: string;
52
- apiKey: string;
53
- apiId: string;
54
- }
55
- import { ZodType } from "zod";
56
1
  /**
57
- * Validates that a tool name contains only alphanumeric characters, hyphens, and underscores.
58
- * No spaces or other special characters are allowed.
2
+ * Types Module - Barrel Export
3
+ *
4
+ * This file serves as the main entry point for all type definitions.
5
+ * It re-exports types from various modules for convenient importing.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * // Import from types module
10
+ * import { LuaSkill, LuaTool, env } from './types/index.js';
11
+ *
12
+ * // Or import specific type groups
13
+ * import { UserDataAPI, ProductAPI } from './types/api-contracts.js';
14
+ * import { validateToolName } from './types/tool-validation.js';
15
+ * ```
59
16
  */
60
- export declare function validateToolName(name: string): boolean;
61
- /**
62
- * Throws an error if the tool name is invalid
63
- */
64
- export declare function assertValidToolName(name: string): void;
65
- export interface LuaTool<TInput extends ZodType = ZodType> {
66
- name: string;
67
- description: string;
68
- inputSchema: TInput;
69
- execute: (input: any) => Promise<any>;
70
- }
71
- export interface LuaSkillConfig {
72
- name: string;
73
- version: string;
74
- description: string;
75
- context: string;
76
- }
77
- export declare class LuaSkill {
78
- private readonly tools;
79
- private readonly name;
80
- private readonly version;
81
- private readonly description;
82
- private readonly context;
83
- constructor(config: LuaSkillConfig);
84
- addTool<TInput extends ZodType>(tool: LuaTool<TInput>): void;
85
- addTools(tools: LuaTool<any>[]): void;
86
- run(input: Record<string, any>): Promise<any>;
87
- }
17
+ export { LuaSkill, LuaTool, LuaSkillConfig, env } from './skill.js';
18
+ export { validateToolName, assertValidToolName } from './tool-validation.js';
19
+ export { UserDataAPI, ProductAPI, BasketAPI, OrderAPI, CustomDataAPI } from './api-contracts.js';
20
+ export { UserData, EmailAddress, Country, Admin, Organization, AgentAuth, OTPResponse, ApiKeyResponse } from '../interfaces/admin.js';
21
+ export { Agent, AgentType, CreateAgentRequest, CreateAgentResponse, AgentDetailsResponse } from '../interfaces/agent.js';
22
+ export { BasketStatus, BasketItem, Basket } from '../interfaces/baskets.js';
23
+ export { OrderStatus, OrderResponse } from '../interfaces/orders.js';
24
+ export { Product } from '../interfaces/product.js';
25
+ export { ApiResponse, Pagination } from '../interfaces/common.js';
@@ -1,16 +1,27 @@
1
1
  /**
2
- * Validates that a tool name contains only alphanumeric characters, hyphens, and underscores.
3
- * No spaces or other special characters are allowed.
2
+ * Types Module - Barrel Export
3
+ *
4
+ * This file serves as the main entry point for all type definitions.
5
+ * It re-exports types from various modules for convenient importing.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * // Import from types module
10
+ * import { LuaSkill, LuaTool, env } from './types/index.js';
11
+ *
12
+ * // Or import specific type groups
13
+ * import { UserDataAPI, ProductAPI } from './types/api-contracts.js';
14
+ * import { validateToolName } from './types/tool-validation.js';
15
+ * ```
4
16
  */
5
- export function validateToolName(name) {
6
- const validNameRegex = /^[a-zA-Z0-9_-]+$/;
7
- return validNameRegex.test(name);
8
- }
9
- /**
10
- * Throws an error if the tool name is invalid
11
- */
12
- export function assertValidToolName(name) {
13
- if (!validateToolName(name)) {
14
- throw new Error(`Invalid tool name "${name}". Tool names can only contain alphanumeric characters, hyphens (-), and underscores (_). No spaces or other special characters are allowed.`);
15
- }
16
- }
17
+ // ============================================================================
18
+ // SKILL SYSTEM EXPORTS
19
+ // ============================================================================
20
+ // Core skill classes and utilities
21
+ export { LuaSkill, env } from './skill.js';
22
+ // Tool validation utilities
23
+ export { validateToolName, assertValidToolName } from './tool-validation.js';
24
+ // Basket types
25
+ export { BasketStatus } from '../interfaces/baskets.js';
26
+ // Order types
27
+ export { OrderStatus } from '../interfaces/orders.js';
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Lua Skill System
3
+ * Core types and classes for building Lua AI skills
4
+ */
5
+ import { ZodType } from "zod";
6
+ /**
7
+ * Safe environment variable access function.
8
+ * Gets injected at runtime with skill-specific environment variables.
9
+ *
10
+ * Checks in order:
11
+ * 1. Process environment variables (.env file)
12
+ * 2. lua.skill.yaml configuration
13
+ *
14
+ * @param key - The environment variable key to retrieve
15
+ * @returns The environment variable value or undefined if not found
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const baseUrl = env('BASE_URL');
20
+ * const apiKey = env('API_KEY');
21
+ * ```
22
+ */
23
+ export declare const env: (key: string) => string | undefined;
24
+ /**
25
+ * Lua Tool interface.
26
+ * Defines the structure of a tool that can be added to a LuaSkill.
27
+ *
28
+ * @template TInput - Zod schema type for input validation
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { z } from 'zod';
33
+ * import { LuaTool } from 'lua-cli';
34
+ *
35
+ * const weatherTool: LuaTool = {
36
+ * name: 'get_weather',
37
+ * description: 'Gets current weather for a city',
38
+ * inputSchema: z.object({
39
+ * city: z.string(),
40
+ * units: z.enum(['metric', 'imperial']).optional()
41
+ * }),
42
+ * execute: async (input) => {
43
+ * // Fetch weather data...
44
+ * return { temperature: 72, condition: 'sunny' };
45
+ * }
46
+ * };
47
+ * ```
48
+ */
49
+ export interface LuaTool<TInput extends ZodType = ZodType> {
50
+ /** Unique tool name (alphanumeric, hyphens, underscores only) */
51
+ name: string;
52
+ /** Description of what the tool does */
53
+ description: string;
54
+ /** Zod schema for input validation */
55
+ inputSchema: TInput;
56
+ /** Async function that executes the tool logic */
57
+ execute: (input: any) => Promise<any>;
58
+ }
59
+ /**
60
+ * Lua Skill configuration.
61
+ * Used to initialize a new LuaSkill instance.
62
+ */
63
+ export interface LuaSkillConfig {
64
+ /** Skill name (optional, defaults to 'unnamed-skill') */
65
+ name?: string;
66
+ /** Skill version (optional, defaults to '1.0.0') */
67
+ version?: string;
68
+ /** Short description of the skill (1-2 sentences) */
69
+ description: string;
70
+ /** Detailed context for how the agent should use the tools */
71
+ context: string;
72
+ /** Optional array of tools to add during construction */
73
+ tools?: LuaTool<any>[];
74
+ }
75
+ /**
76
+ * Lua Skill class.
77
+ * Main class for building AI skills with tools.
78
+ *
79
+ * A skill is a collection of tools that the AI agent can use to accomplish tasks.
80
+ * Tools are functions with validated inputs and well-defined outputs.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * import { LuaSkill } from 'lua-cli';
85
+ *
86
+ * const skill = new LuaSkill({
87
+ * name: 'weather-skill',
88
+ * version: '1.0.0',
89
+ * description: "Weather and calculator utilities",
90
+ * context: "This skill provides weather information and math operations. " +
91
+ * "Use get_weather for current conditions and calculator for arithmetic.",
92
+ * tools: [weatherTool, calculatorTool]
93
+ * });
94
+ *
95
+ * // Or add tools after construction
96
+ * skill.addTool(anotherTool);
97
+ * ```
98
+ */
99
+ export declare class LuaSkill {
100
+ private readonly tools;
101
+ private readonly name;
102
+ private readonly version;
103
+ private readonly description;
104
+ private readonly context;
105
+ /**
106
+ * Creates a new LuaSkill instance.
107
+ *
108
+ * @param config - Configuration object containing skill metadata
109
+ * @param config.name - Skill name (optional, defaults to 'unnamed-skill')
110
+ * @param config.version - Skill version (optional, defaults to '1.0.0')
111
+ * @param config.description - Short description of what the skill does (1-2 sentences)
112
+ * @param config.context - Detailed explanation of how the agent should use the tools
113
+ * @param config.tools - Optional array of tools to add immediately
114
+ */
115
+ constructor(config: LuaSkillConfig);
116
+ /**
117
+ * Adds a single tool to the skill.
118
+ * Tool name is validated before being added.
119
+ *
120
+ * @param tool - Tool to add
121
+ * @throws Error if tool name is invalid
122
+ */
123
+ addTool<TInput extends ZodType>(tool: LuaTool<TInput>): void;
124
+ /**
125
+ * Adds multiple tools to the skill.
126
+ * All tool names are validated before being added.
127
+ *
128
+ * @param tools - Array of tools to add
129
+ * @throws Error if any tool name is invalid
130
+ */
131
+ addTools(tools: LuaTool<any>[]): void;
132
+ /**
133
+ * Executes a tool by name with provided input.
134
+ * Input is validated against the tool's Zod schema.
135
+ *
136
+ * @param input - Input object containing tool name and parameters
137
+ * @param input.tool - Name of the tool to execute
138
+ * @returns Promise resolving to tool execution result
139
+ * @throws Error if tool not found or input validation fails
140
+ */
141
+ run(input: Record<string, any>): Promise<any>;
142
+ }