lua-cli 3.5.0-alpha.3 → 3.5.0-beta.1

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