@cosmicstack/mercury-agent 1.0.5 → 1.0.6
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/dist/index.js +41 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2409,27 +2409,53 @@ var CLIChannel = class extends BaseChannel {
|
|
|
2409
2409
|
this.endOutput();
|
|
2410
2410
|
return full2;
|
|
2411
2411
|
}
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2412
|
+
const startTime = Date.now();
|
|
2413
|
+
const headerLines = ["", chalk3.cyan(` ${this.agentName}:`), ""];
|
|
2414
|
+
for (const line of headerLines) {
|
|
2415
|
+
console.log(line);
|
|
2416
|
+
}
|
|
2417
|
+
const indent = " ";
|
|
2418
|
+
const cols = process.stdout.columns || 80;
|
|
2419
|
+
const contentCols = Math.max(1, cols - indent.length);
|
|
2420
|
+
let visualLines = headerLines.length;
|
|
2421
|
+
let pendingIndent = true;
|
|
2422
|
+
let lineLen = 0;
|
|
2416
2423
|
let full = "";
|
|
2417
2424
|
for await (const chunk of content) {
|
|
2418
|
-
process.stdout.write(chunk);
|
|
2419
2425
|
full += chunk;
|
|
2426
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
2427
|
+
const ch = chunk[i];
|
|
2428
|
+
if (ch === "\n") {
|
|
2429
|
+
visualLines += Math.max(1, Math.ceil((lineLen + indent.length) / cols));
|
|
2430
|
+
process.stdout.write("\n");
|
|
2431
|
+
lineLen = 0;
|
|
2432
|
+
pendingIndent = true;
|
|
2433
|
+
} else {
|
|
2434
|
+
if (pendingIndent) {
|
|
2435
|
+
process.stdout.write(indent);
|
|
2436
|
+
pendingIndent = false;
|
|
2437
|
+
}
|
|
2438
|
+
process.stdout.write(ch);
|
|
2439
|
+
lineLen++;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2420
2442
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
process.stdout.write("\
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
return full;
|
|
2443
|
+
if (lineLen > 0) {
|
|
2444
|
+
visualLines += Math.max(1, Math.ceil((lineLen + indent.length) / cols));
|
|
2445
|
+
process.stdout.write("\n");
|
|
2446
|
+
} else {
|
|
2447
|
+
visualLines += 1;
|
|
2427
2448
|
}
|
|
2428
|
-
|
|
2449
|
+
this.streamActive = false;
|
|
2450
|
+
process.stdout.write(`\x1B[${visualLines}A`);
|
|
2429
2451
|
process.stdout.write("\x1B[J");
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2452
|
+
if (full.trim()) {
|
|
2453
|
+
const block = this.formatBlock(this.agentName, "", full);
|
|
2454
|
+
for (const line of block) {
|
|
2455
|
+
console.log(line);
|
|
2456
|
+
}
|
|
2457
|
+
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
2458
|
+
console.log(chalk3.dim(" " + "\u2500".repeat(50 - elapsed.length - 4) + " " + elapsed + "s"));
|
|
2433
2459
|
}
|
|
2434
2460
|
this.endOutput();
|
|
2435
2461
|
return full;
|