@staff0rd/assist 0.1167.0 → 0.1168.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 (88) hide show
  1. package/dist/.build-files +79 -79
  2. package/dist/{addActivity-KFTWNCJC.js → addActivity-7BL2QCUP.js} +2 -2
  3. package/dist/{addPhase-CYLS4KF3.js → addPhase-DKKE7JH6.js} +3 -3
  4. package/dist/{advise-3NMJIWEG.js → advise-46JSXUDW.js} +3 -3
  5. package/dist/{askCheck-QZQNTYSB.js → askCheck-WXTZA77F.js} +7 -7
  6. package/dist/{askDesign-XJWLHIKM.js → askDesign-C55JXS4W.js} +1 -1
  7. package/dist/{branch-7NZPUOFY.js → branch-7L5HGHC3.js} +3 -3
  8. package/dist/built-version +1 -1
  9. package/dist/{chunk-AY4KVQZ2.js → chunk-34WDUOOB.js} +1 -1
  10. package/dist/chunk-3HNTLFII.js +50 -0
  11. package/dist/{chunk-PIZ5WHKY.js → chunk-3PESUAUN.js} +2 -2
  12. package/dist/{chunk-ZAMEG3EN.js → chunk-425LLTMS.js} +24 -21
  13. package/dist/{chunk-2IH2A3JK.js → chunk-43MJXI4R.js} +71 -19
  14. package/dist/{chunk-F4ADOEV4.js → chunk-5CT7CKQM.js} +1 -1
  15. package/dist/{chunk-PVL3555C.js → chunk-6FGA6L2E.js} +1 -1
  16. package/dist/{chunk-4JI4SMBQ.js → chunk-735FL6ZP.js} +475 -129
  17. package/dist/{chunk-SRSCOXZE.js → chunk-7MUNT7JI.js} +5 -1
  18. package/dist/{chunk-WC7ROMSZ.js → chunk-7QAFWJTK.js} +1 -1
  19. package/dist/{chunk-4YTZUN24.js → chunk-BWOCKEUI.js} +6 -6
  20. package/dist/{chunk-5TJEQ6SM.js → chunk-DNUEENBJ.js} +1 -1
  21. package/dist/{chunk-FF5VHS2Q.js → chunk-DTRDXHGW.js} +1 -1
  22. package/dist/{chunk-BTMRIDZC.js → chunk-DUPJVKAX.js} +1 -1
  23. package/dist/{chunk-4OZ6ULV6.js → chunk-EAREJAOY.js} +1 -1
  24. package/dist/{chunk-DRCSMAFZ.js → chunk-FQJJEZ3O.js} +1 -1
  25. package/dist/{chunk-Z4EP2FTM.js → chunk-FYSUHMKS.js} +1 -1
  26. package/dist/{chunk-GSTZWNA7.js → chunk-HL26MMZX.js} +1 -1
  27. package/dist/{chunk-K3JNJGLB.js → chunk-I3TEQBTO.js} +25 -7
  28. package/dist/{chunk-HK7P5QGC.js → chunk-INIYGNL6.js} +1 -1
  29. package/dist/{chunk-NCTA64LR.js → chunk-IUBV4ZNS.js} +2 -2
  30. package/dist/{chunk-LRMCAFO3.js → chunk-KIM3TG36.js} +1 -1
  31. package/dist/{chunk-5A63PEQ4.js → chunk-L6RKPFKP.js} +5 -3
  32. package/dist/{chunk-J4SHN7I2.js → chunk-MVSLFBWG.js} +1 -1
  33. package/dist/{chunk-XHYDG7UZ.js → chunk-NLTT3LC6.js} +1 -1
  34. package/dist/{chunk-HUUPDV55.js → chunk-OEGJ2WJL.js} +1 -1
  35. package/dist/{chunk-3OL7AV66.js → chunk-OTIEVXH3.js} +2 -2
  36. package/dist/{chunk-HL5PHECL.js → chunk-Q2FPO2KT.js} +4 -4
  37. package/dist/{chunk-4AIX7WAZ.js → chunk-RHUM4UUX.js} +1 -1
  38. package/dist/{chunk-W2TBOOCR.js → chunk-RW2B5RU5.js} +1 -1
  39. package/dist/{chunk-LD3C7W3Q.js → chunk-UCTFPC6X.js} +2 -2
  40. package/dist/{chunk-B6TSGDM3.js → chunk-UY75YJI5.js} +1 -1
  41. package/dist/{chunk-VZ6K4LLZ.js → chunk-VEHHPXW6.js} +1 -1
  42. package/dist/{chunk-IYOKTOCX.js → chunk-WJM6BSEL.js} +3 -3
  43. package/dist/{chunk-BUX5FETL.js → chunk-WWWNWP3Z.js} +1 -1
  44. package/dist/{chunk-KFTPCHSO.js → chunk-YQAATWQ4.js} +1 -1
  45. package/dist/{chunk-LMXSHIFC.js → chunk-ZAS2ZWEK.js} +1 -1
  46. package/dist/{chunk-XRXDSR4I.js → chunk-ZRJFYESX.js} +2 -2
  47. package/dist/{cliHook-PQ4DICPB.js → cliHook-LXPHXYTG.js} +5 -5
  48. package/dist/{cliHookCheck-XPQZAA7K.js → cliHookCheck-X3OTARTS.js} +2 -2
  49. package/dist/{codexHook-OU6CL4R6.js → codexHook-JHA7XAJI.js} +7 -7
  50. package/dist/commands/extension/extension/content.js +1 -1
  51. package/dist/commands/extension/extension/docs.js +1 -1
  52. package/dist/commands/extension/extension/updates.json +2 -2
  53. package/dist/commands/sessions/web/bundle.js +470 -470
  54. package/dist/{commit-XSLHSHPA.js → commit-S237TZOH.js} +3 -3
  55. package/dist/{doctorNodes-UJSW3KXP.js → doctorNodes-LN3IU7VI.js} +3 -3
  56. package/dist/{done-RZTGTNXG.js → done-5HZCYORB.js} +4 -4
  57. package/dist/{editHook-KBXSEJDB.js → editHook-TIPNG6CB.js} +5 -5
  58. package/dist/{fixConflict-IQPXBWTV.js → fixConflict-GLENPF7A.js} +4 -4
  59. package/dist/index.js +48 -48
  60. package/dist/{indexRules-4M2TAWOE.js → indexRules-65H3IE33.js} +1 -2
  61. package/dist/{launchMode-CUMEGSJ2.js → launchMode-7QOKFQ6Z.js} +13 -13
  62. package/dist/{list-6KAXN2EU.js → list-IJS6P6DF.js} +5 -5
  63. package/dist/{next-M6ES2GM5.js → next-BCHDDNK6.js} +12 -12
  64. package/dist/{piHook-SMWFJWJW.js → piHook-GCKOXN5A.js} +5 -5
  65. package/dist/{propose-UZ32UXI7.js → propose-MXYXKAV3.js} +4 -4
  66. package/dist/{refine-IMF3B622.js → refine-BHJO6FOW.js} +14 -14
  67. package/dist/{restartNode-DRKXN7BO.js → restartNode-II6AA2BY.js} +5 -5
  68. package/dist/{review-LV46YDUO.js → review-LQGEHHIW.js} +4 -4
  69. package/dist/{reviewPrComments-2XMV6JYB.js → reviewPrComments-RXADKZLV.js} +4 -4
  70. package/dist/{rewindPhase-CIBJCOEB.js → rewindPhase-UHEZJFPC.js} +8 -8
  71. package/dist/{rulesAdd-T62MTCFM.js → rulesAdd-V4SWWQKL.js} +8 -44
  72. package/dist/{run-OCENG6SA.js → run-CRSLYRI4.js} +10 -10
  73. package/dist/{run-LIMV7FRM.js → run-RETGCI6N.js} +10 -10
  74. package/dist/{runDaemon-ZWJ5RXI3.js → runDaemon-JN5JG4JI.js} +263 -28
  75. package/dist/{runRefine-JDE7UBYZ.js → runRefine-2YX2DZMV.js} +14 -14
  76. package/dist/{scan-DKZKXE2I.js → scan-BO23G2MD.js} +2 -2
  77. package/dist/{schemaConfirm-JYOLGGGL.js → schemaConfirm-AB6SR5SC.js} +2 -2
  78. package/dist/{schemaUnlock-4JRJS5RQ.js → schemaUnlock-AT5T43PB.js} +2 -2
  79. package/dist/{search-CD5NUNSZ.js → search-DQ2UDIBW.js} +5 -5
  80. package/dist/{show-CQEX3RE3.js → show-OLER6JJU.js} +3 -3
  81. package/dist/{show-EBJJQQ5G.js → show-QBR7REUE.js} +3 -3
  82. package/dist/{signExtension-R2SUZ2TV.js → signExtension-MUEEON4E.js} +1 -1
  83. package/dist/{updateNode-OWAXUOKT.js → updateNode-UMI4KHG7.js} +5 -5
  84. package/dist/{updatePlan-U6PK425R.js → updatePlan-UJ76CTUM.js} +4 -4
  85. package/dist/{web-HE7B2H3B.js → web-7EJG7VHM.js} +18 -17
  86. package/dist/{web-C6UIA5QL.js → web-LAOO3BPM.js} +18 -17
  87. package/package.json +1 -1
  88. package/dist/chunk-IZZJUZZY.js +0 -21
@@ -15,12 +15,13 @@ import {
15
15
  } from "./chunk-XV6BO5MK.js";
16
16
  import {
17
17
  allocateTree,
18
+ killTree,
18
19
  prCliCommands,
19
20
  seedWorktree,
20
21
  stopInstall,
21
22
  worktreeConfigFor,
22
23
  worktreeWithBranch
23
- } from "./chunk-ZAMEG3EN.js";
24
+ } from "./chunk-425LLTMS.js";
24
25
  import {
25
26
  describePersistedSession,
26
27
  loadPersistedSessions,
@@ -31,7 +32,7 @@ import {
31
32
  formatScanUsage,
32
33
  inboxScanBlocker,
33
34
  runInboxScan
34
- } from "./chunk-LMXSHIFC.js";
35
+ } from "./chunk-ZAS2ZWEK.js";
35
36
  import "./chunk-2JYMVJGZ.js";
36
37
  import {
37
38
  showNotification
@@ -48,7 +49,7 @@ import {
48
49
  recordPhaseSession,
49
50
  releaseLock,
50
51
  requestPause
51
- } from "./chunk-DRCSMAFZ.js";
52
+ } from "./chunk-FQJJEZ3O.js";
52
53
  import {
53
54
  buildResumePrompt,
54
55
  wrapRestartNudge
@@ -69,12 +70,12 @@ import {
69
70
  import {
70
71
  OneShotUnavailableError,
71
72
  runOneShotPrompt
72
- } from "./chunk-B6TSGDM3.js";
73
+ } from "./chunk-UY75YJI5.js";
73
74
  import {
74
75
  locateConversation,
75
76
  readTranscriptHead,
76
77
  transcriptMessages
77
- } from "./chunk-SRSCOXZE.js";
78
+ } from "./chunk-7MUNT7JI.js";
78
79
  import {
79
80
  CHECK_NOTE_KEY
80
81
  } from "./chunk-OLE7XSNB.js";
@@ -106,7 +107,7 @@ import {
106
107
  toNodeSessionId,
107
108
  usageWindowKey,
108
109
  watcherLogPath
109
- } from "./chunk-Z4EP2FTM.js";
110
+ } from "./chunk-FYSUHMKS.js";
110
111
  import {
111
112
  newTraceId
112
113
  } from "./chunk-4HKB2TAG.js";
@@ -118,7 +119,7 @@ import {
118
119
  isHello,
119
120
  linkVersionCheck,
120
121
  negotiateProtocol
121
- } from "./chunk-HK7P5QGC.js";
122
+ } from "./chunk-INIYGNL6.js";
122
123
  import {
123
124
  loadLinkSpecs
124
125
  } from "./chunk-HHKS3UZB.js";
@@ -133,7 +134,7 @@ import "./chunk-XV2STPP6.js";
133
134
  import {
134
135
  conversationOf,
135
136
  lookupConversation
136
- } from "./chunk-BUX5FETL.js";
137
+ } from "./chunk-WWWNWP3Z.js";
137
138
  import {
138
139
  stripAnsi
139
140
  } from "./chunk-YJ72SXVD.js";
@@ -171,9 +172,9 @@ import {
171
172
  } from "./chunk-QAJUCN3A.js";
172
173
  import {
173
174
  resolvePlan
174
- } from "./chunk-5TJEQ6SM.js";
175
- import "./chunk-F4ADOEV4.js";
176
- import "./chunk-5A63PEQ4.js";
175
+ } from "./chunk-DNUEENBJ.js";
176
+ import "./chunk-5CT7CKQM.js";
177
+ import "./chunk-L6RKPFKP.js";
177
178
  import {
178
179
  loadItem
179
180
  } from "./chunk-U732RAGX.js";
@@ -199,7 +200,7 @@ import {
199
200
  runConfigBaseDirFrom
200
201
  } from "./chunk-QR7KY3Y6.js";
201
202
  import "./chunk-NZYSENRR.js";
202
- import "./chunk-J4SHN7I2.js";
203
+ import "./chunk-MVSLFBWG.js";
203
204
  import "./chunk-MELBVXKL.js";
204
205
  import {
205
206
  resolveCapability
@@ -215,6 +216,7 @@ import {
215
216
  parseRestartNudge,
216
217
  parseRolloutEntry,
217
218
  parseSessionFile,
219
+ quoteForLog,
218
220
  readTranscriptTail,
219
221
  readTranscriptTailSync,
220
222
  refuseMissingCwd,
@@ -227,9 +229,10 @@ import {
227
229
  setSdkUsageSink,
228
230
  spawnClaudeSdk,
229
231
  spawnPty,
232
+ splitShellBlocks,
230
233
  viewerSize,
231
234
  workflowQueryEnv
232
- } from "./chunk-2IH2A3JK.js";
235
+ } from "./chunk-43MJXI4R.js";
233
236
  import {
234
237
  daemonLog,
235
238
  recentDaemonLogLines,
@@ -255,7 +258,7 @@ import {
255
258
  import "./chunk-APZ6ZTDA.js";
256
259
  import "./chunk-BFQSGIN6.js";
257
260
  import "./chunk-D7UZLH36.js";
258
- import "./chunk-AY4KVQZ2.js";
261
+ import "./chunk-34WDUOOB.js";
259
262
  import "./chunk-EW2ZM2PC.js";
260
263
  import "./chunk-QKHOYKUQ.js";
261
264
  import {
@@ -787,6 +790,7 @@ function toSessionViewInfo({
787
790
  sdkProcess,
788
791
  sdkQueued,
789
792
  sdkPending,
793
+ sdkShell,
790
794
  sdkBackgroundTasks,
791
795
  sdkPromptSuggestion,
792
796
  sdkInterrupting,
@@ -799,6 +803,7 @@ function toSessionViewInfo({
799
803
  sdkProcess,
800
804
  sdkQueued,
801
805
  sdkPending,
806
+ sdkShell,
802
807
  sdkBackgroundTasks,
803
808
  sdkPromptSuggestion,
804
809
  sdkInterrupting,
@@ -2705,6 +2710,41 @@ function reportUndeliveredPrompts(session, why) {
2705
2710
  }
2706
2711
  }
2707
2712
 
2713
+ // src/commands/sessions/daemon/shell/stopShellCommand.ts
2714
+ var running = /* @__PURE__ */ new Map();
2715
+ function trackShellCommand(sessionId, shellId, child) {
2716
+ const children = running.get(sessionId) ?? /* @__PURE__ */ new Map();
2717
+ children.set(shellId, child);
2718
+ running.set(sessionId, children);
2719
+ }
2720
+ function untrackShellCommand(sessionId, shellId) {
2721
+ const children = running.get(sessionId);
2722
+ children?.delete(shellId);
2723
+ if (children?.size === 0) running.delete(sessionId);
2724
+ }
2725
+ function stopShellCommand(session, shellId) {
2726
+ const child = running.get(session.id)?.get(shellId);
2727
+ const row = session.sdkShell?.find((r) => r.id === shellId);
2728
+ if (!child?.pid || row?.state !== "running") return false;
2729
+ row.stopped = true;
2730
+ daemonLog(
2731
+ `session ${session.id} shell ${shellId} stopping: killing process tree of pid ${child.pid}`
2732
+ );
2733
+ killTree(child.pid);
2734
+ return true;
2735
+ }
2736
+ function stopSessionShellCommands(session) {
2737
+ for (const shellId of running.get(session.id)?.keys() ?? [])
2738
+ stopShellCommand(session, shellId);
2739
+ running.delete(session.id);
2740
+ const held = session.sdkShell?.filter((row) => row.state === "held") ?? [];
2741
+ if (held.length)
2742
+ daemonLog(
2743
+ `session ${session.id} dismissed: dropped held shell results ${held.map((row) => row.id).join(", ")}`
2744
+ );
2745
+ session.sdkShell = void 0;
2746
+ }
2747
+
2708
2748
  // src/commands/sessions/daemon/worktree/otherTreeHolders.ts
2709
2749
  function otherTreeHolders(sessions, session) {
2710
2750
  const tree = treeUnderClose(session)?.path;
@@ -2720,6 +2760,7 @@ function dismissSession(sessions, id) {
2720
2760
  if (!s) return false;
2721
2761
  const sharedWith = otherTreeHolders(sessions, s);
2722
2762
  if (s.status !== "done" && s.pty) killPtyTree(s.pty);
2763
+ stopSessionShellCommands(s);
2723
2764
  s.activityWatcher?.close();
2724
2765
  s.transcriptWatcher?.close();
2725
2766
  s.gitWatcher?.close();
@@ -4215,9 +4256,34 @@ function applySdkViewEvent(session, event) {
4215
4256
  }
4216
4257
  }
4217
4258
 
4259
+ // src/commands/sessions/shared/formatShellBlocks.ts
4260
+ function streamText(output, stream) {
4261
+ return output.filter((chunk) => chunk.stream === stream).map((chunk) => chunk.text).join("");
4262
+ }
4263
+ function formatShellBlocks(results) {
4264
+ return results.map(
4265
+ ({ command, output }) => `<bash-input>${command}</bash-input>
4266
+ <bash-stdout>${streamText(output, "stdout").trimEnd()}</bash-stdout><bash-stderr>${streamText(output, "stderr").trimEnd()}</bash-stderr>`
4267
+ ).join("\n");
4268
+ }
4269
+
4270
+ // src/commands/sessions/daemon/shell/takeHeldShellResults.ts
4271
+ function takeHeldShellResults(session, notify) {
4272
+ const held = session.sdkShell?.filter((row) => row.state === "held") ?? [];
4273
+ if (!held.length) return "";
4274
+ const running2 = session.sdkShell?.filter((row) => row.state !== "held");
4275
+ session.sdkShell = running2?.length ? running2 : void 0;
4276
+ daemonLog(
4277
+ `session ${session.id} shell results attached to message: ${held.map((row) => row.id).join(", ")}`
4278
+ );
4279
+ notify?.();
4280
+ return formatShellBlocks(held);
4281
+ }
4282
+
4218
4283
  // src/commands/sessions/daemon/wireSdkEvents.ts
4219
4284
  function wireSdkEvents(session, onStatusChange, notify) {
4220
4285
  session.sdkBackgroundTasks = void 0;
4286
+ session.pty?.sdk?.setPrefix?.(() => takeHeldShellResults(session, notify));
4221
4287
  session.pty?.sdk?.onEvent((event) => {
4222
4288
  if (session.status === "done" || session.status === "stopped") return;
4223
4289
  if (event.kind !== "status") {
@@ -4288,12 +4354,13 @@ function latestUserRows(rows) {
4288
4354
  return { texts, restart };
4289
4355
  }
4290
4356
  var normalize = (text) => text.replace(/\s+/g, " ").trim();
4357
+ var ownText = (text) => splitShellBlocks(text)?.text ?? text;
4291
4358
  function unseenPendingTexts(pending, rows) {
4292
4359
  if (!pending?.length) return [];
4293
4360
  const latest2 = latestUserRows(rows);
4294
4361
  const seen = latest2.texts.map(normalize);
4295
4362
  return pending.filter(
4296
- (text) => parseRestartNudge(text) === null ? !seen.some((t) => t.includes(normalize(text))) : !latest2.restart
4363
+ (text) => parseRestartNudge(text) === null ? !seen.some((t) => t.includes(normalize(ownText(text)))) : !latest2.restart
4297
4364
  );
4298
4365
  }
4299
4366
 
@@ -4355,11 +4422,15 @@ function update(session, field, message, label) {
4355
4422
  );
4356
4423
  return true;
4357
4424
  }
4425
+ function lastShellPrompt(session) {
4426
+ const row = session.sdkShell?.at(-1);
4427
+ return row && `! ${row.command}`;
4428
+ }
4358
4429
  function updateLastMessages(session, events, notify) {
4359
4430
  const user = update(
4360
4431
  session,
4361
4432
  "lastUserMessage",
4362
- lastMessageText(events, "user", USER_MAX_LENGTH),
4433
+ lastShellPrompt(session) ?? lastMessageText(events, "user", USER_MAX_LENGTH),
4363
4434
  "user"
4364
4435
  );
4365
4436
  const assistant = update(
@@ -5412,6 +5483,7 @@ function relaySdkActions(label, current) {
5412
5483
  function createSdkRelay(label) {
5413
5484
  const listeners = [];
5414
5485
  let current;
5486
+ let prefixer;
5415
5487
  const emit = (event) => {
5416
5488
  for (const listener of listeners) listener(event);
5417
5489
  };
@@ -5424,8 +5496,13 @@ function createSdkRelay(label) {
5424
5496
  const handle = {
5425
5497
  onEvent: (listener) => listeners.push(listener),
5426
5498
  ...relaySdkActions(label, () => current),
5499
+ setPrefix: (provider) => {
5500
+ prefixer = provider;
5501
+ current?.sdk?.setPrefix?.(provider);
5502
+ },
5427
5503
  attach: (query, idle) => {
5428
5504
  current = query;
5505
+ if (prefixer) query.sdk?.setPrefix?.(prefixer);
5429
5506
  daemonLog(
5430
5507
  `${label} sdk query attached to workflow${idle ? ", awaiting input" : ""}`
5431
5508
  );
@@ -6803,10 +6880,10 @@ function restoreAllSessions(spawner, deps) {
6803
6880
 
6804
6881
  // src/commands/sessions/daemon/retrySession.ts
6805
6882
  function retrySession(session, clients, onStatusChange) {
6806
- const spawn4 = respawnThunk(session);
6807
- if (!spawn4) return false;
6883
+ const spawn5 = respawnThunk(session);
6884
+ if (!spawn5) return false;
6808
6885
  const respawn = () => {
6809
- respawnSession(session, spawn4, "running", clients, onStatusChange);
6886
+ respawnSession(session, spawn5, "running", clients, onStatusChange);
6810
6887
  daemonLog(`session ${session.id} retried: ${session.name}`);
6811
6888
  };
6812
6889
  const pty = session.pty;
@@ -8619,6 +8696,162 @@ var handleSdkLaunch = (client, m, d) => {
8619
8696
  linkWorkflowQuery(client, sessionId, query);
8620
8697
  };
8621
8698
 
8699
+ // src/commands/sessions/daemon/shell/runSdkShell.ts
8700
+ import { randomUUID } from "crypto";
8701
+
8702
+ // src/commands/sessions/daemon/shell/spawnShellCommand.ts
8703
+ import { spawn as spawn4 } from "child_process";
8704
+
8705
+ // src/commands/sessions/daemon/shell/shellInvocation.ts
8706
+ function shellInvocation(command) {
8707
+ if (process.platform === "win32")
8708
+ return ["cmd.exe", ["/d", "/s", "/c", command]];
8709
+ return [process.env.SHELL ?? "bash", ["-l", "-c", command]];
8710
+ }
8711
+
8712
+ // src/commands/sessions/daemon/shell/spawnShellCommand.ts
8713
+ function spawnShellCommand(command, cwd, sessionId) {
8714
+ const [file, args] = shellInvocation(command);
8715
+ return spawn4(file, args, {
8716
+ cwd,
8717
+ env: sessionChildEnv(process.env, sessionId),
8718
+ stdio: ["ignore", "pipe", "pipe"],
8719
+ // why: its own process group, so stopping it reaches every process it starts
8720
+ detached: process.platform !== "win32",
8721
+ windowsHide: true
8722
+ });
8723
+ }
8724
+
8725
+ // src/commands/sessions/daemon/shell/appendShellOutput.ts
8726
+ var MAX_OUTPUT = 2e5;
8727
+ var TRUNCATED = "\n\u2026 output truncated\n";
8728
+ function outputLength(row) {
8729
+ return row.output.reduce((total, chunk) => total + chunk.text.length, 0);
8730
+ }
8731
+ function appendShellOutput(row, stream, text) {
8732
+ const room = MAX_OUTPUT - outputLength(row);
8733
+ if (room <= 0) return;
8734
+ const kept = text.length > room ? `${text.slice(0, room)}${TRUNCATED}` : text;
8735
+ const last = row.output.at(-1);
8736
+ if (last?.stream === stream) last.text += kept;
8737
+ else row.output.push({ stream, text: kept });
8738
+ }
8739
+
8740
+ // src/commands/sessions/daemon/shell/finishShellRow.ts
8741
+ function finishShellRow(row, label, exitCode, reason6) {
8742
+ if (row.state !== "running") return false;
8743
+ row.state = "held";
8744
+ row.exitCode = exitCode;
8745
+ row.durationMs = Date.now() - row.startedAt;
8746
+ daemonLog(
8747
+ `${label} ${row.stopped ? "stopped" : "exited"}: ${reason6}, ${row.durationMs}ms, output held for the next message`
8748
+ );
8749
+ return true;
8750
+ }
8751
+
8752
+ // src/commands/sessions/daemon/shell/throttleNotify.ts
8753
+ var INTERVAL_MS = 150;
8754
+ function throttleNotify(notify) {
8755
+ let timer;
8756
+ const fire = () => {
8757
+ timer = void 0;
8758
+ notify();
8759
+ };
8760
+ const update2 = () => {
8761
+ timer ??= setTimeout(fire, INTERVAL_MS);
8762
+ };
8763
+ update2.cancel = () => {
8764
+ if (timer) clearTimeout(timer);
8765
+ timer = void 0;
8766
+ };
8767
+ return update2;
8768
+ }
8769
+
8770
+ // src/commands/sessions/daemon/shell/watchShellChild.ts
8771
+ function watchShellChild(child, row, label, notify) {
8772
+ const update2 = throttleNotify(notify);
8773
+ const finish = (exitCode, reason6) => {
8774
+ if (!finishShellRow(row, label, exitCode, reason6)) return;
8775
+ update2.cancel();
8776
+ notify();
8777
+ };
8778
+ for (const stream of ["stdout", "stderr"]) {
8779
+ child[stream]?.setEncoding("utf8");
8780
+ child[stream]?.on("data", (chunk) => {
8781
+ appendShellOutput(row, stream, chunk);
8782
+ update2();
8783
+ });
8784
+ }
8785
+ child.on("error", (error) => {
8786
+ appendShellOutput(row, "stderr", `${error.message}
8787
+ `);
8788
+ finish(127, `spawn failed: ${error.message}`);
8789
+ });
8790
+ child.on(
8791
+ "close",
8792
+ (code, signal) => finish(code ?? 1, signal ? `signal ${signal}` : `code ${code}`)
8793
+ );
8794
+ }
8795
+
8796
+ // src/commands/sessions/daemon/shell/runSdkShell.ts
8797
+ function runSdkShell(session, command, notify) {
8798
+ const row = {
8799
+ id: randomUUID().slice(0, 8),
8800
+ command,
8801
+ output: [],
8802
+ state: "running",
8803
+ startedAt: Date.now()
8804
+ };
8805
+ const label = `session ${session.id} shell ${row.id}`;
8806
+ session.sdkShell = [...session.sdkShell ?? [], row];
8807
+ session.lastUserMessage = `! ${command}`;
8808
+ const cwd = session.cwd ?? process.cwd();
8809
+ const child = spawnShellCommand(command, cwd, session.id);
8810
+ daemonLog(
8811
+ `${label} started: pid ${child.pid ?? "none"} in ${cwd}: ${quoteForLog(command)}`
8812
+ );
8813
+ trackShellCommand(session.id, row.id, child);
8814
+ watchShellChild(child, row, label, () => {
8815
+ if (row.state !== "running") untrackShellCommand(session.id, row.id);
8816
+ notify();
8817
+ });
8818
+ notify();
8819
+ }
8820
+
8821
+ // src/commands/sessions/daemon/shell/handleSdkShell.ts
8822
+ var ENDED2 = /* @__PURE__ */ new Set(["done", "stopped", "error"]);
8823
+ var handleSdkShell = routed((_client, m, d) => {
8824
+ const id = String(d.sessionId);
8825
+ const command = String(d.command ?? "").trim();
8826
+ const session = m.session(id);
8827
+ if (!session || !isSdkSession(session) || ENDED2.has(session.status)) {
8828
+ daemonLog(
8829
+ `sdk-shell ignored: session ${id} ${session ? "is not a live Claude (SDK) session" : "was not found"}`
8830
+ );
8831
+ return;
8832
+ }
8833
+ if (!command) {
8834
+ daemonLog(`sdk-shell ignored: session ${id} sent an empty command`);
8835
+ return;
8836
+ }
8837
+ daemonLog(`sdk-shell received: session ${id}`);
8838
+ runSdkShell(session, command, () => m.update(() => true));
8839
+ });
8840
+
8841
+ // src/commands/sessions/daemon/shell/handleSdkShellStop.ts
8842
+ var handleSdkShellStop = routed((_client, m, d) => {
8843
+ const id = String(d.sessionId);
8844
+ const shellId = String(d.shellId);
8845
+ const session = m.session(id);
8846
+ if (!session || !stopShellCommand(session, shellId)) {
8847
+ daemonLog(
8848
+ `sdk-shell-stop ignored: session ${id} shell ${shellId} ${session ? "is not running" : "session was not found"}`
8849
+ );
8850
+ return;
8851
+ }
8852
+ m.update(() => true);
8853
+ });
8854
+
8622
8855
  // src/commands/sessions/daemon/handleWebLog.ts
8623
8856
  var handleWebLog = (client, _m, d) => {
8624
8857
  daemonLog(`web: ${String(d.message)}`);
@@ -8759,7 +8992,7 @@ async function handleSearchHistory(client, data) {
8759
8992
  }
8760
8993
 
8761
8994
  // src/commands/sessions/daemon/creator.ts
8762
- function creator(isNew, spawn4) {
8995
+ function creator(isNew, spawn5) {
8763
8996
  const reply = (client, d, result) => {
8764
8997
  const traceId = typeof d.traceId === "string" ? d.traceId : void 0;
8765
8998
  if (typeof result !== "string") {
@@ -8777,7 +9010,7 @@ function creator(isNew, spawn4) {
8777
9010
  if (m.links.route(client, d)) return;
8778
9011
  let result;
8779
9012
  try {
8780
- result = spawn4(m, d);
9013
+ result = spawn5(m, d);
8781
9014
  } catch (error) {
8782
9015
  fail(client, d, error);
8783
9016
  return;
@@ -8968,7 +9201,7 @@ var handleDismiss = routed((_client, m, d) => {
8968
9201
  });
8969
9202
 
8970
9203
  // src/commands/sessions/daemon/links/routeOutputToLink.ts
8971
- import { randomUUID } from "crypto";
9204
+ import { randomUUID as randomUUID2 } from "crypto";
8972
9205
  function unavailable(links, node) {
8973
9206
  const status = links.nodes().links.find((link) => link.name === node);
8974
9207
  if (!status)
@@ -8992,7 +9225,7 @@ function routeOutputToLink(client, links, data) {
8992
9225
  });
8993
9226
  return void 0;
8994
9227
  }
8995
- links.route(client, { ...data, requestId: data.requestId ?? randomUUID() });
9228
+ links.route(client, { ...data, requestId: data.requestId ?? randomUUID2() });
8996
9229
  return void 0;
8997
9230
  }
8998
9231
 
@@ -9207,7 +9440,7 @@ async function handleFetchSessionTranscript(client, manager, data) {
9207
9440
  }
9208
9441
 
9209
9442
  // src/commands/sessions/daemon/handleFetchTranscript.ts
9210
- import { randomUUID as randomUUID2 } from "crypto";
9443
+ import { randomUUID as randomUUID3 } from "crypto";
9211
9444
 
9212
9445
  // src/commands/sessions/shared/parseTranscript.ts
9213
9446
  import * as fs4 from "fs";
@@ -9246,7 +9479,7 @@ function handleFetchTranscript(client, manager, data) {
9246
9479
  routeOrReadLocal(client, manager, {
9247
9480
  ...data,
9248
9481
  sessionId: toNodeSessionId(node, sessionId),
9249
- requestId: data.requestId ?? randomUUID2()
9482
+ requestId: data.requestId ?? randomUUID3()
9250
9483
  });
9251
9484
  }
9252
9485
 
@@ -9705,14 +9938,14 @@ function spawnAssistCreate(m, d) {
9705
9938
  },
9706
9939
  spawnContextFrom(d)
9707
9940
  );
9708
- const spawn4 = (holder) => m.spawnAssist(
9941
+ const spawn5 = (holder) => m.spawnAssist(
9709
9942
  assistArgs,
9710
9943
  holder ?? cwd,
9711
9944
  { ...meta, inPlace: inPlace || holder !== void 0 },
9712
9945
  spawnContextFrom(d)
9713
9946
  );
9714
- if (inPlace || !isPrCheckoutArgs(assistArgs)) return spawn4();
9715
- return prCheckoutHolder(assistArgs, cwd).then(spawn4);
9947
+ if (inPlace || !isPrCheckoutArgs(assistArgs)) return spawn5();
9948
+ return prCheckoutHolder(assistArgs, cwd).then(spawn5);
9716
9949
  }
9717
9950
 
9718
9951
  // src/commands/sessions/daemon/sessionBlocker.ts
@@ -9826,6 +10059,8 @@ var messageHandlers = {
9826
10059
  ...pinHandlers,
9827
10060
  "type-prompt": handleTypePrompt,
9828
10061
  "sdk-launch": handleSdkLaunch,
10062
+ "sdk-shell": handleSdkShell,
10063
+ "sdk-shell-stop": handleSdkShellStop,
9829
10064
  "type-prompt-to-writer": handleTypePromptToWriter,
9830
10065
  ...retryHandlers,
9831
10066
  dismiss: handleDismiss,
@@ -3,24 +3,24 @@ import {
3
3
  } from "./chunk-FDWIKBS3.js";
4
4
  import {
5
5
  refine
6
- } from "./chunk-NCTA64LR.js";
7
- import "./chunk-HL5PHECL.js";
8
- import "./chunk-IYOKTOCX.js";
6
+ } from "./chunk-IUBV4ZNS.js";
7
+ import "./chunk-Q2FPO2KT.js";
8
+ import "./chunk-WJM6BSEL.js";
9
9
  import "./chunk-SB4BG7PH.js";
10
10
  import "./chunk-B3JSQA5D.js";
11
- import "./chunk-4YTZUN24.js";
12
- import "./chunk-DRCSMAFZ.js";
11
+ import "./chunk-BWOCKEUI.js";
12
+ import "./chunk-FQJJEZ3O.js";
13
13
  import "./chunk-7NZOH4LN.js";
14
14
  import "./chunk-F7QYFJB2.js";
15
15
  import "./chunk-ZYK7V4PG.js";
16
16
  import "./chunk-PYACTCZ2.js";
17
17
  import "./chunk-4YAIQN3S.js";
18
18
  import "./chunk-NWNODYLQ.js";
19
- import "./chunk-FF5VHS2Q.js";
20
- import "./chunk-B6TSGDM3.js";
19
+ import "./chunk-DTRDXHGW.js";
20
+ import "./chunk-UY75YJI5.js";
21
21
  import "./chunk-OZNYQOQK.js";
22
22
  import "./chunk-WTQRIUSK.js";
23
- import "./chunk-PVL3555C.js";
23
+ import "./chunk-6FGA6L2E.js";
24
24
  import "./chunk-ORSRBZ2X.js";
25
25
  import "./chunk-PCF66ALO.js";
26
26
  import "./chunk-UYD7R4HL.js";
@@ -33,10 +33,10 @@ import "./chunk-QAJUCN3A.js";
33
33
  import "./chunk-UVTZ4VFK.js";
34
34
  import "./chunk-DISNKALJ.js";
35
35
  import "./chunk-BJDGVLYX.js";
36
- import "./chunk-XHYDG7UZ.js";
37
- import "./chunk-5TJEQ6SM.js";
38
- import "./chunk-F4ADOEV4.js";
39
- import "./chunk-5A63PEQ4.js";
36
+ import "./chunk-NLTT3LC6.js";
37
+ import "./chunk-DNUEENBJ.js";
38
+ import "./chunk-5CT7CKQM.js";
39
+ import "./chunk-L6RKPFKP.js";
40
40
  import "./chunk-PYZUB3JT.js";
41
41
  import "./chunk-U732RAGX.js";
42
42
  import "./chunk-TCTX3UXU.js";
@@ -48,10 +48,10 @@ import "./chunk-3QKE2ONF.js";
48
48
  import "./chunk-O5JIFWMQ.js";
49
49
  import "./chunk-LMUTL44M.js";
50
50
  import "./chunk-6NDXAN45.js";
51
- import "./chunk-J4SHN7I2.js";
51
+ import "./chunk-MVSLFBWG.js";
52
52
  import "./chunk-MELBVXKL.js";
53
53
  import "./chunk-OGJ6AZK4.js";
54
- import "./chunk-2IH2A3JK.js";
54
+ import "./chunk-43MJXI4R.js";
55
55
  import "./chunk-MRUIXQXS.js";
56
56
  import "./chunk-HO7RNI6V.js";
57
57
  import "./chunk-DIAC4XYA.js";
@@ -2,7 +2,7 @@ import {
2
2
  formatScanUsage,
3
3
  inboxScanBlocker,
4
4
  runInboxScan
5
- } from "./chunk-LMXSHIFC.js";
5
+ } from "./chunk-ZAS2ZWEK.js";
6
6
  import "./chunk-2JYMVJGZ.js";
7
7
  import "./chunk-NWNODYLQ.js";
8
8
  import {
@@ -20,7 +20,7 @@ import "./chunk-MELBVXKL.js";
20
20
  import "./chunk-OGJ6AZK4.js";
21
21
  import {
22
22
  harnessAdapter
23
- } from "./chunk-2IH2A3JK.js";
23
+ } from "./chunk-43MJXI4R.js";
24
24
  import "./chunk-MRUIXQXS.js";
25
25
  import "./chunk-HO7RNI6V.js";
26
26
  import "./chunk-DIAC4XYA.js";
@@ -15,7 +15,7 @@ import {
15
15
  currentExecutionIdentity,
16
16
  getSchemaSessionApprovalDir,
17
17
  getSchemaSessionApprovalPath
18
- } from "./chunk-4OZ6ULV6.js";
18
+ } from "./chunk-EAREJAOY.js";
19
19
  import "./chunk-ZMH7UZNP.js";
20
20
  import {
21
21
  recordGitRef
@@ -31,7 +31,7 @@ import "./chunk-3QKE2ONF.js";
31
31
  import "./chunk-O5JIFWMQ.js";
32
32
  import "./chunk-LMUTL44M.js";
33
33
  import "./chunk-6NDXAN45.js";
34
- import "./chunk-2IH2A3JK.js";
34
+ import "./chunk-43MJXI4R.js";
35
35
  import "./chunk-MRUIXQXS.js";
36
36
  import "./chunk-HO7RNI6V.js";
37
37
  import "./chunk-DIAC4XYA.js";
@@ -11,7 +11,7 @@ import "./chunk-JVG5AJA2.js";
11
11
  import {
12
12
  currentExecutionIdentity,
13
13
  getSchemaSessionApprovalPath
14
- } from "./chunk-4OZ6ULV6.js";
14
+ } from "./chunk-EAREJAOY.js";
15
15
  import "./chunk-ZMH7UZNP.js";
16
16
  import "./chunk-FPWL4VRC.js";
17
17
  import "./chunk-E36L7ASL.js";
@@ -30,7 +30,7 @@ import "./chunk-3QKE2ONF.js";
30
30
  import "./chunk-O5JIFWMQ.js";
31
31
  import "./chunk-LMUTL44M.js";
32
32
  import "./chunk-6NDXAN45.js";
33
- import "./chunk-2IH2A3JK.js";
33
+ import "./chunk-43MJXI4R.js";
34
34
  import "./chunk-MRUIXQXS.js";
35
35
  import "./chunk-HO7RNI6V.js";
36
36
  import "./chunk-DIAC4XYA.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  statusIcon,
3
3
  typeLabel
4
- } from "./chunk-PVL3555C.js";
5
- import "./chunk-F4ADOEV4.js";
6
- import "./chunk-5A63PEQ4.js";
4
+ } from "./chunk-6FGA6L2E.js";
5
+ import "./chunk-5CT7CKQM.js";
6
+ import "./chunk-L6RKPFKP.js";
7
7
  import {
8
8
  searchBacklog
9
9
  } from "./chunk-PYZUB3JT.js";
@@ -18,10 +18,10 @@ import "./chunk-3QKE2ONF.js";
18
18
  import "./chunk-O5JIFWMQ.js";
19
19
  import "./chunk-LMUTL44M.js";
20
20
  import "./chunk-6NDXAN45.js";
21
- import "./chunk-J4SHN7I2.js";
21
+ import "./chunk-MVSLFBWG.js";
22
22
  import "./chunk-MELBVXKL.js";
23
23
  import "./chunk-OGJ6AZK4.js";
24
- import "./chunk-2IH2A3JK.js";
24
+ import "./chunk-43MJXI4R.js";
25
25
  import "./chunk-MRUIXQXS.js";
26
26
  import "./chunk-HO7RNI6V.js";
27
27
  import "./chunk-DIAC4XYA.js";
@@ -5,15 +5,15 @@ import "./chunk-QRTB7PVR.js";
5
5
  import "./chunk-3VDV7VHX.js";
6
6
  import {
7
7
  targetConversationEvents
8
- } from "./chunk-LD3C7W3Q.js";
9
- import "./chunk-BUX5FETL.js";
8
+ } from "./chunk-UCTFPC6X.js";
9
+ import "./chunk-WWWNWP3Z.js";
10
10
  import {
11
11
  readSocketLines
12
12
  } from "./chunk-2EW62DM5.js";
13
13
  import "./chunk-OGJ6AZK4.js";
14
14
  import {
15
15
  harnessAdapter
16
- } from "./chunk-2IH2A3JK.js";
16
+ } from "./chunk-43MJXI4R.js";
17
17
  import "./chunk-MRUIXQXS.js";
18
18
  import "./chunk-HO7RNI6V.js";
19
19
  import "./chunk-DIAC4XYA.js";