@staff0rd/assist 0.1236.2 → 0.1238.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/allowed.cli-reads +2 -0
- package/dist/.build-files +23 -15
- package/dist/allowed.cli-reads +2 -0
- package/dist/built-version +1 -1
- package/dist/chunk-4CJXCOZS.js +39 -0
- package/dist/chunk-7NVNACAR.js +35 -0
- package/dist/{chunk-FVCGWLR4.js → chunk-LCHXB7CA.js} +1 -1
- package/dist/{chunk-NX2KZ5RW.js → chunk-MS2EANQ6.js} +2 -2
- package/dist/{chunk-S5IM25QR.js → chunk-OP4FHH2W.js} +1 -1
- package/dist/{chunk-77KP3CTK.js → chunk-OVA4KT5R.js} +1 -1
- package/dist/{chunk-HNLG7EJC.js → chunk-VDZYALRJ.js} +1 -1
- package/dist/chunk-W356VDGY.js +23 -0
- package/dist/{chunk-WDSOVOXJ.js → chunk-WSJESGWV.js} +1 -1
- package/dist/chunk-XRWFZJJI.js +17 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/{daemonStatus-EAZHBC6O.js → daemonStatus-AUHBSCVE.js} +3 -36
- package/dist/decideSession-QROGLJD6.js +132 -0
- package/dist/{doctorNodes-WP5YWRXP.js → doctorNodes-TG3ALKMC.js} +3 -3
- package/dist/index.js +56 -13
- package/dist/listSessions-7JRA3SZY.js +133 -0
- package/dist/{restartNode-YPEEQ7J6.js → restartNode-5YZL4S47.js} +5 -5
- package/dist/{runDaemon-HT3DTL32.js → runDaemon-SQCNZH6J.js} +69 -24
- package/dist/sendToSession-X4TGJVZY.js +61 -0
- package/dist/{sessionOutput-FHXQCMVC.js → sessionOutput-3QXHREND.js} +6 -14
- package/dist/sessionPreviews-KLHCZ2TA.js +77 -0
- package/dist/{signExtension-MVO3U3DE.js → signExtension-CBXKAL2O.js} +1 -1
- package/dist/{updateNode-35GYVT4L.js → updateNode-NVEQZBTI.js} +5 -5
- package/dist/{web-QJUR24JS.js → web-4Y2F3Z7X.js} +5 -5
- package/dist/{web-RFYNPA2L.js → web-KRUM2J3M.js} +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
failWith,
|
|
3
|
+
findDaemonSession
|
|
4
|
+
} from "./chunk-7NVNACAR.js";
|
|
5
|
+
import {
|
|
6
|
+
parseQuestions
|
|
7
|
+
} from "./chunk-XRWFZJJI.js";
|
|
8
|
+
import "./chunk-4CJXCOZS.js";
|
|
9
|
+
import {
|
|
10
|
+
sendToDaemon
|
|
11
|
+
} from "./chunk-V3AWLJ7P.js";
|
|
12
|
+
import {
|
|
13
|
+
CHECK_NOTE_KEY,
|
|
14
|
+
CHECK_RESULT_KEY
|
|
15
|
+
} from "./chunk-OLE7XSNB.js";
|
|
16
|
+
import "./chunk-2MG2THMQ.js";
|
|
17
|
+
import "./chunk-Q6PZLPK4.js";
|
|
18
|
+
import "./chunk-JJKKIBF5.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/sessions/previews/parseAnswers.ts
|
|
21
|
+
function questionIndex(questions, key) {
|
|
22
|
+
const k = key.trim().toLowerCase();
|
|
23
|
+
const n = Number.parseInt(k, 10);
|
|
24
|
+
if (String(n) === k && n >= 1 && n <= questions.length) return n - 1;
|
|
25
|
+
return questions.findIndex(
|
|
26
|
+
(q) => q.header.toLowerCase() === k || q.question.toLowerCase() === k
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function splitAnswer(questions, answer) {
|
|
30
|
+
const eq = answer.indexOf("=");
|
|
31
|
+
const index = eq > 0 ? questionIndex(questions, answer.slice(0, eq)) : -1;
|
|
32
|
+
if (index >= 0) return [index, answer.slice(eq + 1).trim()];
|
|
33
|
+
if (questions.length === 1) return [0, answer.trim()];
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Answer "${answer}" names no question; use <number|header>=<choice>`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function canonicalChoice(question, choice) {
|
|
39
|
+
const option = question.options.find(
|
|
40
|
+
(o) => o.label.toLowerCase() === choice.toLowerCase()
|
|
41
|
+
);
|
|
42
|
+
return option?.label ?? choice;
|
|
43
|
+
}
|
|
44
|
+
function parseAnswers(questions, answers) {
|
|
45
|
+
const chosen = questions.map(() => []);
|
|
46
|
+
for (const answer of answers) {
|
|
47
|
+
const [index, choice] = splitAnswer(questions, answer);
|
|
48
|
+
if (choice) chosen[index].push(canonicalChoice(questions[index], choice));
|
|
49
|
+
}
|
|
50
|
+
const result = {};
|
|
51
|
+
questions.forEach((q, i) => {
|
|
52
|
+
if (chosen[i].length === 0)
|
|
53
|
+
throw new Error(`No answer for question ${i + 1}: ${q.question}`);
|
|
54
|
+
if (!q.multiSelect && chosen[i].length > 1)
|
|
55
|
+
throw new Error(`Question ${i + 1} takes one answer: ${q.question}`);
|
|
56
|
+
result[q.question] = chosen[i].join(", ");
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/commands/sessions/previews/decisionFor.ts
|
|
62
|
+
function noteOf(value) {
|
|
63
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
64
|
+
}
|
|
65
|
+
function questionDecision(preview, options) {
|
|
66
|
+
if (options.reject)
|
|
67
|
+
return { decision: "reject", reason: noteOf(options.reject) };
|
|
68
|
+
const questions = parseQuestions(preview.body);
|
|
69
|
+
if (!questions) throw new Error("The pending question form is unreadable");
|
|
70
|
+
if (!options.answer?.length)
|
|
71
|
+
throw new Error("Answer a question form with --answer <choice>");
|
|
72
|
+
return {
|
|
73
|
+
decision: "approve",
|
|
74
|
+
answers: parseAnswers(questions, options.answer)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function checkDecision(options) {
|
|
78
|
+
const note = noteOf(options.approve ?? options.reject);
|
|
79
|
+
return {
|
|
80
|
+
decision: "approve",
|
|
81
|
+
answers: {
|
|
82
|
+
[CHECK_RESULT_KEY]: options.approve ? "works" : "doesn't work",
|
|
83
|
+
...note ? { [CHECK_NOTE_KEY]: note } : {}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function reviewDecision(preview, options) {
|
|
88
|
+
if (options.reject)
|
|
89
|
+
return { decision: "reject", reason: noteOf(options.reject) };
|
|
90
|
+
const note = noteOf(options.approve);
|
|
91
|
+
return {
|
|
92
|
+
decision: "approve",
|
|
93
|
+
comments: note ? [{ quote: preview.title, note }] : []
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function decisionFor(preview, options) {
|
|
97
|
+
const picked = [options.approve, options.reject].filter(Boolean).length;
|
|
98
|
+
if (picked > 1)
|
|
99
|
+
throw new Error("Pass either --approve or --reject, not both");
|
|
100
|
+
if (preview.kind === "question") return questionDecision(preview, options);
|
|
101
|
+
if (options.answer?.length)
|
|
102
|
+
throw new Error(
|
|
103
|
+
`--answer only applies to a question form; this preview is ${preview.kind ?? "pr"}`
|
|
104
|
+
);
|
|
105
|
+
if (picked === 0) throw new Error("Pass --approve [note] or --reject [note]");
|
|
106
|
+
if (preview.kind === "check") return checkDecision(options);
|
|
107
|
+
return reviewDecision(preview, options);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/commands/sessions/previews/decideSession.ts
|
|
111
|
+
async function decideSession(sessionId, options) {
|
|
112
|
+
try {
|
|
113
|
+
const preview = (await findDaemonSession(sessionId)).pendingPrPreview;
|
|
114
|
+
if (!preview)
|
|
115
|
+
throw new Error(`Session ${sessionId} has no pending preview to decide`);
|
|
116
|
+
const decision = decisionFor(preview, options);
|
|
117
|
+
await sendToDaemon({
|
|
118
|
+
type: "pr-decision",
|
|
119
|
+
sessionId,
|
|
120
|
+
requestId: preview.requestId,
|
|
121
|
+
...decision
|
|
122
|
+
});
|
|
123
|
+
console.log(
|
|
124
|
+
`${decision.decision === "approve" ? "Approved" : "Rejected"} "${preview.title}" in session ${sessionId}.`
|
|
125
|
+
);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
failWith(error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
decideSession
|
|
132
|
+
};
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
buildDoctorProbes,
|
|
11
11
|
diagnoseLink
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LCHXB7CA.js";
|
|
13
13
|
import "./chunk-VABNWHSE.js";
|
|
14
14
|
import "./chunk-DS2YJZZY.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-VDZYALRJ.js";
|
|
16
16
|
import {
|
|
17
17
|
loadLinkSpecs
|
|
18
18
|
} from "./chunk-P7QEHVJJ.js";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
detectPlatform
|
|
31
31
|
} from "./chunk-E36L7ASL.js";
|
|
32
32
|
import "./chunk-GIHVMELY.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-WSJESGWV.js";
|
|
34
34
|
import "./chunk-KRE3QQUK.js";
|
|
35
35
|
import "./chunk-XNIKOBRH.js";
|
|
36
36
|
import "./chunk-LU67AKT5.js";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./chunk-TJGF3Z72.js";
|
|
18
18
|
import {
|
|
19
19
|
package_default
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WSJESGWV.js";
|
|
21
21
|
import {
|
|
22
22
|
adviceConfigHelp,
|
|
23
23
|
askQuestionConfigHelp,
|
|
@@ -93,7 +93,7 @@ import { Command } from "commander";
|
|
|
93
93
|
// src/commands/registerRootAction.ts
|
|
94
94
|
function registerRootAction(program) {
|
|
95
95
|
program.option("--no-open", "Do not open a browser on startup").action(
|
|
96
|
-
async (options) => (await import("./web-
|
|
96
|
+
async (options) => (await import("./web-4Y2F3Z7X.js")).web({
|
|
97
97
|
port: "3100",
|
|
98
98
|
open: options.open
|
|
99
99
|
})
|
|
@@ -646,7 +646,7 @@ function registerShowCommands(cmd) {
|
|
|
646
646
|
|
|
647
647
|
// src/commands/registerBacklog.ts
|
|
648
648
|
function registerWebCommand(cmd) {
|
|
649
|
-
cmd.command("web").description("Open the backlog tab in the web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(lazyAction(() => import("./web-
|
|
649
|
+
cmd.command("web").description("Open the backlog tab in the web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(lazyAction(() => import("./web-KRUM2J3M.js"), "web"));
|
|
650
650
|
}
|
|
651
651
|
var registrars = [
|
|
652
652
|
registerItemCommands,
|
|
@@ -676,7 +676,7 @@ function registerBacklog(program) {
|
|
|
676
676
|
const { setBacklogDir } = await import("./getBacklogDir-JSH6CV34.js");
|
|
677
677
|
setBacklogDir(thisCommand.opts().dir);
|
|
678
678
|
}).action(
|
|
679
|
-
async (options) => (await import("./web-
|
|
679
|
+
async (options) => (await import("./web-KRUM2J3M.js")).web({ port: "3100", open: options.open })
|
|
680
680
|
);
|
|
681
681
|
for (const register of registrars) {
|
|
682
682
|
register(cmd);
|
|
@@ -989,7 +989,7 @@ function registerExtension(program) {
|
|
|
989
989
|
).action(async (options) => {
|
|
990
990
|
const { extension } = await import("./extension-YYRD5EM6.js");
|
|
991
991
|
const { printExtensionUrl } = await import("./printExtensionUrl-IW2WTSNS.js");
|
|
992
|
-
const { signExtension } = await import("./signExtension-
|
|
992
|
+
const { signExtension } = await import("./signExtension-CBXKAL2O.js");
|
|
993
993
|
if (options.url) return printExtensionUrl();
|
|
994
994
|
return options.sign ? signExtension() : extension();
|
|
995
995
|
});
|
|
@@ -2709,10 +2709,10 @@ function registerDaemon(program) {
|
|
|
2709
2709
|
const cmd = program.command("daemon").description("Long-lived daemon that owns web session PTYs");
|
|
2710
2710
|
cmd.command("run").description(
|
|
2711
2711
|
"Run the sessions daemon in the foreground (auto-spawned by assist sessions)"
|
|
2712
|
-
).action(lazyAction(() => import("./runDaemon-
|
|
2712
|
+
).action(lazyAction(() => import("./runDaemon-SQCNZH6J.js"), "runDaemon"));
|
|
2713
2713
|
cmd.command("status").description(
|
|
2714
2714
|
"Show sessions daemon status, live sessions, and any stray daemon processes"
|
|
2715
|
-
).action(lazyAction(() => import("./daemonStatus-
|
|
2715
|
+
).action(lazyAction(() => import("./daemonStatus-AUHBSCVE.js"), "daemonStatus"));
|
|
2716
2716
|
cmd.command("stop").description(
|
|
2717
2717
|
"Stop the sessions daemon; running claude sessions resume on next start"
|
|
2718
2718
|
).action(lazyAction(() => import("./stopDaemon-ZO5YQUME.js"), "stopDaemon"));
|
|
@@ -2733,7 +2733,7 @@ function registerDiagnoseCommands(nodes, calledBy5) {
|
|
|
2733
2733
|
nodes.command("doctor [name]").description(
|
|
2734
2734
|
"Probe each hop of every link (or one) in order and stop at the first failure with a remediation"
|
|
2735
2735
|
).option("--json", "Output as JSON").action(
|
|
2736
|
-
async (name, _options, command) => (await import("./doctorNodes-
|
|
2736
|
+
async (name, _options, command) => (await import("./doctorNodes-TG3ALKMC.js")).doctorNodes(
|
|
2737
2737
|
name,
|
|
2738
2738
|
command.optsWithGlobals()
|
|
2739
2739
|
)
|
|
@@ -2763,14 +2763,14 @@ function registerPeerActionCommands(nodes, calledBy5) {
|
|
|
2763
2763
|
internalCommand(
|
|
2764
2764
|
nodes.command("restart <name>").description(
|
|
2765
2765
|
"Restart a linked node's daemon and/or web server, wait for its link to reconnect and print its version"
|
|
2766
|
-
).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-
|
|
2766
|
+
).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-5YZL4S47.js"), "restartNode")),
|
|
2767
2767
|
calledBy5
|
|
2768
2768
|
);
|
|
2769
2769
|
internalCommand(
|
|
2770
2770
|
nodes.command("update <name>").description(
|
|
2771
2771
|
"Run assist update on a linked node, restart it, wait for its link to reconnect and print its version"
|
|
2772
2772
|
).action(
|
|
2773
|
-
async (name) => (await import("./updateNode-
|
|
2773
|
+
async (name) => (await import("./updateNode-NVEQZBTI.js")).updateNode(name)
|
|
2774
2774
|
),
|
|
2775
2775
|
calledBy5
|
|
2776
2776
|
);
|
|
@@ -2804,11 +2804,46 @@ function registerOutputCommand(cmd) {
|
|
|
2804
2804
|
).option("-n, --lines <count>", "Number of lines", "200").option(
|
|
2805
2805
|
"--server [group]",
|
|
2806
2806
|
"Read the live server run for this repo's remote and group (default: default)"
|
|
2807
|
-
).action(lazyAction(() => import("./sessionOutput-
|
|
2807
|
+
).action(lazyAction(() => import("./sessionOutput-3QXHREND.js"), "sessionOutput")),
|
|
2808
2808
|
"/run-logs"
|
|
2809
2809
|
);
|
|
2810
2810
|
}
|
|
2811
2811
|
|
|
2812
|
+
// src/commands/sessions/previews/registerPreviewCommands.ts
|
|
2813
|
+
var SESSION_ID = "Session id from assist sessions list (<node>:<id> for a linked node)";
|
|
2814
|
+
function collect7(value, previous) {
|
|
2815
|
+
return [...previous, value];
|
|
2816
|
+
}
|
|
2817
|
+
function registerPreviewCommands(cmd) {
|
|
2818
|
+
cmd.command("previews").argument("<session-id>", SESSION_ID).description(
|
|
2819
|
+
"Show a session's pending preview: kind, title, body and a question form's options"
|
|
2820
|
+
).option("--json", "Print the pending preview as JSON (null when none)").action(lazyAction(() => import("./sessionPreviews-KLHCZ2TA.js"), "sessionPreviews"));
|
|
2821
|
+
cmd.command("decide").argument("<session-id>", SESSION_ID).description(
|
|
2822
|
+
"Answer a session's pending preview, unblocking the command waiting on it"
|
|
2823
|
+
).option(
|
|
2824
|
+
"--approve [note]",
|
|
2825
|
+
"Approve (a manual check: works), optionally with a note"
|
|
2826
|
+
).option(
|
|
2827
|
+
"--reject [note]",
|
|
2828
|
+
"Reject with a reason (a manual check: doesn't work; a question form: decline)"
|
|
2829
|
+
).option(
|
|
2830
|
+
"--answer <choice>",
|
|
2831
|
+
"Answer a question form: <number|header>=<option label or own text>, or just <choice> for a single question; repeat per question or multi-select choice",
|
|
2832
|
+
collect7,
|
|
2833
|
+
[]
|
|
2834
|
+
).action(lazyAction(() => import("./decideSession-QROGLJD6.js"), "decideSession"));
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
// src/commands/sessions/registerSendCommand.ts
|
|
2838
|
+
function registerSendCommand(cmd) {
|
|
2839
|
+
cmd.command("send <id> <text>").description(
|
|
2840
|
+
"Submit a prompt in a session (an id from assist sessions list, <node>:<id> for a linked node)"
|
|
2841
|
+
).option(
|
|
2842
|
+
"--keys",
|
|
2843
|
+
String.raw`Send <text> as raw keystrokes instead of a prompt; \r, \n, \t, \e and \xHH are decoded (e.g. '1\r' answers a permission prompt)`
|
|
2844
|
+
).action(lazyAction(() => import("./sendToSession-X4TGJVZY.js"), "sendToSession"));
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2812
2847
|
// src/commands/sessions/registerSetStatusCommand.ts
|
|
2813
2848
|
function registerSetStatusCommand(cmd) {
|
|
2814
2849
|
internalCommand(
|
|
@@ -2833,7 +2868,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
2833
2868
|
// src/commands/sessions/registerSessionsWeb.ts
|
|
2834
2869
|
function registerSessionsWeb(cmd) {
|
|
2835
2870
|
const webCmd = cmd.command("web").description("Start the sessions web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(
|
|
2836
|
-
async (options, command) => (await import("./web-
|
|
2871
|
+
async (options, command) => (await import("./web-4Y2F3Z7X.js")).web({
|
|
2837
2872
|
...options,
|
|
2838
2873
|
open: command.optsWithGlobals().open
|
|
2839
2874
|
})
|
|
@@ -2848,7 +2883,7 @@ function registerSessionsWeb(cmd) {
|
|
|
2848
2883
|
// src/commands/sessions/registerSessions.ts
|
|
2849
2884
|
function registerSessions(program) {
|
|
2850
2885
|
const cmd = program.command("sessions").description("Web dashboard for coding agent sessions").option("--no-open", "Do not open a browser on startup").action(
|
|
2851
|
-
async (_options, command) => (await import("./web-
|
|
2886
|
+
async (_options, command) => (await import("./web-4Y2F3Z7X.js")).web({
|
|
2852
2887
|
port: "3100",
|
|
2853
2888
|
open: command.optsWithGlobals().open
|
|
2854
2889
|
})
|
|
@@ -2866,7 +2901,15 @@ function registerSessions(program) {
|
|
|
2866
2901
|
).action(lazyAction(() => import("./renameSession-6OCEPFKV.js"), "renameSession")),
|
|
2867
2902
|
"/rename"
|
|
2868
2903
|
);
|
|
2904
|
+
cmd.command("list").description(
|
|
2905
|
+
"List every session on this node and linked nodes, with the ids other sessions commands accept"
|
|
2906
|
+
).option("--json", "Print the sessions as JSON").option(
|
|
2907
|
+
"--node <name>",
|
|
2908
|
+
"Only list sessions on this node (local for this one)"
|
|
2909
|
+
).action(lazyAction(() => import("./listSessions-7JRA3SZY.js"), "listSessions"));
|
|
2869
2910
|
registerOutputCommand(cmd);
|
|
2911
|
+
registerPreviewCommands(cmd);
|
|
2912
|
+
registerSendCommand(cmd);
|
|
2870
2913
|
registerSetStatusCommand(cmd);
|
|
2871
2914
|
registerNodes(cmd);
|
|
2872
2915
|
configHelp(cmd, [...sessionsConfigHelp, ...harnessDefaultsConfigHelp]);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
queryDaemon
|
|
3
|
+
} from "./chunk-4CJXCOZS.js";
|
|
4
|
+
import {
|
|
5
|
+
harnesses
|
|
6
|
+
} from "./chunk-EOOPPGMZ.js";
|
|
7
|
+
import {
|
|
8
|
+
connectToDaemon
|
|
9
|
+
} from "./chunk-Q6PZLPK4.js";
|
|
10
|
+
import "./chunk-JJKKIBF5.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/sessions/list/formatSessionRows.ts
|
|
13
|
+
var HEADERS = [
|
|
14
|
+
"ID",
|
|
15
|
+
"KIND",
|
|
16
|
+
"STATUS",
|
|
17
|
+
"NODE",
|
|
18
|
+
"REPO/BRANCH",
|
|
19
|
+
"AGENT",
|
|
20
|
+
"TITLE"
|
|
21
|
+
];
|
|
22
|
+
function cells(row) {
|
|
23
|
+
const repo = [row.repo, row.branch].filter(Boolean).join("/");
|
|
24
|
+
return [
|
|
25
|
+
row.id,
|
|
26
|
+
row.kind,
|
|
27
|
+
row.status,
|
|
28
|
+
row.node,
|
|
29
|
+
repo || "-",
|
|
30
|
+
row.agentName ?? "-",
|
|
31
|
+
row.title
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function formatSessionRows(rows) {
|
|
35
|
+
const table = [HEADERS, ...rows.map(cells)];
|
|
36
|
+
const widths = HEADERS.map(
|
|
37
|
+
(_, i) => Math.max(...table.map((r) => r[i].length))
|
|
38
|
+
);
|
|
39
|
+
return table.map(
|
|
40
|
+
(r) => r.map((cell, i) => i === r.length - 1 ? cell : cell.padEnd(widths[i])).join(" ")
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/commands/sessions/list/readAgentNames.ts
|
|
45
|
+
import * as fs from "fs";
|
|
46
|
+
import * as path from "path";
|
|
47
|
+
function readAgentNames(dir = path.join(harnesses.claude.homeDir, "sessions")) {
|
|
48
|
+
const names = /* @__PURE__ */ new Map();
|
|
49
|
+
let files;
|
|
50
|
+
try {
|
|
51
|
+
files = fs.readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
52
|
+
} catch {
|
|
53
|
+
return names;
|
|
54
|
+
}
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
try {
|
|
57
|
+
const data = JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
|
|
58
|
+
if (typeof data.sessionId === "string" && typeof data.name === "string")
|
|
59
|
+
names.set(data.sessionId, data.name);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return names;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/commands/sessions/list/readBranch.ts
|
|
67
|
+
import { execFileSync } from "child_process";
|
|
68
|
+
function readBranch(cwd) {
|
|
69
|
+
try {
|
|
70
|
+
const branch = execFileSync(
|
|
71
|
+
"git",
|
|
72
|
+
["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"],
|
|
73
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 2e3 }
|
|
74
|
+
).trim();
|
|
75
|
+
return branch && branch !== "HEAD" ? branch : void 0;
|
|
76
|
+
} catch {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/commands/sessions/list/toSessionRow.ts
|
|
82
|
+
var LOCAL_NODE = "local";
|
|
83
|
+
function sessionKind(session) {
|
|
84
|
+
if (session.server) return "server";
|
|
85
|
+
return session.commandType === "run" ? "run" : "agent";
|
|
86
|
+
}
|
|
87
|
+
function repoName(origin) {
|
|
88
|
+
return origin?.replace(/\.git$/, "").split(/[/:]/).filter(Boolean).pop();
|
|
89
|
+
}
|
|
90
|
+
function toSessionRow(session, { agentNames, branchOf }) {
|
|
91
|
+
const local = !session.node;
|
|
92
|
+
const harnessId = session.claudeSessionId ?? session.harnessSessionId;
|
|
93
|
+
return {
|
|
94
|
+
id: session.id,
|
|
95
|
+
kind: sessionKind(session),
|
|
96
|
+
status: session.status,
|
|
97
|
+
node: session.node ?? LOCAL_NODE,
|
|
98
|
+
repo: repoName(session.repoGroup?.origin),
|
|
99
|
+
branch: local && session.cwd ? branchOf(session.cwd) : void 0,
|
|
100
|
+
title: session.title ?? session.generatedTitle ?? session.name,
|
|
101
|
+
agentName: local && harnessId ? agentNames.get(harnessId) : void 0
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/commands/sessions/list/listSessions.ts
|
|
106
|
+
async function listSessions(options) {
|
|
107
|
+
let socket;
|
|
108
|
+
try {
|
|
109
|
+
socket = await connectToDaemon();
|
|
110
|
+
} catch {
|
|
111
|
+
console.error("No sessions daemon is running");
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const { sessions } = await queryDaemon(socket);
|
|
116
|
+
socket.destroy();
|
|
117
|
+
const lookups = { agentNames: readAgentNames(), branchOf: readBranch };
|
|
118
|
+
const rows = sessions.map((session) => toSessionRow(session, lookups)).filter((row) => !options.node || row.node === options.node);
|
|
119
|
+
if (options.json) {
|
|
120
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (rows.length === 0) {
|
|
124
|
+
console.log(
|
|
125
|
+
options.node ? `No sessions on ${options.node}` : "No sessions"
|
|
126
|
+
);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
for (const line of formatSessionRows(rows)) console.log(line);
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
listSessions
|
|
133
|
+
};
|
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
linkStatus,
|
|
3
3
|
postToPeer,
|
|
4
4
|
startPeerAction
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-OP4FHH2W.js";
|
|
6
|
+
import "./chunk-OVA4KT5R.js";
|
|
7
|
+
import "./chunk-LCHXB7CA.js";
|
|
8
8
|
import "./chunk-VABNWHSE.js";
|
|
9
9
|
import "./chunk-DS2YJZZY.js";
|
|
10
10
|
import "./chunk-4HKB2TAG.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-VDZYALRJ.js";
|
|
12
12
|
import "./chunk-P7QEHVJJ.js";
|
|
13
13
|
import "./chunk-MKBZCWWG.js";
|
|
14
14
|
import "./chunk-B7VOTF5Q.js";
|
|
15
15
|
import "./chunk-E36L7ASL.js";
|
|
16
16
|
import "./chunk-5H7EHZ3J.js";
|
|
17
17
|
import "./chunk-GIHVMELY.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-WSJESGWV.js";
|
|
19
19
|
import "./chunk-XNIKOBRH.js";
|
|
20
20
|
import "./chunk-LU67AKT5.js";
|
|
21
21
|
import "./chunk-GRXFWFGP.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseQuestions
|
|
3
|
+
} from "./chunk-XRWFZJJI.js";
|
|
1
4
|
import {
|
|
2
5
|
cleanLeftoversEnabled,
|
|
3
6
|
currentDeclared,
|
|
@@ -131,7 +134,7 @@ import {
|
|
|
131
134
|
isHello,
|
|
132
135
|
linkVersionCheck,
|
|
133
136
|
negotiateProtocol
|
|
134
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-VDZYALRJ.js";
|
|
135
138
|
import {
|
|
136
139
|
loadLinkSpecs
|
|
137
140
|
} from "./chunk-P7QEHVJJ.js";
|
|
@@ -274,7 +277,7 @@ import {
|
|
|
274
277
|
import "./chunk-APZ6ZTDA.js";
|
|
275
278
|
import "./chunk-K4DJEFDZ.js";
|
|
276
279
|
import "./chunk-D7UZLH36.js";
|
|
277
|
-
import "./chunk-
|
|
280
|
+
import "./chunk-WSJESGWV.js";
|
|
278
281
|
import "./chunk-EW2ZM2PC.js";
|
|
279
282
|
import "./chunk-OTSOBFW2.js";
|
|
280
283
|
import {
|
|
@@ -2988,6 +2991,18 @@ function flushPendingPrompts(session, write) {
|
|
|
2988
2991
|
return true;
|
|
2989
2992
|
}
|
|
2990
2993
|
|
|
2994
|
+
// src/commands/sessions/daemon/typeKeysIntoSession.ts
|
|
2995
|
+
function typeKeysIntoSession(sessions, id, keys, write) {
|
|
2996
|
+
const session = sessions.get(id);
|
|
2997
|
+
if (!session)
|
|
2998
|
+
return { ok: false, message: `assist session ${id} was not found` };
|
|
2999
|
+
if (session.status === "done" || !session.pty)
|
|
3000
|
+
return { ok: false, message: `assist session ${id} has ended` };
|
|
3001
|
+
write(id, keys);
|
|
3002
|
+
daemonLog(`session ${id} typed keys: ${JSON.stringify(keys)}`);
|
|
3003
|
+
return { ok: true, message: `Sent keys to assist session ${id}` };
|
|
3004
|
+
}
|
|
3005
|
+
|
|
2991
3006
|
// src/commands/sessions/daemon/typePromptIntoSession.ts
|
|
2992
3007
|
function typePromptIntoSession(sessions, id, text, write) {
|
|
2993
3008
|
const session = sessions.get(id);
|
|
@@ -3216,6 +3231,9 @@ var SessionIo = class {
|
|
|
3216
3231
|
if ("queued" in result && result.queued) this.notify();
|
|
3217
3232
|
return typePromptReply(id, result);
|
|
3218
3233
|
}
|
|
3234
|
+
typeKeys(id, keys) {
|
|
3235
|
+
return typeKeysIntoSession(this.sessions, id, keys, this.writeAsDaemon);
|
|
3236
|
+
}
|
|
3219
3237
|
async typePromptToLastWriter(target, text) {
|
|
3220
3238
|
const id = await findDocsSession(this.sessions, target);
|
|
3221
3239
|
if (!id)
|
|
@@ -5186,14 +5204,6 @@ function midPlanCheckAnswers(body) {
|
|
|
5186
5204
|
|
|
5187
5205
|
// src/commands/sessions/daemon/recommendedAnswers.ts
|
|
5188
5206
|
var RECOMMENDED = "(Recommended)";
|
|
5189
|
-
function parseQuestions(body) {
|
|
5190
|
-
try {
|
|
5191
|
-
const parsed = askQuestionInputSchema.safeParse(JSON.parse(body));
|
|
5192
|
-
return parsed.success ? parsed.data.questions : void 0;
|
|
5193
|
-
} catch {
|
|
5194
|
-
return void 0;
|
|
5195
|
-
}
|
|
5196
|
-
}
|
|
5197
5207
|
function recommendedAnswers(body) {
|
|
5198
5208
|
const questions = parseQuestions(body);
|
|
5199
5209
|
if (!questions) return void 0;
|
|
@@ -8436,6 +8446,7 @@ var relays = {
|
|
|
8436
8446
|
"session-transcript": relayWithNodeSessionId,
|
|
8437
8447
|
transcript: relayReply,
|
|
8438
8448
|
dequeued: relayReply,
|
|
8449
|
+
"type-prompt-result": relayReply,
|
|
8439
8450
|
limits: (state, msg) => state.onLimits(
|
|
8440
8451
|
msg.harness,
|
|
8441
8452
|
msg.rateLimits
|
|
@@ -9972,7 +9983,7 @@ var handleDismiss = routed((_client, m, d) => {
|
|
|
9972
9983
|
m.dismissSession(d.sessionId, closeServerRuns);
|
|
9973
9984
|
});
|
|
9974
9985
|
|
|
9975
|
-
// src/commands/sessions/daemon/links/
|
|
9986
|
+
// src/commands/sessions/daemon/links/routeToLinkedSession.ts
|
|
9976
9987
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9977
9988
|
function unavailable(links, node) {
|
|
9978
9989
|
const status = links.nodes().links.find((link) => link.name === node);
|
|
@@ -9982,25 +9993,31 @@ function unavailable(links, node) {
|
|
|
9982
9993
|
const detail = status.error ? `: ${status.error}` : "";
|
|
9983
9994
|
return `${node} link is ${status.state}${detail}; run assist sessions nodes doctor ${node}`;
|
|
9984
9995
|
}
|
|
9985
|
-
function
|
|
9996
|
+
function routeToLinkedSession(client, links, data, refusal) {
|
|
9986
9997
|
const sessionId = data.sessionId;
|
|
9987
|
-
|
|
9998
|
+
if (typeof sessionId !== "string") return data;
|
|
9999
|
+
const split = splitNodeSessionId(sessionId);
|
|
9988
10000
|
if (!split) return data;
|
|
9989
10001
|
if (split.node === links.localNode()) return { ...data, sessionId: split.id };
|
|
9990
10002
|
const reason6 = unavailable(links, split.node);
|
|
9991
10003
|
if (reason6) {
|
|
9992
|
-
daemonLog(
|
|
9993
|
-
sendTo(client,
|
|
9994
|
-
type: "session-output",
|
|
9995
|
-
sessionId,
|
|
9996
|
-
error: `Cannot read session ${sessionId}: ${reason6}`
|
|
9997
|
-
});
|
|
10004
|
+
daemonLog(`${data.type} requested: id=${sessionId} ${reason6}`);
|
|
10005
|
+
sendTo(client, refusal(sessionId, reason6));
|
|
9998
10006
|
return void 0;
|
|
9999
10007
|
}
|
|
10000
10008
|
links.route(client, { ...data, requestId: data.requestId ?? randomUUID2() });
|
|
10001
10009
|
return void 0;
|
|
10002
10010
|
}
|
|
10003
10011
|
|
|
10012
|
+
// src/commands/sessions/daemon/links/routeOutputToLink.ts
|
|
10013
|
+
function routeOutputToLink(client, links, data) {
|
|
10014
|
+
return routeToLinkedSession(client, links, data, (sessionId, reason6) => ({
|
|
10015
|
+
type: "session-output",
|
|
10016
|
+
sessionId,
|
|
10017
|
+
error: `Cannot read session ${sessionId}: ${reason6}`
|
|
10018
|
+
}));
|
|
10019
|
+
}
|
|
10020
|
+
|
|
10004
10021
|
// src/commands/sessions/daemon/latestServerRun.ts
|
|
10005
10022
|
function latestServerRun(sessions, origin, group) {
|
|
10006
10023
|
const live = liveServerRun(sessions, { server: true, origin, group });
|
|
@@ -10113,12 +10130,39 @@ function handleSetStatus(client, m, d) {
|
|
|
10113
10130
|
// src/commands/sessions/daemon/handleSubscribeLogs.ts
|
|
10114
10131
|
var handleSubscribeLogs = (client, m, d) => m.clients.subscribeLogs(client, d.replay !== false, d.webServer === true);
|
|
10115
10132
|
|
|
10133
|
+
// src/commands/sessions/daemon/typeIntoSessionHandler.ts
|
|
10134
|
+
function typeIntoSessionHandler(label, typeInto) {
|
|
10135
|
+
return (client, m, request) => {
|
|
10136
|
+
const requestId = request.requestId;
|
|
10137
|
+
const d = routeToLinkedSession(
|
|
10138
|
+
client,
|
|
10139
|
+
m.links,
|
|
10140
|
+
request,
|
|
10141
|
+
(sessionId, reason6) => ({
|
|
10142
|
+
type: "type-prompt-result",
|
|
10143
|
+
ok: false,
|
|
10144
|
+
message: `Cannot reach session ${sessionId}: ${reason6}`,
|
|
10145
|
+
requestId
|
|
10146
|
+
})
|
|
10147
|
+
);
|
|
10148
|
+
if (!d) return;
|
|
10149
|
+
const reply = typeInto(m, String(d.sessionId), String(d.text ?? ""));
|
|
10150
|
+
if (!reply.ok) daemonLog(`${label} refused: ${reply.message}`);
|
|
10151
|
+
sendTo(client, { type: "type-prompt-result", ...reply, requestId });
|
|
10152
|
+
};
|
|
10153
|
+
}
|
|
10154
|
+
|
|
10155
|
+
// src/commands/sessions/daemon/handleTypeKeys.ts
|
|
10156
|
+
var handleTypeKeys = typeIntoSessionHandler(
|
|
10157
|
+
"type-keys",
|
|
10158
|
+
(m, id, keys) => m.io.typeKeys(id, keys)
|
|
10159
|
+
);
|
|
10160
|
+
|
|
10116
10161
|
// src/commands/sessions/daemon/handleTypePrompt.ts
|
|
10117
|
-
var handleTypePrompt = (
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
};
|
|
10162
|
+
var handleTypePrompt = typeIntoSessionHandler(
|
|
10163
|
+
"type-prompt",
|
|
10164
|
+
(m, id, text) => m.io.typePrompt(id, text)
|
|
10165
|
+
);
|
|
10122
10166
|
|
|
10123
10167
|
// src/commands/sessions/daemon/handleTypePromptToWriter.ts
|
|
10124
10168
|
var handleTypePromptToWriter = (client, m, d) => {
|
|
@@ -11080,6 +11124,7 @@ var messageHandlers = {
|
|
|
11080
11124
|
...viewerHandlers,
|
|
11081
11125
|
...pinHandlers,
|
|
11082
11126
|
"type-prompt": handleTypePrompt,
|
|
11127
|
+
"type-keys": handleTypeKeys,
|
|
11083
11128
|
"sdk-launch": handleSdkLaunch,
|
|
11084
11129
|
"sdk-shell": handleSdkShell,
|
|
11085
11130
|
"sdk-shell-stop": handleSdkShellStop,
|