lua-cli 3.5.0-alpha.1 → 3.5.0-alpha.3
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 +1 -0
- package/dist/api/agent.api.service.d.ts +13 -0
- package/dist/api/agent.api.service.js +17 -0
- package/dist/api/agent.api.service.js.map +1 -1
- package/dist/api/chat.api.service.d.ts +2 -1
- package/dist/api/chat.api.service.js +7 -2
- package/dist/api/chat.api.service.js.map +1 -1
- package/dist/api/logs.api.service.d.ts +2 -1
- package/dist/api/logs.api.service.js +2 -0
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/unifiedto.api.service.d.ts +87 -0
- package/dist/api/unifiedto.api.service.js +107 -0
- package/dist/api/unifiedto.api.service.js.map +1 -0
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/webhook.api.service.js.map +1 -1
- package/dist/cli/command-definitions.js +112 -16
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/chat.js +51 -23
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/compile.d.ts +1 -2
- package/dist/commands/compile.js +2 -3
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/configure.d.ts +17 -1
- package/dist/commands/configure.js +29 -4
- package/dist/commands/configure.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/integrations.d.ts +17 -0
- package/dist/commands/integrations.js +2392 -0
- package/dist/commands/integrations.js.map +1 -0
- package/dist/commands/logs.js +33 -12
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.js +3 -2
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.d.ts +19 -0
- package/dist/commands/mcp.js +3 -3
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/push.js +204 -215
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/sync.d.ts +5 -9
- package/dist/commands/sync.js +146 -102
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test.js +41 -13
- package/dist/commands/test.js.map +1 -1
- package/dist/interfaces/mcp.d.ts +11 -0
- package/dist/interfaces/unifiedto.d.ts +95 -0
- package/dist/interfaces/unifiedto.js +6 -0
- package/dist/interfaces/unifiedto.js.map +1 -0
- package/dist/utils/auth-flows.d.ts +29 -1
- package/dist/utils/auth-flows.js +84 -1
- package/dist/utils/auth-flows.js.map +1 -1
- package/dist/utils/sandbox.d.ts +2 -2
- package/dist/utils/sandbox.js +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
package/dist/commands/push.js
CHANGED
|
@@ -17,6 +17,9 @@ import { BASE_URLS } from '../config/constants.js';
|
|
|
17
17
|
import PreProcessorApi from '../api/preprocessor.api.service.js';
|
|
18
18
|
import PostProcessorApi from '../api/postprocessor.api.service.js';
|
|
19
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
|
+
import PersonaApi from '../api/persona.api.service.js';
|
|
20
23
|
import { loadPersonaFromCode } from '../utils/agent-code-utils.js';
|
|
21
24
|
// ============================================================================
|
|
22
25
|
// Core Push Helpers (shared by all push functions)
|
|
@@ -85,6 +88,7 @@ async function selectEntityOrFail(items, options, config) {
|
|
|
85
88
|
* Validates semantic versioning format
|
|
86
89
|
*/
|
|
87
90
|
async function resolveVersionOrFail(currentVersion, options) {
|
|
91
|
+
// If version explicitly provided, use it
|
|
88
92
|
if (options.version) {
|
|
89
93
|
if (!/^\d+\.\d+\.\d+/.test(options.version)) {
|
|
90
94
|
console.log(`❌ Invalid version format: "${options.version}". Use semantic versioning (e.g., 1.0.5)`);
|
|
@@ -93,6 +97,13 @@ async function resolveVersionOrFail(currentVersion, options) {
|
|
|
93
97
|
writeInfo(`📝 Using version: ${options.version}`);
|
|
94
98
|
return options.version;
|
|
95
99
|
}
|
|
100
|
+
// If force flag provided, auto-bump without prompting
|
|
101
|
+
if (options.force) {
|
|
102
|
+
const newVersion = bumpPatchVersion(currentVersion);
|
|
103
|
+
writeInfo(`📝 Auto-bumping version: ${currentVersion} → ${newVersion}`);
|
|
104
|
+
return newVersion;
|
|
105
|
+
}
|
|
106
|
+
// Otherwise, prompt interactively
|
|
96
107
|
return await promptVersionConfirmOrUpdate(currentVersion);
|
|
97
108
|
}
|
|
98
109
|
/**
|
|
@@ -303,7 +314,7 @@ async function pushSkillVersion(options = {}) {
|
|
|
303
314
|
}
|
|
304
315
|
// Step 8: Deploy if requested
|
|
305
316
|
if (await shouldDeployAfterPush(options)) {
|
|
306
|
-
await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion);
|
|
317
|
+
await deployVersionAfterPush(apiKey, config.agent.agentId, selectedSkill, pushedVersion, options.autoDeploy || false);
|
|
307
318
|
}
|
|
308
319
|
}
|
|
309
320
|
else if (result.error) {
|
|
@@ -369,24 +380,16 @@ async function pushPersonaVersion(options = {}) {
|
|
|
369
380
|
// Step 5: Push persona version to server
|
|
370
381
|
writeProgress("🔄 Creating persona version...");
|
|
371
382
|
try {
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
'Content-Type': 'application/json'
|
|
377
|
-
},
|
|
378
|
-
body: JSON.stringify({ persona: currentPersona })
|
|
379
|
-
});
|
|
380
|
-
if (!response.ok) {
|
|
381
|
-
const errorText = await response.text();
|
|
382
|
-
throw new Error(`HTTP error! status: ${response.status}, ${errorText}`);
|
|
383
|
+
const personaApi = new PersonaApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
384
|
+
const result = await personaApi.createVersion(currentPersona);
|
|
385
|
+
if (!result.success || !result.data) {
|
|
386
|
+
throw new Error(result.error?.message || 'Failed to create persona version');
|
|
383
387
|
}
|
|
384
|
-
const
|
|
385
|
-
const versionNum = data.version || data.data?.version || 'N/A';
|
|
388
|
+
const versionNum = result.data.version;
|
|
386
389
|
writeSuccess(`✅ Persona version ${versionNum} created successfully`);
|
|
387
390
|
// Step 6: Deploy if requested
|
|
388
391
|
if (await shouldDeployAfterPush(options)) {
|
|
389
|
-
await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum);
|
|
392
|
+
await deployPersonaVersionAfterPush(apiKey, config.agent.agentId, versionNum, options.autoDeploy || false);
|
|
390
393
|
}
|
|
391
394
|
else {
|
|
392
395
|
writeInfo("💡 You can deploy this version later using: lua deploy");
|
|
@@ -400,36 +403,32 @@ async function pushPersonaVersion(options = {}) {
|
|
|
400
403
|
/**
|
|
401
404
|
* Deploy a persona version immediately after pushing
|
|
402
405
|
*/
|
|
403
|
-
async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum) {
|
|
406
|
+
async function deployPersonaVersionAfterPush(apiKey, agentId, versionNum, skipConfirmation = false) {
|
|
404
407
|
try {
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
408
|
+
// Skip confirmation when called from auto-deploy with --force
|
|
409
|
+
if (!skipConfirmation) {
|
|
410
|
+
// Show warning
|
|
411
|
+
console.log("\n⚠️ WARNING: You are about to deploy to PRODUCTION!");
|
|
412
|
+
console.log("⚠️ This will affect ALL users immediately.\n");
|
|
413
|
+
const confirmAnswer = await safePrompt([
|
|
414
|
+
{
|
|
415
|
+
type: 'confirm',
|
|
416
|
+
name: 'confirm',
|
|
417
|
+
message: 'Are you absolutely sure you want to deploy this persona version?',
|
|
418
|
+
default: false
|
|
419
|
+
}
|
|
420
|
+
]);
|
|
421
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
422
|
+
console.log("\n❌ Deployment cancelled. Persona version created but not deployed.\n");
|
|
423
|
+
return;
|
|
414
424
|
}
|
|
415
|
-
]);
|
|
416
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
417
|
-
console.log("\n❌ Deployment cancelled. Persona version created but not deployed.\n");
|
|
418
|
-
return;
|
|
419
425
|
}
|
|
420
426
|
writeProgress("🔄 Deploying persona version...");
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
},
|
|
427
|
-
body: JSON.stringify({})
|
|
428
|
-
});
|
|
429
|
-
if (!deployResponse.ok) {
|
|
430
|
-
const errorText = await deployResponse.text();
|
|
431
|
-
console.error(`\n❌ Deploy Error: ${deployResponse.status} - ${errorText}\n`);
|
|
432
|
-
throw new Error(`HTTP error! status: ${deployResponse.status}`);
|
|
427
|
+
const personaApi = new PersonaApi(BASE_URLS.API, apiKey, agentId);
|
|
428
|
+
const deployResult = await personaApi.deployVersion(versionNum);
|
|
429
|
+
if (!deployResult.success) {
|
|
430
|
+
console.error(`\n❌ Deploy Error: ${deployResult.error?.message || 'Unknown error'}\n`);
|
|
431
|
+
throw new Error(deployResult.error?.message || 'Failed to deploy persona version');
|
|
433
432
|
}
|
|
434
433
|
writeSuccess(`\n✅ Persona version ${versionNum} deployed successfully to production\n`);
|
|
435
434
|
writeInfo("💡 The new persona is now active for all users.");
|
|
@@ -497,26 +496,18 @@ async function pushWebhookVersion(options = {}) {
|
|
|
497
496
|
executeFunction: bundledWebhookData.executeFunction
|
|
498
497
|
};
|
|
499
498
|
writeProgress(`\n🚀 Pushing ${selectedWebhook.name} v${confirmedVersion} to server...`);
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
},
|
|
506
|
-
body: JSON.stringify(webhookData)
|
|
507
|
-
});
|
|
508
|
-
if (!response.ok) {
|
|
509
|
-
const errorText = await response.text();
|
|
510
|
-
console.log(`\n❌ Push Error: ${response.status} - ${errorText}\n`);
|
|
511
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
499
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, apiKey, config.agent.agentId);
|
|
500
|
+
const result = await webhookApi.pushWebhook(selectedWebhook.webhookId, webhookData);
|
|
501
|
+
if (!result.success) {
|
|
502
|
+
console.log(`\n❌ Push Error: ${result.error?.message || 'Unknown error'}\n`);
|
|
503
|
+
throw new Error(result.error?.message || 'Failed to push webhook');
|
|
512
504
|
}
|
|
513
|
-
await response.json();
|
|
514
505
|
writeSuccess(`\n✅ Successfully pushed ${selectedWebhook.name} v${confirmedVersion}\n`);
|
|
515
506
|
writeInfo(`📦 Webhook URL (id): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.webhookId}`);
|
|
516
507
|
writeInfo(`🔗 Webhook URL (name): ${BASE_URLS.WEBHOOK}/${config.agent.agentId}/${selectedWebhook.name}`);
|
|
517
508
|
// Step 8: Deploy if requested
|
|
518
509
|
if (await shouldDeployAfterPush(options)) {
|
|
519
|
-
await deployWebhookVersionAfterPush(apiKey, config.agent.agentId, selectedWebhook, confirmedVersion);
|
|
510
|
+
await deployWebhookVersionAfterPush(apiKey, config.agent.agentId, selectedWebhook, confirmedVersion, options.autoDeploy || false);
|
|
520
511
|
}
|
|
521
512
|
else {
|
|
522
513
|
writeInfo("💡 You can deploy this version later using: lua webhooks production");
|
|
@@ -530,36 +521,32 @@ async function pushWebhookVersion(options = {}) {
|
|
|
530
521
|
/**
|
|
531
522
|
* Deploy a webhook version immediately after pushing
|
|
532
523
|
*/
|
|
533
|
-
async function deployWebhookVersionAfterPush(apiKey, agentId, selectedWebhook, pushedVersion) {
|
|
524
|
+
async function deployWebhookVersionAfterPush(apiKey, agentId, selectedWebhook, pushedVersion, skipConfirmation = false) {
|
|
534
525
|
try {
|
|
535
|
-
//
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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;
|
|
544
542
|
}
|
|
545
|
-
]);
|
|
546
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
547
|
-
console.log("\n❌ Deployment cancelled. Version pushed but not deployed.\n");
|
|
548
|
-
return;
|
|
549
543
|
}
|
|
550
544
|
writeProgress("🔄 Publishing webhook version...");
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
},
|
|
557
|
-
body: JSON.stringify({})
|
|
558
|
-
});
|
|
559
|
-
if (!publishResponse.ok) {
|
|
560
|
-
const errorText = await publishResponse.text();
|
|
561
|
-
console.error(`\n❌ Deploy Error: ${publishResponse.status} - ${errorText}\n`);
|
|
562
|
-
throw new Error(`HTTP error! status: ${publishResponse.status}`);
|
|
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');
|
|
563
550
|
}
|
|
564
551
|
writeSuccess(`\n✅ Webhook ${selectedWebhook.name} v${pushedVersion} deployed successfully to production\n`);
|
|
565
552
|
writeInfo("💡 The new webhook version is now active for all users.");
|
|
@@ -659,23 +646,16 @@ async function pushJobVersion(options = {}) {
|
|
|
659
646
|
metadata: bundledJobData.metadata || selectedJob.metadata
|
|
660
647
|
};
|
|
661
648
|
writeProgress(`\n🚀 Pushing ${selectedJob.name} v${confirmedVersion} to server...`);
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
},
|
|
668
|
-
body: JSON.stringify(jobData)
|
|
669
|
-
});
|
|
670
|
-
if (!response.ok) {
|
|
671
|
-
const errorText = await response.text();
|
|
672
|
-
console.log(`\n❌ Push Error: ${response.status} - ${errorText}\n`);
|
|
673
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
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');
|
|
674
654
|
}
|
|
675
655
|
writeSuccess(`\n✅ Successfully pushed ${selectedJob.name} v${confirmedVersion}\n`);
|
|
676
656
|
// Step 8: Deploy if requested
|
|
677
657
|
if (await shouldDeployAfterPush(options)) {
|
|
678
|
-
await deployJobVersionAfterPush(apiKey, config.agent.agentId, selectedJob, confirmedVersion);
|
|
658
|
+
await deployJobVersionAfterPush(apiKey, config.agent.agentId, selectedJob, confirmedVersion, options.autoDeploy || false);
|
|
679
659
|
}
|
|
680
660
|
else {
|
|
681
661
|
writeInfo("💡 You can deploy this version later using: lua jobs production");
|
|
@@ -689,36 +669,32 @@ async function pushJobVersion(options = {}) {
|
|
|
689
669
|
/**
|
|
690
670
|
* Deploy a job version immediately after pushing
|
|
691
671
|
*/
|
|
692
|
-
async function deployJobVersionAfterPush(apiKey, agentId, selectedJob, pushedVersion) {
|
|
672
|
+
async function deployJobVersionAfterPush(apiKey, agentId, selectedJob, pushedVersion, skipConfirmation = false) {
|
|
693
673
|
try {
|
|
694
|
-
//
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
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;
|
|
703
690
|
}
|
|
704
|
-
]);
|
|
705
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
706
|
-
console.log("\n❌ Deployment cancelled. Version pushed but not deployed.\n");
|
|
707
|
-
return;
|
|
708
691
|
}
|
|
709
692
|
writeProgress("🔄 Publishing job version...");
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
},
|
|
716
|
-
body: JSON.stringify({})
|
|
717
|
-
});
|
|
718
|
-
if (!publishResponse.ok) {
|
|
719
|
-
const errorText = await publishResponse.text();
|
|
720
|
-
console.error(`\n❌ Deploy Error: ${publishResponse.status} - ${errorText}\n`);
|
|
721
|
-
throw new Error(`HTTP error! status: ${publishResponse.status}`);
|
|
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');
|
|
722
698
|
}
|
|
723
699
|
writeSuccess(`\n✅ Job ${selectedJob.name} v${pushedVersion} deployed successfully to production\n`);
|
|
724
700
|
writeInfo("💡 The new job version is now active and will run on schedule.");
|
|
@@ -784,7 +760,7 @@ async function pushPreProcessorVersion(options = {}) {
|
|
|
784
760
|
writeSuccess(`\n✅ PreProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
|
|
785
761
|
// Step 8: Deploy if requested
|
|
786
762
|
if (await shouldDeployAfterPush(options)) {
|
|
787
|
-
await deployPreProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
|
|
763
|
+
await deployPreProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion, options.autoDeploy || false);
|
|
788
764
|
}
|
|
789
765
|
else {
|
|
790
766
|
writeInfo("💡 You can deploy this version later using: lua preprocessors production");
|
|
@@ -802,22 +778,25 @@ async function pushPreProcessorVersion(options = {}) {
|
|
|
802
778
|
/**
|
|
803
779
|
* Deploy a preprocessor version immediately after pushing
|
|
804
780
|
*/
|
|
805
|
-
async function deployPreProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
|
|
781
|
+
async function deployPreProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion, skipConfirmation = false) {
|
|
806
782
|
try {
|
|
807
|
-
//
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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;
|
|
816
799
|
}
|
|
817
|
-
]);
|
|
818
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
819
|
-
console.log("\n❌ Deployment cancelled. Version pushed but not deployed.\n");
|
|
820
|
-
return;
|
|
821
800
|
}
|
|
822
801
|
writeProgress("🔄 Publishing preprocessor version...");
|
|
823
802
|
const api = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
@@ -889,7 +868,7 @@ async function pushPostProcessorVersion(options = {}) {
|
|
|
889
868
|
writeSuccess(`\n✅ PostProcessor "${selected.name}" v${confirmedVersion} pushed successfully\n`);
|
|
890
869
|
// Step 8: Deploy if requested
|
|
891
870
|
if (await shouldDeployAfterPush(options)) {
|
|
892
|
-
await deployPostProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion);
|
|
871
|
+
await deployPostProcessorVersionAfterPush(apiKey, config.agent.agentId, selected, confirmedVersion, options.autoDeploy || false);
|
|
893
872
|
}
|
|
894
873
|
else {
|
|
895
874
|
writeInfo("💡 You can deploy this version later using: lua postprocessors production");
|
|
@@ -907,22 +886,25 @@ async function pushPostProcessorVersion(options = {}) {
|
|
|
907
886
|
/**
|
|
908
887
|
* Deploy a postprocessor version immediately after pushing
|
|
909
888
|
*/
|
|
910
|
-
async function deployPostProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion) {
|
|
889
|
+
async function deployPostProcessorVersionAfterPush(apiKey, agentId, selected, pushedVersion, skipConfirmation = false) {
|
|
911
890
|
try {
|
|
912
|
-
//
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
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;
|
|
921
907
|
}
|
|
922
|
-
]);
|
|
923
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
924
|
-
console.log("\n❌ Deployment cancelled. Version pushed but not deployed.\n");
|
|
925
|
-
return;
|
|
926
908
|
}
|
|
927
909
|
writeProgress("🔄 Publishing postprocessor version...");
|
|
928
910
|
const api = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
@@ -1083,7 +1065,7 @@ async function pushMCPServerVersion(options = {}) {
|
|
|
1083
1065
|
/**
|
|
1084
1066
|
* Deploy a version immediately after pushing
|
|
1085
1067
|
*/
|
|
1086
|
-
async function deployVersionAfterPush(apiKey, agentId, selectedSkill, pushedVersion) {
|
|
1068
|
+
async function deployVersionAfterPush(apiKey, agentId, selectedSkill, pushedVersion, skipConfirmation = false) {
|
|
1087
1069
|
try {
|
|
1088
1070
|
writeProgress("\n🔄 Fetching available versions...");
|
|
1089
1071
|
// Fetch versions to verify the pushed version exists
|
|
@@ -1092,20 +1074,23 @@ async function deployVersionAfterPush(apiKey, agentId, selectedSkill, pushedVers
|
|
|
1092
1074
|
console.error("❌ No versions available. The push may have failed.");
|
|
1093
1075
|
return;
|
|
1094
1076
|
}
|
|
1095
|
-
//
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
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;
|
|
1104
1093
|
}
|
|
1105
|
-
]);
|
|
1106
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
1107
|
-
console.log("\n❌ Deployment cancelled. Version pushed but not deployed.\n");
|
|
1108
|
-
return;
|
|
1109
1094
|
}
|
|
1110
1095
|
// Find the pushed version in the list
|
|
1111
1096
|
const versionToDeploy = versionsResponse.versions.find((v) => v.version === pushedVersion);
|
|
@@ -1276,17 +1261,11 @@ async function pushAllCommand(options) {
|
|
|
1276
1261
|
code: webhookData.code,
|
|
1277
1262
|
executeFunction: webhookData.executeFunction
|
|
1278
1263
|
};
|
|
1279
|
-
// Push version using
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
'Content-Type': 'application/json'
|
|
1285
|
-
},
|
|
1286
|
-
body: JSON.stringify(pushData)
|
|
1287
|
-
});
|
|
1288
|
-
if (!response.ok) {
|
|
1289
|
-
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
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');
|
|
1290
1269
|
}
|
|
1291
1270
|
// Update YAML
|
|
1292
1271
|
updateWebhookVersionInYaml(webhookConfig.name, newVersion);
|
|
@@ -1337,17 +1316,11 @@ async function pushAllCommand(options) {
|
|
|
1337
1316
|
executeFunction: jobData.executeFunction,
|
|
1338
1317
|
metadata: jobData.metadata
|
|
1339
1318
|
};
|
|
1340
|
-
// Push version using
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
'Content-Type': 'application/json'
|
|
1346
|
-
},
|
|
1347
|
-
body: JSON.stringify(pushData)
|
|
1348
|
-
});
|
|
1349
|
-
if (!response.ok) {
|
|
1350
|
-
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
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');
|
|
1351
1324
|
}
|
|
1352
1325
|
// Update YAML
|
|
1353
1326
|
updateJobVersionInYaml(jobConfig.name, newVersion);
|
|
@@ -1532,19 +1505,15 @@ async function pushAllCommand(options) {
|
|
|
1532
1505
|
// Deploy all webhooks
|
|
1533
1506
|
if (toDeployWebhooks.length > 0) {
|
|
1534
1507
|
writeProgress(`🪝 Deploying ${toDeployWebhooks.length} webhook(s)...`);
|
|
1508
|
+
const webhookService = new WebhookApi(BASE_URLS.API, apiKey, agentId);
|
|
1535
1509
|
for (const webhook of toDeployWebhooks) {
|
|
1536
1510
|
const deployed = await retryDeploy(async () => {
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1541
|
-
'Content-Type': 'application/json'
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
-
if (!response.ok) {
|
|
1545
|
-
throw new Error(`HTTP ${response.status}`);
|
|
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');
|
|
1546
1514
|
}
|
|
1547
|
-
|
|
1515
|
+
return result;
|
|
1516
|
+
}, webhook.name, webhook.version, 3);
|
|
1548
1517
|
if (deployed) {
|
|
1549
1518
|
writeSuccess(` 🚀 ${webhook.name} v${webhook.version} deployed`);
|
|
1550
1519
|
}
|
|
@@ -1556,19 +1525,15 @@ async function pushAllCommand(options) {
|
|
|
1556
1525
|
// Deploy all jobs
|
|
1557
1526
|
if (toDeployJobs.length > 0) {
|
|
1558
1527
|
writeProgress(`⏰ Deploying ${toDeployJobs.length} job(s)...`);
|
|
1528
|
+
const jobService = new JobApi(BASE_URLS.API, apiKey, agentId);
|
|
1559
1529
|
for (const job of toDeployJobs) {
|
|
1560
1530
|
const deployed = await retryDeploy(async () => {
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
1565
|
-
'Content-Type': 'application/json'
|
|
1566
|
-
}
|
|
1567
|
-
});
|
|
1568
|
-
if (!response.ok) {
|
|
1569
|
-
throw new Error(`HTTP ${response.status}`);
|
|
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');
|
|
1570
1534
|
}
|
|
1571
|
-
|
|
1535
|
+
return result;
|
|
1536
|
+
}, job.name, job.version, 3);
|
|
1572
1537
|
if (deployed) {
|
|
1573
1538
|
writeSuccess(` 🚀 ${job.name} v${job.version} deployed`);
|
|
1574
1539
|
}
|
|
@@ -1582,7 +1547,13 @@ async function pushAllCommand(options) {
|
|
|
1582
1547
|
writeProgress(`📥 Deploying ${toDeployPreprocessors.length} preprocessor(s)...`);
|
|
1583
1548
|
const preprocessorService = new PreProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1584
1549
|
for (const processor of toDeployPreprocessors) {
|
|
1585
|
-
const deployed = await retryDeploy(() =>
|
|
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);
|
|
1586
1557
|
if (deployed) {
|
|
1587
1558
|
writeSuccess(` 🚀 ${processor.name} v${processor.version} deployed`);
|
|
1588
1559
|
}
|
|
@@ -1596,7 +1567,13 @@ async function pushAllCommand(options) {
|
|
|
1596
1567
|
writeProgress(`📤 Deploying ${toDeployPostprocessors.length} postprocessor(s)...`);
|
|
1597
1568
|
const postprocessorService = new PostProcessorApi(BASE_URLS.API, apiKey, agentId);
|
|
1598
1569
|
for (const processor of toDeployPostprocessors) {
|
|
1599
|
-
const deployed = await retryDeploy(() =>
|
|
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);
|
|
1600
1577
|
if (deployed) {
|
|
1601
1578
|
writeSuccess(` 🚀 ${processor.name} v${processor.version} deployed`);
|
|
1602
1579
|
}
|
|
@@ -1651,20 +1628,32 @@ function bumpPatchVersion(version) {
|
|
|
1651
1628
|
* Retry deployment with exponential backoff
|
|
1652
1629
|
* The server needs time to process pushed versions before they can be deployed
|
|
1653
1630
|
*/
|
|
1654
|
-
async function retryDeploy(deployFn,
|
|
1631
|
+
async function retryDeploy(deployFn, _componentName, _version, maxRetries = 3) {
|
|
1655
1632
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
1656
1633
|
try {
|
|
1657
|
-
|
|
1658
|
-
|
|
1634
|
+
// Only delay on retry attempts (not first attempt)
|
|
1635
|
+
if (attempt > 1) {
|
|
1636
|
+
const delay = attempt * 2000; // 2s on 2nd attempt, 4s on 3rd, etc.
|
|
1637
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1638
|
+
}
|
|
1659
1639
|
await deployFn();
|
|
1640
|
+
// Show success message if succeeded after retrying
|
|
1641
|
+
if (attempt > 1) {
|
|
1642
|
+
writeInfo(` ✓ Succeeded on retry ${attempt}/${maxRetries}`);
|
|
1643
|
+
}
|
|
1660
1644
|
return true;
|
|
1661
1645
|
}
|
|
1662
1646
|
catch (error) {
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1647
|
+
// Extract detailed error message from API response
|
|
1648
|
+
const errorMessage = error?.error?.message || error?.message || 'Unknown error';
|
|
1649
|
+
if (attempt < maxRetries) {
|
|
1650
|
+
// Intermediate retry - show brief info
|
|
1651
|
+
writeInfo(` [Attempt ${attempt}/${maxRetries}] ${errorMessage} - retrying...`);
|
|
1652
|
+
}
|
|
1653
|
+
else {
|
|
1654
|
+
// Final attempt failed - show error
|
|
1655
|
+
console.error(` ❌ [Attempt ${attempt}/${maxRetries}] Deploy failed: ${errorMessage}`);
|
|
1666
1656
|
}
|
|
1667
|
-
// Continue to next retry silently
|
|
1668
1657
|
}
|
|
1669
1658
|
}
|
|
1670
1659
|
return false;
|