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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/README.md +137 -689
  2. package/dist/api/agent.api.service.d.ts +1 -8
  3. package/dist/api/agent.api.service.js +1 -11
  4. package/dist/api/agent.api.service.js.map +1 -1
  5. package/dist/api/auth.api.service.d.ts +1 -1
  6. package/dist/api/auth.api.service.js +1 -1
  7. package/dist/api/auth.api.service.js.map +1 -1
  8. package/dist/api/backup.api.service.d.ts +80 -0
  9. package/dist/api/backup.api.service.js +101 -0
  10. package/dist/api/backup.api.service.js.map +1 -0
  11. package/dist/api/basket.api.service.d.ts +4 -5
  12. package/dist/api/basket.api.service.js +13 -18
  13. package/dist/api/basket.api.service.js.map +1 -1
  14. package/dist/api/cdn.api.service.d.ts +2 -0
  15. package/dist/api/cdn.api.service.js +2 -0
  16. package/dist/api/cdn.api.service.js.map +1 -1
  17. package/dist/api/chat.api.service.d.ts +10 -2
  18. package/dist/api/chat.api.service.js +21 -2
  19. package/dist/api/chat.api.service.js.map +1 -1
  20. package/dist/api/credentials.js +5 -8
  21. package/dist/api/credentials.js.map +1 -1
  22. package/dist/api/custom.data.api.service.d.ts +3 -3
  23. package/dist/api/custom.data.api.service.js +9 -10
  24. package/dist/api/custom.data.api.service.js.map +1 -1
  25. package/dist/api/developer.api.service.d.ts +1 -1
  26. package/dist/api/developer.api.service.js +1 -1
  27. package/dist/api/developer.api.service.js.map +1 -1
  28. package/dist/api/http.client.js.map +1 -0
  29. package/dist/api/job.api.service.d.ts +2 -2
  30. package/dist/api/job.api.service.js +2 -2
  31. package/dist/api/job.api.service.js.map +1 -1
  32. package/dist/api/logs.api.service.d.ts +1 -1
  33. package/dist/api/logs.api.service.js +1 -1
  34. package/dist/api/logs.api.service.js.map +1 -1
  35. package/dist/api/marketplace.api.service.d.ts +6 -6
  36. package/dist/api/marketplace.api.service.js.map +1 -1
  37. package/dist/api/order.api.service.d.ts +3 -4
  38. package/dist/api/order.api.service.js +8 -10
  39. package/dist/api/order.api.service.js.map +1 -1
  40. package/dist/api/persona.api.service.d.ts +1 -1
  41. package/dist/api/persona.api.service.js +1 -1
  42. package/dist/api/persona.api.service.js.map +1 -1
  43. package/dist/api/postprocessor.api.service.d.ts +1 -1
  44. package/dist/api/postprocessor.api.service.js +1 -1
  45. package/dist/api/postprocessor.api.service.js.map +1 -1
  46. package/dist/api/preprocessor.api.service.d.ts +1 -1
  47. package/dist/api/preprocessor.api.service.js +1 -1
  48. package/dist/api/preprocessor.api.service.js.map +1 -1
  49. package/dist/api/products.api.service.d.ts +4 -4
  50. package/dist/api/products.api.service.js +6 -6
  51. package/dist/api/products.api.service.js.map +1 -1
  52. package/dist/api/resource.api.service.d.ts +76 -0
  53. package/dist/api/resource.api.service.js +74 -0
  54. package/dist/api/resource.api.service.js.map +1 -0
  55. package/dist/api/skills.api.service.d.ts +7 -15
  56. package/dist/api/skills.api.service.js +1 -1
  57. package/dist/api/skills.api.service.js.map +1 -1
  58. package/dist/api/tool.api.service.d.ts +1 -1
  59. package/dist/api/tool.api.service.js +1 -1
  60. package/dist/api/tool.api.service.js.map +1 -1
  61. package/dist/api/unifiedto.api.service.d.ts +1 -1
  62. package/dist/api/unifiedto.api.service.js +1 -1
  63. package/dist/api/unifiedto.api.service.js.map +1 -1
  64. package/dist/api/user.data.api.service.d.ts +7 -8
  65. package/dist/api/user.data.api.service.js +2 -3
  66. package/dist/api/user.data.api.service.js.map +1 -1
  67. package/dist/api/webhook.api.service.d.ts +1 -1
  68. package/dist/api/webhook.api.service.js +1 -1
  69. package/dist/api/webhook.api.service.js.map +1 -1
  70. package/dist/api/whatsapp-templates.api.service.d.ts +1 -1
  71. package/dist/api/whatsapp-templates.api.service.js +1 -1
  72. package/dist/api/whatsapp-templates.api.service.js.map +1 -1
  73. package/dist/api-exports.d.ts +14 -12
  74. package/dist/api-exports.js +8 -8
  75. package/dist/api-exports.js.map +1 -1
  76. package/dist/cli/command-definitions.js +32 -17
  77. package/dist/cli/command-definitions.js.map +1 -1
  78. package/dist/commands/admin.js +3 -24
  79. package/dist/commands/admin.js.map +1 -1
  80. package/dist/commands/agents.d.ts +8 -7
  81. package/dist/commands/agents.js +63 -21
  82. package/dist/commands/agents.js.map +1 -1
  83. package/dist/commands/channels.js +11 -23
  84. package/dist/commands/channels.js.map +1 -1
  85. package/dist/commands/chat.js +33 -47
  86. package/dist/commands/chat.js.map +1 -1
  87. package/dist/commands/chatClear.js +11 -41
  88. package/dist/commands/chatClear.js.map +1 -1
  89. package/dist/commands/compile.d.ts +26 -23
  90. package/dist/commands/compile.js +98 -403
  91. package/dist/commands/compile.js.map +1 -1
  92. package/dist/commands/completion.js +1 -1
  93. package/dist/commands/completion.js.map +1 -1
  94. package/dist/commands/deploy.js +55 -25
  95. package/dist/commands/deploy.js.map +1 -1
  96. package/dist/commands/dev.js +29 -45
  97. package/dist/commands/dev.js.map +1 -1
  98. package/dist/commands/env.js +12 -25
  99. package/dist/commands/env.js.map +1 -1
  100. package/dist/commands/evals.js +3 -20
  101. package/dist/commands/evals.js.map +1 -1
  102. package/dist/commands/features.js +10 -23
  103. package/dist/commands/features.js.map +1 -1
  104. package/dist/commands/index.d.ts +1 -0
  105. package/dist/commands/index.js +1 -0
  106. package/dist/commands/index.js.map +1 -1
  107. package/dist/commands/init.d.ts +1 -0
  108. package/dist/commands/init.js +135 -19
  109. package/dist/commands/init.js.map +1 -1
  110. package/dist/commands/integrations.js +26 -37
  111. package/dist/commands/integrations.js.map +1 -1
  112. package/dist/commands/jobs.js +32 -56
  113. package/dist/commands/jobs.js.map +1 -1
  114. package/dist/commands/logs.js +9 -20
  115. package/dist/commands/logs.js.map +1 -1
  116. package/dist/commands/marketplace.js +34 -52
  117. package/dist/commands/marketplace.js.map +1 -1
  118. package/dist/commands/mcp.js +10 -23
  119. package/dist/commands/mcp.js.map +1 -1
  120. package/dist/commands/persona.js +43 -74
  121. package/dist/commands/persona.js.map +1 -1
  122. package/dist/commands/postprocessors.js +15 -28
  123. package/dist/commands/postprocessors.js.map +1 -1
  124. package/dist/commands/preprocessors.js +15 -28
  125. package/dist/commands/preprocessors.js.map +1 -1
  126. package/dist/commands/production.js +30 -63
  127. package/dist/commands/production.js.map +1 -1
  128. package/dist/commands/push.js +294 -1241
  129. package/dist/commands/push.js.map +1 -1
  130. package/dist/commands/pushBackup.d.ts +22 -0
  131. package/dist/commands/pushBackup.js +133 -0
  132. package/dist/commands/pushBackup.js.map +1 -0
  133. package/dist/commands/resources.js +29 -72
  134. package/dist/commands/resources.js.map +1 -1
  135. package/dist/commands/skills.d.ts +1 -1
  136. package/dist/commands/skills.js +58 -70
  137. package/dist/commands/skills.js.map +1 -1
  138. package/dist/commands/sync.d.ts +1 -3
  139. package/dist/commands/sync.js +12 -24
  140. package/dist/commands/sync.js.map +1 -1
  141. package/dist/commands/test.js +135 -104
  142. package/dist/commands/test.js.map +1 -1
  143. package/dist/commands/webhooks.js +15 -28
  144. package/dist/commands/webhooks.js.map +1 -1
  145. package/dist/compiler/agent-traverser.d.ts +104 -0
  146. package/dist/compiler/agent-traverser.js +311 -0
  147. package/dist/compiler/agent-traverser.js.map +1 -0
  148. package/dist/compiler/bundler.d.ts +42 -0
  149. package/dist/compiler/bundler.js +187 -0
  150. package/dist/compiler/bundler.js.map +1 -0
  151. package/dist/compiler/compiler.d.ts +177 -0
  152. package/dist/compiler/compiler.js +580 -0
  153. package/dist/compiler/compiler.js.map +1 -0
  154. package/dist/compiler/index.d.ts +36 -0
  155. package/dist/compiler/index.js +42 -0
  156. package/dist/compiler/index.js.map +1 -0
  157. package/dist/compiler/plugins/base.d.ts +264 -0
  158. package/dist/compiler/plugins/base.js +307 -0
  159. package/dist/compiler/plugins/base.js.map +1 -0
  160. package/dist/compiler/plugins/job.plugin.d.ts +33 -0
  161. package/dist/compiler/plugins/job.plugin.js +143 -0
  162. package/dist/compiler/plugins/job.plugin.js.map +1 -0
  163. package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
  164. package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
  165. package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
  166. package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
  167. package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
  168. package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
  169. package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
  170. package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
  171. package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
  172. package/dist/compiler/plugins/processor-base.d.ts +16 -0
  173. package/dist/compiler/plugins/processor-base.js +34 -0
  174. package/dist/compiler/plugins/processor-base.js.map +1 -0
  175. package/dist/compiler/plugins/registry.d.ts +61 -0
  176. package/dist/compiler/plugins/registry.js +107 -0
  177. package/dist/compiler/plugins/registry.js.map +1 -0
  178. package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
  179. package/dist/compiler/plugins/skill.plugin.js +243 -0
  180. package/dist/compiler/plugins/skill.plugin.js.map +1 -0
  181. package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
  182. package/dist/compiler/plugins/tool.plugin.js +279 -0
  183. package/dist/compiler/plugins/tool.plugin.js.map +1 -0
  184. package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
  185. package/dist/compiler/plugins/webhook.plugin.js +127 -0
  186. package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
  187. package/dist/compiler/source-writer.d.ts +98 -0
  188. package/dist/compiler/source-writer.js +223 -0
  189. package/dist/compiler/source-writer.js.map +1 -0
  190. package/dist/compiler/types.d.ts +289 -0
  191. package/dist/compiler/types.js +20 -0
  192. package/dist/compiler/types.js.map +1 -0
  193. package/dist/compiler/utils/ast-helpers.d.ts +57 -0
  194. package/dist/compiler/utils/ast-helpers.js +164 -0
  195. package/dist/compiler/utils/ast-helpers.js.map +1 -0
  196. package/dist/compiler/utils/common.d.ts +23 -0
  197. package/dist/compiler/utils/common.js +66 -0
  198. package/dist/compiler/utils/common.js.map +1 -0
  199. package/dist/compiler/utils/file-discovery.d.ts +34 -0
  200. package/dist/compiler/utils/file-discovery.js +68 -0
  201. package/dist/compiler/utils/file-discovery.js.map +1 -0
  202. package/dist/compiler/utils/path-resolver.d.ts +25 -0
  203. package/dist/compiler/utils/path-resolver.js +66 -0
  204. package/dist/compiler/utils/path-resolver.js.map +1 -0
  205. package/dist/compiler/utils/schema-converter.d.ts +26 -0
  206. package/dist/compiler/utils/schema-converter.js +94 -0
  207. package/dist/compiler/utils/schema-converter.js.map +1 -0
  208. package/dist/config/compile.constants.d.ts +2 -22
  209. package/dist/config/compile.constants.js +2 -49
  210. package/dist/config/compile.constants.js.map +1 -1
  211. package/dist/config/constants.d.ts +18 -2
  212. package/dist/config/constants.js +28 -8
  213. package/dist/config/constants.js.map +1 -1
  214. package/dist/config/dev.constants.d.ts +0 -10
  215. package/dist/config/dev.constants.js +0 -10
  216. package/dist/config/dev.constants.js.map +1 -1
  217. package/dist/index.js +7 -0
  218. package/dist/index.js.map +1 -1
  219. package/dist/instances/basket.instance.js.map +1 -0
  220. package/dist/instances/data.entry.instance.js.map +1 -0
  221. package/dist/instances/job.instance.js.map +1 -0
  222. package/dist/instances/order.instance.js.map +1 -0
  223. package/dist/instances/product.instance.js.map +1 -0
  224. package/dist/instances/product.pagination.instance.js.map +1 -0
  225. package/dist/instances/product.search.instance.js.map +1 -0
  226. package/dist/instances/user.instance.js.map +1 -0
  227. package/dist/interfaces/admin.d.ts +0 -38
  228. package/dist/interfaces/backup.d.ts +125 -0
  229. package/dist/interfaces/backup.js +8 -0
  230. package/dist/interfaces/backup.js.map +1 -0
  231. package/dist/interfaces/baskets.d.ts +0 -56
  232. package/dist/interfaces/common.d.ts +1 -0
  233. package/dist/interfaces/deploy.d.ts +0 -15
  234. package/dist/interfaces/index.d.ts +1 -1
  235. package/dist/interfaces/marketplace.d.ts +51 -0
  236. package/dist/interfaces/marketplace.js +1 -1
  237. package/dist/interfaces/marketplace.js.map +1 -1
  238. package/dist/interfaces/message.d.ts +0 -3
  239. package/dist/interfaces/orders.d.ts +0 -24
  240. package/dist/interfaces/postprocessors.d.ts +0 -18
  241. package/dist/interfaces/preprocessors.d.ts +0 -18
  242. package/dist/interfaces/skills.d.ts +61 -0
  243. package/dist/interfaces/user.d.ts +25 -0
  244. package/dist/interfaces/webhooks.d.ts +0 -9
  245. package/dist/primitives/base.handler.d.ts +106 -0
  246. package/dist/primitives/base.handler.js +370 -0
  247. package/dist/primitives/base.handler.js.map +1 -0
  248. package/dist/primitives/index.d.ts +47 -0
  249. package/dist/primitives/index.js +78 -0
  250. package/dist/primitives/index.js.map +1 -0
  251. package/dist/primitives/job.handler.d.ts +52 -0
  252. package/dist/primitives/job.handler.js +118 -0
  253. package/dist/primitives/job.handler.js.map +1 -0
  254. package/dist/primitives/mcp-server.handler.d.ts +54 -0
  255. package/dist/primitives/mcp-server.handler.js +91 -0
  256. package/dist/primitives/mcp-server.handler.js.map +1 -0
  257. package/dist/primitives/postprocessor.handler.d.ts +49 -0
  258. package/dist/primitives/postprocessor.handler.js +81 -0
  259. package/dist/primitives/postprocessor.handler.js.map +1 -0
  260. package/dist/primitives/preprocessor.handler.d.ts +54 -0
  261. package/dist/primitives/preprocessor.handler.js +95 -0
  262. package/dist/primitives/preprocessor.handler.js.map +1 -0
  263. package/dist/primitives/skill.handler.d.ts +44 -0
  264. package/dist/primitives/skill.handler.js +192 -0
  265. package/dist/primitives/skill.handler.js.map +1 -0
  266. package/dist/primitives/types.d.ts +72 -0
  267. package/dist/primitives/types.js +17 -0
  268. package/dist/primitives/types.js.map +1 -0
  269. package/dist/primitives/webhook.handler.d.ts +50 -0
  270. package/dist/primitives/webhook.handler.js +96 -0
  271. package/dist/primitives/webhook.handler.js.map +1 -0
  272. package/dist/services/auth.js +1 -2
  273. package/dist/services/auth.js.map +1 -1
  274. package/dist/services/sandbox.service.d.ts +103 -0
  275. package/dist/services/sandbox.service.js +479 -0
  276. package/dist/services/sandbox.service.js.map +1 -0
  277. package/dist/types/api-contracts.d.ts +1 -1
  278. package/dist/types/index.d.ts +2 -1
  279. package/dist/types/index.js.map +1 -1
  280. package/dist/types/skill.d.ts +8 -2
  281. package/dist/types/skill.js +8 -0
  282. package/dist/types/skill.js.map +1 -1
  283. package/dist/types/yaml.types.d.ts +69 -0
  284. package/dist/types/yaml.types.js +6 -0
  285. package/dist/types/yaml.types.js.map +1 -0
  286. package/dist/utils/artifact-loader.d.ts +108 -0
  287. package/dist/utils/artifact-loader.js +188 -0
  288. package/dist/utils/artifact-loader.js.map +1 -0
  289. package/dist/utils/backup-helpers.d.ts +122 -0
  290. package/dist/utils/backup-helpers.js +274 -0
  291. package/dist/utils/backup-helpers.js.map +1 -0
  292. package/dist/utils/cli.d.ts +8 -0
  293. package/dist/utils/cli.js +19 -2
  294. package/dist/utils/cli.js.map +1 -1
  295. package/dist/utils/command-utils.d.ts +42 -0
  296. package/dist/utils/command-utils.js +83 -0
  297. package/dist/utils/command-utils.js.map +1 -0
  298. package/dist/utils/deploy-helpers.d.ts +0 -29
  299. package/dist/utils/deploy-helpers.js +0 -70
  300. package/dist/utils/deploy-helpers.js.map +1 -1
  301. package/dist/utils/dev-api.d.ts +3 -99
  302. package/dist/utils/dev-api.js +3 -430
  303. package/dist/utils/dev-api.js.map +1 -1
  304. package/dist/utils/dev-server.d.ts +3 -1
  305. package/dist/utils/dev-server.js +69 -145
  306. package/dist/utils/dev-server.js.map +1 -1
  307. package/dist/utils/dev-watcher.d.ts +0 -1
  308. package/dist/utils/dev-watcher.js +23 -8
  309. package/dist/utils/dev-watcher.js.map +1 -1
  310. package/dist/utils/env-loader.utils.d.ts +10 -1
  311. package/dist/utils/env-loader.utils.js +39 -31
  312. package/dist/utils/env-loader.utils.js.map +1 -1
  313. package/dist/utils/files.d.ts +47 -3
  314. package/dist/utils/files.js +98 -40
  315. package/dist/utils/files.js.map +1 -1
  316. package/dist/utils/init-agent.js +1 -2
  317. package/dist/utils/init-agent.js.map +1 -1
  318. package/dist/utils/init-helpers.d.ts +2 -10
  319. package/dist/utils/init-helpers.js +9 -17
  320. package/dist/utils/init-helpers.js.map +1 -1
  321. package/dist/utils/init-prompts.d.ts +0 -8
  322. package/dist/utils/init-prompts.js +0 -22
  323. package/dist/utils/init-prompts.js.map +1 -1
  324. package/dist/utils/prompt-handler.d.ts +3 -0
  325. package/dist/utils/prompt-handler.js +13 -0
  326. package/dist/utils/prompt-handler.js.map +1 -1
  327. package/dist/utils/sandbox-storage.d.ts +6 -5
  328. package/dist/utils/sandbox-storage.js +12 -12
  329. package/dist/utils/sandbox-storage.js.map +1 -1
  330. package/dist/utils/sandbox.d.ts +7 -30
  331. package/dist/utils/sandbox.js +247 -223
  332. package/dist/utils/sandbox.js.map +1 -1
  333. package/dist/utils/semver.d.ts +12 -0
  334. package/dist/utils/semver.js +23 -0
  335. package/dist/utils/semver.js.map +1 -1
  336. package/dist/utils/sync-display.d.ts +9 -0
  337. package/dist/utils/sync-display.js +67 -0
  338. package/dist/utils/sync-display.js.map +1 -0
  339. package/dist/utils/sync-fetch.d.ts +23 -0
  340. package/dist/utils/sync-fetch.js +64 -0
  341. package/dist/utils/sync-fetch.js.map +1 -0
  342. package/dist/utils/sync-helpers.d.ts +4 -59
  343. package/dist/utils/sync-helpers.js +4 -206
  344. package/dist/utils/sync-helpers.js.map +1 -1
  345. package/dist/web/app.css +912 -186
  346. package/dist/web/app.js +46 -46
  347. package/docs/API_INDEX.md +100 -0
  348. package/docs/API_REFERENCE.md +773 -0
  349. package/docs/CLI_REFERENCE.md +924 -0
  350. package/docs/GETTING_STARTED.md +862 -0
  351. package/docs/README.md +270 -0
  352. package/docs/api/AI.md +882 -0
  353. package/docs/api/Baskets.md +511 -0
  354. package/docs/api/CDN.md +524 -0
  355. package/docs/api/Data.md +446 -0
  356. package/docs/api/Jobs.md +524 -0
  357. package/docs/api/LuaAgent.md +454 -0
  358. package/docs/api/LuaJob.md +604 -0
  359. package/docs/api/LuaSkill.md +396 -0
  360. package/docs/api/LuaTool.md +521 -0
  361. package/docs/api/LuaWebhook.md +601 -0
  362. package/docs/api/Orders.md +514 -0
  363. package/docs/api/PostProcessor.md +565 -0
  364. package/docs/api/PreProcessor.md +630 -0
  365. package/docs/api/Products.md +507 -0
  366. package/docs/api/Templates.md +662 -0
  367. package/docs/api/User.md +567 -0
  368. package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
  369. package/docs/compiler-v2/ASSESSMENT.md +205 -0
  370. package/docs/compiler-v2/TEST_PLAN.md +306 -0
  371. package/package.json +3 -7
  372. package/template/tsconfig.json +1 -1
  373. package/dist/common/basket.instance.js.map +0 -1
  374. package/dist/common/data.entry.instance.js.map +0 -1
  375. package/dist/common/http.client.js.map +0 -1
  376. package/dist/common/job.instance.js.map +0 -1
  377. package/dist/common/order.instance.js.map +0 -1
  378. package/dist/common/product.instance.js.map +0 -1
  379. package/dist/common/product.pagination.instance.js.map +0 -1
  380. package/dist/common/product.search.instance.js.map +0 -1
  381. package/dist/common/user.instance.js.map +0 -1
  382. package/dist/config/auth.constants.d.ts +0 -11
  383. package/dist/config/auth.constants.js +0 -12
  384. package/dist/config/auth.constants.js.map +0 -1
  385. package/dist/config/init.constants.d.ts +0 -15
  386. package/dist/config/init.constants.js +0 -20
  387. package/dist/config/init.constants.js.map +0 -1
  388. package/dist/interfaces/compile.d.ts +0 -12
  389. package/dist/interfaces/compile.js +0 -5
  390. package/dist/interfaces/compile.js.map +0 -1
  391. package/dist/types/compile.types.d.ts +0 -131
  392. package/dist/types/compile.types.js +0 -6
  393. package/dist/types/compile.types.js.map +0 -1
  394. package/dist/utils/agent-code-utils.d.ts +0 -25
  395. package/dist/utils/agent-code-utils.js +0 -107
  396. package/dist/utils/agent-code-utils.js.map +0 -1
  397. package/dist/utils/bundling.d.ts +0 -89
  398. package/dist/utils/bundling.js +0 -1068
  399. package/dist/utils/bundling.js.map +0 -1
  400. package/dist/utils/compile.d.ts +0 -116
  401. package/dist/utils/compile.js +0 -1062
  402. package/dist/utils/compile.js.map +0 -1
  403. package/dist/utils/deploy-api.d.ts +0 -26
  404. package/dist/utils/deploy-api.js +0 -54
  405. package/dist/utils/deploy-api.js.map +0 -1
  406. package/dist/utils/deployment.d.ts +0 -26
  407. package/dist/utils/deployment.js +0 -218
  408. package/dist/utils/deployment.js.map +0 -1
  409. package/dist/utils/dev-helpers.d.ts +0 -47
  410. package/dist/utils/dev-helpers.js +0 -82
  411. package/dist/utils/dev-helpers.js.map +0 -1
  412. package/dist/utils/job-management.d.ts +0 -27
  413. package/dist/utils/job-management.js +0 -248
  414. package/dist/utils/job-management.js.map +0 -1
  415. package/dist/utils/mcp-server-management.d.ts +0 -26
  416. package/dist/utils/mcp-server-management.js +0 -197
  417. package/dist/utils/mcp-server-management.js.map +0 -1
  418. package/dist/utils/postprocessor-management.d.ts +0 -9
  419. package/dist/utils/postprocessor-management.js +0 -117
  420. package/dist/utils/postprocessor-management.js.map +0 -1
  421. package/dist/utils/pre-bundle-jobs.d.ts +0 -27
  422. package/dist/utils/pre-bundle-jobs.js +0 -189
  423. package/dist/utils/pre-bundle-jobs.js.map +0 -1
  424. package/dist/utils/preprocessor-management.d.ts +0 -9
  425. package/dist/utils/preprocessor-management.js +0 -117
  426. package/dist/utils/preprocessor-management.js.map +0 -1
  427. package/dist/utils/push-api.d.ts +0 -15
  428. package/dist/utils/push-api.js +0 -49
  429. package/dist/utils/push-api.js.map +0 -1
  430. package/dist/utils/push-helpers.d.ts +0 -82
  431. package/dist/utils/push-helpers.js +0 -246
  432. package/dist/utils/push-helpers.js.map +0 -1
  433. package/dist/utils/skill-management.d.ts +0 -39
  434. package/dist/utils/skill-management.js +0 -299
  435. package/dist/utils/skill-management.js.map +0 -1
  436. package/dist/utils/test-helpers.d.ts +0 -33
  437. package/dist/utils/test-helpers.js +0 -84
  438. package/dist/utils/test-helpers.js.map +0 -1
  439. package/dist/utils/test-prompts.d.ts +0 -23
  440. package/dist/utils/test-prompts.js +0 -187
  441. package/dist/utils/test-prompts.js.map +0 -1
  442. package/dist/utils/tool-detection.d.ts +0 -19
  443. package/dist/utils/tool-detection.js +0 -125
  444. package/dist/utils/tool-detection.js.map +0 -1
  445. package/dist/utils/webhook-management.d.ts +0 -27
  446. package/dist/utils/webhook-management.js +0 -241
  447. package/dist/utils/webhook-management.js.map +0 -1
  448. /package/dist/{common → api}/http.client.d.ts +0 -0
  449. /package/dist/{common → api}/http.client.js +0 -0
  450. /package/dist/{common → instances}/basket.instance.d.ts +0 -0
  451. /package/dist/{common → instances}/basket.instance.js +0 -0
  452. /package/dist/{common → instances}/data.entry.instance.d.ts +0 -0
  453. /package/dist/{common → instances}/data.entry.instance.js +0 -0
  454. /package/dist/{common → instances}/job.instance.d.ts +0 -0
  455. /package/dist/{common → instances}/job.instance.js +0 -0
  456. /package/dist/{common → instances}/order.instance.d.ts +0 -0
  457. /package/dist/{common → instances}/order.instance.js +0 -0
  458. /package/dist/{common → instances}/product.instance.d.ts +0 -0
  459. /package/dist/{common → instances}/product.instance.js +0 -0
  460. /package/dist/{common → instances}/product.pagination.instance.d.ts +0 -0
  461. /package/dist/{common → instances}/product.pagination.instance.js +0 -0
  462. /package/dist/{common → instances}/product.search.instance.d.ts +0 -0
  463. /package/dist/{common → instances}/product.search.instance.js +0 -0
  464. /package/dist/{common → instances}/user.instance.d.ts +0 -0
  465. /package/dist/{common → instances}/user.instance.js +0 -0
@@ -1,1068 +0,0 @@
1
- /**
2
- * Bundling Utilities
3
- * Handles esbuild bundling of tools and main index
4
- */
5
- import fs from "fs";
6
- import path from "path";
7
- import { build } from "esbuild";
8
- import { Project, Node } from "ts-morph";
9
- import { writeProgress } from "./cli.js";
10
- import { COMPILE_DIRS, COMPILE_FILES, ESBUILD_TOOL_CONFIG, ESBUILD_INDEX_CONFIG, DEFAULT_INPUT_SCHEMA, EXTERNAL_PACKAGES, } from '../config/compile.constants.js';
11
- import { wrapExecuteForVM, wrapConditionForVM, evaluateZodSchemaToJsonSchema } from './compile.js';
12
- import { evaluate } from 'ts-evaluator';
13
- import ts from 'typescript';
14
- /**
15
- * Helper function to remove lua-cli and api-exports imports from source code.
16
- * Used when bundling via stdin or temp files where the plugin can't process them.
17
- */
18
- function stripLuaCliImports(sourceCode) {
19
- return sourceCode
20
- // Remove api-exports imports
21
- .replace(/import\s+{([^}]+)}\s+from\s+["'][^"']*api-exports["'];?/g, '// api-exports imports removed - using sandbox globals')
22
- // Remove lua-cli imports
23
- .replace(/import\s+{([^}]+)}\s+from\s+["']lua-cli["'];?/g, '// lua-cli imports removed - using sandbox globals')
24
- // Remove lua-cli/skill imports (but keep LuaTool, etc. for type checking in temp files)
25
- .replace(/import\s+{([^}]+)}\s+from\s+["']lua-cli\/skill["'];?/g, (match, imports) => {
26
- // Keep only LuaTool, LuaWebhook, LuaJob types for temp files
27
- const typeImports = imports.split(',')
28
- .map((imp) => imp.trim())
29
- .filter((imp) => /^(LuaTool|LuaWebhook|LuaJob|LuaPreProcessor|LuaPostProcessor)$/.test(imp));
30
- return typeImports.length > 0
31
- ? `// lua-cli/skill imports removed - using sandbox globals (types kept for compilation)`
32
- : '// lua-cli/skill imports removed - using sandbox globals';
33
- });
34
- }
35
- /**
36
- * Extracts and filters relevant imports from source code.
37
- * Removes lua-cli internal classes and API imports that are available in the sandbox.
38
- *
39
- * @param sourceFilePath - Path to the source file
40
- * @returns Array of relevant import statements
41
- */
42
- function extractRelevantImports(sourceFilePath) {
43
- const sourceContent = fs.readFileSync(sourceFilePath, 'utf8');
44
- // Extract all import statements from the source
45
- const importPattern = /^import\s+.+\s+from\s+['"][^'"]+['"];?$/gm;
46
- const imports = sourceContent.match(importPattern) || [];
47
- // Filter to only imports that might be used (exclude lua-cli internal classes and APIs)
48
- return imports.filter(imp => !imp.includes('LuaTool') &&
49
- !imp.includes('LuaWebhook') &&
50
- !imp.includes('LuaJob') &&
51
- !imp.includes('PreProcessor') &&
52
- !imp.includes('PostProcessor') &&
53
- !imp.includes('LuaAgent') &&
54
- !imp.includes('lua-cli') && // Exclude all lua-cli imports (they're available in sandbox)
55
- !imp.includes('api-exports') && // Exclude api-exports
56
- !imp.includes('../../../dist/api-exports') // Exclude direct api-exports imports
57
- );
58
- }
59
- /**
60
- * Generic function to bundle and compress execute function code with dependencies.
61
- *
62
- * @param executeFunction - Raw execute function code
63
- * @param componentName - Name of the component (webhook/job/processor)
64
- * @param componentType - Type identifier for temp files
65
- * @param vmWrapperGenerator - Function that generates the VM wrapper code
66
- * @param distDir - Distribution directory
67
- * @param sourceFilePath - Path to source file containing the component
68
- * @param debugMode - Enable verbose logging and preserve temp files
69
- * @returns Compressed base64-encoded bundled code
70
- */
71
- async function bundleAndCompressExecuteFunction(executeFunction, componentName, componentType, vmWrapperGenerator, distDir, sourceFilePath, debugMode) {
72
- const { compressCode } = await import('./compile.js');
73
- // Create temporary file with the execute function wrapped as a module
74
- const tempDir = path.join(distDir, '.temp');
75
- if (!fs.existsSync(tempDir)) {
76
- fs.mkdirSync(tempDir, { recursive: true });
77
- }
78
- const tempFile = path.join(tempDir, `${componentName}-${componentType}.ts`);
79
- const tempOutput = path.join(tempDir, `${componentName}-${componentType}.js`);
80
- let moduleCode = ''; // Declare outside try block for debug mode access
81
- try {
82
- // Extract relevant imports from source file
83
- const relevantImports = extractRelevantImports(sourceFilePath);
84
- if (debugMode) {
85
- console.log(` → Found ${relevantImports.length} import(s) to bundle`);
86
- if (relevantImports.length > 0 && debugMode) {
87
- relevantImports.forEach(imp => console.log(` - ${imp}`));
88
- }
89
- }
90
- // Write execute function as a module export with all relevant imports
91
- moduleCode = `
92
- // ${componentType} execute function for ${componentName}
93
- ${relevantImports.join('\n')}
94
-
95
- // The execute function with all dependencies available
96
- const executeFunc = ${executeFunction};
97
-
98
- export default executeFunc;
99
- `;
100
- if (debugMode) {
101
- console.log(` → Using stdin bundling to preserve import resolution`);
102
- }
103
- // Bundle with esbuild using stdin to preserve import resolution
104
- // This ensures relative imports resolve correctly from the original source file location
105
- await build({
106
- stdin: {
107
- contents: moduleCode,
108
- resolveDir: path.dirname(sourceFilePath), // Resolve imports from source file's directory
109
- sourcefile: sourceFilePath, // Pretend we're the source file for better error messages
110
- loader: 'ts',
111
- },
112
- bundle: true,
113
- platform: 'node',
114
- target: 'node16',
115
- format: 'cjs',
116
- minify: true,
117
- outfile: tempOutput,
118
- external: [...EXTERNAL_PACKAGES], // Use same external packages as tools
119
- plugins: [sandboxGlobalsPlugin],
120
- });
121
- // Read bundled code and validate it exists and has content
122
- if (!fs.existsSync(tempOutput)) {
123
- throw new Error(`esbuild failed to create output file for ${componentName}`);
124
- }
125
- const bundledCode = fs.readFileSync(tempOutput, 'utf8');
126
- if (bundledCode.length === 0) {
127
- throw new Error(`esbuild created empty bundle for ${componentName}`);
128
- }
129
- // Wrap for VM execution using provided generator
130
- const wrappedCode = vmWrapperGenerator(bundledCode);
131
- // Compress the wrapped code
132
- const compressed = compressCode(wrappedCode);
133
- if (debugMode) {
134
- console.log(` → Bundle size: ${(bundledCode.length / 1024).toFixed(2)}KB (uncompressed)`);
135
- console.log(` → Compressed: ${(compressed.length / 1024).toFixed(2)}KB (base64 gzip)`);
136
- }
137
- // Clean up temp files (unless in debug mode)
138
- if (!debugMode) {
139
- try {
140
- fs.unlinkSync(tempOutput);
141
- }
142
- catch (cleanupError) {
143
- // Ignore cleanup errors
144
- }
145
- }
146
- else {
147
- // In debug mode, write the moduleCode to tempFile for inspection
148
- fs.writeFileSync(tempFile, moduleCode);
149
- console.log(` ℹ️ Preserved temp files for debugging:`);
150
- console.log(` - ${tempFile} (source with imports)`);
151
- console.log(` - ${tempOutput} (bundled output)`);
152
- }
153
- return compressed;
154
- }
155
- catch (error) {
156
- // Provide helpful error messages based on error type
157
- let errorMessage = `Warning: Could not bundle ${componentType} ${componentName}`;
158
- if (error.message && error.message.includes('Could not resolve')) {
159
- errorMessage += `\n Dependency resolution failed: ${error.message}`;
160
- // Check if it's a relative import issue
161
- if (error.message.includes('"../') || error.message.includes('"./')) {
162
- errorMessage += `\n Hint: Relative imports detected. Consider using TypeScript path aliases (e.g., @/services/...)`;
163
- errorMessage += `\n Or ensure the import path is correct relative to: ${path.dirname(sourceFilePath)}`;
164
- }
165
- else {
166
- errorMessage += `\n Hint: Ensure all imported packages are in package.json and run 'npm install'`;
167
- }
168
- }
169
- else if (error.message && error.message.includes('Transform failed')) {
170
- errorMessage += `\n TypeScript compilation failed: ${error.message}`;
171
- errorMessage += `\n Hint: Check syntax in ${path.basename(sourceFilePath)}`;
172
- }
173
- else {
174
- errorMessage += `: ${error.message || error}`;
175
- }
176
- console.warn(errorMessage);
177
- if (debugMode && error.stack) {
178
- console.error(' Full stack trace:', error.stack);
179
- }
180
- // Clean up on error (unless in debug mode)
181
- if (!debugMode) {
182
- try {
183
- if (fs.existsSync(tempOutput))
184
- fs.unlinkSync(tempOutput);
185
- }
186
- catch (cleanupError) {
187
- // Ignore cleanup errors
188
- }
189
- }
190
- else {
191
- // In debug mode, write the moduleCode for inspection
192
- try {
193
- fs.writeFileSync(tempFile, moduleCode);
194
- console.log(` ℹ️ Temp files preserved for debugging (check dist/.temp/)`);
195
- }
196
- catch (writeError) {
197
- // Ignore write errors
198
- }
199
- }
200
- return '';
201
- }
202
- }
203
- /**
204
- * esbuild plugin to inject sandbox globals instead of requiring lua-cli
205
- * This removes require("lua-cli") statements and injects the global API objects
206
- * that are available in the sandbox (Products, User, Data, Baskets, Orders, Webhooks, Jobs)
207
- */
208
- export const sandboxGlobalsPlugin = {
209
- name: 'sandbox-globals',
210
- setup(build) {
211
- // Only process user files, not node_modules
212
- build.onLoad({ filter: /\.([jt]sx?)$/, namespace: 'file' }, async (args) => {
213
- // Skip node_modules
214
- if (args.path.includes('node_modules')) {
215
- return null;
216
- }
217
- const contents = await fs.promises.readFile(args.path, 'utf8');
218
- // Only transform files that import from lua-cli or api-exports
219
- if (!contents.includes('lua-cli') && !contents.includes('api-exports')) {
220
- return null;
221
- }
222
- // Replace lua-cli imports with global references
223
- let transformedContents = contents;
224
- // Replace named imports from api-exports (e.g., ../../../dist/api-exports)
225
- // Match: import { Jobs, Products, etc. } from "../../../dist/api-exports"
226
- transformedContents = transformedContents.replace(/import\s+{([^}]+)}\s+from\s+["'][^"']*api-exports["'];?/g, (match, imports) => {
227
- // Just remove the import, globals will be available in sandbox
228
- return '// api-exports imports removed - using sandbox globals';
229
- });
230
- // Replace named imports from lua-cli
231
- // Match: import { Products, User, Data, etc. } from "lua-cli"
232
- transformedContents = transformedContents.replace(/import\s+{([^}]+)}\s+from\s+["']lua-cli["'];?/g, (match, imports) => {
233
- // Just remove the import, globals will be available in sandbox
234
- return '// lua-cli imports removed - using sandbox globals';
235
- });
236
- // Replace lua-cli/skill imports - keep env and LuaTool as they might be needed
237
- transformedContents = transformedContents.replace(/import\s+{([^}]+)}\s+from\s+["']lua-cli\/skill["'];?/g, (match, imports) => {
238
- // Check if env is imported, if so we need to keep a reference
239
- if (imports.includes('env')) {
240
- return '// lua-cli/skill imports removed - env available in sandbox';
241
- }
242
- return '// lua-cli/skill imports removed - using sandbox globals';
243
- });
244
- // Map import names to sandbox global names
245
- // Products -> Product, Orders -> Order, etc.
246
- const globalMappings = {
247
- 'Products': 'Products',
248
- 'User': 'User',
249
- 'Data': 'Data',
250
- 'Baskets': 'Baskets',
251
- 'Orders': 'Orders',
252
- 'Webhooks': 'Webhooks',
253
- 'Jobs': 'Jobs',
254
- 'Templates': 'Templates'
255
- };
256
- // Replace usage of imported names with globals
257
- for (const [importName, globalName] of Object.entries(globalMappings)) {
258
- // Replace standalone usage (e.g., Products.method() -> Product.method())
259
- const regex = new RegExp(`\\b${importName}\\.`, 'g');
260
- transformedContents = transformedContents.replace(regex, `${globalName}.`);
261
- }
262
- // Note: env function and LuaTool interface are already available in sandbox
263
- // env is a function in the sandbox context (see sandbox.ts line 333)
264
- return {
265
- contents: transformedContents,
266
- loader: args.path.endsWith('.ts') ? 'ts' :
267
- args.path.endsWith('.tsx') ? 'tsx' : 'js'
268
- };
269
- });
270
- },
271
- };
272
- /**
273
- * Bundles a tool's TypeScript code into a standalone JavaScript file.
274
- * Uses esbuild to:
275
- * - Bundle all dependencies (except external packages)
276
- * - Minify code for production
277
- * - Wrap for VM execution
278
- *
279
- * For inline tools (defined in index.ts), creates a temporary export file first.
280
- *
281
- * @param tool - The tool to bundle
282
- * @param distDir - The distribution directory for output
283
- * @param modifiedSource - Optional modified source (for pre-bundled jobs)
284
- * @param debugMode - Enable verbose logging and preserve temp files
285
- */
286
- export async function bundleTool(tool, distDir, modifiedSource, debugMode) {
287
- if (!debugMode)
288
- writeProgress(`📦 Bundling ${tool.className}...`);
289
- if (debugMode)
290
- console.log(` → Bundling ${tool.className}...`);
291
- try {
292
- const outputPath = path.join(distDir, COMPILE_DIRS.TOOLS, `${tool.className}.js`);
293
- let entryPoint = tool.filePath;
294
- let tempFile = null;
295
- // Note: modifiedSource is handled via stdin below, no temp file needed
296
- // Check if tool is inline (in index.ts or src/index.ts)
297
- const isInlineInIndex = tool.filePath.endsWith('index.ts') || tool.filePath.endsWith('index.tsx');
298
- if (isInlineInIndex) {
299
- // Create a temporary file that exports just this tool class
300
- const tempDir = path.join(distDir, '.temp');
301
- if (!fs.existsSync(tempDir)) {
302
- fs.mkdirSync(tempDir, { recursive: true });
303
- }
304
- tempFile = path.join(tempDir, `${tool.className}.ts`);
305
- // Read the source file and extract just the tool class
306
- const sourceContent = fs.readFileSync(tool.filePath, 'utf8');
307
- const project = new Project();
308
- const sourceFile = project.addSourceFileAtPath(tool.filePath);
309
- const classDecl = sourceFile.getClass(tool.className);
310
- if (classDecl) {
311
- // Get all imports from the original file that this class might need
312
- const imports = sourceFile.getImportDeclarations();
313
- let importsText = '';
314
- // Include imports from lua-cli and zod (tools commonly need these)
315
- imports.forEach(importDecl => {
316
- const moduleSpec = importDecl.getModuleSpecifierValue();
317
- if (moduleSpec === 'lua-cli' || moduleSpec === 'zod' || moduleSpec.startsWith('./')) {
318
- importsText += importDecl.getText() + '\n';
319
- }
320
- });
321
- // Create temporary file with imports and the tool class
322
- const toolClassText = classDecl.getText();
323
- const tempContent = `${importsText}\n${toolClassText}\n\nexport default ${tool.className};\n`;
324
- fs.writeFileSync(tempFile, tempContent);
325
- entryPoint = tempFile;
326
- }
327
- }
328
- // Use stdin for modified source to preserve import resolution
329
- if (modifiedSource && !isInlineInIndex) {
330
- // Remove api-exports and lua-cli imports (they're available in sandbox)
331
- const transformedSource = stripLuaCliImports(modifiedSource);
332
- await build({
333
- ...ESBUILD_TOOL_CONFIG,
334
- stdin: {
335
- contents: transformedSource,
336
- resolveDir: path.dirname(tool.filePath),
337
- sourcefile: tool.filePath,
338
- loader: 'ts',
339
- },
340
- outfile: outputPath,
341
- plugins: [sandboxGlobalsPlugin],
342
- });
343
- }
344
- else {
345
- await build({
346
- ...ESBUILD_TOOL_CONFIG,
347
- entryPoints: [entryPoint],
348
- outfile: outputPath,
349
- plugins: [sandboxGlobalsPlugin],
350
- });
351
- }
352
- // Clean up temp file if created (unless in debug mode)
353
- if (tempFile && fs.existsSync(tempFile) && !debugMode) {
354
- try {
355
- fs.unlinkSync(tempFile);
356
- }
357
- catch (cleanupError) {
358
- // Ignore cleanup errors
359
- }
360
- }
361
- else if (tempFile && debugMode) {
362
- if (debugMode)
363
- console.log(` ℹ️ Preserved temp file: ${tempFile}`);
364
- }
365
- }
366
- catch (error) {
367
- console.warn(`Warning: Failed to bundle ${tool.className}:`, error);
368
- if (debugMode && error instanceof Error) {
369
- console.error(' Stack trace:', error.stack);
370
- }
371
- }
372
- }
373
- /**
374
- * Bundles the main index.ts file into a standalone JavaScript file.
375
- * This creates the entry point for the skill.
376
- *
377
- * @param indexPath - Path to the index.ts file
378
- * @param distDir - The distribution directory for output
379
- */
380
- export async function bundleMainIndex(indexPath, distDir) {
381
- writeProgress("📦 Bundling main index...");
382
- try {
383
- await build({
384
- ...ESBUILD_INDEX_CONFIG,
385
- entryPoints: [indexPath],
386
- outfile: path.join(distDir, COMPILE_FILES.INDEX_JS),
387
- });
388
- }
389
- catch (error) {
390
- console.warn("Warning: Failed to bundle main index:", error);
391
- }
392
- }
393
- /**
394
- * Extracts and bundles webhook execute function and schemas.
395
- *
396
- * @param webhook - Webhook metadata with name and version
397
- * @param indexFile - The TypeScript source file containing the webhook
398
- * @param distDir - Distribution directory for output
399
- * @param project - Optional ts-morph Project for resolving imports
400
- * @param debugMode - Enable verbose logging and preserve temp files
401
- * @returns Webhook with bundled code and schemas
402
- */
403
- export async function bundleWebhook(webhook, indexFile, distDir, project, debugMode) {
404
- if (!debugMode)
405
- writeProgress(`📦 Bundling webhook ${webhook.name}...`);
406
- try {
407
- // Find the LuaWebhook constructor in the AST
408
- let executeFunction = '';
409
- let querySchema = undefined;
410
- let headerSchema = undefined;
411
- let bodySchema = undefined;
412
- let sourceFilePath = indexFile.getFilePath();
413
- // Helper function to search for webhook in a file
414
- const searchFileForWebhook = (file) => {
415
- file.forEachDescendant((node) => {
416
- if (Node.isNewExpression(node)) {
417
- const expression = node.getExpression();
418
- if (expression.getText() === 'LuaWebhook') {
419
- const args = node.getArguments();
420
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
421
- const configObj = args[0];
422
- // First pass: check if this is the webhook we're looking for
423
- let isMatchingWebhook = false;
424
- let foundExecute = '';
425
- let foundQuerySchema = undefined;
426
- let foundHeaderSchema = undefined;
427
- let foundBodySchema = undefined;
428
- configObj.getProperties().forEach((prop) => {
429
- if (Node.isPropertyAssignment(prop)) {
430
- const name = prop.getName();
431
- const value = prop.getInitializer();
432
- if (name === 'name' && value) {
433
- const nameValue = value.getText().replace(/['"]/g, '');
434
- if (nameValue === webhook.name) {
435
- isMatchingWebhook = true;
436
- }
437
- }
438
- if (name === 'execute' && value) {
439
- foundExecute = value.getText();
440
- }
441
- else if (name === 'querySchema' && value) {
442
- foundQuerySchema = value.getText();
443
- }
444
- else if (name === 'headerSchema' && value) {
445
- foundHeaderSchema = value.getText();
446
- }
447
- else if (name === 'bodySchema' && value) {
448
- foundBodySchema = value.getText();
449
- }
450
- }
451
- });
452
- // Only set values if this is the matching webhook
453
- if (isMatchingWebhook) {
454
- executeFunction = foundExecute;
455
- querySchema = foundQuerySchema;
456
- headerSchema = foundHeaderSchema;
457
- bodySchema = foundBodySchema;
458
- // Update source file path to the file where webhook was found
459
- sourceFilePath = file.getFilePath();
460
- }
461
- }
462
- }
463
- }
464
- });
465
- };
466
- // Search in index file first
467
- searchFileForWebhook(indexFile);
468
- // If not found and project is available, search in imported files
469
- if (!executeFunction && project) {
470
- const imports = indexFile.getImportDeclarations();
471
- for (const importDecl of imports) {
472
- try {
473
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
474
- const { resolveImportPath } = await import('./compile.js');
475
- const importPath = resolveImportPath(moduleSpecifier, indexFile.getFilePath());
476
- if (fs.existsSync(importPath)) {
477
- const importedFile = project.addSourceFileAtPath(importPath);
478
- searchFileForWebhook(importedFile);
479
- // If found, stop searching
480
- if (executeFunction) {
481
- break;
482
- }
483
- }
484
- }
485
- catch (error) {
486
- // Continue searching other imports
487
- }
488
- }
489
- }
490
- // Convert Zod schemas to JSON Schema
491
- const convertedSchemas = {};
492
- if (querySchema) {
493
- convertedSchemas.querySchema = await evaluateZodSchemaToJsonSchema(querySchema);
494
- }
495
- if (headerSchema) {
496
- convertedSchemas.headerSchema = await evaluateZodSchemaToJsonSchema(headerSchema);
497
- }
498
- if (bodySchema) {
499
- convertedSchemas.bodySchema = await evaluateZodSchemaToJsonSchema(bodySchema);
500
- }
501
- // Bundle and compress the execute function (like tools)
502
- let compressedCode = '';
503
- if (executeFunction) {
504
- compressedCode = await bundleAndCompressWebhookCode(executeFunction, webhook.name, distDir, sourceFilePath, debugMode);
505
- }
506
- return {
507
- ...webhook,
508
- executeFunction,
509
- code: compressedCode, // Add compressed bundled code
510
- ...convertedSchemas
511
- };
512
- }
513
- catch (error) {
514
- console.warn(`Warning: Could not bundle webhook ${webhook.name}:`, error);
515
- return webhook;
516
- }
517
- }
518
- /**
519
- * Bundles and compresses webhook execute function code.
520
- * Creates a temporary file, bundles with esbuild, compresses with gzip.
521
- * Includes all imports from the source file to ensure dependencies are bundled.
522
- *
523
- * @param executeFunction - Raw execute function code
524
- * @param webhookName - Name of the webhook
525
- * @param distDir - Distribution directory
526
- * @param sourceFilePath - Path to the source file containing the webhook
527
- * @param debugMode - Enable verbose logging and preserve temp files
528
- * @returns Compressed base64-encoded bundled code
529
- */
530
- async function bundleAndCompressWebhookCode(executeFunction, webhookName, distDir, sourceFilePath, debugMode) {
531
- return bundleAndCompressExecuteFunction(executeFunction, webhookName, 'webhook', (bundledCode) => `(async (event) => {
532
-
533
- // Execute the bundled webhook code
534
- ${bundledCode}
535
-
536
- // Get the execute function from exports
537
- const executeFunction = module.exports.default || module.exports;
538
-
539
- // Execute with the unified event object
540
- return await executeFunction(event);
541
- })`, distDir, sourceFilePath, debugMode);
542
- }
543
- /**
544
- * Extracts and bundles job execute function.
545
- *
546
- * @param job - Job metadata with name and version
547
- * @param indexFile - The TypeScript source file containing the job
548
- * @param distDir - Distribution directory for output
549
- * @param project - Optional ts-morph Project for resolving imports
550
- * @param debugMode - Enable verbose logging and preserve temp files
551
- * @returns Job with bundled code
552
- */
553
- export async function bundleJob(job, indexFile, distDir, project, debugMode) {
554
- if (!debugMode)
555
- writeProgress(`📦 Bundling job ${job.name}...`);
556
- try {
557
- // Find the LuaJob constructor in the AST
558
- let executeFunction = '';
559
- let sourceFilePath = indexFile.getFilePath();
560
- // Helper function to search for job in a file
561
- const searchFileForJob = (file) => {
562
- file.forEachDescendant((node) => {
563
- if (Node.isNewExpression(node)) {
564
- const expression = node.getExpression();
565
- if (expression.getText() === 'LuaJob') {
566
- const args = node.getArguments();
567
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
568
- const configObj = args[0];
569
- // First pass: check if this is the job we're looking for
570
- let isMatchingJob = false;
571
- let foundExecute = '';
572
- configObj.getProperties().forEach((prop) => {
573
- if (Node.isPropertyAssignment(prop)) {
574
- const name = prop.getName();
575
- const value = prop.getInitializer();
576
- if (name === 'name' && value) {
577
- const nameValue = value.getText().replace(/['"]/g, '');
578
- if (nameValue === job.name) {
579
- isMatchingJob = true;
580
- }
581
- }
582
- if (name === 'execute' && value) {
583
- foundExecute = value.getText();
584
- }
585
- }
586
- });
587
- // Only set executeFunction if this is the matching job
588
- if (isMatchingJob && foundExecute) {
589
- executeFunction = foundExecute;
590
- // Update source file path to the file where job was found
591
- sourceFilePath = file.getFilePath();
592
- }
593
- }
594
- }
595
- }
596
- });
597
- };
598
- // Search in index file first
599
- searchFileForJob(indexFile);
600
- // If not found and project is available, search in imported files
601
- if (!executeFunction && project) {
602
- const imports = indexFile.getImportDeclarations();
603
- for (const importDecl of imports) {
604
- try {
605
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
606
- const { resolveImportPath } = await import('./compile.js');
607
- const importPath = resolveImportPath(moduleSpecifier, indexFile.getFilePath());
608
- if (fs.existsSync(importPath)) {
609
- const importedFile = project.addSourceFileAtPath(importPath);
610
- searchFileForJob(importedFile);
611
- // If found, stop searching
612
- if (executeFunction) {
613
- break;
614
- }
615
- }
616
- }
617
- catch (error) {
618
- // Continue searching other imports
619
- }
620
- }
621
- }
622
- // Bundle and compress the execute function (like tools)
623
- let compressedCode = '';
624
- if (executeFunction) {
625
- compressedCode = await bundleAndCompressJobCode(executeFunction, job.name, distDir, sourceFilePath, debugMode);
626
- }
627
- return {
628
- ...job,
629
- executeFunction,
630
- code: compressedCode // Add compressed bundled code
631
- };
632
- }
633
- catch (error) {
634
- console.warn(`Warning: Could not bundle job ${job.name}:`, error);
635
- return job;
636
- }
637
- }
638
- /**
639
- * Bundles and compresses job execute function code.
640
- * Creates a temporary file, bundles with esbuild, compresses with gzip.
641
- * Includes all imports from the source file to ensure dependencies are bundled.
642
- *
643
- * @param executeFunction - Raw execute function code
644
- * @param jobName - Name of the job
645
- * @param distDir - Distribution directory
646
- * @param sourceFilePath - Path to the source file containing the job
647
- * @param debugMode - Enable verbose logging and preserve temp files
648
- * @returns Compressed base64-encoded bundled code
649
- */
650
- async function bundleAndCompressJobCode(executeFunction, jobName, distDir, sourceFilePath, debugMode) {
651
- return bundleAndCompressExecuteFunction(executeFunction, jobName, 'job', (bundledCode) => `(async (job) => {
652
- // Execute the bundled job code
653
- ${bundledCode}
654
-
655
- // Get the execute function from exports
656
- const executeFunction = module.exports.default || module.exports;
657
-
658
- // Execute job with job instance parameter
659
- return await executeFunction(job);
660
- })`, distDir, sourceFilePath, debugMode);
661
- }
662
- /**
663
- * Bundles and compresses preprocessor execute function code.
664
- */
665
- export async function bundlePreProcessor(preprocessor, indexFile, distDir, project, debugMode) {
666
- if (!debugMode)
667
- writeProgress(`📦 Bundling preprocessor ${preprocessor.name}...`);
668
- try {
669
- let executeFunction = '';
670
- let sourceFilePath = indexFile.getFilePath();
671
- const searchFileForPreProcessor = (file) => {
672
- file.forEachDescendant((node) => {
673
- if (Node.isNewExpression(node)) {
674
- const expression = node.getExpression();
675
- if (expression.getText() === 'PreProcessor') {
676
- const args = node.getArguments();
677
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
678
- const configObj = args[0];
679
- let isMatching = false;
680
- let foundExecute = '';
681
- configObj.getProperties().forEach((prop) => {
682
- if (Node.isPropertyAssignment(prop)) {
683
- const name = prop.getName();
684
- const value = prop.getInitializer();
685
- if (name === 'name' && value) {
686
- const nameValue = value.getText().replace(/['"]/g, '');
687
- if (nameValue === preprocessor.name) {
688
- isMatching = true;
689
- }
690
- }
691
- if (name === 'execute' && value) {
692
- foundExecute = value.getText();
693
- }
694
- }
695
- });
696
- if (isMatching && foundExecute) {
697
- executeFunction = foundExecute;
698
- // Update source file path to the file where preprocessor was found
699
- sourceFilePath = file.getFilePath();
700
- }
701
- }
702
- }
703
- }
704
- });
705
- };
706
- // Search in index file first
707
- searchFileForPreProcessor(indexFile);
708
- // If not found and project is available, search in imported files
709
- if (!executeFunction && project) {
710
- const imports = indexFile.getImportDeclarations();
711
- for (const importDecl of imports) {
712
- try {
713
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
714
- const { resolveImportPath } = await import('./compile.js');
715
- const importPath = resolveImportPath(moduleSpecifier, indexFile.getFilePath());
716
- if (fs.existsSync(importPath)) {
717
- const importedFile = project.addSourceFileAtPath(importPath);
718
- searchFileForPreProcessor(importedFile);
719
- if (executeFunction) {
720
- break;
721
- }
722
- }
723
- }
724
- catch (error) {
725
- // Continue searching
726
- }
727
- }
728
- }
729
- let compressedCode = '';
730
- if (executeFunction) {
731
- compressedCode = await bundleAndCompressProcessorCode(executeFunction, preprocessor.name, 'pre', distDir, sourceFilePath, debugMode);
732
- }
733
- return {
734
- name: preprocessor.name,
735
- version: preprocessor.version,
736
- description: preprocessor.description,
737
- async: preprocessor.async === true ? true : false, // Explicitly set boolean
738
- executeFunction,
739
- code: compressedCode
740
- };
741
- }
742
- catch (error) {
743
- console.warn(`Warning: Could not bundle preprocessor ${preprocessor.name}:`, error);
744
- return preprocessor;
745
- }
746
- }
747
- /**
748
- * Bundles and compresses postprocessor execute function code.
749
- */
750
- export async function bundlePostProcessor(postprocessor, indexFile, distDir, project, debugMode) {
751
- if (!debugMode)
752
- writeProgress(`📦 Bundling postprocessor ${postprocessor.name}...`);
753
- try {
754
- let executeFunction = '';
755
- let sourceFilePath = indexFile.getFilePath();
756
- const searchFileForPostProcessor = (file) => {
757
- file.forEachDescendant((node) => {
758
- if (Node.isNewExpression(node)) {
759
- const expression = node.getExpression();
760
- if (expression.getText() === 'PostProcessor') {
761
- const args = node.getArguments();
762
- if (args.length > 0 && Node.isObjectLiteralExpression(args[0])) {
763
- const configObj = args[0];
764
- let isMatching = false;
765
- let foundExecute = '';
766
- configObj.getProperties().forEach((prop) => {
767
- if (Node.isPropertyAssignment(prop)) {
768
- const name = prop.getName();
769
- const value = prop.getInitializer();
770
- if (name === 'name' && value) {
771
- const nameValue = value.getText().replace(/['"]/g, '');
772
- if (nameValue === postprocessor.name) {
773
- isMatching = true;
774
- }
775
- }
776
- if (name === 'execute' && value) {
777
- foundExecute = value.getText();
778
- }
779
- }
780
- });
781
- if (isMatching && foundExecute) {
782
- executeFunction = foundExecute;
783
- // Update source file path to the file where postprocessor was found
784
- sourceFilePath = file.getFilePath();
785
- }
786
- }
787
- }
788
- }
789
- });
790
- };
791
- // Search in index file first
792
- searchFileForPostProcessor(indexFile);
793
- // If not found and project is available, search in imported files
794
- if (!executeFunction && project) {
795
- const imports = indexFile.getImportDeclarations();
796
- for (const importDecl of imports) {
797
- try {
798
- const moduleSpecifier = importDecl.getModuleSpecifierValue();
799
- const { resolveImportPath } = await import('./compile.js');
800
- const importPath = resolveImportPath(moduleSpecifier, indexFile.getFilePath());
801
- if (fs.existsSync(importPath)) {
802
- const importedFile = project.addSourceFileAtPath(importPath);
803
- searchFileForPostProcessor(importedFile);
804
- if (executeFunction) {
805
- break;
806
- }
807
- }
808
- }
809
- catch (error) {
810
- // Continue searching
811
- }
812
- }
813
- }
814
- let compressedCode = '';
815
- if (executeFunction) {
816
- compressedCode = await bundleAndCompressProcessorCode(executeFunction, postprocessor.name, 'post', distDir, sourceFilePath, debugMode);
817
- }
818
- return {
819
- name: postprocessor.name,
820
- version: postprocessor.version,
821
- description: postprocessor.description,
822
- executeFunction,
823
- code: compressedCode
824
- };
825
- }
826
- catch (error) {
827
- console.warn(`Warning: Could not bundle postprocessor ${postprocessor.name}:`, error);
828
- return postprocessor;
829
- }
830
- }
831
- /**
832
- * Bundles and compresses processor execute function code.
833
- * Includes all imports from the source file to ensure dependencies are bundled.
834
- */
835
- async function bundleAndCompressProcessorCode(executeFunction, processorName, type, distDir, sourceFilePath, debugMode) {
836
- // Processor execute functions receive: (user, message, [response], channel)
837
- const paramList = type === 'pre' ? 'user, message, channel' : 'user, message, response, channel';
838
- return bundleAndCompressExecuteFunction(executeFunction, processorName, `${type}processor`, (bundledCode) => `(async (${paramList}) => {
839
- // Execute the bundled processor code
840
- ${bundledCode}
841
-
842
- const executeFunction = module.exports.default || module.exports;
843
- return await executeFunction(${paramList});
844
- })`, distDir, sourceFilePath, debugMode);
845
- }
846
- /**
847
- * Extracts tool code from a bundled tool.
848
- * Reads the bundled code, wraps it for VM execution (execute and condition),
849
- * and converts the Zod schema to JSON Schema format.
850
- */
851
- export async function extractToolCode(tool, project) {
852
- try {
853
- const toolSourceFile = project.getSourceFile(tool.filePath);
854
- if (!toolSourceFile) {
855
- console.warn(`Warning: Could not find source file for ${tool.className}`);
856
- return;
857
- }
858
- const classDecl = toolSourceFile.getClass(tool.className);
859
- if (!classDecl) {
860
- console.warn(`Warning: Could not find class ${tool.className} in ${tool.filePath}`);
861
- return;
862
- }
863
- // Verify execute method or property exists
864
- const executeMethod = classDecl.getMethod('execute');
865
- const executeProperty = classDecl.getProperty('execute');
866
- if (!executeMethod && !executeProperty) {
867
- console.warn(`Warning: Could not find execute method or property in ${tool.className}`);
868
- return;
869
- }
870
- // Validate execute has a body (for methods) or initializer (for arrow function properties)
871
- if (executeMethod) {
872
- const executeBody = executeMethod.getBodyText();
873
- if (!executeBody) {
874
- console.warn(`Warning: Execute method has no body in ${tool.className}`);
875
- return;
876
- }
877
- }
878
- else if (executeProperty) {
879
- const initializer = executeProperty.getInitializer();
880
- if (!initializer) {
881
- console.warn(`Warning: Execute property has no initializer in ${tool.className}`);
882
- return;
883
- }
884
- }
885
- // Read bundled code and wrap for VM execution
886
- const rawBundledCode = readBundledToolCode(tool);
887
- if (rawBundledCode) {
888
- tool.executeCode = wrapExecuteForVM(rawBundledCode, tool.className);
889
- // Check if tool has condition and wrap it
890
- const hasCondition = classDecl.getMethod('condition') || classDecl.getProperty('condition');
891
- if (hasCondition) {
892
- tool.conditionCode = wrapConditionForVM(rawBundledCode, tool.className);
893
- }
894
- }
895
- // Extract input schema using ts-evaluator (resolves all imports/expressions automatically)
896
- tool.inputSchema = await extractInputSchema(classDecl, tool);
897
- }
898
- catch (error) {
899
- console.warn(`Warning: Could not extract tool metadata for ${tool.className}:`, error);
900
- }
901
- }
902
- /**
903
- * Reads the raw bundled tool code from the dist directory.
904
- */
905
- function readBundledToolCode(tool) {
906
- const bundledPath = path.join(process.cwd(), COMPILE_DIRS.DIST, COMPILE_DIRS.TOOLS, `${tool.className}.js`);
907
- if (fs.existsSync(bundledPath)) {
908
- return fs.readFileSync(bundledPath, 'utf8');
909
- }
910
- return undefined;
911
- }
912
- /**
913
- * Extracts and converts the input schema from a tool class using ts-evaluator.
914
- * This evaluates the actual TypeScript AST node, resolving all imports and expressions.
915
- *
916
- * @param classDecl - The tool class declaration from ts-morph
917
- * @param tool - The tool being analyzed
918
- * @returns The JSON Schema object or default schema
919
- */
920
- async function extractInputSchema(classDecl, tool) {
921
- const inputSchemaProperty = classDecl.getProperty('inputSchema');
922
- if (!inputSchemaProperty?.getInitializer()) {
923
- return DEFAULT_INPUT_SCHEMA;
924
- }
925
- try {
926
- const initializer = inputSchemaProperty.getInitializer();
927
- const sourceFile = initializer.getSourceFile();
928
- const project = sourceFile.getProject();
929
- // Get the underlying TypeScript compiler objects for ts-evaluator
930
- const tsNode = initializer.compilerNode;
931
- const typeChecker = project.getTypeChecker().compilerObject;
932
- const compilerOptions = project.getCompilerOptions();
933
- // Get zod from node_modules to provide as extra global
934
- const { z } = await import('zod');
935
- // Evaluate the AST node using ts-evaluator
936
- // This resolves all imports, variables, and expressions automatically
937
- const result = evaluate({
938
- node: tsNode,
939
- typeChecker,
940
- typescript: ts,
941
- environment: {
942
- preset: 'NODE',
943
- extra: { z } // Provide zod as a global to avoid import resolution issues
944
- },
945
- policy: {
946
- deterministic: false,
947
- network: false,
948
- console: false,
949
- io: { read: true, write: false },
950
- process: { exit: false, spawnChild: false }
951
- }
952
- });
953
- if (!result.success) {
954
- throw new Error(result.reason?.message || 'Failed to evaluate schema');
955
- }
956
- const zodSchema = result.value;
957
- if (!zodSchema || typeof zodSchema !== 'object') {
958
- return DEFAULT_INPUT_SCHEMA;
959
- }
960
- // Convert Zod schema to JSON Schema
961
- const { zodToJsonSchema } = await import('zod-to-json-schema');
962
- const jsonSchema = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });
963
- // Clean up the JSON schema (remove $schema, title, etc.)
964
- const { $schema, title, definitions, $ref, ...cleanSchema } = jsonSchema;
965
- return cleanSchema;
966
- }
967
- catch (error) {
968
- console.warn(`Warning: Could not evaluate schema for ${tool.className}:`, error?.message || error);
969
- return DEFAULT_INPUT_SCHEMA;
970
- }
971
- }
972
- /**
973
- * Bundles and compresses an MCP resolver function using esbuild.
974
- *
975
- * MCP resolver functions are simple arrow functions like:
976
- * () => ({ KEY: env("KEY") })
977
- *
978
- * They don't have imports (env is runtime-provided), but may have TypeScript
979
- * type annotations that need transpilation. Uses esbuild for TypeScript support.
980
- *
981
- * @param functionCode - Raw function code (e.g., "() => ({ KEY: env('KEY') })")
982
- * @param resolverType - Type of resolver ('env', 'headers', 'url') for temp file naming
983
- * @param serverName - MCP server name for temp file naming
984
- * @param distDir - Distribution directory for temp files
985
- * @param debugMode - Enable verbose logging and preserve temp files
986
- * @returns Compressed base64-encoded bundled code, or null if bundling fails
987
- */
988
- export async function bundleMCPResolverFunction(functionCode, resolverType, serverName, distDir, debugMode) {
989
- const { compressCode } = await import('./compile.js');
990
- // Create temporary file with the function wrapped as a module
991
- const tempDir = path.join(distDir, '.temp');
992
- if (!fs.existsSync(tempDir)) {
993
- fs.mkdirSync(tempDir, { recursive: true });
994
- }
995
- const safeName = serverName.replace(/[^a-zA-Z0-9]/g, '_');
996
- const tempFile = path.join(tempDir, `mcp-${safeName}-${resolverType}.ts`);
997
- const tempOutput = path.join(tempDir, `mcp-${safeName}-${resolverType}.js`);
998
- try {
999
- // Write function as a module export
1000
- // The function references `env` which will be provided by the runtime sandbox
1001
- const moduleCode = `
1002
- // MCP ${resolverType} resolver for ${serverName}
1003
- // Note: env() is provided by the runtime sandbox, not imported
1004
- const resolverFunc = ${functionCode};
1005
- export default resolverFunc;
1006
- `;
1007
- fs.writeFileSync(tempFile, moduleCode);
1008
- if (debugMode) {
1009
- console.log(` → Bundling MCP ${resolverType} resolver for ${serverName}...`);
1010
- }
1011
- // Bundle with esbuild - minimal config since there are no imports to resolve
1012
- await build({
1013
- entryPoints: [tempFile],
1014
- bundle: true,
1015
- platform: 'node',
1016
- target: 'node16',
1017
- format: 'cjs',
1018
- minify: true,
1019
- outfile: tempOutput,
1020
- external: [...EXTERNAL_PACKAGES],
1021
- plugins: [sandboxGlobalsPlugin],
1022
- });
1023
- // Read bundled code
1024
- if (!fs.existsSync(tempOutput)) {
1025
- throw new Error(`esbuild failed to create output file for MCP ${resolverType} resolver`);
1026
- }
1027
- const bundledCode = fs.readFileSync(tempOutput, 'utf8');
1028
- if (bundledCode.length === 0) {
1029
- throw new Error(`esbuild created empty bundle for MCP ${resolverType} resolver`);
1030
- }
1031
- // Wrap for VM execution - the resolver function returns a value directly
1032
- const wrappedCode = `(async () => {
1033
- ${bundledCode}
1034
-
1035
- const resolverFunc = module.exports.default || module.exports;
1036
- return resolverFunc();
1037
- })()`;
1038
- // Compress the wrapped code
1039
- const compressed = compressCode(wrappedCode);
1040
- if (debugMode) {
1041
- console.log(` → MCP ${resolverType} resolver bundled: ${(compressed.length / 1024).toFixed(2)}KB`);
1042
- }
1043
- // Clean up temp files (unless in debug mode)
1044
- if (!debugMode) {
1045
- try {
1046
- fs.unlinkSync(tempFile);
1047
- fs.unlinkSync(tempOutput);
1048
- }
1049
- catch (cleanupError) {
1050
- // Ignore cleanup errors
1051
- }
1052
- }
1053
- return compressed;
1054
- }
1055
- catch (error) {
1056
- console.warn(`Warning: Could not bundle MCP ${resolverType} resolver for ${serverName}: ${error.message}`);
1057
- // Fallback: compress the raw function with simple wrapper (may fail at runtime if TS syntax)
1058
- try {
1059
- const fallbackCode = `(${functionCode})()`;
1060
- return compressCode(fallbackCode);
1061
- }
1062
- catch (fallbackError) {
1063
- console.warn(`Warning: Fallback compression also failed for MCP ${resolverType} resolver`);
1064
- return null;
1065
- }
1066
- }
1067
- }
1068
- //# sourceMappingURL=bundling.js.map