@staff0rd/assist 0.1236.2 → 0.1239.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.
Files changed (36) hide show
  1. package/allowed.cli-reads +2 -0
  2. package/dist/.build-files +27 -17
  3. package/dist/allowed.cli-reads +2 -0
  4. package/dist/built-version +1 -1
  5. package/dist/chunk-2ZTFSV2Z.js +50 -0
  6. package/dist/chunk-4CJXCOZS.js +39 -0
  7. package/dist/{chunk-HNLG7EJC.js → chunk-6AGXBSZL.js} +1 -1
  8. package/dist/chunk-7NVNACAR.js +35 -0
  9. package/dist/{chunk-WDSOVOXJ.js → chunk-HZDILABA.js} +1 -1
  10. package/dist/{chunk-S5IM25QR.js → chunk-JJOJ6NNT.js} +1 -1
  11. package/dist/chunk-W356VDGY.js +23 -0
  12. package/dist/{chunk-77KP3CTK.js → chunk-WEPXPOIF.js} +1 -1
  13. package/dist/chunk-XRWFZJJI.js +17 -0
  14. package/dist/{chunk-FVCGWLR4.js → chunk-ZHJV36LY.js} +1 -1
  15. package/dist/{chunk-NX2KZ5RW.js → chunk-ZONDAPT5.js} +2 -2
  16. package/dist/closeSession-CBSNK2SH.js +22 -0
  17. package/dist/commands/sessions/web/bundle.js +1 -1
  18. package/dist/{daemonStatus-EAZHBC6O.js → daemonStatus-AUHBSCVE.js} +3 -36
  19. package/dist/decideSession-QROGLJD6.js +132 -0
  20. package/dist/{doctorNodes-WP5YWRXP.js → doctorNodes-GLIMPERP.js} +3 -3
  21. package/dist/index.js +84 -25
  22. package/dist/interruptSession-B56EN6OH.js +27 -0
  23. package/dist/listSessions-7JRA3SZY.js +133 -0
  24. package/dist/renameSession-ZLYZCMBB.js +22 -0
  25. package/dist/{restartNode-YPEEQ7J6.js → restartNode-6R435AUB.js} +5 -5
  26. package/dist/{runDaemon-HT3DTL32.js → runDaemon-L2ZIIRVP.js} +69 -24
  27. package/dist/sendToSession-X4TGJVZY.js +61 -0
  28. package/dist/{sessionOutput-FHXQCMVC.js → sessionOutput-3QXHREND.js} +6 -14
  29. package/dist/sessionPreviews-KLHCZ2TA.js +77 -0
  30. package/dist/{signExtension-MVO3U3DE.js → signExtension-RDBHLWQM.js} +1 -1
  31. package/dist/{updateNode-35GYVT4L.js → updateNode-O7N2QLQM.js} +5 -5
  32. package/dist/{web-RFYNPA2L.js → web-TNX4IOCH.js} +5 -5
  33. package/dist/{web-QJUR24JS.js → web-WY2S2A24.js} +5 -5
  34. package/package.json +1 -1
  35. package/dist/closeSession-ECJ6TFRX.js +0 -30
  36. package/dist/renameSession-6OCEPFKV.js +0 -30
@@ -1,3 +1,6 @@
1
+ import {
2
+ queryDaemon
3
+ } from "./chunk-4CJXCOZS.js";
1
4
  import {
2
5
  formatLink
3
6
  } from "./chunk-6G2ADBNV.js";
@@ -27,42 +30,6 @@ function listDaemonPids() {
27
30
  }
28
31
  }
29
32
 
30
- // src/commands/sessions/daemon/queryDaemon.ts
31
- import { createInterface } from "readline";
32
- var STATUS_TIMEOUT_MS = 5e3;
33
- function queryDaemon(socket) {
34
- socket.write(`${JSON.stringify({ type: "ping" })}
35
- `);
36
- return new Promise((resolve) => {
37
- const result = { sessions: [] };
38
- const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
39
- const timer = setTimeout(() => resolve(result), STATUS_TIMEOUT_MS);
40
- const lines = createInterface({ input: socket });
41
- lines.on("error", () => {
42
- });
43
- lines.on("line", (line) => {
44
- applyLine(result, pending, line);
45
- if (pending.size === 0) {
46
- clearTimeout(timer);
47
- resolve(result);
48
- }
49
- });
50
- });
51
- }
52
- function applyLine(result, pending, line) {
53
- try {
54
- const data = JSON.parse(line);
55
- if (data.type === "sessions") {
56
- result.sessions = data.sessions ?? [];
57
- pending.delete("sessions");
58
- } else if (data.type === "pong") {
59
- result.pid = data.pid;
60
- pending.delete("pong");
61
- }
62
- } catch {
63
- }
64
- }
65
-
66
33
  // src/commands/sessions/daemon/reportStolenSocket.ts
67
34
  function reportStolenSocket(socketPid) {
68
35
  if (!socketPid) return;
@@ -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-FVCGWLR4.js";
12
+ } from "./chunk-ZHJV36LY.js";
13
13
  import "./chunk-VABNWHSE.js";
14
14
  import "./chunk-DS2YJZZY.js";
15
- import "./chunk-HNLG7EJC.js";
15
+ import "./chunk-6AGXBSZL.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-WDSOVOXJ.js";
33
+ import "./chunk-HZDILABA.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-WDSOVOXJ.js";
20
+ } from "./chunk-HZDILABA.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-QJUR24JS.js")).web({
96
+ async (options) => (await import("./web-WY2S2A24.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-RFYNPA2L.js"), "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-TNX4IOCH.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-RFYNPA2L.js")).web({ port: "3100", open: options.open })
679
+ async (options) => (await import("./web-TNX4IOCH.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-MVO3U3DE.js");
992
+ const { signExtension } = await import("./signExtension-RDBHLWQM.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-HT3DTL32.js"), "runDaemon"));
2712
+ ).action(lazyAction(() => import("./runDaemon-L2ZIIRVP.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-EAZHBC6O.js"), "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-WP5YWRXP.js")).doctorNodes(
2736
+ async (name, _options, command) => (await import("./doctorNodes-GLIMPERP.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-YPEEQ7J6.js"), "restartNode")),
2766
+ ).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-6R435AUB.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-35GYVT4L.js")).updateNode(name)
2773
+ async (name) => (await import("./updateNode-O7N2QLQM.js")).updateNode(name)
2774
2774
  ),
2775
2775
  calledBy5
2776
2776
  );
@@ -2793,6 +2793,32 @@ function registerNodes(sessions) {
2793
2793
  configHelp(cmd, nodesConfigHelp);
2794
2794
  }
2795
2795
 
2796
+ // src/commands/sessions/sessionIdHelp.ts
2797
+ var sessionIdHelp = "Session id from assist sessions list (<node>:<id> for a linked node)";
2798
+
2799
+ // src/commands/sessions/registerInterruptCommand.ts
2800
+ function registerInterruptCommand(cmd) {
2801
+ cmd.command("interrupt").description(
2802
+ "Interrupt the running turn of a Claude session (the current one by default)"
2803
+ ).option("--id <id>", sessionIdHelp).action(lazyAction(() => import("./interruptSession-B56EN6OH.js"), "interruptSession"));
2804
+ }
2805
+
2806
+ // src/commands/sessions/registerCloseRenameCommands.ts
2807
+ function registerCloseRenameCommands(cmd) {
2808
+ internalCommand(
2809
+ cmd.command("close").description(
2810
+ "Dismiss a daemon-managed session (the current one by default), ending it and reaping its worktree"
2811
+ ).option("--id <id>", sessionIdHelp).action(lazyAction(() => import("./closeSession-CBSNK2SH.js"), "closeSession")),
2812
+ "/close"
2813
+ );
2814
+ internalCommand(
2815
+ cmd.command("rename <title>").description(
2816
+ "Retitle a daemon-managed session (the current one by default), overriding the generated title for the rest of its life"
2817
+ ).option("--id <id>", sessionIdHelp).action(lazyAction(() => import("./renameSession-ZLYZCMBB.js"), "renameSession")),
2818
+ "/rename"
2819
+ );
2820
+ }
2821
+
2796
2822
  // src/commands/sessions/registerOutputCommand.ts
2797
2823
  function registerOutputCommand(cmd) {
2798
2824
  internalCommand(
@@ -2804,11 +2830,46 @@ function registerOutputCommand(cmd) {
2804
2830
  ).option("-n, --lines <count>", "Number of lines", "200").option(
2805
2831
  "--server [group]",
2806
2832
  "Read the live server run for this repo's remote and group (default: default)"
2807
- ).action(lazyAction(() => import("./sessionOutput-FHXQCMVC.js"), "sessionOutput")),
2833
+ ).action(lazyAction(() => import("./sessionOutput-3QXHREND.js"), "sessionOutput")),
2808
2834
  "/run-logs"
2809
2835
  );
2810
2836
  }
2811
2837
 
2838
+ // src/commands/sessions/previews/registerPreviewCommands.ts
2839
+ var SESSION_ID = "Session id from assist sessions list (<node>:<id> for a linked node)";
2840
+ function collect7(value, previous) {
2841
+ return [...previous, value];
2842
+ }
2843
+ function registerPreviewCommands(cmd) {
2844
+ cmd.command("previews").argument("<session-id>", SESSION_ID).description(
2845
+ "Show a session's pending preview: kind, title, body and a question form's options"
2846
+ ).option("--json", "Print the pending preview as JSON (null when none)").action(lazyAction(() => import("./sessionPreviews-KLHCZ2TA.js"), "sessionPreviews"));
2847
+ cmd.command("decide").argument("<session-id>", SESSION_ID).description(
2848
+ "Answer a session's pending preview, unblocking the command waiting on it"
2849
+ ).option(
2850
+ "--approve [note]",
2851
+ "Approve (a manual check: works), optionally with a note"
2852
+ ).option(
2853
+ "--reject [note]",
2854
+ "Reject with a reason (a manual check: doesn't work; a question form: decline)"
2855
+ ).option(
2856
+ "--answer <choice>",
2857
+ "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",
2858
+ collect7,
2859
+ []
2860
+ ).action(lazyAction(() => import("./decideSession-QROGLJD6.js"), "decideSession"));
2861
+ }
2862
+
2863
+ // src/commands/sessions/registerSendCommand.ts
2864
+ function registerSendCommand(cmd) {
2865
+ cmd.command("send <id> <text>").description(
2866
+ "Submit a prompt in a session (an id from assist sessions list, <node>:<id> for a linked node)"
2867
+ ).option(
2868
+ "--keys",
2869
+ 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)`
2870
+ ).action(lazyAction(() => import("./sendToSession-X4TGJVZY.js"), "sendToSession"));
2871
+ }
2872
+
2812
2873
  // src/commands/sessions/registerSetStatusCommand.ts
2813
2874
  function registerSetStatusCommand(cmd) {
2814
2875
  internalCommand(
@@ -2833,7 +2894,7 @@ function registerSetStatusCommand(cmd) {
2833
2894
  // src/commands/sessions/registerSessionsWeb.ts
2834
2895
  function registerSessionsWeb(cmd) {
2835
2896
  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-QJUR24JS.js")).web({
2897
+ async (options, command) => (await import("./web-WY2S2A24.js")).web({
2837
2898
  ...options,
2838
2899
  open: command.optsWithGlobals().open
2839
2900
  })
@@ -2848,25 +2909,23 @@ function registerSessionsWeb(cmd) {
2848
2909
  // src/commands/sessions/registerSessions.ts
2849
2910
  function registerSessions(program) {
2850
2911
  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-QJUR24JS.js")).web({
2912
+ async (_options, command) => (await import("./web-WY2S2A24.js")).web({
2852
2913
  port: "3100",
2853
2914
  open: command.optsWithGlobals().open
2854
2915
  })
2855
2916
  );
2856
2917
  registerSessionsWeb(cmd);
2857
- internalCommand(
2858
- cmd.command("close").description(
2859
- "Dismiss the current daemon-managed session, ending it and reaping its worktree"
2860
- ).action(lazyAction(() => import("./closeSession-ECJ6TFRX.js"), "closeSession")),
2861
- "/close"
2862
- );
2863
- internalCommand(
2864
- cmd.command("rename <title>").description(
2865
- "Retitle the current daemon-managed session, overriding the generated title for the rest of its life"
2866
- ).action(lazyAction(() => import("./renameSession-6OCEPFKV.js"), "renameSession")),
2867
- "/rename"
2868
- );
2918
+ registerCloseRenameCommands(cmd);
2919
+ registerInterruptCommand(cmd);
2920
+ cmd.command("list").description(
2921
+ "List every session on this node and linked nodes, with the ids other sessions commands accept"
2922
+ ).option("--json", "Print the sessions as JSON").option(
2923
+ "--node <name>",
2924
+ "Only list sessions on this node (local for this one)"
2925
+ ).action(lazyAction(() => import("./listSessions-7JRA3SZY.js"), "listSessions"));
2869
2926
  registerOutputCommand(cmd);
2927
+ registerPreviewCommands(cmd);
2928
+ registerSendCommand(cmd);
2870
2929
  registerSetStatusCommand(cmd);
2871
2930
  registerNodes(cmd);
2872
2931
  configHelp(cmd, [...sessionsConfigHelp, ...harnessDefaultsConfigHelp]);
@@ -0,0 +1,27 @@
1
+ import {
2
+ actOnSession
3
+ } from "./chunk-2ZTFSV2Z.js";
4
+ import "./chunk-7NVNACAR.js";
5
+ import "./chunk-4CJXCOZS.js";
6
+ import "./chunk-V3AWLJ7P.js";
7
+ import "./chunk-HKGCLAZ7.js";
8
+ import "./chunk-5H7EHZ3J.js";
9
+ import "./chunk-Q6PZLPK4.js";
10
+ import "./chunk-JJKKIBF5.js";
11
+
12
+ // src/commands/sessions/interruptSession.ts
13
+ function refuseNonSdk(session) {
14
+ if (session.sdk) return void 0;
15
+ return String.raw`Session ${session.id} is not a Claude SDK session, so it cannot be interrupted; send it Escape with: assist sessions send ${session.id} --keys '\e'`;
16
+ }
17
+ function interruptSession(options = {}) {
18
+ return actOnSession(
19
+ options.id,
20
+ "interrupt",
21
+ (sessionId) => ({ type: "interrupt", sessionId }),
22
+ refuseNonSdk
23
+ );
24
+ }
25
+ export {
26
+ interruptSession
27
+ };
@@ -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
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ actOnSession
3
+ } from "./chunk-2ZTFSV2Z.js";
4
+ import "./chunk-7NVNACAR.js";
5
+ import "./chunk-4CJXCOZS.js";
6
+ import "./chunk-V3AWLJ7P.js";
7
+ import "./chunk-HKGCLAZ7.js";
8
+ import "./chunk-5H7EHZ3J.js";
9
+ import "./chunk-Q6PZLPK4.js";
10
+ import "./chunk-JJKKIBF5.js";
11
+
12
+ // src/commands/sessions/renameSession.ts
13
+ function renameSession(title, options = {}) {
14
+ return actOnSession(options.id, "rename", (sessionId) => ({
15
+ type: "rename",
16
+ sessionId,
17
+ title
18
+ }));
19
+ }
20
+ export {
21
+ renameSession
22
+ };
@@ -2,20 +2,20 @@ import {
2
2
  linkStatus,
3
3
  postToPeer,
4
4
  startPeerAction
5
- } from "./chunk-S5IM25QR.js";
6
- import "./chunk-77KP3CTK.js";
7
- import "./chunk-FVCGWLR4.js";
5
+ } from "./chunk-JJOJ6NNT.js";
6
+ import "./chunk-WEPXPOIF.js";
7
+ import "./chunk-ZHJV36LY.js";
8
8
  import "./chunk-VABNWHSE.js";
9
9
  import "./chunk-DS2YJZZY.js";
10
10
  import "./chunk-4HKB2TAG.js";
11
- import "./chunk-HNLG7EJC.js";
11
+ import "./chunk-6AGXBSZL.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-WDSOVOXJ.js";
18
+ import "./chunk-HZDILABA.js";
19
19
  import "./chunk-XNIKOBRH.js";
20
20
  import "./chunk-LU67AKT5.js";
21
21
  import "./chunk-GRXFWFGP.js";