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