plazbot-cli 0.2.6 → 0.2.7
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.
|
@@ -90,13 +90,47 @@ async function connectChannelFlow(ctx) {
|
|
|
90
90
|
catch {
|
|
91
91
|
// Si falla, se parte de vacio
|
|
92
92
|
}
|
|
93
|
-
// Polling para detectar nueva integracion
|
|
94
|
-
const pollSpinner = (0, ora_1.default)({ text: chalk_1.default.gray('Esperando conexion... (
|
|
93
|
+
// Polling para detectar nueva integracion (Enter para saltar)
|
|
94
|
+
const pollSpinner = (0, ora_1.default)({ text: chalk_1.default.gray('Esperando conexion... (Enter para saltar)'), spinner: 'dots', color: 'cyan' }).start();
|
|
95
95
|
const POLL_INTERVAL = 5000;
|
|
96
96
|
const MAX_POLLS = 60; // 5 minutos
|
|
97
97
|
let detected = null;
|
|
98
|
+
let skipped = false;
|
|
99
|
+
// Escuchar Enter para saltar el polling
|
|
100
|
+
const skipPromise = new Promise(resolve => {
|
|
101
|
+
const onData = (data) => {
|
|
102
|
+
if (data.toString().includes('\n') || data.toString().includes('\r')) {
|
|
103
|
+
skipped = true;
|
|
104
|
+
process.stdin.removeListener('data', onData);
|
|
105
|
+
if (wasRaw)
|
|
106
|
+
process.stdin.setRawMode(false);
|
|
107
|
+
resolve();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const wasRaw = process.stdin.isRaw;
|
|
111
|
+
if (process.stdin.isTTY)
|
|
112
|
+
process.stdin.setRawMode(true);
|
|
113
|
+
process.stdin.resume();
|
|
114
|
+
process.stdin.on('data', onData);
|
|
115
|
+
// Limpiar si termina el polling naturalmente
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
process.stdin.removeListener('data', onData);
|
|
118
|
+
if (process.stdin.isTTY && wasRaw !== undefined) {
|
|
119
|
+
try {
|
|
120
|
+
process.stdin.setRawMode(wasRaw);
|
|
121
|
+
}
|
|
122
|
+
catch { }
|
|
123
|
+
}
|
|
124
|
+
resolve();
|
|
125
|
+
}, POLL_INTERVAL * MAX_POLLS + 1000);
|
|
126
|
+
});
|
|
98
127
|
for (let i = 0; i < MAX_POLLS; i++) {
|
|
99
|
-
await
|
|
128
|
+
await Promise.race([
|
|
129
|
+
new Promise(r => setTimeout(r, POLL_INTERVAL)),
|
|
130
|
+
skipPromise,
|
|
131
|
+
]);
|
|
132
|
+
if (skipped)
|
|
133
|
+
break;
|
|
100
134
|
try {
|
|
101
135
|
const wkRes = await axios_1.default.get(`${baseUrl}/api/workspace/${ctx.workspaceId}`, { headers });
|
|
102
136
|
const integrations = wkRes.data?.integrations || [];
|
|
@@ -114,7 +148,7 @@ async function connectChannelFlow(ctx) {
|
|
|
114
148
|
// Ignorar errores de poll individual
|
|
115
149
|
}
|
|
116
150
|
const elapsed = Math.floor(((i + 1) * POLL_INTERVAL) / 1000);
|
|
117
|
-
pollSpinner.text = chalk_1.default.gray(`Esperando conexion... ${elapsed}s`);
|
|
151
|
+
pollSpinner.text = chalk_1.default.gray(`Esperando conexion... ${elapsed}s (Enter para saltar)`);
|
|
118
152
|
}
|
|
119
153
|
if (detected) {
|
|
120
154
|
const detectedName = detected.aliasName || detected.cellphoneNumberFormat || detected.cellphoneNumber || detected.srcName || detected.id;
|
|
@@ -133,7 +167,7 @@ async function connectChannelFlow(ctx) {
|
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
169
|
else {
|
|
136
|
-
pollSpinner.warn(chalk_1.default.hex('#FFA726')('Timeout: no se detecto una conexion.'));
|
|
170
|
+
pollSpinner.warn(chalk_1.default.hex('#FFA726')(skipped ? 'Polling omitido.' : 'Timeout: no se detecto una conexion.'));
|
|
137
171
|
const { action } = await inquirer_1.default.prompt([{
|
|
138
172
|
type: 'list', name: 'action',
|
|
139
173
|
message: 'Que deseas hacer?',
|
package/package.json
CHANGED
|
@@ -192,14 +192,43 @@ async function connectChannelFlow(ctx: WizardContext): Promise<AgentChannel[]> {
|
|
|
192
192
|
// Si falla, se parte de vacio
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
// Polling para detectar nueva integracion
|
|
196
|
-
const pollSpinner = ora({ text: chalk.gray('Esperando conexion... (
|
|
195
|
+
// Polling para detectar nueva integracion (Enter para saltar)
|
|
196
|
+
const pollSpinner = ora({ text: chalk.gray('Esperando conexion... (Enter para saltar)'), spinner: 'dots', color: 'cyan' }).start();
|
|
197
197
|
const POLL_INTERVAL = 5000;
|
|
198
198
|
const MAX_POLLS = 60; // 5 minutos
|
|
199
199
|
let detected: any = null;
|
|
200
|
+
let skipped = false;
|
|
201
|
+
|
|
202
|
+
// Escuchar Enter para saltar el polling
|
|
203
|
+
const skipPromise = new Promise<void>(resolve => {
|
|
204
|
+
const onData = (data: Buffer) => {
|
|
205
|
+
if (data.toString().includes('\n') || data.toString().includes('\r')) {
|
|
206
|
+
skipped = true;
|
|
207
|
+
process.stdin.removeListener('data', onData);
|
|
208
|
+
if (wasRaw) process.stdin.setRawMode(false);
|
|
209
|
+
resolve();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const wasRaw = process.stdin.isRaw;
|
|
213
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
214
|
+
process.stdin.resume();
|
|
215
|
+
process.stdin.on('data', onData);
|
|
216
|
+
// Limpiar si termina el polling naturalmente
|
|
217
|
+
setTimeout(() => {
|
|
218
|
+
process.stdin.removeListener('data', onData);
|
|
219
|
+
if (process.stdin.isTTY && wasRaw !== undefined) {
|
|
220
|
+
try { process.stdin.setRawMode(wasRaw); } catch {}
|
|
221
|
+
}
|
|
222
|
+
resolve();
|
|
223
|
+
}, POLL_INTERVAL * MAX_POLLS + 1000);
|
|
224
|
+
});
|
|
200
225
|
|
|
201
226
|
for (let i = 0; i < MAX_POLLS; i++) {
|
|
202
|
-
await
|
|
227
|
+
await Promise.race([
|
|
228
|
+
new Promise(r => setTimeout(r, POLL_INTERVAL)),
|
|
229
|
+
skipPromise,
|
|
230
|
+
]);
|
|
231
|
+
if (skipped) break;
|
|
203
232
|
try {
|
|
204
233
|
const wkRes = await axios.get(`${baseUrl}/api/workspace/${ctx.workspaceId}`, { headers });
|
|
205
234
|
const integrations = wkRes.data?.integrations || [];
|
|
@@ -218,7 +247,7 @@ async function connectChannelFlow(ctx: WizardContext): Promise<AgentChannel[]> {
|
|
|
218
247
|
// Ignorar errores de poll individual
|
|
219
248
|
}
|
|
220
249
|
const elapsed = Math.floor(((i + 1) * POLL_INTERVAL) / 1000);
|
|
221
|
-
pollSpinner.text = chalk.gray(`Esperando conexion... ${elapsed}s`);
|
|
250
|
+
pollSpinner.text = chalk.gray(`Esperando conexion... ${elapsed}s (Enter para saltar)`);
|
|
222
251
|
}
|
|
223
252
|
|
|
224
253
|
if (detected) {
|
|
@@ -239,7 +268,7 @@ async function connectChannelFlow(ctx: WizardContext): Promise<AgentChannel[]> {
|
|
|
239
268
|
console.log(chalk.hex('#4ade80')(' Canal asociado correctamente.'));
|
|
240
269
|
}
|
|
241
270
|
} else {
|
|
242
|
-
pollSpinner.warn(chalk.hex('#FFA726')('Timeout: no se detecto una conexion.'));
|
|
271
|
+
pollSpinner.warn(chalk.hex('#FFA726')(skipped ? 'Polling omitido.' : 'Timeout: no se detecto una conexion.'));
|
|
243
272
|
const { action } = await (inquirer as any).prompt([{
|
|
244
273
|
type: 'list', name: 'action',
|
|
245
274
|
message: 'Que deseas hacer?',
|