lua-cli 3.5.0-alpha.3 → 3.5.0-beta.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 (465) hide show
  1. package/README.md +137 -689
  2. package/dist/api/agent.api.service.d.ts +1 -8
  3. package/dist/api/agent.api.service.js +1 -11
  4. package/dist/api/agent.api.service.js.map +1 -1
  5. package/dist/api/auth.api.service.d.ts +1 -1
  6. package/dist/api/auth.api.service.js +1 -1
  7. package/dist/api/auth.api.service.js.map +1 -1
  8. package/dist/api/backup.api.service.d.ts +80 -0
  9. package/dist/api/backup.api.service.js +101 -0
  10. package/dist/api/backup.api.service.js.map +1 -0
  11. package/dist/api/basket.api.service.d.ts +4 -5
  12. package/dist/api/basket.api.service.js +13 -18
  13. package/dist/api/basket.api.service.js.map +1 -1
  14. package/dist/api/cdn.api.service.d.ts +2 -0
  15. package/dist/api/cdn.api.service.js +2 -0
  16. package/dist/api/cdn.api.service.js.map +1 -1
  17. package/dist/api/chat.api.service.d.ts +10 -2
  18. package/dist/api/chat.api.service.js +21 -2
  19. package/dist/api/chat.api.service.js.map +1 -1
  20. package/dist/api/credentials.js +5 -8
  21. package/dist/api/credentials.js.map +1 -1
  22. package/dist/api/custom.data.api.service.d.ts +3 -3
  23. package/dist/api/custom.data.api.service.js +9 -10
  24. package/dist/api/custom.data.api.service.js.map +1 -1
  25. package/dist/api/developer.api.service.d.ts +1 -1
  26. package/dist/api/developer.api.service.js +1 -1
  27. package/dist/api/developer.api.service.js.map +1 -1
  28. package/dist/api/http.client.js.map +1 -0
  29. package/dist/api/job.api.service.d.ts +2 -2
  30. package/dist/api/job.api.service.js +2 -2
  31. package/dist/api/job.api.service.js.map +1 -1
  32. package/dist/api/logs.api.service.d.ts +1 -1
  33. package/dist/api/logs.api.service.js +1 -1
  34. package/dist/api/logs.api.service.js.map +1 -1
  35. package/dist/api/marketplace.api.service.d.ts +6 -6
  36. package/dist/api/marketplace.api.service.js.map +1 -1
  37. package/dist/api/order.api.service.d.ts +3 -4
  38. package/dist/api/order.api.service.js +8 -10
  39. package/dist/api/order.api.service.js.map +1 -1
  40. package/dist/api/persona.api.service.d.ts +1 -1
  41. package/dist/api/persona.api.service.js +1 -1
  42. package/dist/api/persona.api.service.js.map +1 -1
  43. package/dist/api/postprocessor.api.service.d.ts +1 -1
  44. package/dist/api/postprocessor.api.service.js +1 -1
  45. package/dist/api/postprocessor.api.service.js.map +1 -1
  46. package/dist/api/preprocessor.api.service.d.ts +1 -1
  47. package/dist/api/preprocessor.api.service.js +1 -1
  48. package/dist/api/preprocessor.api.service.js.map +1 -1
  49. package/dist/api/products.api.service.d.ts +4 -4
  50. package/dist/api/products.api.service.js +6 -6
  51. package/dist/api/products.api.service.js.map +1 -1
  52. package/dist/api/resource.api.service.d.ts +76 -0
  53. package/dist/api/resource.api.service.js +74 -0
  54. package/dist/api/resource.api.service.js.map +1 -0
  55. package/dist/api/skills.api.service.d.ts +7 -15
  56. package/dist/api/skills.api.service.js +1 -1
  57. package/dist/api/skills.api.service.js.map +1 -1
  58. package/dist/api/tool.api.service.d.ts +1 -1
  59. package/dist/api/tool.api.service.js +1 -1
  60. package/dist/api/tool.api.service.js.map +1 -1
  61. package/dist/api/unifiedto.api.service.d.ts +1 -1
  62. package/dist/api/unifiedto.api.service.js +1 -1
  63. package/dist/api/unifiedto.api.service.js.map +1 -1
  64. package/dist/api/user.data.api.service.d.ts +7 -8
  65. package/dist/api/user.data.api.service.js +2 -3
  66. package/dist/api/user.data.api.service.js.map +1 -1
  67. package/dist/api/webhook.api.service.d.ts +1 -1
  68. package/dist/api/webhook.api.service.js +1 -1
  69. package/dist/api/webhook.api.service.js.map +1 -1
  70. package/dist/api/whatsapp-templates.api.service.d.ts +1 -1
  71. package/dist/api/whatsapp-templates.api.service.js +1 -1
  72. package/dist/api/whatsapp-templates.api.service.js.map +1 -1
  73. package/dist/api-exports.d.ts +14 -12
  74. package/dist/api-exports.js +8 -8
  75. package/dist/api-exports.js.map +1 -1
  76. package/dist/cli/command-definitions.js +32 -17
  77. package/dist/cli/command-definitions.js.map +1 -1
  78. package/dist/commands/admin.js +3 -24
  79. package/dist/commands/admin.js.map +1 -1
  80. package/dist/commands/agents.d.ts +8 -7
  81. package/dist/commands/agents.js +63 -21
  82. package/dist/commands/agents.js.map +1 -1
  83. package/dist/commands/channels.js +11 -23
  84. package/dist/commands/channels.js.map +1 -1
  85. package/dist/commands/chat.js +33 -47
  86. package/dist/commands/chat.js.map +1 -1
  87. package/dist/commands/chatClear.js +11 -41
  88. package/dist/commands/chatClear.js.map +1 -1
  89. package/dist/commands/compile.d.ts +26 -23
  90. package/dist/commands/compile.js +98 -403
  91. package/dist/commands/compile.js.map +1 -1
  92. package/dist/commands/completion.js +1 -1
  93. package/dist/commands/completion.js.map +1 -1
  94. package/dist/commands/deploy.js +55 -25
  95. package/dist/commands/deploy.js.map +1 -1
  96. package/dist/commands/dev.js +29 -45
  97. package/dist/commands/dev.js.map +1 -1
  98. package/dist/commands/env.js +12 -25
  99. package/dist/commands/env.js.map +1 -1
  100. package/dist/commands/evals.js +3 -20
  101. package/dist/commands/evals.js.map +1 -1
  102. package/dist/commands/features.js +10 -23
  103. package/dist/commands/features.js.map +1 -1
  104. package/dist/commands/index.d.ts +1 -0
  105. package/dist/commands/index.js +1 -0
  106. package/dist/commands/index.js.map +1 -1
  107. package/dist/commands/init.d.ts +1 -0
  108. package/dist/commands/init.js +135 -19
  109. package/dist/commands/init.js.map +1 -1
  110. package/dist/commands/integrations.js +26 -37
  111. package/dist/commands/integrations.js.map +1 -1
  112. package/dist/commands/jobs.js +32 -56
  113. package/dist/commands/jobs.js.map +1 -1
  114. package/dist/commands/logs.js +9 -20
  115. package/dist/commands/logs.js.map +1 -1
  116. package/dist/commands/marketplace.js +34 -52
  117. package/dist/commands/marketplace.js.map +1 -1
  118. package/dist/commands/mcp.js +10 -23
  119. package/dist/commands/mcp.js.map +1 -1
  120. package/dist/commands/persona.js +43 -74
  121. package/dist/commands/persona.js.map +1 -1
  122. package/dist/commands/postprocessors.js +15 -28
  123. package/dist/commands/postprocessors.js.map +1 -1
  124. package/dist/commands/preprocessors.js +15 -28
  125. package/dist/commands/preprocessors.js.map +1 -1
  126. package/dist/commands/production.js +30 -63
  127. package/dist/commands/production.js.map +1 -1
  128. package/dist/commands/push.js +294 -1241
  129. package/dist/commands/push.js.map +1 -1
  130. package/dist/commands/pushBackup.d.ts +22 -0
  131. package/dist/commands/pushBackup.js +133 -0
  132. package/dist/commands/pushBackup.js.map +1 -0
  133. package/dist/commands/resources.js +29 -72
  134. package/dist/commands/resources.js.map +1 -1
  135. package/dist/commands/skills.d.ts +1 -1
  136. package/dist/commands/skills.js +58 -70
  137. package/dist/commands/skills.js.map +1 -1
  138. package/dist/commands/sync.d.ts +1 -3
  139. package/dist/commands/sync.js +12 -24
  140. package/dist/commands/sync.js.map +1 -1
  141. package/dist/commands/test.js +135 -104
  142. package/dist/commands/test.js.map +1 -1
  143. package/dist/commands/webhooks.js +15 -28
  144. package/dist/commands/webhooks.js.map +1 -1
  145. package/dist/compiler/agent-traverser.d.ts +104 -0
  146. package/dist/compiler/agent-traverser.js +311 -0
  147. package/dist/compiler/agent-traverser.js.map +1 -0
  148. package/dist/compiler/bundler.d.ts +42 -0
  149. package/dist/compiler/bundler.js +187 -0
  150. package/dist/compiler/bundler.js.map +1 -0
  151. package/dist/compiler/compiler.d.ts +177 -0
  152. package/dist/compiler/compiler.js +580 -0
  153. package/dist/compiler/compiler.js.map +1 -0
  154. package/dist/compiler/index.d.ts +36 -0
  155. package/dist/compiler/index.js +42 -0
  156. package/dist/compiler/index.js.map +1 -0
  157. package/dist/compiler/plugins/base.d.ts +264 -0
  158. package/dist/compiler/plugins/base.js +307 -0
  159. package/dist/compiler/plugins/base.js.map +1 -0
  160. package/dist/compiler/plugins/job.plugin.d.ts +33 -0
  161. package/dist/compiler/plugins/job.plugin.js +143 -0
  162. package/dist/compiler/plugins/job.plugin.js.map +1 -0
  163. package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
  164. package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
  165. package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
  166. package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
  167. package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
  168. package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
  169. package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
  170. package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
  171. package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
  172. package/dist/compiler/plugins/processor-base.d.ts +16 -0
  173. package/dist/compiler/plugins/processor-base.js +34 -0
  174. package/dist/compiler/plugins/processor-base.js.map +1 -0
  175. package/dist/compiler/plugins/registry.d.ts +61 -0
  176. package/dist/compiler/plugins/registry.js +107 -0
  177. package/dist/compiler/plugins/registry.js.map +1 -0
  178. package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
  179. package/dist/compiler/plugins/skill.plugin.js +243 -0
  180. package/dist/compiler/plugins/skill.plugin.js.map +1 -0
  181. package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
  182. package/dist/compiler/plugins/tool.plugin.js +279 -0
  183. package/dist/compiler/plugins/tool.plugin.js.map +1 -0
  184. package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
  185. package/dist/compiler/plugins/webhook.plugin.js +127 -0
  186. package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
  187. package/dist/compiler/source-writer.d.ts +98 -0
  188. package/dist/compiler/source-writer.js +223 -0
  189. package/dist/compiler/source-writer.js.map +1 -0
  190. package/dist/compiler/types.d.ts +289 -0
  191. package/dist/compiler/types.js +20 -0
  192. package/dist/compiler/types.js.map +1 -0
  193. package/dist/compiler/utils/ast-helpers.d.ts +57 -0
  194. package/dist/compiler/utils/ast-helpers.js +164 -0
  195. package/dist/compiler/utils/ast-helpers.js.map +1 -0
  196. package/dist/compiler/utils/common.d.ts +23 -0
  197. package/dist/compiler/utils/common.js +66 -0
  198. package/dist/compiler/utils/common.js.map +1 -0
  199. package/dist/compiler/utils/file-discovery.d.ts +34 -0
  200. package/dist/compiler/utils/file-discovery.js +68 -0
  201. package/dist/compiler/utils/file-discovery.js.map +1 -0
  202. package/dist/compiler/utils/path-resolver.d.ts +25 -0
  203. package/dist/compiler/utils/path-resolver.js +66 -0
  204. package/dist/compiler/utils/path-resolver.js.map +1 -0
  205. package/dist/compiler/utils/schema-converter.d.ts +26 -0
  206. package/dist/compiler/utils/schema-converter.js +94 -0
  207. package/dist/compiler/utils/schema-converter.js.map +1 -0
  208. package/dist/config/compile.constants.d.ts +2 -22
  209. package/dist/config/compile.constants.js +2 -49
  210. package/dist/config/compile.constants.js.map +1 -1
  211. package/dist/config/constants.d.ts +18 -2
  212. package/dist/config/constants.js +28 -8
  213. package/dist/config/constants.js.map +1 -1
  214. package/dist/config/dev.constants.d.ts +0 -10
  215. package/dist/config/dev.constants.js +0 -10
  216. package/dist/config/dev.constants.js.map +1 -1
  217. package/dist/index.js +7 -0
  218. package/dist/index.js.map +1 -1
  219. package/dist/instances/basket.instance.js.map +1 -0
  220. package/dist/instances/data.entry.instance.js.map +1 -0
  221. package/dist/instances/job.instance.js.map +1 -0
  222. package/dist/instances/order.instance.js.map +1 -0
  223. package/dist/instances/product.instance.js.map +1 -0
  224. package/dist/instances/product.pagination.instance.js.map +1 -0
  225. package/dist/instances/product.search.instance.js.map +1 -0
  226. package/dist/instances/user.instance.js.map +1 -0
  227. package/dist/interfaces/admin.d.ts +0 -38
  228. package/dist/interfaces/backup.d.ts +125 -0
  229. package/dist/interfaces/backup.js +8 -0
  230. package/dist/interfaces/backup.js.map +1 -0
  231. package/dist/interfaces/baskets.d.ts +0 -56
  232. package/dist/interfaces/common.d.ts +1 -0
  233. package/dist/interfaces/deploy.d.ts +0 -15
  234. package/dist/interfaces/index.d.ts +1 -1
  235. package/dist/interfaces/marketplace.d.ts +51 -0
  236. package/dist/interfaces/marketplace.js +1 -1
  237. package/dist/interfaces/marketplace.js.map +1 -1
  238. package/dist/interfaces/message.d.ts +0 -3
  239. package/dist/interfaces/orders.d.ts +0 -24
  240. package/dist/interfaces/postprocessors.d.ts +0 -18
  241. package/dist/interfaces/preprocessors.d.ts +0 -18
  242. package/dist/interfaces/skills.d.ts +61 -0
  243. package/dist/interfaces/user.d.ts +25 -0
  244. package/dist/interfaces/webhooks.d.ts +0 -9
  245. package/dist/primitives/base.handler.d.ts +106 -0
  246. package/dist/primitives/base.handler.js +370 -0
  247. package/dist/primitives/base.handler.js.map +1 -0
  248. package/dist/primitives/index.d.ts +47 -0
  249. package/dist/primitives/index.js +78 -0
  250. package/dist/primitives/index.js.map +1 -0
  251. package/dist/primitives/job.handler.d.ts +52 -0
  252. package/dist/primitives/job.handler.js +118 -0
  253. package/dist/primitives/job.handler.js.map +1 -0
  254. package/dist/primitives/mcp-server.handler.d.ts +54 -0
  255. package/dist/primitives/mcp-server.handler.js +91 -0
  256. package/dist/primitives/mcp-server.handler.js.map +1 -0
  257. package/dist/primitives/postprocessor.handler.d.ts +49 -0
  258. package/dist/primitives/postprocessor.handler.js +81 -0
  259. package/dist/primitives/postprocessor.handler.js.map +1 -0
  260. package/dist/primitives/preprocessor.handler.d.ts +54 -0
  261. package/dist/primitives/preprocessor.handler.js +95 -0
  262. package/dist/primitives/preprocessor.handler.js.map +1 -0
  263. package/dist/primitives/skill.handler.d.ts +44 -0
  264. package/dist/primitives/skill.handler.js +192 -0
  265. package/dist/primitives/skill.handler.js.map +1 -0
  266. package/dist/primitives/types.d.ts +72 -0
  267. package/dist/primitives/types.js +17 -0
  268. package/dist/primitives/types.js.map +1 -0
  269. package/dist/primitives/webhook.handler.d.ts +50 -0
  270. package/dist/primitives/webhook.handler.js +96 -0
  271. package/dist/primitives/webhook.handler.js.map +1 -0
  272. package/dist/services/auth.js +1 -2
  273. package/dist/services/auth.js.map +1 -1
  274. package/dist/services/sandbox.service.d.ts +103 -0
  275. package/dist/services/sandbox.service.js +479 -0
  276. package/dist/services/sandbox.service.js.map +1 -0
  277. package/dist/types/api-contracts.d.ts +1 -1
  278. package/dist/types/index.d.ts +2 -1
  279. package/dist/types/index.js.map +1 -1
  280. package/dist/types/skill.d.ts +8 -2
  281. package/dist/types/skill.js +8 -0
  282. package/dist/types/skill.js.map +1 -1
  283. package/dist/types/yaml.types.d.ts +69 -0
  284. package/dist/types/yaml.types.js +6 -0
  285. package/dist/types/yaml.types.js.map +1 -0
  286. package/dist/utils/artifact-loader.d.ts +108 -0
  287. package/dist/utils/artifact-loader.js +188 -0
  288. package/dist/utils/artifact-loader.js.map +1 -0
  289. package/dist/utils/backup-helpers.d.ts +122 -0
  290. package/dist/utils/backup-helpers.js +274 -0
  291. package/dist/utils/backup-helpers.js.map +1 -0
  292. package/dist/utils/cli.d.ts +8 -0
  293. package/dist/utils/cli.js +19 -2
  294. package/dist/utils/cli.js.map +1 -1
  295. package/dist/utils/command-utils.d.ts +42 -0
  296. package/dist/utils/command-utils.js +83 -0
  297. package/dist/utils/command-utils.js.map +1 -0
  298. package/dist/utils/deploy-helpers.d.ts +0 -29
  299. package/dist/utils/deploy-helpers.js +0 -70
  300. package/dist/utils/deploy-helpers.js.map +1 -1
  301. package/dist/utils/dev-api.d.ts +3 -99
  302. package/dist/utils/dev-api.js +3 -430
  303. package/dist/utils/dev-api.js.map +1 -1
  304. package/dist/utils/dev-server.d.ts +3 -1
  305. package/dist/utils/dev-server.js +69 -145
  306. package/dist/utils/dev-server.js.map +1 -1
  307. package/dist/utils/dev-watcher.d.ts +0 -1
  308. package/dist/utils/dev-watcher.js +23 -8
  309. package/dist/utils/dev-watcher.js.map +1 -1
  310. package/dist/utils/env-loader.utils.d.ts +10 -1
  311. package/dist/utils/env-loader.utils.js +39 -31
  312. package/dist/utils/env-loader.utils.js.map +1 -1
  313. package/dist/utils/files.d.ts +47 -3
  314. package/dist/utils/files.js +98 -40
  315. package/dist/utils/files.js.map +1 -1
  316. package/dist/utils/init-agent.js +1 -2
  317. package/dist/utils/init-agent.js.map +1 -1
  318. package/dist/utils/init-helpers.d.ts +2 -10
  319. package/dist/utils/init-helpers.js +9 -17
  320. package/dist/utils/init-helpers.js.map +1 -1
  321. package/dist/utils/init-prompts.d.ts +0 -8
  322. package/dist/utils/init-prompts.js +0 -22
  323. package/dist/utils/init-prompts.js.map +1 -1
  324. package/dist/utils/prompt-handler.d.ts +3 -0
  325. package/dist/utils/prompt-handler.js +13 -0
  326. package/dist/utils/prompt-handler.js.map +1 -1
  327. package/dist/utils/sandbox-storage.d.ts +6 -5
  328. package/dist/utils/sandbox-storage.js +12 -12
  329. package/dist/utils/sandbox-storage.js.map +1 -1
  330. package/dist/utils/sandbox.d.ts +7 -30
  331. package/dist/utils/sandbox.js +247 -223
  332. package/dist/utils/sandbox.js.map +1 -1
  333. package/dist/utils/semver.d.ts +12 -0
  334. package/dist/utils/semver.js +23 -0
  335. package/dist/utils/semver.js.map +1 -1
  336. package/dist/utils/sync-display.d.ts +9 -0
  337. package/dist/utils/sync-display.js +67 -0
  338. package/dist/utils/sync-display.js.map +1 -0
  339. package/dist/utils/sync-fetch.d.ts +23 -0
  340. package/dist/utils/sync-fetch.js +64 -0
  341. package/dist/utils/sync-fetch.js.map +1 -0
  342. package/dist/utils/sync-helpers.d.ts +4 -59
  343. package/dist/utils/sync-helpers.js +4 -206
  344. package/dist/utils/sync-helpers.js.map +1 -1
  345. package/dist/web/app.css +912 -186
  346. package/dist/web/app.js +46 -46
  347. package/docs/API_INDEX.md +100 -0
  348. package/docs/API_REFERENCE.md +773 -0
  349. package/docs/CLI_REFERENCE.md +924 -0
  350. package/docs/GETTING_STARTED.md +862 -0
  351. package/docs/README.md +270 -0
  352. package/docs/api/AI.md +882 -0
  353. package/docs/api/Baskets.md +511 -0
  354. package/docs/api/CDN.md +524 -0
  355. package/docs/api/Data.md +446 -0
  356. package/docs/api/Jobs.md +524 -0
  357. package/docs/api/LuaAgent.md +454 -0
  358. package/docs/api/LuaJob.md +604 -0
  359. package/docs/api/LuaSkill.md +396 -0
  360. package/docs/api/LuaTool.md +521 -0
  361. package/docs/api/LuaWebhook.md +601 -0
  362. package/docs/api/Orders.md +514 -0
  363. package/docs/api/PostProcessor.md +565 -0
  364. package/docs/api/PreProcessor.md +630 -0
  365. package/docs/api/Products.md +507 -0
  366. package/docs/api/Templates.md +662 -0
  367. package/docs/api/User.md +567 -0
  368. package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
  369. package/docs/compiler-v2/ASSESSMENT.md +205 -0
  370. package/docs/compiler-v2/TEST_PLAN.md +306 -0
  371. package/package.json +3 -7
  372. package/template/tsconfig.json +1 -1
  373. package/dist/common/basket.instance.js.map +0 -1
  374. package/dist/common/data.entry.instance.js.map +0 -1
  375. package/dist/common/http.client.js.map +0 -1
  376. package/dist/common/job.instance.js.map +0 -1
  377. package/dist/common/order.instance.js.map +0 -1
  378. package/dist/common/product.instance.js.map +0 -1
  379. package/dist/common/product.pagination.instance.js.map +0 -1
  380. package/dist/common/product.search.instance.js.map +0 -1
  381. package/dist/common/user.instance.js.map +0 -1
  382. package/dist/config/auth.constants.d.ts +0 -11
  383. package/dist/config/auth.constants.js +0 -12
  384. package/dist/config/auth.constants.js.map +0 -1
  385. package/dist/config/init.constants.d.ts +0 -15
  386. package/dist/config/init.constants.js +0 -20
  387. package/dist/config/init.constants.js.map +0 -1
  388. package/dist/interfaces/compile.d.ts +0 -12
  389. package/dist/interfaces/compile.js +0 -5
  390. package/dist/interfaces/compile.js.map +0 -1
  391. package/dist/types/compile.types.d.ts +0 -131
  392. package/dist/types/compile.types.js +0 -6
  393. package/dist/types/compile.types.js.map +0 -1
  394. package/dist/utils/agent-code-utils.d.ts +0 -25
  395. package/dist/utils/agent-code-utils.js +0 -107
  396. package/dist/utils/agent-code-utils.js.map +0 -1
  397. package/dist/utils/bundling.d.ts +0 -89
  398. package/dist/utils/bundling.js +0 -1068
  399. package/dist/utils/bundling.js.map +0 -1
  400. package/dist/utils/compile.d.ts +0 -116
  401. package/dist/utils/compile.js +0 -1062
  402. package/dist/utils/compile.js.map +0 -1
  403. package/dist/utils/deploy-api.d.ts +0 -26
  404. package/dist/utils/deploy-api.js +0 -54
  405. package/dist/utils/deploy-api.js.map +0 -1
  406. package/dist/utils/deployment.d.ts +0 -26
  407. package/dist/utils/deployment.js +0 -218
  408. package/dist/utils/deployment.js.map +0 -1
  409. package/dist/utils/dev-helpers.d.ts +0 -47
  410. package/dist/utils/dev-helpers.js +0 -82
  411. package/dist/utils/dev-helpers.js.map +0 -1
  412. package/dist/utils/job-management.d.ts +0 -27
  413. package/dist/utils/job-management.js +0 -248
  414. package/dist/utils/job-management.js.map +0 -1
  415. package/dist/utils/mcp-server-management.d.ts +0 -26
  416. package/dist/utils/mcp-server-management.js +0 -197
  417. package/dist/utils/mcp-server-management.js.map +0 -1
  418. package/dist/utils/postprocessor-management.d.ts +0 -9
  419. package/dist/utils/postprocessor-management.js +0 -117
  420. package/dist/utils/postprocessor-management.js.map +0 -1
  421. package/dist/utils/pre-bundle-jobs.d.ts +0 -27
  422. package/dist/utils/pre-bundle-jobs.js +0 -189
  423. package/dist/utils/pre-bundle-jobs.js.map +0 -1
  424. package/dist/utils/preprocessor-management.d.ts +0 -9
  425. package/dist/utils/preprocessor-management.js +0 -117
  426. package/dist/utils/preprocessor-management.js.map +0 -1
  427. package/dist/utils/push-api.d.ts +0 -15
  428. package/dist/utils/push-api.js +0 -49
  429. package/dist/utils/push-api.js.map +0 -1
  430. package/dist/utils/push-helpers.d.ts +0 -82
  431. package/dist/utils/push-helpers.js +0 -246
  432. package/dist/utils/push-helpers.js.map +0 -1
  433. package/dist/utils/skill-management.d.ts +0 -39
  434. package/dist/utils/skill-management.js +0 -299
  435. package/dist/utils/skill-management.js.map +0 -1
  436. package/dist/utils/test-helpers.d.ts +0 -33
  437. package/dist/utils/test-helpers.js +0 -84
  438. package/dist/utils/test-helpers.js.map +0 -1
  439. package/dist/utils/test-prompts.d.ts +0 -23
  440. package/dist/utils/test-prompts.js +0 -187
  441. package/dist/utils/test-prompts.js.map +0 -1
  442. package/dist/utils/tool-detection.d.ts +0 -19
  443. package/dist/utils/tool-detection.js +0 -125
  444. package/dist/utils/tool-detection.js.map +0 -1
  445. package/dist/utils/webhook-management.d.ts +0 -27
  446. package/dist/utils/webhook-management.js +0 -241
  447. package/dist/utils/webhook-management.js.map +0 -1
  448. /package/dist/{common → api}/http.client.d.ts +0 -0
  449. /package/dist/{common → api}/http.client.js +0 -0
  450. /package/dist/{common → instances}/basket.instance.d.ts +0 -0
  451. /package/dist/{common → instances}/basket.instance.js +0 -0
  452. /package/dist/{common → instances}/data.entry.instance.d.ts +0 -0
  453. /package/dist/{common → instances}/data.entry.instance.js +0 -0
  454. /package/dist/{common → instances}/job.instance.d.ts +0 -0
  455. /package/dist/{common → instances}/job.instance.js +0 -0
  456. /package/dist/{common → instances}/order.instance.d.ts +0 -0
  457. /package/dist/{common → instances}/order.instance.js +0 -0
  458. /package/dist/{common → instances}/product.instance.d.ts +0 -0
  459. /package/dist/{common → instances}/product.instance.js +0 -0
  460. /package/dist/{common → instances}/product.pagination.instance.d.ts +0 -0
  461. /package/dist/{common → instances}/product.pagination.instance.js +0 -0
  462. /package/dist/{common → instances}/product.search.instance.d.ts +0 -0
  463. /package/dist/{common → instances}/product.search.instance.js +0 -0
  464. /package/dist/{common → instances}/user.instance.d.ts +0 -0
  465. /package/dist/{common → instances}/user.instance.js +0 -0
@@ -1,1062 +0,0 @@
1
- /**
2
- * Utility functions for compile command
3
- */
4
- import fs from "fs";
5
- import path from "path";
6
- import { gzipSync } from "zlib";
7
- import { Node } from "ts-morph";
8
- /**
9
- * Compresses code using gzip and returns base64 encoded string
10
- */
11
- export function compressCode(code) {
12
- const compressed = gzipSync(code);
13
- return compressed.toString('base64');
14
- }
15
- /**
16
- * Finds the index.ts file in the project
17
- */
18
- export function findIndexFile() {
19
- // Check for index.ts in current directory
20
- let indexPath = path.join(process.cwd(), "index.ts");
21
- if (fs.existsSync(indexPath)) {
22
- return indexPath;
23
- }
24
- // Check for index.ts in src directory
25
- indexPath = path.join(process.cwd(), "src", "index.ts");
26
- if (fs.existsSync(indexPath)) {
27
- return indexPath;
28
- }
29
- throw new Error("index.ts not found in current directory or src/ directory");
30
- }
31
- /**
32
- * Resolves TypeScript path aliases from tsconfig.json (e.g., @/ -> ./src/)
33
- * @returns Object with baseUrl and paths mappings, or null if not found
34
- */
35
- function getTsConfigPathMappings() {
36
- const tsconfigPath = path.join(process.cwd(), 'tsconfig.json');
37
- if (!fs.existsSync(tsconfigPath)) {
38
- return null;
39
- }
40
- try {
41
- const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
42
- const tsconfig = JSON.parse(tsconfigContent);
43
- const compilerOptions = tsconfig.compilerOptions || {};
44
- if (compilerOptions.paths) {
45
- return {
46
- baseUrl: compilerOptions.baseUrl || '.',
47
- paths: compilerOptions.paths
48
- };
49
- }
50
- }
51
- catch {
52
- // Ignore parsing errors
53
- }
54
- return null;
55
- }
56
- /**
57
- * Resolves a path alias to a relative path using tsconfig.json mappings
58
- * @param specifier - The import specifier (e.g., '@/src/skills/numida.skill')
59
- * @returns Resolved path or null if no alias matched
60
- */
61
- function resolvePathAlias(specifier) {
62
- const mappings = getTsConfigPathMappings();
63
- if (!mappings)
64
- return null;
65
- // Sort patterns by specificity (longest first) to match TypeScript's behavior
66
- // e.g., "@/tools/*" should match before "@/*"
67
- const sortedPatterns = Object.entries(mappings.paths).sort(([a], [b]) => b.length - a.length);
68
- for (const [pattern, targets] of sortedPatterns) {
69
- // Convert TypeScript path pattern to regex (e.g., "@/*" -> /^@\/(.*)$/)
70
- const patternRegex = new RegExp('^' + pattern.replace(/\*/g, '(.*)').replace(/\//g, '\\/') + '$');
71
- const match = specifier.match(patternRegex);
72
- if (match) {
73
- // Get the captured wildcard portion
74
- const captured = match[1] || '';
75
- // Use first target path and substitute the wildcard
76
- const targetPath = targets[0].replace('*', captured);
77
- // Resolve relative to baseUrl (which is relative to tsconfig location)
78
- const resolvedPath = path.join(process.cwd(), mappings.baseUrl, targetPath);
79
- return resolvedPath;
80
- }
81
- }
82
- return null;
83
- }
84
- /**
85
- * Resolves import path from module specifier with support for multiple extensions and index files.
86
- * Handles modern TypeScript projects that use .js extensions in imports (Node16/NodeNext resolution).
87
- * Also handles TypeScript path aliases configured in tsconfig.json (e.g., @/, ~/).
88
- * @param moduleSpecifier - The import path (e.g., './tools/MyTool.js' or '../utils')
89
- * @param currentFilePath - The file doing the importing
90
- * @returns Resolved absolute file path
91
- */
92
- export function resolveImportPath(moduleSpecifier, currentFilePath) {
93
- const extensions = ['.ts', '.tsx', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'];
94
- // Handle modern TS projects using .js extensions in imports (Node16/NodeNext module resolution)
95
- // Strip the extension so we can properly resolve to the .ts source file
96
- let normalizedSpecifier = moduleSpecifier;
97
- if (moduleSpecifier.endsWith('.js')) {
98
- normalizedSpecifier = moduleSpecifier.slice(0, -3);
99
- }
100
- // Try to resolve path aliases first (e.g., @/src/skills/numida.skill)
101
- const aliasResolved = resolvePathAlias(normalizedSpecifier);
102
- if (aliasResolved) {
103
- // Try each extension for the alias-resolved path
104
- for (const ext of extensions) {
105
- const fullPath = ext.startsWith('/') ? path.join(aliasResolved, ext) : aliasResolved + ext;
106
- if (fs.existsSync(fullPath)) {
107
- return fullPath;
108
- }
109
- }
110
- // Fallback: return .ts extension
111
- return aliasResolved + '.ts';
112
- }
113
- if (normalizedSpecifier.startsWith('./') || normalizedSpecifier.startsWith('../')) {
114
- // Relative import - resolve relative to current file
115
- const currentDir = path.dirname(currentFilePath);
116
- const basePath = path.resolve(currentDir, normalizedSpecifier);
117
- // Try each extension in order
118
- for (const ext of extensions) {
119
- const fullPath = ext.startsWith('/') ? path.join(basePath, ext) : basePath + ext;
120
- if (fs.existsSync(fullPath)) {
121
- return fullPath;
122
- }
123
- }
124
- // Fallback: return .ts extension (original behavior)
125
- return basePath + '.ts';
126
- }
127
- else {
128
- // Absolute import - check in src/ directory
129
- const srcBase = path.resolve(process.cwd(), 'src', normalizedSpecifier);
130
- for (const ext of extensions) {
131
- const fullPath = ext.startsWith('/') ? path.join(srcBase, ext) : srcBase + ext;
132
- if (fs.existsSync(fullPath)) {
133
- return fullPath;
134
- }
135
- }
136
- // Fallback: return .ts in src/ (original behavior)
137
- return path.resolve(process.cwd(), 'src', normalizedSpecifier + '.ts');
138
- }
139
- }
140
- /**
141
- * Evaluates Zod schema code and converts it to JSON Schema
142
- */
143
- export async function evaluateZodSchemaToJsonSchema(zodSchemaCode) {
144
- try {
145
- // Import zod and zod-to-json-schema dynamically
146
- const { z } = await import('zod');
147
- const { zodToJsonSchema } = await import('zod-to-json-schema');
148
- // Create a safe evaluation context using Function constructor
149
- const evalFunction = new Function('z', `return ${zodSchemaCode}`);
150
- const zodSchema = evalFunction(z);
151
- // Convert to JSON Schema using the library
152
- const jsonSchema = zodToJsonSchema(zodSchema, 'schema');
153
- // Extract just the core schema, removing JSON Schema references and definitions
154
- if (jsonSchema.$ref && jsonSchema.definitions && jsonSchema.definitions.schema) {
155
- // Return just the schema definition without the wrapper
156
- return jsonSchema.definitions.schema;
157
- }
158
- // Remove the top-level $schema and title properties that we don't need
159
- const { $schema, title, definitions, $ref, ...cleanSchema } = jsonSchema;
160
- return cleanSchema;
161
- }
162
- catch (error) {
163
- console.warn('Warning: Could not evaluate Zod schema, falling back to basic parsing:', error);
164
- // Fallback to basic parsing for simple cases
165
- if (zodSchemaCode.includes('z.object({')) {
166
- return { type: 'object' };
167
- }
168
- if (zodSchemaCode.includes('z.string()'))
169
- return { type: 'string' };
170
- if (zodSchemaCode.includes('z.number()'))
171
- return { type: 'number' };
172
- if (zodSchemaCode.includes('z.boolean()'))
173
- return { type: 'boolean' };
174
- return { type: 'object' };
175
- }
176
- }
177
- /**
178
- * Wraps raw bundled tool code for execute function
179
- */
180
- export function wrapExecuteForVM(bundledCode, className) {
181
- return `async (input) => {
182
- ${bundledCode}
183
-
184
- const ToolClass = module.exports.default || module.exports.${className} || module.exports;
185
- const toolInstance = new ToolClass();
186
- return await toolInstance.execute(input);
187
- }`;
188
- }
189
- /**
190
- * Wraps raw bundled tool code for condition evaluation
191
- */
192
- export function wrapConditionForVM(bundledCode, className) {
193
- return `async () => {
194
- ${bundledCode}
195
-
196
- const ToolClass = module.exports.default || module.exports.${className} || module.exports;
197
- const toolInstance = new ToolClass();
198
- return await toolInstance.condition() === true;
199
- }`;
200
- }
201
- /**
202
- * Extracts tool information from a new expression in the AST
203
- */
204
- export function extractToolFromNewExpressionSync(newExpr, project) {
205
- try {
206
- const expression = newExpr.getExpression();
207
- const className = expression.getText();
208
- const sourceFile = newExpr.getSourceFile();
209
- // Strategy 1: Try to find the tool via imports (separate file)
210
- const imports = sourceFile.getImportDeclarations();
211
- for (const importDecl of imports) {
212
- const namedImports = importDecl.getNamedImports();
213
- const defaultImport = importDecl.getDefaultImport();
214
- let toolFilePath = null;
215
- // Check named imports
216
- for (const namedImport of namedImports) {
217
- if (namedImport.getName() === className) {
218
- toolFilePath = resolveImportPath(importDecl.getModuleSpecifierValue(), sourceFile.getFilePath());
219
- break;
220
- }
221
- }
222
- // Check default import
223
- if (!toolFilePath && defaultImport && defaultImport.getText() === className) {
224
- toolFilePath = resolveImportPath(importDecl.getModuleSpecifierValue(), sourceFile.getFilePath());
225
- }
226
- if (toolFilePath && fs.existsSync(toolFilePath)) {
227
- // Extract tool metadata from the separate file
228
- const toolInfo = extractToolMetadataFromFile(toolFilePath, className, project);
229
- if (toolInfo)
230
- return toolInfo;
231
- }
232
- }
233
- // Strategy 2: Check if tool is defined inline in the same file
234
- const classDecl = sourceFile.getClass(className);
235
- if (classDecl) {
236
- // Tool is defined inline - extract metadata directly
237
- const toolInfo = extractToolMetadataFromClass(classDecl, className, sourceFile.getFilePath());
238
- if (toolInfo)
239
- return toolInfo;
240
- }
241
- return null;
242
- }
243
- catch (error) {
244
- console.warn(`Warning: Could not extract tool info for ${newExpr.getText()}:`, error);
245
- return null;
246
- }
247
- }
248
- /**
249
- * Extracts tool metadata from a separate tool file.
250
- */
251
- function extractToolMetadataFromFile(toolFilePath, className, project) {
252
- try {
253
- const toolSourceFile = project.addSourceFileAtPath(toolFilePath);
254
- const classDecl = toolSourceFile.getClass(className);
255
- if (classDecl) {
256
- return extractToolMetadataFromClass(classDecl, className, toolFilePath);
257
- }
258
- }
259
- catch (fileError) {
260
- console.warn(`Warning: Could not load tool file ${toolFilePath}:`, fileError);
261
- }
262
- return null;
263
- }
264
- /**
265
- * Extracts tool metadata from a class declaration (works for both inline and separate files).
266
- */
267
- function extractToolMetadataFromClass(classDecl, className, filePath) {
268
- const nameProperty = classDecl.getProperty('name');
269
- const descProperty = classDecl.getProperty('description');
270
- let toolName = className.replace(/Tool$/, '').toLowerCase();
271
- let description = '';
272
- // Extract name from property if available
273
- if (nameProperty && nameProperty.getInitializer()) {
274
- const nameValue = nameProperty.getInitializer()?.getText();
275
- if (nameValue) {
276
- toolName = nameValue.replace(/['"]/g, '');
277
- }
278
- }
279
- // Extract description from property if available
280
- if (descProperty && descProperty.getInitializer()) {
281
- const descValue = descProperty.getInitializer()?.getText();
282
- if (descValue) {
283
- description = descValue.replace(/['"]/g, '');
284
- }
285
- }
286
- return {
287
- name: toolName,
288
- className,
289
- filePath,
290
- description
291
- };
292
- }
293
- /**
294
- * Extracts skills metadata from index file
295
- */
296
- export function extractSkillsMetadata(indexFile) {
297
- const skills = [];
298
- // Find all LuaSkill constructor calls
299
- indexFile.forEachDescendant((node) => {
300
- if (Node.isNewExpression(node)) {
301
- const expression = node.getExpression();
302
- if (expression.getText() === 'LuaSkill') {
303
- const args = node.getArguments();
304
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
305
- const configObj = args[0];
306
- let skillName = '';
307
- let description = '';
308
- let context = '';
309
- let tools = [];
310
- // Extract properties
311
- configObj.getProperties().forEach((prop) => {
312
- if (Node.isPropertyAssignment(prop)) {
313
- const name = prop.getName();
314
- const value = prop.getInitializer();
315
- if (name === 'name' && value) {
316
- skillName = value.getText().replace(/['"]/g, '');
317
- }
318
- else if (name === 'description' && value) {
319
- description = value.getText().replace(/['"]/g, '');
320
- }
321
- else if (name === 'context' && value) {
322
- context = value.getText().replace(/['"]/g, '');
323
- }
324
- else if (name === 'tools' && value && Node.isArrayLiteralExpression(value)) {
325
- // Extract tools from constructor array
326
- const toolsArray = value;
327
- tools = toolsArray.getElements().map((element) => {
328
- if (Node.isNewExpression(element)) {
329
- return element.getExpression().getText();
330
- }
331
- return '';
332
- }).filter(name => name);
333
- }
334
- }
335
- });
336
- if (skillName) {
337
- skills.push({
338
- name: skillName,
339
- description,
340
- context,
341
- tools
342
- });
343
- }
344
- }
345
- }
346
- }
347
- });
348
- return skills;
349
- }
350
- /**
351
- * Extracts webhooks metadata from index file
352
- */
353
- export function extractWebhooksMetadata(indexFile) {
354
- const webhooks = [];
355
- // Find all LuaWebhook constructor calls
356
- indexFile.forEachDescendant((node) => {
357
- if (Node.isNewExpression(node)) {
358
- const expression = node.getExpression();
359
- if (expression.getText() === 'LuaWebhook') {
360
- const args = node.getArguments();
361
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
362
- const configObj = args[0];
363
- let webhookName = '';
364
- let description = '';
365
- // Extract properties
366
- configObj.getProperties().forEach((prop) => {
367
- if (Node.isPropertyAssignment(prop)) {
368
- const name = prop.getName();
369
- const value = prop.getInitializer();
370
- if (name === 'name' && value) {
371
- webhookName = value.getText().replace(/['"]/g, '');
372
- }
373
- else if (name === 'description' && value) {
374
- description = value.getText().replace(/['"]/g, '');
375
- }
376
- }
377
- });
378
- if (webhookName) {
379
- webhooks.push({
380
- name: webhookName,
381
- description
382
- });
383
- }
384
- }
385
- }
386
- }
387
- });
388
- return webhooks;
389
- }
390
- /**
391
- * Extracts jobs metadata from index file
392
- */
393
- export function extractJobsMetadata(indexFile) {
394
- const jobs = [];
395
- // Find all LuaJob constructor calls
396
- indexFile.forEachDescendant((node) => {
397
- if (Node.isNewExpression(node)) {
398
- const expression = node.getExpression();
399
- if (expression.getText() === 'LuaJob') {
400
- const args = node.getArguments();
401
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
402
- const configObj = args[0];
403
- let jobName = '';
404
- let description = '';
405
- let schedule = null;
406
- let timeout;
407
- let retry = undefined;
408
- let metadata = undefined;
409
- // Extract properties
410
- configObj.getProperties().forEach((prop) => {
411
- if (Node.isPropertyAssignment(prop)) {
412
- const name = prop.getName();
413
- const value = prop.getInitializer();
414
- if (name === 'name' && value) {
415
- jobName = value.getText().replace(/['"]/g, '');
416
- }
417
- else if (name === 'description' && value) {
418
- description = value.getText().replace(/['"]/g, '');
419
- }
420
- else if (name === 'schedule' && value) {
421
- // Extract schedule configuration
422
- try {
423
- const scheduleText = value.getText();
424
- // Try to evaluate the schedule object
425
- schedule = eval(`(${scheduleText})`);
426
- }
427
- catch (error) {
428
- console.warn('Warning: Could not parse schedule:', error);
429
- schedule = { type: 'unknown' };
430
- }
431
- }
432
- else if (name === 'timeout' && value) {
433
- const timeoutText = value.getText();
434
- timeout = parseInt(timeoutText, 10);
435
- }
436
- else if (name === 'retry' && value) {
437
- // Extract retry configuration
438
- try {
439
- const retryText = value.getText();
440
- retry = eval(`(${retryText})`);
441
- }
442
- catch (error) {
443
- console.warn('Warning: Could not parse retry config:', error);
444
- }
445
- }
446
- else if (name === 'metadata' && value) {
447
- // Extract metadata
448
- try {
449
- const metadataText = value.getText();
450
- metadata = eval(`(${metadataText})`);
451
- }
452
- catch (error) {
453
- console.warn('Warning: Could not parse metadata:', error);
454
- }
455
- }
456
- }
457
- });
458
- if (jobName) {
459
- jobs.push({
460
- name: jobName,
461
- description,
462
- schedule,
463
- timeout,
464
- retry,
465
- metadata
466
- });
467
- }
468
- }
469
- }
470
- }
471
- });
472
- return jobs;
473
- }
474
- /**
475
- * Extracts preprocessors metadata from index file
476
- */
477
- export function extractPreProcessorsMetadata(indexFile) {
478
- const preprocessors = [];
479
- // Find all PreProcessor constructor calls
480
- indexFile.forEachDescendant((node) => {
481
- if (Node.isNewExpression(node)) {
482
- const expression = node.getExpression();
483
- if (expression.getText() === 'PreProcessor') {
484
- const args = node.getArguments();
485
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
486
- const configObj = args[0];
487
- let name = '';
488
- let description = '';
489
- let asyncMode = false;
490
- configObj.getProperties().forEach((prop) => {
491
- if (Node.isPropertyAssignment(prop)) {
492
- const propName = prop.getName();
493
- const value = prop.getInitializer();
494
- if (propName === 'name' && value) {
495
- name = value.getText().replace(/['"]/g, '');
496
- }
497
- else if (propName === 'description' && value) {
498
- description = value.getText().replace(/['"]/g, '');
499
- }
500
- else if (propName === 'async' && value) {
501
- // Properly extract boolean value by checking node kind
502
- const nodeKind = value.getKind();
503
- asyncMode = nodeKind === 110; // TrueKeyword = 110, FalseKeyword = 95
504
- }
505
- }
506
- });
507
- if (name) {
508
- preprocessors.push({
509
- name,
510
- description,
511
- async: asyncMode
512
- });
513
- }
514
- }
515
- }
516
- }
517
- });
518
- return preprocessors;
519
- }
520
- /**
521
- * Extracts postprocessors metadata from index file
522
- */
523
- export function extractPostProcessorsMetadata(indexFile) {
524
- const postprocessors = [];
525
- // Find all PostProcessor constructor calls
526
- indexFile.forEachDescendant((node) => {
527
- if (Node.isNewExpression(node)) {
528
- const expression = node.getExpression();
529
- if (expression.getText() === 'PostProcessor') {
530
- const args = node.getArguments();
531
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
532
- const configObj = args[0];
533
- let name = '';
534
- let description = '';
535
- configObj.getProperties().forEach((prop) => {
536
- if (Node.isPropertyAssignment(prop)) {
537
- const propName = prop.getName();
538
- const value = prop.getInitializer();
539
- if (propName === 'name' && value) {
540
- name = value.getText().replace(/['"]/g, '');
541
- }
542
- else if (propName === 'description' && value) {
543
- description = value.getText().replace(/['"]/g, '');
544
- }
545
- }
546
- });
547
- if (name) {
548
- postprocessors.push({
549
- name,
550
- description
551
- });
552
- }
553
- }
554
- }
555
- }
556
- });
557
- return postprocessors;
558
- }
559
- /**
560
- * Extracts LuaAgent metadata from index file.
561
- * Returns the unified agent configuration if found, otherwise null.
562
- * This function looks for either:
563
- * - A LuaAgent constructor call: new LuaAgent({ ... })
564
- * - A variable assigned to LuaAgent: const agent = new LuaAgent({ ... })
565
- */
566
- export function extractLuaAgentMetadata(indexFile) {
567
- let agentMetadata = null;
568
- // Find LuaAgent constructor calls
569
- indexFile.forEachDescendant((node) => {
570
- if (Node.isNewExpression(node)) {
571
- const expression = node.getExpression();
572
- if (expression.getText() === 'LuaAgent') {
573
- const args = node.getArguments();
574
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
575
- const configObj = args[0];
576
- let name = '';
577
- let persona = '';
578
- const skills = [];
579
- const webhooks = [];
580
- const jobs = [];
581
- const preProcessors = [];
582
- const postProcessors = [];
583
- const mcpServers = [];
584
- // Extract properties from LuaAgent config
585
- configObj.getProperties().forEach((prop) => {
586
- if (Node.isPropertyAssignment(prop)) {
587
- const propName = prop.getName();
588
- const value = prop.getInitializer();
589
- if (propName === 'name' && value) {
590
- // Use getLiteralValue for proper string extraction
591
- if (Node.isStringLiteral(value) || Node.isNoSubstitutionTemplateLiteral(value)) {
592
- name = value.getLiteralValue();
593
- }
594
- else if (Node.isIdentifier(value)) {
595
- // Handle variable reference - resolve to find the actual value
596
- const resolved = resolveIdentifierValue(indexFile, value.getText());
597
- if (resolved) {
598
- name = resolved;
599
- }
600
- }
601
- }
602
- else if (propName === 'persona' && value) {
603
- // Use getLiteralValue to get actual string value (handles escapes correctly)
604
- if (Node.isStringLiteral(value) || Node.isNoSubstitutionTemplateLiteral(value)) {
605
- persona = value.getLiteralValue().trim();
606
- }
607
- else if (Node.isIdentifier(value)) {
608
- // Handle variable reference - resolve to find the actual value
609
- const resolved = resolveIdentifierValue(indexFile, value.getText());
610
- if (resolved) {
611
- persona = resolved.trim();
612
- }
613
- }
614
- }
615
- else if (propName === 'skills' && value && Node.isArrayLiteralExpression(value)) {
616
- // Extract skill references from the array
617
- value.getElements().forEach((element) => {
618
- // Skills can be variable references or inline new LuaSkill()
619
- if (Node.isIdentifier(element)) {
620
- skills.push({ ref: element.getText() });
621
- }
622
- else if (Node.isNewExpression(element)) {
623
- // Extract inline skill metadata
624
- const skillArgs = element.getArguments();
625
- if (skillArgs.length > 0 && Node.isObjectLiteralExpression(skillArgs[0])) {
626
- const skillConfig = extractConfigFromObjectLiteral(skillArgs[0], indexFile);
627
- skills.push(skillConfig);
628
- }
629
- }
630
- });
631
- }
632
- else if (propName === 'webhooks' && value && Node.isArrayLiteralExpression(value)) {
633
- value.getElements().forEach((element) => {
634
- if (Node.isIdentifier(element)) {
635
- webhooks.push({ ref: element.getText() });
636
- }
637
- else if (Node.isNewExpression(element)) {
638
- const webhookArgs = element.getArguments();
639
- if (webhookArgs.length > 0 && Node.isObjectLiteralExpression(webhookArgs[0])) {
640
- const webhookConfig = extractConfigFromObjectLiteral(webhookArgs[0], indexFile);
641
- webhooks.push(webhookConfig);
642
- }
643
- }
644
- });
645
- }
646
- else if (propName === 'jobs' && value && Node.isArrayLiteralExpression(value)) {
647
- value.getElements().forEach((element) => {
648
- if (Node.isIdentifier(element)) {
649
- jobs.push({ ref: element.getText() });
650
- }
651
- else if (Node.isNewExpression(element)) {
652
- const jobArgs = element.getArguments();
653
- if (jobArgs.length > 0 && Node.isObjectLiteralExpression(jobArgs[0])) {
654
- const jobConfig = extractConfigFromObjectLiteral(jobArgs[0], indexFile);
655
- jobs.push(jobConfig);
656
- }
657
- }
658
- });
659
- }
660
- else if (propName === 'preProcessors' && value && Node.isArrayLiteralExpression(value)) {
661
- value.getElements().forEach((element) => {
662
- if (Node.isIdentifier(element)) {
663
- preProcessors.push({ ref: element.getText() });
664
- }
665
- else if (Node.isNewExpression(element)) {
666
- const processorArgs = element.getArguments();
667
- if (processorArgs.length > 0 && Node.isObjectLiteralExpression(processorArgs[0])) {
668
- const processorConfig = extractConfigFromObjectLiteral(processorArgs[0], indexFile);
669
- preProcessors.push(processorConfig);
670
- }
671
- }
672
- });
673
- }
674
- else if (propName === 'postProcessors' && value && Node.isArrayLiteralExpression(value)) {
675
- value.getElements().forEach((element) => {
676
- if (Node.isIdentifier(element)) {
677
- postProcessors.push({ ref: element.getText() });
678
- }
679
- else if (Node.isNewExpression(element)) {
680
- const processorArgs = element.getArguments();
681
- if (processorArgs.length > 0 && Node.isObjectLiteralExpression(processorArgs[0])) {
682
- const processorConfig = extractConfigFromObjectLiteral(processorArgs[0], indexFile);
683
- postProcessors.push(processorConfig);
684
- }
685
- }
686
- });
687
- }
688
- else if (propName === 'mcpServers' && value && Node.isArrayLiteralExpression(value)) {
689
- // Extract MCP server references from the array
690
- value.getElements().forEach((element) => {
691
- if (Node.isIdentifier(element)) {
692
- mcpServers.push({ ref: element.getText() });
693
- }
694
- else if (Node.isNewExpression(element)) {
695
- // Extract inline MCP server metadata
696
- const mcpArgs = element.getArguments();
697
- if (mcpArgs.length > 0 && Node.isObjectLiteralExpression(mcpArgs[0])) {
698
- const mcpConfig = extractConfigFromObjectLiteral(mcpArgs[0], indexFile);
699
- mcpServers.push(mcpConfig);
700
- }
701
- }
702
- });
703
- }
704
- }
705
- });
706
- // Return metadata if we found at least a name or persona
707
- // (previously required both, but that broke variable reference detection)
708
- if (name || persona) {
709
- agentMetadata = {
710
- name,
711
- persona,
712
- skills,
713
- webhooks,
714
- jobs,
715
- preProcessors,
716
- postProcessors,
717
- mcpServers
718
- };
719
- }
720
- }
721
- }
722
- }
723
- });
724
- return agentMetadata;
725
- }
726
- /**
727
- * Helper function to extract configuration from an object literal expression.
728
- * Used by extractLuaAgentMetadata to parse inline skill/webhook/job definitions.
729
- * Handles nested objects, arrays, and various data types.
730
- *
731
- * @param configObj - The object literal expression to extract from
732
- * @param sourceFile - Optional source file for resolving variable references
733
- */
734
- function extractConfigFromObjectLiteral(configObj, sourceFile) {
735
- const config = {};
736
- configObj.getProperties().forEach((prop) => {
737
- if (Node.isPropertyAssignment(prop)) {
738
- const name = prop.getName();
739
- const value = prop.getInitializer();
740
- if (value) {
741
- config[name] = extractValueFromNode(value, sourceFile);
742
- }
743
- }
744
- });
745
- return config;
746
- }
747
- /**
748
- * Extracts a value from an AST node, handling various types.
749
- *
750
- * @param node - The AST node to extract value from
751
- * @param sourceFile - Optional source file for resolving variable references
752
- */
753
- function extractValueFromNode(node, sourceFile) {
754
- if (!node)
755
- return undefined;
756
- // String literal
757
- if (Node.isStringLiteral(node)) {
758
- return node.getLiteralValue();
759
- }
760
- // Template literal without substitutions
761
- if (Node.isNoSubstitutionTemplateLiteral(node)) {
762
- return node.getLiteralValue();
763
- }
764
- // Numeric literal
765
- if (Node.isNumericLiteral(node)) {
766
- return node.getLiteralValue();
767
- }
768
- // Boolean literal (TrueKeyword = 110, FalseKeyword = 95)
769
- const nodeKind = node.getKind();
770
- if (nodeKind === 110)
771
- return true; // TrueKeyword
772
- if (nodeKind === 95)
773
- return false; // FalseKeyword
774
- // Identifier (variable reference) - resolve to actual value if sourceFile provided
775
- if (Node.isIdentifier(node) && sourceFile) {
776
- const resolved = resolveIdentifierValue(sourceFile, node.getText());
777
- if (resolved !== null) {
778
- return resolved;
779
- }
780
- // If we can't resolve it, return the identifier name as-is (might be a class reference)
781
- return node.getText();
782
- }
783
- // New expression (for tools: [new ToolClass()])
784
- // Extract just the class name for compatibility with buildSkillsArray
785
- if (Node.isNewExpression(node)) {
786
- const expression = node.getExpression();
787
- return expression.getText(); // Returns class name like "GetWeatherTool"
788
- }
789
- // Array literal
790
- if (Node.isArrayLiteralExpression(node)) {
791
- return node.getElements().map((element) => extractValueFromNode(element, sourceFile));
792
- }
793
- // Object literal
794
- if (Node.isObjectLiteralExpression(node)) {
795
- return extractConfigFromObjectLiteral(node, sourceFile);
796
- }
797
- // Arrow function or function expression (for execute, etc.)
798
- if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {
799
- return node.getText(); // Return the function as a string
800
- }
801
- // Template literal or other complex expressions
802
- // For persona, context, etc. that might be multiline
803
- const text = node.getText();
804
- // Handle boolean strings (fallback if node kind check didn't catch it)
805
- if (text === 'true')
806
- return true;
807
- if (text === 'false')
808
- return false;
809
- // If it starts with a quote, remove quotes
810
- if ((text.startsWith('"') && text.endsWith('"')) ||
811
- (text.startsWith("'") && text.endsWith("'")) ||
812
- (text.startsWith('`') && text.endsWith('`'))) {
813
- return text.slice(1, -1).replace(/\\n/g, '\n');
814
- }
815
- return text;
816
- }
817
- /**
818
- * Gets the file paths where skills are defined in a LuaAgent.
819
- * This is used to scan those files for tools.
820
- * Returns deduplicated file paths.
821
- *
822
- * @param agentMetadata - Agent metadata from extractLuaAgentMetadata
823
- * @param indexFile - The index source file
824
- * @returns Array of unique file paths where skills are defined
825
- */
826
- export function getSkillFilePaths(agentMetadata, indexFile) {
827
- const filePathsSet = new Set();
828
- const imports = indexFile.getImportDeclarations();
829
- for (const skill of agentMetadata.skills) {
830
- if (skill.ref) {
831
- // Find where this skill is imported from
832
- for (const importDecl of imports) {
833
- const namedImports = importDecl.getNamedImports();
834
- const defaultImport = importDecl.getDefaultImport();
835
- let isMatch = false;
836
- // Check named imports
837
- for (const namedImport of namedImports) {
838
- if (namedImport.getName() === skill.ref) {
839
- isMatch = true;
840
- break;
841
- }
842
- }
843
- // Check default import
844
- if (!isMatch && defaultImport && defaultImport.getText() === skill.ref) {
845
- isMatch = true;
846
- }
847
- if (isMatch) {
848
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
849
- const importPath = resolveImportPath(moduleSpecifier, indexFile.getFilePath());
850
- if (fs.existsSync(importPath)) {
851
- filePathsSet.add(importPath); // Use Set to avoid duplicates
852
- }
853
- break;
854
- }
855
- }
856
- }
857
- }
858
- return Array.from(filePathsSet);
859
- }
860
- /**
861
- * Resolves references in LuaAgent metadata to actual definitions.
862
- * When a LuaAgent contains references like `skills: [userSkill]`, this function
863
- * finds where `userSkill` is defined and extracts its metadata.
864
- */
865
- export function resolveLuaAgentReferences(agentMetadata, indexFile, project) {
866
- const resolveArrayReferences = (items, extractFunction) => {
867
- const resolved = [];
868
- for (const item of items) {
869
- if (item.ref) {
870
- // This is a reference, need to resolve it
871
- const varName = item.ref;
872
- // Find the variable declaration in the index file
873
- const varDecl = findVariableDeclaration(indexFile, varName);
874
- if (varDecl) {
875
- // If it's a new expression, extract metadata
876
- const initializer = varDecl.getInitializer();
877
- if (initializer && Node.isNewExpression(initializer)) {
878
- const expression = initializer.getExpression();
879
- const args = initializer.getArguments();
880
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
881
- const config = extractConfigFromObjectLiteral(args[0], indexFile);
882
- resolved.push(config);
883
- }
884
- }
885
- }
886
- else {
887
- // Check if it's imported from another file
888
- const importedMetadata = findImportedDefinition(indexFile, varName, project, extractFunction);
889
- if (importedMetadata) {
890
- resolved.push(...importedMetadata);
891
- }
892
- }
893
- }
894
- else {
895
- // Not a reference, already has metadata
896
- resolved.push(item);
897
- }
898
- }
899
- return resolved;
900
- };
901
- return {
902
- skills: resolveArrayReferences(agentMetadata.skills, extractSkillsMetadata),
903
- webhooks: resolveArrayReferences(agentMetadata.webhooks, extractWebhooksMetadata),
904
- jobs: resolveArrayReferences(agentMetadata.jobs, extractJobsMetadata),
905
- preProcessors: resolveArrayReferences(agentMetadata.preProcessors, extractPreProcessorsMetadata),
906
- postProcessors: resolveArrayReferences(agentMetadata.postProcessors, extractPostProcessorsMetadata),
907
- mcpServers: resolveArrayReferences(agentMetadata.mcpServers, extractMCPServersMetadata)
908
- };
909
- }
910
- /**
911
- * Extracts MCP server metadata from a source file.
912
- * Looks for LuaMCPServer constructor calls.
913
- *
914
- * Note: Function-based resolvers for env, headers, and url are detected
915
- * during extraction but bundled separately in compile.ts using esbuild
916
- * for proper TypeScript transpilation.
917
- */
918
- export function extractMCPServersMetadata(sourceFile) {
919
- const mcpServers = [];
920
- sourceFile.forEachDescendant((node) => {
921
- if (Node.isNewExpression(node)) {
922
- const expression = node.getExpression();
923
- if (expression.getText() === 'LuaMCPServer') {
924
- const args = node.getArguments();
925
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
926
- const config = extractConfigFromObjectLiteral(args[0], sourceFile);
927
- // Return raw config - resolver bundling is done in compile.ts
928
- mcpServers.push(config);
929
- }
930
- }
931
- }
932
- });
933
- return mcpServers;
934
- }
935
- /**
936
- * Resolves an identifier (variable name) to its string value.
937
- * Used when name or persona are defined as variables rather than inline literals.
938
- *
939
- * @param sourceFile - The source file containing the identifier
940
- * @param identifierName - The name of the variable to resolve
941
- * @returns The string value if found, null otherwise
942
- */
943
- function resolveIdentifierValue(sourceFile, identifierName) {
944
- // Find the variable declaration
945
- const varDecl = findVariableDeclaration(sourceFile, identifierName);
946
- if (!varDecl) {
947
- return null;
948
- }
949
- const initializer = varDecl.getInitializer();
950
- if (!initializer) {
951
- return null;
952
- }
953
- // Check if it's a string literal or template literal
954
- if (Node.isStringLiteral(initializer) || Node.isNoSubstitutionTemplateLiteral(initializer)) {
955
- return initializer.getLiteralValue();
956
- }
957
- // For template literals with substitutions, get the text and clean it up
958
- if (Node.isTemplateExpression(initializer)) {
959
- // This is a complex template with ${} substitutions - get raw text
960
- const text = initializer.getText();
961
- // Remove the backticks
962
- return text.slice(1, -1);
963
- }
964
- return null;
965
- }
966
- /**
967
- * Finds a variable declaration in a source file by name.
968
- */
969
- function findVariableDeclaration(sourceFile, varName) {
970
- const declarations = sourceFile.getVariableDeclarations();
971
- for (const decl of declarations) {
972
- if (decl.getName() === varName) {
973
- return decl;
974
- }
975
- }
976
- return null;
977
- }
978
- /**
979
- * Finds an imported definition and extracts its metadata.
980
- * This directly extracts the config from the variable declaration in the imported file.
981
- * Handles both named imports and default imports.
982
- */
983
- function findImportedDefinition(sourceFile, varName, project, extractFunction) {
984
- const imports = sourceFile.getImportDeclarations();
985
- for (const importDecl of imports) {
986
- let isMatch = false;
987
- // Check named imports: import { varName } from '...'
988
- const namedImports = importDecl.getNamedImports();
989
- for (const namedImport of namedImports) {
990
- if (namedImport.getName() === varName) {
991
- isMatch = true;
992
- break;
993
- }
994
- }
995
- // Check default import: import varName from '...'
996
- if (!isMatch) {
997
- const defaultImport = importDecl.getDefaultImport();
998
- if (defaultImport && defaultImport.getText() === varName) {
999
- isMatch = true;
1000
- }
1001
- }
1002
- if (isMatch) {
1003
- // Found the import, resolve the file
1004
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
1005
- const importPath = resolveImportPath(moduleSpecifier, sourceFile.getFilePath());
1006
- if (fs.existsSync(importPath)) {
1007
- try {
1008
- const importedFile = project.addSourceFileAtPath(importPath);
1009
- // Strategy 1: Look for a variable declaration with the same name
1010
- let varDecl = importedFile.getVariableDeclaration(varName);
1011
- // Strategy 2: If it's a default import, look for default export
1012
- if (!varDecl) {
1013
- // Find any variable declaration with default export
1014
- const allVarDecls = importedFile.getVariableDeclarations();
1015
- for (const decl of allVarDecls) {
1016
- // Check if this is exported as default
1017
- const statement = decl.getVariableStatement();
1018
- if (statement && statement.hasDefaultKeyword()) {
1019
- varDecl = decl;
1020
- break;
1021
- }
1022
- }
1023
- // If still not found, just take the first variable declaration
1024
- if (!varDecl && allVarDecls.length > 0) {
1025
- varDecl = allVarDecls[0];
1026
- }
1027
- }
1028
- if (varDecl) {
1029
- const initializer = varDecl.getInitializer();
1030
- // Check if it's a new expression (new LuaSkill, new LuaJob, etc.)
1031
- if (initializer && Node.isNewExpression(initializer)) {
1032
- const args = initializer.getArguments();
1033
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
1034
- // Extract configuration from the object literal
1035
- const config = extractConfigFromObjectLiteral(args[0], importedFile);
1036
- return [config];
1037
- }
1038
- }
1039
- }
1040
- // Fallback: use the extract function to scan the whole file
1041
- const metadata = extractFunction(importedFile);
1042
- if (metadata.length > 0) {
1043
- // Try to find a match by name
1044
- const matchingItem = metadata.find((item) => {
1045
- return item.name && item.name.toLowerCase().includes(varName.toLowerCase().replace('skill', '').replace('job', '').replace('webhook', ''));
1046
- });
1047
- if (matchingItem) {
1048
- return [matchingItem];
1049
- }
1050
- // Return first item as fallback
1051
- return [metadata[0]];
1052
- }
1053
- }
1054
- catch (error) {
1055
- console.warn(`Warning: Could not resolve import ${varName} from ${importPath}:`, error);
1056
- }
1057
- }
1058
- }
1059
- }
1060
- return null;
1061
- }
1062
- //# sourceMappingURL=compile.js.map