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.
- package/README.md +137 -689
- package/dist/api/agent.api.service.d.ts +1 -8
- package/dist/api/agent.api.service.js +1 -11
- package/dist/api/agent.api.service.js.map +1 -1
- package/dist/api/auth.api.service.d.ts +1 -1
- package/dist/api/auth.api.service.js +1 -1
- package/dist/api/auth.api.service.js.map +1 -1
- package/dist/api/backup.api.service.d.ts +80 -0
- package/dist/api/backup.api.service.js +101 -0
- package/dist/api/backup.api.service.js.map +1 -0
- package/dist/api/basket.api.service.d.ts +4 -5
- package/dist/api/basket.api.service.js +13 -18
- package/dist/api/basket.api.service.js.map +1 -1
- package/dist/api/cdn.api.service.d.ts +2 -0
- package/dist/api/cdn.api.service.js +2 -0
- package/dist/api/cdn.api.service.js.map +1 -1
- package/dist/api/chat.api.service.d.ts +10 -2
- package/dist/api/chat.api.service.js +21 -2
- package/dist/api/chat.api.service.js.map +1 -1
- package/dist/api/credentials.js +5 -8
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/custom.data.api.service.d.ts +3 -3
- package/dist/api/custom.data.api.service.js +9 -10
- package/dist/api/custom.data.api.service.js.map +1 -1
- package/dist/api/developer.api.service.d.ts +1 -1
- package/dist/api/developer.api.service.js +1 -1
- package/dist/api/developer.api.service.js.map +1 -1
- package/dist/api/http.client.js.map +1 -0
- package/dist/api/job.api.service.d.ts +2 -2
- package/dist/api/job.api.service.js +2 -2
- package/dist/api/job.api.service.js.map +1 -1
- package/dist/api/logs.api.service.d.ts +1 -1
- package/dist/api/logs.api.service.js +1 -1
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/marketplace.api.service.d.ts +6 -6
- package/dist/api/marketplace.api.service.js.map +1 -1
- package/dist/api/order.api.service.d.ts +3 -4
- package/dist/api/order.api.service.js +8 -10
- package/dist/api/order.api.service.js.map +1 -1
- package/dist/api/persona.api.service.d.ts +1 -1
- package/dist/api/persona.api.service.js +1 -1
- package/dist/api/persona.api.service.js.map +1 -1
- package/dist/api/postprocessor.api.service.d.ts +1 -1
- package/dist/api/postprocessor.api.service.js +1 -1
- package/dist/api/postprocessor.api.service.js.map +1 -1
- package/dist/api/preprocessor.api.service.d.ts +1 -1
- package/dist/api/preprocessor.api.service.js +1 -1
- package/dist/api/preprocessor.api.service.js.map +1 -1
- package/dist/api/products.api.service.d.ts +4 -4
- package/dist/api/products.api.service.js +6 -6
- package/dist/api/products.api.service.js.map +1 -1
- package/dist/api/resource.api.service.d.ts +76 -0
- package/dist/api/resource.api.service.js +74 -0
- package/dist/api/resource.api.service.js.map +1 -0
- package/dist/api/skills.api.service.d.ts +7 -15
- package/dist/api/skills.api.service.js +1 -1
- package/dist/api/skills.api.service.js.map +1 -1
- package/dist/api/tool.api.service.d.ts +1 -1
- package/dist/api/tool.api.service.js +1 -1
- package/dist/api/tool.api.service.js.map +1 -1
- package/dist/api/unifiedto.api.service.d.ts +1 -1
- package/dist/api/unifiedto.api.service.js +1 -1
- package/dist/api/unifiedto.api.service.js.map +1 -1
- package/dist/api/user.data.api.service.d.ts +7 -8
- package/dist/api/user.data.api.service.js +2 -3
- package/dist/api/user.data.api.service.js.map +1 -1
- package/dist/api/webhook.api.service.d.ts +1 -1
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/webhook.api.service.js.map +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +1 -1
- package/dist/api/whatsapp-templates.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.js.map +1 -1
- package/dist/api-exports.d.ts +14 -12
- package/dist/api-exports.js +8 -8
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.js +32 -17
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/admin.js +3 -24
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/agents.d.ts +8 -7
- package/dist/commands/agents.js +63 -21
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.js +11 -23
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.js +33 -47
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/chatClear.js +11 -41
- package/dist/commands/chatClear.js.map +1 -1
- package/dist/commands/compile.d.ts +26 -23
- package/dist/commands/compile.js +98 -403
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/completion.js +1 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/deploy.js +55 -25
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.js +29 -45
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/env.js +12 -25
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/evals.js +3 -20
- package/dist/commands/evals.js.map +1 -1
- package/dist/commands/features.js +10 -23
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +135 -19
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/integrations.js +26 -37
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/jobs.js +32 -56
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/logs.js +9 -20
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.js +34 -52
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.js +10 -23
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/persona.js +43 -74
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.js +15 -28
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.js +15 -28
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.js +30 -63
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push.js +294 -1241
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts +22 -0
- package/dist/commands/pushBackup.js +133 -0
- package/dist/commands/pushBackup.js.map +1 -0
- package/dist/commands/resources.js +29 -72
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts +1 -1
- package/dist/commands/skills.js +58 -70
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -3
- package/dist/commands/sync.js +12 -24
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test.js +135 -104
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/webhooks.js +15 -28
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts +104 -0
- package/dist/compiler/agent-traverser.js +311 -0
- package/dist/compiler/agent-traverser.js.map +1 -0
- package/dist/compiler/bundler.d.ts +42 -0
- package/dist/compiler/bundler.js +187 -0
- package/dist/compiler/bundler.js.map +1 -0
- package/dist/compiler/compiler.d.ts +177 -0
- package/dist/compiler/compiler.js +580 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +36 -0
- package/dist/compiler/index.js +42 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/plugins/base.d.ts +264 -0
- package/dist/compiler/plugins/base.js +307 -0
- package/dist/compiler/plugins/base.js.map +1 -0
- package/dist/compiler/plugins/job.plugin.d.ts +33 -0
- package/dist/compiler/plugins/job.plugin.js +143 -0
- package/dist/compiler/plugins/job.plugin.js.map +1 -0
- package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
- package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
- package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
- package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
- package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
- package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/processor-base.d.ts +16 -0
- package/dist/compiler/plugins/processor-base.js +34 -0
- package/dist/compiler/plugins/processor-base.js.map +1 -0
- package/dist/compiler/plugins/registry.d.ts +61 -0
- package/dist/compiler/plugins/registry.js +107 -0
- package/dist/compiler/plugins/registry.js.map +1 -0
- package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
- package/dist/compiler/plugins/skill.plugin.js +243 -0
- package/dist/compiler/plugins/skill.plugin.js.map +1 -0
- package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
- package/dist/compiler/plugins/tool.plugin.js +279 -0
- package/dist/compiler/plugins/tool.plugin.js.map +1 -0
- package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
- package/dist/compiler/plugins/webhook.plugin.js +127 -0
- package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
- package/dist/compiler/source-writer.d.ts +98 -0
- package/dist/compiler/source-writer.js +223 -0
- package/dist/compiler/source-writer.js.map +1 -0
- package/dist/compiler/types.d.ts +289 -0
- package/dist/compiler/types.js +20 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/compiler/utils/ast-helpers.d.ts +57 -0
- package/dist/compiler/utils/ast-helpers.js +164 -0
- package/dist/compiler/utils/ast-helpers.js.map +1 -0
- package/dist/compiler/utils/common.d.ts +23 -0
- package/dist/compiler/utils/common.js +66 -0
- package/dist/compiler/utils/common.js.map +1 -0
- package/dist/compiler/utils/file-discovery.d.ts +34 -0
- package/dist/compiler/utils/file-discovery.js +68 -0
- package/dist/compiler/utils/file-discovery.js.map +1 -0
- package/dist/compiler/utils/path-resolver.d.ts +25 -0
- package/dist/compiler/utils/path-resolver.js +66 -0
- package/dist/compiler/utils/path-resolver.js.map +1 -0
- package/dist/compiler/utils/schema-converter.d.ts +26 -0
- package/dist/compiler/utils/schema-converter.js +94 -0
- package/dist/compiler/utils/schema-converter.js.map +1 -0
- package/dist/config/compile.constants.d.ts +2 -22
- package/dist/config/compile.constants.js +2 -49
- package/dist/config/compile.constants.js.map +1 -1
- package/dist/config/constants.d.ts +18 -2
- package/dist/config/constants.js +28 -8
- package/dist/config/constants.js.map +1 -1
- package/dist/config/dev.constants.d.ts +0 -10
- package/dist/config/dev.constants.js +0 -10
- package/dist/config/dev.constants.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/instances/basket.instance.js.map +1 -0
- package/dist/instances/data.entry.instance.js.map +1 -0
- package/dist/instances/job.instance.js.map +1 -0
- package/dist/instances/order.instance.js.map +1 -0
- package/dist/instances/product.instance.js.map +1 -0
- package/dist/instances/product.pagination.instance.js.map +1 -0
- package/dist/instances/product.search.instance.js.map +1 -0
- package/dist/instances/user.instance.js.map +1 -0
- package/dist/interfaces/admin.d.ts +0 -38
- package/dist/interfaces/backup.d.ts +125 -0
- package/dist/interfaces/backup.js +8 -0
- package/dist/interfaces/backup.js.map +1 -0
- package/dist/interfaces/baskets.d.ts +0 -56
- package/dist/interfaces/common.d.ts +1 -0
- package/dist/interfaces/deploy.d.ts +0 -15
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/marketplace.d.ts +51 -0
- package/dist/interfaces/marketplace.js +1 -1
- package/dist/interfaces/marketplace.js.map +1 -1
- package/dist/interfaces/message.d.ts +0 -3
- package/dist/interfaces/orders.d.ts +0 -24
- package/dist/interfaces/postprocessors.d.ts +0 -18
- package/dist/interfaces/preprocessors.d.ts +0 -18
- package/dist/interfaces/skills.d.ts +61 -0
- package/dist/interfaces/user.d.ts +25 -0
- package/dist/interfaces/webhooks.d.ts +0 -9
- package/dist/primitives/base.handler.d.ts +106 -0
- package/dist/primitives/base.handler.js +370 -0
- package/dist/primitives/base.handler.js.map +1 -0
- package/dist/primitives/index.d.ts +47 -0
- package/dist/primitives/index.js +78 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/job.handler.d.ts +52 -0
- package/dist/primitives/job.handler.js +118 -0
- package/dist/primitives/job.handler.js.map +1 -0
- package/dist/primitives/mcp-server.handler.d.ts +54 -0
- package/dist/primitives/mcp-server.handler.js +91 -0
- package/dist/primitives/mcp-server.handler.js.map +1 -0
- package/dist/primitives/postprocessor.handler.d.ts +49 -0
- package/dist/primitives/postprocessor.handler.js +81 -0
- package/dist/primitives/postprocessor.handler.js.map +1 -0
- package/dist/primitives/preprocessor.handler.d.ts +54 -0
- package/dist/primitives/preprocessor.handler.js +95 -0
- package/dist/primitives/preprocessor.handler.js.map +1 -0
- package/dist/primitives/skill.handler.d.ts +44 -0
- package/dist/primitives/skill.handler.js +192 -0
- package/dist/primitives/skill.handler.js.map +1 -0
- package/dist/primitives/types.d.ts +72 -0
- package/dist/primitives/types.js +17 -0
- package/dist/primitives/types.js.map +1 -0
- package/dist/primitives/webhook.handler.d.ts +50 -0
- package/dist/primitives/webhook.handler.js +96 -0
- package/dist/primitives/webhook.handler.js.map +1 -0
- package/dist/services/auth.js +1 -2
- package/dist/services/auth.js.map +1 -1
- package/dist/services/sandbox.service.d.ts +103 -0
- package/dist/services/sandbox.service.js +479 -0
- package/dist/services/sandbox.service.js.map +1 -0
- package/dist/types/api-contracts.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/skill.d.ts +8 -2
- package/dist/types/skill.js +8 -0
- package/dist/types/skill.js.map +1 -1
- package/dist/types/yaml.types.d.ts +69 -0
- package/dist/types/yaml.types.js +6 -0
- package/dist/types/yaml.types.js.map +1 -0
- package/dist/utils/artifact-loader.d.ts +108 -0
- package/dist/utils/artifact-loader.js +188 -0
- package/dist/utils/artifact-loader.js.map +1 -0
- package/dist/utils/backup-helpers.d.ts +122 -0
- package/dist/utils/backup-helpers.js +274 -0
- package/dist/utils/backup-helpers.js.map +1 -0
- package/dist/utils/cli.d.ts +8 -0
- package/dist/utils/cli.js +19 -2
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/command-utils.d.ts +42 -0
- package/dist/utils/command-utils.js +83 -0
- package/dist/utils/command-utils.js.map +1 -0
- package/dist/utils/deploy-helpers.d.ts +0 -29
- package/dist/utils/deploy-helpers.js +0 -70
- package/dist/utils/deploy-helpers.js.map +1 -1
- package/dist/utils/dev-api.d.ts +3 -99
- package/dist/utils/dev-api.js +3 -430
- package/dist/utils/dev-api.js.map +1 -1
- package/dist/utils/dev-server.d.ts +3 -1
- package/dist/utils/dev-server.js +69 -145
- package/dist/utils/dev-server.js.map +1 -1
- package/dist/utils/dev-watcher.d.ts +0 -1
- package/dist/utils/dev-watcher.js +23 -8
- package/dist/utils/dev-watcher.js.map +1 -1
- package/dist/utils/env-loader.utils.d.ts +10 -1
- package/dist/utils/env-loader.utils.js +39 -31
- package/dist/utils/env-loader.utils.js.map +1 -1
- package/dist/utils/files.d.ts +47 -3
- package/dist/utils/files.js +98 -40
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/init-agent.js +1 -2
- package/dist/utils/init-agent.js.map +1 -1
- package/dist/utils/init-helpers.d.ts +2 -10
- package/dist/utils/init-helpers.js +9 -17
- package/dist/utils/init-helpers.js.map +1 -1
- package/dist/utils/init-prompts.d.ts +0 -8
- package/dist/utils/init-prompts.js +0 -22
- package/dist/utils/init-prompts.js.map +1 -1
- package/dist/utils/prompt-handler.d.ts +3 -0
- package/dist/utils/prompt-handler.js +13 -0
- package/dist/utils/prompt-handler.js.map +1 -1
- package/dist/utils/sandbox-storage.d.ts +6 -5
- package/dist/utils/sandbox-storage.js +12 -12
- package/dist/utils/sandbox-storage.js.map +1 -1
- package/dist/utils/sandbox.d.ts +7 -30
- package/dist/utils/sandbox.js +247 -223
- package/dist/utils/sandbox.js.map +1 -1
- package/dist/utils/semver.d.ts +12 -0
- package/dist/utils/semver.js +23 -0
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/sync-display.d.ts +9 -0
- package/dist/utils/sync-display.js +67 -0
- package/dist/utils/sync-display.js.map +1 -0
- package/dist/utils/sync-fetch.d.ts +23 -0
- package/dist/utils/sync-fetch.js +64 -0
- package/dist/utils/sync-fetch.js.map +1 -0
- package/dist/utils/sync-helpers.d.ts +4 -59
- package/dist/utils/sync-helpers.js +4 -206
- package/dist/utils/sync-helpers.js.map +1 -1
- package/dist/web/app.css +912 -186
- package/dist/web/app.js +46 -46
- package/docs/API_INDEX.md +100 -0
- package/docs/API_REFERENCE.md +773 -0
- package/docs/CLI_REFERENCE.md +924 -0
- package/docs/GETTING_STARTED.md +862 -0
- package/docs/README.md +270 -0
- package/docs/api/AI.md +882 -0
- package/docs/api/Baskets.md +511 -0
- package/docs/api/CDN.md +524 -0
- package/docs/api/Data.md +446 -0
- package/docs/api/Jobs.md +524 -0
- package/docs/api/LuaAgent.md +454 -0
- package/docs/api/LuaJob.md +604 -0
- package/docs/api/LuaSkill.md +396 -0
- package/docs/api/LuaTool.md +521 -0
- package/docs/api/LuaWebhook.md +601 -0
- package/docs/api/Orders.md +514 -0
- package/docs/api/PostProcessor.md +565 -0
- package/docs/api/PreProcessor.md +630 -0
- package/docs/api/Products.md +507 -0
- package/docs/api/Templates.md +662 -0
- package/docs/api/User.md +567 -0
- package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
- package/docs/compiler-v2/ASSESSMENT.md +205 -0
- package/docs/compiler-v2/TEST_PLAN.md +306 -0
- package/package.json +3 -7
- package/template/tsconfig.json +1 -1
- package/dist/common/basket.instance.js.map +0 -1
- package/dist/common/data.entry.instance.js.map +0 -1
- package/dist/common/http.client.js.map +0 -1
- package/dist/common/job.instance.js.map +0 -1
- package/dist/common/order.instance.js.map +0 -1
- package/dist/common/product.instance.js.map +0 -1
- package/dist/common/product.pagination.instance.js.map +0 -1
- package/dist/common/product.search.instance.js.map +0 -1
- package/dist/common/user.instance.js.map +0 -1
- package/dist/config/auth.constants.d.ts +0 -11
- package/dist/config/auth.constants.js +0 -12
- package/dist/config/auth.constants.js.map +0 -1
- package/dist/config/init.constants.d.ts +0 -15
- package/dist/config/init.constants.js +0 -20
- package/dist/config/init.constants.js.map +0 -1
- package/dist/interfaces/compile.d.ts +0 -12
- package/dist/interfaces/compile.js +0 -5
- package/dist/interfaces/compile.js.map +0 -1
- package/dist/types/compile.types.d.ts +0 -131
- package/dist/types/compile.types.js +0 -6
- package/dist/types/compile.types.js.map +0 -1
- package/dist/utils/agent-code-utils.d.ts +0 -25
- package/dist/utils/agent-code-utils.js +0 -107
- package/dist/utils/agent-code-utils.js.map +0 -1
- package/dist/utils/bundling.d.ts +0 -89
- package/dist/utils/bundling.js +0 -1068
- package/dist/utils/bundling.js.map +0 -1
- package/dist/utils/compile.d.ts +0 -116
- package/dist/utils/compile.js +0 -1062
- package/dist/utils/compile.js.map +0 -1
- package/dist/utils/deploy-api.d.ts +0 -26
- package/dist/utils/deploy-api.js +0 -54
- package/dist/utils/deploy-api.js.map +0 -1
- package/dist/utils/deployment.d.ts +0 -26
- package/dist/utils/deployment.js +0 -218
- package/dist/utils/deployment.js.map +0 -1
- package/dist/utils/dev-helpers.d.ts +0 -47
- package/dist/utils/dev-helpers.js +0 -82
- package/dist/utils/dev-helpers.js.map +0 -1
- package/dist/utils/job-management.d.ts +0 -27
- package/dist/utils/job-management.js +0 -248
- package/dist/utils/job-management.js.map +0 -1
- package/dist/utils/mcp-server-management.d.ts +0 -26
- package/dist/utils/mcp-server-management.js +0 -197
- package/dist/utils/mcp-server-management.js.map +0 -1
- package/dist/utils/postprocessor-management.d.ts +0 -9
- package/dist/utils/postprocessor-management.js +0 -117
- package/dist/utils/postprocessor-management.js.map +0 -1
- package/dist/utils/pre-bundle-jobs.d.ts +0 -27
- package/dist/utils/pre-bundle-jobs.js +0 -189
- package/dist/utils/pre-bundle-jobs.js.map +0 -1
- package/dist/utils/preprocessor-management.d.ts +0 -9
- package/dist/utils/preprocessor-management.js +0 -117
- package/dist/utils/preprocessor-management.js.map +0 -1
- package/dist/utils/push-api.d.ts +0 -15
- package/dist/utils/push-api.js +0 -49
- package/dist/utils/push-api.js.map +0 -1
- package/dist/utils/push-helpers.d.ts +0 -82
- package/dist/utils/push-helpers.js +0 -246
- package/dist/utils/push-helpers.js.map +0 -1
- package/dist/utils/skill-management.d.ts +0 -39
- package/dist/utils/skill-management.js +0 -299
- package/dist/utils/skill-management.js.map +0 -1
- package/dist/utils/test-helpers.d.ts +0 -33
- package/dist/utils/test-helpers.js +0 -84
- package/dist/utils/test-helpers.js.map +0 -1
- package/dist/utils/test-prompts.d.ts +0 -23
- package/dist/utils/test-prompts.js +0 -187
- package/dist/utils/test-prompts.js.map +0 -1
- package/dist/utils/tool-detection.d.ts +0 -19
- package/dist/utils/tool-detection.js +0 -125
- package/dist/utils/tool-detection.js.map +0 -1
- package/dist/utils/webhook-management.d.ts +0 -27
- package/dist/utils/webhook-management.js +0 -241
- package/dist/utils/webhook-management.js.map +0 -1
- /package/dist/{common → api}/http.client.d.ts +0 -0
- /package/dist/{common → api}/http.client.js +0 -0
- /package/dist/{common → instances}/basket.instance.d.ts +0 -0
- /package/dist/{common → instances}/basket.instance.js +0 -0
- /package/dist/{common → instances}/data.entry.instance.d.ts +0 -0
- /package/dist/{common → instances}/data.entry.instance.js +0 -0
- /package/dist/{common → instances}/job.instance.d.ts +0 -0
- /package/dist/{common → instances}/job.instance.js +0 -0
- /package/dist/{common → instances}/order.instance.d.ts +0 -0
- /package/dist/{common → instances}/order.instance.js +0 -0
- /package/dist/{common → instances}/product.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.instance.js +0 -0
- /package/dist/{common → instances}/product.pagination.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.pagination.instance.js +0 -0
- /package/dist/{common → instances}/product.search.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.search.instance.js +0 -0
- /package/dist/{common → instances}/user.instance.d.ts +0 -0
- /package/dist/{common → instances}/user.instance.js +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Job compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* BACKWARD COMPATIBLE: Detects BOTH patterns:
|
|
5
|
+
* 1. Class-based (legacy): new LuaJob({ ... })
|
|
6
|
+
* 2. Function-based (new): const myJob = defineJob({ ... })
|
|
7
|
+
*/
|
|
8
|
+
import { Node } from 'ts-morph';
|
|
9
|
+
import { PrimitiveKind, } from '../types.js';
|
|
10
|
+
import { BasePlugin, validationError, validationWarning } from './base.js';
|
|
11
|
+
import { extractStringProperty } from '../utils/ast-helpers.js';
|
|
12
|
+
/**
|
|
13
|
+
* Plugin for compiling job primitives.
|
|
14
|
+
* Extends BasePlugin for common detection/entry point/postProcess logic.
|
|
15
|
+
*/
|
|
16
|
+
export class JobPlugin extends BasePlugin {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.kind = 'job';
|
|
20
|
+
this.displayName = 'Job';
|
|
21
|
+
this.defineFunction = 'defineJob';
|
|
22
|
+
this.legacyClassNames = ['LuaJob'];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract metadata from job config object.
|
|
26
|
+
*/
|
|
27
|
+
extractFromConfig(config, exportName, sourcePath, position, pattern) {
|
|
28
|
+
const common = this.extractCommonFields(config, exportName, sourcePath, position);
|
|
29
|
+
if (!common)
|
|
30
|
+
return null;
|
|
31
|
+
// Extract schedule
|
|
32
|
+
const scheduleNode = config.getProperty('schedule');
|
|
33
|
+
let scheduleType;
|
|
34
|
+
let scheduleExpression;
|
|
35
|
+
if (scheduleNode && Node.isPropertyAssignment(scheduleNode)) {
|
|
36
|
+
const scheduleValue = scheduleNode.getInitializer();
|
|
37
|
+
if (scheduleValue && Node.isObjectLiteralExpression(scheduleValue)) {
|
|
38
|
+
scheduleType = extractStringProperty(scheduleValue, 'type');
|
|
39
|
+
scheduleExpression = extractStringProperty(scheduleValue, 'expression');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Extract timeout value
|
|
43
|
+
let timeoutValue;
|
|
44
|
+
const timeoutNode = config.getProperty('timeout');
|
|
45
|
+
if (timeoutNode && Node.isPropertyAssignment(timeoutNode)) {
|
|
46
|
+
const init = timeoutNode.getInitializer();
|
|
47
|
+
if (init && Node.isNumericLiteral(init)) {
|
|
48
|
+
timeoutValue = Number(init.getText());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Extract retry config
|
|
52
|
+
let retryConfig;
|
|
53
|
+
const retryNode = config.getProperty('retry');
|
|
54
|
+
if (retryNode && Node.isPropertyAssignment(retryNode)) {
|
|
55
|
+
const retryValue = retryNode.getInitializer();
|
|
56
|
+
if (retryValue && Node.isObjectLiteralExpression(retryValue)) {
|
|
57
|
+
retryConfig = {};
|
|
58
|
+
const maxProp = retryValue.getProperty('maxAttempts');
|
|
59
|
+
if (maxProp && Node.isPropertyAssignment(maxProp)) {
|
|
60
|
+
const maxInit = maxProp.getInitializer();
|
|
61
|
+
if (maxInit && Node.isNumericLiteral(maxInit)) {
|
|
62
|
+
retryConfig.maxAttempts = Number(maxInit.getText());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const backoffProp = retryValue.getProperty('backoffSeconds');
|
|
66
|
+
if (backoffProp && Node.isPropertyAssignment(backoffProp)) {
|
|
67
|
+
const backoffInit = backoffProp.getInitializer();
|
|
68
|
+
if (backoffInit && Node.isNumericLiteral(backoffInit)) {
|
|
69
|
+
retryConfig.backoffSeconds = Number(backoffInit.getText());
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
kind: this.kind,
|
|
76
|
+
...common,
|
|
77
|
+
metadata: {
|
|
78
|
+
pattern,
|
|
79
|
+
scheduleType,
|
|
80
|
+
scheduleExpression,
|
|
81
|
+
hasExecute: config.getProperty('execute') !== undefined,
|
|
82
|
+
hasTimeout: config.getProperty('timeout') !== undefined,
|
|
83
|
+
hasRetry: config.getProperty('retry') !== undefined,
|
|
84
|
+
timeoutValue,
|
|
85
|
+
retryConfig,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
validate(metadata) {
|
|
90
|
+
const errors = [];
|
|
91
|
+
const warnings = [];
|
|
92
|
+
if (!metadata.name) {
|
|
93
|
+
errors.push(validationError('Job must have a name', { line: metadata.line }));
|
|
94
|
+
}
|
|
95
|
+
if (!metadata.metadata.hasExecute) {
|
|
96
|
+
errors.push(validationError('Job must have an execute function', { line: metadata.line }));
|
|
97
|
+
}
|
|
98
|
+
if (!metadata.metadata.scheduleType) {
|
|
99
|
+
errors.push(validationError('Job must have a schedule', {
|
|
100
|
+
line: metadata.line,
|
|
101
|
+
suggestion: 'Add a schedule: schedule: { type: "cron", expression: "0 9 * * *" }',
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
if (!metadata.description) {
|
|
105
|
+
warnings.push(validationWarning('Job should have a description', { line: metadata.line }));
|
|
106
|
+
}
|
|
107
|
+
// Validate schedule type
|
|
108
|
+
const validScheduleTypes = ['cron', 'interval', 'once'];
|
|
109
|
+
if (metadata.metadata.scheduleType && !validScheduleTypes.includes(metadata.metadata.scheduleType)) {
|
|
110
|
+
errors.push(validationError(`Invalid schedule type: ${metadata.metadata.scheduleType}. Must be one of: ${validScheduleTypes.join(', ')}`, { line: metadata.line }));
|
|
111
|
+
}
|
|
112
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Add runtime validation for executeFunction (LuaJob uses this internally).
|
|
116
|
+
*/
|
|
117
|
+
getRuntimeValidation() {
|
|
118
|
+
return `
|
|
119
|
+
// LuaJob uses executeFunction internally
|
|
120
|
+
if (typeof primitive.primitive?.executeFunction !== 'function') {
|
|
121
|
+
throw new Error('[Lua] Invalid job artifact: executeFunction is not a function');
|
|
122
|
+
}`;
|
|
123
|
+
}
|
|
124
|
+
toManifestEntry(compiled, _context) {
|
|
125
|
+
const jobMeta = compiled.metadata;
|
|
126
|
+
const job = {
|
|
127
|
+
kind: PrimitiveKind.JOB,
|
|
128
|
+
name: compiled.name,
|
|
129
|
+
description: compiled.description,
|
|
130
|
+
path: `artifacts/${compiled.kind}/${compiled.name}.js`,
|
|
131
|
+
sourcePath: compiled.sourcePath,
|
|
132
|
+
hash: compiled.artifact.hash,
|
|
133
|
+
schedule: jobMeta.scheduleType ? {
|
|
134
|
+
type: jobMeta.scheduleType,
|
|
135
|
+
expression: jobMeta.scheduleExpression,
|
|
136
|
+
} : undefined,
|
|
137
|
+
timeout: jobMeta.timeoutValue,
|
|
138
|
+
retry: jobMeta.retryConfig,
|
|
139
|
+
};
|
|
140
|
+
return job;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=job.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.plugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/job.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA2B,IAAI,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,aAAa,GAQd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,UAA6B;IAA5D;;QACW,SAAI,GAAG,KAAK,CAAC;QACb,gBAAW,GAAG,KAAK,CAAC;QACpB,mBAAc,GAAG,WAAW,CAAC;QAC7B,qBAAgB,GAAG,CAAC,QAAQ,CAAC,CAAC;IA6IzC,CAAC;IA3IC;;OAEG;IACO,iBAAiB,CACzB,MAA+B,EAC/B,UAAkB,EAClB,UAAkB,EAClB,QAA0C,EAC1C,OAA6B;QAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAEzB,mBAAmB;QACnB,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,YAAg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E,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACO,oBAAoB;QAC5B,OAAO;;;;IAIP,CAAC;IACH,CAAC;IAED,eAAe,CAAC,QAA2B,EAAE,QAA0B;QACrE,MAAM,OAAO,GAAG,QAAQ,CAAC,QAA6B,CAAC;QACvD,MAAM,GAAG,GAAgB;YACvB,IAAI,EAAE,aAAa,CAAC,GAAG;YACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,IAAI,EAAE,aAAa,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK;YACtD,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI;YAC5B,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC/B,IAAI,EAAE,OAAO,CAAC,YAAY;gBAC1B,UAAU,EAAE,OAAO,CAAC,kBAAkB;aACvC,CAAC,CAAC,CAAC,SAAS;YACb,OAAO,EAAE,OAAO,CAAC,YAAY;YAC7B,KAAK,EAAE,OAAO,CAAC,WAAW;SAC3B,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* BACKWARD COMPATIBLE: Detects BOTH patterns:
|
|
5
|
+
* 1. Class-based (legacy): new LuaMCPServer({ ... })
|
|
6
|
+
* 2. Function-based (new): const myServer = defineMCPServer({ ... })
|
|
7
|
+
*/
|
|
8
|
+
import { ObjectLiteralExpression } from 'ts-morph';
|
|
9
|
+
import { type MCPServerMetadata, type MCPServerMetadataFields, type ValidationResult, type ManifestContext, type CompiledPrimitive, type ManifestPrimitive } from '../types.js';
|
|
10
|
+
import { BasePlugin } from './base.js';
|
|
11
|
+
/**
|
|
12
|
+
* Plugin for compiling MCP server primitives.
|
|
13
|
+
* Extends BasePlugin for common detection/entry point/postProcess logic.
|
|
14
|
+
*/
|
|
15
|
+
export declare class MCPServerPlugin extends BasePlugin<MCPServerMetadataFields> {
|
|
16
|
+
readonly kind = "mcp-server";
|
|
17
|
+
readonly displayName = "MCP Server";
|
|
18
|
+
readonly defineFunction = "defineMCPServer";
|
|
19
|
+
readonly legacyClassNames: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Extract metadata from MCP server config object.
|
|
22
|
+
*/
|
|
23
|
+
protected extractFromConfig(config: ObjectLiteralExpression, exportName: string, sourcePath: string, position: {
|
|
24
|
+
line: number;
|
|
25
|
+
column: number;
|
|
26
|
+
}, pattern: 'function' | 'class'): MCPServerMetadata | null;
|
|
27
|
+
/**
|
|
28
|
+
* Extract the source text of a resolver function property.
|
|
29
|
+
*/
|
|
30
|
+
private getResolverSource;
|
|
31
|
+
/**
|
|
32
|
+
* Bundle a resolver function into a self-contained, compressed, VM-executable string.
|
|
33
|
+
* This is called during compilation for MCP servers with dynamic resolvers.
|
|
34
|
+
*/
|
|
35
|
+
private bundleResolver;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a property has a resolver function (arrow function or function expression).
|
|
38
|
+
*/
|
|
39
|
+
private hasResolverFunction;
|
|
40
|
+
validate(metadata: MCPServerMetadata): ValidationResult;
|
|
41
|
+
/**
|
|
42
|
+
* Add transport field to the entry point.
|
|
43
|
+
*/
|
|
44
|
+
protected getEntryPointFields(metadata: MCPServerMetadata): string;
|
|
45
|
+
/**
|
|
46
|
+
* Create the manifest entry for an MCP server.
|
|
47
|
+
* Bundles resolver functions (url/headers) if present.
|
|
48
|
+
*/
|
|
49
|
+
toManifestEntry(compiled: CompiledPrimitive, context?: ManifestContext): Promise<ManifestPrimitive>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* BACKWARD COMPATIBLE: Detects BOTH patterns:
|
|
5
|
+
* 1. Class-based (legacy): new LuaMCPServer({ ... })
|
|
6
|
+
* 2. Function-based (new): const myServer = defineMCPServer({ ... })
|
|
7
|
+
*/
|
|
8
|
+
import { Node } from 'ts-morph';
|
|
9
|
+
import { build } from 'esbuild';
|
|
10
|
+
import { PrimitiveKind, } from '../types.js';
|
|
11
|
+
import { BasePlugin, validationError, validationWarning } from './base.js';
|
|
12
|
+
import { extractStringProperty } from '../utils/ast-helpers.js';
|
|
13
|
+
import { compressForPush } from '../../utils/artifact-loader.js';
|
|
14
|
+
/**
|
|
15
|
+
* Plugin for compiling MCP server primitives.
|
|
16
|
+
* Extends BasePlugin for common detection/entry point/postProcess logic.
|
|
17
|
+
*/
|
|
18
|
+
export class MCPServerPlugin extends BasePlugin {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.kind = 'mcp-server';
|
|
22
|
+
this.displayName = 'MCP Server';
|
|
23
|
+
this.defineFunction = 'defineMCPServer';
|
|
24
|
+
this.legacyClassNames = ['LuaMCPServer'];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract metadata from MCP server config object.
|
|
28
|
+
*/
|
|
29
|
+
extractFromConfig(config, exportName, sourcePath, position, pattern) {
|
|
30
|
+
const common = this.extractCommonFields(config, exportName, sourcePath, position);
|
|
31
|
+
if (!common)
|
|
32
|
+
return null;
|
|
33
|
+
const transport = extractStringProperty(config, 'transport') || 'streamable-http';
|
|
34
|
+
const url = extractStringProperty(config, 'url');
|
|
35
|
+
// Check for resolver functions and extract their source text
|
|
36
|
+
const hasUrlResolver = this.hasResolverFunction(config, 'url');
|
|
37
|
+
const hasHeadersResolver = this.hasResolverFunction(config, 'headers');
|
|
38
|
+
const urlResolverSource = hasUrlResolver ? this.getResolverSource(config, 'url') : undefined;
|
|
39
|
+
const headersResolverSource = hasHeadersResolver ? this.getResolverSource(config, 'headers') : undefined;
|
|
40
|
+
return {
|
|
41
|
+
kind: this.kind,
|
|
42
|
+
...common,
|
|
43
|
+
metadata: {
|
|
44
|
+
pattern,
|
|
45
|
+
transport,
|
|
46
|
+
url,
|
|
47
|
+
hasUrlResolver,
|
|
48
|
+
hasHeadersResolver,
|
|
49
|
+
urlResolverSource,
|
|
50
|
+
headersResolverSource,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract the source text of a resolver function property.
|
|
56
|
+
*/
|
|
57
|
+
getResolverSource(config, propName) {
|
|
58
|
+
const prop = config.getProperty(propName);
|
|
59
|
+
if (!prop || !Node.isPropertyAssignment(prop))
|
|
60
|
+
return undefined;
|
|
61
|
+
const value = prop.getInitializer();
|
|
62
|
+
if (!value)
|
|
63
|
+
return undefined;
|
|
64
|
+
if (Node.isArrowFunction(value) || Node.isFunctionExpression(value)) {
|
|
65
|
+
return value.getText();
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Bundle a resolver function into a self-contained, compressed, VM-executable string.
|
|
71
|
+
* This is called during compilation for MCP servers with dynamic resolvers.
|
|
72
|
+
*/
|
|
73
|
+
async bundleResolver(functionCode, resolverType, serverName, outDir) {
|
|
74
|
+
try {
|
|
75
|
+
const moduleCode = `const resolverFunc = ${functionCode};\nexport default resolverFunc;\n`;
|
|
76
|
+
const result = await build({
|
|
77
|
+
stdin: {
|
|
78
|
+
contents: moduleCode,
|
|
79
|
+
resolveDir: outDir,
|
|
80
|
+
loader: 'ts',
|
|
81
|
+
},
|
|
82
|
+
bundle: true,
|
|
83
|
+
platform: 'node',
|
|
84
|
+
target: 'node18',
|
|
85
|
+
format: 'cjs',
|
|
86
|
+
minify: true,
|
|
87
|
+
write: false,
|
|
88
|
+
external: ['zod'],
|
|
89
|
+
});
|
|
90
|
+
const bundledCode = result.outputFiles?.[0]?.text ?? '';
|
|
91
|
+
if (!bundledCode) {
|
|
92
|
+
throw new Error(`esbuild produced empty output for MCP ${resolverType} resolver`);
|
|
93
|
+
}
|
|
94
|
+
// Wrap for VM execution and compress (gzip + base64)
|
|
95
|
+
const wrappedCode = `(async () => {\n ${bundledCode}\n const resolverFunc = module.exports.default || module.exports;\n return resolverFunc();\n})()`;
|
|
96
|
+
return compressForPush(wrappedCode);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.warn(`Warning: Could not bundle MCP ${resolverType} resolver for ${serverName}: ${error.message}`);
|
|
100
|
+
try {
|
|
101
|
+
return compressForPush(`(${functionCode})()`);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if a property has a resolver function (arrow function or function expression).
|
|
110
|
+
*/
|
|
111
|
+
hasResolverFunction(config, propName) {
|
|
112
|
+
const prop = config.getProperty(propName);
|
|
113
|
+
if (!prop || !Node.isPropertyAssignment(prop))
|
|
114
|
+
return false;
|
|
115
|
+
const value = prop.getInitializer();
|
|
116
|
+
if (!value)
|
|
117
|
+
return false;
|
|
118
|
+
return Node.isArrowFunction(value) || Node.isFunctionExpression(value);
|
|
119
|
+
}
|
|
120
|
+
validate(metadata) {
|
|
121
|
+
const errors = [];
|
|
122
|
+
const warnings = [];
|
|
123
|
+
if (!metadata.name) {
|
|
124
|
+
errors.push(validationError('MCP Server must have a name', { line: metadata.line }));
|
|
125
|
+
}
|
|
126
|
+
const transport = metadata.metadata.transport;
|
|
127
|
+
const validTransports = ['streamable-http', 'sse'];
|
|
128
|
+
if (transport === 'stdio') {
|
|
129
|
+
errors.push(validationError('stdio transport is not supported. Use streamable-http or sse instead.', {
|
|
130
|
+
line: metadata.line,
|
|
131
|
+
suggestion: 'Change transport to "streamable-http" (recommended) or "sse"',
|
|
132
|
+
docsUrl: 'https://docs.lua.ai/mcp-servers#transport',
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
else if (!validTransports.includes(transport)) {
|
|
136
|
+
errors.push(validationError(`Invalid transport: ${transport}. Must be one of: ${validTransports.join(', ')}`, { line: metadata.line }));
|
|
137
|
+
}
|
|
138
|
+
if (!metadata.metadata.url && !metadata.metadata.hasUrlResolver) {
|
|
139
|
+
errors.push(validationError('MCP Server must have a url or url resolver', { line: metadata.line }));
|
|
140
|
+
}
|
|
141
|
+
if (!metadata.description) {
|
|
142
|
+
warnings.push(validationWarning('MCP Server should have a description', { line: metadata.line }));
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
valid: errors.length === 0,
|
|
146
|
+
errors,
|
|
147
|
+
warnings,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Add transport field to the entry point.
|
|
152
|
+
*/
|
|
153
|
+
getEntryPointFields(metadata) {
|
|
154
|
+
return `transport: ${JSON.stringify(metadata.metadata.transport)},`;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Create the manifest entry for an MCP server.
|
|
158
|
+
* Bundles resolver functions (url/headers) if present.
|
|
159
|
+
*/
|
|
160
|
+
async toManifestEntry(compiled, context) {
|
|
161
|
+
const mcpMeta = compiled.metadata;
|
|
162
|
+
const outDir = context?.outDir || process.cwd();
|
|
163
|
+
// Bundle resolver functions if present
|
|
164
|
+
let urlResolver;
|
|
165
|
+
let headersResolver;
|
|
166
|
+
if (mcpMeta.urlResolverSource) {
|
|
167
|
+
urlResolver = await this.bundleResolver(mcpMeta.urlResolverSource, 'url', compiled.name, outDir) ?? undefined;
|
|
168
|
+
}
|
|
169
|
+
if (mcpMeta.headersResolverSource) {
|
|
170
|
+
headersResolver = await this.bundleResolver(mcpMeta.headersResolverSource, 'headers', compiled.name, outDir) ?? undefined;
|
|
171
|
+
}
|
|
172
|
+
const mcpServer = {
|
|
173
|
+
kind: PrimitiveKind.MCP_SERVER,
|
|
174
|
+
name: compiled.name,
|
|
175
|
+
description: compiled.description,
|
|
176
|
+
path: `artifacts/${compiled.kind}/${compiled.name}.js`,
|
|
177
|
+
sourcePath: compiled.sourcePath,
|
|
178
|
+
hash: compiled.artifact.hash,
|
|
179
|
+
config: mcpMeta.config,
|
|
180
|
+
urlResolver,
|
|
181
|
+
headersResolver,
|
|
182
|
+
};
|
|
183
|
+
return mcpServer;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=mcp-server.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.plugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/mcp-server.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAA2B,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,aAAa,GAQd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAmC;IAAxE;;QACW,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,YAAY,CAAC;QAC3B,mBAAc,GAAG,iBAAiB,CAAC;QACnC,qBAAgB,GAAG,CAAC,cAAc,CAAC,CAAC;IAmM/C,CAAC;IAjMC;;OAEG;IACO,iBAAiB,CACzB,MAA+B,EAC/B,UAAkB,EAClB,UAAkB,EAClB,QAA0C,EAC1C,OAA6B;QAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAEzB,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,EAAE,WA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AAC,cAAc,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC;QAC5H,CAAC;QAED,MAAM,SAAS,GAAsB;YACnC,IAAI,EAAE,aAAa,CAAC,UAAU;YAC9B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,IAAI,EAAE,aAAa,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK;YACtD,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW;YACX,eAAe;SAChB,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostProcessor compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* Extends ProcessorPluginBase for shared validation and runtime checks.
|
|
5
|
+
* Minimal — just config fields and manifest entry.
|
|
6
|
+
*/
|
|
7
|
+
import { ObjectLiteralExpression } from 'ts-morph';
|
|
8
|
+
import { type PostProcessorMetadata, type PostProcessorMetadataFields, type ManifestContext, type CompiledPrimitive, type ManifestPrimitive } from '../types.js';
|
|
9
|
+
import { ProcessorPluginBase } from './processor-base.js';
|
|
10
|
+
export declare class PostProcessorPlugin extends ProcessorPluginBase<PostProcessorMetadataFields> {
|
|
11
|
+
readonly kind = "postprocessor";
|
|
12
|
+
readonly displayName = "PostProcessor";
|
|
13
|
+
readonly defineFunction = "definePostProcessor";
|
|
14
|
+
readonly legacyClassNames: string[];
|
|
15
|
+
protected extractFromConfig(config: ObjectLiteralExpression, exportName: string, sourcePath: string, position: {
|
|
16
|
+
line: number;
|
|
17
|
+
column: number;
|
|
18
|
+
}, pattern: 'function' | 'class'): PostProcessorMetadata | null;
|
|
19
|
+
toManifestEntry(compiled: CompiledPrimitive, _context?: ManifestContext): ManifestPrimitive;
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostProcessor compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* Extends ProcessorPluginBase for shared validation and runtime checks.
|
|
5
|
+
* Minimal — just config fields and manifest entry.
|
|
6
|
+
*/
|
|
7
|
+
import { PrimitiveKind, } from '../types.js';
|
|
8
|
+
import { ProcessorPluginBase } from './processor-base.js';
|
|
9
|
+
export class PostProcessorPlugin extends ProcessorPluginBase {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.kind = 'postprocessor';
|
|
13
|
+
this.displayName = 'PostProcessor';
|
|
14
|
+
this.defineFunction = 'definePostProcessor';
|
|
15
|
+
this.legacyClassNames = ['PostProcessor', 'LuaPostprocessor'];
|
|
16
|
+
}
|
|
17
|
+
extractFromConfig(config, exportName, sourcePath, position, pattern) {
|
|
18
|
+
const common = this.extractCommonFields(config, exportName, sourcePath, position);
|
|
19
|
+
if (!common)
|
|
20
|
+
return null;
|
|
21
|
+
return {
|
|
22
|
+
kind: this.kind,
|
|
23
|
+
...common,
|
|
24
|
+
metadata: { pattern, hasExecute: config.getProperty('execute') !== undefined },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
toManifestEntry(compiled, _context) {
|
|
28
|
+
const postprocessor = {
|
|
29
|
+
kind: PrimitiveKind.POSTPROCESSOR,
|
|
30
|
+
name: compiled.name,
|
|
31
|
+
description: compiled.description,
|
|
32
|
+
path: `artifacts/${compiled.kind}/${compiled.name}.js`,
|
|
33
|
+
sourcePath: compiled.sourcePath,
|
|
34
|
+
hash: compiled.artifact.hash,
|
|
35
|
+
};
|
|
36
|
+
return postprocessor;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=postprocessor.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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vB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PreProcessor compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* Extends ProcessorPluginBase for shared validation and runtime checks.
|
|
5
|
+
* Only adds: isAsync extraction + isAsync in manifest entry.
|
|
6
|
+
*/
|
|
7
|
+
import { ObjectLiteralExpression } from 'ts-morph';
|
|
8
|
+
import { type PreProcessorMetadata, type PreProcessorMetadataFields, type ManifestContext, type CompiledPrimitive, type ManifestPrimitive } from '../types.js';
|
|
9
|
+
import { ProcessorPluginBase } from './processor-base.js';
|
|
10
|
+
export declare class PreProcessorPlugin extends ProcessorPluginBase<PreProcessorMetadataFields> {
|
|
11
|
+
readonly kind = "preprocessor";
|
|
12
|
+
readonly displayName = "PreProcessor";
|
|
13
|
+
readonly defineFunction = "definePreProcessor";
|
|
14
|
+
readonly legacyClassNames: string[];
|
|
15
|
+
protected extractFromConfig(config: ObjectLiteralExpression, exportName: string, sourcePath: string, position: {
|
|
16
|
+
line: number;
|
|
17
|
+
column: number;
|
|
18
|
+
}, pattern: 'function' | 'class'): PreProcessorMetadata | null;
|
|
19
|
+
toManifestEntry(compiled: CompiledPrimitive, _context?: ManifestContext): ManifestPrimitive;
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PreProcessor compilation plugin.
|
|
3
|
+
*
|
|
4
|
+
* Extends ProcessorPluginBase for shared validation and runtime checks.
|
|
5
|
+
* Only adds: isAsync extraction + isAsync in manifest entry.
|
|
6
|
+
*/
|
|
7
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
8
|
+
import { PrimitiveKind, } from '../types.js';
|
|
9
|
+
import { ProcessorPluginBase } from './processor-base.js';
|
|
10
|
+
export class PreProcessorPlugin extends ProcessorPluginBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.kind = 'preprocessor';
|
|
14
|
+
this.displayName = 'PreProcessor';
|
|
15
|
+
this.defineFunction = 'definePreProcessor';
|
|
16
|
+
this.legacyClassNames = ['PreProcessor', 'LuaPreprocessor'];
|
|
17
|
+
}
|
|
18
|
+
extractFromConfig(config, exportName, sourcePath, position, pattern) {
|
|
19
|
+
const common = this.extractCommonFields(config, exportName, sourcePath, position);
|
|
20
|
+
if (!common)
|
|
21
|
+
return null;
|
|
22
|
+
let isAsync = false;
|
|
23
|
+
const asyncProp = config.getProperty('async');
|
|
24
|
+
if (asyncProp && Node.isPropertyAssignment(asyncProp)) {
|
|
25
|
+
const init = asyncProp.getInitializer();
|
|
26
|
+
if (init)
|
|
27
|
+
isAsync = init.getKind() === SyntaxKind.TrueKeyword;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
kind: this.kind,
|
|
31
|
+
...common,
|
|
32
|
+
metadata: { pattern, hasExecute: config.getProperty('execute') !== undefined, isAsync },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
toManifestEntry(compiled, _context) {
|
|
36
|
+
const preprocessor = {
|
|
37
|
+
kind: PrimitiveKind.PREPROCESSOR,
|
|
38
|
+
name: compiled.name,
|
|
39
|
+
description: compiled.description,
|
|
40
|
+
path: `artifacts/${compiled.kind}/${compiled.name}.js`,
|
|
41
|
+
sourcePath: compiled.sourcePath,
|
|
42
|
+
hash: compiled.artifact.hash,
|
|
43
|
+
isAsync: compiled.metadata?.isAsync ?? false,
|
|
44
|
+
};
|
|
45
|
+
return preprocessor;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=preprocessor.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocessor.plugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/preprocessor.plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA2B,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EACL,aAAa,GAOd,MAAM,aA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ACjC,IAAI,EAAE,aAAa,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK;YACtD,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI;YAC5B,OAAO,EAAG,QAAQ,CAAC,QAAuC,EAAE,OAAO,IAAI,KAAK;SAC7E,CAAC;QACF,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared base class for PreProcessor and PostProcessor plugins.
|
|
3
|
+
*
|
|
4
|
+
* These two plugin types are nearly identical — same validation rules,
|
|
5
|
+
* same runtime checks, same extraction pattern. This base eliminates
|
|
6
|
+
* the duplication while letting each plugin customize:
|
|
7
|
+
* - Config fields (kind, displayName, defineFunction, legacyClassNames)
|
|
8
|
+
* - extractFromConfig() (preprocessor extracts isAsync, postprocessor doesn't)
|
|
9
|
+
* - toManifestEntry() (preprocessor includes isAsync field)
|
|
10
|
+
*/
|
|
11
|
+
import type { ProcessorMetadataFields, PrimitiveMetadata, ValidationResult } from '../types.js';
|
|
12
|
+
import { BasePlugin } from './base.js';
|
|
13
|
+
export declare abstract class ProcessorPluginBase<T extends ProcessorMetadataFields> extends BasePlugin<T> {
|
|
14
|
+
validate(metadata: PrimitiveMetadata<T>): ValidationResult;
|
|
15
|
+
protected getRuntimeValidation(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared base class for PreProcessor and PostProcessor plugins.
|
|
3
|
+
*
|
|
4
|
+
* These two plugin types are nearly identical — same validation rules,
|
|
5
|
+
* same runtime checks, same extraction pattern. This base eliminates
|
|
6
|
+
* the duplication while letting each plugin customize:
|
|
7
|
+
* - Config fields (kind, displayName, defineFunction, legacyClassNames)
|
|
8
|
+
* - extractFromConfig() (preprocessor extracts isAsync, postprocessor doesn't)
|
|
9
|
+
* - toManifestEntry() (preprocessor includes isAsync field)
|
|
10
|
+
*/
|
|
11
|
+
import { BasePlugin, validationError, validationWarning } from './base.js';
|
|
12
|
+
export class ProcessorPluginBase extends BasePlugin {
|
|
13
|
+
validate(metadata) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
const warnings = [];
|
|
16
|
+
if (!metadata.name) {
|
|
17
|
+
errors.push(validationError(`${this.displayName} must have a name`, { line: metadata.line }));
|
|
18
|
+
}
|
|
19
|
+
if (!metadata.metadata?.hasExecute) {
|
|
20
|
+
errors.push(validationError(`${this.displayName} must have an execute function`, { line: metadata.line }));
|
|
21
|
+
}
|
|
22
|
+
if (!metadata.description) {
|
|
23
|
+
warnings.push(validationWarning(`${this.displayName} should have a description`, { line: metadata.line }));
|
|
24
|
+
}
|
|
25
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
26
|
+
}
|
|
27
|
+
getRuntimeValidation() {
|
|
28
|
+
return `
|
|
29
|
+
if (typeof primitive.primitive?.execute !== 'function') {
|
|
30
|
+
throw new Error('[Lua] Invalid ${this.kind} artifact: execute is not a function');
|
|
31
|
+
}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=processor-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor-base.js","sourceRoot":"","sources":["../../../src/compiler/plugins/processor-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE3E,MAAM,OAAgB,mBAAuD,SAAQ,UAAa;IAChG,QAAQ,CAAC,QAA8B;QACrC,MAAM,MAAM,GAA+B,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAiC,EAAE,CAAC;QAElD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,WAAW,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChG,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,WAAW,gCAAgC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7G,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,WAAW,4BAA4B,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7G,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAES,oBAAoB;QAC5B,OAAO;;qCAE0B,IAAI,CAAC,IAAI;IAC1C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin registry for the compilation system.
|
|
3
|
+
*
|
|
4
|
+
* This is where all primitive type plugins are registered.
|
|
5
|
+
* To add a new primitive type:
|
|
6
|
+
* 1. Create a new plugin class implementing CompilationPlugin
|
|
7
|
+
* 2. Import it here
|
|
8
|
+
* 3. Register it in the constructor
|
|
9
|
+
*
|
|
10
|
+
* That's the ONLY place you need to change.
|
|
11
|
+
*/
|
|
12
|
+
import type { CompilationPlugin } from './base.js';
|
|
13
|
+
/**
|
|
14
|
+
* Registry of all compilation plugins.
|
|
15
|
+
*
|
|
16
|
+
* Plugins are looked up by their 'kind' property, which must match
|
|
17
|
+
* the primitive's kind value exactly.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PluginRegistry {
|
|
20
|
+
private plugins;
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Register a plugin.
|
|
24
|
+
* @throws Error if a plugin with the same kind is already registered
|
|
25
|
+
*/
|
|
26
|
+
register(plugin: CompilationPlugin): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get a plugin by kind.
|
|
29
|
+
*/
|
|
30
|
+
get(kind: string): CompilationPlugin | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get all registered plugins.
|
|
33
|
+
*/
|
|
34
|
+
getAll(): CompilationPlugin[];
|
|
35
|
+
/**
|
|
36
|
+
* Get all registered primitive kinds.
|
|
37
|
+
*/
|
|
38
|
+
getAllKinds(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Check if a plugin exists for a kind.
|
|
41
|
+
*/
|
|
42
|
+
has(kind: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Get the number of registered plugins.
|
|
45
|
+
*/
|
|
46
|
+
get size(): number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The global plugin registry instance.
|
|
50
|
+
* Use this in the compiler and CLI.
|
|
51
|
+
*/
|
|
52
|
+
export declare const pluginRegistry: PluginRegistry;
|
|
53
|
+
/**
|
|
54
|
+
* Get all define function names (for detection).
|
|
55
|
+
* E.g., ['defineTool', 'defineJob', 'defineWebhook', ...]
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAllDefineFunctions(): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Get plugin by define function name.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getPluginByDefineFunction(funcName: string): CompilationPlugin | undefined;
|