@staff0rd/assist 0.704.7 → 0.705.0
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/README.md +1 -0
- package/dist/commands/sessions/web/bundle.js +366 -366
- package/dist/index.js +163 -108
- 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.705.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -811,6 +811,7 @@ var assistConfigShape = {
|
|
|
811
811
|
outputDir: z3.string().default("./screenshots")
|
|
812
812
|
}).default({ outputDir: "./screenshots" }),
|
|
813
813
|
sessions: z3.strictObject({
|
|
814
|
+
nodeName: z3.string().optional(),
|
|
814
815
|
// why: Windows .claude/projects root as seen from WSL (e.g. /mnt/c/Users/<user>/.claude/projects); when set its transcripts are discovered and tagged windows-origin
|
|
815
816
|
windowsProjectsRoot: z3.string().optional(),
|
|
816
817
|
// why: host the WSL daemon dials to reach the native Windows daemon over TCP (WSL can't use the Windows named pipe); defaults to 127.0.0.1 (WSL2 mirrored networking). NAT-mode users set the Windows host IP.
|
|
@@ -8087,14 +8088,14 @@ import os3 from "os";
|
|
|
8087
8088
|
|
|
8088
8089
|
// src/shared/db/recordPhaseSession.ts
|
|
8089
8090
|
import { sql as sql13 } from "drizzle-orm";
|
|
8090
|
-
async function recordPhaseSession(db, itemId2, phaseIdx, claudeSessionId,
|
|
8091
|
-
await db.insert(phaseSessions).values({ itemId: itemId2, phaseIdx, claudeSessionId, hostname, osUser }).onConflictDoUpdate({
|
|
8091
|
+
async function recordPhaseSession(db, itemId2, phaseIdx, claudeSessionId, hostname2, osUser) {
|
|
8092
|
+
await db.insert(phaseSessions).values({ itemId: itemId2, phaseIdx, claudeSessionId, hostname: hostname2, osUser }).onConflictDoUpdate({
|
|
8092
8093
|
target: [
|
|
8093
8094
|
phaseSessions.itemId,
|
|
8094
8095
|
phaseSessions.phaseIdx,
|
|
8095
8096
|
phaseSessions.claudeSessionId
|
|
8096
8097
|
],
|
|
8097
|
-
set: { hostname, osUser },
|
|
8098
|
+
set: { hostname: hostname2, osUser },
|
|
8098
8099
|
setWhere: sql13`${phaseSessions.hostname} = 'unknown'`
|
|
8099
8100
|
});
|
|
8100
8101
|
}
|
|
@@ -10437,7 +10438,6 @@ function registerUpdateCommands(cmd) {
|
|
|
10437
10438
|
|
|
10438
10439
|
// src/commands/sessions/web.ts
|
|
10439
10440
|
import chalk108 from "chalk";
|
|
10440
|
-
import { WebSocketServer } from "ws";
|
|
10441
10441
|
|
|
10442
10442
|
// src/shared/getInstallDir.ts
|
|
10443
10443
|
import { execSync as execSync20 } from "child_process";
|
|
@@ -10901,7 +10901,114 @@ function currentOriginOfClone(clone) {
|
|
|
10901
10901
|
return main ? originResolutionForCwd(main) : void 0;
|
|
10902
10902
|
}
|
|
10903
10903
|
function hostedGroup(cwd, origin, clone) {
|
|
10904
|
-
return {
|
|
10904
|
+
return {
|
|
10905
|
+
origin: shouldProxyToWindows(cwd) ? `windows:${origin}` : origin,
|
|
10906
|
+
clone
|
|
10907
|
+
};
|
|
10908
|
+
}
|
|
10909
|
+
|
|
10910
|
+
// src/commands/sessions/web/attachSessionSocket.ts
|
|
10911
|
+
import { WebSocketServer } from "ws";
|
|
10912
|
+
|
|
10913
|
+
// src/commands/sessions/web/handleSocket.ts
|
|
10914
|
+
import { createInterface as createInterface4 } from "readline";
|
|
10915
|
+
var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
|
|
10916
|
+
function handleSocket(ws, ctx) {
|
|
10917
|
+
const connection = openDaemonConnection(ws, ctx);
|
|
10918
|
+
connection.catch(() => {
|
|
10919
|
+
});
|
|
10920
|
+
ws.on("message", async (msg) => {
|
|
10921
|
+
const conn = await connection.catch(() => null);
|
|
10922
|
+
conn?.write(`${withDefaultCwd(msg.toString(), ctx.serverCwd)}
|
|
10923
|
+
`);
|
|
10924
|
+
});
|
|
10925
|
+
ws.on("close", () => {
|
|
10926
|
+
void connection.then((conn) => conn.destroy()).catch(() => {
|
|
10927
|
+
});
|
|
10928
|
+
});
|
|
10929
|
+
}
|
|
10930
|
+
async function openDaemonConnection(ws, ctx) {
|
|
10931
|
+
try {
|
|
10932
|
+
await ensureDaemonRunning("web socket connection");
|
|
10933
|
+
const conn = await connectToDaemon();
|
|
10934
|
+
relayDaemonLines(conn, ws, ctx.repoCwd);
|
|
10935
|
+
return conn;
|
|
10936
|
+
} catch (error) {
|
|
10937
|
+
closeWithError(ws, error);
|
|
10938
|
+
throw error;
|
|
10939
|
+
}
|
|
10940
|
+
}
|
|
10941
|
+
function relayDaemonLines(conn, ws, repoCwd) {
|
|
10942
|
+
const lines2 = createInterface4({ input: conn });
|
|
10943
|
+
lines2.on("error", () => {
|
|
10944
|
+
});
|
|
10945
|
+
lines2.on("line", (line) => {
|
|
10946
|
+
if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
|
|
10947
|
+
});
|
|
10948
|
+
conn.on("error", () => {
|
|
10949
|
+
});
|
|
10950
|
+
conn.on("close", () => ws.close());
|
|
10951
|
+
}
|
|
10952
|
+
function closeWithError(ws, e) {
|
|
10953
|
+
if (ws.readyState !== ws.OPEN) return;
|
|
10954
|
+
ws.send(
|
|
10955
|
+
JSON.stringify({
|
|
10956
|
+
type: "error",
|
|
10957
|
+
message: `sessions daemon unavailable: ${e instanceof Error ? e.message : String(e)}`
|
|
10958
|
+
})
|
|
10959
|
+
);
|
|
10960
|
+
ws.close();
|
|
10961
|
+
}
|
|
10962
|
+
function withDefaultCwd(raw, serverCwd) {
|
|
10963
|
+
try {
|
|
10964
|
+
const data = JSON.parse(raw);
|
|
10965
|
+
if (!CWD_DEFAULTED_TYPES.has(data.type) || data.cwd) return raw;
|
|
10966
|
+
data.cwd = serverCwd;
|
|
10967
|
+
return JSON.stringify(data);
|
|
10968
|
+
} catch {
|
|
10969
|
+
return raw;
|
|
10970
|
+
}
|
|
10971
|
+
}
|
|
10972
|
+
function withRepoCwd(line, repoCwd) {
|
|
10973
|
+
if (!repoCwd) return line;
|
|
10974
|
+
try {
|
|
10975
|
+
const data = JSON.parse(line);
|
|
10976
|
+
if (data.type !== "sessions" || data.cwd) return line;
|
|
10977
|
+
data.cwd = repoCwd;
|
|
10978
|
+
return JSON.stringify(data);
|
|
10979
|
+
} catch {
|
|
10980
|
+
return line;
|
|
10981
|
+
}
|
|
10982
|
+
}
|
|
10983
|
+
|
|
10984
|
+
// src/commands/sessions/web/restartMenu/releaseWebServerPort.ts
|
|
10985
|
+
var release;
|
|
10986
|
+
function onReleaseWebServerPort(fn) {
|
|
10987
|
+
release = fn;
|
|
10988
|
+
}
|
|
10989
|
+
function releaseWebServerPort() {
|
|
10990
|
+
const fn = release;
|
|
10991
|
+
release = void 0;
|
|
10992
|
+
fn?.();
|
|
10993
|
+
}
|
|
10994
|
+
|
|
10995
|
+
// src/commands/sessions/web/attachSessionSocket.ts
|
|
10996
|
+
function attachSessionSocket(server, ctx) {
|
|
10997
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
10998
|
+
server.on("upgrade", (req, socket, head) => {
|
|
10999
|
+
if (req.url === "/ws") {
|
|
11000
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
11001
|
+
handleSocket(ws, ctx);
|
|
11002
|
+
});
|
|
11003
|
+
} else {
|
|
11004
|
+
socket.destroy();
|
|
11005
|
+
}
|
|
11006
|
+
});
|
|
11007
|
+
onReleaseWebServerPort(() => {
|
|
11008
|
+
for (const client of wss.clients) client.terminate();
|
|
11009
|
+
server.close();
|
|
11010
|
+
server.closeAllConnections();
|
|
11011
|
+
});
|
|
10905
11012
|
}
|
|
10906
11013
|
|
|
10907
11014
|
// src/shared/createBundleHandler.ts
|
|
@@ -12590,6 +12697,11 @@ var seqConfigHelp = [
|
|
|
12590
12697
|
|
|
12591
12698
|
// src/commands/sessions/sessionsConfigHelp.ts
|
|
12592
12699
|
var sessionsConfigHelp = [
|
|
12700
|
+
{
|
|
12701
|
+
key: "sessions.nodeName",
|
|
12702
|
+
setter: "assist config set sessions.nodeName pc-wsl -g",
|
|
12703
|
+
note: "this install's node label, shown in the web UI header and reported by /api/health (default: OS hostname, with -wsl under WSL)"
|
|
12704
|
+
},
|
|
12593
12705
|
{
|
|
12594
12706
|
key: "sessions.windowsProjectsRoot",
|
|
12595
12707
|
setter: "assist config set sessions.windowsProjectsRoot /mnt/c/Users/you/.claude/projects",
|
|
@@ -13174,6 +13286,46 @@ function harnessCapabilities(_req, res) {
|
|
|
13174
13286
|
respondJson(res, 200, { exposeCodexActions, exposePiActions });
|
|
13175
13287
|
}
|
|
13176
13288
|
|
|
13289
|
+
// src/commands/sessions/daemon/buildHello.ts
|
|
13290
|
+
var ASSIST_VERSION = package_default.version;
|
|
13291
|
+
var PROTOCOL_VERSION = 2;
|
|
13292
|
+
function buildHello() {
|
|
13293
|
+
return { type: "hello", version: ASSIST_VERSION, protocol: PROTOCOL_VERSION };
|
|
13294
|
+
}
|
|
13295
|
+
function isHello(msg) {
|
|
13296
|
+
return msg.type === "hello" && typeof msg.version === "string" && (msg.protocol === void 0 || typeof msg.protocol === "number");
|
|
13297
|
+
}
|
|
13298
|
+
function helloCompatible(msg) {
|
|
13299
|
+
if (protocolMismatched(msg)) return false;
|
|
13300
|
+
return msg.version === ASSIST_VERSION;
|
|
13301
|
+
}
|
|
13302
|
+
function helloMismatchKind(msg) {
|
|
13303
|
+
return protocolMismatched(msg) ? "protocol" : "version";
|
|
13304
|
+
}
|
|
13305
|
+
function protocolMismatched(msg) {
|
|
13306
|
+
return typeof msg.protocol === "number" && msg.protocol !== PROTOCOL_VERSION;
|
|
13307
|
+
}
|
|
13308
|
+
|
|
13309
|
+
// src/commands/sessions/shared/resolveNodeName.ts
|
|
13310
|
+
import { hostname } from "os";
|
|
13311
|
+
function defaultNodeName(host = hostname(), platform = detectPlatform()) {
|
|
13312
|
+
const base = host.split(".")[0].toLowerCase();
|
|
13313
|
+
return platform === "wsl" ? `${base}-wsl` : base;
|
|
13314
|
+
}
|
|
13315
|
+
function resolveNodeName() {
|
|
13316
|
+
return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
|
|
13317
|
+
}
|
|
13318
|
+
|
|
13319
|
+
// src/commands/sessions/web/health.ts
|
|
13320
|
+
async function health(_req, res) {
|
|
13321
|
+
respondJson(res, 200, {
|
|
13322
|
+
nodeName: resolveNodeName(),
|
|
13323
|
+
version: ASSIST_VERSION,
|
|
13324
|
+
protocol: PROTOCOL_VERSION,
|
|
13325
|
+
daemon: { reachable: await isDaemonRunning() }
|
|
13326
|
+
});
|
|
13327
|
+
}
|
|
13328
|
+
|
|
13177
13329
|
// src/commands/sessions/web/jiraSite.ts
|
|
13178
13330
|
function jiraSite(_req, res) {
|
|
13179
13331
|
const config = loadJson("jira.json");
|
|
@@ -14431,13 +14583,15 @@ function reExecWebServer(deps2 = {}) {
|
|
|
14431
14583
|
beforeExec,
|
|
14432
14584
|
execveFn = resolveExecve(),
|
|
14433
14585
|
spawnSyncFn = spawnSync3,
|
|
14434
|
-
exit = (code) => process.exit(code)
|
|
14586
|
+
exit = (code) => process.exit(code),
|
|
14587
|
+
releasePort = releaseWebServerPort
|
|
14435
14588
|
} = deps2;
|
|
14436
14589
|
beforeExec?.();
|
|
14437
14590
|
if (execveFn) {
|
|
14438
14591
|
execveFn(process.execPath, withNoOpen(process.argv), process.env);
|
|
14439
14592
|
return;
|
|
14440
14593
|
}
|
|
14594
|
+
releasePort();
|
|
14441
14595
|
const [, ...args] = process.argv;
|
|
14442
14596
|
const result = spawnSyncFn(process.execPath, withNoOpen(args), {
|
|
14443
14597
|
stdio: "inherit"
|
|
@@ -15481,6 +15635,7 @@ var routes2 = {
|
|
|
15481
15635
|
"commands/sessions/web/monaco.css",
|
|
15482
15636
|
"text/css"
|
|
15483
15637
|
),
|
|
15638
|
+
"GET /api/health": health,
|
|
15484
15639
|
"GET /api/items": listItems,
|
|
15485
15640
|
"GET /api/backlog/summary": getBacklogSummary,
|
|
15486
15641
|
"POST /api/open-in-code": openInCode,
|
|
@@ -15523,77 +15678,6 @@ var handleRequest = createFallbackHandler(
|
|
|
15523
15678
|
handleItemRoute
|
|
15524
15679
|
);
|
|
15525
15680
|
|
|
15526
|
-
// src/commands/sessions/web/handleSocket.ts
|
|
15527
|
-
import { createInterface as createInterface4 } from "readline";
|
|
15528
|
-
var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
|
|
15529
|
-
function handleSocket(ws, ctx) {
|
|
15530
|
-
const connection = openDaemonConnection(ws, ctx);
|
|
15531
|
-
connection.catch(() => {
|
|
15532
|
-
});
|
|
15533
|
-
ws.on("message", async (msg) => {
|
|
15534
|
-
const conn = await connection.catch(() => null);
|
|
15535
|
-
conn?.write(`${withDefaultCwd(msg.toString(), ctx.serverCwd)}
|
|
15536
|
-
`);
|
|
15537
|
-
});
|
|
15538
|
-
ws.on("close", () => {
|
|
15539
|
-
void connection.then((conn) => conn.destroy()).catch(() => {
|
|
15540
|
-
});
|
|
15541
|
-
});
|
|
15542
|
-
}
|
|
15543
|
-
async function openDaemonConnection(ws, ctx) {
|
|
15544
|
-
try {
|
|
15545
|
-
await ensureDaemonRunning("web socket connection");
|
|
15546
|
-
const conn = await connectToDaemon();
|
|
15547
|
-
relayDaemonLines(conn, ws, ctx.repoCwd);
|
|
15548
|
-
return conn;
|
|
15549
|
-
} catch (error) {
|
|
15550
|
-
closeWithError(ws, error);
|
|
15551
|
-
throw error;
|
|
15552
|
-
}
|
|
15553
|
-
}
|
|
15554
|
-
function relayDaemonLines(conn, ws, repoCwd) {
|
|
15555
|
-
const lines2 = createInterface4({ input: conn });
|
|
15556
|
-
lines2.on("error", () => {
|
|
15557
|
-
});
|
|
15558
|
-
lines2.on("line", (line) => {
|
|
15559
|
-
if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
|
|
15560
|
-
});
|
|
15561
|
-
conn.on("error", () => {
|
|
15562
|
-
});
|
|
15563
|
-
conn.on("close", () => ws.close());
|
|
15564
|
-
}
|
|
15565
|
-
function closeWithError(ws, e) {
|
|
15566
|
-
if (ws.readyState !== ws.OPEN) return;
|
|
15567
|
-
ws.send(
|
|
15568
|
-
JSON.stringify({
|
|
15569
|
-
type: "error",
|
|
15570
|
-
message: `sessions daemon unavailable: ${e instanceof Error ? e.message : String(e)}`
|
|
15571
|
-
})
|
|
15572
|
-
);
|
|
15573
|
-
ws.close();
|
|
15574
|
-
}
|
|
15575
|
-
function withDefaultCwd(raw, serverCwd) {
|
|
15576
|
-
try {
|
|
15577
|
-
const data = JSON.parse(raw);
|
|
15578
|
-
if (!CWD_DEFAULTED_TYPES.has(data.type) || data.cwd) return raw;
|
|
15579
|
-
data.cwd = serverCwd;
|
|
15580
|
-
return JSON.stringify(data);
|
|
15581
|
-
} catch {
|
|
15582
|
-
return raw;
|
|
15583
|
-
}
|
|
15584
|
-
}
|
|
15585
|
-
function withRepoCwd(line, repoCwd) {
|
|
15586
|
-
if (!repoCwd) return line;
|
|
15587
|
-
try {
|
|
15588
|
-
const data = JSON.parse(line);
|
|
15589
|
-
if (data.type !== "sessions" || data.cwd) return line;
|
|
15590
|
-
data.cwd = repoCwd;
|
|
15591
|
-
return JSON.stringify(data);
|
|
15592
|
-
} catch {
|
|
15593
|
-
return line;
|
|
15594
|
-
}
|
|
15595
|
-
}
|
|
15596
|
-
|
|
15597
15681
|
// src/commands/sessions/web/restartMenu/installRestartMenu.ts
|
|
15598
15682
|
import chalk107 from "chalk";
|
|
15599
15683
|
import { createLogUpdate } from "log-update";
|
|
@@ -15873,16 +15957,7 @@ async function web(options2) {
|
|
|
15873
15957
|
serverCwd,
|
|
15874
15958
|
repoCwd: isGitRepo(serverCwd) ? repoEntryCwd(serverCwd) : void 0
|
|
15875
15959
|
};
|
|
15876
|
-
|
|
15877
|
-
server.on("upgrade", (req, socket, head) => {
|
|
15878
|
-
if (req.url === "/ws") {
|
|
15879
|
-
wss.handleUpgrade(req, socket, head, (ws) => {
|
|
15880
|
-
handleSocket(ws, ctx);
|
|
15881
|
-
});
|
|
15882
|
-
} else {
|
|
15883
|
-
socket.destroy();
|
|
15884
|
-
}
|
|
15885
|
-
});
|
|
15960
|
+
attachSessionSocket(server, ctx);
|
|
15886
15961
|
installRestartMenu();
|
|
15887
15962
|
streamDaemonLogs();
|
|
15888
15963
|
void ensureDaemonRunning("web server start").catch((error) => {
|
|
@@ -43537,26 +43612,6 @@ function handleSessions(state, msg) {
|
|
|
43537
43612
|
state.onSessionsChanged();
|
|
43538
43613
|
}
|
|
43539
43614
|
|
|
43540
|
-
// src/commands/sessions/daemon/buildHello.ts
|
|
43541
|
-
var ASSIST_VERSION = package_default.version;
|
|
43542
|
-
var PROTOCOL_VERSION = 2;
|
|
43543
|
-
function buildHello() {
|
|
43544
|
-
return { type: "hello", version: ASSIST_VERSION, protocol: PROTOCOL_VERSION };
|
|
43545
|
-
}
|
|
43546
|
-
function isHello(msg) {
|
|
43547
|
-
return msg.type === "hello" && typeof msg.version === "string" && (msg.protocol === void 0 || typeof msg.protocol === "number");
|
|
43548
|
-
}
|
|
43549
|
-
function helloCompatible(msg) {
|
|
43550
|
-
if (protocolMismatched(msg)) return false;
|
|
43551
|
-
return msg.version === ASSIST_VERSION;
|
|
43552
|
-
}
|
|
43553
|
-
function helloMismatchKind(msg) {
|
|
43554
|
-
return protocolMismatched(msg) ? "protocol" : "version";
|
|
43555
|
-
}
|
|
43556
|
-
function protocolMismatched(msg) {
|
|
43557
|
-
return typeof msg.protocol === "number" && msg.protocol !== PROTOCOL_VERSION;
|
|
43558
|
-
}
|
|
43559
|
-
|
|
43560
43615
|
// src/commands/sessions/daemon/windowsVersionCheck.ts
|
|
43561
43616
|
function windowsVersionCheck() {
|
|
43562
43617
|
return loadConfig().sessions?.windowsVersionCheck ?? "block";
|