lua-cli 3.13.0 ā 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -13
- package/dist/api/agent.api.service.d.ts +20 -20
- package/dist/api/agent.api.service.d.ts.map +1 -1
- package/dist/api/agent.api.service.js +1 -1
- package/dist/api/agent.api.service.js.map +1 -1
- package/dist/api/agents.api.service.d.ts +3 -3
- package/dist/api/agents.api.service.d.ts.map +1 -1
- package/dist/api/agents.api.service.js +11 -9
- package/dist/api/agents.api.service.js.map +1 -1
- package/dist/api/ai.api.service.d.ts +4 -4
- package/dist/api/ai.api.service.d.ts.map +1 -1
- package/dist/api/ai.api.service.js +10 -8
- package/dist/api/ai.api.service.js.map +1 -1
- package/dist/api/auth.api.service.d.ts +3 -3
- package/dist/api/auth.api.service.d.ts.map +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.map +1 -1
- package/dist/api/backup.api.service.js +21 -7
- package/dist/api/backup.api.service.js.map +1 -1
- package/dist/api/basket.api.service.d.ts +5 -5
- package/dist/api/basket.api.service.d.ts.map +1 -1
- package/dist/api/basket.api.service.js +4 -4
- package/dist/api/basket.api.service.js.map +1 -1
- package/dist/api/cdn.api.service.d.ts +1 -1
- package/dist/api/cdn.api.service.js +3 -3
- package/dist/api/cdn.api.service.js.map +1 -1
- package/dist/api/chat.api.service.d.ts +4 -4
- package/dist/api/chat.api.service.js +3 -3
- package/dist/api/chat.api.service.js.map +1 -1
- package/dist/api/credentials.js +3 -3
- package/dist/api/custom.data.api.service.d.ts +4 -4
- package/dist/api/custom.data.api.service.d.ts.map +1 -1
- package/dist/api/custom.data.api.service.js +2 -2
- package/dist/api/custom.data.api.service.js.map +1 -1
- package/dist/api/developer.api.service.d.ts +3 -3
- package/dist/api/developer.api.service.d.ts.map +1 -1
- package/dist/api/developer.api.service.js +7 -3
- package/dist/api/developer.api.service.js.map +1 -1
- package/dist/api/device-trigger.api.service.d.ts +3 -3
- package/dist/api/device-trigger.api.service.d.ts.map +1 -1
- package/dist/api/device-trigger.api.service.js +1 -1
- package/dist/api/device-trigger.api.service.js.map +1 -1
- package/dist/api/device.api.service.d.ts +3 -3
- package/dist/api/device.api.service.d.ts.map +1 -1
- package/dist/api/device.api.service.js +1 -1
- package/dist/api/device.api.service.js.map +1 -1
- package/dist/api/http.client.d.ts +1 -1
- package/dist/api/http.client.d.ts.map +1 -1
- package/dist/api/http.client.js +6 -6
- package/dist/api/http.client.js.map +1 -1
- package/dist/api/job.api.service.d.ts +13 -14
- package/dist/api/job.api.service.d.ts.map +1 -1
- package/dist/api/job.api.service.js +12 -20
- package/dist/api/job.api.service.js.map +1 -1
- package/dist/api/lazy-instances.d.ts +12 -12
- package/dist/api/lazy-instances.js +14 -14
- package/dist/api/logs.api.service.d.ts +5 -5
- package/dist/api/logs.api.service.d.ts.map +1 -1
- package/dist/api/logs.api.service.js +9 -9
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/marketplace.api.service.d.ts +1 -1
- package/dist/api/marketplace.api.service.d.ts.map +1 -1
- package/dist/api/marketplace.api.service.js +18 -18
- package/dist/api/marketplace.api.service.js.map +1 -1
- package/dist/api/order.api.service.d.ts +4 -4
- package/dist/api/order.api.service.d.ts.map +1 -1
- package/dist/api/order.api.service.js +2 -2
- package/dist/api/order.api.service.js.map +1 -1
- package/dist/api/persona.api.service.d.ts +3 -3
- package/dist/api/persona.api.service.d.ts.map +1 -1
- package/dist/api/persona.api.service.js +2 -2
- package/dist/api/persona.api.service.js.map +1 -1
- package/dist/api/postprocessor.api.service.d.ts +8 -9
- package/dist/api/postprocessor.api.service.d.ts.map +1 -1
- package/dist/api/postprocessor.api.service.js +1 -2
- package/dist/api/postprocessor.api.service.js.map +1 -1
- package/dist/api/preprocessor.api.service.d.ts +8 -9
- package/dist/api/preprocessor.api.service.d.ts.map +1 -1
- package/dist/api/preprocessor.api.service.js +1 -2
- package/dist/api/preprocessor.api.service.js.map +1 -1
- package/dist/api/products.api.service.d.ts +9 -9
- package/dist/api/products.api.service.d.ts.map +1 -1
- package/dist/api/products.api.service.js +10 -10
- package/dist/api/products.api.service.js.map +1 -1
- package/dist/api/resource.api.service.d.ts +2 -2
- package/dist/api/resource.api.service.js +1 -1
- package/dist/api/skills.api.service.d.ts +4 -4
- package/dist/api/skills.api.service.d.ts.map +1 -1
- 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 +2 -2
- package/dist/api/tool.api.service.js +1 -1
- package/dist/api/unifiedto.api.service.d.ts +3 -3
- package/dist/api/unifiedto.api.service.d.ts.map +1 -1
- package/dist/api/unifiedto.api.service.js +28 -10
- package/dist/api/unifiedto.api.service.js.map +1 -1
- package/dist/api/user.data.api.service.d.ts +6 -6
- package/dist/api/user.data.api.service.d.ts.map +1 -1
- package/dist/api/user.data.api.service.js +5 -5
- package/dist/api/user.data.api.service.js.map +1 -1
- package/dist/api/webhook.api.service.d.ts +3 -3
- package/dist/api/webhook.api.service.d.ts.map +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 +3 -3
- package/dist/api/whatsapp-templates.api.service.js +1 -1
- package/dist/api-exports.d.ts +25 -25
- package/dist/api-exports.d.ts.map +1 -1
- package/dist/api-exports.js +26 -26
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.d.ts +1 -1
- package/dist/cli/command-definitions.d.ts.map +1 -1
- package/dist/cli/command-definitions.js +190 -199
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/agents.js +2 -2
- package/dist/commands/apiKey.js +12 -12
- package/dist/commands/channels.js +163 -163
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat-log-probe.d.ts.map +1 -1
- package/dist/commands/chat-log-probe.js +2 -6
- package/dist/commands/chat-log-probe.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +33 -33
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/chatClear.d.ts.map +1 -1
- package/dist/commands/chatClear.js +10 -6
- package/dist/commands/chatClear.js.map +1 -1
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +18 -11
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/completion.js +1 -1
- package/dist/commands/configure.js +5 -5
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +27 -15
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/destroy.d.ts.map +1 -1
- package/dist/commands/destroy.js +27 -17
- package/dist/commands/destroy.js.map +1 -1
- package/dist/commands/devices.js +1 -3
- package/dist/commands/devices.js.map +1 -1
- package/dist/commands/env.js +58 -60
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/features.js +69 -70
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/governance.d.ts.map +1 -1
- package/dist/commands/governance.js +13 -7
- package/dist/commands/governance.js.map +1 -1
- package/dist/commands/index.d.ts +37 -37
- package/dist/commands/index.js +37 -37
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +69 -69
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/integrations.d.ts.map +1 -1
- package/dist/commands/integrations.js +369 -339
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/jobs.d.ts.map +1 -1
- package/dist/commands/jobs.js +56 -62
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/log-tip.d.ts.map +1 -1
- package/dist/commands/log-tip.js +2 -10
- package/dist/commands/log-tip.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +80 -73
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.d.ts.map +1 -1
- package/dist/commands/marketplace.js +368 -403
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +38 -38
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +2 -2
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona.js +96 -96
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.js +44 -44
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.js +44 -44
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.js +99 -101
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +130 -81
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts.map +1 -1
- package/dist/commands/pushBackup.js +4 -6
- package/dist/commands/pushBackup.js.map +1 -1
- package/dist/commands/resources.js +45 -48
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +68 -55
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +11 -14
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +34 -29
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test-output.helpers.js +1 -1
- package/dist/commands/test-output.helpers.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +81 -71
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +15 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/webhooks.d.ts.map +1 -1
- package/dist/commands/webhooks.js +60 -66
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts.map +1 -1
- package/dist/compiler/agent-traverser.js +2 -4
- package/dist/compiler/agent-traverser.js.map +1 -1
- package/dist/compiler/bundler.d.ts.map +1 -1
- package/dist/compiler/bundler.js +5 -5
- package/dist/compiler/bundler.js.map +1 -1
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compiler.js +12 -11
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +2 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/plugins/agent.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/agent.plugin.js +2 -4
- package/dist/compiler/plugins/agent.plugin.js.map +1 -1
- package/dist/compiler/plugins/base.d.ts.map +1 -1
- package/dist/compiler/plugins/base.js +3 -3
- package/dist/compiler/plugins/base.js.map +1 -1
- package/dist/compiler/plugins/device-trigger.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/device-trigger.plugin.js +8 -4
- package/dist/compiler/plugins/device-trigger.plugin.js.map +1 -1
- package/dist/compiler/plugins/device.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/device.plugin.js +4 -4
- package/dist/compiler/plugins/device.plugin.js.map +1 -1
- package/dist/compiler/plugins/job.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/job.plugin.js +15 -11
- package/dist/compiler/plugins/job.plugin.js.map +1 -1
- package/dist/compiler/plugins/mcp-server.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/mcp-server.plugin.js +10 -4
- package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -1
- package/dist/compiler/plugins/registry.js +2 -2
- package/dist/compiler/plugins/registry.js.map +1 -1
- package/dist/compiler/plugins/skill.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/skill.plugin.js +8 -13
- package/dist/compiler/plugins/skill.plugin.js.map +1 -1
- package/dist/compiler/plugins/tool.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/tool.plugin.js +13 -9
- package/dist/compiler/plugins/tool.plugin.js.map +1 -1
- package/dist/compiler/plugins/webhook.plugin.d.ts.map +1 -1
- package/dist/compiler/plugins/webhook.plugin.js +7 -5
- package/dist/compiler/plugins/webhook.plugin.js.map +1 -1
- package/dist/compiler/source-writer.d.ts.map +1 -1
- package/dist/compiler/source-writer.js +2 -4
- package/dist/compiler/source-writer.js.map +1 -1
- package/dist/compiler/utils/ast-helpers.d.ts.map +1 -1
- package/dist/compiler/utils/ast-helpers.js +12 -7
- package/dist/compiler/utils/ast-helpers.js.map +1 -1
- package/dist/compiler/utils/common.d.ts.map +1 -1
- package/dist/compiler/utils/common.js +1 -11
- package/dist/compiler/utils/common.js.map +1 -1
- package/dist/compiler/utils/file-discovery.d.ts.map +1 -1
- package/dist/compiler/utils/file-discovery.js +2 -10
- package/dist/compiler/utils/file-discovery.js.map +1 -1
- package/dist/compiler/utils/path-resolver.d.ts.map +1 -1
- package/dist/compiler/utils/path-resolver.js.map +1 -1
- package/dist/compiler/utils/reference-resolver.d.ts.map +1 -1
- package/dist/compiler/utils/reference-resolver.js +4 -8
- package/dist/compiler/utils/reference-resolver.js.map +1 -1
- package/dist/compiler/utils/schema-converter.d.ts.map +1 -1
- package/dist/compiler/utils/schema-converter.js +1 -4
- package/dist/compiler/utils/schema-converter.js.map +1 -1
- package/dist/config/compile.constants.d.ts.map +1 -1
- package/dist/config/compile.constants.js +3 -1
- package/dist/config/compile.constants.js.map +1 -1
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/config/constants.js +1 -5
- package/dist/config/constants.js.map +1 -1
- package/dist/errors/auth.error.d.ts.map +1 -1
- package/dist/errors/auth.error.js +3 -5
- package/dist/errors/auth.error.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/instances/basket.instance.d.ts +3 -3
- package/dist/instances/basket.instance.d.ts.map +1 -1
- package/dist/instances/basket.instance.js +26 -8
- package/dist/instances/basket.instance.js.map +1 -1
- package/dist/instances/data.entry.instance.d.ts +2 -2
- package/dist/instances/data.entry.instance.d.ts.map +1 -1
- package/dist/instances/data.entry.instance.js +5 -5
- package/dist/instances/data.entry.instance.js.map +1 -1
- package/dist/instances/order.instance.d.ts +2 -2
- package/dist/instances/order.instance.d.ts.map +1 -1
- package/dist/instances/order.instance.js +20 -9
- package/dist/instances/order.instance.js.map +1 -1
- package/dist/instances/product.instance.d.ts +1 -1
- package/dist/instances/product.instance.d.ts.map +1 -1
- package/dist/instances/product.instance.js +3 -3
- package/dist/instances/product.instance.js.map +1 -1
- package/dist/instances/product.pagination.instance.d.ts +2 -2
- package/dist/instances/product.pagination.instance.d.ts.map +1 -1
- package/dist/instances/product.pagination.instance.js +6 -7
- package/dist/instances/product.pagination.instance.js.map +1 -1
- package/dist/instances/product.search.instance.d.ts +3 -3
- package/dist/instances/product.search.instance.d.ts.map +1 -1
- package/dist/instances/product.search.instance.js +3 -4
- package/dist/instances/product.search.instance.js.map +1 -1
- package/dist/instances/user.instance.d.ts +3 -3
- package/dist/instances/user.instance.d.ts.map +1 -1
- package/dist/instances/user.instance.js +19 -36
- package/dist/instances/user.instance.js.map +1 -1
- package/dist/interfaces/agent.d.ts +8 -8
- package/dist/interfaces/agent.d.ts.map +1 -1
- package/dist/interfaces/device-triggers.d.ts +0 -2
- package/dist/interfaces/device-triggers.d.ts.map +1 -1
- package/dist/interfaces/devices.d.ts +0 -1
- package/dist/interfaces/devices.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +8 -8
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/jobs.d.ts +2 -3
- package/dist/interfaces/jobs.d.ts.map +1 -1
- package/dist/interfaces/message.d.ts +3 -3
- package/dist/interfaces/message.d.ts.map +1 -1
- package/dist/interfaces/orders.d.ts +1 -1
- package/dist/interfaces/webhooks.d.ts +2 -2
- package/dist/interfaces/webhooks.d.ts.map +1 -1
- package/dist/primitives/agent.handler.d.ts.map +1 -1
- package/dist/primitives/agent.handler.js +1 -1
- package/dist/primitives/agent.handler.js.map +1 -1
- package/dist/primitives/base.handler.d.ts +2 -2
- package/dist/primitives/base.handler.d.ts.map +1 -1
- package/dist/primitives/base.handler.js +38 -36
- package/dist/primitives/base.handler.js.map +1 -1
- package/dist/primitives/device-trigger.handler.d.ts +1 -1
- package/dist/primitives/device-trigger.handler.d.ts.map +1 -1
- package/dist/primitives/device-trigger.handler.js +2 -3
- package/dist/primitives/device-trigger.handler.js.map +1 -1
- package/dist/primitives/device.handler.d.ts +1 -1
- package/dist/primitives/device.handler.d.ts.map +1 -1
- package/dist/primitives/device.handler.js +2 -3
- package/dist/primitives/device.handler.js.map +1 -1
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +2 -3
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/job.handler.d.ts +1 -1
- package/dist/primitives/job.handler.d.ts.map +1 -1
- package/dist/primitives/job.handler.js +3 -6
- package/dist/primitives/job.handler.js.map +1 -1
- package/dist/primitives/mcp-server.handler.d.ts.map +1 -1
- package/dist/primitives/mcp-server.handler.js +2 -2
- package/dist/primitives/mcp-server.handler.js.map +1 -1
- package/dist/primitives/postprocessor.handler.d.ts.map +1 -1
- package/dist/primitives/postprocessor.handler.js.map +1 -1
- package/dist/primitives/preprocessor.handler.d.ts +1 -1
- package/dist/primitives/preprocessor.handler.d.ts.map +1 -1
- package/dist/primitives/preprocessor.handler.js +2 -3
- package/dist/primitives/preprocessor.handler.js.map +1 -1
- package/dist/primitives/skill.handler.d.ts +1 -1
- package/dist/primitives/skill.handler.d.ts.map +1 -1
- package/dist/primitives/skill.handler.js +34 -13
- package/dist/primitives/skill.handler.js.map +1 -1
- package/dist/primitives/types.d.ts +1 -1
- package/dist/primitives/types.d.ts.map +1 -1
- package/dist/primitives/types.js.map +1 -1
- package/dist/primitives/webhook.handler.d.ts +1 -1
- package/dist/primitives/webhook.handler.d.ts.map +1 -1
- package/dist/primitives/webhook.handler.js +2 -3
- package/dist/primitives/webhook.handler.js.map +1 -1
- package/dist/services/analytics.d.ts.map +1 -1
- package/dist/services/analytics.js +4 -5
- package/dist/services/analytics.js.map +1 -1
- package/dist/services/auth.d.ts +1 -1
- package/dist/services/auth.js +7 -7
- package/dist/services/auth.js.map +1 -1
- package/dist/services/sandbox.service.d.ts.map +1 -1
- package/dist/services/sandbox.service.js +126 -78
- package/dist/services/sandbox.service.js.map +1 -1
- package/dist/types/api-contracts.d.ts +4 -4
- package/dist/types/api-contracts.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/skill.d.ts +7 -7
- package/dist/types/skill.d.ts.map +1 -1
- package/dist/types/skill.js +2 -2
- package/dist/types/skill.js.map +1 -1
- package/dist/types/tool-validation.js.map +1 -1
- package/dist/types/yaml.types.js +0 -1
- package/dist/types/yaml.types.js.map +1 -1
- package/dist/utils/aliases.d.ts.map +1 -1
- package/dist/utils/aliases.js +38 -3
- package/dist/utils/aliases.js.map +1 -1
- package/dist/utils/artifact-loader.d.ts +9 -0
- package/dist/utils/artifact-loader.d.ts.map +1 -1
- package/dist/utils/artifact-loader.js +16 -6
- package/dist/utils/artifact-loader.js.map +1 -1
- package/dist/utils/auth-flows.d.ts.map +1 -1
- package/dist/utils/auth-flows.js +54 -54
- package/dist/utils/auth-flows.js.map +1 -1
- package/dist/utils/backup-helpers.d.ts.map +1 -1
- package/dist/utils/backup-helpers.js +10 -16
- package/dist/utils/backup-helpers.js.map +1 -1
- package/dist/utils/bundle-upload.d.ts +42 -0
- package/dist/utils/bundle-upload.d.ts.map +1 -0
- package/dist/utils/bundle-upload.js +90 -0
- package/dist/utils/bundle-upload.js.map +1 -0
- package/dist/utils/chat-attachments.js +1 -1
- package/dist/utils/chat-attachments.js.map +1 -1
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +3 -5
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/command-utils.d.ts.map +1 -1
- package/dist/utils/command-utils.js +4 -4
- package/dist/utils/command-utils.js.map +1 -1
- package/dist/utils/deploy-helpers.d.ts.map +1 -1
- package/dist/utils/deploy-helpers.js +13 -13
- package/dist/utils/deploy-helpers.js.map +1 -1
- package/dist/utils/env-loader.utils.d.ts +1 -1
- package/dist/utils/env-loader.utils.d.ts.map +1 -1
- package/dist/utils/env-loader.utils.js +15 -22
- package/dist/utils/env-loader.utils.js.map +1 -1
- package/dist/utils/files.d.ts.map +1 -1
- package/dist/utils/files.js +23 -13
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/hints.d.ts.map +1 -1
- package/dist/utils/hints.js +3 -5
- package/dist/utils/hints.js.map +1 -1
- package/dist/utils/init-agent.d.ts.map +1 -1
- package/dist/utils/init-agent.js +18 -20
- package/dist/utils/init-agent.js.map +1 -1
- package/dist/utils/init-helpers.d.ts.map +1 -1
- package/dist/utils/init-helpers.js +11 -11
- package/dist/utils/init-helpers.js.map +1 -1
- package/dist/utils/init-prompts.d.ts.map +1 -1
- package/dist/utils/init-prompts.js +34 -36
- package/dist/utils/init-prompts.js.map +1 -1
- package/dist/utils/prompt-handler.js +1 -1
- package/dist/utils/prompt-handler.js.map +1 -1
- package/dist/utils/sandbox-storage.d.ts.map +1 -1
- package/dist/utils/sandbox-storage.js.map +1 -1
- package/dist/utils/sandbox.d.ts +1 -1
- package/dist/utils/sandbox.d.ts.map +1 -1
- package/dist/utils/sandbox.js +107 -106
- package/dist/utils/sandbox.js.map +1 -1
- package/dist/utils/semver.js +1 -1
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/suggest.d.ts.map +1 -1
- package/dist/utils/suggest.js +1 -3
- package/dist/utils/suggest.js.map +1 -1
- package/dist/utils/sync-display.d.ts.map +1 -1
- package/dist/utils/sync-display.js +15 -13
- package/dist/utils/sync-display.js.map +1 -1
- package/dist/utils/sync-fetch.d.ts.map +1 -1
- package/dist/utils/sync-fetch.js +33 -24
- package/dist/utils/sync-fetch.js.map +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/README.md +1 -1
- package/node_modules/@lua/shared-types/dist/index.d.mts +13 -1
- package/node_modules/@lua/shared-types/dist/index.d.ts +13 -1
- package/node_modules/@lua/shared-types/src/ai-generate.types.ts +1 -6
- package/node_modules/@lua/shared-types/src/ai-generate.utils.ts +1 -4
- package/node_modules/@lua/shared-types/src/chat-stream.types.ts +11 -0
- package/node_modules/@lua/shared-types/src/device.types.ts +6 -6
- package/node_modules/@lua/shared-types/src/index.ts +1 -0
- package/node_modules/@lua/shared-types/src/sandbox-contract.ts +26 -5
- package/node_modules/@lua/shared-types/src/vm-execution-log.types.ts +11 -11
- package/package.json +1 -1
- package/template/QUICKSTART.md +33 -33
- package/template/README.md +35 -34
- package/template/examples/README.md +44 -38
- package/template/examples/jobs/AbandonedBasketProcessorJob.ts +30 -31
- package/template/examples/jobs/DailyCleanupJob.ts +17 -18
- package/template/examples/jobs/DataMigrationJob.ts +18 -23
- package/template/examples/jobs/HealthCheckJob.ts +13 -14
- package/template/examples/postprocessors/modifyResponse.ts +14 -15
- package/template/examples/preprocessors/messageMatching.ts +28 -29
- package/template/examples/services/ApiService.ts +68 -64
- package/template/examples/services/GetWeather.ts +39 -33
- package/template/examples/skills/basket.skill.ts +27 -7
- package/template/examples/skills/product.skill.ts +21 -8
- package/template/examples/skills/tools/BasketTool.ts +97 -98
- package/template/examples/skills/tools/CreateInlineJob.ts +38 -36
- package/template/examples/skills/tools/CreatePostTool.ts +27 -28
- package/template/examples/skills/tools/CustomDataTool.ts +72 -63
- package/template/examples/skills/tools/GameScoreTrackerTool.ts +72 -78
- package/template/examples/skills/tools/GetWeatherTool.ts +43 -45
- package/template/examples/skills/tools/OrderTool.ts +58 -58
- package/template/examples/skills/tools/PaymentTool.ts +43 -43
- package/template/examples/skills/tools/PremiumFeatureTool.ts +79 -77
- package/template/examples/skills/tools/ProductsTool.ts +68 -69
- package/template/examples/skills/tools/SmartBasketTool.ts +43 -44
- package/template/examples/skills/tools/UserDataTool.ts +97 -98
- package/template/examples/skills/user.skill.ts +7 -8
- package/template/examples/webhooks/FileUploadWebhook.ts +38 -31
- package/template/examples/webhooks/PaymentWebhook.ts +23 -22
- package/template/examples/webhooks/UserEventWebhook.ts +16 -19
- package/template/lua.skill.yaml +2 -2
- package/template/package.json +1 -1
- package/template/src/index.ts +28 -28
|
@@ -23,7 +23,7 @@ import { safePrompt } from '../utils/prompt-handler.js';
|
|
|
23
23
|
import { initializeCommand } from '../utils/command-utils.js';
|
|
24
24
|
import DeveloperApi from '../api/developer.api.service.js';
|
|
25
25
|
import UnifiedToApi from '../api/unifiedto.api.service.js';
|
|
26
|
-
import { fetchServersCore, activateServerCore, deactivateServerCore
|
|
26
|
+
import { fetchServersCore, activateServerCore, deactivateServerCore } from './mcp.js';
|
|
27
27
|
import { trackEvent } from '../services/analytics.js';
|
|
28
28
|
import { validateOrSuggest } from '../utils/aliases.js';
|
|
29
29
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
@@ -74,9 +74,7 @@ function startCallbackServer(timeoutMs = 300000) {
|
|
|
74
74
|
resolved = true;
|
|
75
75
|
if (error) {
|
|
76
76
|
// Unified.to redirects to failure_redirect with ?error=<oauth_error>&log_id=<trace_id>
|
|
77
|
-
const logIdHtml = logId
|
|
78
|
-
? `<p style="color: #888; font-size: 0.85em;">Log ID: <code>${logId}</code></p>`
|
|
79
|
-
: '';
|
|
77
|
+
const logIdHtml = logId ? `<p style="color: #888; font-size: 0.85em;">Log ID: <code>${logId}</code></p>` : '';
|
|
80
78
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
81
79
|
res.end(`
|
|
82
80
|
<!DOCTYPE html>
|
|
@@ -146,8 +144,8 @@ export async function integrationsCommand(action, subaction, cmdObj) {
|
|
|
146
144
|
const { agentId, apiKey, userData } = await initializeCommand({ showProgress: false, validateAuth: true });
|
|
147
145
|
const userId = userData?.admin?.userId;
|
|
148
146
|
if (!userId) {
|
|
149
|
-
console.error(
|
|
150
|
-
throw new Error(
|
|
147
|
+
console.error('ā Failed to get user ID from authentication.');
|
|
148
|
+
throw new Error('Failed to get user ID from authentication.');
|
|
151
149
|
}
|
|
152
150
|
const developerApi = new DeveloperApi(BASE_URLS.API, apiKey, agentId);
|
|
153
151
|
const unifiedToApi = new UnifiedToApi(BASE_URLS.API, apiKey);
|
|
@@ -172,7 +170,7 @@ export async function integrationsCommand(action, subaction, cmdObj) {
|
|
|
172
170
|
integration_type: cmdObj?.integration || null,
|
|
173
171
|
non_interactive: !!action,
|
|
174
172
|
});
|
|
175
|
-
},
|
|
173
|
+
}, 'integrations');
|
|
176
174
|
}
|
|
177
175
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
178
176
|
// Non-Interactive Mode
|
|
@@ -199,9 +197,9 @@ async function executeNonInteractive(context, action, cmdOptions) {
|
|
|
199
197
|
break;
|
|
200
198
|
case 'update':
|
|
201
199
|
if (!options.integration) {
|
|
202
|
-
console.error(
|
|
200
|
+
console.error('ā --integration is required for update');
|
|
203
201
|
console.log("\nš” Run 'lua integrations list' to see connected integrations");
|
|
204
|
-
throw new Error(
|
|
202
|
+
throw new Error('--integration is required for update');
|
|
205
203
|
}
|
|
206
204
|
await updateConnectionFlow(context, options);
|
|
207
205
|
break;
|
|
@@ -216,18 +214,18 @@ async function executeNonInteractive(context, action, cmdOptions) {
|
|
|
216
214
|
// Integration type can be passed as positional arg (info <type>) or as --integration flag
|
|
217
215
|
const infoIntegrationType = options.integration || cmdOptions?._?.[0];
|
|
218
216
|
if (!infoIntegrationType) {
|
|
219
|
-
console.error(
|
|
220
|
-
console.log(
|
|
221
|
-
console.log(
|
|
222
|
-
throw new Error(
|
|
217
|
+
console.error('ā Integration type is required');
|
|
218
|
+
console.log('\nUsage: lua integrations info <type>');
|
|
219
|
+
console.log(' lua integrations info <type> --json');
|
|
220
|
+
throw new Error('Integration type is required');
|
|
223
221
|
}
|
|
224
222
|
await showIntegrationInfo(context, infoIntegrationType, jsonOutput);
|
|
225
223
|
break;
|
|
226
224
|
case 'disconnect':
|
|
227
225
|
if (!options.connectionId) {
|
|
228
|
-
console.error(
|
|
226
|
+
console.error('ā --connection-id is required for disconnect');
|
|
229
227
|
console.log("\nš” Run 'lua integrations list' to see connection IDs");
|
|
230
|
-
throw new Error(
|
|
228
|
+
throw new Error('--connection-id is required for disconnect');
|
|
231
229
|
}
|
|
232
230
|
await disconnectIntegration(context, options.connectionId);
|
|
233
231
|
break;
|
|
@@ -240,7 +238,7 @@ async function executeNonInteractive(context, action, cmdOptions) {
|
|
|
240
238
|
default:
|
|
241
239
|
console.error(`ā Invalid action: "${action}"`);
|
|
242
240
|
showUsage();
|
|
243
|
-
throw new Error(
|
|
241
|
+
throw new Error('Invalid action:');
|
|
244
242
|
}
|
|
245
243
|
}
|
|
246
244
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
@@ -249,9 +247,9 @@ async function executeNonInteractive(context, action, cmdOptions) {
|
|
|
249
247
|
async function interactiveIntegrationsManagement(context) {
|
|
250
248
|
let continueManaging = true;
|
|
251
249
|
while (continueManaging) {
|
|
252
|
-
console.log(
|
|
253
|
-
console.log(
|
|
254
|
-
console.log(
|
|
250
|
+
console.log('\n' + '='.repeat(60));
|
|
251
|
+
console.log('š Integrations');
|
|
252
|
+
console.log('='.repeat(60) + '\n');
|
|
255
253
|
const actionAnswer = await safePrompt([
|
|
256
254
|
{
|
|
257
255
|
type: 'list',
|
|
@@ -265,9 +263,9 @@ async function interactiveIntegrationsManagement(context) {
|
|
|
265
263
|
{ name: 'š Manage triggers', value: 'webhooks' },
|
|
266
264
|
{ name: 'š Manage MCP servers', value: 'mcp' },
|
|
267
265
|
{ name: 'šļø Disconnect an integration', value: 'disconnect' },
|
|
268
|
-
{ name: 'ā Exit', value: 'exit' }
|
|
269
|
-
]
|
|
270
|
-
}
|
|
266
|
+
{ name: 'ā Exit', value: 'exit' },
|
|
267
|
+
],
|
|
268
|
+
},
|
|
271
269
|
]);
|
|
272
270
|
if (!actionAnswer)
|
|
273
271
|
return;
|
|
@@ -296,7 +294,7 @@ async function interactiveIntegrationsManagement(context) {
|
|
|
296
294
|
break;
|
|
297
295
|
case 'exit':
|
|
298
296
|
continueManaging = false;
|
|
299
|
-
console.log(
|
|
297
|
+
console.log('\nš Goodbye!\n');
|
|
300
298
|
break;
|
|
301
299
|
}
|
|
302
300
|
}
|
|
@@ -305,15 +303,15 @@ async function interactiveIntegrationsManagement(context) {
|
|
|
305
303
|
// List Available Integrations
|
|
306
304
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
307
305
|
async function listAvailableIntegrations(context) {
|
|
308
|
-
writeProgress(
|
|
306
|
+
writeProgress('š Fetching available integrations...');
|
|
309
307
|
try {
|
|
310
308
|
const integrations = await fetchAvailableIntegrations(context.unifiedToApi);
|
|
311
|
-
console.log(
|
|
312
|
-
console.log(
|
|
313
|
-
console.log(
|
|
309
|
+
console.log('\n' + '='.repeat(60));
|
|
310
|
+
console.log('š Available Integrations');
|
|
311
|
+
console.log('='.repeat(60) + '\n');
|
|
314
312
|
if (integrations.length === 0) {
|
|
315
|
-
console.log(
|
|
316
|
-
console.log(
|
|
313
|
+
console.log('ā¹ļø No integrations available.');
|
|
314
|
+
console.log('š” Contact support to enable integrations for your workspace.\n');
|
|
317
315
|
return;
|
|
318
316
|
}
|
|
319
317
|
// Group by category
|
|
@@ -326,15 +324,15 @@ async function listAvailableIntegrations(context) {
|
|
|
326
324
|
}
|
|
327
325
|
for (const [category, items] of Object.entries(byCategory)) {
|
|
328
326
|
console.log(`š ${category.toUpperCase()}`);
|
|
329
|
-
items.forEach(i => {
|
|
327
|
+
items.forEach((i) => {
|
|
330
328
|
const authBadge = i.authSupport === 'oauth' ? 'š' : i.authSupport === 'token' ? 'š' : 'šš';
|
|
331
329
|
console.log(` ${authBadge} ${i.name} (${i.value})`);
|
|
332
330
|
});
|
|
333
331
|
console.log();
|
|
334
332
|
}
|
|
335
|
-
console.log(
|
|
333
|
+
console.log('='.repeat(60));
|
|
336
334
|
console.log(`Total: ${integrations.length} integration(s) available`);
|
|
337
|
-
console.log(
|
|
335
|
+
console.log('š = OAuth š = API Key/Token šš = Both\n');
|
|
338
336
|
}
|
|
339
337
|
catch (error) {
|
|
340
338
|
writeError(`ā Failed to fetch integrations: ${error.message}`);
|
|
@@ -351,7 +349,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
351
349
|
try {
|
|
352
350
|
// Fetch integration details
|
|
353
351
|
const integrations = await fetchAvailableIntegrations(context.unifiedToApi);
|
|
354
|
-
const integration = integrations.find(i => i.value === integrationType);
|
|
352
|
+
const integration = integrations.find((i) => i.value === integrationType);
|
|
355
353
|
if (!integration) {
|
|
356
354
|
if (jsonOutput) {
|
|
357
355
|
console.log(JSON.stringify({ error: `Integration not found: ${integrationType}` }));
|
|
@@ -359,9 +357,9 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
359
357
|
else {
|
|
360
358
|
console.error(`ā Integration not found: ${integrationType}`);
|
|
361
359
|
console.log('\nAvailable integrations:');
|
|
362
|
-
integrations.forEach(i => console.log(` - ${i.value} (${i.name})`));
|
|
360
|
+
integrations.forEach((i) => console.log(` - ${i.value} (${i.name})`));
|
|
363
361
|
}
|
|
364
|
-
throw new Error(
|
|
362
|
+
throw new Error('Operation failed');
|
|
365
363
|
}
|
|
366
364
|
// Fetch available webhook events for this integration
|
|
367
365
|
let webhookEvents = [];
|
|
@@ -384,7 +382,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
384
382
|
oauthConfigured: integration.oauthConfigured,
|
|
385
383
|
oauthScopes: integration.oauthScopes || [],
|
|
386
384
|
tokenFields: integration.tokenFields || [],
|
|
387
|
-
webhookEvents: webhookEvents.map(e => ({
|
|
385
|
+
webhookEvents: webhookEvents.map((e) => ({
|
|
388
386
|
trigger: `${e.objectType}.${e.event}`,
|
|
389
387
|
objectType: e.objectType,
|
|
390
388
|
event: e.event,
|
|
@@ -402,9 +400,9 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
402
400
|
}
|
|
403
401
|
else {
|
|
404
402
|
// Human-readable output
|
|
405
|
-
console.log(
|
|
403
|
+
console.log('\n' + '='.repeat(60));
|
|
406
404
|
console.log(`š Integration: ${integration.name}`);
|
|
407
|
-
console.log(
|
|
405
|
+
console.log('='.repeat(60));
|
|
408
406
|
console.log(`\n Type: ${integration.value}`);
|
|
409
407
|
console.log(` Categories: ${integration.categories.join(', ')}`);
|
|
410
408
|
console.log(` Auth Support: ${integration.authSupport}`);
|
|
@@ -412,7 +410,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
412
410
|
// OAuth Scopes
|
|
413
411
|
if (integration.oauthScopes && integration.oauthScopes.length > 0) {
|
|
414
412
|
console.log('\n OAuth Scopes:');
|
|
415
|
-
integration.oauthScopes.forEach(s => {
|
|
413
|
+
integration.oauthScopes.forEach((s) => {
|
|
416
414
|
if (s.friendlyLabel) {
|
|
417
415
|
console.log(` - ${s.friendlyLabel} (${s.unifiedScope})`);
|
|
418
416
|
if (s.friendlyDescription) {
|
|
@@ -427,7 +425,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
427
425
|
// Token Fields
|
|
428
426
|
if (integration.tokenFields && integration.tokenFields.length > 0) {
|
|
429
427
|
console.log('\n Token Fields:');
|
|
430
|
-
integration.tokenFields.forEach(f => {
|
|
428
|
+
integration.tokenFields.forEach((f) => {
|
|
431
429
|
console.log(` - ${f.name}`);
|
|
432
430
|
if (f.instructions) {
|
|
433
431
|
console.log(` š” ${f.instructions}`);
|
|
@@ -437,15 +435,15 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
437
435
|
// Webhook Events/Triggers
|
|
438
436
|
if (webhookEvents.length > 0) {
|
|
439
437
|
console.log('\n Available Triggers:');
|
|
440
|
-
webhookEvents.forEach(e => {
|
|
438
|
+
webhookEvents.forEach((e) => {
|
|
441
439
|
console.log(` - ${e.objectType}.${e.event} [${e.webhookType}] - ${e.friendlyDescription}`);
|
|
442
440
|
});
|
|
443
441
|
}
|
|
444
442
|
else {
|
|
445
443
|
console.log('\n Available Triggers: None');
|
|
446
444
|
}
|
|
447
|
-
console.log(
|
|
448
|
-
console.log(
|
|
445
|
+
console.log('\n' + '='.repeat(60));
|
|
446
|
+
console.log('\nš” Use with non-interactive commands:');
|
|
449
447
|
console.log(` lua integrations connect --integration ${integrationType} --auth-method oauth --scopes all`);
|
|
450
448
|
if (webhookEvents.length > 0) {
|
|
451
449
|
const exampleTrigger = `${webhookEvents[0].objectType}.${webhookEvents[0].event}`;
|
|
@@ -461,7 +459,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
461
459
|
else {
|
|
462
460
|
writeError(`ā Failed to get integration info: ${error.message}`);
|
|
463
461
|
}
|
|
464
|
-
throw new Error(
|
|
462
|
+
throw new Error('Operation failed');
|
|
465
463
|
}
|
|
466
464
|
}
|
|
467
465
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
@@ -469,7 +467,7 @@ async function showIntegrationInfo(context, integrationType, jsonOutput = false)
|
|
|
469
467
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
470
468
|
async function connectIntegrationFlow(context, options = {}) {
|
|
471
469
|
// Step 1: Fetch available integrations (API excludes already-connected types)
|
|
472
|
-
writeProgress(
|
|
470
|
+
writeProgress('š Fetching integrations...');
|
|
473
471
|
let availableIntegrations;
|
|
474
472
|
try {
|
|
475
473
|
availableIntegrations = await fetchAvailableIntegrations(context.unifiedToApi, context.agentId);
|
|
@@ -479,7 +477,7 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
479
477
|
return;
|
|
480
478
|
}
|
|
481
479
|
if (availableIntegrations.length === 0) {
|
|
482
|
-
writeInfo(
|
|
480
|
+
writeInfo('All available integrations are already connected (or none are enabled).');
|
|
483
481
|
console.log("š” Use 'lua integrations update' to change scopes on an existing connection.\n");
|
|
484
482
|
return;
|
|
485
483
|
}
|
|
@@ -487,16 +485,18 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
487
485
|
// Step 2: Select integration (with search/filter support)
|
|
488
486
|
let selectedIntegration;
|
|
489
487
|
if (options.integration) {
|
|
490
|
-
selectedIntegration = availableIntegrations.find(i => i.value === options.integration);
|
|
488
|
+
selectedIntegration = availableIntegrations.find((i) => i.value === options.integration);
|
|
491
489
|
if (!selectedIntegration) {
|
|
492
490
|
// Not in available list ā either already connected or doesn't exist
|
|
493
491
|
console.error(`ā Integration "${options.integration}" not found or already connected.`);
|
|
494
|
-
console.log("š” If already connected, use 'lua integrations update --integration " +
|
|
492
|
+
console.log("š” If already connected, use 'lua integrations update --integration " +
|
|
493
|
+
options.integration +
|
|
494
|
+
"' to change scopes.");
|
|
495
495
|
if (availableIntegrations.length > 0) {
|
|
496
496
|
console.log('\nAvailable integrations to connect:');
|
|
497
|
-
availableIntegrations.forEach(i => console.log(` - ${i.value} (${i.name})`));
|
|
497
|
+
availableIntegrations.forEach((i) => console.log(` - ${i.value} (${i.name})`));
|
|
498
498
|
}
|
|
499
|
-
throw new Error(
|
|
499
|
+
throw new Error('Integration');
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
else {
|
|
@@ -506,7 +506,7 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
506
506
|
type: 'input',
|
|
507
507
|
name: 'searchTerm',
|
|
508
508
|
message: 'Search integrations (or press Enter to browse all):',
|
|
509
|
-
}
|
|
509
|
+
},
|
|
510
510
|
]);
|
|
511
511
|
if (!searchAnswer)
|
|
512
512
|
return;
|
|
@@ -514,9 +514,9 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
514
514
|
let filteredIntegrations = availableIntegrations;
|
|
515
515
|
if (searchAnswer.searchTerm.trim()) {
|
|
516
516
|
const searchLower = searchAnswer.searchTerm.toLowerCase().trim();
|
|
517
|
-
filteredIntegrations = availableIntegrations.filter(i => i.name.toLowerCase().includes(searchLower) ||
|
|
517
|
+
filteredIntegrations = availableIntegrations.filter((i) => i.name.toLowerCase().includes(searchLower) ||
|
|
518
518
|
i.value.toLowerCase().includes(searchLower) ||
|
|
519
|
-
i.categories.some(c => c.toLowerCase().includes(searchLower)));
|
|
519
|
+
i.categories.some((c) => c.toLowerCase().includes(searchLower)));
|
|
520
520
|
if (filteredIntegrations.length === 0) {
|
|
521
521
|
writeInfo(`No available integrations found matching "${searchAnswer.searchTerm}"`);
|
|
522
522
|
console.log(`š” If the integration is already connected, use 'lua integrations update' to change scopes.`);
|
|
@@ -526,8 +526,8 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
526
526
|
type: 'confirm',
|
|
527
527
|
name: 'browseAll',
|
|
528
528
|
message: 'Would you like to browse all available integrations?',
|
|
529
|
-
default: true
|
|
530
|
-
}
|
|
529
|
+
default: true,
|
|
530
|
+
},
|
|
531
531
|
]);
|
|
532
532
|
if (!browseAnswer?.browseAll)
|
|
533
533
|
return;
|
|
@@ -543,14 +543,14 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
543
543
|
name: 'integration',
|
|
544
544
|
message: 'Select an integration to connect:',
|
|
545
545
|
pageSize: 15,
|
|
546
|
-
choices: filteredIntegrations.map(i => {
|
|
546
|
+
choices: filteredIntegrations.map((i) => {
|
|
547
547
|
const authBadge = i.authSupport === 'oauth' ? 'š' : i.authSupport === 'token' ? 'š' : 'šš';
|
|
548
548
|
return {
|
|
549
549
|
name: `${authBadge} ${i.name} (${i.categories.join(', ')})`,
|
|
550
|
-
value: i
|
|
550
|
+
value: i,
|
|
551
551
|
};
|
|
552
|
-
})
|
|
553
|
-
}
|
|
552
|
+
}),
|
|
553
|
+
},
|
|
554
554
|
]);
|
|
555
555
|
if (!integrationAnswer)
|
|
556
556
|
return;
|
|
@@ -561,8 +561,7 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
561
561
|
console.log(` Auth Support: ${selectedIntegration.authSupport}`);
|
|
562
562
|
console.log(` OAuth Configured: ${selectedIntegration.oauthConfigured ? 'Yes' : 'No'}`);
|
|
563
563
|
// Step 3: Determine auth method and get scopes
|
|
564
|
-
const canUseOAuth = selectedIntegration.oauthConfigured &&
|
|
565
|
-
['oauth', 'both'].includes(selectedIntegration.authSupport);
|
|
564
|
+
const canUseOAuth = selectedIntegration.oauthConfigured && ['oauth', 'both'].includes(selectedIntegration.authSupport);
|
|
566
565
|
const canUseToken = ['token', 'both'].includes(selectedIntegration.authSupport);
|
|
567
566
|
let authMethod;
|
|
568
567
|
let selectedScopes = [];
|
|
@@ -570,36 +569,38 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
570
569
|
if (options.authMethod) {
|
|
571
570
|
if (!['oauth', 'token'].includes(options.authMethod)) {
|
|
572
571
|
console.error(`ā Invalid --auth-method: "${options.authMethod}". Use 'oauth' or 'token'`);
|
|
573
|
-
throw new Error(
|
|
572
|
+
throw new Error('Invalid --auth-method:');
|
|
574
573
|
}
|
|
575
574
|
if (options.authMethod === 'oauth' && !canUseOAuth) {
|
|
576
575
|
console.error(`ā OAuth is not available for ${selectedIntegration.name}.`);
|
|
577
576
|
if (canUseToken) {
|
|
578
577
|
console.log(`š” Use --auth-method token instead.`);
|
|
579
578
|
}
|
|
580
|
-
throw new Error(
|
|
579
|
+
throw new Error('Operation failed');
|
|
581
580
|
}
|
|
582
581
|
if (options.authMethod === 'token' && !canUseToken) {
|
|
583
582
|
console.error(`ā Token authentication is not available for ${selectedIntegration.name}.`);
|
|
584
583
|
if (canUseOAuth) {
|
|
585
584
|
console.log(`š” Use --auth-method oauth instead.`);
|
|
586
585
|
}
|
|
587
|
-
throw new Error(
|
|
586
|
+
throw new Error('Operation failed');
|
|
588
587
|
}
|
|
589
588
|
authMethod = options.authMethod;
|
|
590
589
|
writeInfo(`Using ${authMethod === 'oauth' ? 'OAuth 2.0' : 'API Token'} authentication`);
|
|
591
590
|
}
|
|
592
591
|
else if (canUseOAuth && canUseToken) {
|
|
593
592
|
// Both available - let user choose interactively
|
|
594
|
-
const authAnswer = await safePrompt([
|
|
593
|
+
const authAnswer = await safePrompt([
|
|
594
|
+
{
|
|
595
595
|
type: 'list',
|
|
596
596
|
name: 'method',
|
|
597
597
|
message: 'Choose authentication method:',
|
|
598
598
|
choices: [
|
|
599
599
|
{ name: 'š OAuth 2.0 (recommended)', value: 'oauth' },
|
|
600
|
-
{ name: 'š API Token / Personal Access Token', value: 'token' }
|
|
601
|
-
]
|
|
602
|
-
}
|
|
600
|
+
{ name: 'š API Token / Personal Access Token', value: 'token' },
|
|
601
|
+
],
|
|
602
|
+
},
|
|
603
|
+
]);
|
|
603
604
|
if (!authAnswer)
|
|
604
605
|
return;
|
|
605
606
|
authMethod = authAnswer.method;
|
|
@@ -620,7 +621,7 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
620
621
|
}
|
|
621
622
|
// Handle OAuth scope selection
|
|
622
623
|
if (authMethod === 'oauth' && selectedIntegration.oauthScopes?.length) {
|
|
623
|
-
const availableScopes = selectedIntegration.oauthScopes.map(s => s.unifiedScope);
|
|
624
|
+
const availableScopes = selectedIntegration.oauthScopes.map((s) => s.unifiedScope);
|
|
624
625
|
if (options.scopes) {
|
|
625
626
|
// Non-interactive: use provided scopes
|
|
626
627
|
if (options.scopes.toLowerCase() === 'all') {
|
|
@@ -629,13 +630,13 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
629
630
|
}
|
|
630
631
|
else {
|
|
631
632
|
// Parse comma-separated scopes
|
|
632
|
-
const requestedScopes = options.scopes.split(',').map(s => s.trim());
|
|
633
|
-
const invalidScopes = requestedScopes.filter(s => !availableScopes.includes(s));
|
|
633
|
+
const requestedScopes = options.scopes.split(',').map((s) => s.trim());
|
|
634
|
+
const invalidScopes = requestedScopes.filter((s) => !availableScopes.includes(s));
|
|
634
635
|
if (invalidScopes.length > 0) {
|
|
635
636
|
console.error(`ā Invalid scopes: ${invalidScopes.join(', ')}`);
|
|
636
637
|
console.log(`\nAvailable scopes for ${selectedIntegration.name}:`);
|
|
637
|
-
availableScopes.forEach(s => console.log(` - ${s}`));
|
|
638
|
-
throw new Error(
|
|
638
|
+
availableScopes.forEach((s) => console.log(` - ${s}`));
|
|
639
|
+
throw new Error('Invalid scopes: ${invalidScopes.join(');
|
|
639
640
|
}
|
|
640
641
|
selectedScopes = requestedScopes;
|
|
641
642
|
writeInfo(`Using ${selectedScopes.length} specified scope(s)`);
|
|
@@ -643,13 +644,14 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
643
644
|
}
|
|
644
645
|
else {
|
|
645
646
|
// Interactive: prompt for scope selection
|
|
646
|
-
const scopeAnswer = await safePrompt([
|
|
647
|
+
const scopeAnswer = await safePrompt([
|
|
648
|
+
{
|
|
647
649
|
type: 'checkbox',
|
|
648
650
|
name: 'scopes',
|
|
649
651
|
message: 'Select OAuth scopes (Space to toggle, Enter to confirm, leave empty for all):',
|
|
650
652
|
pageSize: 15,
|
|
651
653
|
loop: false,
|
|
652
|
-
choices: selectedIntegration.oauthScopes.map(s => {
|
|
654
|
+
choices: selectedIntegration.oauthScopes.map((s) => {
|
|
653
655
|
// Use friendly label if available, otherwise fall back to technical name
|
|
654
656
|
const displayName = s.friendlyLabel || s.unifiedScope;
|
|
655
657
|
const description = s.friendlyDescription
|
|
@@ -658,16 +660,15 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
658
660
|
return {
|
|
659
661
|
name: `${displayName}${description}`,
|
|
660
662
|
value: s.unifiedScope,
|
|
661
|
-
checked: false
|
|
663
|
+
checked: false,
|
|
662
664
|
};
|
|
663
|
-
})
|
|
664
|
-
}
|
|
665
|
+
}),
|
|
666
|
+
},
|
|
667
|
+
]);
|
|
665
668
|
if (!scopeAnswer)
|
|
666
669
|
return;
|
|
667
670
|
// If none selected, request all scopes
|
|
668
|
-
selectedScopes = scopeAnswer.scopes.length > 0
|
|
669
|
-
? scopeAnswer.scopes
|
|
670
|
-
: availableScopes;
|
|
671
|
+
selectedScopes = scopeAnswer.scopes.length > 0 ? scopeAnswer.scopes : availableScopes;
|
|
671
672
|
console.log(`\nā Will request ${selectedScopes.length} scope(s)`);
|
|
672
673
|
}
|
|
673
674
|
}
|
|
@@ -696,12 +697,14 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
696
697
|
}
|
|
697
698
|
else {
|
|
698
699
|
// Interactive: ask user
|
|
699
|
-
const sensitiveAnswer = await safePrompt([
|
|
700
|
+
const sensitiveAnswer = await safePrompt([
|
|
701
|
+
{
|
|
700
702
|
type: 'confirm',
|
|
701
703
|
name: 'hide',
|
|
702
704
|
message: 'Hide sensitive data (PII) from MCP tools?',
|
|
703
|
-
default: false
|
|
704
|
-
}
|
|
705
|
+
default: false,
|
|
706
|
+
},
|
|
707
|
+
]);
|
|
705
708
|
if (sensitiveAnswer) {
|
|
706
709
|
hideSensitive = sensitiveAnswer.hide;
|
|
707
710
|
}
|
|
@@ -723,24 +726,25 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
723
726
|
}
|
|
724
727
|
if (options.triggers) {
|
|
725
728
|
// Non-interactive: parse comma-separated triggers (e.g., 'task_task.created,task_task.updated')
|
|
726
|
-
const requestedTriggers = options.triggers.split(',').map(t => t.trim());
|
|
729
|
+
const requestedTriggers = options.triggers.split(',').map((t) => t.trim());
|
|
727
730
|
for (const trigger of requestedTriggers) {
|
|
728
731
|
const [objectType, event] = trigger.split('.');
|
|
729
|
-
const matchingEvent = availableEvents.find(e => e.objectType === objectType && e.event === event);
|
|
732
|
+
const matchingEvent = availableEvents.find((e) => e.objectType === objectType && e.event === event);
|
|
730
733
|
if (!matchingEvent) {
|
|
731
734
|
console.error(`ā Invalid trigger: ${trigger}`);
|
|
732
735
|
console.log(`\nAvailable triggers for ${selectedIntegration.name}:`);
|
|
733
|
-
availableEvents.forEach(e => {
|
|
736
|
+
availableEvents.forEach((e) => {
|
|
734
737
|
console.log(` - ${e.objectType}.${e.event} [${e.webhookType}] - ${e.friendlyDescription}`);
|
|
735
738
|
});
|
|
736
|
-
throw new Error(
|
|
739
|
+
throw new Error('Invalid trigger: ${trigger}');
|
|
737
740
|
}
|
|
738
741
|
selectedTriggers.push(matchingEvent);
|
|
739
742
|
}
|
|
740
743
|
writeInfo(`Selected ${selectedTriggers.length} trigger(s)`);
|
|
741
744
|
// If custom webhook mode, prompt for URL if not provided
|
|
742
745
|
if (isCustomWebhook && !options.hookUrl) {
|
|
743
|
-
const urlAnswer = await safePrompt([
|
|
746
|
+
const urlAnswer = await safePrompt([
|
|
747
|
+
{
|
|
744
748
|
type: 'input',
|
|
745
749
|
name: 'url',
|
|
746
750
|
message: 'Enter your webhook URL:',
|
|
@@ -752,8 +756,9 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
752
756
|
catch {
|
|
753
757
|
return 'Please enter a valid URL';
|
|
754
758
|
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
]);
|
|
757
762
|
if (!urlAnswer)
|
|
758
763
|
return;
|
|
759
764
|
webhookUrl = urlAnswer.url;
|
|
@@ -766,46 +771,53 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
766
771
|
console.log('ā'.repeat(60));
|
|
767
772
|
console.log('\nTriggers wake your agent when something happens in the integration.');
|
|
768
773
|
console.log('We recommend adding only what you actually need ā you can always add them later.');
|
|
769
|
-
const wantTriggersAnswer = await safePrompt([
|
|
774
|
+
const wantTriggersAnswer = await safePrompt([
|
|
775
|
+
{
|
|
770
776
|
type: 'confirm',
|
|
771
777
|
name: 'want',
|
|
772
778
|
message: 'Do you want to configure triggers now?',
|
|
773
779
|
default: false,
|
|
774
|
-
}
|
|
780
|
+
},
|
|
781
|
+
]);
|
|
775
782
|
if (!wantTriggersAnswer)
|
|
776
783
|
return;
|
|
777
784
|
if (wantTriggersAnswer.want) {
|
|
778
785
|
console.log('\nSelect the events you actually need:');
|
|
779
786
|
console.log('(Space to toggle, Enter to confirm. Nothing pre-selected.)');
|
|
780
|
-
const triggerAnswer = await safePrompt([
|
|
787
|
+
const triggerAnswer = await safePrompt([
|
|
788
|
+
{
|
|
781
789
|
type: 'checkbox',
|
|
782
790
|
name: 'triggers',
|
|
783
791
|
message: 'Select triggers:',
|
|
784
792
|
pageSize: 15,
|
|
785
793
|
loop: false,
|
|
786
|
-
choices: availableEvents.map(e => ({
|
|
794
|
+
choices: availableEvents.map((e) => ({
|
|
787
795
|
name: `${e.friendlyDescription} [${e.webhookType}]`,
|
|
788
796
|
value: e,
|
|
789
|
-
checked: false // None pre-selected ā user chooses what they need
|
|
790
|
-
}))
|
|
791
|
-
}
|
|
797
|
+
checked: false, // None pre-selected ā user chooses what they need
|
|
798
|
+
})),
|
|
799
|
+
},
|
|
800
|
+
]);
|
|
792
801
|
if (triggerAnswer && triggerAnswer.triggers.length > 0) {
|
|
793
802
|
selectedTriggers = triggerAnswer.triggers;
|
|
794
803
|
// Ask about webhook mode only if triggers are selected
|
|
795
|
-
const modeAnswer = await safePrompt([
|
|
804
|
+
const modeAnswer = await safePrompt([
|
|
805
|
+
{
|
|
796
806
|
type: 'list',
|
|
797
807
|
name: 'mode',
|
|
798
808
|
message: 'How should these events be handled?',
|
|
799
809
|
choices: [
|
|
800
810
|
{ name: 'š¤ Agent Trigger (recommended) - Events wake up your agent', value: 'agent' },
|
|
801
|
-
{ name: 'š Custom URL - Send events to your own webhook URL', value: 'custom' }
|
|
802
|
-
]
|
|
803
|
-
}
|
|
811
|
+
{ name: 'š Custom URL - Send events to your own webhook URL', value: 'custom' },
|
|
812
|
+
],
|
|
813
|
+
},
|
|
814
|
+
]);
|
|
804
815
|
if (!modeAnswer)
|
|
805
816
|
return;
|
|
806
817
|
if (modeAnswer.mode === 'custom') {
|
|
807
818
|
isCustomWebhook = true;
|
|
808
|
-
const urlAnswer = await safePrompt([
|
|
819
|
+
const urlAnswer = await safePrompt([
|
|
820
|
+
{
|
|
809
821
|
type: 'input',
|
|
810
822
|
name: 'url',
|
|
811
823
|
message: 'Enter your webhook URL:',
|
|
@@ -817,8 +829,9 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
817
829
|
catch {
|
|
818
830
|
return 'Please enter a valid URL';
|
|
819
831
|
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
832
|
+
},
|
|
833
|
+
},
|
|
834
|
+
]);
|
|
822
835
|
if (!urlAnswer)
|
|
823
836
|
return;
|
|
824
837
|
webhookUrl = urlAnswer.url;
|
|
@@ -846,12 +859,12 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
846
859
|
writeInfo(`Note: Could not fetch available triggers (${error.message})`);
|
|
847
860
|
}
|
|
848
861
|
// Step 5: Get authorization URL from Lua API
|
|
849
|
-
writeProgress(
|
|
862
|
+
writeProgress('š Preparing authorization...');
|
|
850
863
|
const state = Buffer.from(JSON.stringify({
|
|
851
864
|
agentId: context.agentId,
|
|
852
865
|
integration: selectedIntegration.value,
|
|
853
866
|
authMethod,
|
|
854
|
-
timestamp: Date.now()
|
|
867
|
+
timestamp: Date.now(),
|
|
855
868
|
})).toString('base64');
|
|
856
869
|
// Encode both agentId and userId in externalXref for the connection
|
|
857
870
|
const externalXref = JSON.stringify({
|
|
@@ -872,9 +885,9 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
872
885
|
// Auth URL is already resolved by the API (redirect wrappers followed server-side)
|
|
873
886
|
const authUrl = authUrlResult.data.authUrl;
|
|
874
887
|
// Step 4: Start callback server and open browser
|
|
875
|
-
console.log(
|
|
876
|
-
console.log(
|
|
877
|
-
console.log(
|
|
888
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
889
|
+
console.log('š Starting OAuth authorization flow...');
|
|
890
|
+
console.log('ā'.repeat(60));
|
|
878
891
|
console.log(`\nIntegration: ${selectedIntegration.name}`);
|
|
879
892
|
console.log(`\nš Authorization URL (copy if browser doesn't open):\n ${authUrl}\n`);
|
|
880
893
|
// Start the callback server
|
|
@@ -882,17 +895,17 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
882
895
|
// Auto-open browser
|
|
883
896
|
try {
|
|
884
897
|
await open(authUrl);
|
|
885
|
-
writeInfo(
|
|
898
|
+
writeInfo('š Browser opened - please complete the authorization');
|
|
886
899
|
}
|
|
887
900
|
catch (error) {
|
|
888
|
-
writeInfo(
|
|
901
|
+
writeInfo('š” Could not open browser automatically. Please open the URL above manually.');
|
|
889
902
|
}
|
|
890
|
-
console.log(
|
|
891
|
-
console.log(
|
|
903
|
+
console.log('\nā³ Waiting for authorization (5 minute timeout)...');
|
|
904
|
+
console.log('š” Complete the authorization in your browser.\n');
|
|
892
905
|
// Wait for callback
|
|
893
906
|
const result = await callbackPromise;
|
|
894
907
|
if (result.success && result.connectionId) {
|
|
895
|
-
writeSuccess(
|
|
908
|
+
writeSuccess('\nā
Authorization successful!');
|
|
896
909
|
// Finalize the connection (sets up MCP server internally and creates webhooks)
|
|
897
910
|
await finalizeConnection(context, selectedIntegration, result.connectionId, selectedScopes, hideSensitive, {
|
|
898
911
|
triggers: selectedTriggers,
|
|
@@ -906,13 +919,15 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
906
919
|
console.log(` Log ID: ${result.logId}`);
|
|
907
920
|
}
|
|
908
921
|
// Report auth failure for observability (fire and forget)
|
|
909
|
-
context.unifiedToApi
|
|
922
|
+
context.unifiedToApi
|
|
923
|
+
.reportAuthFailure({
|
|
910
924
|
integrationType: selectedIntegration.value,
|
|
911
925
|
error: result.error || 'Unknown OAuth failure',
|
|
912
926
|
logId: result.logId,
|
|
913
927
|
agentId: context.agentId,
|
|
914
928
|
source: 'cli',
|
|
915
|
-
})
|
|
929
|
+
})
|
|
930
|
+
.catch(() => { });
|
|
916
931
|
console.log("š” Please try again with 'lua integrations connect'\n");
|
|
917
932
|
}
|
|
918
933
|
}
|
|
@@ -923,7 +938,7 @@ async function connectIntegrationFlow(context, options = {}) {
|
|
|
923
938
|
async function finalizeConnection(context, integration, connectionId, scopes, hideSensitive = false, webhookConfig = { triggers: [], webhookUrl: '', isCustomWebhook: false }) {
|
|
924
939
|
writeProgress(`š Setting up ${integration.name} connection...`);
|
|
925
940
|
// Build trigger params for the API (include per-trigger hookUrl/interval if set)
|
|
926
|
-
const triggers = webhookConfig.triggers.map(t => ({
|
|
941
|
+
const triggers = webhookConfig.triggers.map((t) => ({
|
|
927
942
|
objectType: t.objectType,
|
|
928
943
|
event: t.event,
|
|
929
944
|
hookUrl: t.hookUrl || (webhookConfig.isCustomWebhook ? webhookConfig.webhookUrl : undefined),
|
|
@@ -945,9 +960,9 @@ async function finalizeConnection(context, integration, connectionId, scopes, hi
|
|
|
945
960
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
946
961
|
// Display Results
|
|
947
962
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
948
|
-
console.log(
|
|
949
|
-
console.log(
|
|
950
|
-
console.log(
|
|
963
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
964
|
+
console.log('š Connection Established!');
|
|
965
|
+
console.log('ā'.repeat(60));
|
|
951
966
|
console.log(`\n Integration: ${integration.name}`);
|
|
952
967
|
console.log(` Connection ID: ${connectionId}`);
|
|
953
968
|
// MCP Server status
|
|
@@ -958,8 +973,8 @@ async function finalizeConnection(context, integration, connectionId, scopes, hi
|
|
|
958
973
|
// Show requested scopes with friendly labels
|
|
959
974
|
if (scopes.length > 0) {
|
|
960
975
|
console.log(`\n š Permissions (${scopes.length}):`);
|
|
961
|
-
scopes.forEach(scopeName => {
|
|
962
|
-
const scopeInfo = integration.oauthScopes?.find(s => s.unifiedScope === scopeName);
|
|
976
|
+
scopes.forEach((scopeName) => {
|
|
977
|
+
const scopeInfo = integration.oauthScopes?.find((s) => s.unifiedScope === scopeName);
|
|
963
978
|
if (scopeInfo?.friendlyLabel) {
|
|
964
979
|
console.log(` ⢠${scopeInfo.friendlyLabel}`);
|
|
965
980
|
}
|
|
@@ -980,20 +995,20 @@ async function finalizeConnection(context, integration, connectionId, scopes, hi
|
|
|
980
995
|
else {
|
|
981
996
|
console.log(` Mode: Agent wake-up`);
|
|
982
997
|
}
|
|
983
|
-
webhooks.forEach(wh => {
|
|
984
|
-
const trigger = webhookConfig.triggers.find(t => t.objectType === wh.objectType && t.event === wh.event);
|
|
998
|
+
webhooks.forEach((wh) => {
|
|
999
|
+
const trigger = webhookConfig.triggers.find((t) => t.objectType === wh.objectType && t.event === wh.event);
|
|
985
1000
|
const desc = trigger?.friendlyDescription || `${wh.objectType}.${wh.event}`;
|
|
986
1001
|
console.log(` ā ${desc}`);
|
|
987
1002
|
});
|
|
988
1003
|
if (failedWebhooks && failedWebhooks.length > 0) {
|
|
989
|
-
failedWebhooks.forEach(t => console.log(` ā ${t.objectType}.${t.event}: ${t.error}`));
|
|
1004
|
+
failedWebhooks.forEach((t) => console.log(` ā ${t.objectType}.${t.event}: ${t.error}`));
|
|
990
1005
|
}
|
|
991
1006
|
}
|
|
992
1007
|
else {
|
|
993
1008
|
console.log(`\n ā” Triggers: none (add later with: lua triggers create --connection ${connectionId})`);
|
|
994
1009
|
}
|
|
995
1010
|
// Summary message
|
|
996
|
-
console.log(
|
|
1011
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
997
1012
|
const capabilities = [];
|
|
998
1013
|
if (mcpServer.active) {
|
|
999
1014
|
capabilities.push('tools via MCP');
|
|
@@ -1021,16 +1036,16 @@ async function finalizeConnection(context, integration, connectionId, scopes, hi
|
|
|
1021
1036
|
});
|
|
1022
1037
|
}
|
|
1023
1038
|
async function listConnections(context) {
|
|
1024
|
-
writeProgress(
|
|
1039
|
+
writeProgress('š Loading connections...');
|
|
1025
1040
|
try {
|
|
1026
1041
|
// API now returns connections enriched with MCP server info
|
|
1027
1042
|
const connectionsResult = await context.unifiedToApi.getConnections(context.agentId);
|
|
1028
1043
|
const connections = connectionsResult.success ? connectionsResult.data || [] : [];
|
|
1029
|
-
console.log(
|
|
1030
|
-
console.log(
|
|
1031
|
-
console.log(
|
|
1044
|
+
console.log('\n' + '='.repeat(60));
|
|
1045
|
+
console.log('š Connected Integrations');
|
|
1046
|
+
console.log('='.repeat(60) + '\n');
|
|
1032
1047
|
if (connections.length === 0) {
|
|
1033
|
-
console.log(
|
|
1048
|
+
console.log('ā¹ļø No integrations connected yet.');
|
|
1034
1049
|
console.log("š” Run 'lua integrations connect' to connect an integration.\n");
|
|
1035
1050
|
return;
|
|
1036
1051
|
}
|
|
@@ -1064,7 +1079,7 @@ async function listConnections(context) {
|
|
|
1064
1079
|
console.log(` Connected: ${new Date(connection.createdAt).toLocaleDateString()}`);
|
|
1065
1080
|
console.log();
|
|
1066
1081
|
}
|
|
1067
|
-
console.log(
|
|
1082
|
+
console.log('='.repeat(60));
|
|
1068
1083
|
console.log(`Total: ${connections.length} integration(s)\n`);
|
|
1069
1084
|
}
|
|
1070
1085
|
catch (error) {
|
|
@@ -1103,7 +1118,7 @@ async function disconnectIntegrationInteractive(context) {
|
|
|
1103
1118
|
}
|
|
1104
1119
|
const connections = connectionsResult.data || [];
|
|
1105
1120
|
if (connections.length === 0) {
|
|
1106
|
-
console.log(
|
|
1121
|
+
console.log('\nā¹ļø No integrations to disconnect.\n');
|
|
1107
1122
|
return;
|
|
1108
1123
|
}
|
|
1109
1124
|
const connectionAnswer = await safePrompt([
|
|
@@ -1111,25 +1126,25 @@ async function disconnectIntegrationInteractive(context) {
|
|
|
1111
1126
|
type: 'list',
|
|
1112
1127
|
name: 'connection',
|
|
1113
1128
|
message: 'Select an integration to disconnect:',
|
|
1114
|
-
choices: connections.map(c => ({
|
|
1129
|
+
choices: connections.map((c) => ({
|
|
1115
1130
|
name: `${c.integrationName || c.integrationType} (${c.id.substring(0, 8)}...)`,
|
|
1116
|
-
value: c.id
|
|
1117
|
-
}))
|
|
1118
|
-
}
|
|
1131
|
+
value: c.id,
|
|
1132
|
+
})),
|
|
1133
|
+
},
|
|
1119
1134
|
]);
|
|
1120
1135
|
if (!connectionAnswer?.connection)
|
|
1121
1136
|
return;
|
|
1122
|
-
const selectedConnection = connections.find(c => c.id === connectionAnswer.connection);
|
|
1137
|
+
const selectedConnection = connections.find((c) => c.id === connectionAnswer.connection);
|
|
1123
1138
|
const confirmAnswer = await safePrompt([
|
|
1124
1139
|
{
|
|
1125
1140
|
type: 'confirm',
|
|
1126
1141
|
name: 'confirm',
|
|
1127
1142
|
message: `Disconnect ${selectedConnection?.integrationName || selectedConnection?.integrationType}? Your agent will lose access to this integration.`,
|
|
1128
|
-
default: false
|
|
1129
|
-
}
|
|
1143
|
+
default: false,
|
|
1144
|
+
},
|
|
1130
1145
|
]);
|
|
1131
1146
|
if (!confirmAnswer?.confirm) {
|
|
1132
|
-
console.log(
|
|
1147
|
+
console.log('\nā Cancelled.\n');
|
|
1133
1148
|
return;
|
|
1134
1149
|
}
|
|
1135
1150
|
await disconnectIntegration(context, connectionAnswer.connection);
|
|
@@ -1143,13 +1158,13 @@ async function disconnectIntegrationInteractive(context) {
|
|
|
1143
1158
|
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
1144
1159
|
async function updateConnectionFlow(context, options = {}) {
|
|
1145
1160
|
// Step 1: Fetch existing connections and available integrations
|
|
1146
|
-
writeProgress(
|
|
1161
|
+
writeProgress('š Loading connections...');
|
|
1147
1162
|
let connections = [];
|
|
1148
1163
|
let integrations = [];
|
|
1149
1164
|
try {
|
|
1150
1165
|
const [connectionsResult, integrationsResult] = await Promise.all([
|
|
1151
1166
|
context.unifiedToApi.getConnections(context.agentId),
|
|
1152
|
-
fetchAvailableIntegrations(context.unifiedToApi)
|
|
1167
|
+
fetchAvailableIntegrations(context.unifiedToApi),
|
|
1153
1168
|
]);
|
|
1154
1169
|
connections = connectionsResult.success ? connectionsResult.data || [] : [];
|
|
1155
1170
|
integrations = integrationsResult;
|
|
@@ -1159,7 +1174,7 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1159
1174
|
return;
|
|
1160
1175
|
}
|
|
1161
1176
|
if (connections.length === 0) {
|
|
1162
|
-
writeInfo(
|
|
1177
|
+
writeInfo('No integrations to update.');
|
|
1163
1178
|
console.log("š” Run 'lua integrations connect' to connect an integration.\n");
|
|
1164
1179
|
return;
|
|
1165
1180
|
}
|
|
@@ -1168,14 +1183,14 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1168
1183
|
let selectedIntegration;
|
|
1169
1184
|
if (options.integration) {
|
|
1170
1185
|
// Find connection by integration type
|
|
1171
|
-
selectedConnection = connections.find(c => c.integrationType === options.integration);
|
|
1186
|
+
selectedConnection = connections.find((c) => c.integrationType === options.integration);
|
|
1172
1187
|
if (!selectedConnection) {
|
|
1173
1188
|
console.error(`ā No connection found for integration "${options.integration}".`);
|
|
1174
1189
|
console.log('\nConnected integrations:');
|
|
1175
|
-
connections.forEach(c => console.log(` - ${c.integrationType} (${c.integrationName || c.integrationType})`));
|
|
1176
|
-
throw new Error(
|
|
1190
|
+
connections.forEach((c) => console.log(` - ${c.integrationType} (${c.integrationName || c.integrationType})`));
|
|
1191
|
+
throw new Error('No connection found for integration');
|
|
1177
1192
|
}
|
|
1178
|
-
selectedIntegration = integrations.find(i => i.value === options.integration);
|
|
1193
|
+
selectedIntegration = integrations.find((i) => i.value === options.integration);
|
|
1179
1194
|
}
|
|
1180
1195
|
else {
|
|
1181
1196
|
// Interactive selection
|
|
@@ -1184,16 +1199,16 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1184
1199
|
type: 'list',
|
|
1185
1200
|
name: 'connection',
|
|
1186
1201
|
message: 'Select a connection to update:',
|
|
1187
|
-
choices: connections.map(c => ({
|
|
1202
|
+
choices: connections.map((c) => ({
|
|
1188
1203
|
name: `${c.integrationName || c.integrationType} (${c.id.substring(0, 8)}...)`,
|
|
1189
|
-
value: c
|
|
1190
|
-
}))
|
|
1191
|
-
}
|
|
1204
|
+
value: c,
|
|
1205
|
+
})),
|
|
1206
|
+
},
|
|
1192
1207
|
]);
|
|
1193
1208
|
if (!connectionAnswer?.connection)
|
|
1194
1209
|
return;
|
|
1195
1210
|
selectedConnection = connectionAnswer.connection;
|
|
1196
|
-
selectedIntegration = integrations.find(i => i.value === selectedConnection.integrationType);
|
|
1211
|
+
selectedIntegration = integrations.find((i) => i.value === selectedConnection.integrationType);
|
|
1197
1212
|
}
|
|
1198
1213
|
if (!selectedIntegration) {
|
|
1199
1214
|
writeError(`ā Integration details not found for ${selectedConnection.integrationType}`);
|
|
@@ -1202,15 +1217,14 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1202
1217
|
console.log(`\nš Updating: ${selectedIntegration.name}`);
|
|
1203
1218
|
console.log(` Current Connection ID: ${selectedConnection.id}`);
|
|
1204
1219
|
// Step 3: Check if OAuth with configurable scopes
|
|
1205
|
-
const canUseOAuth = selectedIntegration.oauthConfigured &&
|
|
1206
|
-
['oauth', 'both'].includes(selectedIntegration.authSupport);
|
|
1220
|
+
const canUseOAuth = selectedIntegration.oauthConfigured && ['oauth', 'both'].includes(selectedIntegration.authSupport);
|
|
1207
1221
|
if (!canUseOAuth || !selectedIntegration.oauthScopes?.length) {
|
|
1208
|
-
writeInfo(
|
|
1209
|
-
console.log(
|
|
1222
|
+
writeInfo('This integration does not have configurable scopes.');
|
|
1223
|
+
console.log('š” To reconnect with different credentials, disconnect and connect again.\n');
|
|
1210
1224
|
return;
|
|
1211
1225
|
}
|
|
1212
1226
|
// Step 4: Select new scopes
|
|
1213
|
-
const availableScopes = selectedIntegration.oauthScopes.map(s => s.unifiedScope);
|
|
1227
|
+
const availableScopes = selectedIntegration.oauthScopes.map((s) => s.unifiedScope);
|
|
1214
1228
|
let selectedScopes = [];
|
|
1215
1229
|
if (options.scopes) {
|
|
1216
1230
|
// Non-interactive: use provided scopes
|
|
@@ -1219,13 +1233,13 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1219
1233
|
writeInfo(`Using all ${selectedScopes.length} available scope(s)`);
|
|
1220
1234
|
}
|
|
1221
1235
|
else {
|
|
1222
|
-
const requestedScopes = options.scopes.split(',').map(s => s.trim());
|
|
1223
|
-
const invalidScopes = requestedScopes.filter(s => !availableScopes.includes(s));
|
|
1236
|
+
const requestedScopes = options.scopes.split(',').map((s) => s.trim());
|
|
1237
|
+
const invalidScopes = requestedScopes.filter((s) => !availableScopes.includes(s));
|
|
1224
1238
|
if (invalidScopes.length > 0) {
|
|
1225
1239
|
console.error(`ā Invalid scopes: ${invalidScopes.join(', ')}`);
|
|
1226
1240
|
console.log(`\nAvailable scopes for ${selectedIntegration.name}:`);
|
|
1227
|
-
availableScopes.forEach(s => console.log(` - ${s}`));
|
|
1228
|
-
throw new Error(
|
|
1241
|
+
availableScopes.forEach((s) => console.log(` - ${s}`));
|
|
1242
|
+
throw new Error('Invalid scopes: ${invalidScopes.join(');
|
|
1229
1243
|
}
|
|
1230
1244
|
selectedScopes = requestedScopes;
|
|
1231
1245
|
writeInfo(`Using ${selectedScopes.length} specified scope(s)`);
|
|
@@ -1233,13 +1247,14 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1233
1247
|
}
|
|
1234
1248
|
else {
|
|
1235
1249
|
// Interactive: prompt for scope selection
|
|
1236
|
-
const scopeAnswer = await safePrompt([
|
|
1250
|
+
const scopeAnswer = await safePrompt([
|
|
1251
|
+
{
|
|
1237
1252
|
type: 'checkbox',
|
|
1238
1253
|
name: 'scopes',
|
|
1239
1254
|
message: 'Select new OAuth scopes (Space to toggle, Enter to confirm, leave empty for all):',
|
|
1240
1255
|
pageSize: 15,
|
|
1241
1256
|
loop: false,
|
|
1242
|
-
choices: selectedIntegration.oauthScopes.map(s => {
|
|
1257
|
+
choices: selectedIntegration.oauthScopes.map((s) => {
|
|
1243
1258
|
// Use friendly label if available, otherwise fall back to technical name
|
|
1244
1259
|
const displayName = s.friendlyLabel || s.unifiedScope;
|
|
1245
1260
|
const description = s.friendlyDescription
|
|
@@ -1248,15 +1263,14 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1248
1263
|
return {
|
|
1249
1264
|
name: `${displayName}${description}`,
|
|
1250
1265
|
value: s.unifiedScope,
|
|
1251
|
-
checked: false
|
|
1266
|
+
checked: false,
|
|
1252
1267
|
};
|
|
1253
|
-
})
|
|
1254
|
-
}
|
|
1268
|
+
}),
|
|
1269
|
+
},
|
|
1270
|
+
]);
|
|
1255
1271
|
if (!scopeAnswer)
|
|
1256
1272
|
return;
|
|
1257
|
-
selectedScopes = scopeAnswer.scopes.length > 0
|
|
1258
|
-
? scopeAnswer.scopes
|
|
1259
|
-
: availableScopes;
|
|
1273
|
+
selectedScopes = scopeAnswer.scopes.length > 0 ? scopeAnswer.scopes : availableScopes;
|
|
1260
1274
|
console.log(`\nā Will request ${selectedScopes.length} scope(s)`);
|
|
1261
1275
|
}
|
|
1262
1276
|
// Determine hide_sensitive setting
|
|
@@ -1266,12 +1280,14 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1266
1280
|
}
|
|
1267
1281
|
else {
|
|
1268
1282
|
// Interactive: ask user
|
|
1269
|
-
const sensitiveAnswer = await safePrompt([
|
|
1283
|
+
const sensitiveAnswer = await safePrompt([
|
|
1284
|
+
{
|
|
1270
1285
|
type: 'confirm',
|
|
1271
1286
|
name: 'hide',
|
|
1272
1287
|
message: 'Hide sensitive data (PII) from MCP tools?',
|
|
1273
|
-
default: false
|
|
1274
|
-
}
|
|
1288
|
+
default: false,
|
|
1289
|
+
},
|
|
1290
|
+
]);
|
|
1275
1291
|
if (sensitiveAnswer) {
|
|
1276
1292
|
hideSensitive = sensitiveAnswer.hide;
|
|
1277
1293
|
}
|
|
@@ -1282,8 +1298,8 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1282
1298
|
const webhooksResult = await context.unifiedToApi.getWebhookSubscriptions(context.agentId);
|
|
1283
1299
|
if (webhooksResult.success && webhooksResult.data && webhooksResult.data.length > 0) {
|
|
1284
1300
|
// Filter webhooks to only those belonging to this connection
|
|
1285
|
-
const connectionWebhooks = webhooksResult.data.filter(w => w.connectionId === selectedConnection.id);
|
|
1286
|
-
existingTriggers = connectionWebhooks.map(w => ({
|
|
1301
|
+
const connectionWebhooks = webhooksResult.data.filter((w) => w.connectionId === selectedConnection.id);
|
|
1302
|
+
existingTriggers = connectionWebhooks.map((w) => ({
|
|
1287
1303
|
objectType: w.objectType,
|
|
1288
1304
|
event: w.event,
|
|
1289
1305
|
hookUrl: w.hookUrl,
|
|
@@ -1304,11 +1320,11 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1304
1320
|
type: 'confirm',
|
|
1305
1321
|
name: 'confirm',
|
|
1306
1322
|
message: `Update ${selectedIntegration.name}? This will re-authorize with new scopes.`,
|
|
1307
|
-
default: true
|
|
1308
|
-
}
|
|
1323
|
+
default: true,
|
|
1324
|
+
},
|
|
1309
1325
|
]);
|
|
1310
1326
|
if (!confirmAnswer?.confirm) {
|
|
1311
|
-
console.log(
|
|
1327
|
+
console.log('\nā Cancelled.\n');
|
|
1312
1328
|
return;
|
|
1313
1329
|
}
|
|
1314
1330
|
}
|
|
@@ -1327,7 +1343,7 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1327
1343
|
agentId: context.agentId,
|
|
1328
1344
|
integration: selectedIntegration.value,
|
|
1329
1345
|
authMethod: 'oauth',
|
|
1330
|
-
timestamp: Date.now()
|
|
1346
|
+
timestamp: Date.now(),
|
|
1331
1347
|
})).toString('base64');
|
|
1332
1348
|
const externalXref = JSON.stringify({
|
|
1333
1349
|
agentId: context.agentId,
|
|
@@ -1347,25 +1363,25 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1347
1363
|
// Auth URL is already resolved by the API (redirect wrappers followed server-side)
|
|
1348
1364
|
const authUrl = authUrlResult.data.authUrl;
|
|
1349
1365
|
// Step 9: Open browser and wait for callback
|
|
1350
|
-
console.log(
|
|
1351
|
-
console.log(
|
|
1352
|
-
console.log(
|
|
1366
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
1367
|
+
console.log('š Re-authorizing with new scopes...');
|
|
1368
|
+
console.log('ā'.repeat(60));
|
|
1353
1369
|
console.log(`\nš Authorization URL (copy if browser doesn't open):\n ${authUrl}\n`);
|
|
1354
1370
|
const callbackPromise = startCallbackServer(300000);
|
|
1355
1371
|
try {
|
|
1356
1372
|
await open(authUrl);
|
|
1357
|
-
writeInfo(
|
|
1373
|
+
writeInfo('š Browser opened - please complete the authorization');
|
|
1358
1374
|
}
|
|
1359
1375
|
catch (error) {
|
|
1360
|
-
writeInfo(
|
|
1376
|
+
writeInfo('š” Could not open browser automatically. Please open the URL above manually.');
|
|
1361
1377
|
}
|
|
1362
|
-
console.log(
|
|
1363
|
-
console.log(
|
|
1378
|
+
console.log('\nā³ Waiting for authorization (5 minute timeout)...');
|
|
1379
|
+
console.log('š” Complete the authorization in your browser.\n');
|
|
1364
1380
|
const result = await callbackPromise;
|
|
1365
1381
|
if (result.success && result.connectionId) {
|
|
1366
|
-
writeSuccess(
|
|
1382
|
+
writeSuccess('\nā
Authorization successful!');
|
|
1367
1383
|
// Check if any triggers use custom webhooks
|
|
1368
|
-
const hasCustomWebhook = existingTriggers.some(t => t.hookUrl !== AGENT_WEBHOOK_URL);
|
|
1384
|
+
const hasCustomWebhook = existingTriggers.some((t) => t.hookUrl !== AGENT_WEBHOOK_URL);
|
|
1369
1385
|
// Convert existing triggers to TriggerWithSettings format, preserving per-trigger hookUrl and interval
|
|
1370
1386
|
let triggersToRestore = [];
|
|
1371
1387
|
if (existingTriggers.length > 0) {
|
|
@@ -1373,7 +1389,7 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1373
1389
|
const eventsResult = await context.unifiedToApi.getAvailableWebhookEventsByType(selectedIntegration.value);
|
|
1374
1390
|
if (eventsResult.success && eventsResult.data) {
|
|
1375
1391
|
for (const trigger of existingTriggers) {
|
|
1376
|
-
const matchingEvent = eventsResult.data.find(e => e.objectType === trigger.objectType && e.event === trigger.event);
|
|
1392
|
+
const matchingEvent = eventsResult.data.find((e) => e.objectType === trigger.objectType && e.event === trigger.event);
|
|
1377
1393
|
if (matchingEvent) {
|
|
1378
1394
|
// Preserve per-trigger hookUrl and interval from original webhook
|
|
1379
1395
|
triggersToRestore.push({
|
|
@@ -1404,13 +1420,15 @@ async function updateConnectionFlow(context, options = {}) {
|
|
|
1404
1420
|
console.log(` Log ID: ${result.logId}`);
|
|
1405
1421
|
}
|
|
1406
1422
|
// Report auth failure for observability (fire and forget)
|
|
1407
|
-
context.unifiedToApi
|
|
1423
|
+
context.unifiedToApi
|
|
1424
|
+
.reportAuthFailure({
|
|
1408
1425
|
integrationType: selectedIntegration.value,
|
|
1409
1426
|
error: result.error || 'Unknown OAuth failure',
|
|
1410
1427
|
logId: result.logId,
|
|
1411
1428
|
agentId: context.agentId,
|
|
1412
1429
|
source: 'cli',
|
|
1413
|
-
})
|
|
1430
|
+
})
|
|
1431
|
+
.catch(() => { });
|
|
1414
1432
|
console.log("š” The old connection was removed. Please reconnect with 'lua integrations connect'\n");
|
|
1415
1433
|
}
|
|
1416
1434
|
}
|
|
@@ -1443,9 +1461,9 @@ async function webhooksSubcommand(context, cmdOptions) {
|
|
|
1443
1461
|
break;
|
|
1444
1462
|
case 'delete':
|
|
1445
1463
|
if (!options.webhookId) {
|
|
1446
|
-
console.error(
|
|
1464
|
+
console.error('ā --webhook-id is required for delete');
|
|
1447
1465
|
console.log("\nš” Run 'lua integrations webhooks list' to see trigger IDs");
|
|
1448
|
-
throw new Error(
|
|
1466
|
+
throw new Error('--webhook-id is required for delete');
|
|
1449
1467
|
}
|
|
1450
1468
|
await webhooksDeleteFlow(context, options.webhookId);
|
|
1451
1469
|
break;
|
|
@@ -1457,9 +1475,9 @@ async function webhooksSubcommand(context, cmdOptions) {
|
|
|
1457
1475
|
await connectionPauseFlow(context, options.connectionId);
|
|
1458
1476
|
}
|
|
1459
1477
|
else {
|
|
1460
|
-
console.error(
|
|
1478
|
+
console.error('ā --webhook-id or --connection-id is required for pause');
|
|
1461
1479
|
console.log("\nš” Run 'lua integrations webhooks list' to see trigger IDs");
|
|
1462
|
-
throw new Error(
|
|
1480
|
+
throw new Error('--webhook-id or --connection-id is required for pause');
|
|
1463
1481
|
}
|
|
1464
1482
|
break;
|
|
1465
1483
|
case 'resume':
|
|
@@ -1470,9 +1488,9 @@ async function webhooksSubcommand(context, cmdOptions) {
|
|
|
1470
1488
|
await connectionResumeFlow(context, options.connectionId);
|
|
1471
1489
|
}
|
|
1472
1490
|
else {
|
|
1473
|
-
console.error(
|
|
1491
|
+
console.error('ā --webhook-id or --connection-id is required for resume');
|
|
1474
1492
|
console.log("\nš” Run 'lua integrations webhooks list' to see trigger IDs");
|
|
1475
|
-
throw new Error(
|
|
1493
|
+
throw new Error('--webhook-id or --connection-id is required for resume');
|
|
1476
1494
|
}
|
|
1477
1495
|
break;
|
|
1478
1496
|
case 'events':
|
|
@@ -1529,17 +1547,17 @@ async function webhooksEventsFlow(context, options, jsonOutput = false) {
|
|
|
1529
1547
|
console.log(JSON.stringify({ error: 'Either --connection or --integration is required' }));
|
|
1530
1548
|
}
|
|
1531
1549
|
else {
|
|
1532
|
-
console.error(
|
|
1533
|
-
console.log(
|
|
1534
|
-
console.log(
|
|
1535
|
-
console.log(
|
|
1550
|
+
console.error('ā Either --connection <id> or --integration <type> is required');
|
|
1551
|
+
console.log('\nUsage:');
|
|
1552
|
+
console.log(' lua integrations webhooks events --connection <id>');
|
|
1553
|
+
console.log(' lua integrations webhooks events --integration <type>');
|
|
1536
1554
|
}
|
|
1537
|
-
throw new Error(
|
|
1555
|
+
throw new Error('Operation failed');
|
|
1538
1556
|
}
|
|
1539
1557
|
if (jsonOutput) {
|
|
1540
1558
|
const output = {
|
|
1541
1559
|
source: sourceName,
|
|
1542
|
-
events: webhookEvents.map(e => ({
|
|
1560
|
+
events: webhookEvents.map((e) => ({
|
|
1543
1561
|
trigger: `${e.objectType}.${e.event}`,
|
|
1544
1562
|
objectType: e.objectType,
|
|
1545
1563
|
event: e.event,
|
|
@@ -1556,14 +1574,14 @@ async function webhooksEventsFlow(context, options, jsonOutput = false) {
|
|
|
1556
1574
|
console.log(JSON.stringify(output, null, 2));
|
|
1557
1575
|
}
|
|
1558
1576
|
else {
|
|
1559
|
-
console.log(
|
|
1577
|
+
console.log('\n' + '='.repeat(60));
|
|
1560
1578
|
console.log(`š” Available Trigger Events for ${sourceName}`);
|
|
1561
|
-
console.log(
|
|
1579
|
+
console.log('='.repeat(60) + '\n');
|
|
1562
1580
|
if (webhookEvents.length === 0) {
|
|
1563
|
-
console.log(
|
|
1581
|
+
console.log('ā¹ļø No trigger events available for this integration.\n');
|
|
1564
1582
|
}
|
|
1565
1583
|
else {
|
|
1566
|
-
webhookEvents.forEach(e => {
|
|
1584
|
+
webhookEvents.forEach((e) => {
|
|
1567
1585
|
console.log(` ${e.objectType}.${e.event} [${e.webhookType}]`);
|
|
1568
1586
|
console.log(` ${e.friendlyDescription}`);
|
|
1569
1587
|
if (e.availableFilters.length > 0) {
|
|
@@ -1571,10 +1589,13 @@ async function webhooksEventsFlow(context, options, jsonOutput = false) {
|
|
|
1571
1589
|
}
|
|
1572
1590
|
console.log();
|
|
1573
1591
|
});
|
|
1574
|
-
console.log(
|
|
1592
|
+
console.log('ā'.repeat(60));
|
|
1575
1593
|
console.log(`Total: ${webhookEvents.length} event(s) available`);
|
|
1576
|
-
console.log(
|
|
1577
|
-
const exampleTriggers = webhookEvents
|
|
1594
|
+
console.log('\nš” Use with --triggers flag:');
|
|
1595
|
+
const exampleTriggers = webhookEvents
|
|
1596
|
+
.slice(0, 2)
|
|
1597
|
+
.map((e) => `${e.objectType}.${e.event}`)
|
|
1598
|
+
.join(',');
|
|
1578
1599
|
console.log(` lua integrations connect --integration <type> --triggers ${exampleTriggers}\n`);
|
|
1579
1600
|
}
|
|
1580
1601
|
}
|
|
@@ -1586,16 +1607,16 @@ async function webhooksEventsFlow(context, options, jsonOutput = false) {
|
|
|
1586
1607
|
else {
|
|
1587
1608
|
writeError(`ā Failed to get trigger events: ${error.message}`);
|
|
1588
1609
|
}
|
|
1589
|
-
throw new Error(
|
|
1610
|
+
throw new Error('Operation failed');
|
|
1590
1611
|
}
|
|
1591
1612
|
}
|
|
1592
1613
|
/**
|
|
1593
1614
|
* Interactive webhooks menu
|
|
1594
1615
|
*/
|
|
1595
1616
|
async function webhooksInteractiveMenu(context) {
|
|
1596
|
-
console.log(
|
|
1597
|
-
console.log(
|
|
1598
|
-
console.log(
|
|
1617
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
1618
|
+
console.log('š Triggers');
|
|
1619
|
+
console.log('ā'.repeat(60) + '\n');
|
|
1599
1620
|
const actionAnswer = await safePrompt([
|
|
1600
1621
|
{
|
|
1601
1622
|
type: 'list',
|
|
@@ -1609,9 +1630,9 @@ async function webhooksInteractiveMenu(context) {
|
|
|
1609
1630
|
{ name: 'āøļø Pause all triggers for a connection', value: 'pauseConn' },
|
|
1610
1631
|
{ name: 'ā¶ļø Resume all triggers for a connection', value: 'resumeConn' },
|
|
1611
1632
|
{ name: 'šļø Delete a trigger', value: 'delete' },
|
|
1612
|
-
{ name: 'ā Back', value: 'back' }
|
|
1613
|
-
]
|
|
1614
|
-
}
|
|
1633
|
+
{ name: 'ā Back', value: 'back' },
|
|
1634
|
+
],
|
|
1635
|
+
},
|
|
1615
1636
|
]);
|
|
1616
1637
|
if (!actionAnswer || actionAnswer.action === 'back')
|
|
1617
1638
|
return;
|
|
@@ -1643,7 +1664,7 @@ async function webhooksInteractiveMenu(context) {
|
|
|
1643
1664
|
* List all webhook subscriptions
|
|
1644
1665
|
*/
|
|
1645
1666
|
async function webhooksListFlow(context, jsonOutput = false) {
|
|
1646
|
-
writeProgress(
|
|
1667
|
+
writeProgress('š Loading triggers...');
|
|
1647
1668
|
try {
|
|
1648
1669
|
const result = await context.unifiedToApi.getWebhookSubscriptions(context.agentId);
|
|
1649
1670
|
if (!result.success) {
|
|
@@ -1659,7 +1680,7 @@ async function webhooksListFlow(context, jsonOutput = false) {
|
|
|
1659
1680
|
if (jsonOutput) {
|
|
1660
1681
|
// Output as JSON for scripting
|
|
1661
1682
|
console.log(JSON.stringify({
|
|
1662
|
-
triggers: webhooks.map(wh => ({
|
|
1683
|
+
triggers: webhooks.map((wh) => ({
|
|
1663
1684
|
id: wh.id,
|
|
1664
1685
|
integrationType: wh.integrationType,
|
|
1665
1686
|
objectType: wh.objectType,
|
|
@@ -1676,13 +1697,13 @@ async function webhooksListFlow(context, jsonOutput = false) {
|
|
|
1676
1697
|
}, null, 2));
|
|
1677
1698
|
return;
|
|
1678
1699
|
}
|
|
1679
|
-
console.log(
|
|
1680
|
-
console.log(
|
|
1681
|
-
console.log(
|
|
1700
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
1701
|
+
console.log('ā” Triggers / Webhook Subscriptions');
|
|
1702
|
+
console.log('ā'.repeat(60) + '\n');
|
|
1682
1703
|
if (webhooks.length === 0) {
|
|
1683
|
-
console.log(
|
|
1684
|
-
console.log(
|
|
1685
|
-
console.log(
|
|
1704
|
+
console.log('ā¹ļø No triggers configured yet.\n');
|
|
1705
|
+
console.log('š” Add triggers when connecting: lua integrations connect');
|
|
1706
|
+
console.log(' Or add one now: lua integrations webhooks create\n');
|
|
1686
1707
|
return;
|
|
1687
1708
|
}
|
|
1688
1709
|
// Group by integration
|
|
@@ -1728,7 +1749,7 @@ async function webhooksListFlow(context, jsonOutput = false) {
|
|
|
1728
1749
|
}
|
|
1729
1750
|
console.log();
|
|
1730
1751
|
}
|
|
1731
|
-
console.log(
|
|
1752
|
+
console.log('ā'.repeat(60));
|
|
1732
1753
|
console.log(`Total: ${webhooks.length} trigger(s)\n`);
|
|
1733
1754
|
}
|
|
1734
1755
|
catch (error) {
|
|
@@ -1744,7 +1765,7 @@ async function webhooksListFlow(context, jsonOutput = false) {
|
|
|
1744
1765
|
* Pause a single webhook subscription (non-interactive)
|
|
1745
1766
|
*/
|
|
1746
1767
|
async function webhooksPauseFlow(context, webhookId, reason) {
|
|
1747
|
-
writeProgress(
|
|
1768
|
+
writeProgress('š Pausing trigger...');
|
|
1748
1769
|
try {
|
|
1749
1770
|
const result = await context.unifiedToApi.pauseWebhookSubscription(context.agentId, webhookId, reason);
|
|
1750
1771
|
if (result.success) {
|
|
@@ -1766,7 +1787,7 @@ async function webhooksPauseFlow(context, webhookId, reason) {
|
|
|
1766
1787
|
* Resume a single webhook subscription (non-interactive)
|
|
1767
1788
|
*/
|
|
1768
1789
|
async function webhooksResumeFlow(context, webhookId) {
|
|
1769
|
-
writeProgress(
|
|
1790
|
+
writeProgress('š Resuming trigger...');
|
|
1770
1791
|
try {
|
|
1771
1792
|
const result = await context.unifiedToApi.resumeWebhookSubscription(context.agentId, webhookId);
|
|
1772
1793
|
if (result.success) {
|
|
@@ -1792,7 +1813,7 @@ async function webhooksResumeFlow(context, webhookId) {
|
|
|
1792
1813
|
* Pause all triggers for a connection (non-interactive)
|
|
1793
1814
|
*/
|
|
1794
1815
|
async function connectionPauseFlow(context, connectionId) {
|
|
1795
|
-
writeProgress(
|
|
1816
|
+
writeProgress('š Pausing all triggers for connection...');
|
|
1796
1817
|
try {
|
|
1797
1818
|
const result = await context.unifiedToApi.pauseConnection(context.agentId, connectionId);
|
|
1798
1819
|
if (result.success && result.data) {
|
|
@@ -1801,7 +1822,11 @@ async function connectionPauseFlow(context, connectionId) {
|
|
|
1801
1822
|
console.log(` ā ļø ${result.data.failedWebhooks} trigger(s) failed to pause at Unified.to ā check logs.\n`);
|
|
1802
1823
|
}
|
|
1803
1824
|
console.log(`\nš” Resume later with: lua integrations webhooks resume --connection-id ${connectionId}\n`);
|
|
1804
|
-
trackEvent('cli_connection_paused', {
|
|
1825
|
+
trackEvent('cli_connection_paused', {
|
|
1826
|
+
connection_id: connectionId,
|
|
1827
|
+
affected: result.data.affectedWebhooks,
|
|
1828
|
+
failed: result.data.failedWebhooks,
|
|
1829
|
+
});
|
|
1805
1830
|
}
|
|
1806
1831
|
else {
|
|
1807
1832
|
writeError(`ā Failed to pause connection triggers: ${result.error?.message}`);
|
|
@@ -1815,7 +1840,7 @@ async function connectionPauseFlow(context, connectionId) {
|
|
|
1815
1840
|
* Resume all triggers for a connection (non-interactive)
|
|
1816
1841
|
*/
|
|
1817
1842
|
async function connectionResumeFlow(context, connectionId) {
|
|
1818
|
-
writeProgress(
|
|
1843
|
+
writeProgress('š Resuming triggers for connection...');
|
|
1819
1844
|
try {
|
|
1820
1845
|
const result = await context.unifiedToApi.resumeConnection(context.agentId, connectionId);
|
|
1821
1846
|
if (result.success && result.data) {
|
|
@@ -1827,7 +1852,12 @@ async function connectionResumeFlow(context, connectionId) {
|
|
|
1827
1852
|
if (result.data.failedWebhooks > 0) {
|
|
1828
1853
|
console.log(` ā ļø ${result.data.failedWebhooks} trigger(s) failed to resume at Unified.to ā check logs.\n`);
|
|
1829
1854
|
}
|
|
1830
|
-
trackEvent('cli_connection_resumed', {
|
|
1855
|
+
trackEvent('cli_connection_resumed', {
|
|
1856
|
+
connection_id: connectionId,
|
|
1857
|
+
affected: result.data.affectedWebhooks,
|
|
1858
|
+
skipped_credit: result.data.skippedCreditSuspended,
|
|
1859
|
+
failed: result.data.failedWebhooks,
|
|
1860
|
+
});
|
|
1831
1861
|
}
|
|
1832
1862
|
else {
|
|
1833
1863
|
writeError(`ā Failed to resume connection triggers: ${result.error?.message}`);
|
|
@@ -1841,16 +1871,16 @@ async function connectionResumeFlow(context, connectionId) {
|
|
|
1841
1871
|
* Interactive: pause a single trigger
|
|
1842
1872
|
*/
|
|
1843
1873
|
async function webhooksPauseInteractive(context) {
|
|
1844
|
-
writeProgress(
|
|
1874
|
+
writeProgress('š Loading triggers...');
|
|
1845
1875
|
try {
|
|
1846
1876
|
const result = await context.unifiedToApi.getWebhookSubscriptions(context.agentId);
|
|
1847
1877
|
if (!result.success) {
|
|
1848
1878
|
writeError(`ā Failed to load triggers: ${result.error?.message}`);
|
|
1849
1879
|
return;
|
|
1850
1880
|
}
|
|
1851
|
-
const webhooks = (result.data || []).filter(wh => !wh.userPaused && wh.status !== 'unhealthy');
|
|
1881
|
+
const webhooks = (result.data || []).filter((wh) => !wh.userPaused && wh.status !== 'unhealthy');
|
|
1852
1882
|
if (webhooks.length === 0) {
|
|
1853
|
-
console.log(
|
|
1883
|
+
console.log('\nā¹ļø No active triggers to pause.\n');
|
|
1854
1884
|
return;
|
|
1855
1885
|
}
|
|
1856
1886
|
const webhookAnswer = await safePrompt([
|
|
@@ -1858,11 +1888,11 @@ async function webhooksPauseInteractive(context) {
|
|
|
1858
1888
|
type: 'list',
|
|
1859
1889
|
name: 'webhook',
|
|
1860
1890
|
message: 'Select a trigger to pause:',
|
|
1861
|
-
choices: webhooks.map(wh => ({
|
|
1891
|
+
choices: webhooks.map((wh) => ({
|
|
1862
1892
|
name: `${wh.integrationType} ā ${wh.objectType}.${wh.event} (${wh.id.substring(0, 8)}...)`,
|
|
1863
1893
|
value: wh.id,
|
|
1864
|
-
}))
|
|
1865
|
-
}
|
|
1894
|
+
})),
|
|
1895
|
+
},
|
|
1866
1896
|
]);
|
|
1867
1897
|
if (!webhookAnswer?.webhook)
|
|
1868
1898
|
return;
|
|
@@ -1872,10 +1902,10 @@ async function webhooksPauseInteractive(context) {
|
|
|
1872
1902
|
name: 'confirm',
|
|
1873
1903
|
message: `Pause this trigger?`,
|
|
1874
1904
|
default: true,
|
|
1875
|
-
}
|
|
1905
|
+
},
|
|
1876
1906
|
]);
|
|
1877
1907
|
if (!confirmAnswer?.confirm) {
|
|
1878
|
-
console.log(
|
|
1908
|
+
console.log('\nā Cancelled.\n');
|
|
1879
1909
|
return;
|
|
1880
1910
|
}
|
|
1881
1911
|
await webhooksPauseFlow(context, webhookAnswer.webhook);
|
|
@@ -1888,16 +1918,16 @@ async function webhooksPauseInteractive(context) {
|
|
|
1888
1918
|
* Interactive: resume a single trigger
|
|
1889
1919
|
*/
|
|
1890
1920
|
async function webhooksResumeInteractive(context) {
|
|
1891
|
-
writeProgress(
|
|
1921
|
+
writeProgress('š Loading triggers...');
|
|
1892
1922
|
try {
|
|
1893
1923
|
const result = await context.unifiedToApi.getWebhookSubscriptions(context.agentId);
|
|
1894
1924
|
if (!result.success) {
|
|
1895
1925
|
writeError(`ā Failed to load triggers: ${result.error?.message}`);
|
|
1896
1926
|
return;
|
|
1897
1927
|
}
|
|
1898
|
-
const webhooks = (result.data || []).filter(wh => wh.userPaused && !wh.creditSuspended);
|
|
1928
|
+
const webhooks = (result.data || []).filter((wh) => wh.userPaused && !wh.creditSuspended);
|
|
1899
1929
|
if (webhooks.length === 0) {
|
|
1900
|
-
console.log(
|
|
1930
|
+
console.log('\nā¹ļø No user-paused triggers to resume.\n');
|
|
1901
1931
|
return;
|
|
1902
1932
|
}
|
|
1903
1933
|
const webhookAnswer = await safePrompt([
|
|
@@ -1905,11 +1935,11 @@ async function webhooksResumeInteractive(context) {
|
|
|
1905
1935
|
type: 'list',
|
|
1906
1936
|
name: 'webhook',
|
|
1907
1937
|
message: 'Select a trigger to resume:',
|
|
1908
|
-
choices: webhooks.map(wh => ({
|
|
1938
|
+
choices: webhooks.map((wh) => ({
|
|
1909
1939
|
name: `${wh.integrationType} ā ${wh.objectType}.${wh.event} (${wh.id.substring(0, 8)}...)`,
|
|
1910
1940
|
value: wh.id,
|
|
1911
|
-
}))
|
|
1912
|
-
}
|
|
1941
|
+
})),
|
|
1942
|
+
},
|
|
1913
1943
|
]);
|
|
1914
1944
|
if (!webhookAnswer?.webhook)
|
|
1915
1945
|
return;
|
|
@@ -1927,7 +1957,7 @@ async function connectionPauseInteractive(context) {
|
|
|
1927
1957
|
const connectionsResult = await context.unifiedToApi.getConnections(context.agentId);
|
|
1928
1958
|
const connections = connectionsResult.success ? connectionsResult.data || [] : [];
|
|
1929
1959
|
if (connections.length === 0) {
|
|
1930
|
-
console.log(
|
|
1960
|
+
console.log('\nā¹ļø No connected integrations.\n');
|
|
1931
1961
|
return;
|
|
1932
1962
|
}
|
|
1933
1963
|
const connectionAnswer = await safePrompt([
|
|
@@ -1935,11 +1965,11 @@ async function connectionPauseInteractive(context) {
|
|
|
1935
1965
|
type: 'list',
|
|
1936
1966
|
name: 'connection',
|
|
1937
1967
|
message: 'Select a connection to pause all triggers:',
|
|
1938
|
-
choices: connections.map(c => ({
|
|
1968
|
+
choices: connections.map((c) => ({
|
|
1939
1969
|
name: `${c.integrationName || c.integrationType} (${c.id.substring(0, 8)}...)${c.allTriggersPaused ? ' [all triggers paused]' : ''}`,
|
|
1940
1970
|
value: c.id,
|
|
1941
|
-
}))
|
|
1942
|
-
}
|
|
1971
|
+
})),
|
|
1972
|
+
},
|
|
1943
1973
|
]);
|
|
1944
1974
|
if (!connectionAnswer?.connection)
|
|
1945
1975
|
return;
|
|
@@ -1949,10 +1979,10 @@ async function connectionPauseInteractive(context) {
|
|
|
1949
1979
|
name: 'confirm',
|
|
1950
1980
|
message: `Pause all triggers for this connection?`,
|
|
1951
1981
|
default: true,
|
|
1952
|
-
}
|
|
1982
|
+
},
|
|
1953
1983
|
]);
|
|
1954
1984
|
if (!confirmAnswer?.confirm) {
|
|
1955
|
-
console.log(
|
|
1985
|
+
console.log('\nā Cancelled.\n');
|
|
1956
1986
|
return;
|
|
1957
1987
|
}
|
|
1958
1988
|
await connectionPauseFlow(context, connectionAnswer.connection);
|
|
@@ -1969,7 +1999,7 @@ async function connectionResumeInteractive(context) {
|
|
|
1969
1999
|
const connectionsResult = await context.unifiedToApi.getConnections(context.agentId);
|
|
1970
2000
|
const connections = connectionsResult.success ? connectionsResult.data || [] : [];
|
|
1971
2001
|
if (connections.length === 0) {
|
|
1972
|
-
console.log(
|
|
2002
|
+
console.log('\nā¹ļø No connected integrations.\n');
|
|
1973
2003
|
return;
|
|
1974
2004
|
}
|
|
1975
2005
|
const connectionAnswer = await safePrompt([
|
|
@@ -1977,11 +2007,11 @@ async function connectionResumeInteractive(context) {
|
|
|
1977
2007
|
type: 'list',
|
|
1978
2008
|
name: 'connection',
|
|
1979
2009
|
message: 'Select a connection to resume triggers:',
|
|
1980
|
-
choices: connections.map(c => ({
|
|
2010
|
+
choices: connections.map((c) => ({
|
|
1981
2011
|
name: `${c.integrationName || c.integrationType} (${c.id.substring(0, 8)}...)`,
|
|
1982
2012
|
value: c.id,
|
|
1983
|
-
}))
|
|
1984
|
-
}
|
|
2013
|
+
})),
|
|
2014
|
+
},
|
|
1985
2015
|
]);
|
|
1986
2016
|
if (!connectionAnswer?.connection)
|
|
1987
2017
|
return;
|
|
@@ -1996,7 +2026,7 @@ async function connectionResumeInteractive(context) {
|
|
|
1996
2026
|
*/
|
|
1997
2027
|
async function webhooksCreateFlow(context, options) {
|
|
1998
2028
|
// Step 1: Fetch connections
|
|
1999
|
-
writeProgress(
|
|
2029
|
+
writeProgress('š Loading connections...');
|
|
2000
2030
|
let connections = [];
|
|
2001
2031
|
try {
|
|
2002
2032
|
const connectionsResult = await context.unifiedToApi.getConnections(context.agentId);
|
|
@@ -2011,19 +2041,19 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2011
2041
|
return;
|
|
2012
2042
|
}
|
|
2013
2043
|
if (connections.length === 0) {
|
|
2014
|
-
writeInfo(
|
|
2044
|
+
writeInfo('No connections available.');
|
|
2015
2045
|
console.log("š” Run 'lua integrations connect' to connect an integration first.\n");
|
|
2016
2046
|
return;
|
|
2017
2047
|
}
|
|
2018
2048
|
// Step 2: Select connection
|
|
2019
2049
|
let selectedConnection;
|
|
2020
2050
|
if (options.connectionId) {
|
|
2021
|
-
selectedConnection = connections.find(c => c.id === options.connectionId);
|
|
2051
|
+
selectedConnection = connections.find((c) => c.id === options.connectionId);
|
|
2022
2052
|
if (!selectedConnection) {
|
|
2023
2053
|
console.error(`ā Connection "${options.connectionId}" not found.`);
|
|
2024
2054
|
console.log('\nAvailable connections:');
|
|
2025
|
-
connections.forEach(c => console.log(` - ${c.id} (${c.integrationName || c.integrationType})`));
|
|
2026
|
-
throw new Error(
|
|
2055
|
+
connections.forEach((c) => console.log(` - ${c.id} (${c.integrationName || c.integrationType})`));
|
|
2056
|
+
throw new Error('Connection');
|
|
2027
2057
|
}
|
|
2028
2058
|
}
|
|
2029
2059
|
else {
|
|
@@ -2032,18 +2062,18 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2032
2062
|
type: 'list',
|
|
2033
2063
|
name: 'connection',
|
|
2034
2064
|
message: 'Select a connection:',
|
|
2035
|
-
choices: connections.map(c => ({
|
|
2065
|
+
choices: connections.map((c) => ({
|
|
2036
2066
|
name: `${c.integrationName || c.integrationType} (${c.id.substring(0, 8)}...)`,
|
|
2037
|
-
value: c
|
|
2038
|
-
}))
|
|
2039
|
-
}
|
|
2067
|
+
value: c,
|
|
2068
|
+
})),
|
|
2069
|
+
},
|
|
2040
2070
|
]);
|
|
2041
2071
|
if (!connectionAnswer)
|
|
2042
2072
|
return;
|
|
2043
2073
|
selectedConnection = connectionAnswer.connection;
|
|
2044
2074
|
}
|
|
2045
2075
|
// Step 3: Get available events for this connection
|
|
2046
|
-
writeProgress(
|
|
2076
|
+
writeProgress('š Loading available events...');
|
|
2047
2077
|
let availableEvents = [];
|
|
2048
2078
|
try {
|
|
2049
2079
|
const eventsResult = await context.unifiedToApi.getAvailableWebhookEvents(context.agentId, selectedConnection.id);
|
|
@@ -2059,18 +2089,18 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2059
2089
|
}
|
|
2060
2090
|
if (availableEvents.length === 0) {
|
|
2061
2091
|
writeInfo(`No trigger events available for ${selectedConnection.integrationName || selectedConnection.integrationType}.`);
|
|
2062
|
-
console.log(
|
|
2092
|
+
console.log('š” This integration may not support triggers.\n');
|
|
2063
2093
|
return;
|
|
2064
2094
|
}
|
|
2065
2095
|
// Step 4: Select event
|
|
2066
2096
|
let selectedEvent;
|
|
2067
2097
|
if (options.objectType && options.event) {
|
|
2068
|
-
selectedEvent = availableEvents.find(e => e.objectType === options.objectType && e.event === options.event);
|
|
2098
|
+
selectedEvent = availableEvents.find((e) => e.objectType === options.objectType && e.event === options.event);
|
|
2069
2099
|
if (!selectedEvent) {
|
|
2070
2100
|
console.error(`ā Event '${options.objectType}.${options.event}' is not supported.`);
|
|
2071
2101
|
console.log(`\nAvailable events for ${selectedConnection.integrationName || selectedConnection.integrationType}:`);
|
|
2072
|
-
availableEvents.forEach(e => console.log(` - ${e.objectType}.${e.event} [${e.webhookType}]`));
|
|
2073
|
-
throw new Error(
|
|
2102
|
+
availableEvents.forEach((e) => console.log(` - ${e.objectType}.${e.event} [${e.webhookType}]`));
|
|
2103
|
+
throw new Error('Event');
|
|
2074
2104
|
}
|
|
2075
2105
|
}
|
|
2076
2106
|
else {
|
|
@@ -2081,11 +2111,11 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2081
2111
|
name: 'event',
|
|
2082
2112
|
message: 'Select an event to subscribe to:',
|
|
2083
2113
|
pageSize: 15,
|
|
2084
|
-
choices: availableEvents.map(e => ({
|
|
2114
|
+
choices: availableEvents.map((e) => ({
|
|
2085
2115
|
name: `${e.objectTypeDisplay} - ${e.event.charAt(0).toUpperCase() + e.event.slice(1)} [${e.webhookType}]`,
|
|
2086
|
-
value: e
|
|
2087
|
-
}))
|
|
2088
|
-
}
|
|
2116
|
+
value: e,
|
|
2117
|
+
})),
|
|
2118
|
+
},
|
|
2089
2119
|
]);
|
|
2090
2120
|
if (!eventAnswer)
|
|
2091
2121
|
return;
|
|
@@ -2114,7 +2144,7 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2114
2144
|
},
|
|
2115
2145
|
],
|
|
2116
2146
|
default: 'agent',
|
|
2117
|
-
}
|
|
2147
|
+
},
|
|
2118
2148
|
]);
|
|
2119
2149
|
if (!urlModeAnswer)
|
|
2120
2150
|
return;
|
|
@@ -2137,8 +2167,8 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2137
2167
|
catch {
|
|
2138
2168
|
return 'Enter a valid URL (e.g., https://webhook.heylua.ai/myagent/handler)';
|
|
2139
2169
|
}
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2170
|
+
},
|
|
2171
|
+
},
|
|
2142
2172
|
]);
|
|
2143
2173
|
if (!webhookAnswer)
|
|
2144
2174
|
return;
|
|
@@ -2173,7 +2203,7 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2173
2203
|
message: 'Select polling interval:',
|
|
2174
2204
|
choices: intervalOptions,
|
|
2175
2205
|
default: 1,
|
|
2176
|
-
}
|
|
2206
|
+
},
|
|
2177
2207
|
]);
|
|
2178
2208
|
if (!intervalAnswer)
|
|
2179
2209
|
return;
|
|
@@ -2182,35 +2212,35 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2182
2212
|
}
|
|
2183
2213
|
// Helper to format interval display
|
|
2184
2214
|
const formatInterval = (minutes) => {
|
|
2185
|
-
const option = intervalOptions.find(o => o.value === minutes);
|
|
2215
|
+
const option = intervalOptions.find((o) => o.value === minutes);
|
|
2186
2216
|
return option ? option.name : `${minutes} minutes`;
|
|
2187
2217
|
};
|
|
2188
2218
|
// Step 7: Confirmation (interactive only)
|
|
2189
2219
|
if (!options.connectionId) {
|
|
2190
|
-
console.log(
|
|
2191
|
-
console.log(
|
|
2192
|
-
console.log(
|
|
2220
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
2221
|
+
console.log('š Trigger Summary');
|
|
2222
|
+
console.log('ā'.repeat(60));
|
|
2193
2223
|
console.log(` Connection: ${selectedConnection.integrationName || selectedConnection.integrationType}`);
|
|
2194
2224
|
console.log(` Event: ${selectedEvent.objectType}.${selectedEvent.event} [${selectedEvent.webhookType}]`);
|
|
2195
2225
|
console.log(` Webhook URL: ${hookUrl}`);
|
|
2196
2226
|
if (interval)
|
|
2197
2227
|
console.log(` Interval: ${formatInterval(interval)}`);
|
|
2198
|
-
console.log(
|
|
2228
|
+
console.log('ā'.repeat(60) + '\n');
|
|
2199
2229
|
const confirmAnswer = await safePrompt([
|
|
2200
2230
|
{
|
|
2201
2231
|
type: 'confirm',
|
|
2202
2232
|
name: 'confirm',
|
|
2203
2233
|
message: 'Create this trigger?',
|
|
2204
|
-
default: true
|
|
2205
|
-
}
|
|
2234
|
+
default: true,
|
|
2235
|
+
},
|
|
2206
2236
|
]);
|
|
2207
2237
|
if (!confirmAnswer?.confirm) {
|
|
2208
|
-
console.log(
|
|
2238
|
+
console.log('\nā Cancelled.\n');
|
|
2209
2239
|
return;
|
|
2210
2240
|
}
|
|
2211
2241
|
}
|
|
2212
2242
|
// Step 8: Create the webhook
|
|
2213
|
-
writeProgress(
|
|
2243
|
+
writeProgress('š Creating trigger...');
|
|
2214
2244
|
try {
|
|
2215
2245
|
const createResult = await context.unifiedToApi.createWebhookSubscription(context.agentId, {
|
|
2216
2246
|
connectionId: selectedConnection.id,
|
|
@@ -2226,9 +2256,9 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2226
2256
|
const webhook = createResult.data;
|
|
2227
2257
|
const isAgentTrigger = webhook.hookUrl.includes('webhook/unifiedto');
|
|
2228
2258
|
const typeLabel = webhook.webhookType === 'native' ? 'push' : 'polling';
|
|
2229
|
-
console.log(
|
|
2230
|
-
writeSuccess(
|
|
2231
|
-
console.log(
|
|
2259
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
2260
|
+
writeSuccess('ā
Trigger created!');
|
|
2261
|
+
console.log('ā'.repeat(60));
|
|
2232
2262
|
console.log(` Integration: ${webhook.integrationType}`);
|
|
2233
2263
|
console.log(` Event: ${webhook.objectType}.${webhook.event}`);
|
|
2234
2264
|
console.log(` Type: ${typeLabel}`);
|
|
@@ -2239,12 +2269,12 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2239
2269
|
if (webhook.interval)
|
|
2240
2270
|
console.log(` Poll interval: ${formatInterval(webhook.interval)}`);
|
|
2241
2271
|
console.log(` Status: ${webhook.status}`);
|
|
2242
|
-
console.log(
|
|
2272
|
+
console.log('ā'.repeat(60) + '\n');
|
|
2243
2273
|
if (isAgentTrigger) {
|
|
2244
|
-
console.log(
|
|
2274
|
+
console.log('š” Your agent will now wake up when this event occurs.\n');
|
|
2245
2275
|
}
|
|
2246
2276
|
else {
|
|
2247
|
-
console.log(
|
|
2277
|
+
console.log('š” Ensure your webhook endpoint is ready to receive events.\n');
|
|
2248
2278
|
}
|
|
2249
2279
|
}
|
|
2250
2280
|
catch (error) {
|
|
@@ -2255,7 +2285,7 @@ async function webhooksCreateFlow(context, options) {
|
|
|
2255
2285
|
* Delete a webhook subscription (interactive)
|
|
2256
2286
|
*/
|
|
2257
2287
|
async function webhooksDeleteInteractive(context) {
|
|
2258
|
-
writeProgress(
|
|
2288
|
+
writeProgress('š Loading triggers...');
|
|
2259
2289
|
try {
|
|
2260
2290
|
const result = await context.unifiedToApi.getWebhookSubscriptions(context.agentId);
|
|
2261
2291
|
if (!result.success) {
|
|
@@ -2264,7 +2294,7 @@ async function webhooksDeleteInteractive(context) {
|
|
|
2264
2294
|
}
|
|
2265
2295
|
const webhooks = result.data || [];
|
|
2266
2296
|
if (webhooks.length === 0) {
|
|
2267
|
-
console.log(
|
|
2297
|
+
console.log('\nā¹ļø No triggers to delete.\n');
|
|
2268
2298
|
return;
|
|
2269
2299
|
}
|
|
2270
2300
|
const webhookAnswer = await safePrompt([
|
|
@@ -2272,30 +2302,30 @@ async function webhooksDeleteInteractive(context) {
|
|
|
2272
2302
|
type: 'list',
|
|
2273
2303
|
name: 'webhook',
|
|
2274
2304
|
message: 'Select a trigger to delete:',
|
|
2275
|
-
choices: webhooks.map(wh => {
|
|
2305
|
+
choices: webhooks.map((wh) => {
|
|
2276
2306
|
// Show last part of URL for readability
|
|
2277
2307
|
const urlParts = (wh.hookUrl || '').split('/');
|
|
2278
2308
|
const shortUrl = urlParts.length > 3 ? '.../' + urlParts.slice(-2).join('/') : wh.hookUrl || '';
|
|
2279
2309
|
return {
|
|
2280
2310
|
name: `${wh.id.substring(0, 8)}... - ${wh.integrationType} ${wh.objectType}.${wh.event} ā ${shortUrl}`,
|
|
2281
|
-
value: wh.id
|
|
2311
|
+
value: wh.id,
|
|
2282
2312
|
};
|
|
2283
|
-
})
|
|
2284
|
-
}
|
|
2313
|
+
}),
|
|
2314
|
+
},
|
|
2285
2315
|
]);
|
|
2286
2316
|
if (!webhookAnswer?.webhook)
|
|
2287
2317
|
return;
|
|
2288
|
-
const selectedWebhook = webhooks.find(wh => wh.id === webhookAnswer.webhook);
|
|
2318
|
+
const selectedWebhook = webhooks.find((wh) => wh.id === webhookAnswer.webhook);
|
|
2289
2319
|
const confirmAnswer = await safePrompt([
|
|
2290
2320
|
{
|
|
2291
2321
|
type: 'confirm',
|
|
2292
2322
|
name: 'confirm',
|
|
2293
2323
|
message: `Delete trigger for ${selectedWebhook?.objectType}.${selectedWebhook?.event}?`,
|
|
2294
|
-
default: false
|
|
2295
|
-
}
|
|
2324
|
+
default: false,
|
|
2325
|
+
},
|
|
2296
2326
|
]);
|
|
2297
2327
|
if (!confirmAnswer?.confirm) {
|
|
2298
|
-
console.log(
|
|
2328
|
+
console.log('\nā Cancelled.\n');
|
|
2299
2329
|
return;
|
|
2300
2330
|
}
|
|
2301
2331
|
await webhooksDeleteFlow(context, webhookAnswer.webhook);
|
|
@@ -2308,7 +2338,7 @@ async function webhooksDeleteInteractive(context) {
|
|
|
2308
2338
|
* Delete a webhook subscription (non-interactive)
|
|
2309
2339
|
*/
|
|
2310
2340
|
async function webhooksDeleteFlow(context, webhookId) {
|
|
2311
|
-
writeProgress(
|
|
2341
|
+
writeProgress('š Deleting trigger...');
|
|
2312
2342
|
try {
|
|
2313
2343
|
const result = await context.unifiedToApi.deleteWebhookSubscription(context.agentId, webhookId);
|
|
2314
2344
|
if (result.success) {
|
|
@@ -2346,7 +2376,7 @@ async function mcpManagementFlow(context, options, subAction) {
|
|
|
2346
2376
|
}
|
|
2347
2377
|
if (subAction === 'activate') {
|
|
2348
2378
|
if (!options.connectionId) {
|
|
2349
|
-
writeError(
|
|
2379
|
+
writeError('ā Missing required option: --connection <id>');
|
|
2350
2380
|
console.log("\nš” Use 'lua integrations mcp list' to see available connection IDs.\n");
|
|
2351
2381
|
return;
|
|
2352
2382
|
}
|
|
@@ -2355,7 +2385,7 @@ async function mcpManagementFlow(context, options, subAction) {
|
|
|
2355
2385
|
}
|
|
2356
2386
|
if (subAction === 'deactivate') {
|
|
2357
2387
|
if (!options.connectionId) {
|
|
2358
|
-
writeError(
|
|
2388
|
+
writeError('ā Missing required option: --connection <id>');
|
|
2359
2389
|
console.log("\nš” Use 'lua integrations mcp list' to see available connection IDs.\n");
|
|
2360
2390
|
return;
|
|
2361
2391
|
}
|
|
@@ -2372,9 +2402,9 @@ async function mcpManagementFlow(context, options, subAction) {
|
|
|
2372
2402
|
{ name: 'š List connections with MCP status', value: 'list' },
|
|
2373
2403
|
{ name: 'ā
Activate MCP server for a connection', value: 'activate' },
|
|
2374
2404
|
{ name: 'āøļø Deactivate MCP server for a connection', value: 'deactivate' },
|
|
2375
|
-
{ name: 'ā Back', value: 'back' }
|
|
2376
|
-
]
|
|
2377
|
-
}
|
|
2405
|
+
{ name: 'ā Back', value: 'back' },
|
|
2406
|
+
],
|
|
2407
|
+
},
|
|
2378
2408
|
]);
|
|
2379
2409
|
if (!actionAnswer || actionAnswer.action === 'back')
|
|
2380
2410
|
return;
|
|
@@ -2394,11 +2424,11 @@ async function mcpManagementFlow(context, options, subAction) {
|
|
|
2394
2424
|
* List all connections with their MCP server status
|
|
2395
2425
|
*/
|
|
2396
2426
|
async function mcpListFlow(context) {
|
|
2397
|
-
writeProgress(
|
|
2427
|
+
writeProgress('š Loading connections and MCP servers...');
|
|
2398
2428
|
try {
|
|
2399
2429
|
const [connectionsResult, mcpServers] = await Promise.all([
|
|
2400
2430
|
context.unifiedToApi.getConnections(context.agentId),
|
|
2401
|
-
fetchServersCore(context)
|
|
2431
|
+
fetchServersCore(context),
|
|
2402
2432
|
]);
|
|
2403
2433
|
if (!connectionsResult.success) {
|
|
2404
2434
|
writeError(`ā Failed to load connections: ${connectionsResult.error?.message}`);
|
|
@@ -2407,7 +2437,7 @@ async function mcpListFlow(context) {
|
|
|
2407
2437
|
if (!mcpServers)
|
|
2408
2438
|
return;
|
|
2409
2439
|
const connections = connectionsResult.data || [];
|
|
2410
|
-
const unifiedServers = mcpServers.filter(s => s.source === 'unifiedto');
|
|
2440
|
+
const unifiedServers = mcpServers.filter((s) => s.source === 'unifiedto');
|
|
2411
2441
|
// Map connection IDs to MCP servers
|
|
2412
2442
|
const serverByConnectionId = new Map();
|
|
2413
2443
|
for (const server of unifiedServers) {
|
|
@@ -2416,12 +2446,12 @@ async function mcpListFlow(context) {
|
|
|
2416
2446
|
serverByConnectionId.set(connectionMatch[1], server);
|
|
2417
2447
|
}
|
|
2418
2448
|
}
|
|
2419
|
-
console.log(
|
|
2420
|
-
console.log(
|
|
2421
|
-
console.log(
|
|
2449
|
+
console.log('\n' + 'ā'.repeat(80));
|
|
2450
|
+
console.log('š MCP Servers for Connections');
|
|
2451
|
+
console.log('ā'.repeat(80) + '\n');
|
|
2422
2452
|
if (connections.length === 0) {
|
|
2423
|
-
console.log(
|
|
2424
|
-
console.log(
|
|
2453
|
+
console.log('ā¹ļø No connections found.\n');
|
|
2454
|
+
console.log('š” Connect an integration with: lua integrations connect\n');
|
|
2425
2455
|
return;
|
|
2426
2456
|
}
|
|
2427
2457
|
for (const conn of connections) {
|
|
@@ -2432,7 +2462,7 @@ async function mcpListFlow(context) {
|
|
|
2432
2462
|
console.log(` Integration: ${conn.integrationName || conn.integrationType}`);
|
|
2433
2463
|
console.log(` MCP Server: ${serverName}`);
|
|
2434
2464
|
console.log(` Status: ${status}`);
|
|
2435
|
-
console.log(
|
|
2465
|
+
console.log('ā'.repeat(80));
|
|
2436
2466
|
}
|
|
2437
2467
|
console.log(`\nTotal: ${connections.length} connection(s)`);
|
|
2438
2468
|
console.log("\nš” Use --connection <id> with 'activate' or 'deactivate' commands.\n");
|
|
@@ -2445,12 +2475,12 @@ async function mcpListFlow(context) {
|
|
|
2445
2475
|
* Activate MCP server for a connection (non-interactive)
|
|
2446
2476
|
*/
|
|
2447
2477
|
async function mcpActivateFlow(context, connectionId) {
|
|
2448
|
-
writeProgress(
|
|
2478
|
+
writeProgress('š Finding MCP server for connection...');
|
|
2449
2479
|
try {
|
|
2450
2480
|
const mcpServers = await fetchServersCore(context);
|
|
2451
2481
|
if (!mcpServers)
|
|
2452
2482
|
return;
|
|
2453
|
-
const mcpServer = mcpServers.find(s => s.source === 'unifiedto' && s.url?.includes(`connection=${connectionId}`));
|
|
2483
|
+
const mcpServer = mcpServers.find((s) => s.source === 'unifiedto' && s.url?.includes(`connection=${connectionId}`));
|
|
2454
2484
|
if (!mcpServer) {
|
|
2455
2485
|
writeError(`ā No MCP server found for connection: ${connectionId}`);
|
|
2456
2486
|
console.log("\nš” Make sure the connection exists. Use 'lua integrations list' to check.\n");
|
|
@@ -2466,12 +2496,12 @@ async function mcpActivateFlow(context, connectionId) {
|
|
|
2466
2496
|
* Deactivate MCP server for a connection (non-interactive)
|
|
2467
2497
|
*/
|
|
2468
2498
|
async function mcpDeactivateFlow(context, connectionId) {
|
|
2469
|
-
writeProgress(
|
|
2499
|
+
writeProgress('š Finding MCP server for connection...');
|
|
2470
2500
|
try {
|
|
2471
2501
|
const mcpServers = await fetchServersCore(context);
|
|
2472
2502
|
if (!mcpServers)
|
|
2473
2503
|
return;
|
|
2474
|
-
const mcpServer = mcpServers.find(s => s.source === 'unifiedto' && s.url?.includes(`connection=${connectionId}`));
|
|
2504
|
+
const mcpServer = mcpServers.find((s) => s.source === 'unifiedto' && s.url?.includes(`connection=${connectionId}`));
|
|
2475
2505
|
if (!mcpServer) {
|
|
2476
2506
|
writeError(`ā No MCP server found for connection: ${connectionId}`);
|
|
2477
2507
|
console.log("\nš” Make sure the connection exists. Use 'lua integrations list' to check.\n");
|
|
@@ -2487,11 +2517,11 @@ async function mcpDeactivateFlow(context, connectionId) {
|
|
|
2487
2517
|
* Interactive flow for activating MCP server
|
|
2488
2518
|
*/
|
|
2489
2519
|
async function mcpActivateInteractive(context) {
|
|
2490
|
-
writeProgress(
|
|
2520
|
+
writeProgress('š Loading connections...');
|
|
2491
2521
|
try {
|
|
2492
2522
|
const [connectionsResult, mcpServers] = await Promise.all([
|
|
2493
2523
|
context.unifiedToApi.getConnections(context.agentId),
|
|
2494
|
-
fetchServersCore(context)
|
|
2524
|
+
fetchServersCore(context),
|
|
2495
2525
|
]);
|
|
2496
2526
|
if (!connectionsResult.success) {
|
|
2497
2527
|
writeError(`ā Failed to load connections: ${connectionsResult.error?.message}`);
|
|
@@ -2511,12 +2541,12 @@ async function mcpActivateInteractive(context) {
|
|
|
2511
2541
|
}
|
|
2512
2542
|
}
|
|
2513
2543
|
// Filter to show only inactive MCP servers
|
|
2514
|
-
const inactiveConnections = connections.filter(conn => {
|
|
2544
|
+
const inactiveConnections = connections.filter((conn) => {
|
|
2515
2545
|
const server = serverByConnectionId.get(conn.id);
|
|
2516
2546
|
return server && !server.active;
|
|
2517
2547
|
});
|
|
2518
2548
|
if (inactiveConnections.length === 0) {
|
|
2519
|
-
writeInfo(
|
|
2549
|
+
writeInfo('ā¹ļø All MCP servers are already active (or no connections found).\n');
|
|
2520
2550
|
return;
|
|
2521
2551
|
}
|
|
2522
2552
|
const connectionAnswer = await safePrompt([
|
|
@@ -2524,11 +2554,11 @@ async function mcpActivateInteractive(context) {
|
|
|
2524
2554
|
type: 'list',
|
|
2525
2555
|
name: 'connectionId',
|
|
2526
2556
|
message: 'Select a connection to activate MCP:',
|
|
2527
|
-
choices: inactiveConnections.map(conn => ({
|
|
2557
|
+
choices: inactiveConnections.map((conn) => ({
|
|
2528
2558
|
name: `${conn.integrationName || conn.integrationType} (${conn.id.substring(0, 12)}...)`,
|
|
2529
|
-
value: conn.id
|
|
2530
|
-
}))
|
|
2531
|
-
}
|
|
2559
|
+
value: conn.id,
|
|
2560
|
+
})),
|
|
2561
|
+
},
|
|
2532
2562
|
]);
|
|
2533
2563
|
if (!connectionAnswer)
|
|
2534
2564
|
return;
|
|
@@ -2542,11 +2572,11 @@ async function mcpActivateInteractive(context) {
|
|
|
2542
2572
|
* Interactive flow for deactivating MCP server
|
|
2543
2573
|
*/
|
|
2544
2574
|
async function mcpDeactivateInteractive(context) {
|
|
2545
|
-
writeProgress(
|
|
2575
|
+
writeProgress('š Loading connections...');
|
|
2546
2576
|
try {
|
|
2547
2577
|
const [connectionsResult, mcpServers] = await Promise.all([
|
|
2548
2578
|
context.unifiedToApi.getConnections(context.agentId),
|
|
2549
|
-
fetchServersCore(context)
|
|
2579
|
+
fetchServersCore(context),
|
|
2550
2580
|
]);
|
|
2551
2581
|
if (!connectionsResult.success) {
|
|
2552
2582
|
writeError(`ā Failed to load connections: ${connectionsResult.error?.message}`);
|
|
@@ -2566,12 +2596,12 @@ async function mcpDeactivateInteractive(context) {
|
|
|
2566
2596
|
}
|
|
2567
2597
|
}
|
|
2568
2598
|
// Filter to show only active MCP servers
|
|
2569
|
-
const activeConnections = connections.filter(conn => {
|
|
2599
|
+
const activeConnections = connections.filter((conn) => {
|
|
2570
2600
|
const server = serverByConnectionId.get(conn.id);
|
|
2571
2601
|
return server && server.active;
|
|
2572
2602
|
});
|
|
2573
2603
|
if (activeConnections.length === 0) {
|
|
2574
|
-
writeInfo(
|
|
2604
|
+
writeInfo('ā¹ļø No active MCP servers found to deactivate.\n');
|
|
2575
2605
|
return;
|
|
2576
2606
|
}
|
|
2577
2607
|
const connectionAnswer = await safePrompt([
|
|
@@ -2579,11 +2609,11 @@ async function mcpDeactivateInteractive(context) {
|
|
|
2579
2609
|
type: 'list',
|
|
2580
2610
|
name: 'connectionId',
|
|
2581
2611
|
message: 'Select a connection to deactivate MCP:',
|
|
2582
|
-
choices: activeConnections.map(conn => ({
|
|
2612
|
+
choices: activeConnections.map((conn) => ({
|
|
2583
2613
|
name: `${conn.integrationName || conn.integrationType} (${conn.id.substring(0, 12)}...)`,
|
|
2584
|
-
value: conn.id
|
|
2585
|
-
}))
|
|
2586
|
-
}
|
|
2614
|
+
value: conn.id,
|
|
2615
|
+
})),
|
|
2616
|
+
},
|
|
2587
2617
|
]);
|
|
2588
2618
|
if (!connectionAnswer)
|
|
2589
2619
|
return;
|