lua-cli 3.12.2 → 3.14.0

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 (568) hide show
  1. package/README.md +14 -13
  2. package/dist/api/agent.api.service.d.ts +20 -20
  3. package/dist/api/agent.api.service.d.ts.map +1 -1
  4. package/dist/api/agent.api.service.js +1 -1
  5. package/dist/api/agent.api.service.js.map +1 -1
  6. package/dist/api/agents.api.service.d.ts +3 -3
  7. package/dist/api/agents.api.service.d.ts.map +1 -1
  8. package/dist/api/agents.api.service.js +11 -9
  9. package/dist/api/agents.api.service.js.map +1 -1
  10. package/dist/api/ai.api.service.d.ts +4 -4
  11. package/dist/api/ai.api.service.d.ts.map +1 -1
  12. package/dist/api/ai.api.service.js +10 -8
  13. package/dist/api/ai.api.service.js.map +1 -1
  14. package/dist/api/auth.api.service.d.ts +3 -3
  15. package/dist/api/auth.api.service.d.ts.map +1 -1
  16. package/dist/api/auth.api.service.js +1 -1
  17. package/dist/api/auth.api.service.js.map +1 -1
  18. package/dist/api/backup.api.service.d.ts.map +1 -1
  19. package/dist/api/backup.api.service.js +21 -7
  20. package/dist/api/backup.api.service.js.map +1 -1
  21. package/dist/api/basket.api.service.d.ts +5 -5
  22. package/dist/api/basket.api.service.d.ts.map +1 -1
  23. package/dist/api/basket.api.service.js +4 -4
  24. package/dist/api/basket.api.service.js.map +1 -1
  25. package/dist/api/cdn.api.service.d.ts +1 -1
  26. package/dist/api/cdn.api.service.js +3 -3
  27. package/dist/api/cdn.api.service.js.map +1 -1
  28. package/dist/api/chat.api.service.d.ts +4 -4
  29. package/dist/api/chat.api.service.js +3 -3
  30. package/dist/api/chat.api.service.js.map +1 -1
  31. package/dist/api/credentials.js +3 -3
  32. package/dist/api/custom.data.api.service.d.ts +4 -4
  33. package/dist/api/custom.data.api.service.d.ts.map +1 -1
  34. package/dist/api/custom.data.api.service.js +2 -2
  35. package/dist/api/custom.data.api.service.js.map +1 -1
  36. package/dist/api/developer.api.service.d.ts +3 -3
  37. package/dist/api/developer.api.service.d.ts.map +1 -1
  38. package/dist/api/developer.api.service.js +7 -3
  39. package/dist/api/developer.api.service.js.map +1 -1
  40. package/dist/api/device-trigger.api.service.d.ts +3 -3
  41. package/dist/api/device-trigger.api.service.d.ts.map +1 -1
  42. package/dist/api/device-trigger.api.service.js +1 -1
  43. package/dist/api/device-trigger.api.service.js.map +1 -1
  44. package/dist/api/device.api.service.d.ts +3 -3
  45. package/dist/api/device.api.service.d.ts.map +1 -1
  46. package/dist/api/device.api.service.js +1 -1
  47. package/dist/api/device.api.service.js.map +1 -1
  48. package/dist/api/http.client.d.ts +1 -1
  49. package/dist/api/http.client.d.ts.map +1 -1
  50. package/dist/api/http.client.js +6 -6
  51. package/dist/api/http.client.js.map +1 -1
  52. package/dist/api/job.api.service.d.ts +13 -14
  53. package/dist/api/job.api.service.d.ts.map +1 -1
  54. package/dist/api/job.api.service.js +12 -20
  55. package/dist/api/job.api.service.js.map +1 -1
  56. package/dist/api/lazy-instances.d.ts +12 -12
  57. package/dist/api/lazy-instances.js +14 -14
  58. package/dist/api/logs.api.service.d.ts +9 -6
  59. package/dist/api/logs.api.service.d.ts.map +1 -1
  60. package/dist/api/logs.api.service.js +12 -11
  61. package/dist/api/logs.api.service.js.map +1 -1
  62. package/dist/api/marketplace.api.service.d.ts +1 -1
  63. package/dist/api/marketplace.api.service.d.ts.map +1 -1
  64. package/dist/api/marketplace.api.service.js +18 -18
  65. package/dist/api/marketplace.api.service.js.map +1 -1
  66. package/dist/api/order.api.service.d.ts +4 -4
  67. package/dist/api/order.api.service.d.ts.map +1 -1
  68. package/dist/api/order.api.service.js +2 -2
  69. package/dist/api/order.api.service.js.map +1 -1
  70. package/dist/api/persona.api.service.d.ts +3 -3
  71. package/dist/api/persona.api.service.d.ts.map +1 -1
  72. package/dist/api/persona.api.service.js +2 -2
  73. package/dist/api/persona.api.service.js.map +1 -1
  74. package/dist/api/postprocessor.api.service.d.ts +8 -9
  75. package/dist/api/postprocessor.api.service.d.ts.map +1 -1
  76. package/dist/api/postprocessor.api.service.js +1 -2
  77. package/dist/api/postprocessor.api.service.js.map +1 -1
  78. package/dist/api/preprocessor.api.service.d.ts +8 -9
  79. package/dist/api/preprocessor.api.service.d.ts.map +1 -1
  80. package/dist/api/preprocessor.api.service.js +1 -2
  81. package/dist/api/preprocessor.api.service.js.map +1 -1
  82. package/dist/api/products.api.service.d.ts +9 -9
  83. package/dist/api/products.api.service.d.ts.map +1 -1
  84. package/dist/api/products.api.service.js +10 -10
  85. package/dist/api/products.api.service.js.map +1 -1
  86. package/dist/api/resource.api.service.d.ts +2 -2
  87. package/dist/api/resource.api.service.js +1 -1
  88. package/dist/api/skills.api.service.d.ts +4 -4
  89. package/dist/api/skills.api.service.d.ts.map +1 -1
  90. package/dist/api/skills.api.service.js +1 -1
  91. package/dist/api/skills.api.service.js.map +1 -1
  92. package/dist/api/tool.api.service.d.ts +2 -2
  93. package/dist/api/tool.api.service.js +1 -1
  94. package/dist/api/unifiedto.api.service.d.ts +3 -3
  95. package/dist/api/unifiedto.api.service.d.ts.map +1 -1
  96. package/dist/api/unifiedto.api.service.js +28 -10
  97. package/dist/api/unifiedto.api.service.js.map +1 -1
  98. package/dist/api/user.data.api.service.d.ts +6 -6
  99. package/dist/api/user.data.api.service.d.ts.map +1 -1
  100. package/dist/api/user.data.api.service.js +5 -5
  101. package/dist/api/user.data.api.service.js.map +1 -1
  102. package/dist/api/webhook.api.service.d.ts +3 -3
  103. package/dist/api/webhook.api.service.d.ts.map +1 -1
  104. package/dist/api/webhook.api.service.js +1 -1
  105. package/dist/api/webhook.api.service.js.map +1 -1
  106. package/dist/api/whatsapp-templates.api.service.d.ts +3 -3
  107. package/dist/api/whatsapp-templates.api.service.js +1 -1
  108. package/dist/api-exports.d.ts +25 -25
  109. package/dist/api-exports.d.ts.map +1 -1
  110. package/dist/api-exports.js +26 -26
  111. package/dist/api-exports.js.map +1 -1
  112. package/dist/cli/command-definitions.d.ts +1 -1
  113. package/dist/cli/command-definitions.d.ts.map +1 -1
  114. package/dist/cli/command-definitions.js +209 -196
  115. package/dist/cli/command-definitions.js.map +1 -1
  116. package/dist/commands/agents.js +2 -2
  117. package/dist/commands/apiKey.js +12 -12
  118. package/dist/commands/channels.d.ts.map +1 -1
  119. package/dist/commands/channels.js +165 -174
  120. package/dist/commands/channels.js.map +1 -1
  121. package/dist/commands/chat-log-probe.d.ts +59 -0
  122. package/dist/commands/chat-log-probe.d.ts.map +1 -0
  123. package/dist/commands/chat-log-probe.js +87 -0
  124. package/dist/commands/chat-log-probe.js.map +1 -0
  125. package/dist/commands/chat.d.ts.map +1 -1
  126. package/dist/commands/chat.js +143 -40
  127. package/dist/commands/chat.js.map +1 -1
  128. package/dist/commands/chatClear.d.ts.map +1 -1
  129. package/dist/commands/chatClear.js +10 -6
  130. package/dist/commands/chatClear.js.map +1 -1
  131. package/dist/commands/compile.d.ts +7 -0
  132. package/dist/commands/compile.d.ts.map +1 -1
  133. package/dist/commands/compile.js +49 -12
  134. package/dist/commands/compile.js.map +1 -1
  135. package/dist/commands/completion.d.ts.map +1 -1
  136. package/dist/commands/completion.js +8 -9
  137. package/dist/commands/completion.js.map +1 -1
  138. package/dist/commands/configure.js +5 -5
  139. package/dist/commands/deploy.d.ts.map +1 -1
  140. package/dist/commands/deploy.js +132 -35
  141. package/dist/commands/deploy.js.map +1 -1
  142. package/dist/commands/destroy.d.ts.map +1 -1
  143. package/dist/commands/destroy.js +27 -17
  144. package/dist/commands/destroy.js.map +1 -1
  145. package/dist/commands/devices.d.ts.map +1 -1
  146. package/dist/commands/devices.js +4 -5
  147. package/dist/commands/devices.js.map +1 -1
  148. package/dist/commands/env.d.ts.map +1 -1
  149. package/dist/commands/env.js +101 -80
  150. package/dist/commands/env.js.map +1 -1
  151. package/dist/commands/features.d.ts.map +1 -1
  152. package/dist/commands/features.js +71 -82
  153. package/dist/commands/features.js.map +1 -1
  154. package/dist/commands/governance.d.ts.map +1 -1
  155. package/dist/commands/governance.js +17 -15
  156. package/dist/commands/governance.js.map +1 -1
  157. package/dist/commands/index.d.ts +37 -36
  158. package/dist/commands/index.d.ts.map +1 -1
  159. package/dist/commands/index.js +37 -36
  160. package/dist/commands/index.js.map +1 -1
  161. package/dist/commands/init.d.ts.map +1 -1
  162. package/dist/commands/init.js +80 -70
  163. package/dist/commands/init.js.map +1 -1
  164. package/dist/commands/integrations.d.ts.map +1 -1
  165. package/dist/commands/integrations.js +373 -341
  166. package/dist/commands/integrations.js.map +1 -1
  167. package/dist/commands/jobs.d.ts.map +1 -1
  168. package/dist/commands/jobs.js +110 -78
  169. package/dist/commands/jobs.js.map +1 -1
  170. package/dist/commands/log-tip.d.ts +79 -0
  171. package/dist/commands/log-tip.d.ts.map +1 -0
  172. package/dist/commands/log-tip.js +83 -0
  173. package/dist/commands/log-tip.js.map +1 -0
  174. package/dist/commands/logs.d.ts.map +1 -1
  175. package/dist/commands/logs.js +166 -198
  176. package/dist/commands/logs.js.map +1 -1
  177. package/dist/commands/marketplace.d.ts.map +1 -1
  178. package/dist/commands/marketplace.js +381 -427
  179. package/dist/commands/marketplace.js.map +1 -1
  180. package/dist/commands/mcp.d.ts.map +1 -1
  181. package/dist/commands/mcp.js +54 -56
  182. package/dist/commands/mcp.js.map +1 -1
  183. package/dist/commands/models.d.ts.map +1 -1
  184. package/dist/commands/models.js +4 -3
  185. package/dist/commands/models.js.map +1 -1
  186. package/dist/commands/persona.d.ts.map +1 -1
  187. package/dist/commands/persona.js +100 -126
  188. package/dist/commands/persona.js.map +1 -1
  189. package/dist/commands/postprocessors.d.ts.map +1 -1
  190. package/dist/commands/postprocessors.js +87 -61
  191. package/dist/commands/postprocessors.js.map +1 -1
  192. package/dist/commands/preprocessors.d.ts.map +1 -1
  193. package/dist/commands/preprocessors.js +87 -61
  194. package/dist/commands/preprocessors.js.map +1 -1
  195. package/dist/commands/production.d.ts.map +1 -1
  196. package/dist/commands/production.js +101 -113
  197. package/dist/commands/production.js.map +1 -1
  198. package/dist/commands/push-helpers.d.ts +42 -0
  199. package/dist/commands/push-helpers.d.ts.map +1 -0
  200. package/dist/commands/push-helpers.js +48 -0
  201. package/dist/commands/push-helpers.js.map +1 -0
  202. package/dist/commands/push.d.ts +2 -0
  203. package/dist/commands/push.d.ts.map +1 -1
  204. package/dist/commands/push.js +388 -124
  205. package/dist/commands/push.js.map +1 -1
  206. package/dist/commands/pushBackup.d.ts.map +1 -1
  207. package/dist/commands/pushBackup.js +8 -4
  208. package/dist/commands/pushBackup.js.map +1 -1
  209. package/dist/commands/resources.d.ts.map +1 -1
  210. package/dist/commands/resources.js +47 -60
  211. package/dist/commands/resources.js.map +1 -1
  212. package/dist/commands/skills.d.ts.map +1 -1
  213. package/dist/commands/skills.js +117 -89
  214. package/dist/commands/skills.js.map +1 -1
  215. package/dist/commands/status.d.ts +14 -0
  216. package/dist/commands/status.d.ts.map +1 -0
  217. package/dist/commands/status.js +731 -0
  218. package/dist/commands/status.js.map +1 -0
  219. package/dist/commands/sync.d.ts.map +1 -1
  220. package/dist/commands/sync.js +70 -30
  221. package/dist/commands/sync.js.map +1 -1
  222. package/dist/commands/telemetry.d.ts.map +1 -1
  223. package/dist/commands/telemetry.js +4 -0
  224. package/dist/commands/telemetry.js.map +1 -1
  225. package/dist/commands/test-output.helpers.d.ts +24 -0
  226. package/dist/commands/test-output.helpers.d.ts.map +1 -0
  227. package/dist/commands/test-output.helpers.js +62 -0
  228. package/dist/commands/test-output.helpers.js.map +1 -0
  229. package/dist/commands/test.d.ts.map +1 -1
  230. package/dist/commands/test.js +291 -121
  231. package/dist/commands/test.js.map +1 -1
  232. package/dist/commands/update.d.ts.map +1 -1
  233. package/dist/commands/update.js +15 -3
  234. package/dist/commands/update.js.map +1 -1
  235. package/dist/commands/webhooks.d.ts.map +1 -1
  236. package/dist/commands/webhooks.js +94 -87
  237. package/dist/commands/webhooks.js.map +1 -1
  238. package/dist/compiler/agent-traverser.d.ts +50 -14
  239. package/dist/compiler/agent-traverser.d.ts.map +1 -1
  240. package/dist/compiler/agent-traverser.js +189 -86
  241. package/dist/compiler/agent-traverser.js.map +1 -1
  242. package/dist/compiler/bundler.d.ts.map +1 -1
  243. package/dist/compiler/bundler.js +5 -5
  244. package/dist/compiler/bundler.js.map +1 -1
  245. package/dist/compiler/compiler.d.ts +32 -0
  246. package/dist/compiler/compiler.d.ts.map +1 -1
  247. package/dist/compiler/compiler.js +154 -28
  248. package/dist/compiler/compiler.js.map +1 -1
  249. package/dist/compiler/index.d.ts +3 -3
  250. package/dist/compiler/index.d.ts.map +1 -1
  251. package/dist/compiler/index.js +3 -3
  252. package/dist/compiler/index.js.map +1 -1
  253. package/dist/compiler/plugins/agent.plugin.d.ts.map +1 -1
  254. package/dist/compiler/plugins/agent.plugin.js +2 -4
  255. package/dist/compiler/plugins/agent.plugin.js.map +1 -1
  256. package/dist/compiler/plugins/base.d.ts +21 -0
  257. package/dist/compiler/plugins/base.d.ts.map +1 -1
  258. package/dist/compiler/plugins/base.js +13 -3
  259. package/dist/compiler/plugins/base.js.map +1 -1
  260. package/dist/compiler/plugins/device-trigger.plugin.d.ts.map +1 -1
  261. package/dist/compiler/plugins/device-trigger.plugin.js +8 -4
  262. package/dist/compiler/plugins/device-trigger.plugin.js.map +1 -1
  263. package/dist/compiler/plugins/device.plugin.d.ts.map +1 -1
  264. package/dist/compiler/plugins/device.plugin.js +4 -4
  265. package/dist/compiler/plugins/device.plugin.js.map +1 -1
  266. package/dist/compiler/plugins/job.plugin.d.ts.map +1 -1
  267. package/dist/compiler/plugins/job.plugin.js +15 -11
  268. package/dist/compiler/plugins/job.plugin.js.map +1 -1
  269. package/dist/compiler/plugins/mcp-server.plugin.d.ts.map +1 -1
  270. package/dist/compiler/plugins/mcp-server.plugin.js +10 -4
  271. package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -1
  272. package/dist/compiler/plugins/registry.js +2 -2
  273. package/dist/compiler/plugins/registry.js.map +1 -1
  274. package/dist/compiler/plugins/skill.plugin.d.ts +35 -9
  275. package/dist/compiler/plugins/skill.plugin.d.ts.map +1 -1
  276. package/dist/compiler/plugins/skill.plugin.js +129 -87
  277. package/dist/compiler/plugins/skill.plugin.js.map +1 -1
  278. package/dist/compiler/plugins/tool.plugin.d.ts.map +1 -1
  279. package/dist/compiler/plugins/tool.plugin.js +13 -9
  280. package/dist/compiler/plugins/tool.plugin.js.map +1 -1
  281. package/dist/compiler/plugins/webhook.plugin.d.ts.map +1 -1
  282. package/dist/compiler/plugins/webhook.plugin.js +7 -5
  283. package/dist/compiler/plugins/webhook.plugin.js.map +1 -1
  284. package/dist/compiler/source-writer.d.ts.map +1 -1
  285. package/dist/compiler/source-writer.js +2 -4
  286. package/dist/compiler/source-writer.js.map +1 -1
  287. package/dist/compiler/types.d.ts +33 -0
  288. package/dist/compiler/types.d.ts.map +1 -1
  289. package/dist/compiler/types.js.map +1 -1
  290. package/dist/compiler/utils/ast-helpers.d.ts +1 -16
  291. package/dist/compiler/utils/ast-helpers.d.ts.map +1 -1
  292. package/dist/compiler/utils/ast-helpers.js +14 -38
  293. package/dist/compiler/utils/ast-helpers.js.map +1 -1
  294. package/dist/compiler/utils/common.d.ts +14 -0
  295. package/dist/compiler/utils/common.d.ts.map +1 -1
  296. package/dist/compiler/utils/common.js +39 -11
  297. package/dist/compiler/utils/common.js.map +1 -1
  298. package/dist/compiler/utils/file-discovery.d.ts.map +1 -1
  299. package/dist/compiler/utils/file-discovery.js +2 -10
  300. package/dist/compiler/utils/file-discovery.js.map +1 -1
  301. package/dist/compiler/utils/path-resolver.d.ts +67 -10
  302. package/dist/compiler/utils/path-resolver.d.ts.map +1 -1
  303. package/dist/compiler/utils/path-resolver.js +120 -24
  304. package/dist/compiler/utils/path-resolver.js.map +1 -1
  305. package/dist/compiler/utils/reference-resolver.d.ts +196 -0
  306. package/dist/compiler/utils/reference-resolver.d.ts.map +1 -0
  307. package/dist/compiler/utils/reference-resolver.js +1026 -0
  308. package/dist/compiler/utils/reference-resolver.js.map +1 -0
  309. package/dist/compiler/utils/schema-converter.d.ts +25 -0
  310. package/dist/compiler/utils/schema-converter.d.ts.map +1 -1
  311. package/dist/compiler/utils/schema-converter.js +80 -4
  312. package/dist/compiler/utils/schema-converter.js.map +1 -1
  313. package/dist/compiler/utils/workspace.d.ts +35 -0
  314. package/dist/compiler/utils/workspace.d.ts.map +1 -0
  315. package/dist/compiler/utils/workspace.js +121 -0
  316. package/dist/compiler/utils/workspace.js.map +1 -0
  317. package/dist/compiler/utils/zod-runtime.mjs +5334 -0
  318. package/dist/config/compile.constants.d.ts.map +1 -1
  319. package/dist/config/compile.constants.js +3 -1
  320. package/dist/config/compile.constants.js.map +1 -1
  321. package/dist/config/constants.d.ts.map +1 -1
  322. package/dist/config/constants.js +1 -5
  323. package/dist/config/constants.js.map +1 -1
  324. package/dist/errors/auth.error.d.ts.map +1 -1
  325. package/dist/errors/auth.error.js +3 -5
  326. package/dist/errors/auth.error.js.map +1 -1
  327. package/dist/errors/index.d.ts +1 -1
  328. package/dist/errors/index.js +1 -1
  329. package/dist/index.js +9 -8
  330. package/dist/index.js.map +1 -1
  331. package/dist/instances/basket.instance.d.ts +3 -3
  332. package/dist/instances/basket.instance.d.ts.map +1 -1
  333. package/dist/instances/basket.instance.js +26 -8
  334. package/dist/instances/basket.instance.js.map +1 -1
  335. package/dist/instances/data.entry.instance.d.ts +2 -2
  336. package/dist/instances/data.entry.instance.d.ts.map +1 -1
  337. package/dist/instances/data.entry.instance.js +5 -5
  338. package/dist/instances/data.entry.instance.js.map +1 -1
  339. package/dist/instances/order.instance.d.ts +2 -2
  340. package/dist/instances/order.instance.d.ts.map +1 -1
  341. package/dist/instances/order.instance.js +20 -9
  342. package/dist/instances/order.instance.js.map +1 -1
  343. package/dist/instances/product.instance.d.ts +1 -1
  344. package/dist/instances/product.instance.d.ts.map +1 -1
  345. package/dist/instances/product.instance.js +3 -3
  346. package/dist/instances/product.instance.js.map +1 -1
  347. package/dist/instances/product.pagination.instance.d.ts +2 -2
  348. package/dist/instances/product.pagination.instance.d.ts.map +1 -1
  349. package/dist/instances/product.pagination.instance.js +6 -7
  350. package/dist/instances/product.pagination.instance.js.map +1 -1
  351. package/dist/instances/product.search.instance.d.ts +3 -3
  352. package/dist/instances/product.search.instance.d.ts.map +1 -1
  353. package/dist/instances/product.search.instance.js +3 -4
  354. package/dist/instances/product.search.instance.js.map +1 -1
  355. package/dist/instances/user.instance.d.ts +3 -3
  356. package/dist/instances/user.instance.d.ts.map +1 -1
  357. package/dist/instances/user.instance.js +19 -36
  358. package/dist/instances/user.instance.js.map +1 -1
  359. package/dist/interfaces/agent.d.ts +8 -8
  360. package/dist/interfaces/agent.d.ts.map +1 -1
  361. package/dist/interfaces/backup.d.ts +19 -1
  362. package/dist/interfaces/backup.d.ts.map +1 -1
  363. package/dist/interfaces/device-triggers.d.ts +0 -2
  364. package/dist/interfaces/device-triggers.d.ts.map +1 -1
  365. package/dist/interfaces/devices.d.ts +0 -1
  366. package/dist/interfaces/devices.d.ts.map +1 -1
  367. package/dist/interfaces/index.d.ts +8 -8
  368. package/dist/interfaces/index.d.ts.map +1 -1
  369. package/dist/interfaces/jobs.d.ts +2 -3
  370. package/dist/interfaces/jobs.d.ts.map +1 -1
  371. package/dist/interfaces/logs.d.ts +7 -4
  372. package/dist/interfaces/logs.d.ts.map +1 -1
  373. package/dist/interfaces/message.d.ts +3 -3
  374. package/dist/interfaces/message.d.ts.map +1 -1
  375. package/dist/interfaces/orders.d.ts +1 -1
  376. package/dist/interfaces/webhooks.d.ts +2 -2
  377. package/dist/interfaces/webhooks.d.ts.map +1 -1
  378. package/dist/primitives/agent.handler.d.ts.map +1 -1
  379. package/dist/primitives/agent.handler.js +1 -1
  380. package/dist/primitives/agent.handler.js.map +1 -1
  381. package/dist/primitives/base.handler.d.ts +12 -2
  382. package/dist/primitives/base.handler.d.ts.map +1 -1
  383. package/dist/primitives/base.handler.js +104 -73
  384. package/dist/primitives/base.handler.js.map +1 -1
  385. package/dist/primitives/device-trigger.handler.d.ts +1 -1
  386. package/dist/primitives/device-trigger.handler.d.ts.map +1 -1
  387. package/dist/primitives/device-trigger.handler.js +2 -3
  388. package/dist/primitives/device-trigger.handler.js.map +1 -1
  389. package/dist/primitives/device.handler.d.ts +1 -1
  390. package/dist/primitives/device.handler.d.ts.map +1 -1
  391. package/dist/primitives/device.handler.js +2 -3
  392. package/dist/primitives/device.handler.js.map +1 -1
  393. package/dist/primitives/index.d.ts +1 -1
  394. package/dist/primitives/index.d.ts.map +1 -1
  395. package/dist/primitives/index.js +2 -3
  396. package/dist/primitives/index.js.map +1 -1
  397. package/dist/primitives/job.handler.d.ts +6 -1
  398. package/dist/primitives/job.handler.d.ts.map +1 -1
  399. package/dist/primitives/job.handler.js +9 -3
  400. package/dist/primitives/job.handler.js.map +1 -1
  401. package/dist/primitives/mcp-server.handler.d.ts.map +1 -1
  402. package/dist/primitives/mcp-server.handler.js +2 -2
  403. package/dist/primitives/mcp-server.handler.js.map +1 -1
  404. package/dist/primitives/postprocessor.handler.d.ts.map +1 -1
  405. package/dist/primitives/postprocessor.handler.js.map +1 -1
  406. package/dist/primitives/preprocessor.handler.d.ts +1 -1
  407. package/dist/primitives/preprocessor.handler.d.ts.map +1 -1
  408. package/dist/primitives/preprocessor.handler.js +2 -3
  409. package/dist/primitives/preprocessor.handler.js.map +1 -1
  410. package/dist/primitives/skill.handler.d.ts +1 -1
  411. package/dist/primitives/skill.handler.d.ts.map +1 -1
  412. package/dist/primitives/skill.handler.js +34 -13
  413. package/dist/primitives/skill.handler.js.map +1 -1
  414. package/dist/primitives/types.d.ts +1 -1
  415. package/dist/primitives/types.d.ts.map +1 -1
  416. package/dist/primitives/types.js.map +1 -1
  417. package/dist/primitives/webhook.handler.d.ts +3 -2
  418. package/dist/primitives/webhook.handler.d.ts.map +1 -1
  419. package/dist/primitives/webhook.handler.js +9 -4
  420. package/dist/primitives/webhook.handler.js.map +1 -1
  421. package/dist/services/analytics.d.ts.map +1 -1
  422. package/dist/services/analytics.js +4 -5
  423. package/dist/services/analytics.js.map +1 -1
  424. package/dist/services/auth.d.ts +9 -1
  425. package/dist/services/auth.d.ts.map +1 -1
  426. package/dist/services/auth.js +26 -7
  427. package/dist/services/auth.js.map +1 -1
  428. package/dist/services/sandbox.service.d.ts.map +1 -1
  429. package/dist/services/sandbox.service.js +132 -80
  430. package/dist/services/sandbox.service.js.map +1 -1
  431. package/dist/types/api-contracts.d.ts +4 -4
  432. package/dist/types/api-contracts.d.ts.map +1 -1
  433. package/dist/types/index.d.ts +2 -2
  434. package/dist/types/index.d.ts.map +1 -1
  435. package/dist/types/index.js.map +1 -1
  436. package/dist/types/skill.d.ts +7 -7
  437. package/dist/types/skill.d.ts.map +1 -1
  438. package/dist/types/skill.js +2 -2
  439. package/dist/types/skill.js.map +1 -1
  440. package/dist/types/tool-validation.js.map +1 -1
  441. package/dist/types/yaml.types.js +0 -1
  442. package/dist/types/yaml.types.js.map +1 -1
  443. package/dist/utils/aliases.d.ts +7 -0
  444. package/dist/utils/aliases.d.ts.map +1 -0
  445. package/dist/utils/aliases.js +492 -0
  446. package/dist/utils/aliases.js.map +1 -0
  447. package/dist/utils/artifact-loader.d.ts +9 -0
  448. package/dist/utils/artifact-loader.d.ts.map +1 -1
  449. package/dist/utils/artifact-loader.js +16 -6
  450. package/dist/utils/artifact-loader.js.map +1 -1
  451. package/dist/utils/auth-flows.d.ts.map +1 -1
  452. package/dist/utils/auth-flows.js +54 -54
  453. package/dist/utils/auth-flows.js.map +1 -1
  454. package/dist/utils/backup-helpers.d.ts +24 -0
  455. package/dist/utils/backup-helpers.d.ts.map +1 -1
  456. package/dist/utils/backup-helpers.js +102 -22
  457. package/dist/utils/backup-helpers.js.map +1 -1
  458. package/dist/utils/bundle-upload.d.ts +42 -0
  459. package/dist/utils/bundle-upload.d.ts.map +1 -0
  460. package/dist/utils/bundle-upload.js +90 -0
  461. package/dist/utils/bundle-upload.js.map +1 -0
  462. package/dist/utils/chat-attachments.js +1 -1
  463. package/dist/utils/chat-attachments.js.map +1 -1
  464. package/dist/utils/cli.d.ts +24 -6
  465. package/dist/utils/cli.d.ts.map +1 -1
  466. package/dist/utils/cli.js +26 -14
  467. package/dist/utils/cli.js.map +1 -1
  468. package/dist/utils/command-utils.d.ts.map +1 -1
  469. package/dist/utils/command-utils.js +4 -4
  470. package/dist/utils/command-utils.js.map +1 -1
  471. package/dist/utils/deploy-helpers.d.ts.map +1 -1
  472. package/dist/utils/deploy-helpers.js +13 -13
  473. package/dist/utils/deploy-helpers.js.map +1 -1
  474. package/dist/utils/env-loader.utils.d.ts +1 -1
  475. package/dist/utils/env-loader.utils.d.ts.map +1 -1
  476. package/dist/utils/env-loader.utils.js +15 -22
  477. package/dist/utils/env-loader.utils.js.map +1 -1
  478. package/dist/utils/files.d.ts.map +1 -1
  479. package/dist/utils/files.js +23 -13
  480. package/dist/utils/files.js.map +1 -1
  481. package/dist/utils/hints.d.ts +81 -0
  482. package/dist/utils/hints.d.ts.map +1 -0
  483. package/dist/utils/hints.js +81 -0
  484. package/dist/utils/hints.js.map +1 -0
  485. package/dist/utils/init-agent.d.ts.map +1 -1
  486. package/dist/utils/init-agent.js +18 -20
  487. package/dist/utils/init-agent.js.map +1 -1
  488. package/dist/utils/init-helpers.d.ts.map +1 -1
  489. package/dist/utils/init-helpers.js +11 -11
  490. package/dist/utils/init-helpers.js.map +1 -1
  491. package/dist/utils/init-prompts.d.ts.map +1 -1
  492. package/dist/utils/init-prompts.js +34 -36
  493. package/dist/utils/init-prompts.js.map +1 -1
  494. package/dist/utils/prompt-handler.js +1 -1
  495. package/dist/utils/prompt-handler.js.map +1 -1
  496. package/dist/utils/sandbox-storage.d.ts.map +1 -1
  497. package/dist/utils/sandbox-storage.js.map +1 -1
  498. package/dist/utils/sandbox.d.ts +1 -1
  499. package/dist/utils/sandbox.d.ts.map +1 -1
  500. package/dist/utils/sandbox.js +107 -106
  501. package/dist/utils/sandbox.js.map +1 -1
  502. package/dist/utils/semver.js +1 -1
  503. package/dist/utils/semver.js.map +1 -1
  504. package/dist/utils/suggest.d.ts +3 -0
  505. package/dist/utils/suggest.d.ts.map +1 -0
  506. package/dist/utils/suggest.js +32 -0
  507. package/dist/utils/suggest.js.map +1 -0
  508. package/dist/utils/sync-display.d.ts.map +1 -1
  509. package/dist/utils/sync-display.js +15 -13
  510. package/dist/utils/sync-display.js.map +1 -1
  511. package/dist/utils/sync-fetch.d.ts.map +1 -1
  512. package/dist/utils/sync-fetch.js +33 -24
  513. package/dist/utils/sync-fetch.js.map +1 -1
  514. package/dist/utils/version-check.js +1 -1
  515. package/dist/utils/version-check.js.map +1 -1
  516. package/dist/utils/write-info.d.ts +9 -0
  517. package/dist/utils/write-info.d.ts.map +1 -0
  518. package/dist/utils/write-info.js +11 -0
  519. package/dist/utils/write-info.js.map +1 -0
  520. package/docs/README.md +1 -1
  521. package/node_modules/@lua/shared-types/dist/index.d.mts +76 -2
  522. package/node_modules/@lua/shared-types/dist/index.d.ts +76 -2
  523. package/node_modules/@lua/shared-types/dist/index.js +27 -0
  524. package/node_modules/@lua/shared-types/dist/index.mjs +24 -0
  525. package/node_modules/@lua/shared-types/src/ai-generate.types.ts +1 -6
  526. package/node_modules/@lua/shared-types/src/ai-generate.utils.ts +1 -4
  527. package/node_modules/@lua/shared-types/src/channel.type.ts +1 -0
  528. package/node_modules/@lua/shared-types/src/chat-stream.types.ts +11 -0
  529. package/node_modules/@lua/shared-types/src/client-tools.types.ts +47 -0
  530. package/node_modules/@lua/shared-types/src/device.types.ts +6 -6
  531. package/node_modules/@lua/shared-types/src/index.ts +3 -0
  532. package/node_modules/@lua/shared-types/src/sandbox-contract.ts +26 -5
  533. package/node_modules/@lua/shared-types/src/vm-execution-log.types.ts +41 -0
  534. package/package.json +10 -6
  535. package/scripts/build-vendor.mjs +53 -0
  536. package/scripts/vendor-entry.mjs +11 -0
  537. package/template/QUICKSTART.md +33 -33
  538. package/template/README.md +35 -34
  539. package/template/examples/README.md +44 -38
  540. package/template/examples/jobs/AbandonedBasketProcessorJob.ts +30 -31
  541. package/template/examples/jobs/DailyCleanupJob.ts +17 -18
  542. package/template/examples/jobs/DataMigrationJob.ts +18 -23
  543. package/template/examples/jobs/HealthCheckJob.ts +13 -14
  544. package/template/examples/postprocessors/modifyResponse.ts +14 -15
  545. package/template/examples/preprocessors/messageMatching.ts +28 -29
  546. package/template/examples/services/ApiService.ts +68 -64
  547. package/template/examples/services/GetWeather.ts +39 -33
  548. package/template/examples/skills/basket.skill.ts +27 -7
  549. package/template/examples/skills/product.skill.ts +21 -8
  550. package/template/examples/skills/tools/BasketTool.ts +97 -98
  551. package/template/examples/skills/tools/CreateInlineJob.ts +38 -36
  552. package/template/examples/skills/tools/CreatePostTool.ts +27 -28
  553. package/template/examples/skills/tools/CustomDataTool.ts +72 -67
  554. package/template/examples/skills/tools/GameScoreTrackerTool.ts +72 -78
  555. package/template/examples/skills/tools/GetWeatherTool.ts +43 -45
  556. package/template/examples/skills/tools/OrderTool.ts +58 -58
  557. package/template/examples/skills/tools/PaymentTool.ts +43 -43
  558. package/template/examples/skills/tools/PremiumFeatureTool.ts +81 -79
  559. package/template/examples/skills/tools/ProductsTool.ts +68 -69
  560. package/template/examples/skills/tools/SmartBasketTool.ts +43 -44
  561. package/template/examples/skills/tools/UserDataTool.ts +97 -98
  562. package/template/examples/skills/user.skill.ts +7 -8
  563. package/template/examples/webhooks/FileUploadWebhook.ts +38 -31
  564. package/template/examples/webhooks/PaymentWebhook.ts +23 -22
  565. package/template/examples/webhooks/UserEventWebhook.ts +16 -19
  566. package/template/lua.skill.yaml +2 -2
  567. package/template/package.json +1 -1
  568. package/template/src/index.ts +28 -28
@@ -0,0 +1,731 @@
1
+ /**
2
+ * Status Command
3
+ *
4
+ * Unified state dump of the lua-cli + project + server.
5
+ * Print (or emit as JSON) the full state across all "doctor" sections:
6
+ * environment, install method, updates, auth, project, per-primitive sync,
7
+ * persona, backup, telemetry, and derived next-step hints.
8
+ *
9
+ * Aliases: lua describe.
10
+ */
11
+ import { readFileSync, existsSync } from 'fs';
12
+ import { fileURLToPath } from 'url';
13
+ import { dirname, join } from 'path';
14
+ import { performance } from 'perf_hooks';
15
+ import * as os from 'os';
16
+ import { withErrorHandling } from '../utils/cli.js';
17
+ import { hintsDisabled } from '../utils/hints.js';
18
+ import { trackEvent } from '../services/analytics.js';
19
+ import { loadApiKey } from '../services/auth.js';
20
+ import AuthApi from '../api/auth.api.service.js';
21
+ import { readYamlConfig } from '../utils/files.js';
22
+ import { loadManifest, getAgentName } from '../utils/artifact-loader.js';
23
+ import { syncableHandlers, isVersionedHandler } from '../primitives/index.js';
24
+ import { compareVersions, parseVersion } from '../utils/semver.js';
25
+ import { isUpdateAvailable, getCachedVersionCheck } from '../utils/version-check.js';
26
+ import { checkPersonaDrift } from '../utils/sync-fetch.js';
27
+ import { getCurrentProjectHash, isBackupOutOfSync } from '../utils/backup-helpers.js';
28
+ import { BASE_URLS, CLI_CONFIG_DIR, TELEMETRY_FILE } from '../config/constants.js';
29
+ import { COMPILE_FILES } from '../config/compile.constants.js';
30
+ import { PrimitiveKind } from '../compiler/types.js';
31
+ // =============================================================================
32
+ // HELPERS
33
+ // =============================================================================
34
+ function getCliVersion() {
35
+ try {
36
+ const __filename = fileURLToPath(import.meta.url);
37
+ const __dirname = dirname(__filename);
38
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf8'));
39
+ return pkg.version;
40
+ }
41
+ catch {
42
+ return '0.0.0';
43
+ }
44
+ }
45
+ function detectInstallMethod(execPath) {
46
+ if (execPath.includes('/.volta/'))
47
+ return 'volta';
48
+ if (execPath.includes('/.nvm/versions/')) {
49
+ const nodeMajor = process.version.split('.')[0].replace('v', '');
50
+ return `nvm-${nodeMajor}`;
51
+ }
52
+ if (execPath.includes('/.fnm/'))
53
+ return 'fnm';
54
+ if (execPath.includes('/pnpm/global/'))
55
+ return 'pnpm-global';
56
+ if (execPath.includes('/.bun/install/'))
57
+ return 'bun-install';
58
+ if (execPath.startsWith('/usr/local/') || execPath.startsWith('/opt/homebrew/')) {
59
+ return 'homebrew-or-npm-global';
60
+ }
61
+ if (execPath.includes('/node_modules/.bin'))
62
+ return 'project-local';
63
+ return 'unknown';
64
+ }
65
+ function detectChannel(currentVersion) {
66
+ const { preRelease } = parseVersion(currentVersion);
67
+ if (!preRelease)
68
+ return 'latest';
69
+ const tag = preRelease.split('.')[0].replace(/[0-9]/g, '');
70
+ return tag || 'latest';
71
+ }
72
+ function formatRelativeTime(checkedAtMs) {
73
+ if (!checkedAtMs)
74
+ return null;
75
+ return new Date(checkedAtMs).toISOString();
76
+ }
77
+ // =============================================================================
78
+ // SECTION GATHERERS
79
+ // =============================================================================
80
+ function gatherEnvironment(currentVersion) {
81
+ return {
82
+ cliVersion: currentVersion,
83
+ channel: detectChannel(currentVersion),
84
+ nodeVersion: process.version,
85
+ platform: os.platform(),
86
+ arch: os.arch(),
87
+ osRelease: os.release(),
88
+ installMethod: detectInstallMethod(process.execPath),
89
+ execPath: process.execPath,
90
+ configDir: CLI_CONFIG_DIR,
91
+ apiBase: BASE_URLS.API,
92
+ authBase: BASE_URLS.AUTH,
93
+ envOverrides: {
94
+ LUA_API_URL: process.env.LUA_API_URL ?? null,
95
+ LUA_AUTH_URL: process.env.LUA_AUTH_URL ?? null,
96
+ LUA_API_KEY: process.env.LUA_API_KEY ? 'set' : 'not set',
97
+ LUA_TELEMETRY: process.env.LUA_TELEMETRY ?? null,
98
+ LUA_NO_HINTS: process.env.LUA_NO_HINTS ?? null,
99
+ },
100
+ };
101
+ }
102
+ async function gatherUpdates(currentVersion) {
103
+ const preFetchCache = getCachedVersionCheck();
104
+ try {
105
+ const result = await isUpdateAvailable(currentVersion);
106
+ const postFetchCache = getCachedVersionCheck();
107
+ return {
108
+ current: currentVersion,
109
+ latest: result.latest,
110
+ available: result.available,
111
+ lastCheckedAt: postFetchCache ? formatRelativeTime(postFetchCache.checkedAt) : null,
112
+ fromCache: !!preFetchCache,
113
+ };
114
+ }
115
+ catch {
116
+ const postFetchCache = getCachedVersionCheck();
117
+ return {
118
+ current: currentVersion,
119
+ latest: postFetchCache?.latestVersion ?? null,
120
+ available: false,
121
+ lastCheckedAt: postFetchCache ? formatRelativeTime(postFetchCache.checkedAt) : null,
122
+ fromCache: !!preFetchCache,
123
+ };
124
+ }
125
+ }
126
+ async function gatherAuth() {
127
+ let apiKey = null;
128
+ try {
129
+ apiKey = loadApiKey();
130
+ }
131
+ catch {
132
+ apiKey = null;
133
+ }
134
+ if (!apiKey) {
135
+ let serverReachable = null;
136
+ let reachabilityMs = null;
137
+ try {
138
+ const start = performance.now();
139
+ const response = await fetch(BASE_URLS.API, {
140
+ method: 'HEAD',
141
+ signal: AbortSignal.timeout(3000),
142
+ });
143
+ reachabilityMs = Math.round(performance.now() - start);
144
+ serverReachable = response.ok || (response.status >= 200 && response.status < 500);
145
+ }
146
+ catch {
147
+ serverReachable = false;
148
+ reachabilityMs = null;
149
+ }
150
+ return {
151
+ authenticated: false,
152
+ source: null,
153
+ email: null,
154
+ userId: null,
155
+ organizations: [],
156
+ serverReachable,
157
+ reachabilityMs,
158
+ };
159
+ }
160
+ const source = process.env.LUA_API_KEY ? 'env' : 'credentials file';
161
+ let email = null;
162
+ let userId = null;
163
+ let organizations = [];
164
+ let serverReachable = null;
165
+ let reachabilityMs = null;
166
+ let keyAccepted = false;
167
+ try {
168
+ const authApi = new AuthApi(BASE_URLS.API);
169
+ const start = performance.now();
170
+ const result = await authApi.checkApiKey(apiKey);
171
+ reachabilityMs = Math.round(performance.now() - start);
172
+ serverReachable = true; // got a network response (key may still be rejected)
173
+ if (result.success && result.data) {
174
+ keyAccepted = true;
175
+ email = result.data.email ?? null;
176
+ userId = result.data.uid ?? null;
177
+ const orgs = result.data.admin?.orgs ?? [];
178
+ organizations = orgs.map((o) => ({
179
+ id: o.id ?? o.orgId ?? '',
180
+ name: o.registeredName ?? o.name ?? '',
181
+ }));
182
+ }
183
+ }
184
+ catch {
185
+ serverReachable = false; // network error — couldn't reach the server
186
+ }
187
+ return {
188
+ authenticated: keyAccepted,
189
+ source,
190
+ email,
191
+ userId,
192
+ organizations,
193
+ serverReachable,
194
+ reachabilityMs,
195
+ };
196
+ }
197
+ function gatherProject(config) {
198
+ if (!config) {
199
+ return {
200
+ inProject: false,
201
+ rootDir: null,
202
+ configPath: null,
203
+ agentId: null,
204
+ agentName: null,
205
+ manifest: { found: false, primitiveCount: 0 },
206
+ };
207
+ }
208
+ const rootDir = process.cwd();
209
+ const configPath = join(rootDir, COMPILE_FILES.LUA_SKILL_YAML);
210
+ const agentId = config.agent?.agentId != null ? String(config.agent.agentId) : null;
211
+ let agentName = null;
212
+ let manifestFound = false;
213
+ let primitiveCount = 0;
214
+ try {
215
+ agentName = getAgentName() ?? null;
216
+ }
217
+ catch {
218
+ agentName = null;
219
+ }
220
+ try {
221
+ const manifest = loadManifest();
222
+ manifestFound = true;
223
+ primitiveCount = manifest.primitives.filter((p) => p.kind !== PrimitiveKind.AGENT).length;
224
+ }
225
+ catch {
226
+ manifestFound = false;
227
+ }
228
+ return {
229
+ inProject: true,
230
+ rootDir,
231
+ configPath,
232
+ agentId,
233
+ agentName,
234
+ manifest: { found: manifestFound, primitiveCount },
235
+ };
236
+ }
237
+ async function gatherPrimitives(input, warnings) {
238
+ const { apiKey, agentId, config } = input;
239
+ if (!config)
240
+ return [];
241
+ const sections = [];
242
+ // Local items per handler (sync — read from yaml)
243
+ const localPerHandler = new Map();
244
+ for (const handler of syncableHandlers) {
245
+ const yamlItems = handler.getFromYaml(config);
246
+ const items = yamlItems.map((item) => ({
247
+ name: item.name,
248
+ version: item.version || '',
249
+ entityId: item[handler.yamlConfig.idField] ?? '',
250
+ }));
251
+ localPerHandler.set(handler, items);
252
+ }
253
+ // Fetch server state per handler in parallel — Promise.allSettled to isolate failures.
254
+ const serverPerHandler = new Map();
255
+ if (apiKey && agentId) {
256
+ const fetchResults = await Promise.allSettled(syncableHandlers.map((handler) => handler.fetchServerState(apiKey, agentId)));
257
+ syncableHandlers.forEach((handler, i) => {
258
+ const result = fetchResults[i];
259
+ if (result.status === 'fulfilled') {
260
+ if (result.value.fetchError) {
261
+ warnings.push(`Failed to fetch server state for ${handler.displayNamePlural}: ${result.value.fetchError}`);
262
+ serverPerHandler.set(handler, null);
263
+ }
264
+ else {
265
+ serverPerHandler.set(handler, result.value.serverItems ?? []);
266
+ }
267
+ }
268
+ else {
269
+ warnings.push(`Failed to fetch server state for ${handler.displayNamePlural}: ${result.reason?.message ?? 'unknown error'}`);
270
+ serverPerHandler.set(handler, null);
271
+ }
272
+ });
273
+ }
274
+ for (const handler of syncableHandlers) {
275
+ const local = localPerHandler.get(handler) ?? [];
276
+ const serverItems = serverPerHandler.get(handler) ?? null;
277
+ const versioned = isVersionedHandler(handler);
278
+ const server = (serverItems ?? []).map((s) => ({
279
+ name: s.name,
280
+ activeVersion: versioned ? handler.getActiveVersion(s) : null,
281
+ active: handler.isActive?.(s) ?? true,
282
+ }));
283
+ const serverByName = new Map();
284
+ for (const s of serverItems ?? []) {
285
+ serverByName.set(s.name, s);
286
+ }
287
+ const diffs = [];
288
+ if (serverItems !== null) {
289
+ for (const item of local) {
290
+ const serverItem = serverByName.get(item.name);
291
+ const activeVersion = versioned && serverItem ? handler.getActiveVersion(serverItem) : null;
292
+ let status;
293
+ if (!versioned) {
294
+ // Non-versioned (MCP servers): present on server = synced, absent = not deployed
295
+ status = serverItem ? 'synced' : 'not deployed';
296
+ }
297
+ else if (!item.version || activeVersion === null) {
298
+ status = 'not deployed';
299
+ }
300
+ else {
301
+ const cmp = compareVersions(item.version, activeVersion);
302
+ if (cmp > 0)
303
+ status = 'ahead';
304
+ else if (cmp < 0)
305
+ status = 'behind';
306
+ else
307
+ status = 'synced';
308
+ }
309
+ diffs.push({
310
+ name: item.name,
311
+ localVersion: item.version,
312
+ serverVersion: activeVersion,
313
+ status,
314
+ });
315
+ }
316
+ }
317
+ const orphans = [];
318
+ if (serverItems !== null) {
319
+ const localNames = new Set(local.map((i) => i.name));
320
+ const isProcessor = handler.kind === PrimitiveKind.PREPROCESSOR || handler.kind === PrimitiveKind.POSTPROCESSOR;
321
+ for (const s of serverItems) {
322
+ if (localNames.has(s.name))
323
+ continue;
324
+ if (!(handler.isActive?.(s) ?? true))
325
+ continue;
326
+ if (!handler.shouldConsiderForOrphan(s))
327
+ continue;
328
+ const flagName = `--${handler.displayName.toLowerCase().replace(/\s+/g, '-')}-name`;
329
+ // Some primitive types have no CLI delete command yet
330
+ const cleanupCommand = handler.kind !== PrimitiveKind.DEVICE_TRIGGER ? `${handler.deleteCommand} ${flagName} "${s.name}"` : '';
331
+ orphans.push({
332
+ name: s.name,
333
+ cleanupCommand,
334
+ critical: isProcessor,
335
+ });
336
+ }
337
+ }
338
+ sections.push({
339
+ kind: handler.kind,
340
+ displayName: handler.displayNamePlural,
341
+ local,
342
+ server,
343
+ diffs,
344
+ orphans,
345
+ });
346
+ }
347
+ return sections;
348
+ }
349
+ async function gatherPersona(apiKey, agentId) {
350
+ if (!apiKey || !agentId)
351
+ return { status: 'unknown' };
352
+ try {
353
+ const drift = await checkPersonaDrift(apiKey, agentId);
354
+ return { status: drift ? 'drift' : 'synced' };
355
+ }
356
+ catch {
357
+ return { status: 'unknown' };
358
+ }
359
+ }
360
+ function gatherBackup(config) {
361
+ if (!config)
362
+ return { status: 'unknown' };
363
+ let currentHash = null;
364
+ try {
365
+ currentHash = getCurrentProjectHash();
366
+ }
367
+ catch {
368
+ currentHash = null;
369
+ }
370
+ if (!currentHash)
371
+ return { status: 'never-compiled' };
372
+ try {
373
+ const out = isBackupOutOfSync(currentHash, config.backup);
374
+ return { status: out ? 'out-of-sync' : 'synced' };
375
+ }
376
+ catch {
377
+ return { status: 'unknown' };
378
+ }
379
+ }
380
+ function gatherTelemetry() {
381
+ const envVal = process.env.LUA_TELEMETRY;
382
+ const envOverride = envVal !== undefined;
383
+ let enabled = true;
384
+ if (envOverride) {
385
+ enabled = !['false', '0', 'off', 'no'].includes(envVal.toLowerCase());
386
+ }
387
+ else {
388
+ try {
389
+ if (existsSync(TELEMETRY_FILE)) {
390
+ const raw = readFileSync(TELEMETRY_FILE, 'utf8');
391
+ const cfg = JSON.parse(raw);
392
+ if (typeof cfg.enabled === 'boolean')
393
+ enabled = cfg.enabled;
394
+ }
395
+ }
396
+ catch {
397
+ // default enabled = true
398
+ }
399
+ }
400
+ return { enabled, envOverride };
401
+ }
402
+ // =============================================================================
403
+ // HINTS
404
+ // =============================================================================
405
+ function deriveHints(report) {
406
+ const hints = [];
407
+ if (report.updates.available && report.updates.latest) {
408
+ hints.push({
409
+ command: 'lua update',
410
+ reason: `Upgrade lua-cli (${report.updates.current} → ${report.updates.latest})`,
411
+ });
412
+ }
413
+ if (!report.auth.authenticated) {
414
+ hints.push({
415
+ command: 'lua auth configure',
416
+ reason: 'Authenticate for full server comparison',
417
+ });
418
+ }
419
+ for (const section of report.primitives) {
420
+ for (const orphan of section.orphans) {
421
+ if (!orphan.cleanupCommand)
422
+ continue;
423
+ hints.push({
424
+ command: orphan.cleanupCommand,
425
+ reason: orphan.critical
426
+ ? `Remove orphan ${section.displayName} "${orphan.name}" (causes errors)`
427
+ : `Remove orphan ${section.displayName} "${orphan.name}"`,
428
+ });
429
+ }
430
+ }
431
+ if (report.backup.status === 'out-of-sync') {
432
+ hints.push({
433
+ command: 'lua push backup',
434
+ reason: 'Sync source backup',
435
+ });
436
+ }
437
+ if (report.persona.status === 'drift') {
438
+ hints.push({
439
+ command: 'lua sync',
440
+ reason: 'Resolve persona drift',
441
+ });
442
+ }
443
+ return hints;
444
+ }
445
+ // =============================================================================
446
+ // RENDERERS
447
+ // =============================================================================
448
+ function pad(s, n) {
449
+ return s.length >= n ? s : s + ' '.repeat(n - s.length);
450
+ }
451
+ function printJson(report) {
452
+ console.log(JSON.stringify(report));
453
+ }
454
+ function printHuman(report) {
455
+ const lines = [];
456
+ lines.push('');
457
+ lines.push('== lua status ==');
458
+ lines.push('');
459
+ // Environment
460
+ const env = report.environment;
461
+ lines.push('Environment');
462
+ lines.push(` CLI version ${env.cliVersion} (channel: ${env.channel})`);
463
+ lines.push(` Node ${env.nodeVersion}`);
464
+ lines.push(` OS ${env.platform} ${env.osRelease} (${env.arch})`);
465
+ lines.push(` Install method ${env.installMethod}`);
466
+ lines.push(` Exec path ${env.execPath}`);
467
+ lines.push(` Config dir ${env.configDir}`);
468
+ lines.push(` API base ${env.apiBase}`);
469
+ lines.push(` Auth base ${env.authBase}`);
470
+ const overrides = env.envOverrides;
471
+ const overridesStr = [
472
+ `LUA_API_URL: ${overrides.LUA_API_URL ?? 'not set'}`,
473
+ `LUA_AUTH_URL: ${overrides.LUA_AUTH_URL ?? 'not set'}`,
474
+ `LUA_API_KEY: ${overrides.LUA_API_KEY}`,
475
+ `LUA_TELEMETRY: ${overrides.LUA_TELEMETRY ?? 'not set'}`,
476
+ `LUA_NO_HINTS: ${overrides.LUA_NO_HINTS ?? 'not set'}`,
477
+ ].join(', ');
478
+ lines.push(` Env overrides ${overridesStr}`);
479
+ lines.push('');
480
+ // Updates
481
+ const u = report.updates;
482
+ lines.push('Updates');
483
+ lines.push(` Current ${u.current}`);
484
+ lines.push(` Latest published ${u.latest ?? 'unknown'}`);
485
+ lines.push(` Status ${u.available ? 'update available — run `lua update`' : 'up to date'}`);
486
+ if (u.lastCheckedAt) {
487
+ lines.push(` Last checked ${u.lastCheckedAt}${u.fromCache ? ' (cache)' : ''}`);
488
+ }
489
+ lines.push('');
490
+ // Auth
491
+ const a = report.auth;
492
+ lines.push('Auth');
493
+ if (a.source) {
494
+ lines.push(` Key source ${a.source}`);
495
+ if (a.authenticated) {
496
+ lines.push(` Email ${a.email ?? 'unknown'}`);
497
+ lines.push(` User ID ${a.userId ?? 'unknown'}`);
498
+ if (a.organizations.length > 0) {
499
+ const orgNames = a.organizations
500
+ .map((o) => o.name || o.id)
501
+ .filter(Boolean)
502
+ .join(', ');
503
+ lines.push(` Organizations ${a.organizations.length} (${orgNames})`);
504
+ }
505
+ else {
506
+ lines.push(` Organizations 0`);
507
+ }
508
+ lines.push(` Status authenticated${a.reachabilityMs !== null ? ` (${a.reachabilityMs}ms)` : ''}`);
509
+ }
510
+ else if (a.serverReachable) {
511
+ lines.push(` Status key rejected by server${a.reachabilityMs !== null ? ` (${a.reachabilityMs}ms)` : ''}`);
512
+ }
513
+ else {
514
+ lines.push(` Status key found, server unreachable`);
515
+ }
516
+ }
517
+ else {
518
+ lines.push(` Status no API key configured — run \`lua auth configure\``);
519
+ if (a.serverReachable !== null) {
520
+ lines.push(` Server ${a.serverReachable ? 'reachable' : 'unreachable'}${a.reachabilityMs !== null ? ` (${a.reachabilityMs}ms)` : ''}`);
521
+ }
522
+ }
523
+ lines.push('');
524
+ // Project
525
+ const p = report.project;
526
+ lines.push('Project');
527
+ if (p.inProject) {
528
+ lines.push(` Path ${p.rootDir}`);
529
+ lines.push(` Config ${p.configPath} (found)`);
530
+ lines.push(` Agent ${p.agentName ?? 'unnamed'}${p.agentId ? ` (${p.agentId.substring(0, 8)})` : ''}`);
531
+ if (p.manifest.found) {
532
+ lines.push(` Manifest dist-v2/manifest.json (compiled, ${p.manifest.primitiveCount} primitives)`);
533
+ }
534
+ else {
535
+ lines.push(` Manifest (never compiled)`);
536
+ }
537
+ }
538
+ else {
539
+ lines.push(` (not in a lua project)`);
540
+ }
541
+ lines.push('');
542
+ // Per-primitive sections
543
+ for (const section of report.primitives) {
544
+ const label = section.displayName.charAt(0).toUpperCase() + section.displayName.slice(1);
545
+ const localCount = section.local.length;
546
+ const serverCount = section.server.length;
547
+ lines.push(`${pad(label, 22)}${localCount} local ${serverCount} server`);
548
+ if (localCount === 0 && section.orphans.length === 0) {
549
+ lines.push(' (none)');
550
+ lines.push('');
551
+ continue;
552
+ }
553
+ lines.push(` ${pad('name', 22)}${pad('local', 10)}${pad('server', 10)}status`);
554
+ lines.push('');
555
+ for (const diff of section.diffs) {
556
+ const sv = diff.serverVersion ?? '--';
557
+ lines.push(` ${pad(diff.name, 22)}${pad(diff.localVersion, 10)}${pad(sv, 10)}${diff.status}`);
558
+ }
559
+ for (const orphan of section.orphans) {
560
+ const serverEntry = section.server.find((s) => s.name === orphan.name);
561
+ const sv = serverEntry?.activeVersion ?? '--';
562
+ lines.push(` ${pad(orphan.name, 22)}${pad('--', 10)}${pad(sv, 10)}server only${orphan.critical ? ' ⚠ causes errors' : ''}`);
563
+ }
564
+ lines.push('');
565
+ }
566
+ // Persona
567
+ const personaLabel = report.persona.status === 'synced'
568
+ ? '[synced]'
569
+ : report.persona.status === 'drift'
570
+ ? '[drift detected] Local differs from server'
571
+ : '[unknown]';
572
+ lines.push(`Persona ${personaLabel}`);
573
+ // Backup
574
+ const backupLabel = report.backup.status === 'synced'
575
+ ? '[synced]'
576
+ : report.backup.status === 'out-of-sync'
577
+ ? '[out of sync] Source files changed since last push'
578
+ : report.backup.status === 'never-compiled'
579
+ ? '[never-compiled] Run `lua compile` first'
580
+ : '[unknown]';
581
+ lines.push(`Backup ${backupLabel}`);
582
+ // Telemetry
583
+ lines.push(`Telemetry ${report.telemetry.enabled ? 'enabled' : 'disabled'}${report.telemetry.envOverride ? ' (LUA_TELEMETRY override)' : ''}`);
584
+ lines.push('');
585
+ // Warnings
586
+ if (report.warnings.length > 0) {
587
+ lines.push('Warnings');
588
+ for (const w of report.warnings) {
589
+ lines.push(` - ${w}`);
590
+ }
591
+ lines.push('');
592
+ }
593
+ // Next steps
594
+ if (report.hints.length > 0) {
595
+ lines.push('Next steps');
596
+ for (const h of report.hints) {
597
+ lines.push(` - ${h.reason}: \`${h.command}\``);
598
+ }
599
+ lines.push('');
600
+ }
601
+ console.log(lines.join('\n'));
602
+ }
603
+ // =============================================================================
604
+ // ENTRY POINT
605
+ // =============================================================================
606
+ export async function statusCommand(options) {
607
+ return withErrorHandling(async () => {
608
+ const warnings = [];
609
+ const currentVersion = getCliVersion();
610
+ const environment = gatherEnvironment(currentVersion);
611
+ // Gather concurrent sections via allSettled — each failure becomes a warning, never aborts.
612
+ const [updatesResult, authResult] = await Promise.allSettled([gatherUpdates(currentVersion), gatherAuth()]);
613
+ const updates = updatesResult.status === 'fulfilled'
614
+ ? updatesResult.value
615
+ : (() => {
616
+ warnings.push(`updates: ${updatesResult.reason?.message ?? 'unknown'}`);
617
+ return {
618
+ current: currentVersion,
619
+ latest: null,
620
+ available: false,
621
+ lastCheckedAt: null,
622
+ fromCache: false,
623
+ };
624
+ })();
625
+ const auth = authResult.status === 'fulfilled'
626
+ ? authResult.value
627
+ : (() => {
628
+ warnings.push(`auth: ${authResult.reason?.message ?? 'unknown'}`);
629
+ return {
630
+ authenticated: false,
631
+ source: null,
632
+ email: null,
633
+ userId: null,
634
+ organizations: [],
635
+ serverReachable: null,
636
+ reachabilityMs: null,
637
+ };
638
+ })();
639
+ let config = null;
640
+ try {
641
+ config = readYamlConfig();
642
+ }
643
+ catch (err) {
644
+ warnings.push(`config: ${err?.message ?? 'unknown'}`);
645
+ }
646
+ let project;
647
+ try {
648
+ project = gatherProject(config);
649
+ }
650
+ catch (err) {
651
+ warnings.push(`project: ${err?.message ?? 'unknown'}`);
652
+ project = {
653
+ inProject: false,
654
+ rootDir: null,
655
+ configPath: null,
656
+ agentId: null,
657
+ agentName: null,
658
+ manifest: { found: false, primitiveCount: 0 },
659
+ };
660
+ }
661
+ const apiKey = (() => {
662
+ try {
663
+ return loadApiKey();
664
+ }
665
+ catch {
666
+ return null;
667
+ }
668
+ })();
669
+ const [primitivesResult, personaResult] = await Promise.allSettled([
670
+ gatherPrimitives({ apiKey, agentId: project.agentId, config }, warnings),
671
+ gatherPersona(apiKey, project.agentId),
672
+ ]);
673
+ const primitives = primitivesResult.status === 'fulfilled'
674
+ ? primitivesResult.value
675
+ : (() => {
676
+ warnings.push(`primitives: ${primitivesResult.reason?.message ?? 'unknown'}`);
677
+ return [];
678
+ })();
679
+ const persona = personaResult.status === 'fulfilled'
680
+ ? personaResult.value
681
+ : (() => {
682
+ warnings.push(`persona: ${personaResult.reason?.message ?? 'unknown'}`);
683
+ return { status: 'unknown' };
684
+ })();
685
+ let backup;
686
+ try {
687
+ backup = gatherBackup(config);
688
+ }
689
+ catch (err) {
690
+ warnings.push(`backup: ${err?.message ?? 'unknown'}`);
691
+ backup = { status: 'unknown' };
692
+ }
693
+ let telemetry;
694
+ try {
695
+ telemetry = gatherTelemetry();
696
+ }
697
+ catch (err) {
698
+ warnings.push(`telemetry: ${err?.message ?? 'unknown'}`);
699
+ telemetry = { enabled: true, envOverride: false };
700
+ }
701
+ const reportNoHints = {
702
+ schemaVersion: 1,
703
+ command: 'status',
704
+ generatedAt: new Date().toISOString(),
705
+ environment,
706
+ updates,
707
+ auth,
708
+ project,
709
+ primitives,
710
+ persona,
711
+ backup,
712
+ telemetry,
713
+ warnings,
714
+ };
715
+ const hints = hintsDisabled() ? [] : deriveHints(reportNoHints);
716
+ const report = { ...reportNoHints, hints };
717
+ if (options.json) {
718
+ printJson(report);
719
+ }
720
+ else {
721
+ printHuman(report);
722
+ }
723
+ trackEvent('cli_status_completed', {
724
+ has_server: !!apiKey,
725
+ in_project: project.inProject,
726
+ json_mode: !!options.json,
727
+ sections_failed: warnings.length,
728
+ });
729
+ }, 'status');
730
+ }
731
+ //# sourceMappingURL=status.js.map