lua-cli 3.5.0-alpha.2 → 3.5.0-alpha.4

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 (468) 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 +7 -1
  62. package/dist/api/unifiedto.api.service.js +9 -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 +2 -2
  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 +63 -39
  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.d.ts +2 -2
  111. package/dist/commands/integrations.js +761 -158
  112. package/dist/commands/integrations.js.map +1 -1
  113. package/dist/commands/jobs.js +32 -56
  114. package/dist/commands/jobs.js.map +1 -1
  115. package/dist/commands/logs.js +9 -20
  116. package/dist/commands/logs.js.map +1 -1
  117. package/dist/commands/marketplace.js +34 -52
  118. package/dist/commands/marketplace.js.map +1 -1
  119. package/dist/commands/mcp.js +10 -23
  120. package/dist/commands/mcp.js.map +1 -1
  121. package/dist/commands/persona.js +43 -74
  122. package/dist/commands/persona.js.map +1 -1
  123. package/dist/commands/postprocessors.js +15 -28
  124. package/dist/commands/postprocessors.js.map +1 -1
  125. package/dist/commands/preprocessors.js +15 -28
  126. package/dist/commands/preprocessors.js.map +1 -1
  127. package/dist/commands/production.js +30 -63
  128. package/dist/commands/production.js.map +1 -1
  129. package/dist/commands/push.js +350 -1308
  130. package/dist/commands/push.js.map +1 -1
  131. package/dist/commands/pushBackup.d.ts +22 -0
  132. package/dist/commands/pushBackup.js +133 -0
  133. package/dist/commands/pushBackup.js.map +1 -0
  134. package/dist/commands/resources.js +29 -72
  135. package/dist/commands/resources.js.map +1 -1
  136. package/dist/commands/skills.d.ts +1 -1
  137. package/dist/commands/skills.js +58 -70
  138. package/dist/commands/skills.js.map +1 -1
  139. package/dist/commands/sync.d.ts +1 -3
  140. package/dist/commands/sync.js +12 -24
  141. package/dist/commands/sync.js.map +1 -1
  142. package/dist/commands/test.js +135 -104
  143. package/dist/commands/test.js.map +1 -1
  144. package/dist/commands/webhooks.js +15 -28
  145. package/dist/commands/webhooks.js.map +1 -1
  146. package/dist/compiler/agent-traverser.d.ts +104 -0
  147. package/dist/compiler/agent-traverser.js +311 -0
  148. package/dist/compiler/agent-traverser.js.map +1 -0
  149. package/dist/compiler/bundler.d.ts +42 -0
  150. package/dist/compiler/bundler.js +187 -0
  151. package/dist/compiler/bundler.js.map +1 -0
  152. package/dist/compiler/compiler.d.ts +177 -0
  153. package/dist/compiler/compiler.js +580 -0
  154. package/dist/compiler/compiler.js.map +1 -0
  155. package/dist/compiler/index.d.ts +36 -0
  156. package/dist/compiler/index.js +42 -0
  157. package/dist/compiler/index.js.map +1 -0
  158. package/dist/compiler/plugins/base.d.ts +264 -0
  159. package/dist/compiler/plugins/base.js +307 -0
  160. package/dist/compiler/plugins/base.js.map +1 -0
  161. package/dist/compiler/plugins/job.plugin.d.ts +33 -0
  162. package/dist/compiler/plugins/job.plugin.js +143 -0
  163. package/dist/compiler/plugins/job.plugin.js.map +1 -0
  164. package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
  165. package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
  166. package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
  167. package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
  168. package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
  169. package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
  170. package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
  171. package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
  172. package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
  173. package/dist/compiler/plugins/processor-base.d.ts +16 -0
  174. package/dist/compiler/plugins/processor-base.js +34 -0
  175. package/dist/compiler/plugins/processor-base.js.map +1 -0
  176. package/dist/compiler/plugins/registry.d.ts +61 -0
  177. package/dist/compiler/plugins/registry.js +107 -0
  178. package/dist/compiler/plugins/registry.js.map +1 -0
  179. package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
  180. package/dist/compiler/plugins/skill.plugin.js +243 -0
  181. package/dist/compiler/plugins/skill.plugin.js.map +1 -0
  182. package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
  183. package/dist/compiler/plugins/tool.plugin.js +279 -0
  184. package/dist/compiler/plugins/tool.plugin.js.map +1 -0
  185. package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
  186. package/dist/compiler/plugins/webhook.plugin.js +127 -0
  187. package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
  188. package/dist/compiler/source-writer.d.ts +98 -0
  189. package/dist/compiler/source-writer.js +223 -0
  190. package/dist/compiler/source-writer.js.map +1 -0
  191. package/dist/compiler/types.d.ts +289 -0
  192. package/dist/compiler/types.js +20 -0
  193. package/dist/compiler/types.js.map +1 -0
  194. package/dist/compiler/utils/ast-helpers.d.ts +57 -0
  195. package/dist/compiler/utils/ast-helpers.js +164 -0
  196. package/dist/compiler/utils/ast-helpers.js.map +1 -0
  197. package/dist/compiler/utils/common.d.ts +23 -0
  198. package/dist/compiler/utils/common.js +66 -0
  199. package/dist/compiler/utils/common.js.map +1 -0
  200. package/dist/compiler/utils/file-discovery.d.ts +34 -0
  201. package/dist/compiler/utils/file-discovery.js +68 -0
  202. package/dist/compiler/utils/file-discovery.js.map +1 -0
  203. package/dist/compiler/utils/path-resolver.d.ts +25 -0
  204. package/dist/compiler/utils/path-resolver.js +66 -0
  205. package/dist/compiler/utils/path-resolver.js.map +1 -0
  206. package/dist/compiler/utils/schema-converter.d.ts +26 -0
  207. package/dist/compiler/utils/schema-converter.js +94 -0
  208. package/dist/compiler/utils/schema-converter.js.map +1 -0
  209. package/dist/config/compile.constants.d.ts +2 -22
  210. package/dist/config/compile.constants.js +2 -49
  211. package/dist/config/compile.constants.js.map +1 -1
  212. package/dist/config/constants.d.ts +18 -2
  213. package/dist/config/constants.js +28 -8
  214. package/dist/config/constants.js.map +1 -1
  215. package/dist/config/dev.constants.d.ts +0 -10
  216. package/dist/config/dev.constants.js +0 -10
  217. package/dist/config/dev.constants.js.map +1 -1
  218. package/dist/index.js +7 -0
  219. package/dist/index.js.map +1 -1
  220. package/dist/instances/basket.instance.js.map +1 -0
  221. package/dist/instances/data.entry.instance.js.map +1 -0
  222. package/dist/instances/job.instance.js.map +1 -0
  223. package/dist/instances/order.instance.js.map +1 -0
  224. package/dist/instances/product.instance.js.map +1 -0
  225. package/dist/instances/product.pagination.instance.js.map +1 -0
  226. package/dist/instances/product.search.instance.js.map +1 -0
  227. package/dist/instances/user.instance.js.map +1 -0
  228. package/dist/interfaces/admin.d.ts +0 -38
  229. package/dist/interfaces/backup.d.ts +125 -0
  230. package/dist/interfaces/backup.js +8 -0
  231. package/dist/interfaces/backup.js.map +1 -0
  232. package/dist/interfaces/baskets.d.ts +0 -56
  233. package/dist/interfaces/common.d.ts +1 -0
  234. package/dist/interfaces/deploy.d.ts +0 -15
  235. package/dist/interfaces/index.d.ts +1 -1
  236. package/dist/interfaces/marketplace.d.ts +51 -0
  237. package/dist/interfaces/marketplace.js +1 -1
  238. package/dist/interfaces/marketplace.js.map +1 -1
  239. package/dist/interfaces/message.d.ts +0 -3
  240. package/dist/interfaces/orders.d.ts +0 -24
  241. package/dist/interfaces/postprocessors.d.ts +0 -18
  242. package/dist/interfaces/preprocessors.d.ts +0 -18
  243. package/dist/interfaces/skills.d.ts +61 -0
  244. package/dist/interfaces/unifiedto.d.ts +4 -0
  245. package/dist/interfaces/user.d.ts +25 -0
  246. package/dist/interfaces/webhooks.d.ts +0 -9
  247. package/dist/primitives/base.handler.d.ts +106 -0
  248. package/dist/primitives/base.handler.js +370 -0
  249. package/dist/primitives/base.handler.js.map +1 -0
  250. package/dist/primitives/index.d.ts +47 -0
  251. package/dist/primitives/index.js +78 -0
  252. package/dist/primitives/index.js.map +1 -0
  253. package/dist/primitives/job.handler.d.ts +52 -0
  254. package/dist/primitives/job.handler.js +118 -0
  255. package/dist/primitives/job.handler.js.map +1 -0
  256. package/dist/primitives/mcp-server.handler.d.ts +54 -0
  257. package/dist/primitives/mcp-server.handler.js +91 -0
  258. package/dist/primitives/mcp-server.handler.js.map +1 -0
  259. package/dist/primitives/postprocessor.handler.d.ts +49 -0
  260. package/dist/primitives/postprocessor.handler.js +81 -0
  261. package/dist/primitives/postprocessor.handler.js.map +1 -0
  262. package/dist/primitives/preprocessor.handler.d.ts +54 -0
  263. package/dist/primitives/preprocessor.handler.js +95 -0
  264. package/dist/primitives/preprocessor.handler.js.map +1 -0
  265. package/dist/primitives/skill.handler.d.ts +44 -0
  266. package/dist/primitives/skill.handler.js +192 -0
  267. package/dist/primitives/skill.handler.js.map +1 -0
  268. package/dist/primitives/types.d.ts +72 -0
  269. package/dist/primitives/types.js +17 -0
  270. package/dist/primitives/types.js.map +1 -0
  271. package/dist/primitives/webhook.handler.d.ts +50 -0
  272. package/dist/primitives/webhook.handler.js +96 -0
  273. package/dist/primitives/webhook.handler.js.map +1 -0
  274. package/dist/services/auth.js +1 -2
  275. package/dist/services/auth.js.map +1 -1
  276. package/dist/services/sandbox.service.d.ts +103 -0
  277. package/dist/services/sandbox.service.js +479 -0
  278. package/dist/services/sandbox.service.js.map +1 -0
  279. package/dist/types/api-contracts.d.ts +1 -1
  280. package/dist/types/index.d.ts +2 -1
  281. package/dist/types/index.js.map +1 -1
  282. package/dist/types/skill.d.ts +8 -2
  283. package/dist/types/skill.js +8 -0
  284. package/dist/types/skill.js.map +1 -1
  285. package/dist/types/yaml.types.d.ts +69 -0
  286. package/dist/types/yaml.types.js +6 -0
  287. package/dist/types/yaml.types.js.map +1 -0
  288. package/dist/utils/artifact-loader.d.ts +108 -0
  289. package/dist/utils/artifact-loader.js +188 -0
  290. package/dist/utils/artifact-loader.js.map +1 -0
  291. package/dist/utils/backup-helpers.d.ts +122 -0
  292. package/dist/utils/backup-helpers.js +274 -0
  293. package/dist/utils/backup-helpers.js.map +1 -0
  294. package/dist/utils/cli.d.ts +8 -0
  295. package/dist/utils/cli.js +19 -2
  296. package/dist/utils/cli.js.map +1 -1
  297. package/dist/utils/command-utils.d.ts +42 -0
  298. package/dist/utils/command-utils.js +83 -0
  299. package/dist/utils/command-utils.js.map +1 -0
  300. package/dist/utils/deploy-helpers.d.ts +0 -29
  301. package/dist/utils/deploy-helpers.js +0 -70
  302. package/dist/utils/deploy-helpers.js.map +1 -1
  303. package/dist/utils/dev-api.d.ts +3 -99
  304. package/dist/utils/dev-api.js +3 -430
  305. package/dist/utils/dev-api.js.map +1 -1
  306. package/dist/utils/dev-server.d.ts +3 -1
  307. package/dist/utils/dev-server.js +69 -145
  308. package/dist/utils/dev-server.js.map +1 -1
  309. package/dist/utils/dev-watcher.d.ts +0 -1
  310. package/dist/utils/dev-watcher.js +23 -8
  311. package/dist/utils/dev-watcher.js.map +1 -1
  312. package/dist/utils/env-loader.utils.d.ts +10 -1
  313. package/dist/utils/env-loader.utils.js +39 -31
  314. package/dist/utils/env-loader.utils.js.map +1 -1
  315. package/dist/utils/files.d.ts +47 -3
  316. package/dist/utils/files.js +98 -40
  317. package/dist/utils/files.js.map +1 -1
  318. package/dist/utils/init-agent.js +1 -2
  319. package/dist/utils/init-agent.js.map +1 -1
  320. package/dist/utils/init-helpers.d.ts +2 -10
  321. package/dist/utils/init-helpers.js +9 -17
  322. package/dist/utils/init-helpers.js.map +1 -1
  323. package/dist/utils/init-prompts.d.ts +0 -8
  324. package/dist/utils/init-prompts.js +0 -22
  325. package/dist/utils/init-prompts.js.map +1 -1
  326. package/dist/utils/prompt-handler.d.ts +3 -0
  327. package/dist/utils/prompt-handler.js +13 -0
  328. package/dist/utils/prompt-handler.js.map +1 -1
  329. package/dist/utils/sandbox-storage.d.ts +6 -5
  330. package/dist/utils/sandbox-storage.js +12 -12
  331. package/dist/utils/sandbox-storage.js.map +1 -1
  332. package/dist/utils/sandbox.d.ts +7 -30
  333. package/dist/utils/sandbox.js +247 -223
  334. package/dist/utils/sandbox.js.map +1 -1
  335. package/dist/utils/semver.d.ts +12 -0
  336. package/dist/utils/semver.js +23 -0
  337. package/dist/utils/semver.js.map +1 -1
  338. package/dist/utils/sync-display.d.ts +9 -0
  339. package/dist/utils/sync-display.js +67 -0
  340. package/dist/utils/sync-display.js.map +1 -0
  341. package/dist/utils/sync-fetch.d.ts +23 -0
  342. package/dist/utils/sync-fetch.js +64 -0
  343. package/dist/utils/sync-fetch.js.map +1 -0
  344. package/dist/utils/sync-helpers.d.ts +4 -59
  345. package/dist/utils/sync-helpers.js +4 -206
  346. package/dist/utils/sync-helpers.js.map +1 -1
  347. package/dist/web/app.css +912 -186
  348. package/dist/web/app.js +46 -46
  349. package/docs/API_INDEX.md +100 -0
  350. package/docs/API_REFERENCE.md +773 -0
  351. package/docs/CLI_REFERENCE.md +924 -0
  352. package/docs/GETTING_STARTED.md +862 -0
  353. package/docs/README.md +270 -0
  354. package/docs/api/AI.md +882 -0
  355. package/docs/api/Baskets.md +511 -0
  356. package/docs/api/CDN.md +524 -0
  357. package/docs/api/Data.md +446 -0
  358. package/docs/api/Jobs.md +524 -0
  359. package/docs/api/LuaAgent.md +454 -0
  360. package/docs/api/LuaJob.md +604 -0
  361. package/docs/api/LuaSkill.md +396 -0
  362. package/docs/api/LuaTool.md +521 -0
  363. package/docs/api/LuaWebhook.md +601 -0
  364. package/docs/api/Orders.md +514 -0
  365. package/docs/api/PostProcessor.md +565 -0
  366. package/docs/api/PreProcessor.md +630 -0
  367. package/docs/api/Products.md +507 -0
  368. package/docs/api/Templates.md +662 -0
  369. package/docs/api/User.md +567 -0
  370. package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
  371. package/docs/compiler-v2/ASSESSMENT.md +205 -0
  372. package/docs/compiler-v2/TEST_PLAN.md +306 -0
  373. package/package.json +3 -7
  374. package/template/package.json +1 -1
  375. package/template/tsconfig.json +1 -1
  376. package/dist/common/basket.instance.js.map +0 -1
  377. package/dist/common/data.entry.instance.js.map +0 -1
  378. package/dist/common/http.client.js.map +0 -1
  379. package/dist/common/job.instance.js.map +0 -1
  380. package/dist/common/order.instance.js.map +0 -1
  381. package/dist/common/product.instance.js.map +0 -1
  382. package/dist/common/product.pagination.instance.js.map +0 -1
  383. package/dist/common/product.search.instance.js.map +0 -1
  384. package/dist/common/user.instance.js.map +0 -1
  385. package/dist/config/auth.constants.d.ts +0 -11
  386. package/dist/config/auth.constants.js +0 -12
  387. package/dist/config/auth.constants.js.map +0 -1
  388. package/dist/config/init.constants.d.ts +0 -15
  389. package/dist/config/init.constants.js +0 -20
  390. package/dist/config/init.constants.js.map +0 -1
  391. package/dist/interfaces/compile.d.ts +0 -12
  392. package/dist/interfaces/compile.js +0 -5
  393. package/dist/interfaces/compile.js.map +0 -1
  394. package/dist/types/compile.types.d.ts +0 -131
  395. package/dist/types/compile.types.js +0 -6
  396. package/dist/types/compile.types.js.map +0 -1
  397. package/dist/utils/agent-code-utils.d.ts +0 -25
  398. package/dist/utils/agent-code-utils.js +0 -107
  399. package/dist/utils/agent-code-utils.js.map +0 -1
  400. package/dist/utils/bundling.d.ts +0 -89
  401. package/dist/utils/bundling.js +0 -1068
  402. package/dist/utils/bundling.js.map +0 -1
  403. package/dist/utils/compile.d.ts +0 -116
  404. package/dist/utils/compile.js +0 -1062
  405. package/dist/utils/compile.js.map +0 -1
  406. package/dist/utils/deploy-api.d.ts +0 -26
  407. package/dist/utils/deploy-api.js +0 -54
  408. package/dist/utils/deploy-api.js.map +0 -1
  409. package/dist/utils/deployment.d.ts +0 -26
  410. package/dist/utils/deployment.js +0 -218
  411. package/dist/utils/deployment.js.map +0 -1
  412. package/dist/utils/dev-helpers.d.ts +0 -47
  413. package/dist/utils/dev-helpers.js +0 -82
  414. package/dist/utils/dev-helpers.js.map +0 -1
  415. package/dist/utils/job-management.d.ts +0 -27
  416. package/dist/utils/job-management.js +0 -248
  417. package/dist/utils/job-management.js.map +0 -1
  418. package/dist/utils/mcp-server-management.d.ts +0 -26
  419. package/dist/utils/mcp-server-management.js +0 -197
  420. package/dist/utils/mcp-server-management.js.map +0 -1
  421. package/dist/utils/postprocessor-management.d.ts +0 -9
  422. package/dist/utils/postprocessor-management.js +0 -117
  423. package/dist/utils/postprocessor-management.js.map +0 -1
  424. package/dist/utils/pre-bundle-jobs.d.ts +0 -27
  425. package/dist/utils/pre-bundle-jobs.js +0 -189
  426. package/dist/utils/pre-bundle-jobs.js.map +0 -1
  427. package/dist/utils/preprocessor-management.d.ts +0 -9
  428. package/dist/utils/preprocessor-management.js +0 -117
  429. package/dist/utils/preprocessor-management.js.map +0 -1
  430. package/dist/utils/push-api.d.ts +0 -15
  431. package/dist/utils/push-api.js +0 -49
  432. package/dist/utils/push-api.js.map +0 -1
  433. package/dist/utils/push-helpers.d.ts +0 -82
  434. package/dist/utils/push-helpers.js +0 -246
  435. package/dist/utils/push-helpers.js.map +0 -1
  436. package/dist/utils/skill-management.d.ts +0 -39
  437. package/dist/utils/skill-management.js +0 -299
  438. package/dist/utils/skill-management.js.map +0 -1
  439. package/dist/utils/test-helpers.d.ts +0 -33
  440. package/dist/utils/test-helpers.js +0 -84
  441. package/dist/utils/test-helpers.js.map +0 -1
  442. package/dist/utils/test-prompts.d.ts +0 -23
  443. package/dist/utils/test-prompts.js +0 -187
  444. package/dist/utils/test-prompts.js.map +0 -1
  445. package/dist/utils/tool-detection.d.ts +0 -19
  446. package/dist/utils/tool-detection.js +0 -125
  447. package/dist/utils/tool-detection.js.map +0 -1
  448. package/dist/utils/webhook-management.d.ts +0 -27
  449. package/dist/utils/webhook-management.js +0 -241
  450. package/dist/utils/webhook-management.js.map +0 -1
  451. /package/dist/{common → api}/http.client.d.ts +0 -0
  452. /package/dist/{common → api}/http.client.js +0 -0
  453. /package/dist/{common → instances}/basket.instance.d.ts +0 -0
  454. /package/dist/{common → instances}/basket.instance.js +0 -0
  455. /package/dist/{common → instances}/data.entry.instance.d.ts +0 -0
  456. /package/dist/{common → instances}/data.entry.instance.js +0 -0
  457. /package/dist/{common → instances}/job.instance.d.ts +0 -0
  458. /package/dist/{common → instances}/job.instance.js +0 -0
  459. /package/dist/{common → instances}/order.instance.d.ts +0 -0
  460. /package/dist/{common → instances}/order.instance.js +0 -0
  461. /package/dist/{common → instances}/product.instance.d.ts +0 -0
  462. /package/dist/{common → instances}/product.instance.js +0 -0
  463. /package/dist/{common → instances}/product.pagination.instance.d.ts +0 -0
  464. /package/dist/{common → instances}/product.pagination.instance.js +0 -0
  465. /package/dist/{common → instances}/product.search.instance.d.ts +0 -0
  466. /package/dist/{common → instances}/product.search.instance.js +0 -0
  467. /package/dist/{common → instances}/user.instance.d.ts +0 -0
  468. /package/dist/{common → instances}/user.instance.js +0 -0
@@ -2,37 +2,60 @@
2
2
  * Push Command
3
3
  * Orchestrates pushing skill versions to the server
4
4
  */
5
- import fs from 'fs';
6
- import path from 'path';
7
- import yaml from 'js-yaml';
8
5
  import { compileCommand } from './compile.js';
9
- import { checkApiKey, loadApiKey } from '../services/auth.js';
10
- import { readSkillConfig } from '../utils/files.js';
11
- import { withErrorHandling, writeProgress, writeSuccess, writeInfo } from '../utils/cli.js';
6
+ import { readYamlConfig, } from '../utils/files.js';
7
+ import { withErrorHandling, writeProgress, writeSuccess, writeInfo, clearPromptLines } from '../utils/cli.js';
8
+ import { requireAuthOrExit } from '../utils/command-utils.js';
12
9
  import { safePrompt } from '../utils/prompt-handler.js';
13
- import { readDeployJson, validatePushConfig, validateDeployData, promptVersionConfirmOrUpdate, getAvailableSkills, updateSkillVersionInYaml, getSkillDeployData, } from '../utils/push-helpers.js';
14
- import { pushVersion } from '../utils/push-api.js';
15
- import { fetchVersions, publishVersion, } from '../utils/deploy-api.js';
10
+ import { incrementPatchVersion, maxSemver } from '../utils/semver.js';
16
11
  import { BASE_URLS } from '../config/constants.js';
17
- import PreProcessorApi from '../api/preprocessor.api.service.js';
18
- import PostProcessorApi from '../api/postprocessor.api.service.js';
19
- import DeveloperApi from '../api/developer.api.service.js';
20
- import { loadPersonaFromCode } from '../utils/agent-code-utils.js';
12
+ import PersonaApi from '../api/persona.api.service.js';
13
+ import { loadManifest, getAgentPersona } from '../utils/artifact-loader.js';
14
+ import { skillHandler as skillH, webhookHandler as webhookH, jobHandler as jobH, preprocessorHandler as preprocessorH, postprocessorHandler as postprocessorH, } from '../primitives/index.js';
15
+ import { pushBackupCommand } from './pushBackup.js';
21
16
  // ============================================================================
22
17
  // Core Push Helpers (shared by all push functions)
23
18
  // ============================================================================
19
+ /**
20
+ * Prompts user to confirm or update the version.
21
+ *
22
+ * @param currentVersion - Current version of the skill
23
+ * @returns Confirmed or updated version
24
+ */
25
+ async function promptVersionConfirmOrUpdate(currentVersion) {
26
+ console.log(`\nCurrent version: ${currentVersion || '(none - first push)'}`);
27
+ const answer = await safePrompt([
28
+ {
29
+ type: "input",
30
+ name: "newVersion",
31
+ message: "Enter new version to push:",
32
+ default: incrementPatchVersion(currentVersion),
33
+ validate: (input) => {
34
+ if (!input || input.trim() === "") {
35
+ return "Version cannot be empty";
36
+ }
37
+ // Basic semver validation
38
+ const semverRegex = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/;
39
+ if (!semverRegex.test(input.trim())) {
40
+ return "Version must follow semver format (e.g., 1.0.0, 1.0.0-alpha.1)";
41
+ }
42
+ return true;
43
+ }
44
+ }
45
+ ]);
46
+ if (!answer) {
47
+ console.log("Push cancelled.");
48
+ process.exit(0);
49
+ }
50
+ clearPromptLines(2);
51
+ return answer.newVersion.trim();
52
+ }
24
53
  /**
25
54
  * Authenticates the user and returns the API key
26
55
  * Exits with error if authentication fails
27
56
  */
28
57
  async function authenticateOrFail() {
29
- const apiKey = await loadApiKey();
30
- if (!apiKey) {
31
- console.log("āŒ No API key found. Please run 'lua auth configure' to set up your API key.");
32
- process.exit(1);
33
- }
34
- await checkApiKey(apiKey);
35
- return apiKey;
58
+ return requireAuthOrExit(false);
36
59
  }
37
60
  /**
38
61
  * Selects an entity from a list, either by options.entityName or interactive prompt
@@ -43,15 +66,13 @@ async function authenticateOrFail() {
43
66
  async function selectEntityOrFail(items, options, config) {
44
67
  const { entityType, nameFields = ['id', 'name'], formatChoice } = config;
45
68
  if (items.length === 0) {
46
- console.log(`āŒ No ${entityType}s found in lua.skill.yaml.`);
47
- process.exit(1);
69
+ throw new Error(`No ${entityType}s found in lua.skill.yaml.`);
48
70
  }
49
71
  // Non-interactive: find by name
50
72
  if (options.entityName) {
51
73
  const found = items.find((item) => nameFields.some(field => item[field] === options.entityName));
52
74
  if (!found) {
53
- console.log(`āŒ ${entityType} "${options.entityName}" not found`);
54
- process.exit(1);
75
+ throw new Error(`${entityType} "${options.entityName}" not found`);
55
76
  }
56
77
  writeInfo(`šŸ“¦ Selected ${entityType}: ${found.name}`);
57
78
  return found;
@@ -84,38 +105,28 @@ async function selectEntityOrFail(items, options, config) {
84
105
  * Resolves version from options or interactive prompt
85
106
  * Validates semantic versioning format
86
107
  */
87
- async function resolveVersionOrFail(currentVersion, options) {
108
+ async function resolveVersionOrFail(currentVersion, options, highestKnownVersion) {
109
+ // If version explicitly provided, use it
88
110
  if (options.version) {
89
111
  if (!/^\d+\.\d+\.\d+/.test(options.version)) {
90
- console.log(`āŒ Invalid version format: "${options.version}". Use semantic versioning (e.g., 1.0.5)`);
91
- process.exit(1);
112
+ throw new Error(`Invalid version format: "${options.version}". Use semantic versioning (e.g., 1.0.5)`);
92
113
  }
93
114
  writeInfo(`šŸ“ Using version: ${options.version}`);
94
115
  return options.version;
95
116
  }
117
+ // If force flag provided, auto-bump without prompting
118
+ if (options.force) {
119
+ // Bump from the highest known version (max of YAML and server) to avoid conflicts
120
+ const baseVersion = highestKnownVersion ? maxSemver(currentVersion, highestKnownVersion) : currentVersion;
121
+ const newVersion = incrementPatchVersion(baseVersion);
122
+ writeInfo(`šŸ“ Auto-bumping version: ${currentVersion} → ${newVersion}`);
123
+ return newVersion;
124
+ }
125
+ // Otherwise, prompt interactively
96
126
  return await promptVersionConfirmOrUpdate(currentVersion);
97
127
  }
98
128
  /**
99
- * Loads bundled entity data from dist folder
100
- * @returns The bundled data for the entity, or exits if not found
101
- */
102
- function loadBundledEntityData(filename, entityName, entityType) {
103
- const bundledPath = path.join(process.cwd(), 'dist', filename);
104
- if (!fs.existsSync(bundledPath)) {
105
- console.log(`āŒ Bundled ${entityType.toLowerCase()} data not found.`);
106
- console.log("šŸ’” Please ensure your code is properly compiled.");
107
- process.exit(1);
108
- }
109
- const bundled = JSON.parse(fs.readFileSync(bundledPath, 'utf8'));
110
- const bundledData = bundled.find((item) => item.name === entityName) || {};
111
- if (!bundledData || Object.keys(bundledData).length === 0) {
112
- console.log(`\nāŒ ${entityType} "${entityName}" not found in compiled code.`);
113
- console.log("šŸ’” This may have been removed or commented out in your code.");
114
- console.log(`šŸ’” Please uncomment the ${entityType.toLowerCase()} or remove it from lua.skill.yaml.`);
115
- process.exit(1);
116
- }
117
- return bundledData;
118
- }
129
+
119
130
  /**
120
131
  * Determines if we should deploy after push based on options or prompt
121
132
  */
@@ -139,6 +150,107 @@ async function shouldDeployAfterPush(options) {
139
150
  ]);
140
151
  return answer?.deployNow || false;
141
152
  }
153
+ // ============================================================================
154
+ // Generic Push/Deploy (replaces per-type push/deploy functions)
155
+ // ============================================================================
156
+ /**
157
+ * Generic push for any versioned primitive (webhook, job, preprocessor, postprocessor).
158
+ * Skill has its own flow due to tools array + config validation.
159
+ */
160
+ async function pushVersionedPrimitive(handler, options = {}) {
161
+ try {
162
+ // Step 1: Compile
163
+ writeProgress("šŸ“¦ Compiling project...");
164
+ await compileCommand();
165
+ writeSuccess("āœ… Compilation complete");
166
+ // Step 2: Authenticate
167
+ const apiKey = await authenticateOrFail();
168
+ writeSuccess("āœ… Authentication verified");
169
+ // Step 3: Read config
170
+ const config = readYamlConfig();
171
+ if (!config?.agent?.agentId) {
172
+ throw new Error("No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
173
+ }
174
+ const agentId = config.agent.agentId;
175
+ // Step 4: Get items from YAML and select
176
+ const items = handler.getFromYaml(config);
177
+ if (items.length === 0) {
178
+ throw new Error(`No ${handler.displayNamePlural} found in lua.skill.yaml.`);
179
+ }
180
+ const selected = await selectEntityOrFail(items, options, {
181
+ entityType: handler.displayName,
182
+ nameFields: ['id', handler.yamlConfig.idField, 'name']
183
+ });
184
+ const entityId = selected[handler.yamlConfig.idField];
185
+ if (!entityId) {
186
+ throw new Error(`${handler.displayName} "${selected.name}" has no server ID. Run 'lua compile' first.`);
187
+ }
188
+ // Step 5: Load bundled data
189
+ const manifest = loadManifest();
190
+ const pushData = handler.prepareForPush(manifest, selected.name);
191
+ if (!pushData) {
192
+ throw new Error(`${handler.displayName} "${selected.name}" not found in compiled output.`);
193
+ }
194
+ // Step 6: Resolve version (check server for highest to avoid conflicts)
195
+ const serverHighest = options.force
196
+ ? await handler.getHighestServerVersion(apiKey, agentId, entityId)
197
+ : undefined;
198
+ const confirmedVersion = await resolveVersionOrFail(selected.version, options, serverHighest ?? undefined);
199
+ if (confirmedVersion !== selected.version) {
200
+ handler.updateVersionInYaml(selected.name, confirmedVersion);
201
+ }
202
+ // Step 7: Push
203
+ writeProgress(`\nšŸš€ Pushing ${selected.name} v${confirmedVersion} to server...`);
204
+ const result = await handler.pushToServer(apiKey, agentId, entityId, { ...pushData, version: confirmedVersion });
205
+ if (!result.success) {
206
+ throw new Error(`Push Error: ${result.error || 'Unknown error'}`);
207
+ }
208
+ writeSuccess(`\nāœ… Successfully pushed ${selected.name} v${confirmedVersion}\n`);
209
+ // Step 8: Deploy if requested
210
+ if (await shouldDeployAfterPush(options)) {
211
+ await genericDeployAfterPush(handler, apiKey, agentId, entityId, selected.name, confirmedVersion, options.autoDeploy || false);
212
+ }
213
+ else {
214
+ writeInfo(`šŸ’” You can deploy later using: lua ${handler.displayNamePlural} production`);
215
+ }
216
+ }
217
+ catch (error) {
218
+ throw error;
219
+ }
220
+ }
221
+ /**
222
+ * Generic deploy/publish after push for any versioned primitive.
223
+ */
224
+ async function genericDeployAfterPush(handler, apiKey, agentId, entityId, entityName, version, skipConfirmation = false) {
225
+ try {
226
+ if (!skipConfirmation) {
227
+ console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
228
+ console.log("āš ļø This will affect ALL users immediately.\n");
229
+ const confirmAnswer = await safePrompt([{
230
+ type: 'confirm',
231
+ name: 'confirm',
232
+ message: 'Are you absolutely sure you want to deploy?',
233
+ default: false
234
+ }]);
235
+ if (!confirmAnswer || !confirmAnswer.confirm) {
236
+ console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
237
+ return;
238
+ }
239
+ }
240
+ writeProgress(`šŸ”„ Publishing ${handler.displayName} version...`);
241
+ const result = await handler.publishVersion(apiKey, agentId, entityId, version);
242
+ if (!result.success) {
243
+ console.error(`\nāŒ Deploy Error: ${result.error || 'Unknown error'}\n`);
244
+ return;
245
+ }
246
+ writeSuccess(`\nāœ… ${entityName} v${version} deployed to production\n`);
247
+ writeInfo(`šŸ’” The new ${handler.displayName} version is now active.`);
248
+ }
249
+ catch (error) {
250
+ console.error(`\nāŒ Error deploying ${handler.displayName}:`, error);
251
+ console.log(`šŸ’” You can deploy later using: lua ${handler.displayNamePlural} production\n`);
252
+ }
253
+ }
142
254
  /**
143
255
  * Main push command - pushes a skill or persona version to the server.
144
256
  *
@@ -165,33 +277,30 @@ export async function pushCommand(type, cmdObj) {
165
277
  force: cmdObj?.force || false,
166
278
  autoDeploy: cmdObj?.autoDeploy || false,
167
279
  entityName: cmdObj?.name || null,
168
- version: cmdObj?.version || null
280
+ version: cmdObj?.setVersion || null
169
281
  };
170
282
  let selectedType;
171
283
  // Handle 'all' type with force flag
172
284
  if (type === 'all') {
173
285
  if (!options.force) {
174
- console.error('āŒ The "all" type requires the --force flag');
175
286
  console.log('\nUsage:');
176
287
  console.log(' lua push all --force Push all components without prompts');
177
288
  console.log(' lua push all --force --auto-deploy Push and deploy all to production');
178
- process.exit(1);
289
+ throw new Error('The "all" type requires the --force flag');
179
290
  }
180
291
  return await pushAllCommand(options);
181
292
  }
182
293
  // Validate that entityName without type is not allowed
183
294
  if (options.entityName && !type) {
184
- console.error('āŒ Type must be specified when using the --name option.');
185
295
  console.log('\nUsage:');
186
- console.log(' lua push skill --name mySkill --version 1.0.5 Push specific skill');
187
- console.log(' lua push webhook --name myWebhook --version 2.0.0 Push specific webhook');
188
- process.exit(1);
296
+ console.log(' lua push skill --name mySkill --set-version 1.0.5 Push specific skill');
297
+ console.log(' lua push webhook --name myWebhook --set-version 2.0.0 Push specific webhook');
298
+ throw new Error('Type must be specified when using the --name option.');
189
299
  }
190
300
  // Step 1: Check if type was provided as argument
191
301
  if (type) {
192
302
  // Validate the provided type
193
- if (type !== 'skill' && type !== 'persona' && type !== 'webhook' && type !== 'job' && type !== 'preprocessor' && type !== 'postprocessor' && type !== 'mcp') {
194
- console.error(`āŒ Invalid type: "${type}". Must be "skill", "persona", "webhook", "job", "preprocessor", "postprocessor", "mcp", or "all".`);
303
+ if (type !== 'skill' && type !== 'persona' && type !== 'webhook' && type !== 'job' && type !== 'preprocessor' && type !== 'postprocessor' && type !== 'mcp' && type !== 'backup') {
195
304
  console.log('\nUsage:');
196
305
  console.log(' lua push - Interactive selection');
197
306
  console.log(' lua push skill - Push a skill directly');
@@ -201,8 +310,9 @@ export async function pushCommand(type, cmdObj) {
201
310
  console.log(' lua push preprocessor - Push a preprocessor directly');
202
311
  console.log(' lua push postprocessor - Push a postprocessor directly');
203
312
  console.log(' lua push mcp - Push an MCP server directly');
313
+ console.log(' lua push backup - Push project source backup');
204
314
  console.log(' lua push all --force - Push all components without prompts');
205
- process.exit(1);
315
+ throw new Error(`Invalid type: "${type}". Must be "skill", "persona", "webhook", "job", "preprocessor", "postprocessor", "mcp", "backup", or "all".`);
206
316
  }
207
317
  selectedType = type;
208
318
  }
@@ -220,7 +330,8 @@ export async function pushCommand(type, cmdObj) {
220
330
  { name: 'šŸ“„ PreProcessor', value: 'preprocessor' },
221
331
  { name: 'šŸ“¤ PostProcessor', value: 'postprocessor' },
222
332
  { name: 'šŸ”Œ MCP Server', value: 'mcp' },
223
- { name: 'šŸŒ™ Persona', value: 'persona' }
333
+ { name: 'šŸŒ™ Persona', value: 'persona' },
334
+ { name: 'šŸ’¾ Backup (source files)', value: 'backup' }
224
335
  ]
225
336
  }
226
337
  ]);
@@ -232,89 +343,31 @@ export async function pushCommand(type, cmdObj) {
232
343
  }
233
344
  // Step 3: Route to appropriate function
234
345
  if (selectedType === 'skill') {
235
- await pushSkillVersion(options);
346
+ await pushVersionedPrimitive(skillH, options);
236
347
  }
237
348
  else if (selectedType === 'webhook') {
238
- await pushWebhookVersion(options);
349
+ await pushVersionedPrimitive(webhookH, options);
239
350
  }
240
351
  else if (selectedType === 'job') {
241
- await pushJobVersion(options);
352
+ await pushVersionedPrimitive(jobH, options);
242
353
  }
243
354
  else if (selectedType === 'preprocessor') {
244
- await pushPreProcessorVersion(options);
355
+ await pushVersionedPrimitive(preprocessorH, options);
245
356
  }
246
357
  else if (selectedType === 'postprocessor') {
247
- await pushPostProcessorVersion(options);
358
+ await pushVersionedPrimitive(postprocessorH, options);
248
359
  }
249
360
  else if (selectedType === 'mcp') {
250
- await pushMCPServerVersion(options);
361
+ await pushMCPServer(options);
362
+ }
363
+ else if (selectedType === 'backup') {
364
+ await pushBackupCommand({ force: options.force });
251
365
  }
252
366
  else {
253
367
  await pushPersonaVersion(options);
254
368
  }
255
369
  }, "push");
256
370
  }
257
- /**
258
- * Push skill version to the server.
259
- */
260
- async function pushSkillVersion(options = {}) {
261
- // Step 1: Validate configuration
262
- const yamlConfig = readSkillConfig();
263
- validatePushConfig(yamlConfig);
264
- const config = yamlConfig;
265
- // Step 2: Get available skills and select
266
- const availableSkills = getAvailableSkills(config);
267
- if (availableSkills.length === 0) {
268
- console.log("āŒ No skills found in configuration. Please compile your skill first using 'lua compile'.");
269
- process.exit(1);
270
- }
271
- const selectedSkill = await selectEntityOrFail(availableSkills, options, {
272
- entityType: 'skill',
273
- nameFields: ['skillId', 'name']
274
- });
275
- // Step 3: Handle version
276
- const confirmedVersion = await resolveVersionOrFail(selectedSkill.version, options);
277
- if (confirmedVersion !== selectedSkill.version) {
278
- writeInfo(`šŸ“ Updating version from ${selectedSkill.version} to ${confirmedVersion}`);
279
- updateSkillVersionInYaml(selectedSkill.name, confirmedVersion);
280
- selectedSkill.version = confirmedVersion;
281
- }
282
- // Step 4: Authenticate
283
- const apiKey = await authenticateOrFail();
284
- writeProgress("āœ… Authenticated");
285
- // Step 5: Compile the skill
286
- writeProgress("šŸ”„ Compiling skill...");
287
- await compileCommand();
288
- // Step 6: Validate and extract deploy data
289
- const deployData = readDeployJson();
290
- validateDeployData(deployData, selectedSkill);
291
- const skillDeployData = getSkillDeployData(deployData, selectedSkill.name);
292
- // Step 7: Push version to server
293
- writeProgress("šŸ”„ Pushing version to server...");
294
- const result = await pushVersion(apiKey, config.agent.agentId, selectedSkill.skillId, skillDeployData);
295
- if (result.success && result.data) {
296
- const pushedVersion = result.data.version;
297
- writeSuccess(`āœ… Version ${pushedVersion} of "${selectedSkill.name}" pushed successfully`);
298
- // Update YAML with the version returned from server
299
- if (pushedVersion !== selectedSkill.version) {
300
- writeInfo(`šŸ“ Updating YAML with server version: ${pushedVersion}`);
301
- updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
302
- selectedSkill.version = pushedVersion;
303
- }
304
- // Step 8: Deploy if requested
305
- if (await shouldDeployAfterPush(options)) {
306
- await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion);
307
- }
308
- }
309
- else if (result.error) {
310
- console.log(`āŒ ${result.error.message}`);
311
- process.exit(1);
312
- }
313
- else {
314
- console.log("āŒ Failed to push version. Please try again.");
315
- process.exit(1);
316
- }
317
- }
318
371
  /**
319
372
  * Push persona version to the server.
320
373
  *
@@ -329,16 +382,14 @@ async function pushSkillVersion(options = {}) {
329
382
  */
330
383
  async function pushPersonaVersion(options = {}) {
331
384
  // Step 1: Validate configuration
332
- const config = readSkillConfig();
385
+ const config = readYamlConfig();
333
386
  if (!config || !config.agent?.agentId) {
334
- console.log("āŒ No agent configuration found. Please run 'lua init' first.");
335
- process.exit(1);
387
+ throw new Error("No agent configuration found. Please run 'lua init' first.");
336
388
  }
337
389
  // Step 2: Load current persona from code
338
- const currentPersona = loadPersonaFromCode();
390
+ const currentPersona = getAgentPersona();
339
391
  if (!currentPersona || !currentPersona.trim()) {
340
- console.log("āŒ No persona found in configuration. Please edit your persona first using 'lua persona'.");
341
- process.exit(1);
392
+ throw new Error("No persona found in configuration. Please edit your persona first using 'lua persona'.");
342
393
  }
343
394
  writeInfo(`šŸ“¦ Pushing persona for agent: ${config.agent.agentId}`);
344
395
  // Show preview of persona
@@ -369,67 +420,54 @@ async function pushPersonaVersion(options = {}) {
369
420
  // Step 5: Push persona version to server
370
421
  writeProgress("šŸ”„ Creating persona version...");
371
422
  try {
372
- const response = await fetch(`${BASE_URLS.API}/developer/agents/${config.agent.agentId}/persona/version`, {
373
- method: 'POST',
374
- headers: {
375
- 'Authorization': `Bearer ${apiKey}`,
376
- 'Content-Type': 'application/json'
377
- },
378
- body: JSON.stringify({ persona: currentPersona })
379
- });
380
- if (!response.ok) {
381
- const errorText = await response.text();
382
- throw new Error(`HTTP error! status: ${response.status}, ${errorText}`);
423
+ const personaApi = new PersonaApi(BASE_URLS.API, apiKey, config.agent.agentId);
424
+ const result = await personaApi.createVersion(currentPersona);
425
+ if (!result.success || !result.data) {
426
+ throw new Error(result.error?.message || 'Failed to create persona version');
383
427
  }
384
- const data = await response.json();
385
- const versionNum = data.version || data.data?.version || 'N/A';
428
+ const versionNum = result.data.version;
386
429
  writeSuccess(`āœ… Persona version ${versionNum} created successfully`);
387
430
  // Step 6: Deploy if requested
388
431
  if (await shouldDeployAfterPush(options)) {
389
- await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum);
432
+ await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum, options.autoDeploy || false);
390
433
  }
391
434
  else {
392
435
  writeInfo("šŸ’” You can deploy this version later using: lua deploy");
393
436
  }
394
437
  }
395
438
  catch (error) {
396
- console.log('āŒ Error creating persona version:', error);
397
- process.exit(1);
439
+ throw error;
398
440
  }
399
441
  }
400
442
  /**
401
443
  * Deploy a persona version immediately after pushing
402
444
  */
403
- async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
445
+ async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum, skipConfirmation = false) {
404
446
  try {
405
- // Show warning
406
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
407
- console.log("āš ļø This will affect ALL users immediately.\n");
408
- const confirmAnswer = await safePrompt([
409
- {
410
- type: 'confirm',
411
- name: 'confirm',
412
- message: 'Are you absolutely sure you want to deploy this persona version?',
413
- default: false
447
+ // Skip confirmation when called from auto-deploy with --force
448
+ if (!skipConfirmation) {
449
+ // Show warning
450
+ console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
451
+ console.log("āš ļø This will affect ALL users immediately.\n");
452
+ const confirmAnswer = await safePrompt([
453
+ {
454
+ type: 'confirm',
455
+ name: 'confirm',
456
+ message: 'Are you absolutely sure you want to deploy this persona version?',
457
+ default: false
458
+ }
459
+ ]);
460
+ if (!confirmAnswer || !confirmAnswer.confirm) {
461
+ console.log("\nāŒ Deployment cancelled. Persona version created but not deployed.\n");
462
+ return;
414
463
  }
415
- ]);
416
- if (!confirmAnswer || !confirmAnswer.confirm) {
417
- console.log("\nāŒ Deployment cancelled. Persona version created but not deployed.\n");
418
- return;
419
464
  }
420
465
  writeProgress("šŸ”„ Deploying persona version...");
421
- const deployResponse = await fetch(`${BASE_URLS.API}/developer/agents/${agentId}/persona/version/${versionNum}`, {
422
- method: 'POST',
423
- headers: {
424
- 'Authorization': `Bearer ${apiKey}`,
425
- 'Content-Type': 'application/json'
426
- },
427
- body: JSON.stringify({})
428
- });
429
- if (!deployResponse.ok) {
430
- const errorText = await deployResponse.text();
431
- console.error(`\nāŒ Deploy Error: ${deployResponse.status} - ${errorText}\n`);
432
- throw new Error(`HTTP error! status: ${deployResponse.status}`);
466
+ const personaApi = new PersonaApi(BASE_URLS.API, apiKey, agentId);
467
+ const deployResult = await personaApi.deployVersion(versionNum);
468
+ if (!deployResult.success) {
469
+ console.error(`\nāŒ Deploy Error: ${deployResult.error?.message || 'Unknown error'}\n`);
470
+ throw new Error(deployResult.error?.message || 'Failed to deploy persona version');
433
471
  }
434
472
  writeSuccess(`\nāœ… Persona version ${versionNum} deployed successfully to production\n`);
435
473
  writeInfo("šŸ’” The new persona is now active for all users.");
@@ -440,689 +478,47 @@ async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
440
478
  }
441
479
  }
442
480
  /**
443
- * Push webhook version to the server.
444
- *
445
- * Steps:
446
- * 1. Run compilation
447
- * 2. Validate config and deploy data
448
- * 3. Select webhook to push
449
- * 4. Confirm or update version
450
- * 5. Push to server
451
- * 6. Optionally deploy immediately
481
+ * Push MCP server (non-versioned, upsert pattern).
482
+ * Uses the same compile→auth→config→select pattern as versioned primitives,
483
+ * with MCP-specific logic delegated to the handler.
452
484
  */
453
- async function pushWebhookVersion(options = {}) {
485
+ async function pushMCPServer(options = {}) {
454
486
  try {
455
- // Step 1: Compile
456
487
  writeProgress("šŸ“¦ Compiling project...");
457
488
  await compileCommand();
458
489
  writeSuccess("āœ… Compilation complete");
459
- // Step 2: Authenticate
460
490
  const apiKey = await authenticateOrFail();
461
491
  writeSuccess("āœ… Authentication verified");
462
- // Step 3: Read configuration
463
- const config = readSkillConfig();
464
- if (!config?.agent?.agentId) {
465
- console.log("āŒ No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
466
- process.exit(1);
467
- }
468
- const webhooks = config.webhooks || [];
469
- if (webhooks.length === 0) {
470
- console.log("āŒ No webhooks found in lua.skill.yaml.");
471
- console.log("šŸ’” Make sure you have created a webhook using LuaWebhook in your code.");
472
- process.exit(1);
473
- }
474
- // Step 4: Select webhook
475
- const selectedWebhook = await selectEntityOrFail(webhooks, options, {
476
- entityType: 'webhook',
477
- nameFields: ['id', 'webhookId', 'name']
478
- });
479
- // Step 5: Load and validate bundled data
480
- const bundledWebhookData = loadBundledEntityData('webhooks.json', selectedWebhook.name, 'Webhook');
481
- // Step 6: Handle version
482
- const confirmedVersion = await resolveVersionOrFail(selectedWebhook.version, options);
483
- if (confirmedVersion !== selectedWebhook.version) {
484
- writeInfo(`šŸ“ Updating version from ${selectedWebhook.version} to ${confirmedVersion}`);
485
- updateWebhookVersionInYaml(selectedWebhook.name, confirmedVersion);
486
- }
487
- // Step 7: Prepare and push webhook data
488
- const webhookData = {
489
- name: selectedWebhook.name,
490
- version: confirmedVersion,
491
- description: bundledWebhookData.description || selectedWebhook.description || `Webhook: ${selectedWebhook.name}`,
492
- webhookId: selectedWebhook.webhookId,
493
- querySchema: bundledWebhookData.querySchema,
494
- headerSchema: bundledWebhookData.headerSchema,
495
- bodySchema: bundledWebhookData.bodySchema,
496
- code: bundledWebhookData.code,
497
- executeFunction: bundledWebhookData.executeFunction
498
- };
499
- writeProgress(`\nšŸš€ Pushing ${selectedWebhook.name} v${confirmedVersion} to server...`);
500
- const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${config.agent.agentId}/${selectedWebhook.webhookId}/version`, {
501
- method: 'POST',
502
- headers: {
503
- 'Authorization': `Bearer ${apiKey}`,
504
- 'Content-Type': 'application/json'
505
- },
506
- body: JSON.stringify(webhookData)
507
- });
508
- if (!response.ok) {
509
- const errorText = await response.text();
510
- console.log(`\nāŒ Push Error: ${response.status} - ${errorText}\n`);
511
- throw new Error(`HTTP error! status: ${response.status}`);
512
- }
513
- await response.json();
514
- writeSuccess(`\nāœ… Successfully pushed ${selectedWebhook.name} v${confirmedVersion}\n`);
515
- writeInfo(`šŸ“¦ Webhook URL (id): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.webhookId}`);
516
- writeInfo(`šŸ”— Webhook URL (name): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.name}`);
517
- // Step 8: Deploy if requested
518
- if (await shouldDeployAfterPush(options)) {
519
- await deployWebhookVersionAfterPush(apiKey, config.agent.agentId, selectedWebhook, confirmedVersion);
520
- }
521
- else {
522
- writeInfo("šŸ’” You can deploy this version later using: lua webhooks production");
523
- }
524
- }
525
- catch (error) {
526
- console.log('āŒ Error pushing webhook version:', error);
527
- process.exit(1);
528
- }
529
- }
530
- /**
531
- * Deploy a webhook version immediately after pushing
532
- */
533
- async function deployWebhookVersionAfterPush(apiKey, agentId, selectedWebhook, pushedVersion) {
534
- try {
535
- // Show warning
536
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
537
- console.log("āš ļø This will affect ALL users immediately.\n");
538
- const confirmAnswer = await safePrompt([
539
- {
540
- type: 'confirm',
541
- name: 'confirm',
542
- message: 'Are you absolutely sure you want to deploy?',
543
- default: false
544
- }
545
- ]);
546
- if (!confirmAnswer || !confirmAnswer.confirm) {
547
- console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
548
- return;
549
- }
550
- writeProgress("šŸ”„ Publishing webhook version...");
551
- const publishResponse = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${selectedWebhook.webhookId}/${pushedVersion}/publish`, {
552
- method: 'POST',
553
- headers: {
554
- 'Authorization': `Bearer ${apiKey}`,
555
- 'Content-Type': 'application/json'
556
- },
557
- body: JSON.stringify({})
558
- });
559
- if (!publishResponse.ok) {
560
- const errorText = await publishResponse.text();
561
- console.error(`\nāŒ Deploy Error: ${publishResponse.status} - ${errorText}\n`);
562
- throw new Error(`HTTP error! status: ${publishResponse.status}`);
563
- }
564
- writeSuccess(`\nāœ… Webhook ${selectedWebhook.name} v${pushedVersion} deployed successfully to production\n`);
565
- writeInfo("šŸ’” The new webhook version is now active for all users.");
566
- }
567
- catch (error) {
568
- console.error('\nāŒ Error deploying webhook version:', error);
569
- console.log('šŸ’” You can deploy later using: lua webhooks production\n');
570
- }
571
- }
572
- /**
573
- * Updates webhook version in lua.skill.yaml
574
- */
575
- function updateWebhookVersionInYaml(webhookName, newVersion) {
576
- try {
577
- const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
578
- const yamlContent = fs.readFileSync(yamlPath, 'utf8');
579
- const config = yaml.load(yamlContent);
580
- if (config.webhooks) {
581
- const webhook = config.webhooks.find((w) => w.name === webhookName);
582
- if (webhook) {
583
- webhook.version = newVersion;
584
- fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
585
- }
586
- }
587
- }
588
- catch (error) {
589
- console.warn('āš ļø Could not update webhook version in YAML:', error);
590
- }
591
- }
592
- /**
593
- * Updates job version in lua.skill.yaml
594
- */
595
- function updateJobVersionInYaml(jobName, newVersion) {
596
- try {
597
- const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
598
- const yamlContent = fs.readFileSync(yamlPath, 'utf8');
599
- const config = yaml.load(yamlContent);
600
- if (config.jobs) {
601
- const job = config.jobs.find((j) => j.name === jobName);
602
- if (job) {
603
- job.version = newVersion;
604
- fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
605
- }
606
- }
607
- }
608
- catch (error) {
609
- console.warn('āš ļø Could not update job version in YAML:', error);
610
- }
611
- }
612
- /**
613
- * Push job version to the server (simplified version)
614
- */
615
- async function pushJobVersion(options = {}) {
616
- try {
617
- // Step 1: Compile
618
- writeProgress("šŸ“¦ Compiling project...");
619
- await compileCommand();
620
- writeSuccess("āœ… Compilation complete");
621
- // Step 2: Authenticate
622
- const apiKey = await authenticateOrFail();
623
- // Step 3: Read configuration
624
- const config = readSkillConfig();
625
- if (!config?.agent?.agentId) {
626
- console.log("āŒ No agent ID found in lua.skill.yaml.");
627
- process.exit(1);
628
- }
629
- const jobs = config.jobs || [];
630
- if (jobs.length === 0) {
631
- console.log("āŒ No jobs found in lua.skill.yaml.");
632
- console.log("šŸ’” Make sure you have created a job using LuaJob in your code.");
633
- process.exit(1);
634
- }
635
- // Step 4: Select job
636
- const selectedJob = await selectEntityOrFail(jobs, options, {
637
- entityType: 'job',
638
- nameFields: ['id', 'jobId', 'name']
639
- });
640
- // Step 5: Load bundled data
641
- const bundledJobData = loadBundledEntityData('jobs.json', selectedJob.name, 'Job');
642
- // Step 6: Handle version
643
- const confirmedVersion = await resolveVersionOrFail(selectedJob.version, options);
644
- if (confirmedVersion !== selectedJob.version) {
645
- writeInfo(`šŸ“ Updating version from ${selectedJob.version} to ${confirmedVersion}`);
646
- updateJobVersionInYaml(selectedJob.name, confirmedVersion);
647
- }
648
- // Step 7: Prepare and push
649
- const jobData = {
650
- name: selectedJob.name,
651
- version: confirmedVersion,
652
- description: bundledJobData.description || selectedJob.description || `Job: ${selectedJob.name}`,
653
- jobId: selectedJob.jobId,
654
- schedule: bundledJobData.schedule || selectedJob.schedule,
655
- timeout: bundledJobData.timeout,
656
- retry: bundledJobData.retry,
657
- code: bundledJobData.code,
658
- executeFunction: bundledJobData.executeFunction,
659
- metadata: bundledJobData.metadata || selectedJob.metadata
660
- };
661
- writeProgress(`\nšŸš€ Pushing ${selectedJob.name} v${confirmedVersion} to server...`);
662
- const response = await fetch(`${BASE_URLS.API}/developer/jobs/${config.agent.agentId}/${selectedJob.jobId}/version`, {
663
- method: 'POST',
664
- headers: {
665
- 'Authorization': `Bearer ${apiKey}`,
666
- 'Content-Type': 'application/json'
667
- },
668
- body: JSON.stringify(jobData)
669
- });
670
- if (!response.ok) {
671
- const errorText = await response.text();
672
- console.log(`\nāŒ Push Error: ${response.status} - ${errorText}\n`);
673
- throw new Error(`HTTP error! status: ${response.status}`);
674
- }
675
- writeSuccess(`\nāœ… Successfully pushed ${selectedJob.name} v${confirmedVersion}\n`);
676
- // Step 8: Deploy if requested
677
- if (await shouldDeployAfterPush(options)) {
678
- await deployJobVersionAfterPush(apiKey, config.agent.agentId, selectedJob, confirmedVersion);
679
- }
680
- else {
681
- writeInfo("šŸ’” You can deploy this version later using: lua jobs production");
682
- }
683
- }
684
- catch (error) {
685
- console.log('āŒ Error pushing job version:', error);
686
- process.exit(1);
687
- }
688
- }
689
- /**
690
- * Deploy a job version immediately after pushing
691
- */
692
- async function deployJobVersionAfterPush(apiKey, agentId, selectedJob, pushedVersion) {
693
- try {
694
- // Show warning
695
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
696
- console.log("āš ļø This will affect ALL users immediately.\n");
697
- const confirmAnswer = await safePrompt([
698
- {
699
- type: 'confirm',
700
- name: 'confirm',
701
- message: 'Are you absolutely sure you want to deploy?',
702
- default: false
703
- }
704
- ]);
705
- if (!confirmAnswer || !confirmAnswer.confirm) {
706
- console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
707
- return;
708
- }
709
- writeProgress("šŸ”„ Publishing job version...");
710
- const publishResponse = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${selectedJob.jobId}/${pushedVersion}/publish`, {
711
- method: 'POST',
712
- headers: {
713
- 'Authorization': `Bearer ${apiKey}`,
714
- 'Content-Type': 'application/json'
715
- },
716
- body: JSON.stringify({})
717
- });
718
- if (!publishResponse.ok) {
719
- const errorText = await publishResponse.text();
720
- console.error(`\nāŒ Deploy Error: ${publishResponse.status} - ${errorText}\n`);
721
- throw new Error(`HTTP error! status: ${publishResponse.status}`);
722
- }
723
- writeSuccess(`\nāœ… Job ${selectedJob.name} v${pushedVersion} deployed successfully to production\n`);
724
- writeInfo("šŸ’” The new job version is now active and will run on schedule.");
725
- }
726
- catch (error) {
727
- console.error('\nāŒ Error deploying job version:', error);
728
- console.log('šŸ’” You can deploy later using: lua jobs production\n');
729
- }
730
- }
731
- /**
732
- * Push preprocessor version to the server.
733
- */
734
- async function pushPreProcessorVersion(options = {}) {
735
- try {
736
- // Step 1: Compile
737
- writeProgress("šŸ“¦ Compiling project...");
738
- await compileCommand();
739
- writeSuccess("āœ… Compilation complete");
740
- // Step 2: Authenticate
741
- const apiKey = await authenticateOrFail();
742
- // Step 3: Read configuration
743
- const config = readSkillConfig();
744
- if (!config?.agent?.agentId) {
745
- console.log("āŒ No agent ID found in lua.skill.yaml.");
746
- process.exit(1);
747
- }
748
- const preprocessors = config.preprocessors || [];
749
- if (preprocessors.length === 0) {
750
- console.log("āŒ No preprocessors found in lua.skill.yaml.");
751
- process.exit(1);
752
- }
753
- // Step 4: Select preprocessor
754
- const selected = await selectEntityOrFail(preprocessors, options, {
755
- entityType: 'preprocessor',
756
- nameFields: ['id', 'preprocessorId', 'name']
757
- });
758
- // Step 5: Load bundled data
759
- const bundledData = loadBundledEntityData('preprocessors.json', selected.name, 'PreProcessor');
760
- if (!bundledData.code) {
761
- console.log(`āŒ PreProcessor "${selected.name}" has no code in compiled output.`);
762
- process.exit(1);
763
- }
764
- // Step 6: Handle version
765
- const confirmedVersion = await resolveVersionOrFail(selected.version, options);
766
- if (confirmedVersion !== selected.version) {
767
- writeInfo(`šŸ“ Updating version from ${selected.version} to ${confirmedVersion}`);
768
- updateProcessorVersionInYaml('preprocessors', selected.name, confirmedVersion);
769
- }
770
- // Step 7: Prepare and push
771
- const versionData = {
772
- name: selected.name,
773
- version: confirmedVersion,
774
- description: bundledData.description || selected.description,
775
- preprocessorId: selected.preprocessorId,
776
- code: bundledData.code,
777
- executeFunction: bundledData.executeFunction,
778
- async: Boolean(bundledData.async ?? false)
779
- };
780
- writeProgress(`\nšŸš€ Pushing ${selected.name} v${confirmedVersion}...`);
781
- const api = new PreProcessorApi(BASE_URLS.API, apiKey, config.agent.agentId);
782
- const result = await api.pushPreProcessor(selected.preprocessorId, versionData);
783
- if (result.success) {
784
- writeSuccess(`\nāœ… PreProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
785
- // Step 8: Deploy if requested
786
- if (await shouldDeployAfterPush(options)) {
787
- await deployPreProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
788
- }
789
- else {
790
- writeInfo("šŸ’” You can deploy this version later using: lua preprocessors production");
791
- }
792
- }
793
- else {
794
- console.log(`āŒ Failed to push: ${result.error?.message}`);
795
- }
796
- }
797
- catch (error) {
798
- console.log('āŒ Error pushing preprocessor:', error);
799
- process.exit(1);
800
- }
801
- }
802
- /**
803
- * Deploy a preprocessor version immediately after pushing
804
- */
805
- async function deployPreProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
806
- try {
807
- // Show warning
808
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
809
- console.log("āš ļø This will affect ALL users immediately.\n");
810
- const confirmAnswer = await safePrompt([
811
- {
812
- type: 'confirm',
813
- name: 'confirm',
814
- message: 'Are you absolutely sure you want to deploy?',
815
- default: false
816
- }
817
- ]);
818
- if (!confirmAnswer || !confirmAnswer.confirm) {
819
- console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
820
- return;
821
- }
822
- writeProgress("šŸ”„ Publishing preprocessor version...");
823
- const api = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
824
- const publishResponse = await api.publishPreProcessorVersion(selected.preprocessorId, pushedVersion);
825
- if (!publishResponse.success) {
826
- console.error(`\nāŒ Deploy Error: ${publishResponse.error?.message || 'Unknown error'}\n`);
827
- throw new Error(publishResponse.error?.message || 'Failed to publish preprocessor version');
828
- }
829
- writeSuccess(`\nāœ… PreProcessor ${selected.name} v${pushedVersion} deployed successfully to production\n`);
830
- writeInfo("šŸ’” The new preprocessor version is now active for all users.");
831
- }
832
- catch (error) {
833
- console.error('\nāŒ Error deploying preprocessor version:', error);
834
- console.log('šŸ’” You can deploy later using: lua preprocessors production\n');
835
- }
836
- }
837
- /**
838
- * Push postprocessor version to the server.
839
- */
840
- async function pushPostProcessorVersion(options = {}) {
841
- try {
842
- // Step 1: Compile
843
- writeProgress("šŸ“¦ Compiling project...");
844
- await compileCommand();
845
- writeSuccess("āœ… Compilation complete");
846
- // Step 2: Authenticate
847
- const apiKey = await authenticateOrFail();
848
- // Step 3: Read configuration
849
- const config = readSkillConfig();
492
+ const config = readYamlConfig();
850
493
  if (!config?.agent?.agentId) {
851
- console.log("āŒ No agent ID found in lua.skill.yaml.");
852
- process.exit(1);
853
- }
854
- const postprocessors = config.postprocessors || [];
855
- if (postprocessors.length === 0) {
856
- console.log("āŒ No postprocessors found in lua.skill.yaml.");
857
- process.exit(1);
858
- }
859
- // Step 4: Select postprocessor
860
- const selected = await selectEntityOrFail(postprocessors, options, {
861
- entityType: 'postprocessor',
862
- nameFields: ['id', 'postprocessorId', 'name']
494
+ throw new Error("No agent ID found. Run 'lua init' first.");
495
+ }
496
+ const agentId = config.agent.agentId;
497
+ const { mcpServerHandler } = await import('../primitives/mcp-server.handler.js');
498
+ const bundledServers = mcpServerHandler.loadBundledServers();
499
+ if (bundledServers.length === 0) {
500
+ throw new Error("No MCP servers found in compiled output.");
501
+ }
502
+ const selectedServer = await selectEntityOrFail(bundledServers, options, {
503
+ entityType: 'MCP server',
504
+ nameFields: ['name'],
505
+ formatChoice: (s) => `${s.name} (${s.transport})`,
863
506
  });
864
- // Step 5: Load bundled data
865
- const bundledData = loadBundledEntityData('postprocessors.json', selected.name, 'PostProcessor');
866
- if (!bundledData.code) {
867
- console.log(`āŒ PostProcessor "${selected.name}" has no code in compiled output.`);
868
- process.exit(1);
869
- }
870
- // Step 6: Handle version
871
- const confirmedVersion = await resolveVersionOrFail(selected.version, options);
872
- if (confirmedVersion !== selected.version) {
873
- writeInfo(`šŸ“ Updating version from ${selected.version} to ${confirmedVersion}`);
874
- updateProcessorVersionInYaml('postprocessors', selected.name, confirmedVersion);
875
- }
876
- // Step 7: Prepare and push
877
- const versionData = {
878
- name: selected.name,
879
- version: confirmedVersion,
880
- description: bundledData.description || selected.description,
881
- postprocessorId: selected.postprocessorId,
882
- code: bundledData.code,
883
- executeFunction: bundledData.executeFunction
884
- };
885
- writeProgress(`\nšŸš€ Pushing ${selected.name} v${confirmedVersion}...`);
886
- const api = new PostProcessorApi(BASE_URLS.API, apiKey, config.agent.agentId);
887
- const result = await api.pushPostProcessor(selected.postprocessorId, versionData);
888
- if (result.success) {
889
- writeSuccess(`\nāœ… PostProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
890
- // Step 8: Deploy if requested
891
- if (await shouldDeployAfterPush(options)) {
892
- await deployPostProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
893
- }
894
- else {
895
- writeInfo("šŸ’” You can deploy this version later using: lua postprocessors production");
896
- }
897
- }
898
- else {
899
- console.log(`āŒ Failed to push: ${result.error?.message}`);
900
- }
901
- }
902
- catch (error) {
903
- console.log('āŒ Error pushing postprocessor:', error);
904
- process.exit(1);
905
- }
906
- }
907
- /**
908
- * Deploy a postprocessor version immediately after pushing
909
- */
910
- async function deployPostProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
911
- try {
912
- // Show warning
913
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
914
- console.log("āš ļø This will affect ALL users immediately.\n");
915
- const confirmAnswer = await safePrompt([
916
- {
917
- type: 'confirm',
918
- name: 'confirm',
919
- message: 'Are you absolutely sure you want to deploy?',
920
- default: false
921
- }
922
- ]);
923
- if (!confirmAnswer || !confirmAnswer.confirm) {
924
- console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
925
- return;
926
- }
927
- writeProgress("šŸ”„ Publishing postprocessor version...");
928
- const api = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
929
- const publishResponse = await api.publishPostProcessorVersion(selected.postprocessorId, pushedVersion);
930
- if (!publishResponse.success) {
931
- console.error(`\nāŒ Deploy Error: ${publishResponse.error?.message || 'Unknown error'}\n`);
932
- throw new Error(publishResponse.error?.message || 'Failed to publish postprocessor version');
933
- }
934
- writeSuccess(`\nāœ… PostProcessor ${selected.name} v${pushedVersion} deployed successfully to production\n`);
935
- writeInfo("šŸ’” The new postprocessor version is now active for all users.");
936
- }
937
- catch (error) {
938
- console.error('\nāŒ Error deploying postprocessor version:', error);
939
- console.log('šŸ’” You can deploy later using: lua postprocessors production\n');
940
- }
941
- }
942
- /**
943
- * Updates processor version in lua.skill.yaml
944
- */
945
- function updateProcessorVersionInYaml(processorType, processorName, newVersion) {
946
- try {
947
- const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
948
- const yamlContent = fs.readFileSync(yamlPath, 'utf8');
949
- const config = yaml.load(yamlContent);
950
- if (config[processorType]) {
951
- const processor = config[processorType].find((p) => p.name === processorName);
952
- if (processor) {
953
- processor.version = newVersion;
954
- fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
955
- }
956
- }
957
- }
958
- catch (error) {
959
- console.warn('āš ļø Could not update processor version in YAML:', error);
960
- }
961
- }
962
- /**
963
- * Push MCP Server to the server
964
- */
965
- async function pushMCPServerVersion(options = {}) {
966
- try {
967
- // Step 1: Compile
968
- writeProgress("šŸ“¦ Compiling project...");
969
- await compileCommand();
970
- writeSuccess("āœ… Compilation complete");
971
- // Step 2: Authenticate
972
- const apiKey = await authenticateOrFail();
973
- writeSuccess("āœ… Authentication verified");
974
- // Step 3: Read configuration
975
- const config = readSkillConfig();
976
- if (!config?.agent?.agentId) {
977
- console.log("āŒ No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
978
- process.exit(1);
979
- }
980
- const mcpServers = config.mcpServers || [];
981
- if (mcpServers.length === 0) {
982
- console.log("āŒ No MCP servers found in lua.skill.yaml.");
983
- console.log("šŸ’” Make sure you have defined MCP servers in your LuaAgent configuration.");
984
- process.exit(1);
985
- }
986
- // Step 4: Load bundled MCP server data
987
- const bundledServersPath = path.join(process.cwd(), 'dist', 'mcp-servers.json');
988
- if (!fs.existsSync(bundledServersPath)) {
989
- console.log('āŒ Bundled MCP server data not found.');
990
- console.log("šŸ’” Please ensure your MCP servers are properly compiled.");
991
- process.exit(1);
992
- }
993
- const bundledServers = JSON.parse(fs.readFileSync(bundledServersPath, 'utf8'));
994
- // Step 5: Select MCP server (special handling - uses bundled data with YAML IDs)
995
- let selectedServer;
996
- let bundledServerData;
997
- if (options.entityName) {
998
- bundledServerData = bundledServers.find((s) => s.id === options.entityName || s.mcpServerId === options.entityName || s.name === options.entityName);
999
- if (!bundledServerData) {
1000
- console.log(`āŒ MCP server "${options.entityName}" not found`);
1001
- process.exit(1);
1002
- }
1003
- const yamlEntry = mcpServers.find((s) => s.name === bundledServerData.name);
1004
- selectedServer = { ...bundledServerData, mcpServerId: yamlEntry?.mcpServerId };
1005
- writeInfo(`šŸ“¦ Selected MCP server: ${selectedServer.name}`);
1006
- }
1007
- else if (bundledServers.length === 1) {
1008
- bundledServerData = bundledServers[0];
1009
- const yamlEntry = mcpServers.find((s) => s.name === bundledServerData.name);
1010
- selectedServer = { ...bundledServerData, mcpServerId: yamlEntry?.mcpServerId };
1011
- writeInfo(`šŸ“¦ Pushing MCP server: ${selectedServer.name}`);
1012
- }
1013
- else {
1014
- const serverAnswer = await safePrompt([
1015
- {
1016
- type: 'list',
1017
- name: 'selectedServer',
1018
- message: 'Select an MCP server to push:',
1019
- choices: bundledServers.map((server) => {
1020
- const yamlEntry = mcpServers.find((s) => s.name === server.name);
1021
- return {
1022
- name: `${server.name} (${server.transport})`,
1023
- value: { ...server, mcpServerId: yamlEntry?.mcpServerId }
1024
- };
1025
- })
1026
- }
1027
- ]);
1028
- if (!serverAnswer) {
1029
- console.log("Push cancelled.");
1030
- return;
1031
- }
1032
- selectedServer = serverAnswer.selectedServer;
1033
- bundledServerData = selectedServer;
1034
- }
1035
- // Step 6: Prepare server data for push
1036
- // Include resolver fields for function-based env/headers/url resolution
1037
- const serverData = {
1038
- name: bundledServerData.name,
1039
- transport: bundledServerData.transport,
1040
- timeout: bundledServerData.timeout,
1041
- ...(bundledServerData.transport === 'stdio' ? {
1042
- command: bundledServerData.command,
1043
- args: bundledServerData.args,
1044
- env: bundledServerData.env,
1045
- envResolver: bundledServerData.envResolver, // Compressed function for runtime resolution
1046
- } : {
1047
- url: bundledServerData.url,
1048
- urlResolver: bundledServerData.urlResolver, // Compressed function for runtime resolution
1049
- headers: bundledServerData.headers,
1050
- headersResolver: bundledServerData.headersResolver, // Compressed function for runtime resolution
1051
- })
1052
- };
1053
- writeProgress(`\nšŸš€ Pushing MCP server "${selectedServer.name}" to server...`);
1054
- const developerApi = new DeveloperApi(BASE_URLS.API, apiKey, config.agent.agentId);
1055
- const result = await developerApi.upsertMCPServer(serverData);
1056
- if (result.success && result.data) {
1057
- writeSuccess(`\nāœ… MCP server "${selectedServer.name}" pushed successfully\n`);
1058
- // Step 7: Activate if requested (MCP uses activate instead of deploy)
1059
- if (await shouldDeployAfterPush(options)) {
1060
- writeProgress("šŸ”„ Activating MCP server...");
1061
- const activateResult = await developerApi.activateMCPServer(result.data.id);
1062
- if (activateResult.success) {
1063
- writeSuccess(`\nāœ… MCP server "${selectedServer.name}" activated successfully\n`);
1064
- writeInfo("šŸ’” The server's tools are now available to your agent.");
1065
- }
1066
- else {
1067
- console.log(`āŒ Failed to activate: ${activateResult.error?.message}`);
1068
- }
1069
- }
1070
- else {
1071
- writeInfo("šŸ’” You can activate this server later using: lua mcp activate");
1072
- }
1073
- }
1074
- else {
1075
- console.log(`āŒ Failed to push: ${result.error?.message}`);
1076
- }
1077
- }
1078
- catch (error) {
1079
- console.log('āŒ Error pushing MCP server:', error);
1080
- process.exit(1);
1081
- }
1082
- }
1083
- /**
1084
- * Deploy a version immediately after pushing
1085
- */
1086
- async function deployVersionAfterPush(apiKey, agentId, selectedSkill, pushedVersion) {
1087
- try {
1088
- writeProgress("\nšŸ”„ Fetching available versions...");
1089
- // Fetch versions to verify the pushed version exists
1090
- const versionsResponse = await fetchVersions(apiKey, agentId, selectedSkill.skillId);
1091
- if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
1092
- console.error("āŒ No versions available. The push may have failed.");
1093
- return;
1094
- }
1095
- // Show warning
1096
- console.log("\nāš ļø WARNING: You are about to deploy to PRODUCTION!");
1097
- console.log("āš ļø This will affect ALL users immediately.\n");
1098
- const confirmAnswer = await safePrompt([
1099
- {
1100
- type: 'confirm',
1101
- name: 'confirm',
1102
- message: 'Are you absolutely sure you want to deploy?',
1103
- default: false
1104
- }
1105
- ]);
1106
- if (!confirmAnswer || !confirmAnswer.confirm) {
1107
- console.log("\nāŒ Deployment cancelled. Version pushed but not deployed.\n");
1108
- return;
507
+ writeProgress(`\nšŸš€ Pushing MCP server "${selectedServer.name}"...`);
508
+ const result = await mcpServerHandler.upsertOnServer(apiKey, agentId, selectedServer);
509
+ if (!result.success) {
510
+ throw new Error(`Failed: ${result.error}`);
1109
511
  }
1110
- // Find the pushed version in the list
1111
- const versionToDeploy = versionsResponse.versions.find((v) => v.version === pushedVersion);
1112
- if (!versionToDeploy) {
1113
- console.error(`\nāŒ Version ${pushedVersion} not found in available versions.\n`);
1114
- return;
512
+ writeSuccess(`\nāœ… MCP server "${selectedServer.name}" pushed successfully\n`);
513
+ if (result.id && await shouldDeployAfterPush(options)) {
514
+ writeProgress("šŸ”„ Activating MCP server...");
515
+ const activateResult = await mcpServerHandler.activate(apiKey, agentId, result.id);
516
+ if (activateResult.success)
517
+ writeSuccess(`āœ… MCP server activated\n`);
1115
518
  }
1116
- writeProgress("šŸ”„ Publishing version...");
1117
- const publishResponse = await publishVersion(apiKey, agentId, selectedSkill.skillId, pushedVersion);
1118
- writeSuccess(`\nāœ… Version ${pushedVersion} of "${selectedSkill.name}" deployed successfully to production\n`);
1119
- // Update YAML with deployed version (should already be updated from push, but ensure consistency)
1120
- writeInfo(`šŸ“ Ensuring YAML is updated with deployed version: ${pushedVersion}`);
1121
- updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
1122
519
  }
1123
520
  catch (error) {
1124
- console.error('\nāŒ Error deploying version:', error);
1125
- console.log('šŸ’” You can deploy later using: lua deploy\n');
521
+ throw error;
1126
522
  }
1127
523
  }
1128
524
  /**
@@ -1146,525 +542,171 @@ async function pushAllCommand(options) {
1146
542
  writeProgress("šŸ“¦ Compiling project...");
1147
543
  await compileCommand();
1148
544
  // Step 2: Load configuration and API key
1149
- const config = readSkillConfig();
545
+ const config = readYamlConfig();
1150
546
  if (!config?.agent?.agentId) {
1151
- console.error('āŒ No agent ID found in lua.skill.yaml. Run "lua init" first.');
1152
- process.exit(1);
547
+ throw new Error('No agent ID found in lua.skill.yaml. Run "lua init" first.');
1153
548
  }
1154
- const apiKey = await loadApiKey();
1155
- if (!apiKey) {
1156
- console.error('āŒ No API key found. Run "lua auth configure" first.');
1157
- process.exit(1);
1158
- }
1159
- const agentId = config.agent.agentId; // Validated above, safe to assert
1160
- // Step 3: Read deploy.json for component data
1161
- const deployJsonPath = path.join(process.cwd(), '.lua', 'deploy.json');
1162
- if (!fs.existsSync(deployJsonPath)) {
1163
- console.error('āŒ No deploy.json found. Compilation may have failed.');
1164
- process.exit(1);
549
+ const apiKey = await requireAuthOrExit(false);
550
+ const agentId = config.agent.agentId;
551
+ // Step 3: Load manifest
552
+ let manifest;
553
+ try {
554
+ manifest = loadManifest();
1165
555
  }
1166
- const deployData = JSON.parse(fs.readFileSync(deployJsonPath, 'utf8'));
1167
- // Step 3b: Read bundled webhooks and jobs from dist/
1168
- const webhooksJsonPath = path.join(process.cwd(), 'dist', 'webhooks.json');
1169
- const jobsJsonPath = path.join(process.cwd(), 'dist', 'jobs.json');
1170
- const preprocessorsJsonPath = path.join(process.cwd(), 'dist', 'preprocessors.json');
1171
- const postprocessorsJsonPath = path.join(process.cwd(), 'dist', 'postprocessors.json');
1172
- const bundledWebhooks = fs.existsSync(webhooksJsonPath)
1173
- ? JSON.parse(fs.readFileSync(webhooksJsonPath, 'utf8'))
1174
- : [];
1175
- const bundledJobs = fs.existsSync(jobsJsonPath)
1176
- ? JSON.parse(fs.readFileSync(jobsJsonPath, 'utf8'))
1177
- : [];
1178
- const bundledPreprocessors = fs.existsSync(preprocessorsJsonPath)
1179
- ? JSON.parse(fs.readFileSync(preprocessorsJsonPath, 'utf8'))
1180
- : [];
1181
- const bundledPostprocessors = fs.existsSync(postprocessorsJsonPath)
1182
- ? JSON.parse(fs.readFileSync(postprocessorsJsonPath, 'utf8'))
1183
- : [];
1184
- // Track results for both push and deploy
1185
- const results = {
1186
- skills: [],
1187
- webhooks: [],
1188
- jobs: [],
1189
- preprocessors: [],
1190
- postprocessors: []
556
+ catch (error) {
557
+ throw new Error(`Compilation output not found. Compilation may have failed. ${error.message}`);
558
+ }
559
+ // Track results and deploy queue per handler
560
+ const allResults = [];
561
+ const toDeploy = [];
562
+ // Icons per kind for display
563
+ const kindIcons = {
564
+ skill: 'šŸ“¦', webhook: 'šŸŖ', job: 'ā°', preprocessor: 'šŸ“„', postprocessor: 'šŸ“¤',
1191
565
  };
1192
- // Track what needs to be deployed
1193
- const toDeploySkills = [];
1194
- const toDeployWebhooks = [];
1195
- const toDeployJobs = [];
1196
- const toDeployPreprocessors = [];
1197
- const toDeployPostprocessors = [];
1198
- // Step 4: Push all skills
1199
- if (config.skills && config.skills.length > 0) {
1200
- writeProgress(`\nšŸ“¦ Pushing ${config.skills.length} skill(s)...`);
1201
- for (const skillConfig of config.skills) {
1202
- try {
1203
- const skillData = deployData.skills.find((s) => s.name === skillConfig.name);
1204
- if (!skillData) {
1205
- console.warn(`āš ļø Skill "${skillConfig.name}" not found in deploy.json, skipping`);
1206
- continue;
1207
- }
1208
- // Validate skillId and version exist
1209
- const skillId = skillConfig.skillId;
1210
- const currentVersion = skillConfig.version;
1211
- if (!skillId) {
1212
- console.warn(`āš ļø Skill "${skillConfig.name}" has no skillId, skipping`);
1213
- continue;
1214
- }
1215
- if (!currentVersion) {
1216
- console.warn(`āš ļø Skill "${skillConfig.name}" has no version, skipping`);
1217
- continue;
1218
- }
1219
- // Auto-bump patch version
1220
- const newVersion = bumpPatchVersion(currentVersion);
1221
- writeInfo(` šŸ“ ${skillConfig.name}: ${currentVersion} → ${newVersion}`);
1222
- // Push version - use the full skillData with tools
1223
- const pushResult = await pushVersion(apiKey, agentId, skillId, {
1224
- ...skillData, // Include all fields from deploy.json (tools, name, etc.)
1225
- version: newVersion, // Override with new version
1226
- });
1227
- if (!pushResult.success) {
1228
- console.error(` āŒ Failed to push ${skillConfig.name}:`, pushResult.error?.message);
1229
- continue;
1230
- }
1231
- // Update YAML with new version
1232
- updateSkillVersionInYaml(skillConfig.name, newVersion);
1233
- results.skills.push({ name: skillConfig.name, version: newVersion, skillId });
1234
- writeSuccess(` āœ… ${skillConfig.name} v${newVersion} pushed`);
1235
- // Queue for deployment if requested
1236
- if (options.autoDeploy) {
1237
- toDeploySkills.push({ skillId, version: newVersion, name: skillConfig.name });
1238
- }
1239
- }
1240
- catch (error) {
1241
- console.error(` āŒ Failed to push ${skillConfig.name}:`, error.message);
1242
- }
1243
- }
1244
- }
1245
- // Step 5: Push all webhooks
1246
- if (config.webhooks && config.webhooks.length > 0) {
1247
- writeProgress(`\nšŸŖ Pushing ${config.webhooks.length} webhook(s)...`);
1248
- for (const webhookConfig of config.webhooks) {
1249
- try {
1250
- const webhookData = bundledWebhooks.find((w) => w.name === webhookConfig.name);
1251
- if (!webhookData) {
1252
- console.warn(`āš ļø Webhook "${webhookConfig.name}" not found in compiled data, skipping`);
1253
- continue;
1254
- }
1255
- // Validate webhookId and version exist
1256
- if (!webhookConfig.webhookId) {
1257
- console.warn(`āš ļø Webhook "${webhookConfig.name}" has no webhookId, skipping`);
1258
- continue;
1259
- }
1260
- if (!webhookConfig.version) {
1261
- console.warn(`āš ļø Webhook "${webhookConfig.name}" has no version, skipping`);
1262
- continue;
1263
- }
1264
- // Auto-bump patch version
1265
- const newVersion = bumpPatchVersion(webhookConfig.version);
1266
- writeInfo(` šŸ“ ${webhookConfig.name}: ${webhookConfig.version} → ${newVersion}`);
1267
- // Prepare webhook data for push
1268
- const pushData = {
1269
- name: webhookConfig.name,
1270
- version: newVersion,
1271
- description: webhookData.description || '',
1272
- webhookId: webhookConfig.webhookId,
1273
- querySchema: webhookData.querySchema,
1274
- headerSchema: webhookData.headerSchema,
1275
- bodySchema: webhookData.bodySchema,
1276
- code: webhookData.code,
1277
- executeFunction: webhookData.executeFunction
1278
- };
1279
- // Push version using fetch (like existing webhook push)
1280
- const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${webhookConfig.webhookId}/version`, {
1281
- method: 'POST',
1282
- headers: {
1283
- 'Authorization': `Bearer ${apiKey}`,
1284
- 'Content-Type': 'application/json'
1285
- },
1286
- body: JSON.stringify(pushData)
1287
- });
1288
- if (!response.ok) {
1289
- throw new Error(`HTTP ${response.status}: ${await response.text()}`);
1290
- }
1291
- // Update YAML
1292
- updateWebhookVersionInYaml(webhookConfig.name, newVersion);
1293
- results.webhooks.push({ name: webhookConfig.name, version: newVersion });
1294
- writeSuccess(` āœ… ${webhookConfig.name} v${newVersion} pushed`);
1295
- // Queue for deployment if requested
1296
- if (options.autoDeploy) {
1297
- toDeployWebhooks.push({ webhookId: webhookConfig.webhookId, version: newVersion, name: webhookConfig.name });
1298
- }
1299
- }
1300
- catch (error) {
1301
- console.error(` āŒ Failed to push ${webhookConfig.name}:`, error.message);
1302
- }
1303
- }
1304
- }
1305
- // Step 6: Push all jobs
1306
- if (config.jobs && config.jobs.length > 0) {
1307
- writeProgress(`\nā° Pushing ${config.jobs.length} job(s)...`);
1308
- for (const jobConfig of config.jobs) {
1309
- try {
1310
- const jobData = bundledJobs.find((j) => j.name === jobConfig.name);
1311
- if (!jobData) {
1312
- console.warn(`āš ļø Job "${jobConfig.name}" not found in compiled data, skipping`);
1313
- continue;
1314
- }
1315
- // Validate jobId and version exist
1316
- if (!jobConfig.jobId) {
1317
- console.warn(`āš ļø Job "${jobConfig.name}" has no jobId, skipping`);
1318
- continue;
1319
- }
1320
- if (!jobConfig.version) {
1321
- console.warn(`āš ļø Job "${jobConfig.name}" has no version, skipping`);
1322
- continue;
1323
- }
1324
- // Auto-bump patch version
1325
- const newVersion = bumpPatchVersion(jobConfig.version);
1326
- writeInfo(` šŸ“ ${jobConfig.name}: ${jobConfig.version} → ${newVersion}`);
1327
- // Prepare job data for push
1328
- const pushData = {
1329
- name: jobConfig.name,
1330
- version: newVersion,
1331
- description: jobData.description || '',
1332
- jobId: jobConfig.jobId,
1333
- schedule: jobData.schedule || jobConfig.schedule,
1334
- timeout: jobData.timeout,
1335
- retry: jobData.retry,
1336
- code: jobData.code,
1337
- executeFunction: jobData.executeFunction,
1338
- metadata: jobData.metadata
1339
- };
1340
- // Push version using fetch
1341
- const response = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${jobConfig.jobId}/version`, {
1342
- method: 'POST',
1343
- headers: {
1344
- 'Authorization': `Bearer ${apiKey}`,
1345
- 'Content-Type': 'application/json'
1346
- },
1347
- body: JSON.stringify(pushData)
1348
- });
1349
- if (!response.ok) {
1350
- throw new Error(`HTTP ${response.status}: ${await response.text()}`);
1351
- }
1352
- // Update YAML
1353
- updateJobVersionInYaml(jobConfig.name, newVersion);
1354
- results.jobs.push({ name: jobConfig.name, version: newVersion });
1355
- writeSuccess(` āœ… ${jobConfig.name} v${newVersion} pushed`);
1356
- // Queue for deployment if requested
1357
- if (options.autoDeploy) {
1358
- toDeployJobs.push({ jobId: jobConfig.jobId, version: newVersion, name: jobConfig.name });
1359
- }
1360
- }
1361
- catch (error) {
1362
- console.error(` āŒ Failed to push ${jobConfig.name}:`, error.message);
1363
- }
1364
- }
1365
- }
1366
- // Step 7: Push all preprocessors
1367
- if (config.preprocessors && config.preprocessors.length > 0) {
1368
- writeProgress(`\nšŸ“„ Pushing ${config.preprocessors.length} preprocessor(s)...`);
1369
- const preprocessorService = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
1370
- for (const processorConfig of config.preprocessors) {
566
+ // Step 4: Push all versioned primitives using handlers
567
+ const handlers = [skillH, webhookH, jobH, preprocessorH, postprocessorH];
568
+ for (const handler of handlers) {
569
+ const items = handler.getFromYaml(config);
570
+ if (items.length === 0)
571
+ continue;
572
+ const icon = kindIcons[handler.kind] || 'šŸ“¦';
573
+ writeProgress(`\n${icon} Pushing ${items.length} ${handler.displayName}(s)...`);
574
+ for (const item of items) {
1371
575
  try {
1372
- const processorData = bundledPreprocessors.find((p) => p.name === processorConfig.name);
1373
- if (!processorData) {
1374
- console.warn(`āš ļø Preprocessor "${processorConfig.name}" not found in compiled data, skipping`);
576
+ const pushData = handler.prepareForPush(manifest, item.name);
577
+ if (!pushData) {
578
+ console.warn(`āš ļø ${handler.displayName} "${item.name}" not found in compiled output, skipping`);
1375
579
  continue;
1376
580
  }
1377
- // Validate preprocessorId and version exist
1378
- const preprocessorId = processorConfig.preprocessorId;
1379
- const currentVersion = processorConfig.version;
1380
- if (!preprocessorId) {
1381
- console.warn(`āš ļø Preprocessor "${processorConfig.name}" has no preprocessorId, skipping`);
581
+ const entityId = item[handler.yamlConfig.idField];
582
+ if (!entityId) {
583
+ console.warn(`āš ļø ${handler.displayName} "${item.name}" has no server ID, skipping. Run 'lua compile' first.`);
1382
584
  continue;
1383
585
  }
1384
- if (!currentVersion) {
1385
- console.warn(`āš ļø Preprocessor "${processorConfig.name}" has no version, skipping`);
586
+ if (!item.version) {
587
+ console.warn(`āš ļø ${handler.displayName} "${item.name}" has no version, skipping`);
1386
588
  continue;
1387
589
  }
1388
- // Auto-bump patch version
1389
- const newVersion = bumpPatchVersion(currentVersion);
1390
- writeInfo(` šŸ“ ${processorConfig.name}: ${currentVersion} → ${newVersion}`);
1391
- // Prepare version data
1392
- const versionData = {
1393
- name: processorConfig.name,
1394
- version: newVersion,
1395
- description: processorData.description || '',
1396
- preprocessorId: preprocessorId,
1397
- code: processorData.code,
1398
- executeFunction: processorData.executeFunction,
1399
- async: Boolean(processorData.async ?? false)
1400
- };
1401
- // Push version
1402
- const result = await preprocessorService.pushPreProcessor(preprocessorId, versionData);
590
+ // Auto-bump version (check server for highest to avoid conflicts)
591
+ const serverHighest = await handler.getHighestServerVersion(apiKey, agentId, entityId);
592
+ const baseVersion = serverHighest ? maxSemver(item.version, serverHighest) : item.version;
593
+ const newVersion = incrementPatchVersion(baseVersion);
594
+ writeInfo(` šŸ“ ${item.name}: ${item.version} → ${newVersion}`);
595
+ // Push
596
+ const result = await handler.pushToServer(apiKey, agentId, entityId, { ...pushData, version: newVersion });
1403
597
  if (!result.success) {
1404
- throw new Error(result.error?.message || 'Failed to push preprocessor');
1405
- }
1406
- // Update YAML
1407
- updateProcessorVersionInYaml('preprocessors', processorConfig.name, newVersion);
1408
- results.preprocessors.push({ name: processorConfig.name, version: newVersion });
1409
- writeSuccess(` āœ… ${processorConfig.name} v${newVersion} pushed`);
1410
- // Queue for deployment if requested
1411
- if (options.autoDeploy) {
1412
- toDeployPreprocessors.push({ preprocessorId, version: newVersion, name: processorConfig.name });
1413
- }
1414
- }
1415
- catch (error) {
1416
- console.error(` āŒ Failed to push ${processorConfig.name}:`, error.message);
1417
- }
1418
- }
1419
- }
1420
- // Step 8: Push all postprocessors
1421
- if (config.postprocessors && config.postprocessors.length > 0) {
1422
- writeProgress(`\nšŸ“¤ Pushing ${config.postprocessors.length} postprocessor(s)...`);
1423
- const postprocessorService = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
1424
- for (const processorConfig of config.postprocessors) {
1425
- try {
1426
- const processorData = bundledPostprocessors.find((p) => p.name === processorConfig.name);
1427
- if (!processorData) {
1428
- console.warn(`āš ļø Postprocessor "${processorConfig.name}" not found in compiled data, skipping`);
1429
- continue;
1430
- }
1431
- // Validate postprocessorId and version exist
1432
- const postprocessorId = processorConfig.postprocessorId;
1433
- const currentVersion = processorConfig.version;
1434
- if (!postprocessorId) {
1435
- console.warn(`āš ļø Postprocessor "${processorConfig.name}" has no postprocessorId, skipping`);
598
+ console.error(` āŒ Failed to push ${item.name}: ${result.error}`);
1436
599
  continue;
1437
600
  }
1438
- if (!currentVersion) {
1439
- console.warn(`āš ļø Postprocessor "${processorConfig.name}" has no version, skipping`);
1440
- continue;
1441
- }
1442
- // Auto-bump patch version
1443
- const newVersion = bumpPatchVersion(currentVersion);
1444
- writeInfo(` šŸ“ ${processorConfig.name}: ${currentVersion} → ${newVersion}`);
1445
- // Prepare version data
1446
- const versionData = {
1447
- name: processorConfig.name,
1448
- version: newVersion,
1449
- description: processorData.description || '',
1450
- postprocessorId: postprocessorId,
1451
- code: processorData.code,
1452
- executeFunction: processorData.executeFunction
1453
- };
1454
- // Push version
1455
- const result = await postprocessorService.pushPostProcessor(postprocessorId, versionData);
1456
- if (!result.success) {
1457
- throw new Error(result.error?.message || 'Failed to push postprocessor');
1458
- }
1459
- // Update YAML
1460
- updateProcessorVersionInYaml('postprocessors', processorConfig.name, newVersion);
1461
- results.postprocessors.push({ name: processorConfig.name, version: newVersion });
1462
- writeSuccess(` āœ… ${processorConfig.name} v${newVersion} pushed`);
1463
- // Queue for deployment if requested
601
+ handler.updateVersionInYaml(item.name, newVersion, { silent: true });
602
+ allResults.push({ handler, name: item.name, version: newVersion, entityId });
603
+ writeSuccess(` āœ… ${item.name} v${newVersion} pushed`);
1464
604
  if (options.autoDeploy) {
1465
- toDeployPostprocessors.push({ postprocessorId, version: newVersion, name: processorConfig.name });
605
+ toDeploy.push({ handler, name: item.name, version: newVersion, entityId });
1466
606
  }
1467
607
  }
1468
608
  catch (error) {
1469
- console.error(` āŒ Failed to push ${processorConfig.name}:`, error.message);
609
+ console.error(` āŒ Failed to push ${item.name}: ${error.message}`);
1470
610
  }
1471
611
  }
1472
612
  }
1473
- // Step 9: Push MCP server configurations
1474
- const mcpServersJsonPath = path.join(process.cwd(), 'dist', 'mcp-servers.json');
1475
- if (fs.existsSync(mcpServersJsonPath)) {
1476
- const mcpServers = JSON.parse(fs.readFileSync(mcpServersJsonPath, 'utf8'));
1477
- if (mcpServers.length > 0) {
1478
- writeProgress(`\nšŸ”Œ Pushing ${mcpServers.length} MCP server(s)...`);
613
+ // Step 5: Push MCP server configurations (non-versioned, separate flow)
614
+ const { mcpServerHandler: mcpH } = await import('../primitives/mcp-server.handler.js');
615
+ const mcpServers = mcpH.loadBundledServers();
616
+ if (mcpServers.length > 0) {
617
+ writeProgress(`\nšŸ”Œ Pushing ${mcpServers.length} MCP server(s)...`);
618
+ for (const serverConfig of mcpServers) {
1479
619
  try {
1480
- const DeveloperApi = (await import('../api/developer.api.service.js')).default;
1481
- const developerApi = new DeveloperApi(BASE_URLS.API, apiKey, agentId);
1482
- for (const serverConfig of mcpServers) {
1483
- try {
1484
- // Upsert the MCP server (create or update by name)
1485
- const result = await developerApi.upsertMCPServer(serverConfig);
1486
- if (result.success && result.data) {
1487
- const mcpServerId = result.data.id;
1488
- const isActive = result.data.active;
1489
- writeSuccess(` āœ… ${serverConfig.name} (${serverConfig.transport}) - ${isActive ? 'active' : 'inactive'}`);
1490
- // Auto-activate if autoDeploy is enabled
1491
- if (options.autoDeploy && !isActive) {
1492
- const activateResult = await developerApi.activateMCPServer(mcpServerId);
1493
- if (activateResult.success) {
1494
- writeSuccess(` šŸ”Œ Auto-activated`);
1495
- }
1496
- }
1497
- }
1498
- else {
1499
- console.error(` āŒ Failed to push ${serverConfig.name}:`, result.error?.message);
1500
- }
1501
- }
1502
- catch (error) {
1503
- console.error(` āŒ Failed to push ${serverConfig.name}:`, error.message);
620
+ const result = await mcpH.upsertOnServer(apiKey, agentId, serverConfig);
621
+ if (result.success && result.id) {
622
+ writeSuccess(` āœ… ${serverConfig.name} (${serverConfig.transport})`);
623
+ if (options.autoDeploy && !result.active) {
624
+ const activateResult = await mcpH.activate(apiKey, agentId, result.id);
625
+ if (activateResult.success)
626
+ writeSuccess(` šŸ”Œ Auto-activated`);
1504
627
  }
1505
628
  }
629
+ else {
630
+ console.error(` āŒ Failed to push ${serverConfig.name}:`, result.error);
631
+ }
1506
632
  }
1507
633
  catch (error) {
1508
- console.error(` āŒ Failed to push MCP servers:`, error.message);
634
+ console.error(` āŒ Failed to push ${serverConfig.name}:`, error.message);
1509
635
  }
1510
636
  }
1511
637
  }
1512
- // Step 10: Deploy all components if autoDeploy is enabled
1513
- if (options.autoDeploy && (toDeploySkills.length > 0 || toDeployWebhooks.length > 0 || toDeployJobs.length > 0 || toDeployPreprocessors.length > 0 || toDeployPostprocessors.length > 0)) {
638
+ // Step 6: Deploy all queued components
639
+ if (options.autoDeploy && toDeploy.length > 0) {
1514
640
  writeProgress('\nšŸš€ Deploying all pushed versions to production...');
1515
641
  writeInfo('ā±ļø Waiting for server to process versions (5 seconds)...\n');
1516
- // Wait for server to process all pushed versions
1517
642
  await new Promise(resolve => setTimeout(resolve, 5000));
1518
- // Deploy all skills
1519
- if (toDeploySkills.length > 0) {
1520
- writeProgress(`šŸ“¦ Deploying ${toDeploySkills.length} skill(s)...`);
1521
- for (const skill of toDeploySkills) {
1522
- const deployed = await retryDeploy(() => publishVersion(apiKey, agentId, skill.skillId, skill.version), skill.name, skill.version, 2 // Only 2 retries since we already waited
1523
- );
1524
- if (deployed) {
1525
- writeSuccess(` šŸš€ ${skill.name} v${skill.version} deployed`);
1526
- }
1527
- else {
1528
- console.warn(` āš ļø ${skill.name} deployment failed`);
1529
- }
1530
- }
1531
- }
1532
- // Deploy all webhooks
1533
- if (toDeployWebhooks.length > 0) {
1534
- writeProgress(`šŸŖ Deploying ${toDeployWebhooks.length} webhook(s)...`);
1535
- for (const webhook of toDeployWebhooks) {
1536
- const deployed = await retryDeploy(async () => {
1537
- const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${webhook.webhookId}/${webhook.version}/publish`, {
1538
- method: 'PUT',
1539
- headers: {
1540
- 'Authorization': `Bearer ${apiKey}`,
1541
- 'Content-Type': 'application/json'
1542
- }
1543
- });
1544
- if (!response.ok) {
1545
- throw new Error(`HTTP ${response.status}`);
1546
- }
1547
- }, webhook.name, webhook.version, 2);
1548
- if (deployed) {
1549
- writeSuccess(` šŸš€ ${webhook.name} v${webhook.version} deployed`);
1550
- }
1551
- else {
1552
- console.warn(` āš ļø ${webhook.name} deployment failed`);
1553
- }
1554
- }
1555
- }
1556
- // Deploy all jobs
1557
- if (toDeployJobs.length > 0) {
1558
- writeProgress(`ā° Deploying ${toDeployJobs.length} job(s)...`);
1559
- for (const job of toDeployJobs) {
1560
- const deployed = await retryDeploy(async () => {
1561
- const response = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${job.jobId}/${job.version}/publish`, {
1562
- method: 'PUT',
1563
- headers: {
1564
- 'Authorization': `Bearer ${apiKey}`,
1565
- 'Content-Type': 'application/json'
1566
- }
1567
- });
1568
- if (!response.ok) {
1569
- throw new Error(`HTTP ${response.status}`);
1570
- }
1571
- }, job.name, job.version, 2);
1572
- if (deployed) {
1573
- writeSuccess(` šŸš€ ${job.name} v${job.version} deployed`);
1574
- }
1575
- else {
1576
- console.warn(` āš ļø ${job.name} deployment failed`);
1577
- }
1578
- }
1579
- }
1580
- // Deploy all preprocessors
1581
- if (toDeployPreprocessors.length > 0) {
1582
- writeProgress(`šŸ“„ Deploying ${toDeployPreprocessors.length} preprocessor(s)...`);
1583
- const preprocessorService = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
1584
- for (const processor of toDeployPreprocessors) {
1585
- const deployed = await retryDeploy(() => preprocessorService.publishPreProcessorVersion(processor.preprocessorId, processor.version), processor.name, processor.version, 2);
1586
- if (deployed) {
1587
- writeSuccess(` šŸš€ ${processor.name} v${processor.version} deployed`);
1588
- }
1589
- else {
1590
- console.warn(` āš ļø ${processor.name} deployment failed`);
1591
- }
643
+ for (const item of toDeploy) {
644
+ const deployed = await retryDeploy(async () => {
645
+ const result = await item.handler.publishVersion(apiKey, agentId, item.entityId, item.version);
646
+ if (!result.success)
647
+ throw new Error(result.error || 'Deploy failed');
648
+ }, item.name, item.version, 3);
649
+ if (deployed) {
650
+ writeSuccess(` šŸš€ ${item.name} v${item.version} deployed`);
1592
651
  }
1593
- }
1594
- // Deploy all postprocessors
1595
- if (toDeployPostprocessors.length > 0) {
1596
- writeProgress(`šŸ“¤ Deploying ${toDeployPostprocessors.length} postprocessor(s)...`);
1597
- const postprocessorService = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
1598
- for (const processor of toDeployPostprocessors) {
1599
- const deployed = await retryDeploy(() => postprocessorService.publishPostProcessorVersion(processor.postprocessorId, processor.version), processor.name, processor.version, 2);
1600
- if (deployed) {
1601
- writeSuccess(` šŸš€ ${processor.name} v${processor.version} deployed`);
1602
- }
1603
- else {
1604
- console.warn(` āš ļø ${processor.name} deployment failed`);
1605
- }
652
+ else {
653
+ console.warn(` āš ļø ${item.name} deployment failed`);
1606
654
  }
1607
655
  }
1608
656
  }
1609
- // Step 10: Print summary
657
+ // Step 7: Print summary
1610
658
  writeSuccess('\nāœ… Push All Complete!\n');
1611
- if (results.skills.length > 0) {
1612
- console.log(`šŸ› ļø Skills (${results.skills.length}):`);
1613
- results.skills.forEach(s => console.log(` • ${s.name} v${s.version}`));
1614
- }
1615
- if (results.webhooks.length > 0) {
1616
- console.log(`šŸŖ Webhooks (${results.webhooks.length}):`);
1617
- results.webhooks.forEach(w => console.log(` • ${w.name} v${w.version}`));
1618
- }
1619
- if (results.jobs.length > 0) {
1620
- console.log(`ā° Jobs (${results.jobs.length}):`);
1621
- results.jobs.forEach(j => console.log(` • ${j.name} v${j.version}`));
1622
- }
1623
- if (results.preprocessors.length > 0) {
1624
- console.log(`šŸ“„ PreProcessors (${results.preprocessors.length}):`);
1625
- results.preprocessors.forEach(p => console.log(` • ${p.name} v${p.version}`));
1626
- }
1627
- if (results.postprocessors.length > 0) {
1628
- console.log(`šŸ“¤ PostProcessors (${results.postprocessors.length}):`);
1629
- results.postprocessors.forEach(p => console.log(` • ${p.name} v${p.version}`));
659
+ // Group results by kind for display
660
+ const byKind = new Map();
661
+ for (const r of allResults) {
662
+ const kind = r.handler.displayNamePlural;
663
+ if (!byKind.has(kind))
664
+ byKind.set(kind, []);
665
+ byKind.get(kind).push(r);
666
+ }
667
+ const summaryIcons = {
668
+ skills: 'šŸ› ļø ', webhooks: 'šŸŖ', jobs: 'ā°', preprocessors: 'šŸ“„', postprocessors: 'šŸ“¤',
669
+ };
670
+ for (const [kind, items] of byKind) {
671
+ const icon = summaryIcons[kind] || 'šŸ“¦';
672
+ console.log(`${icon} ${kind.charAt(0).toUpperCase() + kind.slice(1)} (${items.length}):`);
673
+ items.forEach(i => console.log(` • ${i.name} v${i.version}`));
1630
674
  }
1631
675
  if (options.autoDeploy) {
1632
676
  writeSuccess('\nšŸš€ All components deployed to production!');
1633
677
  }
1634
678
  console.log('');
1635
679
  }
1636
- /**
1637
- * Bumps the patch version of a semantic version string
1638
- * e.g., "1.2.3" -> "1.2.4"
1639
- */
1640
- function bumpPatchVersion(version) {
1641
- const parts = version.split('.');
1642
- if (parts.length !== 3) {
1643
- // If not a valid semver, just return incremented version
1644
- return version + '.1';
1645
- }
1646
- const [major, minor, patch] = parts;
1647
- const newPatch = parseInt(patch, 10) + 1;
1648
- return `${major}.${minor}.${newPatch}`;
1649
- }
1650
680
  /**
1651
681
  * Retry deployment with exponential backoff
1652
682
  * The server needs time to process pushed versions before they can be deployed
1653
683
  */
1654
- async function retryDeploy(deployFn, componentName, version, maxRetries = 3) {
684
+ async function retryDeploy(deployFn, _componentName, _version, maxRetries = 3) {
1655
685
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
1656
686
  try {
1657
- const delay = attempt * 2000; // 2s, 4s, 6s (longer delays)
1658
- await new Promise(resolve => setTimeout(resolve, delay));
687
+ // Only delay on retry attempts (not first attempt)
688
+ if (attempt > 1) {
689
+ const delay = attempt * 2000; // 2s on 2nd attempt, 4s on 3rd, etc.
690
+ await new Promise(resolve => setTimeout(resolve, delay));
691
+ }
1659
692
  await deployFn();
693
+ // Show success message if succeeded after retrying
694
+ if (attempt > 1) {
695
+ writeInfo(` āœ“ Succeeded on retry ${attempt}/${maxRetries}`);
696
+ }
1660
697
  return true;
1661
698
  }
1662
699
  catch (error) {
1663
- if (attempt === maxRetries) {
1664
- console.error(` [Retry ${attempt}/${maxRetries}] Deploy failed: ${error.message}`);
1665
- return false;
700
+ // Extract detailed error message from API response
701
+ const errorMessage = error?.error?.message || error?.message || 'Unknown error';
702
+ if (attempt < maxRetries) {
703
+ // Intermediate retry - show brief info
704
+ writeInfo(` [Attempt ${attempt}/${maxRetries}] ${errorMessage} - retrying...`);
705
+ }
706
+ else {
707
+ // Final attempt failed - show error
708
+ console.error(` āŒ [Attempt ${attempt}/${maxRetries}] Deploy failed: ${errorMessage}`);
1666
709
  }
1667
- // Continue to next retry silently
1668
710
  }
1669
711
  }
1670
712
  return false;