@staff0rd/assist 0.322.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 +19 -79
- 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.1",
|
|
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})`);
|
|
@@ -21461,6 +21398,8 @@ var WindowsProxy = class {
|
|
|
21461
21398
|
state;
|
|
21462
21399
|
conn;
|
|
21463
21400
|
healer;
|
|
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";
|
|
21464
21403
|
constructor(clients, onSessionsChanged, connect4 = defaultConnect, heal = healWindowsDaemon) {
|
|
21465
21404
|
this.state = createState(
|
|
21466
21405
|
(msg) => broadcast(clients, msg),
|
|
@@ -21478,7 +21417,7 @@ var WindowsProxy = class {
|
|
|
21478
21417
|
return this.state.windowsSessions;
|
|
21479
21418
|
}
|
|
21480
21419
|
discover() {
|
|
21481
|
-
if (this.healer.blocked) return Promise.resolve();
|
|
21420
|
+
if (!this.enabled || this.healer.blocked) return Promise.resolve();
|
|
21482
21421
|
return discoverWindowsSessions(this.conn);
|
|
21483
21422
|
}
|
|
21484
21423
|
replayScrollback(client) {
|
|
@@ -21487,6 +21426,7 @@ var WindowsProxy = class {
|
|
|
21487
21426
|
// Returns true when the message targets Windows: a create/resume in a
|
|
21488
21427
|
// windows-origin cwd is forwarded, as is I/O for a namespaced session id.
|
|
21489
21428
|
route(client, data) {
|
|
21429
|
+
if (!this.enabled) return false;
|
|
21490
21430
|
if (isWindowsCreate(data)) {
|
|
21491
21431
|
if (this.healer.blocked) sendTo(client, this.healer.refusal());
|
|
21492
21432
|
else void forwardWindowsCreate(this.conn, this.state, client, data);
|