sentinelayer-cli 0.8.6 → 0.8.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.
- package/package.json +1 -1
- package/src/commands/session.js +49 -1
package/package.json
CHANGED
package/src/commands/session.js
CHANGED
|
@@ -52,6 +52,7 @@ import { appendToStream, readStream, tailStream } from "../session/stream.js";
|
|
|
52
52
|
import { readSessionPreview } from "../session/preview.js";
|
|
53
53
|
import { syncSessionMetadataToApi } from "../session/sync.js";
|
|
54
54
|
import { hydrateSessionFromRemote } from "../session/remote-hydrate.js";
|
|
55
|
+
import { mergeLiveSources } from "../session/live-source.js";
|
|
55
56
|
import {
|
|
56
57
|
buildDashboardUrl,
|
|
57
58
|
buildTemplateLaunchPlan,
|
|
@@ -453,7 +454,11 @@ export function registerSessionCommand(program) {
|
|
|
453
454
|
.command("read <sessionId>")
|
|
454
455
|
.description("Read recent session messages")
|
|
455
456
|
.option("--tail <n>", "Number of recent events", "20")
|
|
456
|
-
.option("--follow", "Continuously follow new events")
|
|
457
|
+
.option("--follow", "Continuously follow new events (local fs poll)")
|
|
458
|
+
.option(
|
|
459
|
+
"--live",
|
|
460
|
+
"Subscribe to SSE + fs.watch combined source (replaces --follow). Same-machine peers via fs.watch, remote peers via SSE; events deduped by id.",
|
|
461
|
+
)
|
|
457
462
|
.option(
|
|
458
463
|
"--remote",
|
|
459
464
|
"Hydrate from the SentinelLayer API before reading (pulls web-posted messages into the local NDJSON)",
|
|
@@ -516,6 +521,49 @@ export function registerSessionCommand(program) {
|
|
|
516
521
|
return;
|
|
517
522
|
}
|
|
518
523
|
|
|
524
|
+
if (options.live) {
|
|
525
|
+
if (!emitJson) {
|
|
526
|
+
console.log(
|
|
527
|
+
pc.gray(
|
|
528
|
+
`Live-tailing ${normalizedSessionId} (SSE + fs.watch)… Ctrl+C to stop.`,
|
|
529
|
+
),
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
const ac = new AbortController();
|
|
533
|
+
const onSigint = () => ac.abort();
|
|
534
|
+
process.on("SIGINT", onSigint);
|
|
535
|
+
const session = await resolveActiveAuthSession({
|
|
536
|
+
cwd: targetPath,
|
|
537
|
+
env: process.env,
|
|
538
|
+
autoRotate: false,
|
|
539
|
+
}).catch(() => null);
|
|
540
|
+
const apiBaseUrl = session?.apiUrl || "";
|
|
541
|
+
const token = session?.token || "";
|
|
542
|
+
try {
|
|
543
|
+
for await (const item of mergeLiveSources({
|
|
544
|
+
sessionId: normalizedSessionId,
|
|
545
|
+
targetPath,
|
|
546
|
+
apiBaseUrl: apiBaseUrl || undefined,
|
|
547
|
+
token: token || undefined,
|
|
548
|
+
signal: ac.signal,
|
|
549
|
+
})) {
|
|
550
|
+
if (item.event) {
|
|
551
|
+
if (emitJson) {
|
|
552
|
+
console.log(JSON.stringify({ source: item.source, event: item.event }));
|
|
553
|
+
} else {
|
|
554
|
+
const sourceTag = item.source === "sse" ? pc.cyan("[sse]") : pc.gray("[fs] ");
|
|
555
|
+
console.log(`${sourceTag} ${formatEventLine(item.event)}`);
|
|
556
|
+
}
|
|
557
|
+
} else if (item.error && !emitJson) {
|
|
558
|
+
console.log(pc.yellow(`(${item.source} stream: ${item.error})`));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
} finally {
|
|
562
|
+
process.removeListener("SIGINT", onSigint);
|
|
563
|
+
}
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
|
|
519
567
|
if (!emitJson) {
|
|
520
568
|
console.log(pc.gray(`Following session ${normalizedSessionId}... Press Ctrl+C to stop.`));
|
|
521
569
|
}
|