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
@@ -1,53 +1,51 @@
1
- import { LuaTool } from "lua-cli";
2
- import { z } from "zod";
1
+ import { LuaTool } from 'lua-cli';
2
+ import { z } from 'zod';
3
3
 
4
4
  export default class GetWeatherTool implements LuaTool {
5
- name = "get_weather";
6
- description = "Get the weather for a given city";
7
- inputSchema = z.object({
8
- city: z.string()
9
- });
10
- outputSchema = z.object({
11
- weather: z.string(),
12
- city: z.string(),
13
- temperature: z.number().optional(),
14
- humidity: z.number().optional(),
15
- description: z.string().optional()
16
- });
5
+ name = 'get_weather';
6
+ description = 'Get the weather for a given city';
7
+ inputSchema = z.object({
8
+ city: z.string(),
9
+ });
10
+ outputSchema = z.object({
11
+ weather: z.string(),
12
+ city: z.string(),
13
+ temperature: z.number().optional(),
14
+ humidity: z.number().optional(),
15
+ description: z.string().optional(),
16
+ });
17
17
 
18
- async execute(input: z.infer<typeof this.inputSchema>) {
19
- // Step 1: Geocode city → lat/lon (use Open-Meteo’s free geocoding API)
20
- const geoUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(
21
- input.city
22
- )}&count=1`;
23
-
24
- const geoRes = await fetch(geoUrl);
25
- if (!geoRes.ok) {
26
- throw new Error(`Failed to fetch location: ${geoRes.statusText}`);
27
- }
28
- const geoData = await geoRes.json();
29
- if (!geoData.results || geoData.results.length === 0) {
30
- throw new Error(`No location found for ${input.city}`);
31
- }
18
+ async execute(input: z.infer<typeof this.inputSchema>) {
19
+ // Step 1: Geocode city → lat/lon (use Open-Meteo’s free geocoding API)
20
+ const geoUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(input.city)}&count=1`;
32
21
 
33
- const { latitude, longitude, name } = geoData.results[0];
22
+ const geoRes = await fetch(geoUrl);
23
+ if (!geoRes.ok) {
24
+ throw new Error(`Failed to fetch location: ${geoRes.statusText}`);
25
+ }
26
+ const geoData = await geoRes.json();
27
+ if (!geoData.results || geoData.results.length === 0) {
28
+ throw new Error(`No location found for ${input.city}`);
29
+ }
34
30
 
35
- // Step 2: Get weather for lat/lon
36
- const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true`;
37
-
38
- const weatherRes = await fetch(weatherUrl);
39
- if (!weatherRes.ok) {
40
- throw new Error(`Failed to fetch weather: ${weatherRes.statusText}`);
41
- }
42
- const weatherData = await weatherRes.json();
43
- const current = weatherData.current_weather;
31
+ const { latitude, longitude, name } = geoData.results[0];
44
32
 
45
- return {
46
- weather: current.weathercode?.toString() || "Unknown",
47
- city: name,
48
- temperature: current.temperature,
49
- humidity: undefined, // Open-Meteo current_weather does not include humidity
50
- description: `Windspeed ${current.windspeed} km/h`
51
- };
33
+ // Step 2: Get weather for lat/lon
34
+ const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true`;
35
+
36
+ const weatherRes = await fetch(weatherUrl);
37
+ if (!weatherRes.ok) {
38
+ throw new Error(`Failed to fetch weather: ${weatherRes.statusText}`);
52
39
  }
40
+ const weatherData = await weatherRes.json();
41
+ const current = weatherData.current_weather;
42
+
43
+ return {
44
+ weather: current.weathercode?.toString() || 'Unknown',
45
+ city: name,
46
+ temperature: current.temperature,
47
+ humidity: undefined, // Open-Meteo current_weather does not include humidity
48
+ description: `Windspeed ${current.windspeed} km/h`,
49
+ };
50
+ }
53
51
  }
@@ -1,56 +1,56 @@
1
- import { LuaTool, Orders, } from "lua-cli";
2
- import { z } from "zod";
1
+ import { LuaTool, Orders } from 'lua-cli';
2
+ import { z } from 'zod';
3
3
  import { OrderStatus } from 'lua-cli';
4
4
 
5
-
6
-
7
5
  export class CreateOrderTool implements LuaTool {
8
- name = "create_order";
9
- description = "Create a new order";
10
- inputSchema = z.object({
11
- order: z.object({
12
- basketId: z.string(),
13
- data: z.object({
14
- storeId: z.string(),
15
- }).optional()
6
+ name = 'create_order';
7
+ description = 'Create a new order';
8
+ inputSchema = z.object({
9
+ order: z.object({
10
+ basketId: z.string(),
11
+ data: z
12
+ .object({
13
+ storeId: z.string(),
16
14
  })
17
- });
18
- async execute(input: z.infer<typeof this.inputSchema>) {
19
- return Orders.create(input.order);
20
- }
15
+ .optional(),
16
+ }),
17
+ });
18
+ async execute(input: z.infer<typeof this.inputSchema>) {
19
+ return Orders.create(input.order);
20
+ }
21
21
  }
22
22
 
23
23
  export class UpdateOrderStatusTool implements LuaTool {
24
- name = "update_order_status";
25
- description = "Update the status of an order";
26
- inputSchema = z.object({
27
- orderId: z.string(),
28
- status: z.enum(['pending', 'confirmed', 'fulfilled', 'cancelled'])
29
- });
30
- async execute(input: z.infer<typeof this.inputSchema>) {
31
- const order = await Orders.getById(input.orderId);
32
- return order.updateStatus(input.status as OrderStatus);
33
- }
24
+ name = 'update_order_status';
25
+ description = 'Update the status of an order';
26
+ inputSchema = z.object({
27
+ orderId: z.string(),
28
+ status: z.enum(['pending', 'confirmed', 'fulfilled', 'cancelled']),
29
+ });
30
+ async execute(input: z.infer<typeof this.inputSchema>) {
31
+ const order = await Orders.getById(input.orderId);
32
+ return order.updateStatus(input.status as OrderStatus);
33
+ }
34
34
  }
35
35
 
36
36
  export class GetUserOrdersTool implements LuaTool {
37
- name = "get_user_orders";
38
- description = "Get all orders for a user";
39
- inputSchema = z.object({});
40
- async execute(input: z.infer<typeof this.inputSchema>) {
41
- return Orders.get();
42
- }
37
+ name = 'get_user_orders';
38
+ description = 'Get all orders for a user';
39
+ inputSchema = z.object({});
40
+ async execute(input: z.infer<typeof this.inputSchema>) {
41
+ return Orders.get();
42
+ }
43
43
  }
44
44
 
45
45
  export class GetOrderByIdTool implements LuaTool {
46
- name = "get_order_by_id";
47
- description = "Get an order by id";
48
- inputSchema = z.object({
49
- orderId: z.string()
50
- });
51
- async execute(input: z.infer<typeof this.inputSchema>) {
52
- return Orders.getById(input.orderId);
53
- }
46
+ name = 'get_order_by_id';
47
+ description = 'Get an order by id';
48
+ inputSchema = z.object({
49
+ orderId: z.string(),
50
+ });
51
+ async execute(input: z.infer<typeof this.inputSchema>) {
52
+ return Orders.getById(input.orderId);
53
+ }
54
54
  }
55
55
 
56
56
  /**
@@ -58,22 +58,22 @@ export class GetOrderByIdTool implements LuaTool {
58
58
  * Useful for adding tracking info, notes, or custom metadata.
59
59
  */
60
60
  export class UpdateOrderDataTool implements LuaTool {
61
- name = "update_order_data";
62
- description = "Update custom data on an order (tracking info, notes, etc.)";
63
- inputSchema = z.object({
64
- orderId: z.string().describe("The order ID to update"),
65
- data: z.record(z.any()).describe("Custom data to add/update on the order")
66
- });
67
- async execute(input: z.infer<typeof this.inputSchema>) {
68
- console.log(`📝 Updating order ${input.orderId} with data:`, input.data);
69
-
70
- const result = await Orders.updateData(input.data, input.orderId);
71
-
72
- return {
73
- success: true,
74
- orderId: input.orderId,
75
- message: "Order data updated successfully",
76
- updatedData: input.data
77
- };
78
- }
61
+ name = 'update_order_data';
62
+ description = 'Update custom data on an order (tracking info, notes, etc.)';
63
+ inputSchema = z.object({
64
+ orderId: z.string().describe('The order ID to update'),
65
+ data: z.record(z.any()).describe('Custom data to add/update on the order'),
66
+ });
67
+ async execute(input: z.infer<typeof this.inputSchema>) {
68
+ console.log(`📝 Updating order ${input.orderId} with data:`, input.data);
69
+
70
+ const result = await Orders.updateData(input.data, input.orderId);
71
+
72
+ return {
73
+ success: true,
74
+ orderId: input.orderId,
75
+ message: 'Order data updated successfully',
76
+ updatedData: input.data,
77
+ };
78
+ }
79
79
  }
@@ -1,51 +1,51 @@
1
- import { LuaTool, env } from "lua-cli";
2
- import { z } from "zod";
1
+ import { LuaTool, env } from 'lua-cli';
2
+ import { z } from 'zod';
3
3
 
4
4
  export default class CreatePaymentLinkTool implements LuaTool {
5
- name = "create_payment_link";
6
- description = "Create a Stripe payment link for a one-time payment";
7
- inputSchema = z.object({
8
- amount: z.number().int().positive(), // in cents
9
- currency: z.string().default("usd")
10
- });
11
- outputSchema = z.object({
12
- url: z.string(),
13
- id: z.string(),
14
- });
5
+ name = 'create_payment_link';
6
+ description = 'Create a Stripe payment link for a one-time payment';
7
+ inputSchema = z.object({
8
+ amount: z.number().int().positive(), // in cents
9
+ currency: z.string().default('usd'),
10
+ });
11
+ outputSchema = z.object({
12
+ url: z.string(),
13
+ id: z.string(),
14
+ });
15
15
 
16
- async execute(input: z.infer<typeof this.inputSchema>) {
17
- const apiKey = env("STRIPE_SECRET_KEY");
18
- if (!apiKey) {
19
- throw new Error("STRIPE_SECRET_KEY is not set in environment variables");
20
- }
16
+ async execute(input: z.infer<typeof this.inputSchema>) {
17
+ const apiKey = env('STRIPE_SECRET_KEY');
18
+ if (!apiKey) {
19
+ throw new Error('STRIPE_SECRET_KEY is not set in environment variables');
20
+ }
21
21
 
22
- // Create a one-time Checkout Session with dummy redirect URLs
23
- const sessionRes = await fetch("https://api.stripe.com/v1/checkout/sessions", {
24
- method: "POST",
25
- headers: {
26
- Authorization: `Bearer ${apiKey}`,
27
- "Content-Type": "application/x-www-form-urlencoded",
28
- },
29
- body: new URLSearchParams({
30
- mode: "payment",
31
- "line_items[0][price_data][currency]": input.currency,
32
- "line_items[0][price_data][product_data][name]": "One-time Payment",
33
- "line_items[0][price_data][unit_amount]": input.amount.toString(),
34
- "line_items[0][quantity]": "1",
35
- success_url: "https://example.com/success",
36
- cancel_url: "https://example.com/cancel",
37
- }),
38
- });
22
+ // Create a one-time Checkout Session with dummy redirect URLs
23
+ const sessionRes = await fetch('https://api.stripe.com/v1/checkout/sessions', {
24
+ method: 'POST',
25
+ headers: {
26
+ Authorization: `Bearer ${apiKey}`,
27
+ 'Content-Type': 'application/x-www-form-urlencoded',
28
+ },
29
+ body: new URLSearchParams({
30
+ mode: 'payment',
31
+ 'line_items[0][price_data][currency]': input.currency,
32
+ 'line_items[0][price_data][product_data][name]': 'One-time Payment',
33
+ 'line_items[0][price_data][unit_amount]': input.amount.toString(),
34
+ 'line_items[0][quantity]': '1',
35
+ success_url: 'https://example.com/success',
36
+ cancel_url: 'https://example.com/cancel',
37
+ }),
38
+ });
39
39
 
40
- if (!sessionRes.ok) {
41
- throw new Error(`Failed to create checkout session: ${await sessionRes.text()}`);
42
- }
40
+ if (!sessionRes.ok) {
41
+ throw new Error(`Failed to create checkout session: ${await sessionRes.text()}`);
42
+ }
43
43
 
44
- const session = await sessionRes.json();
44
+ const session = await sessionRes.json();
45
45
 
46
- return {
47
- url: session.url,
48
- id: session.id,
49
- };
50
- }
46
+ return {
47
+ url: session.url,
48
+ id: session.id,
49
+ };
50
+ }
51
51
  }
@@ -1,98 +1,100 @@
1
- import { LuaTool, Products, User } from "lua-cli";
2
- import { z } from "zod";
1
+ import { LuaTool, Products, User } from 'lua-cli';
2
+ import { z } from 'zod';
3
3
 
4
4
  /**
5
5
  * Example tool with a condition.
6
- *
6
+ *
7
7
  * The `condition` function determines if this tool should be available to the LLM.
8
8
  * It runs BEFORE the tool is offered, so the LLM won't see this tool if condition returns false.
9
- *
9
+ *
10
10
  * Use cases:
11
11
  * - Premium/paid features only for subscribed users
12
12
  * - Features based on user verification status
13
13
  * - Region-specific tools
14
14
  * - A/B testing tool availability
15
15
  * - Time-based feature access
16
- *
16
+ *
17
17
  * The condition has access to all Platform APIs: User, Data, Products, Baskets, Orders, etc.
18
18
  */
19
19
  export default class PremiumFeatureTool implements LuaTool {
20
- name = "premium_advanced_search";
21
- description = "Advanced search with filters and sorting - available to premium users only";
22
-
23
- inputSchema = z.object({
24
- query: z.string().describe("Search query"),
25
- filters: z.object({
26
- category: z.string().optional().describe("Filter by category"),
27
- minPrice: z.number().optional().describe("Minimum price filter"),
28
- maxPrice: z.number().optional().describe("Maximum price filter"),
29
- }).optional().describe("Optional filters"),
30
- sortBy: z.enum(["relevance", "price_asc", "price_desc", "newest"]).optional().describe("Sort order")
31
- });
20
+ name = 'premium_advanced_search';
21
+ description = 'Advanced search with filters and sorting - available to premium users only';
32
22
 
33
- /**
34
- * Condition function - determines if this tool should be available.
35
- *
36
- * This runs once per request when tools are being built.
37
- * Return true to enable the tool, false to hide it from the LLM.
38
- *
39
- * If condition throws an error, the tool is disabled (fail-closed behavior).
40
- */
41
- condition = async () => {
42
- // Get the current user's data
43
- const user = await User.get();
44
-
45
- // Check if user has premium subscription
46
- // The 'data' field contains custom user data stored via User.update()
47
- const isPremium = user.data?.subscription === "premium" || user.data?.isPremium === true;
48
-
49
- // You can also check other conditions:
50
- // - user.data?.trialEndsAt > Date.now() (trial period)
51
- // - user.country?.code === "US" (region-based)
52
- // - user.data?.featureFlags?.advancedSearch (feature flags)
53
-
54
- return isPremium;
55
- };
23
+ inputSchema = z.object({
24
+ query: z.string().describe('Search query'),
25
+ filters: z
26
+ .object({
27
+ category: z.string().optional().describe('Filter by category'),
28
+ minPrice: z.number().optional().describe('Minimum price filter'),
29
+ maxPrice: z.number().optional().describe('Maximum price filter'),
30
+ })
31
+ .optional()
32
+ .describe('Optional filters'),
33
+ sortBy: z.enum(['relevance', 'price_asc', 'price_desc']).optional().describe('Sort order'),
34
+ });
35
+
36
+ /**
37
+ * Condition function - determines if this tool should be available.
38
+ *
39
+ * This runs once per request when tools are being built.
40
+ * Return true to enable the tool, false to hide it from the LLM.
41
+ *
42
+ * If condition throws an error, the tool is disabled (fail-closed behavior).
43
+ */
44
+ condition = async () => {
45
+ // Get the current user's data (returns null when called outside a conversation)
46
+ const user = await User.get();
47
+ if (!user) return false;
48
+
49
+ // Check if user has premium subscription
50
+ // The 'data' field contains custom user data stored via User.update()
51
+ const isPremium = user.data?.subscription === 'premium' || user.data?.isPremium === true;
52
+
53
+ // You can also check other conditions:
54
+ // - user.data?.trialEndsAt > Date.now() (trial period)
55
+ // - user.country?.code === "US" (region-based)
56
+ // - user.data?.featureFlags?.advancedSearch (feature flags)
57
+
58
+ return isPremium;
59
+ };
60
+
61
+ async execute(input: z.infer<typeof this.inputSchema>) {
62
+ // This only runs if condition returned true
63
+ const { query, filters, sortBy } = input;
64
+
65
+ // Products.search(query) — returns ProductSearchInstance (iterable, has .products)
66
+ const searchResult = await Products.search(query);
67
+ const products = searchResult.products;
56
68
 
57
- async execute(input: z.infer<typeof this.inputSchema>) {
58
- // This only runs if condition returned true
59
- const { query, filters, sortBy } = input;
60
-
61
- // Example: Search products with advanced filters
62
- const searchOptions: any = {
63
- query,
64
- limit: 20,
65
- };
66
-
67
- if (filters?.category) {
68
- searchOptions.category = filters.category;
69
- }
70
-
71
- if (sortBy) {
72
- searchOptions.sortBy = sortBy;
73
- }
69
+ // Apply filters client-side
70
+ let filteredResults = products;
74
71
 
75
- const searchResult = await Products.search(searchOptions);
76
- const products = searchResult.products;
77
-
78
- // Apply price filters if provided
79
- let filteredResults = products;
80
- if (filters?.minPrice !== undefined || filters?.maxPrice !== undefined) {
81
- filteredResults = products.filter((product) => {
82
- const price = product.price || 0;
83
- if (filters.minPrice !== undefined && price < filters.minPrice) return false;
84
- if (filters.maxPrice !== undefined && price > filters.maxPrice) return false;
85
- return true;
86
- });
87
- }
88
-
89
- return {
90
- query,
91
- totalResults: filteredResults.length,
92
- results: filteredResults.slice(0, 10), // Return top 10
93
- appliedFilters: filters,
94
- sortedBy: sortBy || "relevance"
95
- };
72
+ if (filters?.category) {
73
+ filteredResults = filteredResults.filter((p) => p.category === filters.category);
74
+ }
75
+
76
+ if (filters?.minPrice !== undefined || filters?.maxPrice !== undefined) {
77
+ filteredResults = filteredResults.filter((product) => {
78
+ const price = product.price || 0;
79
+ if (filters.minPrice !== undefined && price < filters.minPrice) return false;
80
+ if (filters.maxPrice !== undefined && price > filters.maxPrice) return false;
81
+ return true;
82
+ });
96
83
  }
97
- }
98
84
 
85
+ // Sort client-side when requested
86
+ if (sortBy === 'price_asc') {
87
+ filteredResults = [...filteredResults].sort((a, b) => (a.price || 0) - (b.price || 0));
88
+ } else if (sortBy === 'price_desc') {
89
+ filteredResults = [...filteredResults].sort((a, b) => (b.price || 0) - (a.price || 0));
90
+ }
91
+
92
+ return {
93
+ query,
94
+ totalResults: filteredResults.length,
95
+ results: filteredResults.slice(0, 10), // Return top 10
96
+ appliedFilters: filters,
97
+ sortedBy: sortBy || 'relevance',
98
+ };
99
+ }
100
+ }