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,61 @@
1
+ /**
2
+ * Dev API Utilities
3
+ * Handles all API calls for dev mode (chat, push, update)
4
+ */
5
+ import { DevVersionResponse, UpdateDevVersionResponse, SandboxIdsMap } from '../interfaces/dev.js';
6
+ /**
7
+ * Sends a chat message to the API with skill override for sandbox testing.
8
+ *
9
+ * @param apiKey - User's API key
10
+ * @param agentId - Agent ID
11
+ * @param skillId - Skill ID
12
+ * @param sandboxId - Sandbox skill ID
13
+ * @param message - Message to send
14
+ * @param persona - Optional persona override
15
+ * @param deployData - Deploy data containing all skills
16
+ * @returns The chat response text or null if failed
17
+ */
18
+ export declare function sendChatMessage(apiKey: string, agentId: string, skillId: string, sandboxId: string, message: string, persona: string | undefined, deployData: any): Promise<string | null>;
19
+ /**
20
+ * Updates an existing sandbox version.
21
+ *
22
+ * @param apiKey - User's API key
23
+ * @param agentId - Agent ID
24
+ * @param skillId - Skill ID
25
+ * @param sandboxVersionId - Existing sandbox version ID
26
+ * @param versionData - Version data to update
27
+ * @returns Update response
28
+ */
29
+ export declare function updateDevVersion(apiKey: string, agentId: string, skillId: string, sandboxVersionId: string, versionData: any): Promise<UpdateDevVersionResponse>;
30
+ /**
31
+ * Creates a new sandbox version.
32
+ *
33
+ * @param apiKey - User's API key
34
+ * @param agentId - Agent ID
35
+ * @param skillId - Skill ID
36
+ * @param versionData - Version data to create
37
+ * @returns Dev version response
38
+ */
39
+ export declare function pushDevVersion(apiKey: string, agentId: string, skillId: string, versionData: any): Promise<DevVersionResponse>;
40
+ /**
41
+ * Pushes a single skill to the sandbox.
42
+ * Attempts to update existing sandbox version, creates new one if update fails.
43
+ *
44
+ * @param apiKey - User's API key
45
+ * @param agentId - Agent ID
46
+ * @param skillId - Skill ID
47
+ * @param skillData - Skill data to push
48
+ * @param isInitial - Whether this is the initial push (affects logging)
49
+ * @returns True if successful, false otherwise
50
+ */
51
+ export declare function pushSingleSkillToSandbox(apiKey: string, agentId: string, skillId: string, skillData: any, isInitial?: boolean): Promise<boolean>;
52
+ /**
53
+ * Pushes multiple skills to the sandbox.
54
+ *
55
+ * @param apiKey - User's API key
56
+ * @param agentId - Agent ID
57
+ * @param deployData - Deploy data containing all skills
58
+ * @param isInitial - Whether this is the initial push
59
+ * @returns Map of skill names to their sandbox IDs
60
+ */
61
+ export declare function pushSkillsToSandbox(apiKey: string, agentId: string, deployData: any, isInitial?: boolean): Promise<SandboxIdsMap>;
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Dev API Utilities
3
+ * Handles all API calls for dev mode (chat, push, update)
4
+ */
5
+ import ChatApi from '../api/chat.api.service.js';
6
+ import SkillApi from '../api/skills.api.service.js';
7
+ import { BASE_URLS } from '../config/constants.js';
8
+ import { writeProgress, writeSuccess } from './cli.js';
9
+ import { loadEnvironmentVariables } from './sandbox.js';
10
+ import { getSandboxSkillId, setSandboxSkillId, getAllSandboxSkillIds } from './sandbox-storage.js';
11
+ /**
12
+ * Sends a chat message to the API with skill override for sandbox testing.
13
+ *
14
+ * @param apiKey - User's API key
15
+ * @param agentId - Agent ID
16
+ * @param skillId - Skill ID
17
+ * @param sandboxId - Sandbox skill ID
18
+ * @param message - Message to send
19
+ * @param persona - Optional persona override
20
+ * @param deployData - Deploy data containing all skills
21
+ * @returns The chat response text or null if failed
22
+ */
23
+ export async function sendChatMessage(apiKey, agentId, skillId, sandboxId, message, persona, deployData) {
24
+ try {
25
+ // Get all sandbox skill IDs for skill override
26
+ const allSkillOverrides = await getAllSandboxSkillIds(deployData);
27
+ // If no skills found, fallback to the provided skillId and sandboxId
28
+ const skillOverride = allSkillOverrides.length > 0 ? allSkillOverrides : [
29
+ {
30
+ skillId: skillId,
31
+ sandboxId: sandboxId
32
+ }
33
+ ];
34
+ const chatRequest = {
35
+ messages: [
36
+ {
37
+ type: "text",
38
+ text: message
39
+ }
40
+ ],
41
+ navigate: true,
42
+ skillOverride: skillOverride
43
+ };
44
+ // Add persona override if provided
45
+ if (persona) {
46
+ chatRequest.personaOverride = persona;
47
+ }
48
+ const chatApi = new ChatApi(BASE_URLS.CHAT, apiKey);
49
+ const response = await chatApi.sendMessage(agentId, chatRequest);
50
+ if (!response.success) {
51
+ console.error(`❌ Chat API error: ${response.error?.message || 'Unknown error'}`);
52
+ return null;
53
+ }
54
+ return response.data?.text || null;
55
+ }
56
+ catch (error) {
57
+ console.error("❌ Error sending chat message:", error);
58
+ return null;
59
+ }
60
+ }
61
+ /**
62
+ * Updates an existing sandbox version.
63
+ *
64
+ * @param apiKey - User's API key
65
+ * @param agentId - Agent ID
66
+ * @param skillId - Skill ID
67
+ * @param sandboxVersionId - Existing sandbox version ID
68
+ * @param versionData - Version data to update
69
+ * @returns Update response
70
+ */
71
+ export async function updateDevVersion(apiKey, agentId, skillId, sandboxVersionId, versionData) {
72
+ try {
73
+ const skillsApi = new SkillApi(BASE_URLS.API, apiKey, agentId);
74
+ const response = await skillsApi.updateDevSkill(skillId, sandboxVersionId, versionData);
75
+ if (response.success) {
76
+ return {
77
+ success: true,
78
+ data: response.data
79
+ };
80
+ }
81
+ else {
82
+ return {
83
+ success: false,
84
+ error: {
85
+ message: response.error?.message || 'Unknown error',
86
+ error: response.error?.message || 'Unknown error',
87
+ statusCode: response.error?.statusCode || 500
88
+ }
89
+ };
90
+ }
91
+ }
92
+ catch (error) {
93
+ console.error("Network error updating dev version:", error);
94
+ return {
95
+ success: false,
96
+ error: {
97
+ message: "Network error",
98
+ error: error instanceof Error ? error.message : "Failed to connect to server",
99
+ statusCode: 500
100
+ }
101
+ };
102
+ }
103
+ }
104
+ /**
105
+ * Creates a new sandbox version.
106
+ *
107
+ * @param apiKey - User's API key
108
+ * @param agentId - Agent ID
109
+ * @param skillId - Skill ID
110
+ * @param versionData - Version data to create
111
+ * @returns Dev version response
112
+ */
113
+ export async function pushDevVersion(apiKey, agentId, skillId, versionData) {
114
+ try {
115
+ const skillsApi = new SkillApi(BASE_URLS.API, apiKey, agentId);
116
+ const response = await skillsApi.pushDevSkill(skillId, versionData);
117
+ if (response.success) {
118
+ return {
119
+ success: true,
120
+ data: response.data
121
+ };
122
+ }
123
+ else {
124
+ return {
125
+ success: false,
126
+ error: {
127
+ message: response.error?.message || 'Unknown error',
128
+ error: response.error?.message || 'Unknown error',
129
+ statusCode: response.error?.statusCode || 500
130
+ }
131
+ };
132
+ }
133
+ }
134
+ catch (error) {
135
+ console.error("❌ Network error pushing dev version:", error);
136
+ return {
137
+ success: false,
138
+ error: {
139
+ message: "Network error",
140
+ error: error instanceof Error ? error.message : "Failed to connect to server",
141
+ statusCode: 500
142
+ }
143
+ };
144
+ }
145
+ }
146
+ /**
147
+ * Pushes a single skill to the sandbox.
148
+ * Attempts to update existing sandbox version, creates new one if update fails.
149
+ *
150
+ * @param apiKey - User's API key
151
+ * @param agentId - Agent ID
152
+ * @param skillId - Skill ID
153
+ * @param skillData - Skill data to push
154
+ * @param isInitial - Whether this is the initial push (affects logging)
155
+ * @returns True if successful, false otherwise
156
+ */
157
+ export async function pushSingleSkillToSandbox(apiKey, agentId, skillId, skillData, isInitial = false) {
158
+ const skillName = skillData.name || 'Unknown Skill';
159
+ const sandboxSkillId = await getSandboxSkillId(skillName);
160
+ // Load environment variables
161
+ const envVars = loadEnvironmentVariables();
162
+ const payloadWithNameAndEnv = {
163
+ ...skillData,
164
+ name: skillName,
165
+ env: envVars
166
+ };
167
+ if (sandboxSkillId) {
168
+ // Try to update existing sandbox version
169
+ if (!isInitial) {
170
+ writeProgress("🔄 Updating existing sandbox version...");
171
+ }
172
+ const updateResult = await updateDevVersion(apiKey, agentId, skillId, sandboxSkillId, payloadWithNameAndEnv);
173
+ if (updateResult.success && updateResult.data) {
174
+ if (!isInitial) {
175
+ // writeSuccess(`✅ Version ${updateResult.data.version} updated in sandbox successfully`);
176
+ // writeSuccess(`🔑 Sandbox Skill ID: ${updateResult.data.skillId}`);
177
+ }
178
+ return true;
179
+ }
180
+ else if (updateResult.error) {
181
+ writeProgress("⚠️ Failed to update existing sandbox, creating new one...");
182
+ console.error(`❌ Sandbox update failed: ${updateResult.error.message}`);
183
+ if (updateResult.error.error) {
184
+ console.error(` Details: ${updateResult.error.error}`);
185
+ }
186
+ // If skill not found during update, give helpful guidance before trying to create
187
+ if (updateResult.error.message.includes('Skill not found') || updateResult.error.statusCode === 400 || updateResult.error.statusCode === 404) {
188
+ console.error('\n💡 The skill doesn\'t exist on the server.');
189
+ console.error(' Please run "lua push" first to deploy your skill, then try "lua dev" again.\n');
190
+ }
191
+ // Fall through to create new sandbox
192
+ }
193
+ }
194
+ // Create new sandbox version (either no existing ID or update failed)
195
+ if (!isInitial) {
196
+ writeProgress("🔄 Creating new sandbox version...");
197
+ }
198
+ const result = await pushDevVersion(apiKey, agentId, skillId, payloadWithNameAndEnv);
199
+ if (result.success && result.data) {
200
+ // Store the new sandbox skill ID
201
+ await setSandboxSkillId(result.data.skillId, skillName);
202
+ if (!isInitial) {
203
+ writeSuccess(`✅ Version ${result.data.version} pushed to sandbox successfully`);
204
+ writeSuccess(`🔑 Sandbox Skill ID: ${result.data.skillId}`);
205
+ }
206
+ return true;
207
+ }
208
+ else if (result.error) {
209
+ console.error(`❌ Sandbox creation failed: ${result.error.message}`);
210
+ if (result.error.error) {
211
+ console.error(` Details: ${result.error.error}`);
212
+ }
213
+ if (result.error.statusCode) {
214
+ console.error(` Status Code: ${result.error.statusCode}`);
215
+ }
216
+ // If skill not found, give helpful guidance
217
+ if (result.error.message.includes('Skill not found') || result.error.statusCode === 400 || result.error.statusCode === 404) {
218
+ console.error('\n💡 The skill hasn\'t been deployed to the server yet.');
219
+ console.error(' Please run "lua push" first to deploy your skill, then try "lua dev" again.');
220
+ }
221
+ return false;
222
+ }
223
+ else {
224
+ console.error("❌ Failed to push version to sandbox. Please try again.");
225
+ return false;
226
+ }
227
+ }
228
+ /**
229
+ * Pushes multiple skills to the sandbox.
230
+ *
231
+ * @param apiKey - User's API key
232
+ * @param agentId - Agent ID
233
+ * @param deployData - Deploy data containing all skills
234
+ * @param isInitial - Whether this is the initial push
235
+ * @returns Map of skill names to their sandbox IDs
236
+ */
237
+ export async function pushSkillsToSandbox(apiKey, agentId, deployData, isInitial = false) {
238
+ const sandboxIds = {};
239
+ if (!deployData.skills || !Array.isArray(deployData.skills)) {
240
+ throw new Error("No skills found in deploy data");
241
+ }
242
+ for (const skill of deployData.skills) {
243
+ if (!skill.skillId) {
244
+ console.warn(`⚠️ Skipping skill ${skill.name} - no skillId found`);
245
+ continue;
246
+ }
247
+ try {
248
+ const success = await pushSingleSkillToSandbox(apiKey, agentId, skill.skillId, skill, isInitial);
249
+ if (success) {
250
+ // Get the sandbox ID for this skill
251
+ const sandboxId = await getSandboxSkillId(skill.name);
252
+ if (sandboxId) {
253
+ sandboxIds[skill.name] = sandboxId;
254
+ }
255
+ }
256
+ }
257
+ catch (error) {
258
+ console.error(`❌ Failed to push skill ${skill.name}:`, error);
259
+ }
260
+ }
261
+ return sandboxIds;
262
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Dev Helper Utilities
3
+ * Small helper functions for dev mode
4
+ */
5
+ /**
6
+ * Reads the version from config (handles both old and new formats).
7
+ *
8
+ * @param config - The skill configuration
9
+ * @returns The version string
10
+ */
11
+ export declare function readConfigVersion(config: any): string;
12
+ /**
13
+ * Reads the deploy.json file from .lua directory.
14
+ *
15
+ * @returns Parsed deploy data or null if not found
16
+ */
17
+ export declare function readDeployJson(): any | null;
18
+ /**
19
+ * Extracts skill ID from config (handles both old and new formats).
20
+ * For multi-skill projects, returns the first skill's ID.
21
+ *
22
+ * @param config - The skill configuration
23
+ * @returns The skill ID or null if not found
24
+ */
25
+ export declare function extractSkillId(config: any): string | null;
26
+ /**
27
+ * Validates that the configuration has required fields.
28
+ *
29
+ * @param config - The skill configuration to validate
30
+ * @throws Error if configuration is invalid
31
+ */
32
+ export declare function validateConfig(config: any): void;
33
+ /**
34
+ * Validates that deploy data has skills.
35
+ *
36
+ * @param deployData - The deploy data to validate
37
+ * @throws Error if deploy data is invalid
38
+ */
39
+ export declare function validateDeployData(deployData: any): void;
40
+ /**
41
+ * Validates that config has required agent information.
42
+ *
43
+ * @param config - The skill configuration
44
+ * @throws Error if agent info is missing
45
+ */
46
+ export declare function validateAgentConfig(config: any): void;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Dev Helper Utilities
3
+ * Small helper functions for dev mode
4
+ */
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { DEV_DEFAULTS } from '../config/dev.constants.js';
8
+ /**
9
+ * Reads the version from config (handles both old and new formats).
10
+ *
11
+ * @param config - The skill configuration
12
+ * @returns The version string
13
+ */
14
+ export function readConfigVersion(config) {
15
+ let version = config?.skill?.version; // Legacy format
16
+ if (!version && config?.skills && config.skills.length > 0) {
17
+ version = config.skills[0].version; // New format - use first skill's version
18
+ }
19
+ return version || DEV_DEFAULTS.VERSION;
20
+ }
21
+ /**
22
+ * Reads the deploy.json file from .lua directory.
23
+ *
24
+ * @returns Parsed deploy data or null if not found
25
+ */
26
+ export function readDeployJson() {
27
+ const deployPath = path.join(process.cwd(), '.lua', 'deploy.json');
28
+ if (!fs.existsSync(deployPath)) {
29
+ return null;
30
+ }
31
+ const deployContent = fs.readFileSync(deployPath, 'utf8');
32
+ return JSON.parse(deployContent);
33
+ }
34
+ /**
35
+ * Extracts skill ID from config (handles both old and new formats).
36
+ * For multi-skill projects, returns the first skill's ID.
37
+ *
38
+ * @param config - The skill configuration
39
+ * @returns The skill ID or null if not found
40
+ */
41
+ export function extractSkillId(config) {
42
+ let skillId = config?.skill?.skillId; // Legacy format
43
+ if (!skillId && config?.skills && config.skills.length > 0) {
44
+ skillId = config.skills[0].skillId; // New format - use first skill
45
+ }
46
+ return skillId || null;
47
+ }
48
+ /**
49
+ * Validates that the configuration has required fields.
50
+ *
51
+ * @param config - The skill configuration to validate
52
+ * @throws Error if configuration is invalid
53
+ */
54
+ export function validateConfig(config) {
55
+ if (!config) {
56
+ throw new Error("❌ No lua.skill.yaml found. Please run this command from a skill directory.");
57
+ }
58
+ }
59
+ /**
60
+ * Validates that deploy data has skills.
61
+ *
62
+ * @param deployData - The deploy data to validate
63
+ * @throws Error if deploy data is invalid
64
+ */
65
+ export function validateDeployData(deployData) {
66
+ if (!deployData) {
67
+ throw new Error("❌ No deploy.json found. Compilation may have failed.");
68
+ }
69
+ if (!deployData.skills || !Array.isArray(deployData.skills) || deployData.skills.length === 0) {
70
+ throw new Error("❌ No skills found in deploy.json. Compilation may have failed.");
71
+ }
72
+ }
73
+ /**
74
+ * Validates that config has required agent information.
75
+ *
76
+ * @param config - The skill configuration
77
+ * @throws Error if agent info is missing
78
+ */
79
+ export function validateAgentConfig(config) {
80
+ if (!config.agent?.agentId) {
81
+ throw new Error("❌ Missing agentId in skill configuration");
82
+ }
83
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Dev Server Utilities
3
+ * Handles HTTP server, WebSocket connections, and all HTTP endpoints for dev mode
4
+ */
5
+ import { WebSocketServer } from 'ws';
6
+ /**
7
+ * Server instance with WebSocket and broadcast capabilities
8
+ */
9
+ export interface DevServer {
10
+ server: any;
11
+ wss: WebSocketServer;
12
+ broadcastLog: (message: string, subType?: 'info' | 'warn' | 'error' | 'debug') => void;
13
+ }
14
+ /**
15
+ * Creates and starts the dev web server with chat interface and tool testing.
16
+ *
17
+ * @param apiKey - User's API key
18
+ * @param agentId - Agent ID
19
+ * @param skillId - Skill ID
20
+ * @param sandboxId - Sandbox skill ID
21
+ * @param port - Port to run server on
22
+ * @returns Server instance with WebSocket and broadcast function
23
+ */
24
+ export declare function createChatServer(apiKey: string, agentId: string, skillId: string, sandboxId: string, port: number): DevServer;