@staff0rd/assist 0.321.0 → 0.322.1
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 +132 -109
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.322.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1556,19 +1556,19 @@ function moveCaseInsensitive(absSource, absDest) {
|
|
|
1556
1556
|
fs9.renameSync(absSource, tmp);
|
|
1557
1557
|
fs9.renameSync(tmp, absDest);
|
|
1558
1558
|
}
|
|
1559
|
-
function applyMoves(project, moves, cwd,
|
|
1559
|
+
function applyMoves(project, moves, cwd, emit4) {
|
|
1560
1560
|
for (const { sourcePath, destPath } of moves) {
|
|
1561
1561
|
const start3 = performance.now();
|
|
1562
1562
|
const absSource = path15.resolve(sourcePath);
|
|
1563
1563
|
const absDest = path15.resolve(destPath);
|
|
1564
1564
|
for (const r of renameExports(project, absSource, absDest)) {
|
|
1565
|
-
|
|
1565
|
+
emit4(` Renamed export ${r} in ${sourcePath}`);
|
|
1566
1566
|
}
|
|
1567
1567
|
const sourceFile = project.getSourceFile(absSource);
|
|
1568
1568
|
if (sourceFile) sourceFile.move(absDest);
|
|
1569
1569
|
const ms = (performance.now() - start3).toFixed(0);
|
|
1570
1570
|
const rel = `${path15.relative(cwd, absSource)} \u2192 ${path15.relative(cwd, absDest)}`;
|
|
1571
|
-
|
|
1571
|
+
emit4(` Renamed ${rel} (${ms}ms)`);
|
|
1572
1572
|
}
|
|
1573
1573
|
project.saveSync();
|
|
1574
1574
|
for (const { sourcePath, destPath } of moves) {
|
|
@@ -6361,81 +6361,6 @@ var handleRequest = createFallbackHandler(
|
|
|
6361
6361
|
|
|
6362
6362
|
// src/commands/sessions/web/handleSocket.ts
|
|
6363
6363
|
import { createInterface as createInterface2 } from "readline";
|
|
6364
|
-
|
|
6365
|
-
// src/commands/sessions/daemon/toWindowsSessionId.ts
|
|
6366
|
-
var PREFIX = "w-";
|
|
6367
|
-
function toWindowsSessionId(id2) {
|
|
6368
|
-
return isWindowsSessionId(id2) ? id2 : `${PREFIX}${id2}`;
|
|
6369
|
-
}
|
|
6370
|
-
function isWindowsSessionId(id2) {
|
|
6371
|
-
return id2.startsWith(PREFIX);
|
|
6372
|
-
}
|
|
6373
|
-
function stripWindowsSessionId(id2) {
|
|
6374
|
-
let stripped = id2;
|
|
6375
|
-
while (stripped.startsWith(PREFIX)) stripped = stripped.slice(PREFIX.length);
|
|
6376
|
-
return stripped;
|
|
6377
|
-
}
|
|
6378
|
-
|
|
6379
|
-
// src/commands/sessions/web/ui/repoLabel.ts
|
|
6380
|
-
function repoLabel(cwd) {
|
|
6381
|
-
if (!cwd) return "";
|
|
6382
|
-
const segments = cwd.split(/[/\\]/).filter(Boolean);
|
|
6383
|
-
return segments[segments.length - 1] ?? "";
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
|
-
// src/commands/sessions/web/createSessionLifecycleLogger.ts
|
|
6387
|
-
function createSessionLifecycleLogger() {
|
|
6388
|
-
const known = /* @__PURE__ */ new Map();
|
|
6389
|
-
return (line) => {
|
|
6390
|
-
const sessions = parseSnapshot(line);
|
|
6391
|
-
if (sessions) applySnapshot(known, sessions);
|
|
6392
|
-
};
|
|
6393
|
-
}
|
|
6394
|
-
function parseSnapshot(line) {
|
|
6395
|
-
try {
|
|
6396
|
-
const data = JSON.parse(line);
|
|
6397
|
-
if (data.type === "sessions" && Array.isArray(data.sessions))
|
|
6398
|
-
return data.sessions;
|
|
6399
|
-
} catch {
|
|
6400
|
-
}
|
|
6401
|
-
return null;
|
|
6402
|
-
}
|
|
6403
|
-
function applySnapshot(known, sessions) {
|
|
6404
|
-
const present = /* @__PURE__ */ new Set();
|
|
6405
|
-
for (const session of sessions) {
|
|
6406
|
-
present.add(session.id);
|
|
6407
|
-
const previous = known.get(session.id);
|
|
6408
|
-
known.set(session.id, session);
|
|
6409
|
-
if (previous === void 0) logEvent("started", session);
|
|
6410
|
-
else if (isDone(session) && !isDone(previous)) logEvent("ended", session);
|
|
6411
|
-
}
|
|
6412
|
-
for (const [id2, session] of known) {
|
|
6413
|
-
if (present.has(id2)) continue;
|
|
6414
|
-
known.delete(id2);
|
|
6415
|
-
if (!isDone(session)) logEvent("ended", session);
|
|
6416
|
-
}
|
|
6417
|
-
}
|
|
6418
|
-
function isDone(session) {
|
|
6419
|
-
return session.status === "done";
|
|
6420
|
-
}
|
|
6421
|
-
function logEvent(event, session) {
|
|
6422
|
-
const origin = isWindowsSessionId(session.id) ? "windows" : detectPlatform();
|
|
6423
|
-
console.log(
|
|
6424
|
-
`${(/* @__PURE__ */ new Date()).toISOString()} session ${event}: ${session.id}${describe(session)} [${origin} daemon]`
|
|
6425
|
-
);
|
|
6426
|
-
}
|
|
6427
|
-
function describe(session) {
|
|
6428
|
-
const parts = [];
|
|
6429
|
-
const repo = repoLabel(session.cwd);
|
|
6430
|
-
if (repo) parts.push(repo);
|
|
6431
|
-
const { itemId, phase, totalPhases } = session.activity ?? {};
|
|
6432
|
-
if (itemId !== void 0) parts.push(`#${itemId}`);
|
|
6433
|
-
if (phase !== void 0)
|
|
6434
|
-
parts.push(`phase ${phase}${totalPhases ? `/${totalPhases}` : ""}`);
|
|
6435
|
-
return parts.length ? ` ${parts.join(" ")}` : "";
|
|
6436
|
-
}
|
|
6437
|
-
|
|
6438
|
-
// src/commands/sessions/web/handleSocket.ts
|
|
6439
6364
|
var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
|
|
6440
6365
|
function handleSocket(ws, ctx) {
|
|
6441
6366
|
const connection = openDaemonConnection(ws, ctx);
|
|
@@ -6467,7 +6392,6 @@ function relayDaemonLines(conn, ws, repoCwd) {
|
|
|
6467
6392
|
lines.on("error", () => {
|
|
6468
6393
|
});
|
|
6469
6394
|
lines.on("line", (line) => {
|
|
6470
|
-
logSessionLifecycle(line);
|
|
6471
6395
|
if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
|
|
6472
6396
|
});
|
|
6473
6397
|
conn.on("error", () => {
|
|
@@ -6494,7 +6418,6 @@ function withDefaultCwd(raw, serverCwd) {
|
|
|
6494
6418
|
return raw;
|
|
6495
6419
|
}
|
|
6496
6420
|
}
|
|
6497
|
-
var logSessionLifecycle = createSessionLifecycleLogger();
|
|
6498
6421
|
function withRepoCwd(line, repoCwd) {
|
|
6499
6422
|
if (!repoCwd) return line;
|
|
6500
6423
|
try {
|
|
@@ -6728,6 +6651,44 @@ function installRestartMenu(options2 = {}) {
|
|
|
6728
6651
|
return cleanup;
|
|
6729
6652
|
}
|
|
6730
6653
|
|
|
6654
|
+
// src/commands/sessions/web/streamDaemonLogs.ts
|
|
6655
|
+
import { createInterface as createInterface3 } from "readline";
|
|
6656
|
+
var RECONNECT_MS = 3e3;
|
|
6657
|
+
function streamDaemonLogs() {
|
|
6658
|
+
void connect2();
|
|
6659
|
+
}
|
|
6660
|
+
async function connect2() {
|
|
6661
|
+
try {
|
|
6662
|
+
await ensureDaemonRunning("web log stream");
|
|
6663
|
+
const socket = await connectToDaemon();
|
|
6664
|
+
wire(socket);
|
|
6665
|
+
socket.write(`${JSON.stringify({ type: "subscribe-logs" })}
|
|
6666
|
+
`);
|
|
6667
|
+
} catch {
|
|
6668
|
+
scheduleReconnect();
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6671
|
+
function wire(socket) {
|
|
6672
|
+
const lines = createInterface3({ input: socket });
|
|
6673
|
+
lines.on("error", () => {
|
|
6674
|
+
});
|
|
6675
|
+
lines.on("line", emit);
|
|
6676
|
+
socket.on("error", () => {
|
|
6677
|
+
});
|
|
6678
|
+
socket.on("close", scheduleReconnect);
|
|
6679
|
+
}
|
|
6680
|
+
function emit(line) {
|
|
6681
|
+
try {
|
|
6682
|
+
const data = JSON.parse(line);
|
|
6683
|
+
if (data.type === "log" && typeof data.line === "string")
|
|
6684
|
+
console.log(data.line);
|
|
6685
|
+
} catch {
|
|
6686
|
+
}
|
|
6687
|
+
}
|
|
6688
|
+
function scheduleReconnect() {
|
|
6689
|
+
setTimeout(() => void connect2(), RECONNECT_MS).unref();
|
|
6690
|
+
}
|
|
6691
|
+
|
|
6731
6692
|
// src/commands/sessions/web/index.ts
|
|
6732
6693
|
async function web(options2) {
|
|
6733
6694
|
const port = Number.parseInt(options2.port, 10);
|
|
@@ -6754,6 +6715,7 @@ async function web(options2) {
|
|
|
6754
6715
|
}
|
|
6755
6716
|
});
|
|
6756
6717
|
installRestartMenu();
|
|
6718
|
+
streamDaemonLogs();
|
|
6757
6719
|
void ensureDaemonRunning("web server start").catch((error) => {
|
|
6758
6720
|
console.error(
|
|
6759
6721
|
chalk55.yellow(
|
|
@@ -11669,7 +11631,7 @@ function advisory(count6) {
|
|
|
11669
11631
|
const noun = count6 === 1 ? "handover" : "handovers";
|
|
11670
11632
|
return `${count6} unrecalled ${noun} for this repo. Run /recall to load.`;
|
|
11671
11633
|
}
|
|
11672
|
-
function
|
|
11634
|
+
function emit2(message) {
|
|
11673
11635
|
const json = JSON.stringify({
|
|
11674
11636
|
hookSpecificOutput: { hookEventName: "SessionStart" },
|
|
11675
11637
|
systemMessage: message
|
|
@@ -11686,7 +11648,7 @@ async function load2(options2 = {}) {
|
|
|
11686
11648
|
await migrateDiskHandovers(orm, origin, cwd);
|
|
11687
11649
|
const count6 = await countPendingHandovers(orm, origin);
|
|
11688
11650
|
if (count6 === 0) return null;
|
|
11689
|
-
return
|
|
11651
|
+
return emit2(advisory(count6));
|
|
11690
11652
|
}
|
|
11691
11653
|
|
|
11692
11654
|
// src/commands/handover/listPendingHandovers.ts
|
|
@@ -12401,25 +12363,25 @@ function isVisibleText(t) {
|
|
|
12401
12363
|
return /[a-zA-Z]{3,}/.test(t);
|
|
12402
12364
|
}
|
|
12403
12365
|
var isHashtag = (t) => /^#[A-Za-z0-9_]+$/.test(t);
|
|
12404
|
-
function collectRscText(v, resolve17,
|
|
12366
|
+
function collectRscText(v, resolve17, sink2, seen) {
|
|
12405
12367
|
if (v == null) return;
|
|
12406
12368
|
if (typeof v === "string") {
|
|
12407
12369
|
if (isRscRef(v)) {
|
|
12408
12370
|
if (!seen.has(v)) {
|
|
12409
12371
|
seen.add(v);
|
|
12410
|
-
collectRscText(resolve17(v), resolve17,
|
|
12372
|
+
collectRscText(resolve17(v), resolve17, sink2, seen);
|
|
12411
12373
|
}
|
|
12412
|
-
} else if (isHashtag(v))
|
|
12413
|
-
else if (isVisibleText(v))
|
|
12374
|
+
} else if (isHashtag(v)) sink2.hashtags.push(v);
|
|
12375
|
+
else if (isVisibleText(v)) sink2.text.push(v);
|
|
12414
12376
|
return;
|
|
12415
12377
|
}
|
|
12416
12378
|
if (Array.isArray(v)) {
|
|
12417
|
-
for (const x of v) collectRscText(x, resolve17,
|
|
12379
|
+
for (const x of v) collectRscText(x, resolve17, sink2, seen);
|
|
12418
12380
|
return;
|
|
12419
12381
|
}
|
|
12420
12382
|
if (typeof v === "object") {
|
|
12421
12383
|
for (const val of Object.values(v)) {
|
|
12422
|
-
collectRscText(val, resolve17,
|
|
12384
|
+
collectRscText(val, resolve17, sink2, seen);
|
|
12423
12385
|
}
|
|
12424
12386
|
}
|
|
12425
12387
|
}
|
|
@@ -12458,9 +12420,9 @@ function buildMentionMap(rows, resolve17) {
|
|
|
12458
12420
|
if (!url || o.children == null) return;
|
|
12459
12421
|
const slug = slugFromProfileUrl(url);
|
|
12460
12422
|
if (!slug || map.has(slug)) return;
|
|
12461
|
-
const
|
|
12462
|
-
collectRscText(o.children, resolve17,
|
|
12463
|
-
const name =
|
|
12423
|
+
const sink2 = { text: [], hashtags: [] };
|
|
12424
|
+
collectRscText(o.children, resolve17, sink2, /* @__PURE__ */ new Set());
|
|
12425
|
+
const name = sink2.text.join(" ").replace(/\s+/g, " ").trim();
|
|
12464
12426
|
map.set(slug, name ? { slug, name, url } : { slug, url });
|
|
12465
12427
|
});
|
|
12466
12428
|
return map;
|
|
@@ -12561,8 +12523,8 @@ function walkPostRow(v, resolve17, raw) {
|
|
|
12561
12523
|
if (a) raw.related.push(a[0]);
|
|
12562
12524
|
}
|
|
12563
12525
|
if (isCommentary(o)) {
|
|
12564
|
-
const
|
|
12565
|
-
collectRscText(o.children, resolve17,
|
|
12526
|
+
const sink2 = { text: raw.text, hashtags: raw.hashtags };
|
|
12527
|
+
collectRscText(o.children, resolve17, sink2, /* @__PURE__ */ new Set());
|
|
12566
12528
|
}
|
|
12567
12529
|
for (const val of Object.values(o)) walkPostRow(val, resolve17, raw);
|
|
12568
12530
|
}
|
|
@@ -19985,7 +19947,7 @@ function listDaemonPids() {
|
|
|
19985
19947
|
}
|
|
19986
19948
|
|
|
19987
19949
|
// src/commands/sessions/daemon/queryDaemon.ts
|
|
19988
|
-
import { createInterface as
|
|
19950
|
+
import { createInterface as createInterface5 } from "readline";
|
|
19989
19951
|
var STATUS_TIMEOUT_MS = 5e3;
|
|
19990
19952
|
function queryDaemon(socket) {
|
|
19991
19953
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
@@ -19994,7 +19956,7 @@ function queryDaemon(socket) {
|
|
|
19994
19956
|
const result = { sessions: [] };
|
|
19995
19957
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
19996
19958
|
const timer = setTimeout(() => resolve17(result), STATUS_TIMEOUT_MS);
|
|
19997
|
-
const lines =
|
|
19959
|
+
const lines = createInterface5({ input: socket });
|
|
19998
19960
|
lines.on("error", () => {
|
|
19999
19961
|
});
|
|
20000
19962
|
lines.on("line", (line) => {
|
|
@@ -20074,14 +20036,32 @@ function reportStrays(pids) {
|
|
|
20074
20036
|
}
|
|
20075
20037
|
|
|
20076
20038
|
// src/commands/sessions/daemon/drainDaemon.ts
|
|
20077
|
-
import { createInterface as
|
|
20039
|
+
import { createInterface as createInterface6 } from "readline";
|
|
20078
20040
|
|
|
20079
20041
|
// src/commands/sessions/daemon/loadPersistedSessions.ts
|
|
20080
20042
|
import { z as z5 } from "zod";
|
|
20081
20043
|
|
|
20082
20044
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
20045
|
+
var RING_CAPACITY = 1e3;
|
|
20046
|
+
var ring = [];
|
|
20047
|
+
var sink;
|
|
20083
20048
|
function daemonLog(message) {
|
|
20084
|
-
|
|
20049
|
+
emit3(`${(/* @__PURE__ */ new Date()).toISOString()} [${process.pid}] ${message}`);
|
|
20050
|
+
}
|
|
20051
|
+
function relayDaemonLog(line) {
|
|
20052
|
+
emit3(`[windows] ${line}`);
|
|
20053
|
+
}
|
|
20054
|
+
function emit3(line) {
|
|
20055
|
+
console.log(line);
|
|
20056
|
+
ring.push(line);
|
|
20057
|
+
if (ring.length > RING_CAPACITY) ring.shift();
|
|
20058
|
+
sink?.(line);
|
|
20059
|
+
}
|
|
20060
|
+
function setDaemonLogSink(next3) {
|
|
20061
|
+
sink = next3;
|
|
20062
|
+
}
|
|
20063
|
+
function recentDaemonLogLines() {
|
|
20064
|
+
return [...ring];
|
|
20085
20065
|
}
|
|
20086
20066
|
|
|
20087
20067
|
// src/commands/sessions/daemon/loadPersistedSessions.ts
|
|
@@ -20163,7 +20143,7 @@ function requestDrain(socket) {
|
|
|
20163
20143
|
`);
|
|
20164
20144
|
return new Promise((resolve17) => {
|
|
20165
20145
|
const timer = setTimeout(() => resolve17(0), DRAIN_TIMEOUT_MS);
|
|
20166
|
-
const lines =
|
|
20146
|
+
const lines = createInterface6({ input: socket });
|
|
20167
20147
|
lines.on("error", () => {
|
|
20168
20148
|
});
|
|
20169
20149
|
lines.on("line", (line) => {
|
|
@@ -20324,6 +20304,8 @@ var ClientHub = class extends Set {
|
|
|
20324
20304
|
this.persistPeak = persistPeak;
|
|
20325
20305
|
}
|
|
20326
20306
|
latestLimits;
|
|
20307
|
+
// why: log delivery is opt-in so browser tabs aren't spammed; only connections that ask via subscribe-logs receive daemonLog lines.
|
|
20308
|
+
logSubscribers = /* @__PURE__ */ new Set();
|
|
20327
20309
|
updateLimits(rateLimits) {
|
|
20328
20310
|
this.latestLimits = rateLimits;
|
|
20329
20311
|
broadcast(this, { type: "limits", rateLimits });
|
|
@@ -20334,6 +20316,21 @@ var ClientHub = class extends Set {
|
|
|
20334
20316
|
sendTo(client, { type: "limits", rateLimits: this.latestLimits });
|
|
20335
20317
|
}
|
|
20336
20318
|
}
|
|
20319
|
+
subscribeLogs(client) {
|
|
20320
|
+
for (const line of recentDaemonLogLines()) {
|
|
20321
|
+
sendTo(client, { type: "log", line });
|
|
20322
|
+
}
|
|
20323
|
+
this.logSubscribers.add(client);
|
|
20324
|
+
}
|
|
20325
|
+
unsubscribeLogs(client) {
|
|
20326
|
+
this.logSubscribers.delete(client);
|
|
20327
|
+
}
|
|
20328
|
+
// why: bound so it can be handed to setDaemonLogSink as a bare reference.
|
|
20329
|
+
emitLog = (line) => {
|
|
20330
|
+
for (const client of this.logSubscribers) {
|
|
20331
|
+
sendTo(client, { type: "log", line });
|
|
20332
|
+
}
|
|
20333
|
+
};
|
|
20337
20334
|
};
|
|
20338
20335
|
|
|
20339
20336
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
@@ -20940,10 +20937,10 @@ async function isWindowsDaemonRunning() {
|
|
|
20940
20937
|
import { spawn as spawn10 } from "child_process";
|
|
20941
20938
|
|
|
20942
20939
|
// src/commands/sessions/daemon/logChildStream.ts
|
|
20943
|
-
import { createInterface as
|
|
20940
|
+
import { createInterface as createInterface7 } from "readline";
|
|
20944
20941
|
function logChildStream(stream, label2) {
|
|
20945
20942
|
if (!stream) return;
|
|
20946
|
-
const lines =
|
|
20943
|
+
const lines = createInterface7({ input: stream });
|
|
20947
20944
|
lines.on("line", (line) => daemonLog(`[${label2}] ${line}`));
|
|
20948
20945
|
lines.on("error", () => {
|
|
20949
20946
|
});
|
|
@@ -21021,6 +21018,20 @@ async function discoverWindowsSessions(conn) {
|
|
|
21021
21018
|
}
|
|
21022
21019
|
}
|
|
21023
21020
|
|
|
21021
|
+
// src/commands/sessions/daemon/toWindowsSessionId.ts
|
|
21022
|
+
var PREFIX = "w-";
|
|
21023
|
+
function toWindowsSessionId(id2) {
|
|
21024
|
+
return isWindowsSessionId(id2) ? id2 : `${PREFIX}${id2}`;
|
|
21025
|
+
}
|
|
21026
|
+
function isWindowsSessionId(id2) {
|
|
21027
|
+
return id2.startsWith(PREFIX);
|
|
21028
|
+
}
|
|
21029
|
+
function stripWindowsSessionId(id2) {
|
|
21030
|
+
let stripped = id2;
|
|
21031
|
+
while (stripped.startsWith(PREFIX)) stripped = stripped.slice(PREFIX.length);
|
|
21032
|
+
return stripped;
|
|
21033
|
+
}
|
|
21034
|
+
|
|
21024
21035
|
// src/commands/sessions/daemon/forwardWindowsCreate.ts
|
|
21025
21036
|
async function forwardWindowsCreate(conn, state, client, data) {
|
|
21026
21037
|
daemonLog(`windows proxy: routing ${data.type} (cwd=${data.cwd})`);
|
|
@@ -21099,6 +21110,10 @@ var inbound = {
|
|
|
21099
21110
|
created: handleCreated,
|
|
21100
21111
|
sessions: handleSessions,
|
|
21101
21112
|
output: handleOutput,
|
|
21113
|
+
// why: relay the Windows daemon's own log lines into this daemon's stream (ring + subscribers) so assist.log shows both daemons; not state.broadcast — browsers must not receive log spam.
|
|
21114
|
+
log: (_state, msg) => {
|
|
21115
|
+
if (typeof msg.line === "string") relayDaemonLog(msg.line);
|
|
21116
|
+
},
|
|
21102
21117
|
clear: relayWithSessionId,
|
|
21103
21118
|
error: (state, msg) => {
|
|
21104
21119
|
daemonLog(`windows daemon: inbound error: ${msg.message}`);
|
|
@@ -21215,7 +21230,7 @@ function isWindowsIo(data) {
|
|
|
21215
21230
|
}
|
|
21216
21231
|
|
|
21217
21232
|
// src/commands/sessions/daemon/WindowsConnection.ts
|
|
21218
|
-
import { createInterface as
|
|
21233
|
+
import { createInterface as createInterface8 } from "readline";
|
|
21219
21234
|
|
|
21220
21235
|
// src/commands/sessions/daemon/LaunchCircuitBreaker.ts
|
|
21221
21236
|
var MAX_FAILURES = 3;
|
|
@@ -21292,10 +21307,11 @@ var WindowsConnection = class {
|
|
|
21292
21307
|
this.socket = socket;
|
|
21293
21308
|
this.wire(socket);
|
|
21294
21309
|
this.write(buildHello());
|
|
21310
|
+
this.write({ type: "subscribe-logs" });
|
|
21295
21311
|
return socket;
|
|
21296
21312
|
}
|
|
21297
21313
|
wire(socket) {
|
|
21298
|
-
const lines =
|
|
21314
|
+
const lines = createInterface8({ input: socket });
|
|
21299
21315
|
lines.on("error", () => {
|
|
21300
21316
|
});
|
|
21301
21317
|
lines.on("line", (line) => this.deps.onLine(line));
|
|
@@ -21382,14 +21398,16 @@ var WindowsProxy = class {
|
|
|
21382
21398
|
state;
|
|
21383
21399
|
conn;
|
|
21384
21400
|
healer;
|
|
21385
|
-
|
|
21401
|
+
// why: on the Windows host the proxy would dial its own bridge, self-feeding a log loop and connect churn.
|
|
21402
|
+
enabled = process.platform !== "win32";
|
|
21403
|
+
constructor(clients, onSessionsChanged, connect4 = defaultConnect, heal = healWindowsDaemon) {
|
|
21386
21404
|
this.state = createState(
|
|
21387
21405
|
(msg) => broadcast(clients, msg),
|
|
21388
21406
|
onSessionsChanged,
|
|
21389
21407
|
(version2) => void this.healer.onMismatch(version2)
|
|
21390
21408
|
);
|
|
21391
21409
|
this.conn = new WindowsConnection({
|
|
21392
|
-
connect:
|
|
21410
|
+
connect: connect4,
|
|
21393
21411
|
onLine: (line) => handleInbound(this.state, line),
|
|
21394
21412
|
onClose: () => this.handleClose()
|
|
21395
21413
|
});
|
|
@@ -21399,7 +21417,7 @@ var WindowsProxy = class {
|
|
|
21399
21417
|
return this.state.windowsSessions;
|
|
21400
21418
|
}
|
|
21401
21419
|
discover() {
|
|
21402
|
-
if (this.healer.blocked) return Promise.resolve();
|
|
21420
|
+
if (!this.enabled || this.healer.blocked) return Promise.resolve();
|
|
21403
21421
|
return discoverWindowsSessions(this.conn);
|
|
21404
21422
|
}
|
|
21405
21423
|
replayScrollback(client) {
|
|
@@ -21408,6 +21426,7 @@ var WindowsProxy = class {
|
|
|
21408
21426
|
// Returns true when the message targets Windows: a create/resume in a
|
|
21409
21427
|
// windows-origin cwd is forwarded, as is I/O for a namespaced session id.
|
|
21410
21428
|
route(client, data) {
|
|
21429
|
+
if (!this.enabled) return false;
|
|
21411
21430
|
if (isWindowsCreate(data)) {
|
|
21412
21431
|
if (this.healer.blocked) sendTo(client, this.healer.refusal());
|
|
21413
21432
|
else void forwardWindowsCreate(this.conn, this.state, client, data);
|
|
@@ -21486,6 +21505,7 @@ var SessionManager = class {
|
|
|
21486
21505
|
}
|
|
21487
21506
|
removeClient(client) {
|
|
21488
21507
|
this.clients.delete(client);
|
|
21508
|
+
this.clients.unsubscribeLogs(client);
|
|
21489
21509
|
this.onIdleChange?.(this.isIdle());
|
|
21490
21510
|
}
|
|
21491
21511
|
isIdle = () => this.sessions.size === 0 && this.clients.size === 0;
|
|
@@ -21566,7 +21586,7 @@ import { unlinkSync as unlinkSync19 } from "fs";
|
|
|
21566
21586
|
import * as net3 from "net";
|
|
21567
21587
|
|
|
21568
21588
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
21569
|
-
import { createInterface as
|
|
21589
|
+
import { createInterface as createInterface9 } from "readline";
|
|
21570
21590
|
|
|
21571
21591
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
21572
21592
|
import * as fs31 from "fs";
|
|
@@ -21875,6 +21895,7 @@ function routed(local) {
|
|
|
21875
21895
|
}
|
|
21876
21896
|
var messageHandlers = {
|
|
21877
21897
|
ping: (client) => sendTo(client, { type: "pong", pid: process.pid }),
|
|
21898
|
+
"subscribe-logs": (client, m) => m.clients.subscribeLogs(client),
|
|
21878
21899
|
hello: (client) => sendTo(client, buildHello()),
|
|
21879
21900
|
create: creator(
|
|
21880
21901
|
true,
|
|
@@ -21943,7 +21964,7 @@ function handleConnection(socket, manager) {
|
|
|
21943
21964
|
};
|
|
21944
21965
|
manager.addClient(client);
|
|
21945
21966
|
manager.clients.greet(client);
|
|
21946
|
-
const lines =
|
|
21967
|
+
const lines = createInterface9({ input: socket });
|
|
21947
21968
|
lines.on("error", () => {
|
|
21948
21969
|
});
|
|
21949
21970
|
lines.on("line", (line) => {
|
|
@@ -22079,7 +22100,9 @@ async function runDaemon() {
|
|
|
22079
22100
|
daemonLog("no sessions and no connected server; exiting");
|
|
22080
22101
|
process.exit(0);
|
|
22081
22102
|
});
|
|
22082
|
-
|
|
22103
|
+
const manager = new SessionManager(checkAutoExit);
|
|
22104
|
+
setDaemonLogSink(manager.clients.emitLog);
|
|
22105
|
+
startDaemonServer(manager, checkAutoExit);
|
|
22083
22106
|
}
|
|
22084
22107
|
|
|
22085
22108
|
// src/commands/sessions/daemon/registerDaemon.ts
|