lua-cli 2.2.8-alpha.2 → 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 (193) 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 +33 -6
  7. package/dist/api/agent.api.service.js +27 -0
  8. package/dist/api/auth.api.service.d.ts +31 -2
  9. package/dist/api/auth.api.service.js +29 -0
  10. package/dist/api/basket.api.service.d.ts +53 -11
  11. package/dist/api/basket.api.service.js +63 -14
  12. package/dist/api/chat.api.service.d.ts +15 -3
  13. package/dist/api/chat.api.service.js +12 -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 +45 -9
  17. package/dist/api/custom.data.api.service.js +43 -9
  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 +34 -4
  21. package/dist/api/order.api.service.js +41 -3
  22. package/dist/api/products.api.service.d.ts +39 -9
  23. package/dist/api/products.api.service.js +43 -5
  24. package/dist/api/skills.api.service.d.ts +49 -2
  25. package/dist/api/skills.api.service.js +47 -1
  26. package/dist/api/tool.api.service.d.ts +39 -1
  27. package/dist/api/tool.api.service.js +38 -0
  28. package/dist/api/user.data.api.service.d.ts +23 -1
  29. package/dist/api/user.data.api.service.js +22 -0
  30. package/dist/api-exports.d.ts +236 -5
  31. package/dist/api-exports.js +264 -81
  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 -878
  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 +54 -3
  55. package/dist/common/basket.instance.js +56 -3
  56. package/dist/common/data.entry.instance.d.ts +25 -2
  57. package/dist/common/data.entry.instance.js +24 -0
  58. package/dist/common/http.client.d.ts +51 -1
  59. package/dist/common/http.client.js +50 -0
  60. package/dist/common/order.instance.d.ts +22 -0
  61. package/dist/common/order.instance.js +31 -4
  62. package/dist/common/product.instance.d.ts +22 -1
  63. package/dist/common/product.instance.js +24 -6
  64. package/dist/common/product.pagination.instance.d.ts +22 -2
  65. package/dist/common/product.pagination.instance.js +22 -1
  66. package/dist/common/product.search.instance.d.ts +13 -3
  67. package/dist/common/product.search.instance.js +12 -1
  68. package/dist/common/user.instance.d.ts +27 -3
  69. package/dist/common/user.instance.js +28 -7
  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 +56 -50
  83. package/dist/interfaces/admin.js +4 -0
  84. package/dist/interfaces/agent.d.ts +21 -0
  85. package/dist/interfaces/agent.js +4 -0
  86. package/dist/interfaces/baskets.d.ts +60 -0
  87. package/dist/interfaces/baskets.js +12 -0
  88. package/dist/interfaces/chat.d.ts +48 -4
  89. package/dist/interfaces/chat.js +4 -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 +49 -19
  95. package/dist/interfaces/custom.data.js +4 -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 +37 -0
  103. package/dist/interfaces/orders.js +12 -0
  104. package/dist/interfaces/product.d.ts +38 -10
  105. package/dist/interfaces/product.js +4 -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 -121
  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 -17
  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 -114
  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 +7 -4
  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 +5 -5
  170. package/template/package.json +1 -1
  171. package/template/src/index.ts +147 -207
  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 -26
  178. package/dist/common/config.d.ts +0 -5
  179. package/dist/common/config.js +0 -5
  180. package/dist/custom-data-api.d.ts +0 -72
  181. package/dist/custom-data-api.js +0 -174
  182. package/dist/product-api.d.ts +0 -189
  183. package/dist/product-api.js +0 -141
  184. package/dist/services/api.d.ts +0 -549
  185. package/dist/services/api.js +0 -596
  186. package/dist/skill.d.ts +0 -50
  187. package/dist/types.d.ts +0 -1
  188. package/dist/types.js +0 -2
  189. package/dist/user-data-api.d.ts +0 -39
  190. package/dist/user-data-api.js +0 -50
  191. package/template/API.md +0 -604
  192. package/template/DEVELOPER.md +0 -771
  193. package/template/lua.skill.yaml +0 -7
@@ -1,50 +0,0 @@
1
- /**
2
- * User Data API for Lua CLI projects
3
- * Provides methods to interact with user data stored in the Lua system
4
- */
5
- export class UserDataAPI {
6
- constructor() {
7
- this.userData = {};
8
- }
9
- /**
10
- * Get user data for the current agent
11
- * @returns Promise<UserDataResponse>
12
- */
13
- async get() {
14
- return { success: true, data: this.userData };
15
- }
16
- /**
17
- * Create or update user data for the current agent
18
- * @param data - The user data to store
19
- * @returns Promise<UserDataResponse>
20
- */
21
- async create(data) {
22
- this.userData = data;
23
- return { success: true, data: this.userData };
24
- }
25
- /**
26
- * Update existing user data for the current agent
27
- * @param data - The user data to update
28
- * @returns Promise<UserDataResponse>
29
- */
30
- async update(data) {
31
- // Update is the same as create for this API
32
- this.userData = { ...this.userData, ...data };
33
- return { success: true, data: this.userData };
34
- }
35
- /**
36
- * Clear all user data for the current agent
37
- * @returns Promise<{success: boolean}>
38
- */
39
- async clear() {
40
- this.userData = {};
41
- return { success: true };
42
- }
43
- }
44
- /**
45
- * Convenience object for user data operations
46
- * Usage: user.data.get(), user.data.create(data), user.data.update(data), user.data.clear()
47
- */
48
- export const user = {
49
- data: new UserDataAPI()
50
- };
package/template/API.md DELETED
@@ -1,604 +0,0 @@
1
- # Lua CLI API Reference
2
-
3
- Complete API documentation for the Lua CLI framework.
4
-
5
- ## 📚 Table of Contents
6
-
7
- - [LuaSkill Class](#luaskill-class)
8
- - [LuaTool Interface](#luatool-interface)
9
- - [Zod Schema Reference](#zod-schema-reference)
10
- - [CLI Commands](#cli-commands)
11
- - [Error Handling](#error-handling)
12
- - [Type Definitions](#type-definitions)
13
-
14
- ## 🎯 LuaSkill Class
15
-
16
- The main orchestrator for managing and executing LuaTools.
17
-
18
- ### Constructor
19
-
20
- ```typescript
21
- constructor()
22
- ```
23
-
24
- Creates a new LuaSkill instance.
25
-
26
- **Example:**
27
- ```typescript
28
- const skill = new LuaSkill();
29
- ```
30
-
31
- ### Methods
32
-
33
- #### `addTool<TInput, TOutput>(tool: LuaTool<TInput, TOutput>): void`
34
-
35
- Adds a tool to the skill.
36
-
37
- **Parameters:**
38
- - `tool` - The tool to add
39
-
40
- **Example:**
41
- ```typescript
42
- const skill = new LuaSkill();
43
- skill.addTool(new MyTool());
44
- ```
45
-
46
- #### `async run(input: Record<string, any>): Promise<any>`
47
-
48
- Executes a tool with the given input.
49
-
50
- **Parameters:**
51
- - `input` - Object containing the tool name and parameters
52
-
53
- **Returns:**
54
- - Promise resolving to the tool's output
55
-
56
- **Example:**
57
- ```typescript
58
- const result = await skill.run({
59
- tool: "my_tool",
60
- param1: "value1",
61
- param2: 42
62
- });
63
- ```
64
-
65
- **Throws:**
66
- - `Error` - If tool is not found or input validation fails
67
-
68
- ## 🛠️ LuaTool Interface
69
-
70
- Interface that all tools must implement.
71
-
72
- ### Properties
73
-
74
- #### `name: string`
75
-
76
- Unique identifier for the tool.
77
-
78
- **Example:**
79
- ```typescript
80
- name = "get_weather";
81
- ```
82
-
83
- #### `description: string`
84
-
85
- Human-readable description of what the tool does.
86
-
87
- **Example:**
88
- ```typescript
89
- description = "Get current weather for a given city";
90
- ```
91
-
92
- #### `inputSchema: TInput`
93
-
94
- Zod schema defining the expected input structure.
95
-
96
- **Example:**
97
- ```typescript
98
- inputSchema = z.object({
99
- city: z.string().describe("City name"),
100
- units: z.enum(["metric", "imperial"]).optional()
101
- });
102
- ```
103
-
104
- #### `outputSchema: TOutput`
105
-
106
- Zod schema defining the expected output structure.
107
-
108
- **Example:**
109
- ```typescript
110
- outputSchema = z.object({
111
- temperature: z.number(),
112
- condition: z.string(),
113
- timestamp: z.string()
114
- });
115
- ```
116
-
117
- ### Methods
118
-
119
- #### `async execute(input: z.infer<TInput>): Promise<z.infer<TOutput>>`
120
-
121
- Executes the tool with validated input.
122
-
123
- **Parameters:**
124
- - `input` - Validated input object
125
-
126
- **Returns:**
127
- - Promise resolving to the tool's output
128
-
129
- **Example:**
130
- ```typescript
131
- async execute(input) {
132
- const weather = await this.fetchWeather(input.city);
133
- return {
134
- temperature: weather.temp,
135
- condition: weather.description,
136
- timestamp: new Date().toISOString()
137
- };
138
- }
139
- ```
140
-
141
- ## 📋 Zod Schema Reference
142
-
143
- Common Zod schema patterns for tool development.
144
-
145
- ### Basic Types
146
-
147
- ```typescript
148
- // String
149
- z.string() // Any string
150
- z.string().min(1) // Non-empty string
151
- z.string().max(100) // String with max length
152
- z.string().email() // Valid email
153
- z.string().url() // Valid URL
154
- z.string().uuid() // Valid UUID
155
- z.string().regex(/^[a-z]+$/) // Custom regex
156
-
157
- // Number
158
- z.number() // Any number
159
- z.number().int() // Integer
160
- z.number().positive() // Positive number
161
- z.number().min(0) // Non-negative
162
- z.number().max(100) // Maximum value
163
-
164
- // Boolean
165
- z.boolean() // True or false
166
-
167
- // Date
168
- z.date() // Date object
169
- z.string().datetime() // ISO datetime string
170
-
171
- // Array
172
- z.array(z.string()) // Array of strings
173
- z.array(z.number()).min(1) // Non-empty number array
174
-
175
- // Object
176
- z.object({ // Object with specific shape
177
- name: z.string(),
178
- age: z.number()
179
- })
180
- ```
181
-
182
- ### Advanced Patterns
183
-
184
- ```typescript
185
- // Optional fields
186
- z.object({
187
- required: z.string(),
188
- optional: z.string().optional(),
189
- withDefault: z.string().default("default value")
190
- })
191
-
192
- // Union types
193
- z.union([z.string(), z.number()]) // String or number
194
- z.enum(["option1", "option2"]) // Specific values
195
-
196
- // Discriminated unions
197
- z.discriminatedUnion("type", [
198
- z.object({ type: z.literal("user"), name: z.string() }),
199
- z.object({ type: z.literal("admin"), permissions: z.array(z.string()) })
200
- ])
201
-
202
- // Record types
203
- z.record(z.string(), z.any()) // Object with string keys
204
- z.record(z.string(), z.number()) // Object with number values
205
-
206
- // Tuple types
207
- z.tuple([z.string(), z.number()]) // Fixed-length array
208
-
209
- // Lazy evaluation
210
- z.lazy(() => z.object({
211
- name: z.string(),
212
- children: z.array(z.lazy(() => TreeNode))
213
- }))
214
-
215
- // Custom validation
216
- z.string().refine(
217
- (val) => val.length > 5,
218
- { message: "Must be longer than 5 characters" }
219
- )
220
-
221
- // Transform
222
- z.string().transform((val) => val.toUpperCase())
223
- ```
224
-
225
- ### Schema Composition
226
-
227
- ```typescript
228
- // Extending schemas
229
- const BaseSchema = z.object({
230
- id: z.string(),
231
- createdAt: z.date()
232
- });
233
-
234
- const UserSchema = BaseSchema.extend({
235
- name: z.string(),
236
- email: z.string().email()
237
- });
238
-
239
- // Merging schemas
240
- const SchemaA = z.object({ a: z.string() });
241
- const SchemaB = z.object({ b: z.number() });
242
- const MergedSchema = SchemaA.merge(SchemaB);
243
-
244
- // Partial schemas
245
- const PartialUser = UserSchema.partial(); // All fields optional
246
- const RequiredUser = UserSchema.required(); // All fields required
247
-
248
- // Pick and omit
249
- const NameOnly = UserSchema.pick({ name: true });
250
- const WithoutId = UserSchema.omit({ id: true });
251
- ```
252
-
253
- ## 🖥️ CLI Commands
254
-
255
- ### `lua init`
256
-
257
- Initializes a new LuaSkill project.
258
-
259
- **Usage:**
260
- ```bash
261
- lua init
262
- ```
263
-
264
- **Creates:**
265
- - `package.json` with dependencies
266
- - `tsconfig.json` for TypeScript
267
- - `tools/` directory
268
- - `services/` directory
269
- - `index.ts` template
270
-
271
- ### `lua compile`
272
-
273
- Compiles the LuaSkill and bundles dependencies.
274
-
275
- **Usage:**
276
- ```bash
277
- lua compile
278
- ```
279
-
280
- **Output:**
281
- - `.lua/deploy.json` - Compiled skill data
282
- - `.lua/*.js` - Bundled tool files
283
-
284
- **Options:**
285
- - `--watch` - Watch for changes and recompile
286
- - `--minify` - Minify output code
287
-
288
- ### `lua test`
289
-
290
- Interactive testing interface for tools.
291
-
292
- **Usage:**
293
- ```bash
294
- lua test
295
- ```
296
-
297
- **Features:**
298
- - Tool selection menu
299
- - Input validation
300
- - Real-time execution
301
- - Error reporting
302
-
303
- ### `lua deploy`
304
-
305
- Deploys the compiled skill to the Lua platform.
306
-
307
- **Usage:**
308
- ```bash
309
- lua deploy
310
- ```
311
-
312
- **Requirements:**
313
- - Valid API key (configured with `lua configure`)
314
- - Compiled skill (run `lua compile` first)
315
-
316
- ### `lua configure`
317
-
318
- Configures API keys and settings.
319
-
320
- **Usage:**
321
- ```bash
322
- lua configure
323
- ```
324
-
325
- **Stores:**
326
- - API keys securely
327
- - Platform settings
328
- - User preferences
329
-
330
- ### `lua agents`
331
-
332
- Lists available agents on the platform.
333
-
334
- **Usage:**
335
- ```bash
336
- lua agents
337
- ```
338
-
339
- **Output:**
340
- - Agent names and descriptions
341
- - Available capabilities
342
- - Status information
343
-
344
- ## ⚠️ Error Handling
345
-
346
- ### Common Error Types
347
-
348
- #### Validation Errors
349
-
350
- ```typescript
351
- // Thrown when input doesn't match schema
352
- const error = new ZodError([
353
- {
354
- code: "invalid_type",
355
- expected: "string",
356
- received: "number",
357
- path: ["name"],
358
- message: "Expected string, received number"
359
- }
360
- ]);
361
- ```
362
-
363
- #### Tool Not Found Errors
364
-
365
- ```typescript
366
- // Thrown when tool name doesn't exist
367
- throw new Error(`Tool '${toolName}' not found`);
368
- ```
369
-
370
- #### Execution Errors
371
-
372
- ```typescript
373
- // Thrown during tool execution
374
- throw new Error(`Tool execution failed: ${error.message}`);
375
- ```
376
-
377
- ### Error Handling Patterns
378
-
379
- #### 1. Graceful Error Handling
380
-
381
- ```typescript
382
- async execute(input) {
383
- try {
384
- const result = await riskyOperation(input);
385
- return { success: true, data: result };
386
- } catch (error) {
387
- return {
388
- success: false,
389
- error: error.message,
390
- timestamp: new Date().toISOString()
391
- };
392
- }
393
- }
394
- ```
395
-
396
- #### 2. Error Propagation
397
-
398
- ```typescript
399
- async execute(input) {
400
- // Let errors bubble up to be handled by the framework
401
- const result = await riskyOperation(input);
402
- return result;
403
- }
404
- ```
405
-
406
- #### 3. Custom Error Types
407
-
408
- ```typescript
409
- class ToolError extends Error {
410
- constructor(
411
- message: string,
412
- public code: string,
413
- public details?: any
414
- ) {
415
- super(message);
416
- this.name = 'ToolError';
417
- }
418
- }
419
-
420
- async execute(input) {
421
- if (!input.required) {
422
- throw new ToolError(
423
- 'Required parameter missing',
424
- 'MISSING_PARAMETER',
425
- { parameter: 'required' }
426
- );
427
- }
428
- }
429
- ```
430
-
431
- ## 📝 Type Definitions
432
-
433
- ### Core Types
434
-
435
- ```typescript
436
- // Tool interface
437
- interface LuaTool<TInput extends ZodType, TOutput extends ZodType> {
438
- name: string;
439
- description: string;
440
- inputSchema: TInput;
441
- outputSchema: TOutput;
442
- execute(input: z.infer<TInput>): Promise<z.infer<TOutput>>;
443
- }
444
-
445
- // Skill class
446
- class LuaSkill {
447
- constructor();
448
- addTool<TInput, TOutput>(tool: LuaTool<TInput, TOutput>): void;
449
- run(input: Record<string, any>): Promise<any>;
450
- }
451
-
452
- // Tool execution context
453
- interface ExecutionContext {
454
- toolName: string;
455
- input: any;
456
- startTime: number;
457
- requestId: string;
458
- }
459
-
460
- // Tool result
461
- interface ToolResult<T = any> {
462
- success: boolean;
463
- data?: T;
464
- error?: string;
465
- timestamp: string;
466
- duration?: number;
467
- }
468
- ```
469
-
470
- ### Utility Types
471
-
472
- ```typescript
473
- // Extract input type from tool
474
- type ToolInput<T> = T extends LuaTool<infer I, any> ? z.infer<I> : never;
475
-
476
- // Extract output type from tool
477
- type ToolOutput<T> = T extends LuaTool<any, infer O> ? z.infer<O> : never;
478
-
479
- // Tool registry
480
- type ToolRegistry = Record<string, LuaTool<any, any>>;
481
-
482
- // Skill configuration
483
- interface SkillConfig {
484
- name: string;
485
- version: string;
486
- description?: string;
487
- author?: string;
488
- license?: string;
489
- }
490
- ```
491
-
492
- ### Service Types
493
-
494
- ```typescript
495
- // HTTP service configuration
496
- interface HttpServiceConfig {
497
- baseURL: string;
498
- timeout?: number;
499
- headers?: Record<string, string>;
500
- retries?: number;
501
- }
502
-
503
- // Database service configuration
504
- interface DatabaseServiceConfig {
505
- connectionString: string;
506
- poolSize?: number;
507
- timeout?: number;
508
- }
509
-
510
- // Cache service configuration
511
- interface CacheServiceConfig {
512
- ttl: number;
513
- maxSize?: number;
514
- strategy?: 'lru' | 'fifo';
515
- }
516
- ```
517
-
518
- ## 🔧 Configuration
519
-
520
- ### Package.json
521
-
522
- ```json
523
- {
524
- "name": "my-lua-skill",
525
- "version": "1.0.0",
526
- "type": "module",
527
- "main": "index.ts",
528
- "scripts": {
529
- "build": "tsc",
530
- "test": "lua test",
531
- "compile": "lua compile",
532
- "deploy": "lua deploy"
533
- },
534
- "dependencies": {
535
- "lua-cli": "^1.0.0",
536
- "zod": "^3.22.0",
537
- "axios": "^1.6.0"
538
- },
539
- "devDependencies": {
540
- "@types/node": "^20.0.0",
541
- "typescript": "^5.0.0"
542
- }
543
- }
544
- ```
545
-
546
- ### TypeScript Configuration
547
-
548
- ```json
549
- {
550
- "compilerOptions": {
551
- "target": "ES2020",
552
- "module": "ESNext",
553
- "moduleResolution": "Node",
554
- "strict": true,
555
- "esModuleInterop": true,
556
- "skipLibCheck": true,
557
- "forceConsistentCasingInFileNames": true,
558
- "declaration": true,
559
- "outDir": "./dist"
560
- },
561
- "include": ["**/*.ts"],
562
- "exclude": ["node_modules", "dist"]
563
- }
564
- ```
565
-
566
- ## 📊 Performance Metrics
567
-
568
- ### Tool Execution Metrics
569
-
570
- ```typescript
571
- interface ExecutionMetrics {
572
- executionCount: number;
573
- successCount: number;
574
- errorCount: number;
575
- averageDuration: number;
576
- minDuration: number;
577
- maxDuration: number;
578
- lastExecution?: Date;
579
- }
580
- ```
581
-
582
- ### Memory Usage
583
-
584
- ```typescript
585
- interface MemoryMetrics {
586
- heapUsed: number;
587
- heapTotal: number;
588
- external: number;
589
- rss: number;
590
- }
591
- ```
592
-
593
- ### Bundle Metrics
594
-
595
- ```typescript
596
- interface BundleMetrics {
597
- totalSize: number;
598
- compressedSize: number;
599
- dependencyCount: number;
600
- toolCount: number;
601
- }
602
- ```
603
-
604
- This API reference provides complete documentation for building LuaSkills with the Lua CLI framework.