@lifeaitools/clauth 1.5.43 → 1.5.44
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/cli/commands/serve.js +75 -0
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -3382,6 +3382,81 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
3382
3382
|
});
|
|
3383
3383
|
}
|
|
3384
3384
|
|
|
3385
|
+
// GET /debug/sessions — live view of all terminal/chitchat sessions
|
|
3386
|
+
if (method === "GET" && reqPath === "/debug/sessions") {
|
|
3387
|
+
const now = Date.now();
|
|
3388
|
+
const sessions = [];
|
|
3389
|
+
for (const [, s] of terminalSessions) {
|
|
3390
|
+
const startedMs = new Date(s.started_at).getTime();
|
|
3391
|
+
sessions.push({
|
|
3392
|
+
session_id: s.session_id,
|
|
3393
|
+
name: s.name,
|
|
3394
|
+
type: s.is_chitchat ? "chitchat" : "terminal",
|
|
3395
|
+
status: s.status,
|
|
3396
|
+
turn: s.turn || 0,
|
|
3397
|
+
cwd: s.cwd || null,
|
|
3398
|
+
knowledge_tier: s.knowledge_tier,
|
|
3399
|
+
started_at: s.started_at,
|
|
3400
|
+
age_seconds: Math.round((now - startedMs) / 1000),
|
|
3401
|
+
last_response_at: s.lastResponseAt || null,
|
|
3402
|
+
last_response_preview: s.lastResponse
|
|
3403
|
+
? s.lastResponse.slice(0, 300) + (s.lastResponse.length > 300 ? "…" : "")
|
|
3404
|
+
: null,
|
|
3405
|
+
context_chars: s.context ? s.context.length : 0,
|
|
3406
|
+
active_pid: s.activeProc ? s.activeProc.pid : null,
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3409
|
+
const html = `<!DOCTYPE html>
|
|
3410
|
+
<html>
|
|
3411
|
+
<head>
|
|
3412
|
+
<meta charset="utf-8">
|
|
3413
|
+
<meta http-equiv="refresh" content="3">
|
|
3414
|
+
<title>clauth sessions</title>
|
|
3415
|
+
<style>
|
|
3416
|
+
body { font-family: monospace; background: #0d1117; color: #c9d1d9; padding: 20px; }
|
|
3417
|
+
h1 { color: #58a6ff; font-size: 16px; margin-bottom: 4px; }
|
|
3418
|
+
.meta { color: #6e7681; font-size: 12px; margin-bottom: 20px; }
|
|
3419
|
+
.empty { color: #6e7681; }
|
|
3420
|
+
.session { border: 1px solid #30363d; border-radius: 6px; padding: 16px; margin-bottom: 16px; }
|
|
3421
|
+
.session.busy { border-color: #f0883e; }
|
|
3422
|
+
.session.ready { border-color: #3fb950; }
|
|
3423
|
+
.session.stopped { border-color: #6e7681; opacity: 0.6; }
|
|
3424
|
+
.label { color: #6e7681; font-size: 11px; text-transform: uppercase; }
|
|
3425
|
+
.value { color: #e6edf3; font-size: 13px; margin-bottom: 8px; }
|
|
3426
|
+
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; }
|
|
3427
|
+
.badge.chitchat { background: #1f4068; color: #58a6ff; }
|
|
3428
|
+
.badge.terminal { background: #2d1f3d; color: #bc8cff; }
|
|
3429
|
+
.badge.busy { background: #3d2400; color: #f0883e; }
|
|
3430
|
+
.badge.ready { background: #0f2a0f; color: #3fb950; }
|
|
3431
|
+
.preview { background: #161b22; border-radius: 4px; padding: 10px; font-size: 12px; color: #8b949e; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: auto; }
|
|
3432
|
+
</style>
|
|
3433
|
+
</head>
|
|
3434
|
+
<body>
|
|
3435
|
+
<h1>clauth · live sessions</h1>
|
|
3436
|
+
<div class="meta">v${VERSION} · ${sessions.length} session${sessions.length !== 1 ? "s" : ""} · auto-refresh 3s · ${new Date().toISOString()}</div>
|
|
3437
|
+
${sessions.length === 0
|
|
3438
|
+
? '<div class="empty">No active sessions.</div>'
|
|
3439
|
+
: sessions.map(s => `
|
|
3440
|
+
<div class="session ${s.status}">
|
|
3441
|
+
<span class="badge ${s.type}">${s.type}</span>
|
|
3442
|
+
<span class="badge ${s.status}" style="margin-left:6px">${s.status}${s.status === "busy" ? " ⟳" : ""}</span>
|
|
3443
|
+
<div style="margin-top:10px">
|
|
3444
|
+
<div class="label">name</div><div class="value">${s.name}</div>
|
|
3445
|
+
<div class="label">session_id</div><div class="value" style="color:#6e7681;font-size:11px">${s.session_id}</div>
|
|
3446
|
+
<div class="label">turn / age / context</div>
|
|
3447
|
+
<div class="value">turn ${s.turn} · ${s.age_seconds}s old · ${s.context_chars} chars context${s.active_pid ? ` · pid ${s.active_pid}` : ""}</div>
|
|
3448
|
+
<div class="label">cwd</div><div class="value" style="color:#6e7681">${s.cwd || "(not set)"}</div>
|
|
3449
|
+
${s.last_response_preview ? `
|
|
3450
|
+
<div class="label">last response ${s.last_response_at ? "· " + s.last_response_at : ""}</div>
|
|
3451
|
+
<div class="preview">${s.last_response_preview.replace(/</g, "<").replace(/>/g, ">")}</div>` : ""}
|
|
3452
|
+
</div>
|
|
3453
|
+
</div>`).join("")}
|
|
3454
|
+
</body>
|
|
3455
|
+
</html>`;
|
|
3456
|
+
res.writeHead(200, { "Content-Type": "text/html", ...CORS });
|
|
3457
|
+
return res.end(html);
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3385
3460
|
// GET /builds — CI build status (no auth required, same as /ping)
|
|
3386
3461
|
if (method === "GET" && reqPath === "/builds") {
|
|
3387
3462
|
return ok(res, buildStatus);
|