lua-cli 3.5.0-alpha.2 ā 3.5.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -689
- package/dist/api/agent.api.service.d.ts +1 -8
- package/dist/api/agent.api.service.js +1 -11
- package/dist/api/agent.api.service.js.map +1 -1
- package/dist/api/auth.api.service.d.ts +1 -1
- package/dist/api/auth.api.service.js +1 -1
- package/dist/api/auth.api.service.js.map +1 -1
- package/dist/api/backup.api.service.d.ts +80 -0
- package/dist/api/backup.api.service.js +101 -0
- package/dist/api/backup.api.service.js.map +1 -0
- package/dist/api/basket.api.service.d.ts +4 -5
- package/dist/api/basket.api.service.js +13 -18
- package/dist/api/basket.api.service.js.map +1 -1
- package/dist/api/cdn.api.service.d.ts +2 -0
- package/dist/api/cdn.api.service.js +2 -0
- package/dist/api/cdn.api.service.js.map +1 -1
- package/dist/api/chat.api.service.d.ts +10 -2
- package/dist/api/chat.api.service.js +21 -2
- package/dist/api/chat.api.service.js.map +1 -1
- package/dist/api/credentials.js +5 -8
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/custom.data.api.service.d.ts +3 -3
- package/dist/api/custom.data.api.service.js +9 -10
- package/dist/api/custom.data.api.service.js.map +1 -1
- package/dist/api/developer.api.service.d.ts +1 -1
- package/dist/api/developer.api.service.js +1 -1
- package/dist/api/developer.api.service.js.map +1 -1
- package/dist/api/http.client.js.map +1 -0
- package/dist/api/job.api.service.d.ts +2 -2
- package/dist/api/job.api.service.js +2 -2
- package/dist/api/job.api.service.js.map +1 -1
- package/dist/api/logs.api.service.d.ts +1 -1
- package/dist/api/logs.api.service.js +1 -1
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/marketplace.api.service.d.ts +6 -6
- package/dist/api/marketplace.api.service.js.map +1 -1
- package/dist/api/order.api.service.d.ts +3 -4
- package/dist/api/order.api.service.js +8 -10
- package/dist/api/order.api.service.js.map +1 -1
- package/dist/api/persona.api.service.d.ts +1 -1
- package/dist/api/persona.api.service.js +1 -1
- package/dist/api/persona.api.service.js.map +1 -1
- package/dist/api/postprocessor.api.service.d.ts +1 -1
- package/dist/api/postprocessor.api.service.js +1 -1
- package/dist/api/postprocessor.api.service.js.map +1 -1
- package/dist/api/preprocessor.api.service.d.ts +1 -1
- package/dist/api/preprocessor.api.service.js +1 -1
- package/dist/api/preprocessor.api.service.js.map +1 -1
- package/dist/api/products.api.service.d.ts +4 -4
- package/dist/api/products.api.service.js +6 -6
- package/dist/api/products.api.service.js.map +1 -1
- package/dist/api/resource.api.service.d.ts +76 -0
- package/dist/api/resource.api.service.js +74 -0
- package/dist/api/resource.api.service.js.map +1 -0
- package/dist/api/skills.api.service.d.ts +7 -15
- package/dist/api/skills.api.service.js +1 -1
- package/dist/api/skills.api.service.js.map +1 -1
- package/dist/api/tool.api.service.d.ts +1 -1
- package/dist/api/tool.api.service.js +1 -1
- package/dist/api/tool.api.service.js.map +1 -1
- package/dist/api/unifiedto.api.service.d.ts +7 -1
- package/dist/api/unifiedto.api.service.js +9 -1
- package/dist/api/unifiedto.api.service.js.map +1 -1
- package/dist/api/user.data.api.service.d.ts +7 -8
- package/dist/api/user.data.api.service.js +2 -3
- package/dist/api/user.data.api.service.js.map +1 -1
- package/dist/api/webhook.api.service.d.ts +1 -1
- package/dist/api/webhook.api.service.js +2 -2
- package/dist/api/webhook.api.service.js.map +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +1 -1
- package/dist/api/whatsapp-templates.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.js.map +1 -1
- package/dist/api-exports.d.ts +14 -12
- package/dist/api-exports.js +8 -8
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.js +63 -39
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/admin.js +3 -24
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/agents.d.ts +8 -7
- package/dist/commands/agents.js +63 -21
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.js +11 -23
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.js +33 -47
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/chatClear.js +11 -41
- package/dist/commands/chatClear.js.map +1 -1
- package/dist/commands/compile.d.ts +26 -23
- package/dist/commands/compile.js +98 -403
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/completion.js +1 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/deploy.js +55 -25
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.js +29 -45
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/env.js +12 -25
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/evals.js +3 -20
- package/dist/commands/evals.js.map +1 -1
- package/dist/commands/features.js +10 -23
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +135 -19
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/integrations.d.ts +2 -2
- package/dist/commands/integrations.js +761 -158
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/jobs.js +32 -56
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/logs.js +9 -20
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.js +34 -52
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.js +10 -23
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/persona.js +43 -74
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.js +15 -28
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.js +15 -28
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.js +30 -63
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push.js +350 -1308
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts +22 -0
- package/dist/commands/pushBackup.js +133 -0
- package/dist/commands/pushBackup.js.map +1 -0
- package/dist/commands/resources.js +29 -72
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts +1 -1
- package/dist/commands/skills.js +58 -70
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -3
- package/dist/commands/sync.js +12 -24
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test.js +135 -104
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/webhooks.js +15 -28
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts +104 -0
- package/dist/compiler/agent-traverser.js +311 -0
- package/dist/compiler/agent-traverser.js.map +1 -0
- package/dist/compiler/bundler.d.ts +42 -0
- package/dist/compiler/bundler.js +187 -0
- package/dist/compiler/bundler.js.map +1 -0
- package/dist/compiler/compiler.d.ts +177 -0
- package/dist/compiler/compiler.js +580 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +36 -0
- package/dist/compiler/index.js +42 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/plugins/base.d.ts +264 -0
- package/dist/compiler/plugins/base.js +307 -0
- package/dist/compiler/plugins/base.js.map +1 -0
- package/dist/compiler/plugins/job.plugin.d.ts +33 -0
- package/dist/compiler/plugins/job.plugin.js +143 -0
- package/dist/compiler/plugins/job.plugin.js.map +1 -0
- package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
- package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
- package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
- package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
- package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
- package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/processor-base.d.ts +16 -0
- package/dist/compiler/plugins/processor-base.js +34 -0
- package/dist/compiler/plugins/processor-base.js.map +1 -0
- package/dist/compiler/plugins/registry.d.ts +61 -0
- package/dist/compiler/plugins/registry.js +107 -0
- package/dist/compiler/plugins/registry.js.map +1 -0
- package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
- package/dist/compiler/plugins/skill.plugin.js +243 -0
- package/dist/compiler/plugins/skill.plugin.js.map +1 -0
- package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
- package/dist/compiler/plugins/tool.plugin.js +279 -0
- package/dist/compiler/plugins/tool.plugin.js.map +1 -0
- package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
- package/dist/compiler/plugins/webhook.plugin.js +127 -0
- package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
- package/dist/compiler/source-writer.d.ts +98 -0
- package/dist/compiler/source-writer.js +223 -0
- package/dist/compiler/source-writer.js.map +1 -0
- package/dist/compiler/types.d.ts +289 -0
- package/dist/compiler/types.js +20 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/compiler/utils/ast-helpers.d.ts +57 -0
- package/dist/compiler/utils/ast-helpers.js +164 -0
- package/dist/compiler/utils/ast-helpers.js.map +1 -0
- package/dist/compiler/utils/common.d.ts +23 -0
- package/dist/compiler/utils/common.js +66 -0
- package/dist/compiler/utils/common.js.map +1 -0
- package/dist/compiler/utils/file-discovery.d.ts +34 -0
- package/dist/compiler/utils/file-discovery.js +68 -0
- package/dist/compiler/utils/file-discovery.js.map +1 -0
- package/dist/compiler/utils/path-resolver.d.ts +25 -0
- package/dist/compiler/utils/path-resolver.js +66 -0
- package/dist/compiler/utils/path-resolver.js.map +1 -0
- package/dist/compiler/utils/schema-converter.d.ts +26 -0
- package/dist/compiler/utils/schema-converter.js +94 -0
- package/dist/compiler/utils/schema-converter.js.map +1 -0
- package/dist/config/compile.constants.d.ts +2 -22
- package/dist/config/compile.constants.js +2 -49
- package/dist/config/compile.constants.js.map +1 -1
- package/dist/config/constants.d.ts +18 -2
- package/dist/config/constants.js +28 -8
- package/dist/config/constants.js.map +1 -1
- package/dist/config/dev.constants.d.ts +0 -10
- package/dist/config/dev.constants.js +0 -10
- package/dist/config/dev.constants.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/instances/basket.instance.js.map +1 -0
- package/dist/instances/data.entry.instance.js.map +1 -0
- package/dist/instances/job.instance.js.map +1 -0
- package/dist/instances/order.instance.js.map +1 -0
- package/dist/instances/product.instance.js.map +1 -0
- package/dist/instances/product.pagination.instance.js.map +1 -0
- package/dist/instances/product.search.instance.js.map +1 -0
- package/dist/instances/user.instance.js.map +1 -0
- package/dist/interfaces/admin.d.ts +0 -38
- package/dist/interfaces/backup.d.ts +125 -0
- package/dist/interfaces/backup.js +8 -0
- package/dist/interfaces/backup.js.map +1 -0
- package/dist/interfaces/baskets.d.ts +0 -56
- package/dist/interfaces/common.d.ts +1 -0
- package/dist/interfaces/deploy.d.ts +0 -15
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/marketplace.d.ts +51 -0
- package/dist/interfaces/marketplace.js +1 -1
- package/dist/interfaces/marketplace.js.map +1 -1
- package/dist/interfaces/message.d.ts +0 -3
- package/dist/interfaces/orders.d.ts +0 -24
- package/dist/interfaces/postprocessors.d.ts +0 -18
- package/dist/interfaces/preprocessors.d.ts +0 -18
- package/dist/interfaces/skills.d.ts +61 -0
- package/dist/interfaces/unifiedto.d.ts +4 -0
- package/dist/interfaces/user.d.ts +25 -0
- package/dist/interfaces/webhooks.d.ts +0 -9
- package/dist/primitives/base.handler.d.ts +106 -0
- package/dist/primitives/base.handler.js +370 -0
- package/dist/primitives/base.handler.js.map +1 -0
- package/dist/primitives/index.d.ts +47 -0
- package/dist/primitives/index.js +78 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/job.handler.d.ts +52 -0
- package/dist/primitives/job.handler.js +118 -0
- package/dist/primitives/job.handler.js.map +1 -0
- package/dist/primitives/mcp-server.handler.d.ts +54 -0
- package/dist/primitives/mcp-server.handler.js +91 -0
- package/dist/primitives/mcp-server.handler.js.map +1 -0
- package/dist/primitives/postprocessor.handler.d.ts +49 -0
- package/dist/primitives/postprocessor.handler.js +81 -0
- package/dist/primitives/postprocessor.handler.js.map +1 -0
- package/dist/primitives/preprocessor.handler.d.ts +54 -0
- package/dist/primitives/preprocessor.handler.js +95 -0
- package/dist/primitives/preprocessor.handler.js.map +1 -0
- package/dist/primitives/skill.handler.d.ts +44 -0
- package/dist/primitives/skill.handler.js +192 -0
- package/dist/primitives/skill.handler.js.map +1 -0
- package/dist/primitives/types.d.ts +72 -0
- package/dist/primitives/types.js +17 -0
- package/dist/primitives/types.js.map +1 -0
- package/dist/primitives/webhook.handler.d.ts +50 -0
- package/dist/primitives/webhook.handler.js +96 -0
- package/dist/primitives/webhook.handler.js.map +1 -0
- package/dist/services/auth.js +1 -2
- package/dist/services/auth.js.map +1 -1
- package/dist/services/sandbox.service.d.ts +103 -0
- package/dist/services/sandbox.service.js +479 -0
- package/dist/services/sandbox.service.js.map +1 -0
- package/dist/types/api-contracts.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/skill.d.ts +8 -2
- package/dist/types/skill.js +8 -0
- package/dist/types/skill.js.map +1 -1
- package/dist/types/yaml.types.d.ts +69 -0
- package/dist/types/yaml.types.js +6 -0
- package/dist/types/yaml.types.js.map +1 -0
- package/dist/utils/artifact-loader.d.ts +108 -0
- package/dist/utils/artifact-loader.js +188 -0
- package/dist/utils/artifact-loader.js.map +1 -0
- package/dist/utils/backup-helpers.d.ts +122 -0
- package/dist/utils/backup-helpers.js +274 -0
- package/dist/utils/backup-helpers.js.map +1 -0
- package/dist/utils/cli.d.ts +8 -0
- package/dist/utils/cli.js +19 -2
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/command-utils.d.ts +42 -0
- package/dist/utils/command-utils.js +83 -0
- package/dist/utils/command-utils.js.map +1 -0
- package/dist/utils/deploy-helpers.d.ts +0 -29
- package/dist/utils/deploy-helpers.js +0 -70
- package/dist/utils/deploy-helpers.js.map +1 -1
- package/dist/utils/dev-api.d.ts +3 -99
- package/dist/utils/dev-api.js +3 -430
- package/dist/utils/dev-api.js.map +1 -1
- package/dist/utils/dev-server.d.ts +3 -1
- package/dist/utils/dev-server.js +69 -145
- package/dist/utils/dev-server.js.map +1 -1
- package/dist/utils/dev-watcher.d.ts +0 -1
- package/dist/utils/dev-watcher.js +23 -8
- package/dist/utils/dev-watcher.js.map +1 -1
- package/dist/utils/env-loader.utils.d.ts +10 -1
- package/dist/utils/env-loader.utils.js +39 -31
- package/dist/utils/env-loader.utils.js.map +1 -1
- package/dist/utils/files.d.ts +47 -3
- package/dist/utils/files.js +98 -40
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/init-agent.js +1 -2
- package/dist/utils/init-agent.js.map +1 -1
- package/dist/utils/init-helpers.d.ts +2 -10
- package/dist/utils/init-helpers.js +9 -17
- package/dist/utils/init-helpers.js.map +1 -1
- package/dist/utils/init-prompts.d.ts +0 -8
- package/dist/utils/init-prompts.js +0 -22
- package/dist/utils/init-prompts.js.map +1 -1
- package/dist/utils/prompt-handler.d.ts +3 -0
- package/dist/utils/prompt-handler.js +13 -0
- package/dist/utils/prompt-handler.js.map +1 -1
- package/dist/utils/sandbox-storage.d.ts +6 -5
- package/dist/utils/sandbox-storage.js +12 -12
- package/dist/utils/sandbox-storage.js.map +1 -1
- package/dist/utils/sandbox.d.ts +7 -30
- package/dist/utils/sandbox.js +247 -223
- package/dist/utils/sandbox.js.map +1 -1
- package/dist/utils/semver.d.ts +12 -0
- package/dist/utils/semver.js +23 -0
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/sync-display.d.ts +9 -0
- package/dist/utils/sync-display.js +67 -0
- package/dist/utils/sync-display.js.map +1 -0
- package/dist/utils/sync-fetch.d.ts +23 -0
- package/dist/utils/sync-fetch.js +64 -0
- package/dist/utils/sync-fetch.js.map +1 -0
- package/dist/utils/sync-helpers.d.ts +4 -59
- package/dist/utils/sync-helpers.js +4 -206
- package/dist/utils/sync-helpers.js.map +1 -1
- package/dist/web/app.css +912 -186
- package/dist/web/app.js +46 -46
- package/docs/API_INDEX.md +100 -0
- package/docs/API_REFERENCE.md +773 -0
- package/docs/CLI_REFERENCE.md +924 -0
- package/docs/GETTING_STARTED.md +862 -0
- package/docs/README.md +270 -0
- package/docs/api/AI.md +882 -0
- package/docs/api/Baskets.md +511 -0
- package/docs/api/CDN.md +524 -0
- package/docs/api/Data.md +446 -0
- package/docs/api/Jobs.md +524 -0
- package/docs/api/LuaAgent.md +454 -0
- package/docs/api/LuaJob.md +604 -0
- package/docs/api/LuaSkill.md +396 -0
- package/docs/api/LuaTool.md +521 -0
- package/docs/api/LuaWebhook.md +601 -0
- package/docs/api/Orders.md +514 -0
- package/docs/api/PostProcessor.md +565 -0
- package/docs/api/PreProcessor.md +630 -0
- package/docs/api/Products.md +507 -0
- package/docs/api/Templates.md +662 -0
- package/docs/api/User.md +567 -0
- package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
- package/docs/compiler-v2/ASSESSMENT.md +205 -0
- package/docs/compiler-v2/TEST_PLAN.md +306 -0
- package/package.json +3 -7
- package/template/package.json +1 -1
- package/template/tsconfig.json +1 -1
- package/dist/common/basket.instance.js.map +0 -1
- package/dist/common/data.entry.instance.js.map +0 -1
- package/dist/common/http.client.js.map +0 -1
- package/dist/common/job.instance.js.map +0 -1
- package/dist/common/order.instance.js.map +0 -1
- package/dist/common/product.instance.js.map +0 -1
- package/dist/common/product.pagination.instance.js.map +0 -1
- package/dist/common/product.search.instance.js.map +0 -1
- package/dist/common/user.instance.js.map +0 -1
- package/dist/config/auth.constants.d.ts +0 -11
- package/dist/config/auth.constants.js +0 -12
- package/dist/config/auth.constants.js.map +0 -1
- package/dist/config/init.constants.d.ts +0 -15
- package/dist/config/init.constants.js +0 -20
- package/dist/config/init.constants.js.map +0 -1
- package/dist/interfaces/compile.d.ts +0 -12
- package/dist/interfaces/compile.js +0 -5
- package/dist/interfaces/compile.js.map +0 -1
- package/dist/types/compile.types.d.ts +0 -131
- package/dist/types/compile.types.js +0 -6
- package/dist/types/compile.types.js.map +0 -1
- package/dist/utils/agent-code-utils.d.ts +0 -25
- package/dist/utils/agent-code-utils.js +0 -107
- package/dist/utils/agent-code-utils.js.map +0 -1
- package/dist/utils/bundling.d.ts +0 -89
- package/dist/utils/bundling.js +0 -1068
- package/dist/utils/bundling.js.map +0 -1
- package/dist/utils/compile.d.ts +0 -116
- package/dist/utils/compile.js +0 -1062
- package/dist/utils/compile.js.map +0 -1
- package/dist/utils/deploy-api.d.ts +0 -26
- package/dist/utils/deploy-api.js +0 -54
- package/dist/utils/deploy-api.js.map +0 -1
- package/dist/utils/deployment.d.ts +0 -26
- package/dist/utils/deployment.js +0 -218
- package/dist/utils/deployment.js.map +0 -1
- package/dist/utils/dev-helpers.d.ts +0 -47
- package/dist/utils/dev-helpers.js +0 -82
- package/dist/utils/dev-helpers.js.map +0 -1
- package/dist/utils/job-management.d.ts +0 -27
- package/dist/utils/job-management.js +0 -248
- package/dist/utils/job-management.js.map +0 -1
- package/dist/utils/mcp-server-management.d.ts +0 -26
- package/dist/utils/mcp-server-management.js +0 -197
- package/dist/utils/mcp-server-management.js.map +0 -1
- package/dist/utils/postprocessor-management.d.ts +0 -9
- package/dist/utils/postprocessor-management.js +0 -117
- package/dist/utils/postprocessor-management.js.map +0 -1
- package/dist/utils/pre-bundle-jobs.d.ts +0 -27
- package/dist/utils/pre-bundle-jobs.js +0 -189
- package/dist/utils/pre-bundle-jobs.js.map +0 -1
- package/dist/utils/preprocessor-management.d.ts +0 -9
- package/dist/utils/preprocessor-management.js +0 -117
- package/dist/utils/preprocessor-management.js.map +0 -1
- package/dist/utils/push-api.d.ts +0 -15
- package/dist/utils/push-api.js +0 -49
- package/dist/utils/push-api.js.map +0 -1
- package/dist/utils/push-helpers.d.ts +0 -82
- package/dist/utils/push-helpers.js +0 -246
- package/dist/utils/push-helpers.js.map +0 -1
- package/dist/utils/skill-management.d.ts +0 -39
- package/dist/utils/skill-management.js +0 -299
- package/dist/utils/skill-management.js.map +0 -1
- package/dist/utils/test-helpers.d.ts +0 -33
- package/dist/utils/test-helpers.js +0 -84
- package/dist/utils/test-helpers.js.map +0 -1
- package/dist/utils/test-prompts.d.ts +0 -23
- package/dist/utils/test-prompts.js +0 -187
- package/dist/utils/test-prompts.js.map +0 -1
- package/dist/utils/tool-detection.d.ts +0 -19
- package/dist/utils/tool-detection.js +0 -125
- package/dist/utils/tool-detection.js.map +0 -1
- package/dist/utils/webhook-management.d.ts +0 -27
- package/dist/utils/webhook-management.js +0 -241
- package/dist/utils/webhook-management.js.map +0 -1
- /package/dist/{common ā api}/http.client.d.ts +0 -0
- /package/dist/{common ā api}/http.client.js +0 -0
- /package/dist/{common ā instances}/basket.instance.d.ts +0 -0
- /package/dist/{common ā instances}/basket.instance.js +0 -0
- /package/dist/{common ā instances}/data.entry.instance.d.ts +0 -0
- /package/dist/{common ā instances}/data.entry.instance.js +0 -0
- /package/dist/{common ā instances}/job.instance.d.ts +0 -0
- /package/dist/{common ā instances}/job.instance.js +0 -0
- /package/dist/{common ā instances}/order.instance.d.ts +0 -0
- /package/dist/{common ā instances}/order.instance.js +0 -0
- /package/dist/{common ā instances}/product.instance.d.ts +0 -0
- /package/dist/{common ā instances}/product.instance.js +0 -0
- /package/dist/{common ā instances}/product.pagination.instance.d.ts +0 -0
- /package/dist/{common ā instances}/product.pagination.instance.js +0 -0
- /package/dist/{common ā instances}/product.search.instance.d.ts +0 -0
- /package/dist/{common ā instances}/product.search.instance.js +0 -0
- /package/dist/{common ā instances}/user.instance.d.ts +0 -0
- /package/dist/{common ā instances}/user.instance.js +0 -0
package/dist/commands/push.js
CHANGED
|
@@ -2,37 +2,60 @@
|
|
|
2
2
|
* Push Command
|
|
3
3
|
* Orchestrates pushing skill versions to the server
|
|
4
4
|
*/
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import yaml from 'js-yaml';
|
|
8
5
|
import { compileCommand } from './compile.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { readYamlConfig, } from '../utils/files.js';
|
|
7
|
+
import { withErrorHandling, writeProgress, writeSuccess, writeInfo, clearPromptLines } from '../utils/cli.js';
|
|
8
|
+
import { requireAuthOrExit } from '../utils/command-utils.js';
|
|
12
9
|
import { safePrompt } from '../utils/prompt-handler.js';
|
|
13
|
-
import {
|
|
14
|
-
import { pushVersion } from '../utils/push-api.js';
|
|
15
|
-
import { fetchVersions, publishVersion, } from '../utils/deploy-api.js';
|
|
10
|
+
import { incrementPatchVersion, maxSemver } from '../utils/semver.js';
|
|
16
11
|
import { BASE_URLS } from '../config/constants.js';
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
12
|
+
import PersonaApi from '../api/persona.api.service.js';
|
|
13
|
+
import { loadManifest, getAgentPersona } from '../utils/artifact-loader.js';
|
|
14
|
+
import { skillHandler as skillH, webhookHandler as webhookH, jobHandler as jobH, preprocessorHandler as preprocessorH, postprocessorHandler as postprocessorH, } from '../primitives/index.js';
|
|
15
|
+
import { pushBackupCommand } from './pushBackup.js';
|
|
21
16
|
// ============================================================================
|
|
22
17
|
// Core Push Helpers (shared by all push functions)
|
|
23
18
|
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Prompts user to confirm or update the version.
|
|
21
|
+
*
|
|
22
|
+
* @param currentVersion - Current version of the skill
|
|
23
|
+
* @returns Confirmed or updated version
|
|
24
|
+
*/
|
|
25
|
+
async function promptVersionConfirmOrUpdate(currentVersion) {
|
|
26
|
+
console.log(`\nCurrent version: ${currentVersion || '(none - first push)'}`);
|
|
27
|
+
const answer = await safePrompt([
|
|
28
|
+
{
|
|
29
|
+
type: "input",
|
|
30
|
+
name: "newVersion",
|
|
31
|
+
message: "Enter new version to push:",
|
|
32
|
+
default: incrementPatchVersion(currentVersion),
|
|
33
|
+
validate: (input) => {
|
|
34
|
+
if (!input || input.trim() === "") {
|
|
35
|
+
return "Version cannot be empty";
|
|
36
|
+
}
|
|
37
|
+
// Basic semver validation
|
|
38
|
+
const semverRegex = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/;
|
|
39
|
+
if (!semverRegex.test(input.trim())) {
|
|
40
|
+
return "Version must follow semver format (e.g., 1.0.0, 1.0.0-alpha.1)";
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]);
|
|
46
|
+
if (!answer) {
|
|
47
|
+
console.log("Push cancelled.");
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
clearPromptLines(2);
|
|
51
|
+
return answer.newVersion.trim();
|
|
52
|
+
}
|
|
24
53
|
/**
|
|
25
54
|
* Authenticates the user and returns the API key
|
|
26
55
|
* Exits with error if authentication fails
|
|
27
56
|
*/
|
|
28
57
|
async function authenticateOrFail() {
|
|
29
|
-
|
|
30
|
-
if (!apiKey) {
|
|
31
|
-
console.log("ā No API key found. Please run 'lua auth configure' to set up your API key.");
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
await checkApiKey(apiKey);
|
|
35
|
-
return apiKey;
|
|
58
|
+
return requireAuthOrExit(false);
|
|
36
59
|
}
|
|
37
60
|
/**
|
|
38
61
|
* Selects an entity from a list, either by options.entityName or interactive prompt
|
|
@@ -43,15 +66,13 @@ async function authenticateOrFail() {
|
|
|
43
66
|
async function selectEntityOrFail(items, options, config) {
|
|
44
67
|
const { entityType, nameFields = ['id', 'name'], formatChoice } = config;
|
|
45
68
|
if (items.length === 0) {
|
|
46
|
-
|
|
47
|
-
process.exit(1);
|
|
69
|
+
throw new Error(`No ${entityType}s found in lua.skill.yaml.`);
|
|
48
70
|
}
|
|
49
71
|
// Non-interactive: find by name
|
|
50
72
|
if (options.entityName) {
|
|
51
73
|
const found = items.find((item) => nameFields.some(field => item[field] === options.entityName));
|
|
52
74
|
if (!found) {
|
|
53
|
-
|
|
54
|
-
process.exit(1);
|
|
75
|
+
throw new Error(`${entityType} "${options.entityName}" not found`);
|
|
55
76
|
}
|
|
56
77
|
writeInfo(`š¦ Selected ${entityType}: ${found.name}`);
|
|
57
78
|
return found;
|
|
@@ -84,38 +105,28 @@ async function selectEntityOrFail(items, options, config) {
|
|
|
84
105
|
* Resolves version from options or interactive prompt
|
|
85
106
|
* Validates semantic versioning format
|
|
86
107
|
*/
|
|
87
|
-
async function resolveVersionOrFail(currentVersion, options) {
|
|
108
|
+
async function resolveVersionOrFail(currentVersion, options, highestKnownVersion) {
|
|
109
|
+
// If version explicitly provided, use it
|
|
88
110
|
if (options.version) {
|
|
89
111
|
if (!/^\d+\.\d+\.\d+/.test(options.version)) {
|
|
90
|
-
|
|
91
|
-
process.exit(1);
|
|
112
|
+
throw new Error(`Invalid version format: "${options.version}". Use semantic versioning (e.g., 1.0.5)`);
|
|
92
113
|
}
|
|
93
114
|
writeInfo(`š Using version: ${options.version}`);
|
|
94
115
|
return options.version;
|
|
95
116
|
}
|
|
117
|
+
// If force flag provided, auto-bump without prompting
|
|
118
|
+
if (options.force) {
|
|
119
|
+
// Bump from the highest known version (max of YAML and server) to avoid conflicts
|
|
120
|
+
const baseVersion = highestKnownVersion ? maxSemver(currentVersion, highestKnownVersion) : currentVersion;
|
|
121
|
+
const newVersion = incrementPatchVersion(baseVersion);
|
|
122
|
+
writeInfo(`š Auto-bumping version: ${currentVersion} ā ${newVersion}`);
|
|
123
|
+
return newVersion;
|
|
124
|
+
}
|
|
125
|
+
// Otherwise, prompt interactively
|
|
96
126
|
return await promptVersionConfirmOrUpdate(currentVersion);
|
|
97
127
|
}
|
|
98
128
|
/**
|
|
99
|
-
|
|
100
|
-
* @returns The bundled data for the entity, or exits if not found
|
|
101
|
-
*/
|
|
102
|
-
function loadBundledEntityData(filename, entityName, entityType) {
|
|
103
|
-
const bundledPath = path.join(process.cwd(), 'dist', filename);
|
|
104
|
-
if (!fs.existsSync(bundledPath)) {
|
|
105
|
-
console.log(`ā Bundled ${entityType.toLowerCase()} data not found.`);
|
|
106
|
-
console.log("š” Please ensure your code is properly compiled.");
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
const bundled = JSON.parse(fs.readFileSync(bundledPath, 'utf8'));
|
|
110
|
-
const bundledData = bundled.find((item) => item.name === entityName) || {};
|
|
111
|
-
if (!bundledData || Object.keys(bundledData).length === 0) {
|
|
112
|
-
console.log(`\nā ${entityType} "${entityName}" not found in compiled code.`);
|
|
113
|
-
console.log("š” This may have been removed or commented out in your code.");
|
|
114
|
-
console.log(`š” Please uncomment the ${entityType.toLowerCase()} or remove it from lua.skill.yaml.`);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
return bundledData;
|
|
118
|
-
}
|
|
129
|
+
|
|
119
130
|
/**
|
|
120
131
|
* Determines if we should deploy after push based on options or prompt
|
|
121
132
|
*/
|
|
@@ -139,6 +150,107 @@ async function shouldDeployAfterPush(options) {
|
|
|
139
150
|
]);
|
|
140
151
|
return answer?.deployNow || false;
|
|
141
152
|
}
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// Generic Push/Deploy (replaces per-type push/deploy functions)
|
|
155
|
+
// ============================================================================
|
|
156
|
+
/**
|
|
157
|
+
* Generic push for any versioned primitive (webhook, job, preprocessor, postprocessor).
|
|
158
|
+
* Skill has its own flow due to tools array + config validation.
|
|
159
|
+
*/
|
|
160
|
+
async function pushVersionedPrimitive(handler, options = {}) {
|
|
161
|
+
try {
|
|
162
|
+
// Step 1: Compile
|
|
163
|
+
writeProgress("š¦ Compiling project...");
|
|
164
|
+
await compileCommand();
|
|
165
|
+
writeSuccess("ā
Compilation complete");
|
|
166
|
+
// Step 2: Authenticate
|
|
167
|
+
const apiKey = await authenticateOrFail();
|
|
168
|
+
writeSuccess("ā
Authentication verified");
|
|
169
|
+
// Step 3: Read config
|
|
170
|
+
const config = readYamlConfig();
|
|
171
|
+
if (!config?.agent?.agentId) {
|
|
172
|
+
throw new Error("No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
|
|
173
|
+
}
|
|
174
|
+
const agentId = config.agent.agentId;
|
|
175
|
+
// Step 4: Get items from YAML and select
|
|
176
|
+
const items = handler.getFromYaml(config);
|
|
177
|
+
if (items.length === 0) {
|
|
178
|
+
throw new Error(`No ${handler.displayNamePlural} found in lua.skill.yaml.`);
|
|
179
|
+
}
|
|
180
|
+
const selected = await selectEntityOrFail(items, options, {
|
|
181
|
+
entityType: handler.displayName,
|
|
182
|
+
nameFields: ['id', handler.yamlConfig.idField, 'name']
|
|
183
|
+
});
|
|
184
|
+
const entityId = selected[handler.yamlConfig.idField];
|
|
185
|
+
if (!entityId) {
|
|
186
|
+
throw new Error(`${handler.displayName} "${selected.name}" has no server ID. Run 'lua compile' first.`);
|
|
187
|
+
}
|
|
188
|
+
// Step 5: Load bundled data
|
|
189
|
+
const manifest = loadManifest();
|
|
190
|
+
const pushData = handler.prepareForPush(manifest, selected.name);
|
|
191
|
+
if (!pushData) {
|
|
192
|
+
throw new Error(`${handler.displayName} "${selected.name}" not found in compiled output.`);
|
|
193
|
+
}
|
|
194
|
+
// Step 6: Resolve version (check server for highest to avoid conflicts)
|
|
195
|
+
const serverHighest = options.force
|
|
196
|
+
? await handler.getHighestServerVersion(apiKey, agentId, entityId)
|
|
197
|
+
: undefined;
|
|
198
|
+
const confirmedVersion = await resolveVersionOrFail(selected.version, options, serverHighest ?? undefined);
|
|
199
|
+
if (confirmedVersion !== selected.version) {
|
|
200
|
+
handler.updateVersionInYaml(selected.name, confirmedVersion);
|
|
201
|
+
}
|
|
202
|
+
// Step 7: Push
|
|
203
|
+
writeProgress(`\nš Pushing ${selected.name} v${confirmedVersion} to server...`);
|
|
204
|
+
const result = await handler.pushToServer(apiKey, agentId, entityId, { ...pushData, version: confirmedVersion });
|
|
205
|
+
if (!result.success) {
|
|
206
|
+
throw new Error(`Push Error: ${result.error || 'Unknown error'}`);
|
|
207
|
+
}
|
|
208
|
+
writeSuccess(`\nā
Successfully pushed ${selected.name} v${confirmedVersion}\n`);
|
|
209
|
+
// Step 8: Deploy if requested
|
|
210
|
+
if (await shouldDeployAfterPush(options)) {
|
|
211
|
+
await genericDeployAfterPush(handler, apiKey, agentId, entityId, selected.name, confirmedVersion, options.autoDeploy || false);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
writeInfo(`š” You can deploy later using: lua ${handler.displayNamePlural} production`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Generic deploy/publish after push for any versioned primitive.
|
|
223
|
+
*/
|
|
224
|
+
async function genericDeployAfterPush(handler, apiKey, agentId, entityId, entityName, version, skipConfirmation = false) {
|
|
225
|
+
try {
|
|
226
|
+
if (!skipConfirmation) {
|
|
227
|
+
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
228
|
+
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
229
|
+
const confirmAnswer = await safePrompt([{
|
|
230
|
+
type: 'confirm',
|
|
231
|
+
name: 'confirm',
|
|
232
|
+
message: 'Are you absolutely sure you want to deploy?',
|
|
233
|
+
default: false
|
|
234
|
+
}]);
|
|
235
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
236
|
+
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
writeProgress(`š Publishing ${handler.displayName} version...`);
|
|
241
|
+
const result = await handler.publishVersion(apiKey, agentId, entityId, version);
|
|
242
|
+
if (!result.success) {
|
|
243
|
+
console.error(`\nā Deploy Error: ${result.error || 'Unknown error'}\n`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
writeSuccess(`\nā
${entityName} v${version} deployed to production\n`);
|
|
247
|
+
writeInfo(`š” The new ${handler.displayName} version is now active.`);
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
console.error(`\nā Error deploying ${handler.displayName}:`, error);
|
|
251
|
+
console.log(`š” You can deploy later using: lua ${handler.displayNamePlural} production\n`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
142
254
|
/**
|
|
143
255
|
* Main push command - pushes a skill or persona version to the server.
|
|
144
256
|
*
|
|
@@ -165,33 +277,30 @@ export async function pushCommand(type, cmdObj) {
|
|
|
165
277
|
force: cmdObj?.force || false,
|
|
166
278
|
autoDeploy: cmdObj?.autoDeploy || false,
|
|
167
279
|
entityName: cmdObj?.name || null,
|
|
168
|
-
version: cmdObj?.
|
|
280
|
+
version: cmdObj?.setVersion || null
|
|
169
281
|
};
|
|
170
282
|
let selectedType;
|
|
171
283
|
// Handle 'all' type with force flag
|
|
172
284
|
if (type === 'all') {
|
|
173
285
|
if (!options.force) {
|
|
174
|
-
console.error('ā The "all" type requires the --force flag');
|
|
175
286
|
console.log('\nUsage:');
|
|
176
287
|
console.log(' lua push all --force Push all components without prompts');
|
|
177
288
|
console.log(' lua push all --force --auto-deploy Push and deploy all to production');
|
|
178
|
-
|
|
289
|
+
throw new Error('The "all" type requires the --force flag');
|
|
179
290
|
}
|
|
180
291
|
return await pushAllCommand(options);
|
|
181
292
|
}
|
|
182
293
|
// Validate that entityName without type is not allowed
|
|
183
294
|
if (options.entityName && !type) {
|
|
184
|
-
console.error('ā Type must be specified when using the --name option.');
|
|
185
295
|
console.log('\nUsage:');
|
|
186
|
-
console.log(' lua push skill --name mySkill --version 1.0.5 Push specific skill');
|
|
187
|
-
console.log(' lua push webhook --name myWebhook --version 2.0.0 Push specific webhook');
|
|
188
|
-
|
|
296
|
+
console.log(' lua push skill --name mySkill --set-version 1.0.5 Push specific skill');
|
|
297
|
+
console.log(' lua push webhook --name myWebhook --set-version 2.0.0 Push specific webhook');
|
|
298
|
+
throw new Error('Type must be specified when using the --name option.');
|
|
189
299
|
}
|
|
190
300
|
// Step 1: Check if type was provided as argument
|
|
191
301
|
if (type) {
|
|
192
302
|
// Validate the provided type
|
|
193
|
-
if (type !== 'skill' && type !== 'persona' && type !== 'webhook' && type !== 'job' && type !== 'preprocessor' && type !== 'postprocessor' && type !== 'mcp') {
|
|
194
|
-
console.error(`ā Invalid type: "${type}". Must be "skill", "persona", "webhook", "job", "preprocessor", "postprocessor", "mcp", or "all".`);
|
|
303
|
+
if (type !== 'skill' && type !== 'persona' && type !== 'webhook' && type !== 'job' && type !== 'preprocessor' && type !== 'postprocessor' && type !== 'mcp' && type !== 'backup') {
|
|
195
304
|
console.log('\nUsage:');
|
|
196
305
|
console.log(' lua push - Interactive selection');
|
|
197
306
|
console.log(' lua push skill - Push a skill directly');
|
|
@@ -201,8 +310,9 @@ export async function pushCommand(type, cmdObj) {
|
|
|
201
310
|
console.log(' lua push preprocessor - Push a preprocessor directly');
|
|
202
311
|
console.log(' lua push postprocessor - Push a postprocessor directly');
|
|
203
312
|
console.log(' lua push mcp - Push an MCP server directly');
|
|
313
|
+
console.log(' lua push backup - Push project source backup');
|
|
204
314
|
console.log(' lua push all --force - Push all components without prompts');
|
|
205
|
-
|
|
315
|
+
throw new Error(`Invalid type: "${type}". Must be "skill", "persona", "webhook", "job", "preprocessor", "postprocessor", "mcp", "backup", or "all".`);
|
|
206
316
|
}
|
|
207
317
|
selectedType = type;
|
|
208
318
|
}
|
|
@@ -220,7 +330,8 @@ export async function pushCommand(type, cmdObj) {
|
|
|
220
330
|
{ name: 'š„ PreProcessor', value: 'preprocessor' },
|
|
221
331
|
{ name: 'š¤ PostProcessor', value: 'postprocessor' },
|
|
222
332
|
{ name: 'š MCP Server', value: 'mcp' },
|
|
223
|
-
{ name: 'š Persona', value: 'persona' }
|
|
333
|
+
{ name: 'š Persona', value: 'persona' },
|
|
334
|
+
{ name: 'š¾ Backup (source files)', value: 'backup' }
|
|
224
335
|
]
|
|
225
336
|
}
|
|
226
337
|
]);
|
|
@@ -232,89 +343,31 @@ export async function pushCommand(type, cmdObj) {
|
|
|
232
343
|
}
|
|
233
344
|
// Step 3: Route to appropriate function
|
|
234
345
|
if (selectedType === 'skill') {
|
|
235
|
-
await
|
|
346
|
+
await pushVersionedPrimitive(skillH, options);
|
|
236
347
|
}
|
|
237
348
|
else if (selectedType === 'webhook') {
|
|
238
|
-
await
|
|
349
|
+
await pushVersionedPrimitive(webhookH, options);
|
|
239
350
|
}
|
|
240
351
|
else if (selectedType === 'job') {
|
|
241
|
-
await
|
|
352
|
+
await pushVersionedPrimitive(jobH, options);
|
|
242
353
|
}
|
|
243
354
|
else if (selectedType === 'preprocessor') {
|
|
244
|
-
await
|
|
355
|
+
await pushVersionedPrimitive(preprocessorH, options);
|
|
245
356
|
}
|
|
246
357
|
else if (selectedType === 'postprocessor') {
|
|
247
|
-
await
|
|
358
|
+
await pushVersionedPrimitive(postprocessorH, options);
|
|
248
359
|
}
|
|
249
360
|
else if (selectedType === 'mcp') {
|
|
250
|
-
await
|
|
361
|
+
await pushMCPServer(options);
|
|
362
|
+
}
|
|
363
|
+
else if (selectedType === 'backup') {
|
|
364
|
+
await pushBackupCommand({ force: options.force });
|
|
251
365
|
}
|
|
252
366
|
else {
|
|
253
367
|
await pushPersonaVersion(options);
|
|
254
368
|
}
|
|
255
369
|
}, "push");
|
|
256
370
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Push skill version to the server.
|
|
259
|
-
*/
|
|
260
|
-
async function pushSkillVersion(options = {}) {
|
|
261
|
-
// Step 1: Validate configuration
|
|
262
|
-
const yamlConfig = readSkillConfig();
|
|
263
|
-
validatePushConfig(yamlConfig);
|
|
264
|
-
const config = yamlConfig;
|
|
265
|
-
// Step 2: Get available skills and select
|
|
266
|
-
const availableSkills = getAvailableSkills(config);
|
|
267
|
-
if (availableSkills.length === 0) {
|
|
268
|
-
console.log("ā No skills found in configuration. Please compile your skill first using 'lua compile'.");
|
|
269
|
-
process.exit(1);
|
|
270
|
-
}
|
|
271
|
-
const selectedSkill = await selectEntityOrFail(availableSkills, options, {
|
|
272
|
-
entityType: 'skill',
|
|
273
|
-
nameFields: ['skillId', 'name']
|
|
274
|
-
});
|
|
275
|
-
// Step 3: Handle version
|
|
276
|
-
const confirmedVersion = await resolveVersionOrFail(selectedSkill.version, options);
|
|
277
|
-
if (confirmedVersion !== selectedSkill.version) {
|
|
278
|
-
writeInfo(`š Updating version from ${selectedSkill.version} to ${confirmedVersion}`);
|
|
279
|
-
updateSkillVersionInYaml(selectedSkill.name, confirmedVersion);
|
|
280
|
-
selectedSkill.version = confirmedVersion;
|
|
281
|
-
}
|
|
282
|
-
// Step 4: Authenticate
|
|
283
|
-
const apiKey = await authenticateOrFail();
|
|
284
|
-
writeProgress("ā
Authenticated");
|
|
285
|
-
// Step 5: Compile the skill
|
|
286
|
-
writeProgress("š Compiling skill...");
|
|
287
|
-
await compileCommand();
|
|
288
|
-
// Step 6: Validate and extract deploy data
|
|
289
|
-
const deployData = readDeployJson();
|
|
290
|
-
validateDeployData(deployData, selectedSkill);
|
|
291
|
-
const skillDeployData = getSkillDeployData(deployData, selectedSkill.name);
|
|
292
|
-
// Step 7: Push version to server
|
|
293
|
-
writeProgress("š Pushing version to server...");
|
|
294
|
-
const result = await pushVersion(apiKey, config.agent.agentId, selectedSkill.skillId, skillDeployData);
|
|
295
|
-
if (result.success && result.data) {
|
|
296
|
-
const pushedVersion = result.data.version;
|
|
297
|
-
writeSuccess(`ā
Version ${pushedVersion} of "${selectedSkill.name}" pushed successfully`);
|
|
298
|
-
// Update YAML with the version returned from server
|
|
299
|
-
if (pushedVersion !== selectedSkill.version) {
|
|
300
|
-
writeInfo(`š Updating YAML with server version: ${pushedVersion}`);
|
|
301
|
-
updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
|
|
302
|
-
selectedSkill.version = pushedVersion;
|
|
303
|
-
}
|
|
304
|
-
// Step 8: Deploy if requested
|
|
305
|
-
if (await shouldDeployAfterPush(options)) {
|
|
306
|
-
await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
else if (result.error) {
|
|
310
|
-
console.log(`ā ${result.error.message}`);
|
|
311
|
-
process.exit(1);
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
console.log("ā Failed to push version. Please try again.");
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
371
|
/**
|
|
319
372
|
* Push persona version to the server.
|
|
320
373
|
*
|
|
@@ -329,16 +382,14 @@ async function pushSkillVersion(options = {}) {
|
|
|
329
382
|
*/
|
|
330
383
|
async function pushPersonaVersion(options = {}) {
|
|
331
384
|
// Step 1: Validate configuration
|
|
332
|
-
const config =
|
|
385
|
+
const config = readYamlConfig();
|
|
333
386
|
if (!config || !config.agent?.agentId) {
|
|
334
|
-
|
|
335
|
-
process.exit(1);
|
|
387
|
+
throw new Error("No agent configuration found. Please run 'lua init' first.");
|
|
336
388
|
}
|
|
337
389
|
// Step 2: Load current persona from code
|
|
338
|
-
const currentPersona =
|
|
390
|
+
const currentPersona = getAgentPersona();
|
|
339
391
|
if (!currentPersona || !currentPersona.trim()) {
|
|
340
|
-
|
|
341
|
-
process.exit(1);
|
|
392
|
+
throw new Error("No persona found in configuration. Please edit your persona first using 'lua persona'.");
|
|
342
393
|
}
|
|
343
394
|
writeInfo(`š¦ Pushing persona for agent: ${config.agent.agentId}`);
|
|
344
395
|
// Show preview of persona
|
|
@@ -369,67 +420,54 @@ async function pushPersonaVersion(options = {}) {
|
|
|
369
420
|
// Step 5: Push persona version to server
|
|
370
421
|
writeProgress("š Creating persona version...");
|
|
371
422
|
try {
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
'Content-Type': 'application/json'
|
|
377
|
-
},
|
|
378
|
-
body: JSON.stringify({ persona: currentPersona })
|
|
379
|
-
});
|
|
380
|
-
if (!response.ok) {
|
|
381
|
-
const errorText = await response.text();
|
|
382
|
-
throw new Error(`HTTP error! status: ${response.status}, ${errorText}`);
|
|
423
|
+
const personaApi = new PersonaApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
424
|
+
const result = await personaApi.createVersion(currentPersona);
|
|
425
|
+
if (!result.success || !result.data) {
|
|
426
|
+
throw new Error(result.error?.message || 'Failed to create persona version');
|
|
383
427
|
}
|
|
384
|
-
const
|
|
385
|
-
const versionNum = data.version || data.data?.version || 'N/A';
|
|
428
|
+
const versionNum = result.data.version;
|
|
386
429
|
writeSuccess(`ā
Persona version ${versionNum} created successfully`);
|
|
387
430
|
// Step 6: Deploy if requested
|
|
388
431
|
if (await shouldDeployAfterPush(options)) {
|
|
389
|
-
await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum);
|
|
432
|
+
await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum, options.autoDeploy || false);
|
|
390
433
|
}
|
|
391
434
|
else {
|
|
392
435
|
writeInfo("š” You can deploy this version later using: lua deploy");
|
|
393
436
|
}
|
|
394
437
|
}
|
|
395
438
|
catch (error) {
|
|
396
|
-
|
|
397
|
-
process.exit(1);
|
|
439
|
+
throw error;
|
|
398
440
|
}
|
|
399
441
|
}
|
|
400
442
|
/**
|
|
401
443
|
* Deploy a persona version immediately after pushing
|
|
402
444
|
*/
|
|
403
|
-
async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
|
|
445
|
+
async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum, skipConfirmation = false) {
|
|
404
446
|
try {
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
447
|
+
// Skip confirmation when called from auto-deploy with --force
|
|
448
|
+
if (!skipConfirmation) {
|
|
449
|
+
// Show warning
|
|
450
|
+
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
451
|
+
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
452
|
+
const confirmAnswer = await safePrompt([
|
|
453
|
+
{
|
|
454
|
+
type: 'confirm',
|
|
455
|
+
name: 'confirm',
|
|
456
|
+
message: 'Are you absolutely sure you want to deploy this persona version?',
|
|
457
|
+
default: false
|
|
458
|
+
}
|
|
459
|
+
]);
|
|
460
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
461
|
+
console.log("\nā Deployment cancelled. Persona version created but not deployed.\n");
|
|
462
|
+
return;
|
|
414
463
|
}
|
|
415
|
-
]);
|
|
416
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
417
|
-
console.log("\nā Deployment cancelled. Persona version created but not deployed.\n");
|
|
418
|
-
return;
|
|
419
464
|
}
|
|
420
465
|
writeProgress("š Deploying persona version...");
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
},
|
|
427
|
-
body: JSON.stringify({})
|
|
428
|
-
});
|
|
429
|
-
if (!deployResponse.ok) {
|
|
430
|
-
const errorText = await deployResponse.text();
|
|
431
|
-
console.error(`\nā Deploy Error: ${deployResponse.status} - ${errorText}\n`);
|
|
432
|
-
throw new Error(`HTTP error! status: ${deployResponse.status}`);
|
|
466
|
+
const personaApi = new PersonaApi(BASE_URLS.API, apiKey, agentId);
|
|
467
|
+
const deployResult = await personaApi.deployVersion(versionNum);
|
|
468
|
+
if (!deployResult.success) {
|
|
469
|
+
console.error(`\nā Deploy Error: ${deployResult.error?.message || 'Unknown error'}\n`);
|
|
470
|
+
throw new Error(deployResult.error?.message || 'Failed to deploy persona version');
|
|
433
471
|
}
|
|
434
472
|
writeSuccess(`\nā
Persona version ${versionNum} deployed successfully to production\n`);
|
|
435
473
|
writeInfo("š” The new persona is now active for all users.");
|
|
@@ -440,689 +478,47 @@ async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
|
|
|
440
478
|
}
|
|
441
479
|
}
|
|
442
480
|
/**
|
|
443
|
-
* Push
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* 1. Run compilation
|
|
447
|
-
* 2. Validate config and deploy data
|
|
448
|
-
* 3. Select webhook to push
|
|
449
|
-
* 4. Confirm or update version
|
|
450
|
-
* 5. Push to server
|
|
451
|
-
* 6. Optionally deploy immediately
|
|
481
|
+
* Push MCP server (non-versioned, upsert pattern).
|
|
482
|
+
* Uses the same compileāauthāconfigāselect pattern as versioned primitives,
|
|
483
|
+
* with MCP-specific logic delegated to the handler.
|
|
452
484
|
*/
|
|
453
|
-
async function
|
|
485
|
+
async function pushMCPServer(options = {}) {
|
|
454
486
|
try {
|
|
455
|
-
// Step 1: Compile
|
|
456
487
|
writeProgress("š¦ Compiling project...");
|
|
457
488
|
await compileCommand();
|
|
458
489
|
writeSuccess("ā
Compilation complete");
|
|
459
|
-
// Step 2: Authenticate
|
|
460
490
|
const apiKey = await authenticateOrFail();
|
|
461
491
|
writeSuccess("ā
Authentication verified");
|
|
462
|
-
|
|
463
|
-
const config = readSkillConfig();
|
|
464
|
-
if (!config?.agent?.agentId) {
|
|
465
|
-
console.log("ā No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
|
|
466
|
-
process.exit(1);
|
|
467
|
-
}
|
|
468
|
-
const webhooks = config.webhooks || [];
|
|
469
|
-
if (webhooks.length === 0) {
|
|
470
|
-
console.log("ā No webhooks found in lua.skill.yaml.");
|
|
471
|
-
console.log("š” Make sure you have created a webhook using LuaWebhook in your code.");
|
|
472
|
-
process.exit(1);
|
|
473
|
-
}
|
|
474
|
-
// Step 4: Select webhook
|
|
475
|
-
const selectedWebhook = await selectEntityOrFail(webhooks, options, {
|
|
476
|
-
entityType: 'webhook',
|
|
477
|
-
nameFields: ['id', 'webhookId', 'name']
|
|
478
|
-
});
|
|
479
|
-
// Step 5: Load and validate bundled data
|
|
480
|
-
const bundledWebhookData = loadBundledEntityData('webhooks.json', selectedWebhook.name, 'Webhook');
|
|
481
|
-
// Step 6: Handle version
|
|
482
|
-
const confirmedVersion = await resolveVersionOrFail(selectedWebhook.version, options);
|
|
483
|
-
if (confirmedVersion !== selectedWebhook.version) {
|
|
484
|
-
writeInfo(`š Updating version from ${selectedWebhook.version} to ${confirmedVersion}`);
|
|
485
|
-
updateWebhookVersionInYaml(selectedWebhook.name, confirmedVersion);
|
|
486
|
-
}
|
|
487
|
-
// Step 7: Prepare and push webhook data
|
|
488
|
-
const webhookData = {
|
|
489
|
-
name: selectedWebhook.name,
|
|
490
|
-
version: confirmedVersion,
|
|
491
|
-
description: bundledWebhookData.description || selectedWebhook.description || `Webhook: ${selectedWebhook.name}`,
|
|
492
|
-
webhookId: selectedWebhook.webhookId,
|
|
493
|
-
querySchema: bundledWebhookData.querySchema,
|
|
494
|
-
headerSchema: bundledWebhookData.headerSchema,
|
|
495
|
-
bodySchema: bundledWebhookData.bodySchema,
|
|
496
|
-
code: bundledWebhookData.code,
|
|
497
|
-
executeFunction: bundledWebhookData.executeFunction
|
|
498
|
-
};
|
|
499
|
-
writeProgress(`\nš Pushing ${selectedWebhook.name} v${confirmedVersion} to server...`);
|
|
500
|
-
const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${config.agent.agentId}/${selectedWebhook.webhookId}/version`, {
|
|
501
|
-
method: 'POST',
|
|
502
|
-
headers: {
|
|
503
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
504
|
-
'Content-Type': 'application/json'
|
|
505
|
-
},
|
|
506
|
-
body: JSON.stringify(webhookData)
|
|
507
|
-
});
|
|
508
|
-
if (!response.ok) {
|
|
509
|
-
const errorText = await response.text();
|
|
510
|
-
console.log(`\nā Push Error: ${response.status} - ${errorText}\n`);
|
|
511
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
512
|
-
}
|
|
513
|
-
await response.json();
|
|
514
|
-
writeSuccess(`\nā
Successfully pushed ${selectedWebhook.name} v${confirmedVersion}\n`);
|
|
515
|
-
writeInfo(`š¦ Webhook URL (id): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.webhookId}`);
|
|
516
|
-
writeInfo(`š Webhook URL (name): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.name}`);
|
|
517
|
-
// Step 8: Deploy if requested
|
|
518
|
-
if (await shouldDeployAfterPush(options)) {
|
|
519
|
-
await deployWebhookVersionAfterPush(apiKey, config.agent.agentId, selectedWebhook, confirmedVersion);
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
writeInfo("š” You can deploy this version later using: lua webhooks production");
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
catch (error) {
|
|
526
|
-
console.log('ā Error pushing webhook version:', error);
|
|
527
|
-
process.exit(1);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Deploy a webhook version immediately after pushing
|
|
532
|
-
*/
|
|
533
|
-
async function deployWebhookVersionAfterPush(apiKey, agentId, selectedWebhook, pushedVersion) {
|
|
534
|
-
try {
|
|
535
|
-
// Show warning
|
|
536
|
-
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
537
|
-
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
538
|
-
const confirmAnswer = await safePrompt([
|
|
539
|
-
{
|
|
540
|
-
type: 'confirm',
|
|
541
|
-
name: 'confirm',
|
|
542
|
-
message: 'Are you absolutely sure you want to deploy?',
|
|
543
|
-
default: false
|
|
544
|
-
}
|
|
545
|
-
]);
|
|
546
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
547
|
-
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
writeProgress("š Publishing webhook version...");
|
|
551
|
-
const publishResponse = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${selectedWebhook.webhookId}/${pushedVersion}/publish`, {
|
|
552
|
-
method: 'POST',
|
|
553
|
-
headers: {
|
|
554
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
555
|
-
'Content-Type': 'application/json'
|
|
556
|
-
},
|
|
557
|
-
body: JSON.stringify({})
|
|
558
|
-
});
|
|
559
|
-
if (!publishResponse.ok) {
|
|
560
|
-
const errorText = await publishResponse.text();
|
|
561
|
-
console.error(`\nā Deploy Error: ${publishResponse.status} - ${errorText}\n`);
|
|
562
|
-
throw new Error(`HTTP error! status: ${publishResponse.status}`);
|
|
563
|
-
}
|
|
564
|
-
writeSuccess(`\nā
Webhook ${selectedWebhook.name} v${pushedVersion} deployed successfully to production\n`);
|
|
565
|
-
writeInfo("š” The new webhook version is now active for all users.");
|
|
566
|
-
}
|
|
567
|
-
catch (error) {
|
|
568
|
-
console.error('\nā Error deploying webhook version:', error);
|
|
569
|
-
console.log('š” You can deploy later using: lua webhooks production\n');
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Updates webhook version in lua.skill.yaml
|
|
574
|
-
*/
|
|
575
|
-
function updateWebhookVersionInYaml(webhookName, newVersion) {
|
|
576
|
-
try {
|
|
577
|
-
const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
|
|
578
|
-
const yamlContent = fs.readFileSync(yamlPath, 'utf8');
|
|
579
|
-
const config = yaml.load(yamlContent);
|
|
580
|
-
if (config.webhooks) {
|
|
581
|
-
const webhook = config.webhooks.find((w) => w.name === webhookName);
|
|
582
|
-
if (webhook) {
|
|
583
|
-
webhook.version = newVersion;
|
|
584
|
-
fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
catch (error) {
|
|
589
|
-
console.warn('ā ļø Could not update webhook version in YAML:', error);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Updates job version in lua.skill.yaml
|
|
594
|
-
*/
|
|
595
|
-
function updateJobVersionInYaml(jobName, newVersion) {
|
|
596
|
-
try {
|
|
597
|
-
const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
|
|
598
|
-
const yamlContent = fs.readFileSync(yamlPath, 'utf8');
|
|
599
|
-
const config = yaml.load(yamlContent);
|
|
600
|
-
if (config.jobs) {
|
|
601
|
-
const job = config.jobs.find((j) => j.name === jobName);
|
|
602
|
-
if (job) {
|
|
603
|
-
job.version = newVersion;
|
|
604
|
-
fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
catch (error) {
|
|
609
|
-
console.warn('ā ļø Could not update job version in YAML:', error);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
/**
|
|
613
|
-
* Push job version to the server (simplified version)
|
|
614
|
-
*/
|
|
615
|
-
async function pushJobVersion(options = {}) {
|
|
616
|
-
try {
|
|
617
|
-
// Step 1: Compile
|
|
618
|
-
writeProgress("š¦ Compiling project...");
|
|
619
|
-
await compileCommand();
|
|
620
|
-
writeSuccess("ā
Compilation complete");
|
|
621
|
-
// Step 2: Authenticate
|
|
622
|
-
const apiKey = await authenticateOrFail();
|
|
623
|
-
// Step 3: Read configuration
|
|
624
|
-
const config = readSkillConfig();
|
|
625
|
-
if (!config?.agent?.agentId) {
|
|
626
|
-
console.log("ā No agent ID found in lua.skill.yaml.");
|
|
627
|
-
process.exit(1);
|
|
628
|
-
}
|
|
629
|
-
const jobs = config.jobs || [];
|
|
630
|
-
if (jobs.length === 0) {
|
|
631
|
-
console.log("ā No jobs found in lua.skill.yaml.");
|
|
632
|
-
console.log("š” Make sure you have created a job using LuaJob in your code.");
|
|
633
|
-
process.exit(1);
|
|
634
|
-
}
|
|
635
|
-
// Step 4: Select job
|
|
636
|
-
const selectedJob = await selectEntityOrFail(jobs, options, {
|
|
637
|
-
entityType: 'job',
|
|
638
|
-
nameFields: ['id', 'jobId', 'name']
|
|
639
|
-
});
|
|
640
|
-
// Step 5: Load bundled data
|
|
641
|
-
const bundledJobData = loadBundledEntityData('jobs.json', selectedJob.name, 'Job');
|
|
642
|
-
// Step 6: Handle version
|
|
643
|
-
const confirmedVersion = await resolveVersionOrFail(selectedJob.version, options);
|
|
644
|
-
if (confirmedVersion !== selectedJob.version) {
|
|
645
|
-
writeInfo(`š Updating version from ${selectedJob.version} to ${confirmedVersion}`);
|
|
646
|
-
updateJobVersionInYaml(selectedJob.name, confirmedVersion);
|
|
647
|
-
}
|
|
648
|
-
// Step 7: Prepare and push
|
|
649
|
-
const jobData = {
|
|
650
|
-
name: selectedJob.name,
|
|
651
|
-
version: confirmedVersion,
|
|
652
|
-
description: bundledJobData.description || selectedJob.description || `Job: ${selectedJob.name}`,
|
|
653
|
-
jobId: selectedJob.jobId,
|
|
654
|
-
schedule: bundledJobData.schedule || selectedJob.schedule,
|
|
655
|
-
timeout: bundledJobData.timeout,
|
|
656
|
-
retry: bundledJobData.retry,
|
|
657
|
-
code: bundledJobData.code,
|
|
658
|
-
executeFunction: bundledJobData.executeFunction,
|
|
659
|
-
metadata: bundledJobData.metadata || selectedJob.metadata
|
|
660
|
-
};
|
|
661
|
-
writeProgress(`\nš Pushing ${selectedJob.name} v${confirmedVersion} to server...`);
|
|
662
|
-
const response = await fetch(`${BASE_URLS.API}/developer/jobs/${config.agent.agentId}/${selectedJob.jobId}/version`, {
|
|
663
|
-
method: 'POST',
|
|
664
|
-
headers: {
|
|
665
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
666
|
-
'Content-Type': 'application/json'
|
|
667
|
-
},
|
|
668
|
-
body: JSON.stringify(jobData)
|
|
669
|
-
});
|
|
670
|
-
if (!response.ok) {
|
|
671
|
-
const errorText = await response.text();
|
|
672
|
-
console.log(`\nā Push Error: ${response.status} - ${errorText}\n`);
|
|
673
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
674
|
-
}
|
|
675
|
-
writeSuccess(`\nā
Successfully pushed ${selectedJob.name} v${confirmedVersion}\n`);
|
|
676
|
-
// Step 8: Deploy if requested
|
|
677
|
-
if (await shouldDeployAfterPush(options)) {
|
|
678
|
-
await deployJobVersionAfterPush(apiKey, config.agent.agentId, selectedJob, confirmedVersion);
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
writeInfo("š” You can deploy this version later using: lua jobs production");
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
catch (error) {
|
|
685
|
-
console.log('ā Error pushing job version:', error);
|
|
686
|
-
process.exit(1);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Deploy a job version immediately after pushing
|
|
691
|
-
*/
|
|
692
|
-
async function deployJobVersionAfterPush(apiKey, agentId, selectedJob, pushedVersion) {
|
|
693
|
-
try {
|
|
694
|
-
// Show warning
|
|
695
|
-
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
696
|
-
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
697
|
-
const confirmAnswer = await safePrompt([
|
|
698
|
-
{
|
|
699
|
-
type: 'confirm',
|
|
700
|
-
name: 'confirm',
|
|
701
|
-
message: 'Are you absolutely sure you want to deploy?',
|
|
702
|
-
default: false
|
|
703
|
-
}
|
|
704
|
-
]);
|
|
705
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
706
|
-
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
writeProgress("š Publishing job version...");
|
|
710
|
-
const publishResponse = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${selectedJob.jobId}/${pushedVersion}/publish`, {
|
|
711
|
-
method: 'POST',
|
|
712
|
-
headers: {
|
|
713
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
714
|
-
'Content-Type': 'application/json'
|
|
715
|
-
},
|
|
716
|
-
body: JSON.stringify({})
|
|
717
|
-
});
|
|
718
|
-
if (!publishResponse.ok) {
|
|
719
|
-
const errorText = await publishResponse.text();
|
|
720
|
-
console.error(`\nā Deploy Error: ${publishResponse.status} - ${errorText}\n`);
|
|
721
|
-
throw new Error(`HTTP error! status: ${publishResponse.status}`);
|
|
722
|
-
}
|
|
723
|
-
writeSuccess(`\nā
Job ${selectedJob.name} v${pushedVersion} deployed successfully to production\n`);
|
|
724
|
-
writeInfo("š” The new job version is now active and will run on schedule.");
|
|
725
|
-
}
|
|
726
|
-
catch (error) {
|
|
727
|
-
console.error('\nā Error deploying job version:', error);
|
|
728
|
-
console.log('š” You can deploy later using: lua jobs production\n');
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Push preprocessor version to the server.
|
|
733
|
-
*/
|
|
734
|
-
async function pushPreProcessorVersion(options = {}) {
|
|
735
|
-
try {
|
|
736
|
-
// Step 1: Compile
|
|
737
|
-
writeProgress("š¦ Compiling project...");
|
|
738
|
-
await compileCommand();
|
|
739
|
-
writeSuccess("ā
Compilation complete");
|
|
740
|
-
// Step 2: Authenticate
|
|
741
|
-
const apiKey = await authenticateOrFail();
|
|
742
|
-
// Step 3: Read configuration
|
|
743
|
-
const config = readSkillConfig();
|
|
744
|
-
if (!config?.agent?.agentId) {
|
|
745
|
-
console.log("ā No agent ID found in lua.skill.yaml.");
|
|
746
|
-
process.exit(1);
|
|
747
|
-
}
|
|
748
|
-
const preprocessors = config.preprocessors || [];
|
|
749
|
-
if (preprocessors.length === 0) {
|
|
750
|
-
console.log("ā No preprocessors found in lua.skill.yaml.");
|
|
751
|
-
process.exit(1);
|
|
752
|
-
}
|
|
753
|
-
// Step 4: Select preprocessor
|
|
754
|
-
const selected = await selectEntityOrFail(preprocessors, options, {
|
|
755
|
-
entityType: 'preprocessor',
|
|
756
|
-
nameFields: ['id', 'preprocessorId', 'name']
|
|
757
|
-
});
|
|
758
|
-
// Step 5: Load bundled data
|
|
759
|
-
const bundledData = loadBundledEntityData('preprocessors.json', selected.name, 'PreProcessor');
|
|
760
|
-
if (!bundledData.code) {
|
|
761
|
-
console.log(`ā PreProcessor "${selected.name}" has no code in compiled output.`);
|
|
762
|
-
process.exit(1);
|
|
763
|
-
}
|
|
764
|
-
// Step 6: Handle version
|
|
765
|
-
const confirmedVersion = await resolveVersionOrFail(selected.version, options);
|
|
766
|
-
if (confirmedVersion !== selected.version) {
|
|
767
|
-
writeInfo(`š Updating version from ${selected.version} to ${confirmedVersion}`);
|
|
768
|
-
updateProcessorVersionInYaml('preprocessors', selected.name, confirmedVersion);
|
|
769
|
-
}
|
|
770
|
-
// Step 7: Prepare and push
|
|
771
|
-
const versionData = {
|
|
772
|
-
name: selected.name,
|
|
773
|
-
version: confirmedVersion,
|
|
774
|
-
description: bundledData.description || selected.description,
|
|
775
|
-
preprocessorId: selected.preprocessorId,
|
|
776
|
-
code: bundledData.code,
|
|
777
|
-
executeFunction: bundledData.executeFunction,
|
|
778
|
-
async: Boolean(bundledData.async ?? false)
|
|
779
|
-
};
|
|
780
|
-
writeProgress(`\nš Pushing ${selected.name} v${confirmedVersion}...`);
|
|
781
|
-
const api = new PreProcessorApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
782
|
-
const result = await api.pushPreProcessor(selected.preprocessorId, versionData);
|
|
783
|
-
if (result.success) {
|
|
784
|
-
writeSuccess(`\nā
PreProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
|
|
785
|
-
// Step 8: Deploy if requested
|
|
786
|
-
if (await shouldDeployAfterPush(options)) {
|
|
787
|
-
await deployPreProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
|
|
788
|
-
}
|
|
789
|
-
else {
|
|
790
|
-
writeInfo("š” You can deploy this version later using: lua preprocessors production");
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
else {
|
|
794
|
-
console.log(`ā Failed to push: ${result.error?.message}`);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
catch (error) {
|
|
798
|
-
console.log('ā Error pushing preprocessor:', error);
|
|
799
|
-
process.exit(1);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Deploy a preprocessor version immediately after pushing
|
|
804
|
-
*/
|
|
805
|
-
async function deployPreProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
|
|
806
|
-
try {
|
|
807
|
-
// Show warning
|
|
808
|
-
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
809
|
-
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
810
|
-
const confirmAnswer = await safePrompt([
|
|
811
|
-
{
|
|
812
|
-
type: 'confirm',
|
|
813
|
-
name: 'confirm',
|
|
814
|
-
message: 'Are you absolutely sure you want to deploy?',
|
|
815
|
-
default: false
|
|
816
|
-
}
|
|
817
|
-
]);
|
|
818
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
819
|
-
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
writeProgress("š Publishing preprocessor version...");
|
|
823
|
-
const api = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
824
|
-
const publishResponse = await api.publishPreProcessorVersion(selected.preprocessorId, pushedVersion);
|
|
825
|
-
if (!publishResponse.success) {
|
|
826
|
-
console.error(`\nā Deploy Error: ${publishResponse.error?.message || 'Unknown error'}\n`);
|
|
827
|
-
throw new Error(publishResponse.error?.message || 'Failed to publish preprocessor version');
|
|
828
|
-
}
|
|
829
|
-
writeSuccess(`\nā
PreProcessor ${selected.name} v${pushedVersion} deployed successfully to production\n`);
|
|
830
|
-
writeInfo("š” The new preprocessor version is now active for all users.");
|
|
831
|
-
}
|
|
832
|
-
catch (error) {
|
|
833
|
-
console.error('\nā Error deploying preprocessor version:', error);
|
|
834
|
-
console.log('š” You can deploy later using: lua preprocessors production\n');
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Push postprocessor version to the server.
|
|
839
|
-
*/
|
|
840
|
-
async function pushPostProcessorVersion(options = {}) {
|
|
841
|
-
try {
|
|
842
|
-
// Step 1: Compile
|
|
843
|
-
writeProgress("š¦ Compiling project...");
|
|
844
|
-
await compileCommand();
|
|
845
|
-
writeSuccess("ā
Compilation complete");
|
|
846
|
-
// Step 2: Authenticate
|
|
847
|
-
const apiKey = await authenticateOrFail();
|
|
848
|
-
// Step 3: Read configuration
|
|
849
|
-
const config = readSkillConfig();
|
|
492
|
+
const config = readYamlConfig();
|
|
850
493
|
if (!config?.agent?.agentId) {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
494
|
+
throw new Error("No agent ID found. Run 'lua init' first.");
|
|
495
|
+
}
|
|
496
|
+
const agentId = config.agent.agentId;
|
|
497
|
+
const { mcpServerHandler } = await import('../primitives/mcp-server.handler.js');
|
|
498
|
+
const bundledServers = mcpServerHandler.loadBundledServers();
|
|
499
|
+
if (bundledServers.length === 0) {
|
|
500
|
+
throw new Error("No MCP servers found in compiled output.");
|
|
501
|
+
}
|
|
502
|
+
const selectedServer = await selectEntityOrFail(bundledServers, options, {
|
|
503
|
+
entityType: 'MCP server',
|
|
504
|
+
nameFields: ['name'],
|
|
505
|
+
formatChoice: (s) => `${s.name} (${s.transport})`,
|
|
863
506
|
});
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
if (!
|
|
867
|
-
|
|
868
|
-
process.exit(1);
|
|
869
|
-
}
|
|
870
|
-
// Step 6: Handle version
|
|
871
|
-
const confirmedVersion = await resolveVersionOrFail(selected.version, options);
|
|
872
|
-
if (confirmedVersion !== selected.version) {
|
|
873
|
-
writeInfo(`š Updating version from ${selected.version} to ${confirmedVersion}`);
|
|
874
|
-
updateProcessorVersionInYaml('postprocessors', selected.name, confirmedVersion);
|
|
875
|
-
}
|
|
876
|
-
// Step 7: Prepare and push
|
|
877
|
-
const versionData = {
|
|
878
|
-
name: selected.name,
|
|
879
|
-
version: confirmedVersion,
|
|
880
|
-
description: bundledData.description || selected.description,
|
|
881
|
-
postprocessorId: selected.postprocessorId,
|
|
882
|
-
code: bundledData.code,
|
|
883
|
-
executeFunction: bundledData.executeFunction
|
|
884
|
-
};
|
|
885
|
-
writeProgress(`\nš Pushing ${selected.name} v${confirmedVersion}...`);
|
|
886
|
-
const api = new PostProcessorApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
887
|
-
const result = await api.pushPostProcessor(selected.postprocessorId, versionData);
|
|
888
|
-
if (result.success) {
|
|
889
|
-
writeSuccess(`\nā
PostProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
|
|
890
|
-
// Step 8: Deploy if requested
|
|
891
|
-
if (await shouldDeployAfterPush(options)) {
|
|
892
|
-
await deployPostProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
|
|
893
|
-
}
|
|
894
|
-
else {
|
|
895
|
-
writeInfo("š” You can deploy this version later using: lua postprocessors production");
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
else {
|
|
899
|
-
console.log(`ā Failed to push: ${result.error?.message}`);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
catch (error) {
|
|
903
|
-
console.log('ā Error pushing postprocessor:', error);
|
|
904
|
-
process.exit(1);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Deploy a postprocessor version immediately after pushing
|
|
909
|
-
*/
|
|
910
|
-
async function deployPostProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
|
|
911
|
-
try {
|
|
912
|
-
// Show warning
|
|
913
|
-
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
914
|
-
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
915
|
-
const confirmAnswer = await safePrompt([
|
|
916
|
-
{
|
|
917
|
-
type: 'confirm',
|
|
918
|
-
name: 'confirm',
|
|
919
|
-
message: 'Are you absolutely sure you want to deploy?',
|
|
920
|
-
default: false
|
|
921
|
-
}
|
|
922
|
-
]);
|
|
923
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
924
|
-
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
|
-
writeProgress("š Publishing postprocessor version...");
|
|
928
|
-
const api = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
929
|
-
const publishResponse = await api.publishPostProcessorVersion(selected.postprocessorId, pushedVersion);
|
|
930
|
-
if (!publishResponse.success) {
|
|
931
|
-
console.error(`\nā Deploy Error: ${publishResponse.error?.message || 'Unknown error'}\n`);
|
|
932
|
-
throw new Error(publishResponse.error?.message || 'Failed to publish postprocessor version');
|
|
933
|
-
}
|
|
934
|
-
writeSuccess(`\nā
PostProcessor ${selected.name} v${pushedVersion} deployed successfully to production\n`);
|
|
935
|
-
writeInfo("š” The new postprocessor version is now active for all users.");
|
|
936
|
-
}
|
|
937
|
-
catch (error) {
|
|
938
|
-
console.error('\nā Error deploying postprocessor version:', error);
|
|
939
|
-
console.log('š” You can deploy later using: lua postprocessors production\n');
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Updates processor version in lua.skill.yaml
|
|
944
|
-
*/
|
|
945
|
-
function updateProcessorVersionInYaml(processorType, processorName, newVersion) {
|
|
946
|
-
try {
|
|
947
|
-
const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
|
|
948
|
-
const yamlContent = fs.readFileSync(yamlPath, 'utf8');
|
|
949
|
-
const config = yaml.load(yamlContent);
|
|
950
|
-
if (config[processorType]) {
|
|
951
|
-
const processor = config[processorType].find((p) => p.name === processorName);
|
|
952
|
-
if (processor) {
|
|
953
|
-
processor.version = newVersion;
|
|
954
|
-
fs.writeFileSync(yamlPath, yaml.dump(config, { indent: 2, lineWidth: 120, noRefs: true }));
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
catch (error) {
|
|
959
|
-
console.warn('ā ļø Could not update processor version in YAML:', error);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Push MCP Server to the server
|
|
964
|
-
*/
|
|
965
|
-
async function pushMCPServerVersion(options = {}) {
|
|
966
|
-
try {
|
|
967
|
-
// Step 1: Compile
|
|
968
|
-
writeProgress("š¦ Compiling project...");
|
|
969
|
-
await compileCommand();
|
|
970
|
-
writeSuccess("ā
Compilation complete");
|
|
971
|
-
// Step 2: Authenticate
|
|
972
|
-
const apiKey = await authenticateOrFail();
|
|
973
|
-
writeSuccess("ā
Authentication verified");
|
|
974
|
-
// Step 3: Read configuration
|
|
975
|
-
const config = readSkillConfig();
|
|
976
|
-
if (!config?.agent?.agentId) {
|
|
977
|
-
console.log("ā No agent ID found in lua.skill.yaml. Please run 'lua init' first.");
|
|
978
|
-
process.exit(1);
|
|
979
|
-
}
|
|
980
|
-
const mcpServers = config.mcpServers || [];
|
|
981
|
-
if (mcpServers.length === 0) {
|
|
982
|
-
console.log("ā No MCP servers found in lua.skill.yaml.");
|
|
983
|
-
console.log("š” Make sure you have defined MCP servers in your LuaAgent configuration.");
|
|
984
|
-
process.exit(1);
|
|
985
|
-
}
|
|
986
|
-
// Step 4: Load bundled MCP server data
|
|
987
|
-
const bundledServersPath = path.join(process.cwd(), 'dist', 'mcp-servers.json');
|
|
988
|
-
if (!fs.existsSync(bundledServersPath)) {
|
|
989
|
-
console.log('ā Bundled MCP server data not found.');
|
|
990
|
-
console.log("š” Please ensure your MCP servers are properly compiled.");
|
|
991
|
-
process.exit(1);
|
|
992
|
-
}
|
|
993
|
-
const bundledServers = JSON.parse(fs.readFileSync(bundledServersPath, 'utf8'));
|
|
994
|
-
// Step 5: Select MCP server (special handling - uses bundled data with YAML IDs)
|
|
995
|
-
let selectedServer;
|
|
996
|
-
let bundledServerData;
|
|
997
|
-
if (options.entityName) {
|
|
998
|
-
bundledServerData = bundledServers.find((s) => s.id === options.entityName || s.mcpServerId === options.entityName || s.name === options.entityName);
|
|
999
|
-
if (!bundledServerData) {
|
|
1000
|
-
console.log(`ā MCP server "${options.entityName}" not found`);
|
|
1001
|
-
process.exit(1);
|
|
1002
|
-
}
|
|
1003
|
-
const yamlEntry = mcpServers.find((s) => s.name === bundledServerData.name);
|
|
1004
|
-
selectedServer = { ...bundledServerData, mcpServerId: yamlEntry?.mcpServerId };
|
|
1005
|
-
writeInfo(`š¦ Selected MCP server: ${selectedServer.name}`);
|
|
1006
|
-
}
|
|
1007
|
-
else if (bundledServers.length === 1) {
|
|
1008
|
-
bundledServerData = bundledServers[0];
|
|
1009
|
-
const yamlEntry = mcpServers.find((s) => s.name === bundledServerData.name);
|
|
1010
|
-
selectedServer = { ...bundledServerData, mcpServerId: yamlEntry?.mcpServerId };
|
|
1011
|
-
writeInfo(`š¦ Pushing MCP server: ${selectedServer.name}`);
|
|
1012
|
-
}
|
|
1013
|
-
else {
|
|
1014
|
-
const serverAnswer = await safePrompt([
|
|
1015
|
-
{
|
|
1016
|
-
type: 'list',
|
|
1017
|
-
name: 'selectedServer',
|
|
1018
|
-
message: 'Select an MCP server to push:',
|
|
1019
|
-
choices: bundledServers.map((server) => {
|
|
1020
|
-
const yamlEntry = mcpServers.find((s) => s.name === server.name);
|
|
1021
|
-
return {
|
|
1022
|
-
name: `${server.name} (${server.transport})`,
|
|
1023
|
-
value: { ...server, mcpServerId: yamlEntry?.mcpServerId }
|
|
1024
|
-
};
|
|
1025
|
-
})
|
|
1026
|
-
}
|
|
1027
|
-
]);
|
|
1028
|
-
if (!serverAnswer) {
|
|
1029
|
-
console.log("Push cancelled.");
|
|
1030
|
-
return;
|
|
1031
|
-
}
|
|
1032
|
-
selectedServer = serverAnswer.selectedServer;
|
|
1033
|
-
bundledServerData = selectedServer;
|
|
1034
|
-
}
|
|
1035
|
-
// Step 6: Prepare server data for push
|
|
1036
|
-
// Include resolver fields for function-based env/headers/url resolution
|
|
1037
|
-
const serverData = {
|
|
1038
|
-
name: bundledServerData.name,
|
|
1039
|
-
transport: bundledServerData.transport,
|
|
1040
|
-
timeout: bundledServerData.timeout,
|
|
1041
|
-
...(bundledServerData.transport === 'stdio' ? {
|
|
1042
|
-
command: bundledServerData.command,
|
|
1043
|
-
args: bundledServerData.args,
|
|
1044
|
-
env: bundledServerData.env,
|
|
1045
|
-
envResolver: bundledServerData.envResolver, // Compressed function for runtime resolution
|
|
1046
|
-
} : {
|
|
1047
|
-
url: bundledServerData.url,
|
|
1048
|
-
urlResolver: bundledServerData.urlResolver, // Compressed function for runtime resolution
|
|
1049
|
-
headers: bundledServerData.headers,
|
|
1050
|
-
headersResolver: bundledServerData.headersResolver, // Compressed function for runtime resolution
|
|
1051
|
-
})
|
|
1052
|
-
};
|
|
1053
|
-
writeProgress(`\nš Pushing MCP server "${selectedServer.name}" to server...`);
|
|
1054
|
-
const developerApi = new DeveloperApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
1055
|
-
const result = await developerApi.upsertMCPServer(serverData);
|
|
1056
|
-
if (result.success && result.data) {
|
|
1057
|
-
writeSuccess(`\nā
MCP server "${selectedServer.name}" pushed successfully\n`);
|
|
1058
|
-
// Step 7: Activate if requested (MCP uses activate instead of deploy)
|
|
1059
|
-
if (await shouldDeployAfterPush(options)) {
|
|
1060
|
-
writeProgress("š Activating MCP server...");
|
|
1061
|
-
const activateResult = await developerApi.activateMCPServer(result.data.id);
|
|
1062
|
-
if (activateResult.success) {
|
|
1063
|
-
writeSuccess(`\nā
MCP server "${selectedServer.name}" activated successfully\n`);
|
|
1064
|
-
writeInfo("š” The server's tools are now available to your agent.");
|
|
1065
|
-
}
|
|
1066
|
-
else {
|
|
1067
|
-
console.log(`ā Failed to activate: ${activateResult.error?.message}`);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
else {
|
|
1071
|
-
writeInfo("š” You can activate this server later using: lua mcp activate");
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
else {
|
|
1075
|
-
console.log(`ā Failed to push: ${result.error?.message}`);
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
catch (error) {
|
|
1079
|
-
console.log('ā Error pushing MCP server:', error);
|
|
1080
|
-
process.exit(1);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Deploy a version immediately after pushing
|
|
1085
|
-
*/
|
|
1086
|
-
async function deployVersionAfterPush(apiKey, agentId, selectedSkill, pushedVersion) {
|
|
1087
|
-
try {
|
|
1088
|
-
writeProgress("\nš Fetching available versions...");
|
|
1089
|
-
// Fetch versions to verify the pushed version exists
|
|
1090
|
-
const versionsResponse = await fetchVersions(apiKey, agentId, selectedSkill.skillId);
|
|
1091
|
-
if (!versionsResponse.versions || versionsResponse.versions.length === 0) {
|
|
1092
|
-
console.error("ā No versions available. The push may have failed.");
|
|
1093
|
-
return;
|
|
1094
|
-
}
|
|
1095
|
-
// Show warning
|
|
1096
|
-
console.log("\nā ļø WARNING: You are about to deploy to PRODUCTION!");
|
|
1097
|
-
console.log("ā ļø This will affect ALL users immediately.\n");
|
|
1098
|
-
const confirmAnswer = await safePrompt([
|
|
1099
|
-
{
|
|
1100
|
-
type: 'confirm',
|
|
1101
|
-
name: 'confirm',
|
|
1102
|
-
message: 'Are you absolutely sure you want to deploy?',
|
|
1103
|
-
default: false
|
|
1104
|
-
}
|
|
1105
|
-
]);
|
|
1106
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
1107
|
-
console.log("\nā Deployment cancelled. Version pushed but not deployed.\n");
|
|
1108
|
-
return;
|
|
507
|
+
writeProgress(`\nš Pushing MCP server "${selectedServer.name}"...`);
|
|
508
|
+
const result = await mcpServerHandler.upsertOnServer(apiKey, agentId, selectedServer);
|
|
509
|
+
if (!result.success) {
|
|
510
|
+
throw new Error(`Failed: ${result.error}`);
|
|
1109
511
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
512
|
+
writeSuccess(`\nā
MCP server "${selectedServer.name}" pushed successfully\n`);
|
|
513
|
+
if (result.id && await shouldDeployAfterPush(options)) {
|
|
514
|
+
writeProgress("š Activating MCP server...");
|
|
515
|
+
const activateResult = await mcpServerHandler.activate(apiKey, agentId, result.id);
|
|
516
|
+
if (activateResult.success)
|
|
517
|
+
writeSuccess(`ā
MCP server activated\n`);
|
|
1115
518
|
}
|
|
1116
|
-
writeProgress("š Publishing version...");
|
|
1117
|
-
const publishResponse = await publishVersion(apiKey, agentId, selectedSkill.skillId, pushedVersion);
|
|
1118
|
-
writeSuccess(`\nā
Version ${pushedVersion} of "${selectedSkill.name}" deployed successfully to production\n`);
|
|
1119
|
-
// Update YAML with deployed version (should already be updated from push, but ensure consistency)
|
|
1120
|
-
writeInfo(`š Ensuring YAML is updated with deployed version: ${pushedVersion}`);
|
|
1121
|
-
updateSkillVersionInYaml(selectedSkill.name, pushedVersion);
|
|
1122
519
|
}
|
|
1123
520
|
catch (error) {
|
|
1124
|
-
|
|
1125
|
-
console.log('š” You can deploy later using: lua deploy\n');
|
|
521
|
+
throw error;
|
|
1126
522
|
}
|
|
1127
523
|
}
|
|
1128
524
|
/**
|
|
@@ -1146,525 +542,171 @@ async function pushAllCommand(options) {
|
|
|
1146
542
|
writeProgress("š¦ Compiling project...");
|
|
1147
543
|
await compileCommand();
|
|
1148
544
|
// Step 2: Load configuration and API key
|
|
1149
|
-
const config =
|
|
545
|
+
const config = readYamlConfig();
|
|
1150
546
|
if (!config?.agent?.agentId) {
|
|
1151
|
-
|
|
1152
|
-
process.exit(1);
|
|
547
|
+
throw new Error('No agent ID found in lua.skill.yaml. Run "lua init" first.');
|
|
1153
548
|
}
|
|
1154
|
-
const apiKey = await
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
// Step 3: Read deploy.json for component data
|
|
1161
|
-
const deployJsonPath = path.join(process.cwd(), '.lua', 'deploy.json');
|
|
1162
|
-
if (!fs.existsSync(deployJsonPath)) {
|
|
1163
|
-
console.error('ā No deploy.json found. Compilation may have failed.');
|
|
1164
|
-
process.exit(1);
|
|
549
|
+
const apiKey = await requireAuthOrExit(false);
|
|
550
|
+
const agentId = config.agent.agentId;
|
|
551
|
+
// Step 3: Load manifest
|
|
552
|
+
let manifest;
|
|
553
|
+
try {
|
|
554
|
+
manifest = loadManifest();
|
|
1165
555
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
const
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
:
|
|
1175
|
-
const bundledJobs = fs.existsSync(jobsJsonPath)
|
|
1176
|
-
? JSON.parse(fs.readFileSync(jobsJsonPath, 'utf8'))
|
|
1177
|
-
: [];
|
|
1178
|
-
const bundledPreprocessors = fs.existsSync(preprocessorsJsonPath)
|
|
1179
|
-
? JSON.parse(fs.readFileSync(preprocessorsJsonPath, 'utf8'))
|
|
1180
|
-
: [];
|
|
1181
|
-
const bundledPostprocessors = fs.existsSync(postprocessorsJsonPath)
|
|
1182
|
-
? JSON.parse(fs.readFileSync(postprocessorsJsonPath, 'utf8'))
|
|
1183
|
-
: [];
|
|
1184
|
-
// Track results for both push and deploy
|
|
1185
|
-
const results = {
|
|
1186
|
-
skills: [],
|
|
1187
|
-
webhooks: [],
|
|
1188
|
-
jobs: [],
|
|
1189
|
-
preprocessors: [],
|
|
1190
|
-
postprocessors: []
|
|
556
|
+
catch (error) {
|
|
557
|
+
throw new Error(`Compilation output not found. Compilation may have failed. ${error.message}`);
|
|
558
|
+
}
|
|
559
|
+
// Track results and deploy queue per handler
|
|
560
|
+
const allResults = [];
|
|
561
|
+
const toDeploy = [];
|
|
562
|
+
// Icons per kind for display
|
|
563
|
+
const kindIcons = {
|
|
564
|
+
skill: 'š¦', webhook: 'šŖ', job: 'ā°', preprocessor: 'š„', postprocessor: 'š¤',
|
|
1191
565
|
};
|
|
1192
|
-
//
|
|
1193
|
-
const
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
for (const skillConfig of config.skills) {
|
|
1202
|
-
try {
|
|
1203
|
-
const skillData = deployData.skills.find((s) => s.name === skillConfig.name);
|
|
1204
|
-
if (!skillData) {
|
|
1205
|
-
console.warn(`ā ļø Skill "${skillConfig.name}" not found in deploy.json, skipping`);
|
|
1206
|
-
continue;
|
|
1207
|
-
}
|
|
1208
|
-
// Validate skillId and version exist
|
|
1209
|
-
const skillId = skillConfig.skillId;
|
|
1210
|
-
const currentVersion = skillConfig.version;
|
|
1211
|
-
if (!skillId) {
|
|
1212
|
-
console.warn(`ā ļø Skill "${skillConfig.name}" has no skillId, skipping`);
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
if (!currentVersion) {
|
|
1216
|
-
console.warn(`ā ļø Skill "${skillConfig.name}" has no version, skipping`);
|
|
1217
|
-
continue;
|
|
1218
|
-
}
|
|
1219
|
-
// Auto-bump patch version
|
|
1220
|
-
const newVersion = bumpPatchVersion(currentVersion);
|
|
1221
|
-
writeInfo(` š ${skillConfig.name}: ${currentVersion} ā ${newVersion}`);
|
|
1222
|
-
// Push version - use the full skillData with tools
|
|
1223
|
-
const pushResult = await pushVersion(apiKey, agentId, skillId, {
|
|
1224
|
-
...skillData, // Include all fields from deploy.json (tools, name, etc.)
|
|
1225
|
-
version: newVersion, // Override with new version
|
|
1226
|
-
});
|
|
1227
|
-
if (!pushResult.success) {
|
|
1228
|
-
console.error(` ā Failed to push ${skillConfig.name}:`, pushResult.error?.message);
|
|
1229
|
-
continue;
|
|
1230
|
-
}
|
|
1231
|
-
// Update YAML with new version
|
|
1232
|
-
updateSkillVersionInYaml(skillConfig.name, newVersion);
|
|
1233
|
-
results.skills.push({ name: skillConfig.name, version: newVersion, skillId });
|
|
1234
|
-
writeSuccess(` ā
${skillConfig.name} v${newVersion} pushed`);
|
|
1235
|
-
// Queue for deployment if requested
|
|
1236
|
-
if (options.autoDeploy) {
|
|
1237
|
-
toDeploySkills.push({ skillId, version: newVersion, name: skillConfig.name });
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
catch (error) {
|
|
1241
|
-
console.error(` ā Failed to push ${skillConfig.name}:`, error.message);
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
// Step 5: Push all webhooks
|
|
1246
|
-
if (config.webhooks && config.webhooks.length > 0) {
|
|
1247
|
-
writeProgress(`\nšŖ Pushing ${config.webhooks.length} webhook(s)...`);
|
|
1248
|
-
for (const webhookConfig of config.webhooks) {
|
|
1249
|
-
try {
|
|
1250
|
-
const webhookData = bundledWebhooks.find((w) => w.name === webhookConfig.name);
|
|
1251
|
-
if (!webhookData) {
|
|
1252
|
-
console.warn(`ā ļø Webhook "${webhookConfig.name}" not found in compiled data, skipping`);
|
|
1253
|
-
continue;
|
|
1254
|
-
}
|
|
1255
|
-
// Validate webhookId and version exist
|
|
1256
|
-
if (!webhookConfig.webhookId) {
|
|
1257
|
-
console.warn(`ā ļø Webhook "${webhookConfig.name}" has no webhookId, skipping`);
|
|
1258
|
-
continue;
|
|
1259
|
-
}
|
|
1260
|
-
if (!webhookConfig.version) {
|
|
1261
|
-
console.warn(`ā ļø Webhook "${webhookConfig.name}" has no version, skipping`);
|
|
1262
|
-
continue;
|
|
1263
|
-
}
|
|
1264
|
-
// Auto-bump patch version
|
|
1265
|
-
const newVersion = bumpPatchVersion(webhookConfig.version);
|
|
1266
|
-
writeInfo(` š ${webhookConfig.name}: ${webhookConfig.version} ā ${newVersion}`);
|
|
1267
|
-
// Prepare webhook data for push
|
|
1268
|
-
const pushData = {
|
|
1269
|
-
name: webhookConfig.name,
|
|
1270
|
-
version: newVersion,
|
|
1271
|
-
description: webhookData.description || '',
|
|
1272
|
-
webhookId: webhookConfig.webhookId,
|
|
1273
|
-
querySchema: webhookData.querySchema,
|
|
1274
|
-
headerSchema: webhookData.headerSchema,
|
|
1275
|
-
bodySchema: webhookData.bodySchema,
|
|
1276
|
-
code: webhookData.code,
|
|
1277
|
-
executeFunction: webhookData.executeFunction
|
|
1278
|
-
};
|
|
1279
|
-
// Push version using fetch (like existing webhook push)
|
|
1280
|
-
const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${webhookConfig.webhookId}/version`, {
|
|
1281
|
-
method: 'POST',
|
|
1282
|
-
headers: {
|
|
1283
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1284
|
-
'Content-Type': 'application/json'
|
|
1285
|
-
},
|
|
1286
|
-
body: JSON.stringify(pushData)
|
|
1287
|
-
});
|
|
1288
|
-
if (!response.ok) {
|
|
1289
|
-
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
1290
|
-
}
|
|
1291
|
-
// Update YAML
|
|
1292
|
-
updateWebhookVersionInYaml(webhookConfig.name, newVersion);
|
|
1293
|
-
results.webhooks.push({ name: webhookConfig.name, version: newVersion });
|
|
1294
|
-
writeSuccess(` ā
${webhookConfig.name} v${newVersion} pushed`);
|
|
1295
|
-
// Queue for deployment if requested
|
|
1296
|
-
if (options.autoDeploy) {
|
|
1297
|
-
toDeployWebhooks.push({ webhookId: webhookConfig.webhookId, version: newVersion, name: webhookConfig.name });
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
catch (error) {
|
|
1301
|
-
console.error(` ā Failed to push ${webhookConfig.name}:`, error.message);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
// Step 6: Push all jobs
|
|
1306
|
-
if (config.jobs && config.jobs.length > 0) {
|
|
1307
|
-
writeProgress(`\nā° Pushing ${config.jobs.length} job(s)...`);
|
|
1308
|
-
for (const jobConfig of config.jobs) {
|
|
1309
|
-
try {
|
|
1310
|
-
const jobData = bundledJobs.find((j) => j.name === jobConfig.name);
|
|
1311
|
-
if (!jobData) {
|
|
1312
|
-
console.warn(`ā ļø Job "${jobConfig.name}" not found in compiled data, skipping`);
|
|
1313
|
-
continue;
|
|
1314
|
-
}
|
|
1315
|
-
// Validate jobId and version exist
|
|
1316
|
-
if (!jobConfig.jobId) {
|
|
1317
|
-
console.warn(`ā ļø Job "${jobConfig.name}" has no jobId, skipping`);
|
|
1318
|
-
continue;
|
|
1319
|
-
}
|
|
1320
|
-
if (!jobConfig.version) {
|
|
1321
|
-
console.warn(`ā ļø Job "${jobConfig.name}" has no version, skipping`);
|
|
1322
|
-
continue;
|
|
1323
|
-
}
|
|
1324
|
-
// Auto-bump patch version
|
|
1325
|
-
const newVersion = bumpPatchVersion(jobConfig.version);
|
|
1326
|
-
writeInfo(` š ${jobConfig.name}: ${jobConfig.version} ā ${newVersion}`);
|
|
1327
|
-
// Prepare job data for push
|
|
1328
|
-
const pushData = {
|
|
1329
|
-
name: jobConfig.name,
|
|
1330
|
-
version: newVersion,
|
|
1331
|
-
description: jobData.description || '',
|
|
1332
|
-
jobId: jobConfig.jobId,
|
|
1333
|
-
schedule: jobData.schedule || jobConfig.schedule,
|
|
1334
|
-
timeout: jobData.timeout,
|
|
1335
|
-
retry: jobData.retry,
|
|
1336
|
-
code: jobData.code,
|
|
1337
|
-
executeFunction: jobData.executeFunction,
|
|
1338
|
-
metadata: jobData.metadata
|
|
1339
|
-
};
|
|
1340
|
-
// Push version using fetch
|
|
1341
|
-
const response = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${jobConfig.jobId}/version`, {
|
|
1342
|
-
method: 'POST',
|
|
1343
|
-
headers: {
|
|
1344
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1345
|
-
'Content-Type': 'application/json'
|
|
1346
|
-
},
|
|
1347
|
-
body: JSON.stringify(pushData)
|
|
1348
|
-
});
|
|
1349
|
-
if (!response.ok) {
|
|
1350
|
-
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
1351
|
-
}
|
|
1352
|
-
// Update YAML
|
|
1353
|
-
updateJobVersionInYaml(jobConfig.name, newVersion);
|
|
1354
|
-
results.jobs.push({ name: jobConfig.name, version: newVersion });
|
|
1355
|
-
writeSuccess(` ā
${jobConfig.name} v${newVersion} pushed`);
|
|
1356
|
-
// Queue for deployment if requested
|
|
1357
|
-
if (options.autoDeploy) {
|
|
1358
|
-
toDeployJobs.push({ jobId: jobConfig.jobId, version: newVersion, name: jobConfig.name });
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
catch (error) {
|
|
1362
|
-
console.error(` ā Failed to push ${jobConfig.name}:`, error.message);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
// Step 7: Push all preprocessors
|
|
1367
|
-
if (config.preprocessors && config.preprocessors.length > 0) {
|
|
1368
|
-
writeProgress(`\nš„ Pushing ${config.preprocessors.length} preprocessor(s)...`);
|
|
1369
|
-
const preprocessorService = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1370
|
-
for (const processorConfig of config.preprocessors) {
|
|
566
|
+
// Step 4: Push all versioned primitives using handlers
|
|
567
|
+
const handlers = [skillH, webhookH, jobH, preprocessorH, postprocessorH];
|
|
568
|
+
for (const handler of handlers) {
|
|
569
|
+
const items = handler.getFromYaml(config);
|
|
570
|
+
if (items.length === 0)
|
|
571
|
+
continue;
|
|
572
|
+
const icon = kindIcons[handler.kind] || 'š¦';
|
|
573
|
+
writeProgress(`\n${icon} Pushing ${items.length} ${handler.displayName}(s)...`);
|
|
574
|
+
for (const item of items) {
|
|
1371
575
|
try {
|
|
1372
|
-
const
|
|
1373
|
-
if (!
|
|
1374
|
-
console.warn(`ā ļø
|
|
576
|
+
const pushData = handler.prepareForPush(manifest, item.name);
|
|
577
|
+
if (!pushData) {
|
|
578
|
+
console.warn(`ā ļø ${handler.displayName} "${item.name}" not found in compiled output, skipping`);
|
|
1375
579
|
continue;
|
|
1376
580
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
if (!preprocessorId) {
|
|
1381
|
-
console.warn(`ā ļø Preprocessor "${processorConfig.name}" has no preprocessorId, skipping`);
|
|
581
|
+
const entityId = item[handler.yamlConfig.idField];
|
|
582
|
+
if (!entityId) {
|
|
583
|
+
console.warn(`ā ļø ${handler.displayName} "${item.name}" has no server ID, skipping. Run 'lua compile' first.`);
|
|
1382
584
|
continue;
|
|
1383
585
|
}
|
|
1384
|
-
if (!
|
|
1385
|
-
console.warn(`ā ļø
|
|
586
|
+
if (!item.version) {
|
|
587
|
+
console.warn(`ā ļø ${handler.displayName} "${item.name}" has no version, skipping`);
|
|
1386
588
|
continue;
|
|
1387
589
|
}
|
|
1388
|
-
// Auto-bump
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
description: processorData.description || '',
|
|
1396
|
-
preprocessorId: preprocessorId,
|
|
1397
|
-
code: processorData.code,
|
|
1398
|
-
executeFunction: processorData.executeFunction,
|
|
1399
|
-
async: Boolean(processorData.async ?? false)
|
|
1400
|
-
};
|
|
1401
|
-
// Push version
|
|
1402
|
-
const result = await preprocessorService.pushPreProcessor(preprocessorId, versionData);
|
|
590
|
+
// Auto-bump version (check server for highest to avoid conflicts)
|
|
591
|
+
const serverHighest = await handler.getHighestServerVersion(apiKey, agentId, entityId);
|
|
592
|
+
const baseVersion = serverHighest ? maxSemver(item.version, serverHighest) : item.version;
|
|
593
|
+
const newVersion = incrementPatchVersion(baseVersion);
|
|
594
|
+
writeInfo(` š ${item.name}: ${item.version} ā ${newVersion}`);
|
|
595
|
+
// Push
|
|
596
|
+
const result = await handler.pushToServer(apiKey, agentId, entityId, { ...pushData, version: newVersion });
|
|
1403
597
|
if (!result.success) {
|
|
1404
|
-
|
|
1405
|
-
}
|
|
1406
|
-
// Update YAML
|
|
1407
|
-
updateProcessorVersionInYaml('preprocessors', processorConfig.name, newVersion);
|
|
1408
|
-
results.preprocessors.push({ name: processorConfig.name, version: newVersion });
|
|
1409
|
-
writeSuccess(` ā
${processorConfig.name} v${newVersion} pushed`);
|
|
1410
|
-
// Queue for deployment if requested
|
|
1411
|
-
if (options.autoDeploy) {
|
|
1412
|
-
toDeployPreprocessors.push({ preprocessorId, version: newVersion, name: processorConfig.name });
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
catch (error) {
|
|
1416
|
-
console.error(` ā Failed to push ${processorConfig.name}:`, error.message);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
// Step 8: Push all postprocessors
|
|
1421
|
-
if (config.postprocessors && config.postprocessors.length > 0) {
|
|
1422
|
-
writeProgress(`\nš¤ Pushing ${config.postprocessors.length} postprocessor(s)...`);
|
|
1423
|
-
const postprocessorService = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1424
|
-
for (const processorConfig of config.postprocessors) {
|
|
1425
|
-
try {
|
|
1426
|
-
const processorData = bundledPostprocessors.find((p) => p.name === processorConfig.name);
|
|
1427
|
-
if (!processorData) {
|
|
1428
|
-
console.warn(`ā ļø Postprocessor "${processorConfig.name}" not found in compiled data, skipping`);
|
|
1429
|
-
continue;
|
|
1430
|
-
}
|
|
1431
|
-
// Validate postprocessorId and version exist
|
|
1432
|
-
const postprocessorId = processorConfig.postprocessorId;
|
|
1433
|
-
const currentVersion = processorConfig.version;
|
|
1434
|
-
if (!postprocessorId) {
|
|
1435
|
-
console.warn(`ā ļø Postprocessor "${processorConfig.name}" has no postprocessorId, skipping`);
|
|
598
|
+
console.error(` ā Failed to push ${item.name}: ${result.error}`);
|
|
1436
599
|
continue;
|
|
1437
600
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
// Auto-bump patch version
|
|
1443
|
-
const newVersion = bumpPatchVersion(currentVersion);
|
|
1444
|
-
writeInfo(` š ${processorConfig.name}: ${currentVersion} ā ${newVersion}`);
|
|
1445
|
-
// Prepare version data
|
|
1446
|
-
const versionData = {
|
|
1447
|
-
name: processorConfig.name,
|
|
1448
|
-
version: newVersion,
|
|
1449
|
-
description: processorData.description || '',
|
|
1450
|
-
postprocessorId: postprocessorId,
|
|
1451
|
-
code: processorData.code,
|
|
1452
|
-
executeFunction: processorData.executeFunction
|
|
1453
|
-
};
|
|
1454
|
-
// Push version
|
|
1455
|
-
const result = await postprocessorService.pushPostProcessor(postprocessorId, versionData);
|
|
1456
|
-
if (!result.success) {
|
|
1457
|
-
throw new Error(result.error?.message || 'Failed to push postprocessor');
|
|
1458
|
-
}
|
|
1459
|
-
// Update YAML
|
|
1460
|
-
updateProcessorVersionInYaml('postprocessors', processorConfig.name, newVersion);
|
|
1461
|
-
results.postprocessors.push({ name: processorConfig.name, version: newVersion });
|
|
1462
|
-
writeSuccess(` ā
${processorConfig.name} v${newVersion} pushed`);
|
|
1463
|
-
// Queue for deployment if requested
|
|
601
|
+
handler.updateVersionInYaml(item.name, newVersion, { silent: true });
|
|
602
|
+
allResults.push({ handler, name: item.name, version: newVersion, entityId });
|
|
603
|
+
writeSuccess(` ā
${item.name} v${newVersion} pushed`);
|
|
1464
604
|
if (options.autoDeploy) {
|
|
1465
|
-
|
|
605
|
+
toDeploy.push({ handler, name: item.name, version: newVersion, entityId });
|
|
1466
606
|
}
|
|
1467
607
|
}
|
|
1468
608
|
catch (error) {
|
|
1469
|
-
console.error(` ā Failed to push ${
|
|
609
|
+
console.error(` ā Failed to push ${item.name}: ${error.message}`);
|
|
1470
610
|
}
|
|
1471
611
|
}
|
|
1472
612
|
}
|
|
1473
|
-
// Step
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
613
|
+
// Step 5: Push MCP server configurations (non-versioned, separate flow)
|
|
614
|
+
const { mcpServerHandler: mcpH } = await import('../primitives/mcp-server.handler.js');
|
|
615
|
+
const mcpServers = mcpH.loadBundledServers();
|
|
616
|
+
if (mcpServers.length > 0) {
|
|
617
|
+
writeProgress(`\nš Pushing ${mcpServers.length} MCP server(s)...`);
|
|
618
|
+
for (const serverConfig of mcpServers) {
|
|
1479
619
|
try {
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
const mcpServerId = result.data.id;
|
|
1488
|
-
const isActive = result.data.active;
|
|
1489
|
-
writeSuccess(` ā
${serverConfig.name} (${serverConfig.transport}) - ${isActive ? 'active' : 'inactive'}`);
|
|
1490
|
-
// Auto-activate if autoDeploy is enabled
|
|
1491
|
-
if (options.autoDeploy && !isActive) {
|
|
1492
|
-
const activateResult = await developerApi.activateMCPServer(mcpServerId);
|
|
1493
|
-
if (activateResult.success) {
|
|
1494
|
-
writeSuccess(` š Auto-activated`);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
else {
|
|
1499
|
-
console.error(` ā Failed to push ${serverConfig.name}:`, result.error?.message);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
catch (error) {
|
|
1503
|
-
console.error(` ā Failed to push ${serverConfig.name}:`, error.message);
|
|
620
|
+
const result = await mcpH.upsertOnServer(apiKey, agentId, serverConfig);
|
|
621
|
+
if (result.success && result.id) {
|
|
622
|
+
writeSuccess(` ā
${serverConfig.name} (${serverConfig.transport})`);
|
|
623
|
+
if (options.autoDeploy && !result.active) {
|
|
624
|
+
const activateResult = await mcpH.activate(apiKey, agentId, result.id);
|
|
625
|
+
if (activateResult.success)
|
|
626
|
+
writeSuccess(` š Auto-activated`);
|
|
1504
627
|
}
|
|
1505
628
|
}
|
|
629
|
+
else {
|
|
630
|
+
console.error(` ā Failed to push ${serverConfig.name}:`, result.error);
|
|
631
|
+
}
|
|
1506
632
|
}
|
|
1507
633
|
catch (error) {
|
|
1508
|
-
console.error(` ā Failed to push
|
|
634
|
+
console.error(` ā Failed to push ${serverConfig.name}:`, error.message);
|
|
1509
635
|
}
|
|
1510
636
|
}
|
|
1511
637
|
}
|
|
1512
|
-
// Step
|
|
1513
|
-
if (options.autoDeploy &&
|
|
638
|
+
// Step 6: Deploy all queued components
|
|
639
|
+
if (options.autoDeploy && toDeploy.length > 0) {
|
|
1514
640
|
writeProgress('\nš Deploying all pushed versions to production...');
|
|
1515
641
|
writeInfo('ā±ļø Waiting for server to process versions (5 seconds)...\n');
|
|
1516
|
-
// Wait for server to process all pushed versions
|
|
1517
642
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
}
|
|
1527
|
-
else {
|
|
1528
|
-
console.warn(` ā ļø ${skill.name} deployment failed`);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
// Deploy all webhooks
|
|
1533
|
-
if (toDeployWebhooks.length > 0) {
|
|
1534
|
-
writeProgress(`šŖ Deploying ${toDeployWebhooks.length} webhook(s)...`);
|
|
1535
|
-
for (const webhook of toDeployWebhooks) {
|
|
1536
|
-
const deployed = await retryDeploy(async () => {
|
|
1537
|
-
const response = await fetch(`${BASE_URLS.API}/developer/webhooks/${agentId}/${webhook.webhookId}/${webhook.version}/publish`, {
|
|
1538
|
-
method: 'PUT',
|
|
1539
|
-
headers: {
|
|
1540
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1541
|
-
'Content-Type': 'application/json'
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
-
if (!response.ok) {
|
|
1545
|
-
throw new Error(`HTTP ${response.status}`);
|
|
1546
|
-
}
|
|
1547
|
-
}, webhook.name, webhook.version, 2);
|
|
1548
|
-
if (deployed) {
|
|
1549
|
-
writeSuccess(` š ${webhook.name} v${webhook.version} deployed`);
|
|
1550
|
-
}
|
|
1551
|
-
else {
|
|
1552
|
-
console.warn(` ā ļø ${webhook.name} deployment failed`);
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
// Deploy all jobs
|
|
1557
|
-
if (toDeployJobs.length > 0) {
|
|
1558
|
-
writeProgress(`ā° Deploying ${toDeployJobs.length} job(s)...`);
|
|
1559
|
-
for (const job of toDeployJobs) {
|
|
1560
|
-
const deployed = await retryDeploy(async () => {
|
|
1561
|
-
const response = await fetch(`${BASE_URLS.API}/developer/jobs/${agentId}/${job.jobId}/${job.version}/publish`, {
|
|
1562
|
-
method: 'PUT',
|
|
1563
|
-
headers: {
|
|
1564
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1565
|
-
'Content-Type': 'application/json'
|
|
1566
|
-
}
|
|
1567
|
-
});
|
|
1568
|
-
if (!response.ok) {
|
|
1569
|
-
throw new Error(`HTTP ${response.status}`);
|
|
1570
|
-
}
|
|
1571
|
-
}, job.name, job.version, 2);
|
|
1572
|
-
if (deployed) {
|
|
1573
|
-
writeSuccess(` š ${job.name} v${job.version} deployed`);
|
|
1574
|
-
}
|
|
1575
|
-
else {
|
|
1576
|
-
console.warn(` ā ļø ${job.name} deployment failed`);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
// Deploy all preprocessors
|
|
1581
|
-
if (toDeployPreprocessors.length > 0) {
|
|
1582
|
-
writeProgress(`š„ Deploying ${toDeployPreprocessors.length} preprocessor(s)...`);
|
|
1583
|
-
const preprocessorService = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1584
|
-
for (const processor of toDeployPreprocessors) {
|
|
1585
|
-
const deployed = await retryDeploy(() => preprocessorService.publishPreProcessorVersion(processor.preprocessorId, processor.version), processor.name, processor.version, 2);
|
|
1586
|
-
if (deployed) {
|
|
1587
|
-
writeSuccess(` š ${processor.name} v${processor.version} deployed`);
|
|
1588
|
-
}
|
|
1589
|
-
else {
|
|
1590
|
-
console.warn(` ā ļø ${processor.name} deployment failed`);
|
|
1591
|
-
}
|
|
643
|
+
for (const item of toDeploy) {
|
|
644
|
+
const deployed = await retryDeploy(async () => {
|
|
645
|
+
const result = await item.handler.publishVersion(apiKey, agentId, item.entityId, item.version);
|
|
646
|
+
if (!result.success)
|
|
647
|
+
throw new Error(result.error || 'Deploy failed');
|
|
648
|
+
}, item.name, item.version, 3);
|
|
649
|
+
if (deployed) {
|
|
650
|
+
writeSuccess(` š ${item.name} v${item.version} deployed`);
|
|
1592
651
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
if (toDeployPostprocessors.length > 0) {
|
|
1596
|
-
writeProgress(`š¤ Deploying ${toDeployPostprocessors.length} postprocessor(s)...`);
|
|
1597
|
-
const postprocessorService = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1598
|
-
for (const processor of toDeployPostprocessors) {
|
|
1599
|
-
const deployed = await retryDeploy(() => postprocessorService.publishPostProcessorVersion(processor.postprocessorId, processor.version), processor.name, processor.version, 2);
|
|
1600
|
-
if (deployed) {
|
|
1601
|
-
writeSuccess(` š ${processor.name} v${processor.version} deployed`);
|
|
1602
|
-
}
|
|
1603
|
-
else {
|
|
1604
|
-
console.warn(` ā ļø ${processor.name} deployment failed`);
|
|
1605
|
-
}
|
|
652
|
+
else {
|
|
653
|
+
console.warn(` ā ļø ${item.name} deployment failed`);
|
|
1606
654
|
}
|
|
1607
655
|
}
|
|
1608
656
|
}
|
|
1609
|
-
// Step
|
|
657
|
+
// Step 7: Print summary
|
|
1610
658
|
writeSuccess('\nā
Push All Complete!\n');
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
console.log(
|
|
1625
|
-
|
|
1626
|
-
}
|
|
1627
|
-
if (results.postprocessors.length > 0) {
|
|
1628
|
-
console.log(`š¤ PostProcessors (${results.postprocessors.length}):`);
|
|
1629
|
-
results.postprocessors.forEach(p => console.log(` ⢠${p.name} v${p.version}`));
|
|
659
|
+
// Group results by kind for display
|
|
660
|
+
const byKind = new Map();
|
|
661
|
+
for (const r of allResults) {
|
|
662
|
+
const kind = r.handler.displayNamePlural;
|
|
663
|
+
if (!byKind.has(kind))
|
|
664
|
+
byKind.set(kind, []);
|
|
665
|
+
byKind.get(kind).push(r);
|
|
666
|
+
}
|
|
667
|
+
const summaryIcons = {
|
|
668
|
+
skills: 'š ļø ', webhooks: 'šŖ', jobs: 'ā°', preprocessors: 'š„', postprocessors: 'š¤',
|
|
669
|
+
};
|
|
670
|
+
for (const [kind, items] of byKind) {
|
|
671
|
+
const icon = summaryIcons[kind] || 'š¦';
|
|
672
|
+
console.log(`${icon} ${kind.charAt(0).toUpperCase() + kind.slice(1)} (${items.length}):`);
|
|
673
|
+
items.forEach(i => console.log(` ⢠${i.name} v${i.version}`));
|
|
1630
674
|
}
|
|
1631
675
|
if (options.autoDeploy) {
|
|
1632
676
|
writeSuccess('\nš All components deployed to production!');
|
|
1633
677
|
}
|
|
1634
678
|
console.log('');
|
|
1635
679
|
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Bumps the patch version of a semantic version string
|
|
1638
|
-
* e.g., "1.2.3" -> "1.2.4"
|
|
1639
|
-
*/
|
|
1640
|
-
function bumpPatchVersion(version) {
|
|
1641
|
-
const parts = version.split('.');
|
|
1642
|
-
if (parts.length !== 3) {
|
|
1643
|
-
// If not a valid semver, just return incremented version
|
|
1644
|
-
return version + '.1';
|
|
1645
|
-
}
|
|
1646
|
-
const [major, minor, patch] = parts;
|
|
1647
|
-
const newPatch = parseInt(patch, 10) + 1;
|
|
1648
|
-
return `${major}.${minor}.${newPatch}`;
|
|
1649
|
-
}
|
|
1650
680
|
/**
|
|
1651
681
|
* Retry deployment with exponential backoff
|
|
1652
682
|
* The server needs time to process pushed versions before they can be deployed
|
|
1653
683
|
*/
|
|
1654
|
-
async function retryDeploy(deployFn,
|
|
684
|
+
async function retryDeploy(deployFn, _componentName, _version, maxRetries = 3) {
|
|
1655
685
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
1656
686
|
try {
|
|
1657
|
-
|
|
1658
|
-
|
|
687
|
+
// Only delay on retry attempts (not first attempt)
|
|
688
|
+
if (attempt > 1) {
|
|
689
|
+
const delay = attempt * 2000; // 2s on 2nd attempt, 4s on 3rd, etc.
|
|
690
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
691
|
+
}
|
|
1659
692
|
await deployFn();
|
|
693
|
+
// Show success message if succeeded after retrying
|
|
694
|
+
if (attempt > 1) {
|
|
695
|
+
writeInfo(` ā Succeeded on retry ${attempt}/${maxRetries}`);
|
|
696
|
+
}
|
|
1660
697
|
return true;
|
|
1661
698
|
}
|
|
1662
699
|
catch (error) {
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
700
|
+
// Extract detailed error message from API response
|
|
701
|
+
const errorMessage = error?.error?.message || error?.message || 'Unknown error';
|
|
702
|
+
if (attempt < maxRetries) {
|
|
703
|
+
// Intermediate retry - show brief info
|
|
704
|
+
writeInfo(` [Attempt ${attempt}/${maxRetries}] ${errorMessage} - retrying...`);
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
// Final attempt failed - show error
|
|
708
|
+
console.error(` ā [Attempt ${attempt}/${maxRetries}] Deploy failed: ${errorMessage}`);
|
|
1666
709
|
}
|
|
1667
|
-
// Continue to next retry silently
|
|
1668
710
|
}
|
|
1669
711
|
}
|
|
1670
712
|
return false;
|