@staff0rd/assist 0.322.0 → 0.322.2
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 +48 -100
- 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.322.
|
|
9
|
+
version: "0.322.2",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -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 {
|
|
@@ -21095,6 +21018,20 @@ async function discoverWindowsSessions(conn) {
|
|
|
21095
21018
|
}
|
|
21096
21019
|
}
|
|
21097
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
|
+
|
|
21098
21035
|
// src/commands/sessions/daemon/forwardWindowsCreate.ts
|
|
21099
21036
|
async function forwardWindowsCreate(conn, state, client, data) {
|
|
21100
21037
|
daemonLog(`windows proxy: routing ${data.type} (cwd=${data.cwd})`);
|
|
@@ -21225,6 +21162,18 @@ function nsId(msg) {
|
|
|
21225
21162
|
return toWindowsSessionId(msg.sessionId);
|
|
21226
21163
|
}
|
|
21227
21164
|
|
|
21165
|
+
// src/commands/sessions/daemon/handleWindowsClose.ts
|
|
21166
|
+
function handleWindowsClose(state) {
|
|
21167
|
+
daemonLog("windows proxy: connection to windows daemon closed");
|
|
21168
|
+
for (const client of state.pendingCreators)
|
|
21169
|
+
sendTo(client, {
|
|
21170
|
+
type: "error",
|
|
21171
|
+
message: "Windows daemon connection closed"
|
|
21172
|
+
});
|
|
21173
|
+
resetState(state);
|
|
21174
|
+
state.onSessionsChanged();
|
|
21175
|
+
}
|
|
21176
|
+
|
|
21228
21177
|
// src/commands/sessions/daemon/healWindowsDaemon.ts
|
|
21229
21178
|
import { spawn as spawn11 } from "child_process";
|
|
21230
21179
|
var UPDATE_TIMEOUT_MS = 5 * 6e4;
|
|
@@ -21461,6 +21410,8 @@ var WindowsProxy = class {
|
|
|
21461
21410
|
state;
|
|
21462
21411
|
conn;
|
|
21463
21412
|
healer;
|
|
21413
|
+
// why: on the Windows host the proxy would dial its own bridge, self-feeding a log loop and connect churn.
|
|
21414
|
+
enabled = process.platform !== "win32";
|
|
21464
21415
|
constructor(clients, onSessionsChanged, connect4 = defaultConnect, heal = healWindowsDaemon) {
|
|
21465
21416
|
this.state = createState(
|
|
21466
21417
|
(msg) => broadcast(clients, msg),
|
|
@@ -21470,7 +21421,7 @@ var WindowsProxy = class {
|
|
|
21470
21421
|
this.conn = new WindowsConnection({
|
|
21471
21422
|
connect: connect4,
|
|
21472
21423
|
onLine: (line) => handleInbound(this.state, line),
|
|
21473
|
-
onClose: () => this.
|
|
21424
|
+
onClose: () => handleWindowsClose(this.state)
|
|
21474
21425
|
});
|
|
21475
21426
|
this.healer = new WindowsVersionHealer(this.conn, this.state, heal);
|
|
21476
21427
|
}
|
|
@@ -21478,7 +21429,7 @@ var WindowsProxy = class {
|
|
|
21478
21429
|
return this.state.windowsSessions;
|
|
21479
21430
|
}
|
|
21480
21431
|
discover() {
|
|
21481
|
-
if (this.healer.blocked) return Promise.resolve();
|
|
21432
|
+
if (!this.enabled || this.healer.blocked) return Promise.resolve();
|
|
21482
21433
|
return discoverWindowsSessions(this.conn);
|
|
21483
21434
|
}
|
|
21484
21435
|
replayScrollback(client) {
|
|
@@ -21487,31 +21438,28 @@ var WindowsProxy = class {
|
|
|
21487
21438
|
// Returns true when the message targets Windows: a create/resume in a
|
|
21488
21439
|
// windows-origin cwd is forwarded, as is I/O for a namespaced session id.
|
|
21489
21440
|
route(client, data) {
|
|
21490
|
-
if (
|
|
21491
|
-
|
|
21492
|
-
|
|
21493
|
-
return true;
|
|
21494
|
-
}
|
|
21495
|
-
if (isWindowsIo(data)) {
|
|
21496
|
-
const sessionId = stripWindowsSessionId(data.sessionId);
|
|
21497
|
-
this.conn.trySend({ ...data, sessionId });
|
|
21498
|
-
return true;
|
|
21499
|
-
}
|
|
21441
|
+
if (!this.enabled) return false;
|
|
21442
|
+
if (isWindowsCreate(data)) return this.routeCreate(client, data);
|
|
21443
|
+
if (isWindowsIo(data)) return this.routeIo(data);
|
|
21500
21444
|
return false;
|
|
21501
21445
|
}
|
|
21446
|
+
routeCreate(client, data) {
|
|
21447
|
+
if (this.healer.blocked) {
|
|
21448
|
+
daemonLog(
|
|
21449
|
+
`windows proxy: refusing ${data.type} (cwd=${data.cwd}); windows host version incompatible`
|
|
21450
|
+
);
|
|
21451
|
+
sendTo(client, this.healer.refusal());
|
|
21452
|
+
} else void forwardWindowsCreate(this.conn, this.state, client, data);
|
|
21453
|
+
return true;
|
|
21454
|
+
}
|
|
21455
|
+
routeIo(data) {
|
|
21456
|
+
const sessionId = stripWindowsSessionId(data.sessionId);
|
|
21457
|
+
this.conn.trySend({ ...data, sessionId });
|
|
21458
|
+
return true;
|
|
21459
|
+
}
|
|
21502
21460
|
dispose() {
|
|
21503
21461
|
this.conn.dispose();
|
|
21504
21462
|
}
|
|
21505
|
-
handleClose() {
|
|
21506
|
-
daemonLog("windows proxy: connection to windows daemon closed");
|
|
21507
|
-
for (const client of this.state.pendingCreators)
|
|
21508
|
-
sendTo(client, {
|
|
21509
|
-
type: "error",
|
|
21510
|
-
message: "Windows daemon connection closed"
|
|
21511
|
-
});
|
|
21512
|
-
resetState(this.state);
|
|
21513
|
-
this.state.onSessionsChanged();
|
|
21514
|
-
}
|
|
21515
21463
|
};
|
|
21516
21464
|
|
|
21517
21465
|
// src/commands/sessions/daemon/writeToSession.ts
|