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,601 @@
|
|
|
1
|
+
# LuaWebhook
|
|
2
|
+
|
|
3
|
+
The `LuaWebhook` class defines HTTP endpoints that can receive external requests with validated query parameters, headers, and body. Use webhooks to integrate with external services and trigger agent actions.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { LuaWebhook } from 'lua-cli';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Webhooks enable:
|
|
15
|
+
- Receive HTTP requests from external services
|
|
16
|
+
- Validate query parameters, headers, and body
|
|
17
|
+
- Process events from third-party platforms
|
|
18
|
+
- Trigger agent actions based on external events
|
|
19
|
+
- Build integrations with APIs and services
|
|
20
|
+
|
|
21
|
+
## Class Definition
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
class LuaWebhook {
|
|
25
|
+
constructor(config: LuaWebhookConfig);
|
|
26
|
+
getName(): string;
|
|
27
|
+
getDescription(): string;
|
|
28
|
+
execute(query?, headers?, body?): Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
interface LuaWebhookConfig {
|
|
36
|
+
/** Webhook name (optional, defaults to 'unnamed-webhook') */
|
|
37
|
+
name?: string;
|
|
38
|
+
|
|
39
|
+
/** Short description of the webhook (1-2 sentences) */
|
|
40
|
+
description: string;
|
|
41
|
+
|
|
42
|
+
/** Optional Zod schema for query parameter validation */
|
|
43
|
+
querySchema?: ZodType;
|
|
44
|
+
|
|
45
|
+
/** Optional Zod schema for header validation */
|
|
46
|
+
headerSchema?: ZodType;
|
|
47
|
+
|
|
48
|
+
/** Optional Zod schema for body validation */
|
|
49
|
+
bodySchema?: ZodType;
|
|
50
|
+
|
|
51
|
+
/** Function that executes the webhook logic */
|
|
52
|
+
execute: (event: LuaWebhookEvent) => Promise<any>;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Event Structure
|
|
57
|
+
|
|
58
|
+
The `execute` function receives a `LuaWebhookEvent`:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
interface LuaWebhookEvent {
|
|
62
|
+
/** Parsed query parameters */
|
|
63
|
+
query?: Record<string, any>;
|
|
64
|
+
|
|
65
|
+
/** Request headers */
|
|
66
|
+
headers?: Record<string, any>;
|
|
67
|
+
|
|
68
|
+
/** Request body (JSON or raw data) */
|
|
69
|
+
body?: any;
|
|
70
|
+
|
|
71
|
+
/** ISO timestamp when the webhook was received */
|
|
72
|
+
timestamp: string;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Complete Examples
|
|
77
|
+
|
|
78
|
+
### GitHub Webhook
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { LuaWebhook, User, Data } from 'lua-cli';
|
|
82
|
+
import { z } from 'zod';
|
|
83
|
+
|
|
84
|
+
export const githubWebhook = new LuaWebhook({
|
|
85
|
+
name: 'github-push',
|
|
86
|
+
description: 'Handles GitHub push events',
|
|
87
|
+
|
|
88
|
+
headerSchema: z.object({
|
|
89
|
+
'x-github-event': z.string(),
|
|
90
|
+
'x-hub-signature': z.string()
|
|
91
|
+
}),
|
|
92
|
+
|
|
93
|
+
bodySchema: z.object({
|
|
94
|
+
repository: z.object({
|
|
95
|
+
name: z.string(),
|
|
96
|
+
full_name: z.string()
|
|
97
|
+
}),
|
|
98
|
+
pusher: z.object({
|
|
99
|
+
name: z.string(),
|
|
100
|
+
email: z.string()
|
|
101
|
+
}),
|
|
102
|
+
commits: z.array(z.object({
|
|
103
|
+
message: z.string(),
|
|
104
|
+
url: z.string()
|
|
105
|
+
}))
|
|
106
|
+
}),
|
|
107
|
+
|
|
108
|
+
execute: async (event) => {
|
|
109
|
+
const { headers, body } = event;
|
|
110
|
+
|
|
111
|
+
// Verify it's a push event
|
|
112
|
+
if (headers['x-github-event'] !== 'push') {
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
message: 'Only push events are supported'
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Store commit information
|
|
120
|
+
for (const commit of body.commits) {
|
|
121
|
+
await Data.create('commits', {
|
|
122
|
+
repository: body.repository.full_name,
|
|
123
|
+
author: body.pusher.name,
|
|
124
|
+
message: commit.message,
|
|
125
|
+
url: commit.url,
|
|
126
|
+
timestamp: event.timestamp
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Notify relevant user
|
|
131
|
+
const user = await User.get({ email: body.pusher.email });
|
|
132
|
+
if (user) {
|
|
133
|
+
await user.send([{
|
|
134
|
+
type: 'text',
|
|
135
|
+
text: `✅ ${body.commits.length} commits pushed to ${body.repository.name}`
|
|
136
|
+
}]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
commits: body.commits.length,
|
|
142
|
+
repository: body.repository.name
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Stripe Payment Webhook
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { LuaWebhook, User, Orders, OrderStatus } from 'lua-cli';
|
|
152
|
+
import { z } from 'zod';
|
|
153
|
+
|
|
154
|
+
export const stripeWebhook = new LuaWebhook({
|
|
155
|
+
name: 'stripe-payment',
|
|
156
|
+
description: 'Handles Stripe payment events',
|
|
157
|
+
|
|
158
|
+
headerSchema: z.object({
|
|
159
|
+
'stripe-signature': z.string()
|
|
160
|
+
}),
|
|
161
|
+
|
|
162
|
+
bodySchema: z.object({
|
|
163
|
+
type: z.string(),
|
|
164
|
+
data: z.object({
|
|
165
|
+
object: z.object({
|
|
166
|
+
id: z.string(),
|
|
167
|
+
amount: z.number(),
|
|
168
|
+
currency: z.string(),
|
|
169
|
+
customer: z.string().optional(),
|
|
170
|
+
metadata: z.record(z.any()).optional()
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
}),
|
|
174
|
+
|
|
175
|
+
execute: async (event) => {
|
|
176
|
+
const { body } = event;
|
|
177
|
+
|
|
178
|
+
// Handle different event types
|
|
179
|
+
switch (body.type) {
|
|
180
|
+
case 'payment_intent.succeeded': {
|
|
181
|
+
const payment = body.data.object;
|
|
182
|
+
const orderId = payment.metadata?.orderId;
|
|
183
|
+
|
|
184
|
+
if (orderId) {
|
|
185
|
+
// Update order status
|
|
186
|
+
const order = await Orders.getById(orderId);
|
|
187
|
+
await order.updateStatus(OrderStatus.PROCESSING);
|
|
188
|
+
await order.update({
|
|
189
|
+
paymentId: payment.id,
|
|
190
|
+
paidAmount: payment.amount / 100,
|
|
191
|
+
paidAt: event.timestamp
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Notify customer
|
|
195
|
+
if (payment.customer) {
|
|
196
|
+
const user = await User.get(payment.customer);
|
|
197
|
+
await user.send([{
|
|
198
|
+
type: 'text',
|
|
199
|
+
text: `✅ Payment received! Your order #${orderId} is being processed.`
|
|
200
|
+
}]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
success: true,
|
|
206
|
+
event: 'payment_succeeded',
|
|
207
|
+
orderId
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
case 'payment_intent.payment_failed': {
|
|
212
|
+
const payment = body.data.object;
|
|
213
|
+
const orderId = payment.metadata?.orderId;
|
|
214
|
+
|
|
215
|
+
// Notify customer of failure
|
|
216
|
+
if (payment.customer) {
|
|
217
|
+
const user = await User.get(payment.customer);
|
|
218
|
+
await user.send([{
|
|
219
|
+
type: 'text',
|
|
220
|
+
text: `❌ Payment failed for order #${orderId}. Please try again.`
|
|
221
|
+
}]);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
success: true,
|
|
226
|
+
event: 'payment_failed',
|
|
227
|
+
orderId
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
default:
|
|
232
|
+
return {
|
|
233
|
+
success: true,
|
|
234
|
+
event: body.type,
|
|
235
|
+
message: 'Event received but not handled'
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Slack Message Webhook
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { LuaWebhook, Data, AI } from 'lua-cli';
|
|
246
|
+
import { z } from 'zod';
|
|
247
|
+
|
|
248
|
+
export const slackWebhook = new LuaWebhook({
|
|
249
|
+
name: 'slack-message',
|
|
250
|
+
description: 'Receives messages from Slack',
|
|
251
|
+
|
|
252
|
+
bodySchema: z.object({
|
|
253
|
+
type: z.string(),
|
|
254
|
+
challenge: z.string().optional(),
|
|
255
|
+
event: z.object({
|
|
256
|
+
type: z.string(),
|
|
257
|
+
user: z.string().optional(),
|
|
258
|
+
text: z.string().optional(),
|
|
259
|
+
channel: z.string()
|
|
260
|
+
}).optional()
|
|
261
|
+
}),
|
|
262
|
+
|
|
263
|
+
execute: async (event) => {
|
|
264
|
+
const { body } = event;
|
|
265
|
+
|
|
266
|
+
// Handle Slack challenge (verification)
|
|
267
|
+
if (body.type === 'url_verification') {
|
|
268
|
+
return { challenge: body.challenge };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Handle message events
|
|
272
|
+
if (body.type === 'event_callback' && body.event) {
|
|
273
|
+
const slackEvent = body.event;
|
|
274
|
+
|
|
275
|
+
// Ignore bot messages
|
|
276
|
+
if (slackEvent.user === 'USLACKBOT') {
|
|
277
|
+
return { success: true, message: 'Ignored bot message' };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Process user message
|
|
281
|
+
if (slackEvent.type === 'message' && slackEvent.text) {
|
|
282
|
+
// Generate AI response
|
|
283
|
+
const response = await AI.generate(
|
|
284
|
+
'You are a helpful Slack bot assistant.',
|
|
285
|
+
[{ type: 'text', text: slackEvent.text }]
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
// Store interaction
|
|
289
|
+
await Data.create('slack_messages', {
|
|
290
|
+
user: slackEvent.user,
|
|
291
|
+
channel: slackEvent.channel,
|
|
292
|
+
message: slackEvent.text,
|
|
293
|
+
response,
|
|
294
|
+
timestamp: event.timestamp
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// TODO: Send response back to Slack using Slack API
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
success: true,
|
|
301
|
+
response
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return { success: true, message: 'Event received' };
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Form Submission Webhook
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
import { LuaWebhook, User, Data } from 'lua-cli';
|
|
315
|
+
import { z } from 'zod';
|
|
316
|
+
|
|
317
|
+
export const contactFormWebhook = new LuaWebhook({
|
|
318
|
+
name: 'contact-form',
|
|
319
|
+
description: 'Handles contact form submissions',
|
|
320
|
+
|
|
321
|
+
querySchema: z.object({
|
|
322
|
+
source: z.enum(['website', 'mobile_app']).optional()
|
|
323
|
+
}),
|
|
324
|
+
|
|
325
|
+
bodySchema: z.object({
|
|
326
|
+
name: z.string().min(2),
|
|
327
|
+
email: z.string().email(),
|
|
328
|
+
phone: z.string().optional(),
|
|
329
|
+
subject: z.string(),
|
|
330
|
+
message: z.string().min(10),
|
|
331
|
+
consent: z.boolean()
|
|
332
|
+
}),
|
|
333
|
+
|
|
334
|
+
execute: async (event) => {
|
|
335
|
+
const { query, body } = event;
|
|
336
|
+
|
|
337
|
+
// Verify consent
|
|
338
|
+
if (!body.consent) {
|
|
339
|
+
return {
|
|
340
|
+
success: false,
|
|
341
|
+
error: 'Consent is required'
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Store submission
|
|
346
|
+
const entry = await Data.create('contact_submissions', {
|
|
347
|
+
name: body.name,
|
|
348
|
+
email: body.email,
|
|
349
|
+
phone: body.phone,
|
|
350
|
+
subject: body.subject,
|
|
351
|
+
message: body.message,
|
|
352
|
+
source: query?.source || 'unknown',
|
|
353
|
+
submittedAt: event.timestamp,
|
|
354
|
+
status: 'new'
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Create or update user
|
|
358
|
+
let user = await User.get({ email: body.email });
|
|
359
|
+
if (!user) {
|
|
360
|
+
user = await User.get(); // Create new user context
|
|
361
|
+
await user.update({
|
|
362
|
+
name: body.name,
|
|
363
|
+
email: body.email,
|
|
364
|
+
phone: body.phone
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Send confirmation
|
|
369
|
+
await user.send([{
|
|
370
|
+
type: 'text',
|
|
371
|
+
text: `Thank you for contacting us, ${body.name}! We've received your message about "${body.subject}" and will get back to you soon.`
|
|
372
|
+
}]);
|
|
373
|
+
|
|
374
|
+
return {
|
|
375
|
+
success: true,
|
|
376
|
+
submissionId: entry.id,
|
|
377
|
+
message: 'Form submitted successfully'
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### API Integration Webhook
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { LuaWebhook, Data } from 'lua-cli';
|
|
387
|
+
import { z } from 'zod';
|
|
388
|
+
|
|
389
|
+
export const apiWebhook = new LuaWebhook({
|
|
390
|
+
name: 'external-api',
|
|
391
|
+
description: 'Receives data from external API',
|
|
392
|
+
|
|
393
|
+
headerSchema: z.object({
|
|
394
|
+
'x-api-key': z.string(),
|
|
395
|
+
'content-type': z.literal('application/json')
|
|
396
|
+
}),
|
|
397
|
+
|
|
398
|
+
querySchema: z.object({
|
|
399
|
+
action: z.enum(['create', 'update', 'delete']),
|
|
400
|
+
entity: z.string()
|
|
401
|
+
}),
|
|
402
|
+
|
|
403
|
+
bodySchema: z.object({
|
|
404
|
+
id: z.string(),
|
|
405
|
+
data: z.record(z.any())
|
|
406
|
+
}),
|
|
407
|
+
|
|
408
|
+
execute: async (event) => {
|
|
409
|
+
const { query, headers, body } = event;
|
|
410
|
+
|
|
411
|
+
// Verify API key
|
|
412
|
+
const validApiKey = process.env.WEBHOOK_API_KEY;
|
|
413
|
+
if (headers['x-api-key'] !== validApiKey) {
|
|
414
|
+
return {
|
|
415
|
+
success: false,
|
|
416
|
+
error: 'Invalid API key'
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Handle different actions
|
|
421
|
+
switch (query.action) {
|
|
422
|
+
case 'create':
|
|
423
|
+
await Data.create(query.entity, {
|
|
424
|
+
externalId: body.id,
|
|
425
|
+
...body.data,
|
|
426
|
+
syncedAt: event.timestamp
|
|
427
|
+
});
|
|
428
|
+
break;
|
|
429
|
+
|
|
430
|
+
case 'update':
|
|
431
|
+
const entries = await Data.search(query.entity, body.id);
|
|
432
|
+
if (entries.data.length > 0) {
|
|
433
|
+
await Data.update(query.entity, entries.data[0].id, {
|
|
434
|
+
...body.data,
|
|
435
|
+
syncedAt: event.timestamp
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
break;
|
|
439
|
+
|
|
440
|
+
case 'delete':
|
|
441
|
+
const toDelete = await Data.search(query.entity, body.id);
|
|
442
|
+
if (toDelete.data.length > 0) {
|
|
443
|
+
await Data.delete(query.entity, toDelete.data[0].id);
|
|
444
|
+
}
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return {
|
|
449
|
+
success: true,
|
|
450
|
+
action: query.action,
|
|
451
|
+
entity: query.entity,
|
|
452
|
+
id: body.id
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Webhook URL
|
|
459
|
+
|
|
460
|
+
After deploying your webhook, it will be available at:
|
|
461
|
+
|
|
462
|
+
```
|
|
463
|
+
https://api.heylua.ai/webhook/{agentId}/{webhookName}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Example:
|
|
467
|
+
```
|
|
468
|
+
https://api.heylua.ai/webhook/agent_123/github-push
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Testing Webhooks
|
|
472
|
+
|
|
473
|
+
### Local Testing with lua dev
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Start dev mode
|
|
477
|
+
lua dev
|
|
478
|
+
|
|
479
|
+
# Webhook will be available at:
|
|
480
|
+
# http://localhost:3002/webhook/{webhookName}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Testing with curl
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
# Test webhook locally
|
|
487
|
+
curl -X POST http://localhost:3002/webhook/contact-form \
|
|
488
|
+
-H "Content-Type: application/json" \
|
|
489
|
+
-d '{
|
|
490
|
+
"name": "John Doe",
|
|
491
|
+
"email": "john@example.com",
|
|
492
|
+
"subject": "Question",
|
|
493
|
+
"message": "This is a test message",
|
|
494
|
+
"consent": true
|
|
495
|
+
}'
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Best Practices
|
|
499
|
+
|
|
500
|
+
### ✅ DO
|
|
501
|
+
|
|
502
|
+
- Always validate input with schemas (query, headers, body)
|
|
503
|
+
- Verify webhook signatures when available (GitHub, Stripe, etc.)
|
|
504
|
+
- Return meaningful response objects
|
|
505
|
+
- Store webhook events for auditing
|
|
506
|
+
- Handle errors gracefully
|
|
507
|
+
- Use appropriate HTTP status codes in responses
|
|
508
|
+
- Implement idempotency for critical operations
|
|
509
|
+
- Log webhook events for debugging
|
|
510
|
+
|
|
511
|
+
### ❌ DON'T
|
|
512
|
+
|
|
513
|
+
- Don't skip validation - always use schemas
|
|
514
|
+
- Don't expose sensitive data in responses
|
|
515
|
+
- Don't perform long-running operations synchronously
|
|
516
|
+
- Don't trust incoming data without verification
|
|
517
|
+
- Don't forget to handle webhook retry logic
|
|
518
|
+
- Don't ignore timestamp for event ordering
|
|
519
|
+
|
|
520
|
+
## Error Handling
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
export const webhook = new LuaWebhook({
|
|
524
|
+
name: 'robust-webhook',
|
|
525
|
+
description: 'Webhook with error handling',
|
|
526
|
+
|
|
527
|
+
bodySchema: z.object({
|
|
528
|
+
data: z.string()
|
|
529
|
+
}),
|
|
530
|
+
|
|
531
|
+
execute: async (event) => {
|
|
532
|
+
try {
|
|
533
|
+
// Process webhook
|
|
534
|
+
const result = await processData(event.body.data);
|
|
535
|
+
|
|
536
|
+
return {
|
|
537
|
+
success: true,
|
|
538
|
+
result
|
|
539
|
+
};
|
|
540
|
+
} catch (error) {
|
|
541
|
+
// Log error
|
|
542
|
+
await Data.create('webhook_errors', {
|
|
543
|
+
webhookName: 'robust-webhook',
|
|
544
|
+
error: error.message,
|
|
545
|
+
event: event.body,
|
|
546
|
+
timestamp: event.timestamp
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Return error response
|
|
550
|
+
return {
|
|
551
|
+
success: false,
|
|
552
|
+
error: error.message,
|
|
553
|
+
retry: true // Indicate that the sender should retry
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Security
|
|
561
|
+
|
|
562
|
+
### Verify Signatures
|
|
563
|
+
|
|
564
|
+
```typescript
|
|
565
|
+
import crypto from 'crypto';
|
|
566
|
+
|
|
567
|
+
function verifyGitHubSignature(
|
|
568
|
+
body: string,
|
|
569
|
+
signature: string,
|
|
570
|
+
secret: string
|
|
571
|
+
): boolean {
|
|
572
|
+
const hmac = crypto.createHmac('sha256', secret);
|
|
573
|
+
const digest = 'sha256=' + hmac.update(body).digest('hex');
|
|
574
|
+
return crypto.timingSafeEqual(
|
|
575
|
+
Buffer.from(signature),
|
|
576
|
+
Buffer.from(digest)
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### API Key Validation
|
|
582
|
+
|
|
583
|
+
```typescript
|
|
584
|
+
headerSchema: z.object({
|
|
585
|
+
'x-api-key': z.string()
|
|
586
|
+
.refine(key => key === process.env.WEBHOOK_API_KEY, {
|
|
587
|
+
message: 'Invalid API key'
|
|
588
|
+
})
|
|
589
|
+
})
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
## Related APIs
|
|
593
|
+
|
|
594
|
+
- [LuaJob](./LuaJob.md) - Schedule recurring tasks
|
|
595
|
+
- [Data API](./Data.md) - Store webhook events
|
|
596
|
+
- [User API](./User.md) - Notify users about events
|
|
597
|
+
|
|
598
|
+
## See Also
|
|
599
|
+
|
|
600
|
+
- [Webhook Integration Guide](../guides/Webhooks.md)
|
|
601
|
+
- [Third-Party Integrations](../guides/Integrations.md)
|