plazbot-cli 0.2.0 → 0.2.2
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.
|
@@ -722,7 +722,26 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
722
722
|
}]);
|
|
723
723
|
whatsappNumber = number.trim();
|
|
724
724
|
}
|
|
725
|
-
// Paso 4:
|
|
725
|
+
// Paso 4: API Key de OpenAI
|
|
726
|
+
console.log(ui_1.theme.bold('\n Configuracion de IA'));
|
|
727
|
+
const { configureApiKey } = await inquirer_1.default.prompt([{
|
|
728
|
+
type: 'confirm',
|
|
729
|
+
name: 'configureApiKey',
|
|
730
|
+
message: 'Deseas configurar tu API Key de OpenAI? (necesario para que el agente funcione)',
|
|
731
|
+
default: true,
|
|
732
|
+
}]);
|
|
733
|
+
let apiToken = '';
|
|
734
|
+
if (configureApiKey) {
|
|
735
|
+
const { key } = await inquirer_1.default.prompt([{
|
|
736
|
+
type: 'password',
|
|
737
|
+
name: 'key',
|
|
738
|
+
message: 'API Key de OpenAI (sk-...):',
|
|
739
|
+
mask: '*',
|
|
740
|
+
validate: (v) => v.trim().length > 0 || 'La API Key es requerida',
|
|
741
|
+
}]);
|
|
742
|
+
apiToken = key.trim();
|
|
743
|
+
}
|
|
744
|
+
// Paso 5: Zona horaria
|
|
726
745
|
const { timezone } = await inquirer_1.default.prompt([{
|
|
727
746
|
type: 'input',
|
|
728
747
|
name: 'timezone',
|
|
@@ -739,19 +758,23 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
739
758
|
else {
|
|
740
759
|
finalConfig.channels = [];
|
|
741
760
|
}
|
|
761
|
+
if (apiToken && finalConfig.aiProviders && finalConfig.aiProviders.length > 0) {
|
|
762
|
+
finalConfig.aiProviders[0].apiToken = apiToken;
|
|
763
|
+
}
|
|
742
764
|
// Si es --json, solo mostrar y salir
|
|
743
765
|
if (options.json) {
|
|
744
766
|
console.log((0, ui_1.section)('JSON de configuracion'));
|
|
745
767
|
logger_1.logger.json(finalConfig);
|
|
746
768
|
return;
|
|
747
769
|
}
|
|
748
|
-
// Paso
|
|
770
|
+
// Paso 6: Confirmacion
|
|
749
771
|
console.log((0, ui_1.section)('Resumen'));
|
|
750
772
|
console.log((0, ui_1.kvPair)('Plantilla', template.name));
|
|
751
773
|
for (const ph of template.placeholders) {
|
|
752
774
|
console.log((0, ui_1.kvPair)(ph.label, placeholderAnswers[ph.key]));
|
|
753
775
|
}
|
|
754
776
|
console.log((0, ui_1.kvPair)('WhatsApp', deployWhatsApp ? whatsappNumber : 'No configurado'));
|
|
777
|
+
console.log((0, ui_1.kvPair)('API Key OpenAI', apiToken ? 'Configurada' : 'No configurada (el agente no funcionara sin ella)'));
|
|
755
778
|
console.log((0, ui_1.kvPair)('Zona horaria', timezone));
|
|
756
779
|
console.log((0, ui_1.kvPair)('Acciones', String(finalConfig.actions.length)));
|
|
757
780
|
console.log((0, ui_1.kvPair)('IA', `${finalConfig.aiProviders[0].provider} / ${finalConfig.aiProviders[0].model}`));
|
|
@@ -766,7 +789,7 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
766
789
|
logger_1.logger.warning('Creacion cancelada');
|
|
767
790
|
return;
|
|
768
791
|
}
|
|
769
|
-
// Paso
|
|
792
|
+
// Paso 7: Crear agente
|
|
770
793
|
const credentials = await (0, credentials_1.getStoredCredentials)();
|
|
771
794
|
const agent = new plazbot_1.Agent({
|
|
772
795
|
workspaceId: credentials.workspace,
|
|
@@ -790,7 +813,18 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
790
813
|
}
|
|
791
814
|
logger_1.logger.label('Acciones', String(finalConfig.actions.length));
|
|
792
815
|
console.log();
|
|
793
|
-
|
|
816
|
+
console.log((0, ui_1.section)('Siguientes pasos'));
|
|
817
|
+
console.log(ui_1.theme.bold(' 1.') + ' Crea tu cuenta en ' + ui_1.theme.success('appla.plazbot.com/register'));
|
|
818
|
+
console.log(ui_1.theme.bold(' 2.') + ' Ve a Agentes en el menu e importa el archivo');
|
|
819
|
+
console.log(ui_1.theme.bold(' 3.') + ' Conecta WhatsApp en Ajustes > Integraciones');
|
|
820
|
+
console.log(ui_1.theme.bold(' 4.') + ' Agrega tu API Key de OpenAI en Modelos de IA');
|
|
821
|
+
console.log();
|
|
822
|
+
if (!apiToken) {
|
|
823
|
+
logger_1.logger.warning('Recuerda configurar tu API Key de OpenAI para que el agente funcione:');
|
|
824
|
+
logger_1.logger.dim(`plazbot agent ai-config ${result.agentId || '<agentId>'}`);
|
|
825
|
+
console.log();
|
|
826
|
+
}
|
|
827
|
+
logger_1.logger.dim('Probar agente: plazbot agent chat -a ' + (result.agentId || '<agentId>'));
|
|
794
828
|
if (options.dev) {
|
|
795
829
|
logger_1.logger.warning('Ambiente: desarrollo');
|
|
796
830
|
}
|
package/package.json
CHANGED
|
@@ -747,7 +747,28 @@ export const templatesCommand = new Command('templates')
|
|
|
747
747
|
whatsappNumber = number.trim();
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
// Paso 4:
|
|
750
|
+
// Paso 4: API Key de OpenAI
|
|
751
|
+
console.log(theme.bold('\n Configuracion de IA'));
|
|
752
|
+
const { configureApiKey } = await (inquirer as any).prompt([{
|
|
753
|
+
type: 'confirm',
|
|
754
|
+
name: 'configureApiKey',
|
|
755
|
+
message: 'Deseas configurar tu API Key de OpenAI? (necesario para que el agente funcione)',
|
|
756
|
+
default: true,
|
|
757
|
+
}]);
|
|
758
|
+
|
|
759
|
+
let apiToken = '';
|
|
760
|
+
if (configureApiKey) {
|
|
761
|
+
const { key } = await (inquirer as any).prompt([{
|
|
762
|
+
type: 'password',
|
|
763
|
+
name: 'key',
|
|
764
|
+
message: 'API Key de OpenAI (sk-...):',
|
|
765
|
+
mask: '*',
|
|
766
|
+
validate: (v: string) => v.trim().length > 0 || 'La API Key es requerida',
|
|
767
|
+
}]);
|
|
768
|
+
apiToken = key.trim();
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Paso 5: Zona horaria
|
|
751
772
|
const { timezone } = await (inquirer as any).prompt([{
|
|
752
773
|
type: 'input',
|
|
753
774
|
name: 'timezone',
|
|
@@ -767,6 +788,10 @@ export const templatesCommand = new Command('templates')
|
|
|
767
788
|
finalConfig.channels = [];
|
|
768
789
|
}
|
|
769
790
|
|
|
791
|
+
if (apiToken && finalConfig.aiProviders && finalConfig.aiProviders.length > 0) {
|
|
792
|
+
finalConfig.aiProviders[0].apiToken = apiToken;
|
|
793
|
+
}
|
|
794
|
+
|
|
770
795
|
// Si es --json, solo mostrar y salir
|
|
771
796
|
if (options.json) {
|
|
772
797
|
console.log(section('JSON de configuracion'));
|
|
@@ -774,13 +799,14 @@ export const templatesCommand = new Command('templates')
|
|
|
774
799
|
return;
|
|
775
800
|
}
|
|
776
801
|
|
|
777
|
-
// Paso
|
|
802
|
+
// Paso 6: Confirmacion
|
|
778
803
|
console.log(section('Resumen'));
|
|
779
804
|
console.log(kvPair('Plantilla', template.name));
|
|
780
805
|
for (const ph of template.placeholders) {
|
|
781
806
|
console.log(kvPair(ph.label, placeholderAnswers[ph.key]));
|
|
782
807
|
}
|
|
783
808
|
console.log(kvPair('WhatsApp', deployWhatsApp ? whatsappNumber : 'No configurado'));
|
|
809
|
+
console.log(kvPair('API Key OpenAI', apiToken ? 'Configurada' : 'No configurada (el agente no funcionara sin ella)'));
|
|
784
810
|
console.log(kvPair('Zona horaria', timezone));
|
|
785
811
|
console.log(kvPair('Acciones', String(finalConfig.actions.length)));
|
|
786
812
|
console.log(kvPair('IA', `${finalConfig.aiProviders[0].provider} / ${finalConfig.aiProviders[0].model}`));
|
|
@@ -798,7 +824,7 @@ export const templatesCommand = new Command('templates')
|
|
|
798
824
|
return;
|
|
799
825
|
}
|
|
800
826
|
|
|
801
|
-
// Paso
|
|
827
|
+
// Paso 7: Crear agente
|
|
802
828
|
const credentials = await getStoredCredentials();
|
|
803
829
|
|
|
804
830
|
const agent = new Agent({
|
|
@@ -829,7 +855,19 @@ export const templatesCommand = new Command('templates')
|
|
|
829
855
|
logger.label('Acciones', String(finalConfig.actions.length));
|
|
830
856
|
|
|
831
857
|
console.log();
|
|
832
|
-
|
|
858
|
+
console.log(section('Siguientes pasos'));
|
|
859
|
+
console.log(theme.bold(' 1.') + ' Crea tu cuenta en ' + theme.success('appla.plazbot.com/register'));
|
|
860
|
+
console.log(theme.bold(' 2.') + ' Ve a Agentes en el menu e importa el archivo');
|
|
861
|
+
console.log(theme.bold(' 3.') + ' Conecta WhatsApp en Ajustes > Integraciones');
|
|
862
|
+
console.log(theme.bold(' 4.') + ' Agrega tu API Key de OpenAI en Modelos de IA');
|
|
863
|
+
console.log();
|
|
864
|
+
|
|
865
|
+
if (!apiToken) {
|
|
866
|
+
logger.warning('Recuerda configurar tu API Key de OpenAI para que el agente funcione:');
|
|
867
|
+
logger.dim(`plazbot agent ai-config ${result.agentId || '<agentId>'}`);
|
|
868
|
+
console.log();
|
|
869
|
+
}
|
|
870
|
+
logger.dim('Probar agente: plazbot agent chat -a ' + (result.agentId || '<agentId>'));
|
|
833
871
|
|
|
834
872
|
if (options.dev) {
|
|
835
873
|
logger.warning('Ambiente: desarrollo');
|