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,1294 @@
|
|
|
1
|
+
# Lua CLI Development Guide
|
|
2
|
+
|
|
3
|
+
A comprehensive guide for developers and AI assistants working on features and updates in the lua-cli ecosystem.
|
|
4
|
+
|
|
5
|
+
> โ ๏ธ **Important:** After every change to lua-cli, remember to update **lua-dev-docs** (public developer documentation). See [Documentation Checklist](#documentation-checklist-always-do-this).
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
1. [Architecture Overview](#architecture-overview)
|
|
10
|
+
2. [Repository Structure](#repository-structure)
|
|
11
|
+
3. [Adding a New Primitive](#adding-a-new-primitive)
|
|
12
|
+
4. [Modifying an Existing Primitive](#modifying-an-existing-primitive)
|
|
13
|
+
5. [Adding a New API](#adding-a-new-api)
|
|
14
|
+
6. [Modifying an Existing API](#modifying-an-existing-api)
|
|
15
|
+
7. [Adding New CLI Commands](#adding-new-cli-commands)
|
|
16
|
+
8. [Key Patterns](#key-patterns)
|
|
17
|
+
9. [Checklists](#checklists)
|
|
18
|
+
10. [Example Walkthroughs](#example-walkthroughs)
|
|
19
|
+
11. [Commit Message Conventions](#commit-message-conventions)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Architecture Overview
|
|
24
|
+
|
|
25
|
+
The Lua platform is a multi-repository system for building and deploying AI agents. Code written by developers using lua-cli gets compiled, bundled, and executed at runtime by lua-core.
|
|
26
|
+
|
|
27
|
+
### System Architecture Diagram
|
|
28
|
+
|
|
29
|
+
```mermaid
|
|
30
|
+
flowchart TB
|
|
31
|
+
subgraph Developer [Developer Environment]
|
|
32
|
+
DevCode[Developer Code<br/>Skills, Jobs, Webhooks]
|
|
33
|
+
LuaCLI[lua-cli<br/>Compile & Bundle]
|
|
34
|
+
TestSandbox[Test Sandbox VM]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
subgraph LuaAPI [lua-api Gateway]
|
|
38
|
+
AuthMW[Auth Middleware]
|
|
39
|
+
Proxy[Proxy Layer]
|
|
40
|
+
DevServices[Developer Services<br/>Jobs, Webhooks, Processors]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
subgraph LuaAgents [lua-agents]
|
|
44
|
+
SkillsSvc[Skills Service]
|
|
45
|
+
DataSvc[Data Service]
|
|
46
|
+
EcommSvc[Ecommerce Service]
|
|
47
|
+
MCPSvc[MCP Server Service]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
subgraph LuaCore [lua-core Runtime]
|
|
51
|
+
AgentSvc[Agent Service<br/>stream/generate]
|
|
52
|
+
VMExec[VM Execution]
|
|
53
|
+
DynTools[Dynamic Tool Service]
|
|
54
|
+
PromptSvc[Prompt Service]
|
|
55
|
+
ExecSvc[Execution Services<br/>Job, Webhook, Processors]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
subgraph LuaAuth [lua-auth]
|
|
59
|
+
AuthSvc[Auth Service]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
subgraph Supporting [Supporting Services]
|
|
63
|
+
LuaCDN[lua-cdn<br/>File Storage]
|
|
64
|
+
LuaEmail[lua-email<br/>Email Service]
|
|
65
|
+
LuaWhatsApp[lua-whatsapp<br/>Channel Integrations]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
subgraph Channels [External Channels]
|
|
69
|
+
WA[WhatsApp]
|
|
70
|
+
IG[Instagram]
|
|
71
|
+
Slack[Slack]
|
|
72
|
+
Other[Other Channels]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
DevCode --> LuaCLI
|
|
76
|
+
LuaCLI --> TestSandbox
|
|
77
|
+
LuaCLI -->|push/deploy| AuthMW
|
|
78
|
+
AuthMW --> Proxy
|
|
79
|
+
Proxy --> DevServices
|
|
80
|
+
Proxy --> SkillsSvc
|
|
81
|
+
Proxy --> DataSvc
|
|
82
|
+
Proxy --> EcommSvc
|
|
83
|
+
Proxy --> AgentSvc
|
|
84
|
+
AuthMW --> AuthSvc
|
|
85
|
+
|
|
86
|
+
AgentSvc --> VMExec
|
|
87
|
+
AgentSvc --> DynTools
|
|
88
|
+
AgentSvc --> PromptSvc
|
|
89
|
+
VMExec --> ExecSvc
|
|
90
|
+
|
|
91
|
+
WA --> LuaWhatsApp
|
|
92
|
+
IG --> LuaWhatsApp
|
|
93
|
+
Slack --> LuaWhatsApp
|
|
94
|
+
Other --> LuaWhatsApp
|
|
95
|
+
LuaWhatsApp -->|webhook payload| AgentSvc
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Request Flow Diagram
|
|
99
|
+
|
|
100
|
+
```mermaid
|
|
101
|
+
sequenceDiagram
|
|
102
|
+
participant Dev as Developer
|
|
103
|
+
participant CLI as lua-cli
|
|
104
|
+
participant API as lua-api
|
|
105
|
+
participant Agents as lua-agents
|
|
106
|
+
participant Core as lua-core
|
|
107
|
+
participant VM as VM Sandbox
|
|
108
|
+
|
|
109
|
+
Note over Dev,VM: Deployment Flow
|
|
110
|
+
Dev->>CLI: lua push
|
|
111
|
+
CLI->>CLI: Compile & Bundle
|
|
112
|
+
CLI->>API: POST /skills (with bundled code)
|
|
113
|
+
API->>API: Authenticate
|
|
114
|
+
API->>Agents: Store skill/job/webhook
|
|
115
|
+
Agents-->>API: Success
|
|
116
|
+
API-->>CLI: Deployed
|
|
117
|
+
|
|
118
|
+
Note over Dev,VM: Runtime Flow (Agent Request)
|
|
119
|
+
Dev->>API: POST /chat/stream
|
|
120
|
+
API->>Core: Forward to lua-core
|
|
121
|
+
Core->>Core: Resolve tools dynamically
|
|
122
|
+
Core->>VM: Execute tool code
|
|
123
|
+
VM->>VM: APIs available (User, Data, Products, etc.)
|
|
124
|
+
VM-->>Core: Result
|
|
125
|
+
Core-->>API: Response
|
|
126
|
+
API-->>Dev: Streamed response
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Repository Structure
|
|
132
|
+
|
|
133
|
+
### lua-cli
|
|
134
|
+
|
|
135
|
+
The command-line tool for building and deploying Lua agents.
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
lua-cli/
|
|
139
|
+
โโโ src/
|
|
140
|
+
โ โโโ api/ # API services (HTTP-based, for test sandbox)
|
|
141
|
+
โ โ โโโ user.data.api.service.ts
|
|
142
|
+
โ โ โโโ products.api.service.ts
|
|
143
|
+
โ โ โโโ basket.api.service.ts
|
|
144
|
+
โ โ โโโ order.api.service.ts
|
|
145
|
+
โ โ โโโ custom.data.api.service.ts
|
|
146
|
+
โ โ โโโ job.api.service.ts
|
|
147
|
+
โ โ โโโ webhook.api.service.ts
|
|
148
|
+
โ โ โโโ ...
|
|
149
|
+
โ โโโ cli/
|
|
150
|
+
โ โ โโโ command-definitions.ts # CLI command definitions
|
|
151
|
+
โ โโโ commands/ # Command implementations
|
|
152
|
+
โ โ โโโ skills.ts
|
|
153
|
+
โ โ โโโ jobs.ts
|
|
154
|
+
โ โ โโโ webhooks.ts
|
|
155
|
+
โ โ โโโ test.ts
|
|
156
|
+
โ โ โโโ ...
|
|
157
|
+
โ โโโ common/ # Instance classes
|
|
158
|
+
โ โ โโโ user.instance.ts
|
|
159
|
+
โ โ โโโ product.instance.ts
|
|
160
|
+
โ โ โโโ basket.instance.ts
|
|
161
|
+
โ โ โโโ job.instance.ts
|
|
162
|
+
โ โ โโโ ...
|
|
163
|
+
โ โโโ interfaces/ # TypeScript interfaces
|
|
164
|
+
โ โโโ types/
|
|
165
|
+
โ โ โโโ skill.ts # Primitive classes (LuaSkill, LuaJob, etc.)
|
|
166
|
+
โ โ โโโ api-contracts.ts # API contract interfaces
|
|
167
|
+
โ โ โโโ index.ts # Barrel export
|
|
168
|
+
โ โโโ utils/
|
|
169
|
+
โ โ โโโ compile.ts # Code compilation (IMPORTANT)
|
|
170
|
+
โ โ โโโ bundling.ts # Code bundling (IMPORTANT)
|
|
171
|
+
โ โ โโโ sandbox.ts # Test VM sandbox (IMPORTANT)
|
|
172
|
+
โ โโโ api-exports.ts # Public API exports
|
|
173
|
+
โ โโโ index.ts # CLI entry point
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### lua-core
|
|
177
|
+
|
|
178
|
+
The runtime service where agent code executes.
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
lua-core/
|
|
182
|
+
โโโ src/
|
|
183
|
+
โ โโโ controllers/
|
|
184
|
+
โ โ โโโ chat.controller.ts
|
|
185
|
+
โ โ โโโ job.controller.ts
|
|
186
|
+
โ โ โโโ webhook.controller.ts
|
|
187
|
+
โ โโโ services/
|
|
188
|
+
โ โ โโโ agent.service.ts # Main agent request handling
|
|
189
|
+
โ โโโ mastra/
|
|
190
|
+
โ โโโ agents/
|
|
191
|
+
โ โ โโโ base/
|
|
192
|
+
โ โ โโโ base.agent.ts # Base agent template
|
|
193
|
+
โ โโโ common/
|
|
194
|
+
โ โโโ devtools/
|
|
195
|
+
โ โ โโโ apis/ # API services (direct DB calls)
|
|
196
|
+
โ โ โโโ common/ # Instance classes (MUST MATCH lua-cli)
|
|
197
|
+
โ โ โโโ interfaces/ # Types
|
|
198
|
+
โ โ โโโ types/
|
|
199
|
+
โ โโโ services/
|
|
200
|
+
โ โ โโโ execute-function.service.ts
|
|
201
|
+
โ โ โโโ execute.job.service.ts
|
|
202
|
+
โ โ โโโ execute.webhook.service.ts
|
|
203
|
+
โ โ โโโ execute.preprocessor.service.ts
|
|
204
|
+
โ โ โโโ execute.postprocessor.service.ts
|
|
205
|
+
โ โ โโโ dynamic.tool.service.ts
|
|
206
|
+
โ โ โโโ prompt.service.ts
|
|
207
|
+
โ โโโ utils/
|
|
208
|
+
โ โโโ vm-execution.utils.ts # Production VM (IMPORTANT)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### lua-api
|
|
212
|
+
|
|
213
|
+
The API gateway with authentication.
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
lua-api/
|
|
217
|
+
โโโ src/
|
|
218
|
+
โ โโโ controllers/ # API endpoints
|
|
219
|
+
โ โโโ services/
|
|
220
|
+
โ โโโ developer.job.service.ts
|
|
221
|
+
โ โโโ developer.webhook.service.ts
|
|
222
|
+
โ โโโ developer.preprocessor.service.ts
|
|
223
|
+
โ โโโ developer.postprocessor.service.ts
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### lua-agents
|
|
227
|
+
|
|
228
|
+
Business logic for all primitives and APIs.
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
lua-agents/
|
|
232
|
+
โโโ src/
|
|
233
|
+
โ โโโ services/
|
|
234
|
+
โ โโโ agent.service.ts
|
|
235
|
+
โ โโโ skills.service.ts
|
|
236
|
+
โ โโโ data.service.ts
|
|
237
|
+
โ โโโ ecommerce.service.ts
|
|
238
|
+
โ โโโ mcp-server.service.ts
|
|
239
|
+
โ โโโ ...
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Supporting Services
|
|
243
|
+
|
|
244
|
+
These services support specific features and rarely need modification during lua-cli development.
|
|
245
|
+
|
|
246
|
+
#### lua-cdn
|
|
247
|
+
|
|
248
|
+
CDN service for file uploads and downloads. Backs the `CDN` API.
|
|
249
|
+
|
|
250
|
+
**When to modify:**
|
|
251
|
+
- Changing file storage/retrieval logic
|
|
252
|
+
- Adding new file type support
|
|
253
|
+
- Modifying CDN endpoints
|
|
254
|
+
|
|
255
|
+
#### lua-email
|
|
256
|
+
|
|
257
|
+
Email microservice for sending emails.
|
|
258
|
+
|
|
259
|
+
**When to modify:**
|
|
260
|
+
- Adding new email templates
|
|
261
|
+
- Changing email delivery logic
|
|
262
|
+
- Modifying email providers
|
|
263
|
+
|
|
264
|
+
#### lua-whatsapp
|
|
265
|
+
|
|
266
|
+
**Important service** containing all channel integration logic: WhatsApp, Instagram, Facebook Messenger, Slack, Teams, Front, MessageBird, and more.
|
|
267
|
+
|
|
268
|
+
**When to modify:**
|
|
269
|
+
- Adding a new channel integration
|
|
270
|
+
- Changing webhook payload structure (this is where `Lua.request.webhook` payload originates)
|
|
271
|
+
- Modifying message transformation logic
|
|
272
|
+
- Adding channel-specific features
|
|
273
|
+
|
|
274
|
+
**Key responsibility:** This service receives incoming messages from various channels, transforms them into a unified format, and passes the raw webhook payload that becomes available via `Lua.request.webhook` in user code.
|
|
275
|
+
|
|
276
|
+
### Documentation & Examples Repositories
|
|
277
|
+
|
|
278
|
+
> โ ๏ธ These repos **must be updated** for every lua-cli change that affects developers.
|
|
279
|
+
|
|
280
|
+
#### lua-dev-docs (ALWAYS UPDATE)
|
|
281
|
+
|
|
282
|
+
**Public** developer documentation. Update for every functional change.
|
|
283
|
+
|
|
284
|
+
**Important:** lua-cli is a **private repository**. Documentation should:
|
|
285
|
+
- Focus on functional changes (features, API changes, fixes)
|
|
286
|
+
- NOT include internal implementation details
|
|
287
|
+
- Be written from user/developer perspective
|
|
288
|
+
|
|
289
|
+
#### lua-dev-examples
|
|
290
|
+
|
|
291
|
+
**Public** repository with example code. Update when:
|
|
292
|
+
- New features need examples
|
|
293
|
+
- Existing patterns change
|
|
294
|
+
|
|
295
|
+
#### lua-market
|
|
296
|
+
|
|
297
|
+
Marketplace repository (not public). Update when:
|
|
298
|
+
- Marketplace features change
|
|
299
|
+
- Skill/installation functionality is modified
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Adding a New Primitive
|
|
304
|
+
|
|
305
|
+
A "primitive" is a deployable unit like Skill, Job, Webhook, Preprocessor, or Postprocessor.
|
|
306
|
+
|
|
307
|
+
### Example: Adding an "Automation" Primitive
|
|
308
|
+
|
|
309
|
+
#### Step 1: Define Types in lua-cli
|
|
310
|
+
|
|
311
|
+
**`src/types/skill.ts`** - Add the primitive class:
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
export interface LuaAutomationConfig {
|
|
315
|
+
name: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
trigger: AutomationTrigger;
|
|
318
|
+
timeout?: number;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export type AutomationTrigger =
|
|
322
|
+
| { type: 'event'; eventName: string }
|
|
323
|
+
| { type: 'schedule'; cron: string };
|
|
324
|
+
|
|
325
|
+
export class LuaAutomation {
|
|
326
|
+
name: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
trigger: AutomationTrigger;
|
|
329
|
+
timeout?: number;
|
|
330
|
+
execute: (context: AutomationContext) => Promise<any>;
|
|
331
|
+
|
|
332
|
+
constructor(config: LuaAutomationConfig) {
|
|
333
|
+
this.name = config.name;
|
|
334
|
+
this.description = config.description;
|
|
335
|
+
this.trigger = config.trigger;
|
|
336
|
+
this.timeout = config.timeout;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**`src/interfaces/automations.ts`** - Add interfaces:
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
export interface AutomationContext {
|
|
345
|
+
automationId: string;
|
|
346
|
+
triggeredAt: Date;
|
|
347
|
+
metadata: Record<string, any>;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export interface AutomationResponse {
|
|
351
|
+
id: string;
|
|
352
|
+
name: string;
|
|
353
|
+
status: 'active' | 'inactive';
|
|
354
|
+
// ...
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
#### Step 2: Update Compilation Logic
|
|
359
|
+
|
|
360
|
+
**`src/utils/compile.ts`** - Add compilation for the new primitive:
|
|
361
|
+
|
|
362
|
+
Look for existing primitive handling (like `extractJobConfigs`) and add similar:
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
export async function extractAutomationConfigs(
|
|
366
|
+
project: Project,
|
|
367
|
+
indexPath: string
|
|
368
|
+
): Promise<AutomationInfo[]> {
|
|
369
|
+
// Follow the pattern of extractJobConfigs or extractWebhookConfigs
|
|
370
|
+
// 1. Find exports of LuaAutomation type
|
|
371
|
+
// 2. Extract config properties
|
|
372
|
+
// 3. Extract execute function
|
|
373
|
+
// 4. Return structured data
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
#### Step 3: Update Bundling Logic
|
|
378
|
+
|
|
379
|
+
**`src/utils/bundling.ts`** - Add bundling support:
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
export async function bundleAutomations(
|
|
383
|
+
automations: AutomationInfo[],
|
|
384
|
+
dependencies: string[]
|
|
385
|
+
): Promise<BundledAutomation[]> {
|
|
386
|
+
// Follow existing patterns for jobs/webhooks
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
#### Step 4: Add Test Sandbox Execution
|
|
391
|
+
|
|
392
|
+
**`src/utils/sandbox.ts`** - Add execution function:
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
export interface ExecuteAutomationOptions extends SandboxOptions {
|
|
396
|
+
automationCode: string;
|
|
397
|
+
context: AutomationContext;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export async function executeAutomation(
|
|
401
|
+
options: ExecuteAutomationOptions
|
|
402
|
+
): Promise<any> {
|
|
403
|
+
const { automationCode, context } = options;
|
|
404
|
+
const sandbox = createSandbox(options);
|
|
405
|
+
|
|
406
|
+
const commonJsWrapper = `
|
|
407
|
+
const executeFunction = ${automationCode};
|
|
408
|
+
|
|
409
|
+
module.exports = async (context) => {
|
|
410
|
+
try {
|
|
411
|
+
return await executeFunction(context);
|
|
412
|
+
} catch(e) {
|
|
413
|
+
console.error(e);
|
|
414
|
+
return { status: 'error', error: e.message };
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
`;
|
|
418
|
+
|
|
419
|
+
const vmContext = vm.createContext(sandbox);
|
|
420
|
+
// ... execute and return result
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
#### Step 5: Add CLI Commands
|
|
425
|
+
|
|
426
|
+
**`src/cli/command-definitions.ts`**:
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
export const automationsCommands = {
|
|
430
|
+
name: 'automations',
|
|
431
|
+
description: 'Manage automations',
|
|
432
|
+
subcommands: [
|
|
433
|
+
{ name: 'list', description: 'List all automations' },
|
|
434
|
+
{ name: 'test', description: 'Test an automation locally' },
|
|
435
|
+
// ...
|
|
436
|
+
],
|
|
437
|
+
};
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**`src/commands/automations.ts`** - Implement the commands.
|
|
441
|
+
|
|
442
|
+
#### Step 6: Update API Exports
|
|
443
|
+
|
|
444
|
+
**`src/api-exports.ts`**:
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
export {
|
|
448
|
+
LuaAutomation,
|
|
449
|
+
LuaAutomationConfig,
|
|
450
|
+
AutomationTrigger,
|
|
451
|
+
} from './types/skill.js';
|
|
452
|
+
|
|
453
|
+
export {
|
|
454
|
+
AutomationContext,
|
|
455
|
+
AutomationResponse,
|
|
456
|
+
} from './interfaces/automations.js';
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### Step 7: Add Backend Services
|
|
460
|
+
|
|
461
|
+
**lua-api** - Add controller and service:
|
|
462
|
+
- `src/controllers/automation.controller.ts`
|
|
463
|
+
- `src/services/developer.automation.service.ts`
|
|
464
|
+
|
|
465
|
+
**lua-agents** - Add business logic:
|
|
466
|
+
- `src/services/automation.service.ts`
|
|
467
|
+
|
|
468
|
+
**lua-core** - Add execution service:
|
|
469
|
+
- `src/mastra/common/services/execute.automation.service.ts`
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## Modifying an Existing Primitive
|
|
474
|
+
|
|
475
|
+
### Example: Adding a `retryDelay` Field to Jobs
|
|
476
|
+
|
|
477
|
+
#### Step 1: Update Types
|
|
478
|
+
|
|
479
|
+
**`lua-cli/src/types/skill.ts`**:
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
export interface LuaJobConfig {
|
|
483
|
+
name: string;
|
|
484
|
+
description?: string;
|
|
485
|
+
schedule: JobSchedule;
|
|
486
|
+
timeout?: number;
|
|
487
|
+
retry?: { maxAttempts: number; backoffSeconds?: number };
|
|
488
|
+
retryDelay?: number; // NEW FIELD
|
|
489
|
+
metadata?: Record<string, any>;
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
**`lua-cli/src/interfaces/jobs.ts`**:
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
export interface JobData {
|
|
497
|
+
// ... existing fields
|
|
498
|
+
retryDelay?: number; // NEW FIELD
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
#### Step 2: Update Compilation
|
|
503
|
+
|
|
504
|
+
**`lua-cli/src/utils/compile.ts`**:
|
|
505
|
+
|
|
506
|
+
Find the job config extraction code and add handling for the new field:
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
// In extractJobConfigs or similar function
|
|
510
|
+
const retryDelay = configArg.getProperty('retryDelay')?.getInitializer()?.getText();
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
#### Step 3: Update Bundling
|
|
514
|
+
|
|
515
|
+
**`lua-cli/src/utils/bundling.ts`**:
|
|
516
|
+
|
|
517
|
+
Ensure the new field is included in the bundled output.
|
|
518
|
+
|
|
519
|
+
#### Step 4: Update Backend
|
|
520
|
+
|
|
521
|
+
**`lua-api/src/services/developer.job.service.ts`**:
|
|
522
|
+
|
|
523
|
+
Handle the new field in create/update operations.
|
|
524
|
+
|
|
525
|
+
**`lua-core/src/mastra/common/services/execute.job.service.ts`**:
|
|
526
|
+
|
|
527
|
+
Use the new field during job execution.
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
## Adding a New API
|
|
532
|
+
|
|
533
|
+
APIs are services available to user code at runtime (User, Data, Products, etc.).
|
|
534
|
+
|
|
535
|
+
### Example: Adding a "Notifications" API
|
|
536
|
+
|
|
537
|
+
This requires changes in BOTH lua-cli (test) and lua-core (production).
|
|
538
|
+
|
|
539
|
+
#### Step 1: Create API Service in lua-cli
|
|
540
|
+
|
|
541
|
+
**`lua-cli/src/api/notifications.api.service.ts`**:
|
|
542
|
+
|
|
543
|
+
```typescript
|
|
544
|
+
import { HttpClient } from '../common/http.client.js';
|
|
545
|
+
|
|
546
|
+
export default class NotificationsApi extends HttpClient {
|
|
547
|
+
private apiKey: string;
|
|
548
|
+
private agentId: string;
|
|
549
|
+
|
|
550
|
+
constructor(baseUrl: string, apiKey: string, agentId: string) {
|
|
551
|
+
super(baseUrl);
|
|
552
|
+
this.apiKey = apiKey;
|
|
553
|
+
this.agentId = agentId;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async send(userId: string, message: string): Promise<NotificationResult> {
|
|
557
|
+
const response = await this.httpPost<NotificationResult>(
|
|
558
|
+
`/developer/notifications/agent/${this.agentId}`,
|
|
559
|
+
{ userId, message },
|
|
560
|
+
{ Authorization: `Bearer ${this.apiKey}` }
|
|
561
|
+
);
|
|
562
|
+
if (!response.success) {
|
|
563
|
+
throw new Error(response.error?.message || 'Failed to send notification');
|
|
564
|
+
}
|
|
565
|
+
return response.data;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
async getHistory(userId: string): Promise<Notification[]> {
|
|
569
|
+
const response = await this.httpGet<Notification[]>(
|
|
570
|
+
`/developer/notifications/agent/${this.agentId}/user/${userId}`,
|
|
571
|
+
{ Authorization: `Bearer ${this.apiKey}` }
|
|
572
|
+
);
|
|
573
|
+
if (!response.success) {
|
|
574
|
+
throw new Error(response.error?.message || 'Failed to get notifications');
|
|
575
|
+
}
|
|
576
|
+
return response.data || [];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
#### Step 2: Add Interfaces
|
|
582
|
+
|
|
583
|
+
**`lua-cli/src/interfaces/notifications.ts`**:
|
|
584
|
+
|
|
585
|
+
```typescript
|
|
586
|
+
export interface Notification {
|
|
587
|
+
id: string;
|
|
588
|
+
userId: string;
|
|
589
|
+
message: string;
|
|
590
|
+
sentAt: string;
|
|
591
|
+
read: boolean;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export interface NotificationResult {
|
|
595
|
+
id: string;
|
|
596
|
+
success: boolean;
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
#### Step 3: Add to Sandbox
|
|
601
|
+
|
|
602
|
+
**`lua-cli/src/utils/sandbox.ts`**:
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
import NotificationsApi from '../api/notifications.api.service.js';
|
|
606
|
+
|
|
607
|
+
export function createSandbox(options: SandboxOptions): any {
|
|
608
|
+
// ... existing code
|
|
609
|
+
|
|
610
|
+
const notificationsService = new NotificationsApi(BASE_URLS.API, apiKey, agentId);
|
|
611
|
+
|
|
612
|
+
const sandbox = {
|
|
613
|
+
// ... existing APIs
|
|
614
|
+
Notifications: notificationsService,
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
return sandbox;
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
#### Step 4: Export in api-exports.ts
|
|
622
|
+
|
|
623
|
+
**`lua-cli/src/api-exports.ts`**:
|
|
624
|
+
|
|
625
|
+
```typescript
|
|
626
|
+
import {
|
|
627
|
+
// ... existing imports
|
|
628
|
+
getNotificationsInstance,
|
|
629
|
+
} from './api/lazy-instances.js';
|
|
630
|
+
|
|
631
|
+
export const Notifications = {
|
|
632
|
+
async send(userId: string, message: string): Promise<NotificationResult> {
|
|
633
|
+
const instance = await getNotificationsInstance();
|
|
634
|
+
return instance.send(userId, message);
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
async getHistory(userId: string): Promise<Notification[]> {
|
|
638
|
+
const instance = await getNotificationsInstance();
|
|
639
|
+
return instance.getHistory(userId);
|
|
640
|
+
},
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// Also export types
|
|
644
|
+
export { Notification, NotificationResult } from './interfaces/notifications.js';
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
#### Step 5: Create Matching API in lua-core
|
|
648
|
+
|
|
649
|
+
**`lua-core/src/mastra/common/devtools/apis/notifications.api.service.ts`**:
|
|
650
|
+
|
|
651
|
+
```typescript
|
|
652
|
+
// Note: NO HTTP calls - direct service calls
|
|
653
|
+
import { sendNotification, getNotificationHistory } from '../../services/notifications.service';
|
|
654
|
+
|
|
655
|
+
export default class NotificationsApi {
|
|
656
|
+
userId: string;
|
|
657
|
+
agentId: string;
|
|
658
|
+
|
|
659
|
+
constructor(userId: string, agentId: string) {
|
|
660
|
+
this.userId = userId;
|
|
661
|
+
this.agentId = agentId;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async send(targetUserId: string, message: string): Promise<NotificationResult> {
|
|
665
|
+
return await sendNotification(this.agentId, targetUserId, message);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
async getHistory(targetUserId: string): Promise<Notification[]> {
|
|
669
|
+
return await getNotificationHistory(this.agentId, targetUserId);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
#### Step 6: Register in lua-core VM
|
|
675
|
+
|
|
676
|
+
**`lua-core/src/mastra/common/utils/vm-execution.utils.ts`**:
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
import NotificationsApi from '../devtools/apis/notifications.api.service';
|
|
680
|
+
|
|
681
|
+
static createSandboxContext(/* ... */) {
|
|
682
|
+
return {
|
|
683
|
+
// ... existing APIs
|
|
684
|
+
Notifications: new NotificationsApi(userId, agentId),
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
#### Step 7: Implement Backend
|
|
690
|
+
|
|
691
|
+
**lua-agents** - Add business logic service
|
|
692
|
+
**lua-api** - Add endpoints if needed for external access
|
|
693
|
+
|
|
694
|
+
---
|
|
695
|
+
|
|
696
|
+
## Modifying an Existing API
|
|
697
|
+
|
|
698
|
+
### Example: Adding `getProfile()` to User API
|
|
699
|
+
|
|
700
|
+
#### Step 1: Update lua-cli API Service
|
|
701
|
+
|
|
702
|
+
**`lua-cli/src/api/user.data.api.service.ts`**:
|
|
703
|
+
|
|
704
|
+
```typescript
|
|
705
|
+
async getProfile(): Promise<UserProfile> {
|
|
706
|
+
const response = await this.httpGet<UserProfile>(
|
|
707
|
+
`/developer/user/profile/agent/${this.agentId}`,
|
|
708
|
+
{ Authorization: `Bearer ${this.apiKey}` }
|
|
709
|
+
);
|
|
710
|
+
if (!response.success) {
|
|
711
|
+
throw new Error(response.error?.message || 'Failed to get profile');
|
|
712
|
+
}
|
|
713
|
+
return response.data;
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
#### Step 2: Update Instance (if needed)
|
|
718
|
+
|
|
719
|
+
**`lua-cli/src/common/user.instance.ts`**:
|
|
720
|
+
|
|
721
|
+
```typescript
|
|
722
|
+
async getProfile(): Promise<UserProfile> {
|
|
723
|
+
return this.apiService.getProfile();
|
|
724
|
+
}
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
#### Step 3: Update API Exports
|
|
728
|
+
|
|
729
|
+
**`lua-cli/src/api-exports.ts`**:
|
|
730
|
+
|
|
731
|
+
```typescript
|
|
732
|
+
export const User = {
|
|
733
|
+
// ... existing methods
|
|
734
|
+
|
|
735
|
+
async getProfile(): Promise<UserProfile> {
|
|
736
|
+
const instance = await getUserInstance();
|
|
737
|
+
return instance.getProfile();
|
|
738
|
+
},
|
|
739
|
+
};
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
#### Step 4: Update Type Contracts
|
|
743
|
+
|
|
744
|
+
**`lua-cli/src/types/api-contracts.ts`**:
|
|
745
|
+
|
|
746
|
+
```typescript
|
|
747
|
+
export interface UserDataAPI {
|
|
748
|
+
// ... existing methods
|
|
749
|
+
getProfile(): Promise<UserProfile>;
|
|
750
|
+
}
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
#### Step 5: Update lua-core API Service (CRITICAL)
|
|
754
|
+
|
|
755
|
+
**`lua-core/src/mastra/common/devtools/apis/user.data.api.service.ts`**:
|
|
756
|
+
|
|
757
|
+
```typescript
|
|
758
|
+
async getProfile(): Promise<UserProfile> {
|
|
759
|
+
// Direct service call - no HTTP
|
|
760
|
+
return await getUserProfile(this.userId, this.agentId);
|
|
761
|
+
}
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
#### Step 6: Update lua-core Instance
|
|
765
|
+
|
|
766
|
+
**`lua-core/src/mastra/common/devtools/common/user.instance.ts`**:
|
|
767
|
+
|
|
768
|
+
Keep in sync with lua-cli version.
|
|
769
|
+
|
|
770
|
+
#### Step 7: Implement Backend
|
|
771
|
+
|
|
772
|
+
**lua-agents** - Add `getUserProfile()` function in data.service.ts
|
|
773
|
+
|
|
774
|
+
---
|
|
775
|
+
|
|
776
|
+
## Adding New CLI Commands
|
|
777
|
+
|
|
778
|
+
### Example: Adding a `lua analytics` Command
|
|
779
|
+
|
|
780
|
+
#### Step 1: Define Command
|
|
781
|
+
|
|
782
|
+
**`lua-cli/src/cli/command-definitions.ts`**:
|
|
783
|
+
|
|
784
|
+
```typescript
|
|
785
|
+
export const analyticsCommands = {
|
|
786
|
+
name: 'analytics',
|
|
787
|
+
description: 'View agent analytics and metrics',
|
|
788
|
+
subcommands: [
|
|
789
|
+
{
|
|
790
|
+
name: 'overview',
|
|
791
|
+
description: 'Show analytics overview',
|
|
792
|
+
options: [
|
|
793
|
+
{ name: 'period', short: 'p', description: 'Time period (7d, 30d, 90d)', default: '7d' },
|
|
794
|
+
],
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
name: 'export',
|
|
798
|
+
description: 'Export analytics data',
|
|
799
|
+
options: [
|
|
800
|
+
{ name: 'format', short: 'f', description: 'Export format (json, csv)', default: 'json' },
|
|
801
|
+
],
|
|
802
|
+
},
|
|
803
|
+
],
|
|
804
|
+
};
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
#### Step 2: Implement Command
|
|
808
|
+
|
|
809
|
+
**`lua-cli/src/commands/analytics.ts`**:
|
|
810
|
+
|
|
811
|
+
```typescript
|
|
812
|
+
import { Command } from 'commander';
|
|
813
|
+
import { getCredentials } from '../api/credentials.js';
|
|
814
|
+
|
|
815
|
+
export function registerAnalyticsCommands(program: Command) {
|
|
816
|
+
const analytics = program
|
|
817
|
+
.command('analytics')
|
|
818
|
+
.description('View agent analytics and metrics');
|
|
819
|
+
|
|
820
|
+
analytics
|
|
821
|
+
.command('overview')
|
|
822
|
+
.description('Show analytics overview')
|
|
823
|
+
.option('-p, --period <period>', 'Time period', '7d')
|
|
824
|
+
.action(async (options) => {
|
|
825
|
+
const credentials = await getCredentials();
|
|
826
|
+
// Implement analytics fetching and display
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
analytics
|
|
830
|
+
.command('export')
|
|
831
|
+
.description('Export analytics data')
|
|
832
|
+
.option('-f, --format <format>', 'Export format', 'json')
|
|
833
|
+
.action(async (options) => {
|
|
834
|
+
// Implement export logic
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
#### Step 3: Register in Index
|
|
840
|
+
|
|
841
|
+
**`lua-cli/src/commands/index.ts`**:
|
|
842
|
+
|
|
843
|
+
```typescript
|
|
844
|
+
export { registerAnalyticsCommands } from './analytics.js';
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
**`lua-cli/src/index.ts`**:
|
|
848
|
+
|
|
849
|
+
```typescript
|
|
850
|
+
import { registerAnalyticsCommands } from './commands/index.js';
|
|
851
|
+
|
|
852
|
+
// In the main function
|
|
853
|
+
registerAnalyticsCommands(program);
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
## Key Patterns
|
|
859
|
+
|
|
860
|
+
### VM Sandbox Pattern
|
|
861
|
+
|
|
862
|
+
Both `sandbox.ts` (lua-cli) and `vm-execution.utils.ts` (lua-core) must expose identical APIs:
|
|
863
|
+
|
|
864
|
+
```typescript
|
|
865
|
+
// APIs available in user code:
|
|
866
|
+
User // User data management
|
|
867
|
+
Data // Custom data collections
|
|
868
|
+
Products // Product catalog
|
|
869
|
+
Baskets // Shopping baskets
|
|
870
|
+
Orders // Order management
|
|
871
|
+
Jobs // Job scheduling
|
|
872
|
+
Templates // Message templates (Templates.whatsapp)
|
|
873
|
+
CDN // File upload/download
|
|
874
|
+
AI // AI generation
|
|
875
|
+
Lua // Runtime context (Lua.request.channel)
|
|
876
|
+
env() // Environment variables
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
### API Service Pattern Differences
|
|
880
|
+
|
|
881
|
+
| Aspect | lua-cli (Test) | lua-core (Production) |
|
|
882
|
+
|--------|----------------|----------------------|
|
|
883
|
+
| Authentication | API key in headers | User context from request |
|
|
884
|
+
| Communication | HTTP calls to lua-api | Direct function calls |
|
|
885
|
+
| Constructor | `(baseUrl, apiKey, agentId)` | `(userId, agentId)` |
|
|
886
|
+
|
|
887
|
+
### Type Export Chain
|
|
888
|
+
|
|
889
|
+
When adding types, update in this order:
|
|
890
|
+
|
|
891
|
+
1. `src/interfaces/*.ts` - Create/update interface file
|
|
892
|
+
2. `src/types/api-contracts.ts` - Add API contract interface
|
|
893
|
+
3. `src/types/index.ts` - Add to barrel export
|
|
894
|
+
4. `src/api-exports.ts` - Export for public use
|
|
895
|
+
|
|
896
|
+
---
|
|
897
|
+
|
|
898
|
+
## Checklists
|
|
899
|
+
|
|
900
|
+
### New Primitive Checklist
|
|
901
|
+
|
|
902
|
+
- [ ] **lua-cli Types**
|
|
903
|
+
- [ ] Add class in `src/types/skill.ts`
|
|
904
|
+
- [ ] Add interfaces in `src/interfaces/`
|
|
905
|
+
- [ ] Export in `src/api-exports.ts`
|
|
906
|
+
- [ ] Export in `src/types/index.ts`
|
|
907
|
+
- [ ] **lua-cli Compile/Bundle**
|
|
908
|
+
- [ ] Add extraction in `src/utils/compile.ts`
|
|
909
|
+
- [ ] Add bundling in `src/utils/bundling.ts`
|
|
910
|
+
- [ ] **lua-cli Sandbox**
|
|
911
|
+
- [ ] Add execution function in `src/utils/sandbox.ts`
|
|
912
|
+
- [ ] **lua-cli Commands**
|
|
913
|
+
- [ ] Add command definition in `src/cli/command-definitions.ts`
|
|
914
|
+
- [ ] Implement command in `src/commands/`
|
|
915
|
+
- [ ] Export in `src/commands/index.ts`
|
|
916
|
+
- [ ] **lua-api**
|
|
917
|
+
- [ ] Add controller
|
|
918
|
+
- [ ] Add developer service
|
|
919
|
+
- [ ] **lua-agents**
|
|
920
|
+
- [ ] Add business logic service
|
|
921
|
+
- [ ] **lua-core**
|
|
922
|
+
- [ ] Add execution service in `src/mastra/common/services/`
|
|
923
|
+
- [ ] Add controller if needed
|
|
924
|
+
- [ ] **Documentation** (see Documentation Checklist below)
|
|
925
|
+
|
|
926
|
+
### New API Checklist
|
|
927
|
+
|
|
928
|
+
- [ ] **lua-cli**
|
|
929
|
+
- [ ] Create API service in `src/api/`
|
|
930
|
+
- [ ] Create instance class in `src/common/` (if needed)
|
|
931
|
+
- [ ] Add interfaces in `src/interfaces/`
|
|
932
|
+
- [ ] Add type contract in `src/types/api-contracts.ts`
|
|
933
|
+
- [ ] Register in `src/utils/sandbox.ts`
|
|
934
|
+
- [ ] Export in `src/api-exports.ts`
|
|
935
|
+
- [ ] Add lazy instance getter in `src/api/lazy-instances.ts`
|
|
936
|
+
- [ ] **lua-core** (MUST MATCH lua-cli)
|
|
937
|
+
- [ ] Create API service in `src/mastra/common/devtools/apis/`
|
|
938
|
+
- [ ] Create instance class in `src/mastra/common/devtools/common/`
|
|
939
|
+
- [ ] Add interfaces in `src/mastra/common/devtools/interfaces/`
|
|
940
|
+
- [ ] Register in `src/mastra/common/utils/vm-execution.utils.ts`
|
|
941
|
+
- [ ] **Backend**
|
|
942
|
+
- [ ] Implement in lua-agents
|
|
943
|
+
- [ ] Add endpoints in lua-api (if external access needed)
|
|
944
|
+
- [ ] **Documentation** (see Documentation Checklist below)
|
|
945
|
+
|
|
946
|
+
### API Modification Checklist
|
|
947
|
+
|
|
948
|
+
- [ ] **lua-cli**
|
|
949
|
+
- [ ] Update API service method
|
|
950
|
+
- [ ] Update instance class (if applicable)
|
|
951
|
+
- [ ] Update type contract
|
|
952
|
+
- [ ] Update exports
|
|
953
|
+
- [ ] **lua-core** (KEEP IN SYNC!)
|
|
954
|
+
- [ ] Update API service method
|
|
955
|
+
- [ ] Update instance class
|
|
956
|
+
- [ ] **Backend**
|
|
957
|
+
- [ ] Update lua-agents service
|
|
958
|
+
- [ ] Update lua-api endpoint (if applicable)
|
|
959
|
+
- [ ] **Documentation** (see Documentation Checklist below)
|
|
960
|
+
|
|
961
|
+
### CLI Command Checklist
|
|
962
|
+
|
|
963
|
+
- [ ] Add command definition in `src/cli/command-definitions.ts`
|
|
964
|
+
- [ ] Implement command in `src/commands/`
|
|
965
|
+
- [ ] Export in `src/commands/index.ts`
|
|
966
|
+
- [ ] Register in `src/index.ts`
|
|
967
|
+
- [ ] Add any required API services
|
|
968
|
+
- [ ] **Documentation** (see below)
|
|
969
|
+
|
|
970
|
+
### Documentation Checklist (ALWAYS DO THIS)
|
|
971
|
+
|
|
972
|
+
> โ ๏ธ **Critical:** Documentation must be updated for **every change** to lua-cli, even if a new version hasn't been published yet.
|
|
973
|
+
|
|
974
|
+
- [ ] **lua-dev-docs** (Public developer docs - ALWAYS UPDATE)
|
|
975
|
+
- [ ] Document new features, API changes, or bug fixes
|
|
976
|
+
- [ ] Write from user/developer perspective
|
|
977
|
+
- [ ] Focus on **functional changes only** (lua-cli is a private repo - no internal implementation details!)
|
|
978
|
+
- [ ] Include code examples where helpful
|
|
979
|
+
- [ ] **lua-dev-examples** (Public examples repo)
|
|
980
|
+
- [ ] Add examples for new features
|
|
981
|
+
- [ ] Update existing examples if patterns changed
|
|
982
|
+
- [ ] **lua-market** (Marketplace repo)
|
|
983
|
+
- [ ] Update if marketplace-related features changed
|
|
984
|
+
|
|
985
|
+
**What belongs in lua-dev-docs:**
|
|
986
|
+
- New features and how to use them
|
|
987
|
+
- API additions/changes with examples
|
|
988
|
+
- Bug fixes affecting user behavior
|
|
989
|
+
- Breaking changes and migration guides
|
|
990
|
+
|
|
991
|
+
**What does NOT belong in lua-dev-docs:**
|
|
992
|
+
- Internal implementation details
|
|
993
|
+
- Technical details about lua-cli codebase
|
|
994
|
+
- Service-to-service communication internals
|
|
995
|
+
- Code architecture decisions
|
|
996
|
+
|
|
997
|
+
---
|
|
998
|
+
|
|
999
|
+
## Example Walkthroughs
|
|
1000
|
+
|
|
1001
|
+
### Walkthrough 1: Adding `sendReminder()` to User API
|
|
1002
|
+
|
|
1003
|
+
**Goal**: Allow sending reminder messages to users.
|
|
1004
|
+
|
|
1005
|
+
**Step 1**: Add to lua-cli API service
|
|
1006
|
+
|
|
1007
|
+
```typescript
|
|
1008
|
+
// lua-cli/src/api/user.data.api.service.ts
|
|
1009
|
+
async sendReminder(message: string, scheduleAt?: Date): Promise<ReminderResult> {
|
|
1010
|
+
const response = await this.httpPost<ReminderResult>(
|
|
1011
|
+
`/developer/user/reminder/agent/${this.agentId}`,
|
|
1012
|
+
{ message, scheduleAt: scheduleAt?.toISOString() },
|
|
1013
|
+
{ Authorization: `Bearer ${this.apiKey}` }
|
|
1014
|
+
);
|
|
1015
|
+
if (!response.success) {
|
|
1016
|
+
throw new Error(response.error?.message || 'Failed to send reminder');
|
|
1017
|
+
}
|
|
1018
|
+
return response.data;
|
|
1019
|
+
}
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
**Step 2**: Add interface
|
|
1023
|
+
|
|
1024
|
+
```typescript
|
|
1025
|
+
// lua-cli/src/interfaces/user.ts
|
|
1026
|
+
export interface ReminderResult {
|
|
1027
|
+
id: string;
|
|
1028
|
+
scheduledAt: string;
|
|
1029
|
+
status: 'scheduled' | 'sent';
|
|
1030
|
+
}
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
**Step 3**: Export in api-exports.ts
|
|
1034
|
+
|
|
1035
|
+
```typescript
|
|
1036
|
+
// lua-cli/src/api-exports.ts
|
|
1037
|
+
export const User = {
|
|
1038
|
+
// ... existing
|
|
1039
|
+
async sendReminder(message: string, scheduleAt?: Date): Promise<ReminderResult> {
|
|
1040
|
+
const instance = await getUserInstance();
|
|
1041
|
+
return instance.sendReminder(message, scheduleAt);
|
|
1042
|
+
},
|
|
1043
|
+
};
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
**Step 4**: Add to lua-core (CRITICAL - must match!)
|
|
1047
|
+
|
|
1048
|
+
```typescript
|
|
1049
|
+
// lua-core/src/mastra/common/devtools/apis/user.data.api.service.ts
|
|
1050
|
+
async sendReminder(message: string, scheduleAt?: Date): Promise<ReminderResult> {
|
|
1051
|
+
return await sendUserReminder(this.userId, this.agentId, message, scheduleAt);
|
|
1052
|
+
}
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
**Step 5**: Implement backend
|
|
1056
|
+
|
|
1057
|
+
```typescript
|
|
1058
|
+
// lua-agents/src/services/data.service.ts
|
|
1059
|
+
export async function sendUserReminder(
|
|
1060
|
+
userId: string,
|
|
1061
|
+
agentId: string,
|
|
1062
|
+
message: string,
|
|
1063
|
+
scheduleAt?: Date
|
|
1064
|
+
): Promise<ReminderResult> {
|
|
1065
|
+
// Implementation
|
|
1066
|
+
}
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
### Walkthrough 2: Adding a `metadata` Field to Webhooks
|
|
1070
|
+
|
|
1071
|
+
**Goal**: Allow webhooks to store custom metadata.
|
|
1072
|
+
|
|
1073
|
+
**Step 1**: Update type definition
|
|
1074
|
+
|
|
1075
|
+
```typescript
|
|
1076
|
+
// lua-cli/src/types/skill.ts
|
|
1077
|
+
export interface LuaWebhookConfig {
|
|
1078
|
+
name: string;
|
|
1079
|
+
description?: string;
|
|
1080
|
+
path?: string;
|
|
1081
|
+
metadata?: Record<string, any>; // NEW
|
|
1082
|
+
}
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
**Step 2**: Update interface
|
|
1086
|
+
|
|
1087
|
+
```typescript
|
|
1088
|
+
// lua-cli/src/interfaces/webhooks.ts
|
|
1089
|
+
export interface WebhookData {
|
|
1090
|
+
// ... existing
|
|
1091
|
+
metadata?: Record<string, any>; // NEW
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
**Step 3**: Update compilation
|
|
1096
|
+
|
|
1097
|
+
```typescript
|
|
1098
|
+
// lua-cli/src/utils/compile.ts
|
|
1099
|
+
// In extractWebhookConfigs function, add:
|
|
1100
|
+
const metadata = configArg.getProperty('metadata')?.getInitializer()?.getText();
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
**Step 4**: Update bundling
|
|
1104
|
+
|
|
1105
|
+
```typescript
|
|
1106
|
+
// lua-cli/src/utils/bundling.ts
|
|
1107
|
+
// Ensure metadata is included in bundled webhook data
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
**Step 5**: Update backend services
|
|
1111
|
+
|
|
1112
|
+
- `lua-api/src/services/developer.webhook.service.ts`
|
|
1113
|
+
- `lua-core/src/mastra/common/services/execute.webhook.service.ts`
|
|
1114
|
+
|
|
1115
|
+
---
|
|
1116
|
+
|
|
1117
|
+
## Common Issues and Solutions
|
|
1118
|
+
|
|
1119
|
+
### Issue: API not available in user code
|
|
1120
|
+
|
|
1121
|
+
**Cause**: Missing registration in sandbox context.
|
|
1122
|
+
|
|
1123
|
+
**Solution**: Check both:
|
|
1124
|
+
- `lua-cli/src/utils/sandbox.ts` - `createSandbox` function
|
|
1125
|
+
- `lua-core/src/mastra/common/utils/vm-execution.utils.ts` - `createSandboxContext` function
|
|
1126
|
+
|
|
1127
|
+
### Issue: Type errors after adding new API method
|
|
1128
|
+
|
|
1129
|
+
**Cause**: Type contract not updated.
|
|
1130
|
+
|
|
1131
|
+
**Solution**: Update `src/types/api-contracts.ts` with the new method signature.
|
|
1132
|
+
|
|
1133
|
+
### Issue: Test works but production fails
|
|
1134
|
+
|
|
1135
|
+
**Cause**: lua-core API service not updated to match lua-cli.
|
|
1136
|
+
|
|
1137
|
+
**Solution**: Ensure both API services have identical method signatures.
|
|
1138
|
+
|
|
1139
|
+
### Issue: Compilation fails for new primitive
|
|
1140
|
+
|
|
1141
|
+
**Cause**: Missing handling in compile.ts.
|
|
1142
|
+
|
|
1143
|
+
**Solution**:
|
|
1144
|
+
1. Read entire compile.ts to understand patterns
|
|
1145
|
+
2. Add extraction function following existing patterns
|
|
1146
|
+
3. Handle edge cases (optional fields, default values)
|
|
1147
|
+
|
|
1148
|
+
---
|
|
1149
|
+
|
|
1150
|
+
## Testing Changes
|
|
1151
|
+
|
|
1152
|
+
### Local Testing with lua-cli
|
|
1153
|
+
|
|
1154
|
+
```bash
|
|
1155
|
+
# Test a skill
|
|
1156
|
+
lua test skill <skill-name>
|
|
1157
|
+
|
|
1158
|
+
# Test a job
|
|
1159
|
+
lua test job <job-name>
|
|
1160
|
+
|
|
1161
|
+
# Test a webhook
|
|
1162
|
+
lua test webhook <webhook-name> --body '{"key": "value"}'
|
|
1163
|
+
|
|
1164
|
+
# Test a preprocessor
|
|
1165
|
+
lua test preprocessor <name> --message "test message"
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
### Verifying Synchronization
|
|
1169
|
+
|
|
1170
|
+
After making changes, verify:
|
|
1171
|
+
|
|
1172
|
+
1. **API methods match** between lua-cli and lua-core
|
|
1173
|
+
2. **Instance classes match** between lua-cli and lua-core
|
|
1174
|
+
3. **Types are exported** in api-exports.ts
|
|
1175
|
+
4. **Sandbox context** includes all APIs
|
|
1176
|
+
|
|
1177
|
+
---
|
|
1178
|
+
|
|
1179
|
+
---
|
|
1180
|
+
|
|
1181
|
+
## Commit Message Conventions
|
|
1182
|
+
|
|
1183
|
+
lua-cli uses **conventional commits** with a changelog-friendly format. Commit messages are used to auto-generate the changelog for releases, so following the correct format is important.
|
|
1184
|
+
|
|
1185
|
+
### Format
|
|
1186
|
+
|
|
1187
|
+
```
|
|
1188
|
+
<type>(<scope>): <description>
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
### Commit Types
|
|
1192
|
+
|
|
1193
|
+
| Type | Description | Changelog Section |
|
|
1194
|
+
|------|-------------|-------------------|
|
|
1195
|
+
| `feat` | New feature | โจ New Features |
|
|
1196
|
+
| `fix` | Bug fix | ๐ Bug Fixes |
|
|
1197
|
+
| `refactor` | Code refactoring (no behavior change) | ๐ Refactoring |
|
|
1198
|
+
| `docs` | Documentation changes | ๐ Documentation |
|
|
1199
|
+
| `chore` | Maintenance, tooling, releases | (often not in changelog) |
|
|
1200
|
+
| `test` | Adding or updating tests | ๐งช Tests |
|
|
1201
|
+
| `perf` | Performance improvements | โก Performance |
|
|
1202
|
+
|
|
1203
|
+
### Scope Guidelines
|
|
1204
|
+
|
|
1205
|
+
Use the primary affected area as scope:
|
|
1206
|
+
|
|
1207
|
+
**Primitives:**
|
|
1208
|
+
- `skills`, `jobs`, `webhooks`, `preprocessors`, `postprocessors`, `mcp`
|
|
1209
|
+
|
|
1210
|
+
**Core Systems:**
|
|
1211
|
+
- `compile` - Compilation logic
|
|
1212
|
+
- `bundling` - Bundling logic
|
|
1213
|
+
- `sandbox` - Test sandbox VM
|
|
1214
|
+
|
|
1215
|
+
**APIs:**
|
|
1216
|
+
- `products`, `baskets`, `orders`, `data`, `user`, `templates`, `cdn`
|
|
1217
|
+
|
|
1218
|
+
**Commands:**
|
|
1219
|
+
- `chat`, `sync`, `push`, `test`, `deploy`, `init`, `logs`
|
|
1220
|
+
|
|
1221
|
+
**Other:**
|
|
1222
|
+
- `runtime` - Lua runtime API
|
|
1223
|
+
- `marketplace` - Marketplace features
|
|
1224
|
+
- `release` - Version releases
|
|
1225
|
+
|
|
1226
|
+
### Examples
|
|
1227
|
+
|
|
1228
|
+
```bash
|
|
1229
|
+
# New features
|
|
1230
|
+
feat(compile): add variable reference and path alias resolution
|
|
1231
|
+
feat(mcp): add streamable-http transport, block stdio (not supported yet)
|
|
1232
|
+
feat(products): add filter support to Products.get() with backward compatibility
|
|
1233
|
+
feat(runtime): add Lua.request.webhook for raw webhook payload access
|
|
1234
|
+
|
|
1235
|
+
# Bug fixes
|
|
1236
|
+
fix(push): handle undefined version when pushing primitives without version field
|
|
1237
|
+
fix(sync): fix persistent drift detection issues
|
|
1238
|
+
fix(compile): normalize skill metadata property naming
|
|
1239
|
+
|
|
1240
|
+
# Refactoring
|
|
1241
|
+
refactor(commands): normalize action handling across multiple command files
|
|
1242
|
+
refactor(agent): centralize persona handling and simplify yaml
|
|
1243
|
+
refactor(init): simplify agent creation, remove deprecated persona prompts
|
|
1244
|
+
|
|
1245
|
+
# Documentation
|
|
1246
|
+
docs(api): update User API documentation with new methods
|
|
1247
|
+
|
|
1248
|
+
# Tests
|
|
1249
|
+
test(compile): add comprehensive tests for configuration extraction
|
|
1250
|
+
|
|
1251
|
+
# Releases
|
|
1252
|
+
chore(release): lua-cli v3.4.0
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
### Writing Good Commit Messages
|
|
1256
|
+
|
|
1257
|
+
1. **Be specific** - Describe what changed, not just the file
|
|
1258
|
+
- Good: `feat(products): add filter support to Products.get()`
|
|
1259
|
+
- Bad: `feat(products): update products`
|
|
1260
|
+
|
|
1261
|
+
2. **Use imperative mood** - "add" not "added" or "adds"
|
|
1262
|
+
- Good: `fix(sync): handle edge case for empty configs`
|
|
1263
|
+
- Bad: `fix(sync): fixed edge case handling`
|
|
1264
|
+
|
|
1265
|
+
3. **Keep it concise** - First line under 72 characters
|
|
1266
|
+
- Use body for additional details if needed
|
|
1267
|
+
|
|
1268
|
+
4. **Reference issues** - If fixing a bug from an issue
|
|
1269
|
+
- `fix(compile): resolve path alias in nested imports (#123)`
|
|
1270
|
+
|
|
1271
|
+
### Pre-release Commits
|
|
1272
|
+
|
|
1273
|
+
For alpha/beta releases, use descriptive version commits:
|
|
1274
|
+
|
|
1275
|
+
```bash
|
|
1276
|
+
v3.2.0-alpha.1: Sync Command, Chat Clear, Lua Runtime API
|
|
1277
|
+
v3.2.0-alpha.2: Fix Skill Metadata Property Naming
|
|
1278
|
+
```
|
|
1279
|
+
|
|
1280
|
+
### Checking Existing Patterns
|
|
1281
|
+
|
|
1282
|
+
Before committing, check recent history to match the style:
|
|
1283
|
+
|
|
1284
|
+
```bash
|
|
1285
|
+
git log --oneline -20
|
|
1286
|
+
```
|
|
1287
|
+
|
|
1288
|
+
---
|
|
1289
|
+
|
|
1290
|
+
## Additional Resources
|
|
1291
|
+
|
|
1292
|
+
- [API Index](./API_INDEX.md) - Complete API reference
|
|
1293
|
+
- [Lua CLI README](../README.md) - Getting started guide
|
|
1294
|
+
- [Changelog](../CHANGELOG_V3.md) - Version history
|