@staff0rd/assist 0.193.1 → 0.194.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/dist/commands/sessions/web/bundle.js +20 -20
- package/dist/index.js +82 -53
- 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.194.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -12446,6 +12446,45 @@ var routes3 = {
|
|
|
12446
12446
|
var handleRequest3 = createFallbackHandler(routes3, htmlHandler2);
|
|
12447
12447
|
|
|
12448
12448
|
// src/commands/sessions/web/handleSocket.ts
|
|
12449
|
+
function dispatch(ws, manager, data) {
|
|
12450
|
+
switch (data.type) {
|
|
12451
|
+
case "create": {
|
|
12452
|
+
const id = manager.spawn(
|
|
12453
|
+
data.prompt,
|
|
12454
|
+
data.cwd
|
|
12455
|
+
);
|
|
12456
|
+
ws.send(JSON.stringify({ type: "created", sessionId: id }));
|
|
12457
|
+
break;
|
|
12458
|
+
}
|
|
12459
|
+
case "input":
|
|
12460
|
+
manager.writeToSession(data.sessionId, data.data);
|
|
12461
|
+
break;
|
|
12462
|
+
case "resize":
|
|
12463
|
+
manager.resizeSession(
|
|
12464
|
+
data.sessionId,
|
|
12465
|
+
data.cols,
|
|
12466
|
+
data.rows
|
|
12467
|
+
);
|
|
12468
|
+
break;
|
|
12469
|
+
case "resume": {
|
|
12470
|
+
const id = manager.resume(
|
|
12471
|
+
data.sessionId,
|
|
12472
|
+
data.cwd,
|
|
12473
|
+
data.name
|
|
12474
|
+
);
|
|
12475
|
+
ws.send(JSON.stringify({ type: "created", sessionId: id }));
|
|
12476
|
+
break;
|
|
12477
|
+
}
|
|
12478
|
+
case "dismiss":
|
|
12479
|
+
manager.dismissSession(data.sessionId);
|
|
12480
|
+
break;
|
|
12481
|
+
case "history":
|
|
12482
|
+
manager.getHistory().then((history) => {
|
|
12483
|
+
ws.send(JSON.stringify({ type: "history", sessions: history }));
|
|
12484
|
+
});
|
|
12485
|
+
break;
|
|
12486
|
+
}
|
|
12487
|
+
}
|
|
12449
12488
|
function handleSocket(ws, manager) {
|
|
12450
12489
|
manager.addClient(ws);
|
|
12451
12490
|
ws.on("message", (msg) => {
|
|
@@ -12455,40 +12494,7 @@ function handleSocket(ws, manager) {
|
|
|
12455
12494
|
} catch {
|
|
12456
12495
|
return;
|
|
12457
12496
|
}
|
|
12458
|
-
|
|
12459
|
-
case "create": {
|
|
12460
|
-
const id = manager.spawn(data.prompt);
|
|
12461
|
-
ws.send(JSON.stringify({ type: "created", sessionId: id }));
|
|
12462
|
-
break;
|
|
12463
|
-
}
|
|
12464
|
-
case "input":
|
|
12465
|
-
manager.writeToSession(data.sessionId, data.data);
|
|
12466
|
-
break;
|
|
12467
|
-
case "resize":
|
|
12468
|
-
manager.resizeSession(
|
|
12469
|
-
data.sessionId,
|
|
12470
|
-
data.cols,
|
|
12471
|
-
data.rows
|
|
12472
|
-
);
|
|
12473
|
-
break;
|
|
12474
|
-
case "resume": {
|
|
12475
|
-
const id = manager.resume(
|
|
12476
|
-
data.sessionId,
|
|
12477
|
-
data.cwd,
|
|
12478
|
-
data.name
|
|
12479
|
-
);
|
|
12480
|
-
ws.send(JSON.stringify({ type: "created", sessionId: id }));
|
|
12481
|
-
break;
|
|
12482
|
-
}
|
|
12483
|
-
case "dismiss":
|
|
12484
|
-
manager.dismissSession(data.sessionId);
|
|
12485
|
-
break;
|
|
12486
|
-
case "history":
|
|
12487
|
-
manager.getHistory().then((history) => {
|
|
12488
|
-
ws.send(JSON.stringify({ type: "history", sessions: history }));
|
|
12489
|
-
});
|
|
12490
|
-
break;
|
|
12491
|
-
}
|
|
12497
|
+
dispatch(ws, manager, data);
|
|
12492
12498
|
});
|
|
12493
12499
|
ws.on("close", () => {
|
|
12494
12500
|
manager.removeClient(ws);
|
|
@@ -12520,13 +12526,13 @@ function shellEscape(s) {
|
|
|
12520
12526
|
}
|
|
12521
12527
|
|
|
12522
12528
|
// src/commands/sessions/web/createSession.ts
|
|
12523
|
-
function createSession(id, prompt) {
|
|
12529
|
+
function createSession(id, prompt, cwd) {
|
|
12524
12530
|
return {
|
|
12525
12531
|
id,
|
|
12526
12532
|
name: prompt?.slice(0, 40) || `Session ${id}`,
|
|
12527
12533
|
status: "running",
|
|
12528
12534
|
startedAt: Date.now(),
|
|
12529
|
-
pty: spawnClaude2({ prompt }),
|
|
12535
|
+
pty: spawnClaude2({ prompt, cwd }),
|
|
12530
12536
|
scrollback: "",
|
|
12531
12537
|
idleTimer: null,
|
|
12532
12538
|
lastResizeAt: 0
|
|
@@ -12702,14 +12708,47 @@ function wirePtyEvents(session, clients, onStatusChange) {
|
|
|
12702
12708
|
});
|
|
12703
12709
|
}
|
|
12704
12710
|
|
|
12711
|
+
// src/commands/sessions/web/writeToSession.ts
|
|
12712
|
+
function writeToSession(sessions, id, data) {
|
|
12713
|
+
const s = sessions.get(id);
|
|
12714
|
+
if (s && s.status !== "done") s.pty.write(data);
|
|
12715
|
+
}
|
|
12716
|
+
function resizeSession(sessions, id, cols, rows) {
|
|
12717
|
+
const s = sessions.get(id);
|
|
12718
|
+
if (s && s.status !== "done") {
|
|
12719
|
+
s.lastResizeAt = Date.now();
|
|
12720
|
+
s.pty.resize(cols, rows);
|
|
12721
|
+
}
|
|
12722
|
+
}
|
|
12723
|
+
function dismissSession(sessions, id) {
|
|
12724
|
+
const s = sessions.get(id);
|
|
12725
|
+
if (!s) return false;
|
|
12726
|
+
if (s.status !== "done") s.pty.kill();
|
|
12727
|
+
clearIdle(s);
|
|
12728
|
+
sessions.delete(id);
|
|
12729
|
+
return true;
|
|
12730
|
+
}
|
|
12731
|
+
|
|
12705
12732
|
// src/commands/sessions/web/SessionManager.ts
|
|
12706
12733
|
var SessionManager = class {
|
|
12707
12734
|
sessions = /* @__PURE__ */ new Map();
|
|
12708
12735
|
clients = /* @__PURE__ */ new Set();
|
|
12709
12736
|
nextId = 1;
|
|
12737
|
+
repoCwd;
|
|
12738
|
+
constructor() {
|
|
12739
|
+
const cwd = process.cwd();
|
|
12740
|
+
this.repoCwd = isGitRepo(cwd) ? cwd : void 0;
|
|
12741
|
+
}
|
|
12710
12742
|
addClient(ws) {
|
|
12711
12743
|
this.clients.add(ws);
|
|
12712
|
-
wsSend(ws, {
|
|
12744
|
+
wsSend(ws, {
|
|
12745
|
+
type: "sessions",
|
|
12746
|
+
cwd: this.repoCwd,
|
|
12747
|
+
sessions: this.listSessions()
|
|
12748
|
+
});
|
|
12749
|
+
this.replayScrollback(ws);
|
|
12750
|
+
}
|
|
12751
|
+
replayScrollback(ws) {
|
|
12713
12752
|
for (const s of this.sessions.values()) {
|
|
12714
12753
|
if (s.scrollback)
|
|
12715
12754
|
wsSend(ws, { type: "output", sessionId: s.id, data: s.scrollback });
|
|
@@ -12718,9 +12757,9 @@ var SessionManager = class {
|
|
|
12718
12757
|
removeClient(ws) {
|
|
12719
12758
|
this.clients.delete(ws);
|
|
12720
12759
|
}
|
|
12721
|
-
spawn(prompt) {
|
|
12760
|
+
spawn(prompt, cwd) {
|
|
12722
12761
|
const id = String(this.nextId++);
|
|
12723
|
-
const session = createSession(id, prompt);
|
|
12762
|
+
const session = createSession(id, prompt, cwd);
|
|
12724
12763
|
this.wire(session);
|
|
12725
12764
|
return id;
|
|
12726
12765
|
}
|
|
@@ -12743,23 +12782,13 @@ var SessionManager = class {
|
|
|
12743
12782
|
this.notify();
|
|
12744
12783
|
}
|
|
12745
12784
|
writeToSession(id, data) {
|
|
12746
|
-
|
|
12747
|
-
if (s && s.status !== "done") s.pty.write(data);
|
|
12785
|
+
writeToSession(this.sessions, id, data);
|
|
12748
12786
|
}
|
|
12749
12787
|
resizeSession(id, cols, rows) {
|
|
12750
|
-
|
|
12751
|
-
if (s && s.status !== "done") {
|
|
12752
|
-
s.lastResizeAt = Date.now();
|
|
12753
|
-
s.pty.resize(cols, rows);
|
|
12754
|
-
}
|
|
12788
|
+
resizeSession(this.sessions, id, cols, rows);
|
|
12755
12789
|
}
|
|
12756
12790
|
dismissSession(id) {
|
|
12757
|
-
|
|
12758
|
-
if (!s) return;
|
|
12759
|
-
if (s.status !== "done") s.pty.kill();
|
|
12760
|
-
clearIdle(s);
|
|
12761
|
-
this.sessions.delete(id);
|
|
12762
|
-
this.notify();
|
|
12791
|
+
if (dismissSession(this.sessions, id)) this.notify();
|
|
12763
12792
|
}
|
|
12764
12793
|
listSessions() {
|
|
12765
12794
|
return [...this.sessions.values()].map(
|