@staff0rd/assist 0.1237.0 → 0.1239.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.
Files changed (33) hide show
  1. package/allowed.cli-reads +1 -0
  2. package/dist/.build-files +24 -16
  3. package/dist/allowed.cli-reads +1 -0
  4. package/dist/built-version +1 -1
  5. package/dist/{chunk-SGNCR5K6.js → chunk-3WQPSQ5K.js} +2 -2
  6. package/dist/{chunk-VEEMB7N4.js → chunk-63PVYPGV.js} +1 -1
  7. package/dist/{chunk-7W5H4AYH.js → chunk-6GOMLI26.js} +1 -1
  8. package/dist/chunk-7NVNACAR.js +35 -0
  9. package/dist/{chunk-WT45UA2O.js → chunk-N7QAL5FW.js} +1 -1
  10. package/dist/{chunk-K5X4E3IU.js → chunk-NNMGZFFK.js} +1 -1
  11. package/dist/chunk-Q4NYTG3K.js +48 -0
  12. package/dist/{chunk-FJSC75IR.js → chunk-RV553IIM.js} +1 -1
  13. package/dist/chunk-W356VDGY.js +23 -0
  14. package/dist/chunk-XRWFZJJI.js +17 -0
  15. package/dist/closeSession-63HWZCLL.js +22 -0
  16. package/dist/commands/sessions/web/bundle.js +1 -1
  17. package/dist/decideSession-QROGLJD6.js +132 -0
  18. package/dist/{doctorNodes-WRMJHURB.js → doctorNodes-C74RIR6T.js} +3 -3
  19. package/dist/index.js +77 -24
  20. package/dist/interruptSession-CECE76SI.js +21 -0
  21. package/dist/renameSession-SVAMBOZY.js +22 -0
  22. package/dist/{restartNode-IILQ6JME.js → restartNode-5MXE4GXQ.js} +5 -5
  23. package/dist/{runDaemon-6J65XLN4.js → runDaemon-LIYR4AUN.js} +69 -24
  24. package/dist/sendToSession-X4TGJVZY.js +61 -0
  25. package/dist/{sessionOutput-FHXQCMVC.js → sessionOutput-3QXHREND.js} +6 -14
  26. package/dist/sessionPreviews-KLHCZ2TA.js +77 -0
  27. package/dist/{signExtension-4OPSZCHA.js → signExtension-2QOSGE5Y.js} +1 -1
  28. package/dist/{updateNode-WG3TYKRG.js → updateNode-Y4FNWVFR.js} +5 -5
  29. package/dist/{web-2FU3IPKG.js → web-JMQHXVH4.js} +5 -5
  30. package/dist/{web-GVLIYD53.js → web-UFDQZ47I.js} +5 -5
  31. package/package.json +1 -1
  32. package/dist/closeSession-ECJ6TFRX.js +0 -30
  33. package/dist/renameSession-6OCEPFKV.js +0 -30
@@ -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-K5X4E3IU.js";
12
+ } from "./chunk-NNMGZFFK.js";
13
13
  import "./chunk-VABNWHSE.js";
14
14
  import "./chunk-DS2YJZZY.js";
15
- import "./chunk-VEEMB7N4.js";
15
+ import "./chunk-63PVYPGV.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-7W5H4AYH.js";
33
+ import "./chunk-6GOMLI26.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-7W5H4AYH.js";
20
+ } from "./chunk-6GOMLI26.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-GVLIYD53.js")).web({
96
+ async (options) => (await import("./web-UFDQZ47I.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-2FU3IPKG.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-JMQHXVH4.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-2FU3IPKG.js")).web({ port: "3100", open: options.open })
679
+ async (options) => (await import("./web-JMQHXVH4.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-4OPSZCHA.js");
992
+ const { signExtension } = await import("./signExtension-2QOSGE5Y.js");
993
993
  if (options.url) return printExtensionUrl();
994
994
  return options.sign ? signExtension() : extension();
995
995
  });
@@ -2709,7 +2709,7 @@ 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-6J65XLN4.js"), "runDaemon"));
2712
+ ).action(lazyAction(() => import("./runDaemon-LIYR4AUN.js"), "runDaemon"));
2713
2713
  cmd.command("status").description(
2714
2714
  "Show sessions daemon status, live sessions, and any stray daemon processes"
2715
2715
  ).action(lazyAction(() => import("./daemonStatus-AUHBSCVE.js"), "daemonStatus"));
@@ -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-WRMJHURB.js")).doctorNodes(
2736
+ async (name, _options, command) => (await import("./doctorNodes-C74RIR6T.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-IILQ6JME.js"), "restartNode")),
2766
+ ).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-5MXE4GXQ.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-WG3TYKRG.js")).updateNode(name)
2773
+ async (name) => (await import("./updateNode-Y4FNWVFR.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-CECE76SI.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-63HWZCLL.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-SVAMBOZY.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-GVLIYD53.js")).web({
2897
+ async (options, command) => (await import("./web-UFDQZ47I.js")).web({
2837
2898
  ...options,
2838
2899
  open: command.optsWithGlobals().open
2839
2900
  })
@@ -2848,24 +2909,14 @@ 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-GVLIYD53.js")).web({
2912
+ async (_options, command) => (await import("./web-UFDQZ47I.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);
2869
2920
  cmd.command("list").description(
2870
2921
  "List every session on this node and linked nodes, with the ids other sessions commands accept"
2871
2922
  ).option("--json", "Print the sessions as JSON").option(
@@ -2873,6 +2924,8 @@ function registerSessions(program) {
2873
2924
  "Only list sessions on this node (local for this one)"
2874
2925
  ).action(lazyAction(() => import("./listSessions-7JRA3SZY.js"), "listSessions"));
2875
2926
  registerOutputCommand(cmd);
2927
+ registerPreviewCommands(cmd);
2928
+ registerSendCommand(cmd);
2876
2929
  registerSetStatusCommand(cmd);
2877
2930
  registerNodes(cmd);
2878
2931
  configHelp(cmd, [...sessionsConfigHelp, ...harnessDefaultsConfigHelp]);
@@ -0,0 +1,21 @@
1
+ import {
2
+ actOnSession
3
+ } from "./chunk-Q4NYTG3K.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 interruptSession(options = {}) {
14
+ return actOnSession(options.id, "interrupt", (sessionId) => ({
15
+ type: "interrupt",
16
+ sessionId
17
+ }));
18
+ }
19
+ export {
20
+ interruptSession
21
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ actOnSession
3
+ } from "./chunk-Q4NYTG3K.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-WT45UA2O.js";
6
- import "./chunk-FJSC75IR.js";
7
- import "./chunk-K5X4E3IU.js";
5
+ } from "./chunk-N7QAL5FW.js";
6
+ import "./chunk-RV553IIM.js";
7
+ import "./chunk-NNMGZFFK.js";
8
8
  import "./chunk-VABNWHSE.js";
9
9
  import "./chunk-DS2YJZZY.js";
10
10
  import "./chunk-4HKB2TAG.js";
11
- import "./chunk-VEEMB7N4.js";
11
+ import "./chunk-63PVYPGV.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-7W5H4AYH.js";
18
+ import "./chunk-6GOMLI26.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-VEEMB7N4.js";
137
+ } from "./chunk-63PVYPGV.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-7W5H4AYH.js";
280
+ import "./chunk-6GOMLI26.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/routeOutputToLink.ts
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 routeOutputToLink(client, links, data) {
9996
+ function routeToLinkedSession(client, links, data, refusal) {
9986
9997
  const sessionId = data.sessionId;
9987
- const split = typeof sessionId === "string" ? splitNodeSessionId(sessionId) : void 0;
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(`output requested: id=${sessionId} ${reason6}`);
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 = (client, m, d) => {
10118
- const reply = m.io.typePrompt(String(d.sessionId), String(d.text ?? ""));
10119
- if (!reply.ok) daemonLog(`type-prompt refused: ${reply.message}`);
10120
- sendTo(client, { type: "type-prompt-result", ...reply });
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,
@@ -0,0 +1,61 @@
1
+ import {
2
+ withDaemonConnection
3
+ } from "./chunk-W356VDGY.js";
4
+ import {
5
+ readDaemonMessage
6
+ } from "./chunk-NH33OKZQ.js";
7
+ import "./chunk-Q6PZLPK4.js";
8
+ import "./chunk-JJKKIBF5.js";
9
+
10
+ // src/commands/sessions/daemon/requestTypeIntoSession.ts
11
+ import { randomUUID } from "crypto";
12
+ var TYPE_TIMEOUT_MS = 1e4;
13
+ function requestTypeIntoSession(request) {
14
+ return withDaemonConnection((socket, lines) => {
15
+ const requestId = randomUUID();
16
+ const reply = readDaemonMessage(
17
+ lines,
18
+ TYPE_TIMEOUT_MS,
19
+ { ok: false, message: "Timed out waiting for the sessions daemon" },
20
+ (data) => data.type === "type-prompt-result" && data.requestId === requestId ? { ok: data.ok === true, message: String(data.message ?? "") } : void 0
21
+ );
22
+ socket.write(`${JSON.stringify({ ...request, requestId })}
23
+ `);
24
+ return reply;
25
+ });
26
+ }
27
+
28
+ // src/commands/sessions/send/decodeKeys.ts
29
+ var NAMED = {
30
+ r: "\r",
31
+ n: "\n",
32
+ t: " ",
33
+ e: "\x1B",
34
+ "\\": "\\"
35
+ };
36
+ function decodeKeys(keys) {
37
+ return keys.replace(
38
+ /\\(x[0-9a-fA-F]{2}|[rnte\\])/g,
39
+ (_, code) => code.startsWith("x") ? String.fromCharCode(Number.parseInt(code.slice(1), 16)) : NAMED[code]
40
+ );
41
+ }
42
+
43
+ // src/commands/sessions/send/sendToSession.ts
44
+ async function sendToSession(sessionId, text, options) {
45
+ try {
46
+ const reply = await requestTypeIntoSession(
47
+ options.keys ? { type: "type-keys", sessionId, text: decodeKeys(text) } : { type: "type-prompt", sessionId, text }
48
+ );
49
+ if (reply.ok) console.log(reply.message);
50
+ else fail(reply.message);
51
+ } catch (error) {
52
+ fail(error instanceof Error ? error.message : String(error));
53
+ }
54
+ }
55
+ function fail(message) {
56
+ console.error(message);
57
+ process.exitCode = 1;
58
+ }
59
+ export {
60
+ sendToSession
61
+ };