very-happy-cli 0.2.159 → 0.2.161

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 (259) hide show
  1. package/dist/{AcpBackend-VsfkZiVF.mjs → AcpBackend-6U6pQgx1.mjs} +4 -2
  2. package/dist/{AcpBackend-DUYFlyfN.cjs → AcpBackend-Ba98QDif.cjs} +78 -76
  3. package/dist/{AcpSessionManager-Bdv8LWXh.cjs → AcpSessionManager-BAY1Pggx.cjs} +9 -9
  4. package/dist/{AcpSessionManager-rYtVb0kN.mjs → AcpSessionManager-CoMWFVw3.mjs} +1 -1
  5. package/dist/BasePermissionHandler-2R0uH2CI.cjs +157 -0
  6. package/dist/BasePermissionHandler-BvvhBTja.mjs +155 -0
  7. package/dist/BaseReasoningProcessor-DyhO1uoU.mjs +198 -0
  8. package/dist/BaseReasoningProcessor-fsVNmCEF.cjs +200 -0
  9. package/dist/RemoteModeDisplay-D-HewyXg.mjs +150 -0
  10. package/dist/RemoteModeDisplay-NC1gPHtj.cjs +153 -0
  11. package/dist/agentAttachments-Dbw8iMCZ.cjs +20 -0
  12. package/dist/agentAttachments-M_B5qEF2.mjs +18 -0
  13. package/dist/agentGuidance-B5NATuFa.cjs +28 -0
  14. package/dist/agentGuidance-CQuNlNx8.mjs +20 -0
  15. package/dist/{agentHome-CvsJyeQB.mjs → agentHome-Ck1i1TQB.mjs} +8 -22
  16. package/dist/{agentHome-CHh4lmjM.cjs → agentHome-DvNnGphb.cjs} +14 -28
  17. package/dist/api-B2vLMS-z.cjs +3346 -0
  18. package/dist/api-SffjRQ1b.mjs +3339 -0
  19. package/dist/{types-Dh-s4Lqs.mjs → apiMachine-BpW9t8MO.mjs} +9116 -16205
  20. package/dist/{types-BbvK1Tr_.cjs → apiMachine-gFA54X7y.cjs} +9104 -16247
  21. package/dist/assistantTools-BfA0R3_m.cjs +380 -0
  22. package/dist/assistantTools-CgiTbnWb.mjs +376 -0
  23. package/dist/attachmentContent-CSGxr71v.mjs +82 -0
  24. package/dist/attachmentContent-DMMZzevR.cjs +88 -0
  25. package/dist/attachmentLimits-CzVrqgLR.cjs +354 -0
  26. package/dist/attachmentLimits-yba1uHFO.mjs +348 -0
  27. package/dist/auth-Bt4ceBBy.cjs +227 -0
  28. package/dist/auth-CYHjQ8oQ.mjs +225 -0
  29. package/dist/auth-DdyVZSo6.mjs +218 -0
  30. package/dist/auth-x4CEoysH.cjs +220 -0
  31. package/dist/authRelay-BdYkC1Po.cjs +156 -0
  32. package/dist/authRelay-DSAvg1uv.mjs +143 -0
  33. package/dist/{auto-DKmEls8Z.cjs → auto-BDXDUnjB.cjs} +70 -79
  34. package/dist/{auto-nb8GhRRy.mjs → auto-CXLlRi3a.mjs} +27 -36
  35. package/dist/backgroundTaskActivity-8PdPxrvy.mjs +149 -0
  36. package/dist/backgroundTaskActivity-CBvUdj39.cjs +157 -0
  37. package/dist/bootstrap-BNQq05jR.mjs +112 -0
  38. package/dist/bootstrap-CkgIq8N3.cjs +116 -0
  39. package/dist/browser-9pyhQr1R.mjs +20 -0
  40. package/dist/browser-BDOlKWYe.cjs +22 -0
  41. package/dist/claudeCliPath-BqkaH2oR.mjs +8 -0
  42. package/dist/claudeCliPath-U4HHmV4r.cjs +10 -0
  43. package/dist/claudeLocal-BDuGFnjJ.cjs +343 -0
  44. package/dist/claudeLocal-CQa8qnwq.mjs +339 -0
  45. package/dist/claudeLocalLauncher-Bd5I2-j6.cjs +154 -0
  46. package/dist/claudeLocalLauncher-CDqQI9ak.mjs +152 -0
  47. package/dist/cliUpdate-DsKXPFYp.cjs +120 -0
  48. package/dist/cliUpdate-Y34VGe9Y.mjs +112 -0
  49. package/dist/client-Brn-UwVk.mjs +100 -0
  50. package/dist/client-CXb1VJui.mjs +112 -0
  51. package/dist/client-C_axwRry.cjs +104 -0
  52. package/dist/client-DOBWJL3u.cjs +119 -0
  53. package/dist/codex/happyMcpStdioBridge.cjs +33 -14
  54. package/dist/codex/happyMcpStdioBridge.mjs +26 -7
  55. package/dist/codexAppServerClient-ZzhUTWPo.cjs +1090 -0
  56. package/dist/codexAppServerClient-oeQKD6Qf.mjs +1088 -0
  57. package/dist/codexCommand-C7H0NpBe.cjs +2088 -0
  58. package/dist/codexCommand-CJ82bl3l.mjs +2086 -0
  59. package/dist/codexThreadFork-BCaEMBiM.mjs +338 -0
  60. package/dist/codexThreadFork-BZqF-9bX.cjs +350 -0
  61. package/dist/{config-ClLtM6F3.mjs → config-BglnktIo.mjs} +7 -40
  62. package/dist/{config-DLx-vW3I.cjs → config-CYpL1Ahd.cjs} +26 -59
  63. package/dist/configuration-DoWFJUPm.mjs +170 -0
  64. package/dist/configuration-v9f8LM9T.cjs +181 -0
  65. package/dist/connect-hgcNjyAB.mjs +682 -0
  66. package/dist/connect-yEvjdRvx.cjs +684 -0
  67. package/dist/constants-BC4St0xd.mjs +11 -0
  68. package/dist/constants-VJ0N6WuG.cjs +17 -0
  69. package/dist/contentLogMetadata-BlWI0egu.mjs +51 -0
  70. package/dist/contentLogMetadata-ZSFk_NjQ.cjs +54 -0
  71. package/dist/context-B45vMtSZ.cjs +69 -0
  72. package/dist/context-C9GHPLEm.mjs +65 -0
  73. package/dist/controlClient-DjoKTtgK.mjs +260 -0
  74. package/dist/controlClient-fEHE85bH.cjs +279 -0
  75. package/dist/createSessionMetadata-BRLB9CNO.cjs +58 -0
  76. package/dist/createSessionMetadata-mIeehclp.mjs +54 -0
  77. package/dist/defaultPermissionMode-BnxJPVHT.mjs +4 -0
  78. package/dist/defaultPermissionMode-CxmTXUQR.cjs +7 -0
  79. package/dist/detectCLI-CSGMlV51.mjs +58 -0
  80. package/dist/detectCLI-DR9ZaN6B.cjs +61 -0
  81. package/dist/deterministicJson-DKDP_mM-.cjs +507 -0
  82. package/dist/deterministicJson-p835AdAU.mjs +502 -0
  83. package/dist/doctor-BPkYWSuq.mjs +75 -0
  84. package/dist/doctor-BeUuQXFs.mjs +391 -0
  85. package/dist/doctor-hVNnSZJn.cjs +395 -0
  86. package/dist/doctor-u46qYYKX.cjs +79 -0
  87. package/dist/doctorReadiness-BCZGcN0a.cjs +151 -0
  88. package/dist/doctorReadiness-C208SMN9.mjs +142 -0
  89. package/dist/editPaths-BVfS_FFL.mjs +68 -0
  90. package/dist/editPaths-Bqp4OFPw.cjs +73 -0
  91. package/dist/ensureDaemonRunning-CO7d1gOC.mjs +61 -0
  92. package/dist/ensureDaemonRunning-Dg9aZfjs.cjs +64 -0
  93. package/dist/handleResumeCommand-BiTPK0qd.mjs +240 -0
  94. package/dist/handleResumeCommand-DnVmy7a3.cjs +245 -0
  95. package/dist/ids-B6ZC0HGt.cjs +13 -0
  96. package/dist/ids-DU6sLx4C.mjs +10 -0
  97. package/dist/index-B6UGRQ7h.mjs +102 -0
  98. package/dist/{index-2mCaeKyf.mjs → index-CAFwetLk.mjs} +68 -38
  99. package/dist/index-Cqx-Raq6.mjs +68 -0
  100. package/dist/index-D3kI0hDR.cjs +107 -0
  101. package/dist/index-DA7yINuk.cjs +994 -0
  102. package/dist/{index-BEOMECtE.cjs → index-LIn6nCcq.cjs} +121 -91
  103. package/dist/index-Pf2cV9cn.cjs +182 -0
  104. package/dist/index-SPGPenK5.mjs +158 -0
  105. package/dist/index-gNTWtSKN.cjs +71 -0
  106. package/dist/index-qdS1friN.mjs +949 -0
  107. package/dist/index.cjs +5 -46
  108. package/dist/index.mjs +5 -46
  109. package/dist/{install-BPhJppvd.mjs → install-BO_W7VhL.mjs} +37 -37
  110. package/dist/install-Bu85vlHD.cjs +88 -0
  111. package/dist/install-ClUUl3yp.mjs +86 -0
  112. package/dist/{install-BOHrUaFM.cjs → install-Cs5qAPrB.cjs} +38 -38
  113. package/dist/{installPiTools-DuZ6jZvX.cjs → installPiTools-BKnXjrVu.cjs} +2 -3
  114. package/dist/{installPiTools-Cj7yU9Fc.mjs → installPiTools-B_CdM5_2.mjs} +1 -2
  115. package/dist/{installTerminalHooks-Cou3WUf3.cjs → installTerminalHooks-BQZbvxsZ.cjs} +5 -40
  116. package/dist/{installTerminalHooks-WeznjkuC.mjs → installTerminalHooks-By7gBMEF.mjs} +3 -38
  117. package/dist/lib.cjs +28 -19
  118. package/dist/lib.d.cts +12 -2
  119. package/dist/lib.d.mts +12 -2
  120. package/dist/lib.mjs +23 -14
  121. package/dist/lidState-C2dI0FAN.mjs +297 -0
  122. package/dist/lidState-KHHu1015.cjs +305 -0
  123. package/dist/limits-C-a7gr04.cjs +43 -0
  124. package/dist/limits-DIo7rEBR.mjs +36 -0
  125. package/dist/localHappyAgentAuth-BXiHPXdC.cjs +86 -0
  126. package/dist/localHappyAgentAuth-DCsetiyG.mjs +82 -0
  127. package/dist/logger-Bc8-u1w0.cjs +275 -0
  128. package/dist/logger-fXoNzNuB.mjs +271 -0
  129. package/dist/loginShellEnv-BkuYtExZ.cjs +182 -0
  130. package/dist/loginShellEnv-Dw8M7tkI.mjs +167 -0
  131. package/dist/machineMetadata-BHjehxJY.mjs +38 -0
  132. package/dist/machineMetadata-BibDMFVx.cjs +41 -0
  133. package/dist/main-BktM4A1K.mjs +939 -0
  134. package/dist/main-CLaX-t-b.cjs +941 -0
  135. package/dist/manager-BQ4flvQZ.mjs +101 -0
  136. package/dist/manager-Cly8xVIR.cjs +105 -0
  137. package/dist/{mcp-Dy3f_K0h.mjs → mcp-CeUd9KDr.mjs} +27 -33
  138. package/dist/{mcp-CPYbtsYG.cjs → mcp-GBfE70nk.cjs} +42 -48
  139. package/dist/messageBuffer-BWlGgR3A.mjs +71 -0
  140. package/dist/messageBuffer-fJMH6uY8.cjs +73 -0
  141. package/dist/mirrorProtocol-BNLtoWjO.mjs +170 -0
  142. package/dist/mirrorProtocol-BUtmg1ws.cjs +186 -0
  143. package/dist/oneShotPrompts-CL0dip9C.cjs +16 -0
  144. package/dist/oneShotPrompts-DT4p6RNd.mjs +12 -0
  145. package/dist/package-Cl5BEP5x.cjs +173 -0
  146. package/dist/package-uOg9SCKi.mjs +171 -0
  147. package/dist/path-B7zW-WwE.cjs +18 -0
  148. package/dist/path-D2wdaNSk.mjs +15 -0
  149. package/dist/peerTools-CIeiy9wn.cjs +283 -0
  150. package/dist/peerTools-Dz3_7Bkk.mjs +272 -0
  151. package/dist/permissionMode-CH4FoZfU.mjs +80 -0
  152. package/dist/permissionMode-CrV-XuMs.cjs +87 -0
  153. package/dist/persistence-CBNMzSa8.cjs +414 -0
  154. package/dist/persistence-oET5n61f.mjs +372 -0
  155. package/dist/piExtension.mjs +2 -1
  156. package/dist/piRunnerArgs-Bf7RUF__.cjs +66 -0
  157. package/dist/piRunnerArgs-Dk1ncwHF.mjs +59 -0
  158. package/dist/{piRuntime-NtF0YqjH.cjs → piRuntime-B_6TE9Eb.cjs} +4 -4
  159. package/dist/{piRuntime-kLZNpAAl.mjs → piRuntime-BwRdhK_N.mjs} +2 -2
  160. package/dist/{piTerminal-B0fEOV_2.mjs → piTerminal-Bap3R8Re.mjs} +32 -35
  161. package/dist/{piTerminal-9J0GAKzb.cjs → piTerminal-CagmEoez.cjs} +32 -35
  162. package/dist/previewPath-B0rBdhy1.cjs +83 -0
  163. package/dist/previewPath-CXN4Vag0.mjs +81 -0
  164. package/dist/projectPath-BTBIMB57.mjs +10 -0
  165. package/dist/projectPath-ChLhdOyt.cjs +13 -0
  166. package/dist/registerCommonHandlers-BjSV2Skz.cjs +538 -0
  167. package/dist/registerCommonHandlers-CrgvJsOy.mjs +536 -0
  168. package/dist/registerKillSessionHandler-6TC2S3lf.cjs +366 -0
  169. package/dist/registerKillSessionHandler-Cbc8Rgtd.mjs +363 -0
  170. package/dist/remoteSessionClient-BNx78NLb.cjs +634 -0
  171. package/dist/remoteSessionClient-CO7qOjR0.mjs +612 -0
  172. package/dist/resources-BdFBQi8r.mjs +117 -0
  173. package/dist/resources-JDPugcDq.cjs +120 -0
  174. package/dist/run-2l5vSt2h.mjs +5743 -0
  175. package/dist/run-D5xAEWSB.cjs +5766 -0
  176. package/dist/runClaude-BX6ixjtW.cjs +894 -0
  177. package/dist/runClaude-BgN6xo05.mjs +892 -0
  178. package/dist/runClaudeDeps-Bp20MScE.cjs +4168 -0
  179. package/dist/runClaudeDeps-COBBhD9o.mjs +4129 -0
  180. package/dist/{runGemini-F-mqx3_K.cjs → runGemini-CSMPkt0p.cjs} +202 -175
  181. package/dist/{runGemini-DV6Ouadt.mjs → runGemini-Cc2jq-uh.mjs} +58 -31
  182. package/dist/{runOpenClaw-D7MlPS5n.mjs → runOpenClaw-CIlCwdW2.mjs} +31 -32
  183. package/dist/{runOpenClaw-Qqo9j63M.cjs → runOpenClaw-YBwua4Rf.cjs} +64 -65
  184. package/dist/sandbox-C4gXLP1p.cjs +187 -0
  185. package/dist/sandbox-CNkwOtHI.mjs +180 -0
  186. package/dist/selfCheck-CU8xSDsl.cjs +87 -0
  187. package/dist/selfCheck-hJ6PCh7v.mjs +84 -0
  188. package/dist/{send-CLhYXNgy.mjs → send-CGHcKZ-w.mjs} +12 -5
  189. package/dist/{send-4qJTCAYW.cjs → send-DY9Nr-x4.cjs} +16 -9
  190. package/dist/server-II51Mimf.cjs +407 -0
  191. package/dist/server-m2b5pamZ.mjs +404 -0
  192. package/dist/sessionLock-7ePAYDOg.cjs +205 -0
  193. package/dist/sessionLock-Cw6FmbMv.mjs +197 -0
  194. package/dist/sessionModeFile-BVCV5f7E.cjs +36 -0
  195. package/dist/sessionModeFile-CDmDyRkD.mjs +32 -0
  196. package/dist/sessionOps-C_f1wKOr.mjs +760 -0
  197. package/dist/sessionOps-DJdExmBy.cjs +783 -0
  198. package/dist/sessionScanner-CaAHLyNV.mjs +206 -0
  199. package/dist/sessionScanner-D1goKdd3.cjs +209 -0
  200. package/dist/{sessions-Bh1pyddi.cjs → sessions-DGs6ALNo.cjs} +37 -28
  201. package/dist/{sessions-CzIH2rGp.mjs → sessions-DnvmWUel.mjs} +17 -8
  202. package/dist/setupOfflineReconnection-CVViqZft.mjs +72 -0
  203. package/dist/setupOfflineReconnection-R7XuR_sj.cjs +74 -0
  204. package/dist/smallFastModel-BLNgMrwR.mjs +18 -0
  205. package/dist/smallFastModel-D_uxGMo3.cjs +21 -0
  206. package/dist/{spawn-CmFOSVdW.cjs → spawn-CXTH7qg1.cjs} +61 -65
  207. package/dist/{spawn-CPIWlPOM.mjs → spawn-DNYSvFtC.mjs} +35 -40
  208. package/dist/spawnAgents-BGQiEF-w.cjs +52 -0
  209. package/dist/spawnAgents-DZzZ9jMI.mjs +45 -0
  210. package/dist/spawnHappyCLI-BhYj84rv.cjs +66 -0
  211. package/dist/spawnHappyCLI-cqWQbwsb.mjs +64 -0
  212. package/dist/specialCommands-BSqhYg5X.mjs +52 -0
  213. package/dist/specialCommands-DSsTeRej.cjs +54 -0
  214. package/dist/startFileWatcher-CKKx-8ZO.cjs +71 -0
  215. package/dist/startFileWatcher-CdegMbJj.mjs +69 -0
  216. package/dist/startupPlan-BLMbfQIH.cjs +12 -0
  217. package/dist/startupPlan-DFMyNgAs.mjs +10 -0
  218. package/dist/streamRelay-BiKw59Cc.cjs +233 -0
  219. package/dist/streamRelay-FPVbHpbM.mjs +231 -0
  220. package/dist/sync-CVk4QERO.cjs +71 -0
  221. package/dist/sync-CxD-w_40.mjs +69 -0
  222. package/dist/systemPrompt-BygJcmbi.cjs +97 -0
  223. package/dist/systemPrompt-DmtypUc7.mjs +94 -0
  224. package/dist/{teams-CEahj4cm.mjs → teams-BOC6nIPL.mjs} +9 -40
  225. package/dist/{teams-CB1R9-Z9.cjs → teams-BsvpOBfn.cjs} +14 -45
  226. package/dist/template-BaHAmH2K.cjs +129 -0
  227. package/dist/template-CiOPa2rd.mjs +121 -0
  228. package/dist/{terminalTitleSuggest-DKgX3osW.mjs → terminalTitleSuggest-CeKsX_V6.mjs} +1 -9
  229. package/dist/{terminalTitleSuggest-Dji8I0Jy.cjs → terminalTitleSuggest-DhvRFX3H.cjs} +0 -10
  230. package/dist/terminals-B_bfC9c2.cjs +250 -0
  231. package/dist/terminals-Dlg0x3nY.mjs +235 -0
  232. package/dist/time-BZNdNiIV.mjs +38 -0
  233. package/dist/time-CNRE4ChD.cjs +42 -0
  234. package/dist/titleGenerator-CFRhU-xq.cjs +172 -0
  235. package/dist/titleGenerator-ox6ptCsp.mjs +166 -0
  236. package/dist/tmuxSocket-B8Yx20sT.mjs +19 -0
  237. package/dist/tmuxSocket-D-Xt6Vn-.cjs +24 -0
  238. package/dist/{todo-DqyRI4wP.cjs → todo-B-KB7oAB.cjs} +15 -12
  239. package/dist/{todo-Cknp5D4U.mjs → todo-C5KBVbUw.mjs} +11 -8
  240. package/dist/tools-BZabNIid.mjs +177 -0
  241. package/dist/tools-BmQQUATY.mjs +60 -0
  242. package/dist/tools-CsSovyNp.cjs +180 -0
  243. package/dist/tools-lMDra4Pv.cjs +63 -0
  244. package/dist/trimIdent-4gvk9Wk6.cjs +22 -0
  245. package/dist/trimIdent-BAjmv_TG.mjs +20 -0
  246. package/dist/types-CRS-srZK.cjs +66 -0
  247. package/dist/types-CkqAACXx.mjs +64 -0
  248. package/dist/uninstall-B1WLtC1d.mjs +47 -0
  249. package/dist/uninstall-fvA5aWpU.cjs +49 -0
  250. package/package.json +7 -7
  251. package/scripts/session_hook_forwarder.cjs +9 -2
  252. package/dist/agentGuidance-BRDN1NoZ.cjs +0 -2217
  253. package/dist/agentGuidance-KgvYuF3R.mjs +0 -2145
  254. package/dist/index-BF6WfgV5.mjs +0 -19624
  255. package/dist/index-C-JazrMB.mjs +0 -52
  256. package/dist/index-blDSadUR.cjs +0 -58
  257. package/dist/index-rH3DrQ5B.cjs +0 -19688
  258. package/dist/limits-BH5CV5vR.cjs +0 -2683
  259. package/dist/limits-CjRj8IX5.mjs +0 -2558
@@ -0,0 +1,231 @@
1
+ import { S as STREAM_DELTA_MAX_CHARS } from './index-qdS1friN.mjs';
2
+
3
+ const STREAM_FLUSH_MS = 80;
4
+ const PROGRESS_FLUSH_MS = 250;
5
+ const STREAM_FLUSH_MAX_BYTES = 16 * 1024;
6
+ class StreamRelay {
7
+ send;
8
+ setTimer;
9
+ clearTimer;
10
+ now;
11
+ /** The block currently accumulating deltas. At most one is open at a time
12
+ * in practice; a switch flushes the previous one first, so out-of-order
13
+ * SDK frames degrade to "slightly chunkier", never to interleaved text. */
14
+ pending = null;
15
+ flushHandle = null;
16
+ progress = {};
17
+ progressDirty = false;
18
+ progressHandle = null;
19
+ /** Message id of the block currently open, so `content_block_delta` (which
20
+ * carries only an index) can be attributed. Reset per assistant message. */
21
+ currentMid = null;
22
+ openBlocks = /* @__PURE__ */ new Set();
23
+ /** True while nothing has been ingested since the last sweep. Both the SDK
24
+ * `result` frame and the launcher's `finally` call endTurn (the second is
25
+ * the safety net for turns that die before producing a result), so
26
+ * without this a normal turn would emit two sweeps. */
27
+ idleSinceTurnEnd = true;
28
+ constructor(options) {
29
+ this.send = options.send;
30
+ this.setTimer = options.setTimer ?? ((fn, ms) => setTimeout(fn, ms));
31
+ this.clearTimer = options.clearTimer ?? ((handle) => clearTimeout(handle));
32
+ this.now = options.now ?? (() => Date.now());
33
+ }
34
+ /** Feed one SDK frame. Unknown shapes are ignored, never thrown on: this
35
+ * channel must not be able to take a turn down. */
36
+ ingest(message) {
37
+ this.idleSinceTurnEnd = false;
38
+ try {
39
+ if (message.type === "stream_event") {
40
+ this.ingestStreamEvent(message.event);
41
+ return;
42
+ }
43
+ if (message.type === "system" && message.subtype === "thinking_tokens") {
44
+ if (typeof message.estimated_tokens === "number") {
45
+ this.setProgress({ thinkingTokens: message.estimated_tokens });
46
+ }
47
+ return;
48
+ }
49
+ if (message.type === "system" && message.subtype === "status") {
50
+ const status = message.status === "requesting" || message.status === "compacting" ? message.status : void 0;
51
+ this.progress.status = status;
52
+ this.progressDirty = true;
53
+ this.scheduleProgress();
54
+ return;
55
+ }
56
+ } catch {
57
+ }
58
+ }
59
+ /** The turn produced its result. Flushes everything and tells the web to
60
+ * sweep drafts that no persisted message ever claimed. */
61
+ endTurn() {
62
+ if (this.idleSinceTurnEnd) {
63
+ this.clearTimers();
64
+ return;
65
+ }
66
+ this.idleSinceTurnEnd = true;
67
+ this.flushPending();
68
+ this.closeOpenBlocks();
69
+ this.flushProgress();
70
+ this.progress = {};
71
+ this.currentMid = null;
72
+ this.send({ t: "turn-end" });
73
+ }
74
+ /** Release timers without emitting anything (session teardown). */
75
+ dispose() {
76
+ this.clearTimers();
77
+ this.pending = null;
78
+ this.openBlocks.clear();
79
+ }
80
+ clearTimers() {
81
+ if (this.flushHandle !== null) this.clearTimer(this.flushHandle);
82
+ if (this.progressHandle !== null) this.clearTimer(this.progressHandle);
83
+ this.flushHandle = null;
84
+ this.progressHandle = null;
85
+ }
86
+ ingestStreamEvent(event) {
87
+ const e = event;
88
+ if (!e || typeof e.type !== "string") return;
89
+ if (e.type === "message_start") {
90
+ const mid = e.message?.id;
91
+ this.flushPending();
92
+ this.closeOpenBlocks();
93
+ this.currentMid = typeof mid === "string" && mid.length > 0 ? mid : null;
94
+ const usage = e.message?.usage;
95
+ if (usage || ["inputTokens", "cacheTokens", "outputTokens", "thinkingTokens"].some((key) => key in this.progress)) {
96
+ const count = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
97
+ this.setProgress({
98
+ inputTokens: count(usage?.input_tokens),
99
+ cacheTokens: count(usage?.cache_creation_input_tokens) + count(usage?.cache_read_input_tokens),
100
+ outputTokens: count(usage?.output_tokens),
101
+ thinkingTokens: 0
102
+ });
103
+ }
104
+ return;
105
+ }
106
+ if (e.type === "content_block_start") {
107
+ const kind = e.content_block?.type === "thinking" ? "thinking" : e.content_block?.type === "text" ? "text" : null;
108
+ if (!kind || !this.currentMid || typeof e.index !== "number") return;
109
+ this.openBlock(this.currentMid, e.index, kind);
110
+ return;
111
+ }
112
+ if (e.type === "content_block_delta") {
113
+ const delta = e.delta;
114
+ const text = delta?.type === "text_delta" ? delta.text : delta?.type === "thinking_delta" ? delta.thinking : null;
115
+ if (typeof text !== "string" || text.length === 0) return;
116
+ if (!this.currentMid || typeof e.index !== "number") return;
117
+ this.appendDelta(this.currentMid, e.index, text);
118
+ return;
119
+ }
120
+ if (e.type === "content_block_stop") {
121
+ if (!this.currentMid || typeof e.index !== "number") return;
122
+ this.closeBlock(this.currentMid, e.index);
123
+ return;
124
+ }
125
+ if (e.type === "message_delta") {
126
+ const outputTokens = e.usage?.output_tokens;
127
+ if (typeof outputTokens === "number") {
128
+ this.setProgress({ outputTokens });
129
+ }
130
+ return;
131
+ }
132
+ }
133
+ // ---- Block-level API (see module comment) --------------------------------
134
+ /** Open a draft block. A different `mid` than the one currently open closes
135
+ * whatever the previous message left open, exactly like the SDK's
136
+ * `message_start` does. Re-opening an already open block is a no-op. */
137
+ openBlock(mid, idx, kind) {
138
+ this.idleSinceTurnEnd = false;
139
+ if (this.currentMid !== mid) {
140
+ this.flushPending();
141
+ this.closeOpenBlocks();
142
+ this.currentMid = mid;
143
+ }
144
+ if (this.openBlocks.has(idx)) return;
145
+ this.flushPending();
146
+ this.openBlocks.add(idx);
147
+ this.send({ t: "block-start", mid, idx, kind });
148
+ }
149
+ /** Append text to an OPEN block; deltas for a block that was never opened
150
+ * (or belongs to another message) are dropped — the SDK path relies on
151
+ * this to ignore `input_json_delta` for tool_use blocks. */
152
+ appendDelta(mid, idx, text) {
153
+ this.idleSinceTurnEnd = false;
154
+ if (text.length === 0) return;
155
+ if (this.currentMid !== mid || !this.openBlocks.has(idx)) return;
156
+ if (this.pending && (this.pending.mid !== mid || this.pending.idx !== idx)) {
157
+ this.flushPending();
158
+ }
159
+ if (!this.pending) {
160
+ this.pending = { mid, idx, text: "", bytes: 0 };
161
+ }
162
+ this.pending.text += text;
163
+ this.pending.bytes += Buffer.byteLength(text, "utf8");
164
+ if (this.pending.bytes >= STREAM_FLUSH_MAX_BYTES || this.pending.text.length >= STREAM_DELTA_MAX_CHARS) {
165
+ this.flushPending();
166
+ return;
167
+ }
168
+ if (this.flushHandle === null) {
169
+ this.flushHandle = this.setTimer(() => {
170
+ this.flushHandle = null;
171
+ this.flushPending();
172
+ }, STREAM_FLUSH_MS);
173
+ }
174
+ }
175
+ /** Close an open block: pending text goes out first, then `block-end`. */
176
+ closeBlock(mid, idx) {
177
+ this.idleSinceTurnEnd = false;
178
+ if (this.currentMid !== mid || !this.openBlocks.has(idx)) return;
179
+ this.flushPending();
180
+ this.openBlocks.delete(idx);
181
+ this.send({ t: "block-end", mid, idx });
182
+ }
183
+ /** Merge quantified progress; flushed on the progress cadence. */
184
+ setProgress(patch) {
185
+ this.idleSinceTurnEnd = false;
186
+ this.progress = { ...this.progress, ...patch };
187
+ this.progressDirty = true;
188
+ this.scheduleProgress();
189
+ }
190
+ // -------------------------------------------------------------------------
191
+ flushPending() {
192
+ if (this.flushHandle !== null) {
193
+ this.clearTimer(this.flushHandle);
194
+ this.flushHandle = null;
195
+ }
196
+ const pending = this.pending;
197
+ this.pending = null;
198
+ if (!pending || pending.text.length === 0) return;
199
+ this.send({ t: "block-delta", mid: pending.mid, idx: pending.idx, text: pending.text });
200
+ }
201
+ /** Close blocks the SDK never stopped (interrupt, error, message switch) so
202
+ * the web's draft does not keep a blinking cursor forever. */
203
+ closeOpenBlocks() {
204
+ if (!this.currentMid || this.openBlocks.size === 0) {
205
+ this.openBlocks.clear();
206
+ return;
207
+ }
208
+ for (const idx of [...this.openBlocks].sort((a, b) => a - b)) {
209
+ this.send({ t: "block-end", mid: this.currentMid, idx });
210
+ }
211
+ this.openBlocks.clear();
212
+ }
213
+ scheduleProgress() {
214
+ if (this.progressHandle !== null) return;
215
+ this.progressHandle = this.setTimer(() => {
216
+ this.progressHandle = null;
217
+ this.flushProgress();
218
+ }, PROGRESS_FLUSH_MS);
219
+ }
220
+ flushProgress() {
221
+ if (this.progressHandle !== null) {
222
+ this.clearTimer(this.progressHandle);
223
+ this.progressHandle = null;
224
+ }
225
+ if (!this.progressDirty) return;
226
+ this.progressDirty = false;
227
+ this.send({ t: "progress", ...this.progress });
228
+ }
229
+ }
230
+
231
+ export { StreamRelay as S };
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ var time = require('./time-CNRE4ChD.cjs');
4
+
5
+ class InvalidateSync {
6
+ _invalidated = false;
7
+ _invalidatedDouble = false;
8
+ _stopped = false;
9
+ _command;
10
+ _pendings = [];
11
+ constructor(command) {
12
+ this._command = command;
13
+ }
14
+ invalidate() {
15
+ if (this._stopped) {
16
+ return;
17
+ }
18
+ if (!this._invalidated) {
19
+ this._invalidated = true;
20
+ this._invalidatedDouble = false;
21
+ this._doSync();
22
+ } else {
23
+ if (!this._invalidatedDouble) {
24
+ this._invalidatedDouble = true;
25
+ }
26
+ }
27
+ }
28
+ async invalidateAndAwait() {
29
+ if (this._stopped) {
30
+ return;
31
+ }
32
+ await new Promise((resolve) => {
33
+ this._pendings.push(resolve);
34
+ this.invalidate();
35
+ });
36
+ }
37
+ stop() {
38
+ if (this._stopped) {
39
+ return;
40
+ }
41
+ this._notifyPendings();
42
+ this._stopped = true;
43
+ }
44
+ _notifyPendings = () => {
45
+ for (let pending of this._pendings) {
46
+ pending();
47
+ }
48
+ this._pendings = [];
49
+ };
50
+ _doSync = async () => {
51
+ await time.backoff(async () => {
52
+ if (this._stopped) {
53
+ return;
54
+ }
55
+ await this._command();
56
+ });
57
+ if (this._stopped) {
58
+ this._notifyPendings();
59
+ return;
60
+ }
61
+ if (this._invalidatedDouble) {
62
+ this._invalidatedDouble = false;
63
+ this._doSync();
64
+ } else {
65
+ this._invalidated = false;
66
+ this._notifyPendings();
67
+ }
68
+ };
69
+ }
70
+
71
+ exports.InvalidateSync = InvalidateSync;
@@ -0,0 +1,69 @@
1
+ import { b as backoff } from './time-BZNdNiIV.mjs';
2
+
3
+ class InvalidateSync {
4
+ _invalidated = false;
5
+ _invalidatedDouble = false;
6
+ _stopped = false;
7
+ _command;
8
+ _pendings = [];
9
+ constructor(command) {
10
+ this._command = command;
11
+ }
12
+ invalidate() {
13
+ if (this._stopped) {
14
+ return;
15
+ }
16
+ if (!this._invalidated) {
17
+ this._invalidated = true;
18
+ this._invalidatedDouble = false;
19
+ this._doSync();
20
+ } else {
21
+ if (!this._invalidatedDouble) {
22
+ this._invalidatedDouble = true;
23
+ }
24
+ }
25
+ }
26
+ async invalidateAndAwait() {
27
+ if (this._stopped) {
28
+ return;
29
+ }
30
+ await new Promise((resolve) => {
31
+ this._pendings.push(resolve);
32
+ this.invalidate();
33
+ });
34
+ }
35
+ stop() {
36
+ if (this._stopped) {
37
+ return;
38
+ }
39
+ this._notifyPendings();
40
+ this._stopped = true;
41
+ }
42
+ _notifyPendings = () => {
43
+ for (let pending of this._pendings) {
44
+ pending();
45
+ }
46
+ this._pendings = [];
47
+ };
48
+ _doSync = async () => {
49
+ await backoff(async () => {
50
+ if (this._stopped) {
51
+ return;
52
+ }
53
+ await this._command();
54
+ });
55
+ if (this._stopped) {
56
+ this._notifyPendings();
57
+ return;
58
+ }
59
+ if (this._invalidatedDouble) {
60
+ this._invalidatedDouble = false;
61
+ this._doSync();
62
+ } else {
63
+ this._invalidated = false;
64
+ this._notifyPendings();
65
+ }
66
+ };
67
+ }
68
+
69
+ export { InvalidateSync as I };
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var logger = require('./logger-Bc8-u1w0.cjs');
4
+ var node_fs = require('node:fs');
5
+ var path$1 = require('node:path');
6
+ var path = require('./path-B7zW-WwE.cjs');
7
+ var index = require('./index-DA7yINuk.cjs');
8
+ var trimIdent = require('./trimIdent-4gvk9Wk6.cjs');
9
+ var os = require('node:os');
10
+ var agentGuidance = require('./agentGuidance-B5NATuFa.cjs');
11
+
12
+ function claudeCheckSession(sessionId, path$2) {
13
+ const projectDir = path.getProjectPath(path$2);
14
+ const sessionFile = path$1.join(projectDir, `${sessionId}.jsonl`);
15
+ const sessionExists = node_fs.existsSync(sessionFile);
16
+ if (!sessionExists) {
17
+ logger.logger.debug(`[claudeCheckSession] Path ${sessionFile} does not exist`);
18
+ return false;
19
+ }
20
+ const sessionData = node_fs.readFileSync(sessionFile, "utf-8").split("\n");
21
+ const hasGoodMessage = !!sessionData.find((v, index) => {
22
+ if (!v.trim()) return false;
23
+ try {
24
+ const parsed = JSON.parse(v);
25
+ return typeof parsed.uuid === "string" && parsed.uuid.length > 0 || // Claude Code 2.1.x
26
+ typeof parsed.messageId === "string" && parsed.messageId.length > 0 || // Older Claude Code
27
+ typeof parsed.leafUuid === "string" && parsed.leafUuid.length > 0;
28
+ } catch (e) {
29
+ logger.logger.debug(`[claudeCheckSession] Malformed JSON at line ${index + 1}:`, e);
30
+ return false;
31
+ }
32
+ });
33
+ logger.logger.debug(`[claudeCheckSession] Session ${sessionId}: ${hasGoodMessage ? "valid" : "invalid"}`);
34
+ return hasGoodMessage;
35
+ }
36
+
37
+ function getClaudeSettingsPath() {
38
+ const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR || path$1.join(os.homedir(), ".claude");
39
+ return path$1.join(claudeConfigDir, "settings.json");
40
+ }
41
+ function readClaudeSettings() {
42
+ try {
43
+ const settingsPath = getClaudeSettingsPath();
44
+ if (!node_fs.existsSync(settingsPath)) {
45
+ logger.logger.debug(`[ClaudeSettings] No Claude settings file found at ${settingsPath}`);
46
+ return null;
47
+ }
48
+ const settingsContent = node_fs.readFileSync(settingsPath, "utf-8");
49
+ const settings = JSON.parse(settingsContent);
50
+ logger.logger.debug(`[ClaudeSettings] Successfully read Claude settings from ${settingsPath}`);
51
+ logger.logger.debug(`[ClaudeSettings] includeCoAuthoredBy: ${settings.includeCoAuthoredBy}`);
52
+ return settings;
53
+ } catch (error) {
54
+ logger.logger.debug(`[ClaudeSettings] Error reading Claude settings: ${error}`);
55
+ return null;
56
+ }
57
+ }
58
+ function shouldIncludeCoAuthoredBy() {
59
+ const settings = readClaudeSettings();
60
+ if (!settings) {
61
+ return true;
62
+ }
63
+ if (settings.attribution?.commit === "") {
64
+ return false;
65
+ }
66
+ if (settings.includeCoAuthoredBy === void 0) {
67
+ return true;
68
+ }
69
+ return settings.includeCoAuthoredBy;
70
+ }
71
+
72
+ const BASE_SYSTEM_PROMPT = (() => trimIdent.trimIdent(`
73
+ This chat is titled automatically from the user's first message. Call "mcp__happy__change_title" only when the topic has clearly moved on or the current title is too generic to find this chat later. Do not call it as a ritual at the start of a chat, and not for a quick question you can just answer.
74
+ `))() + "\n\n" + agentGuidance.AGENT_GUIDANCE + "\n\n" + index.BUILTIN_TODO_DISCOVERY;
75
+ const CO_AUTHORED_CREDITS = (() => trimIdent.trimIdent(`
76
+ When you yourself create a git commit, instead of just giving co-credit to Claude, also give credit to Happy like so:
77
+
78
+ <main commit message>
79
+
80
+ Generated with [Claude Code](https://claude.ai/code)
81
+ via [Very Happy](https://github.com/Mereithhh/very-happy)
82
+
83
+ Co-Authored-By: Claude <noreply@anthropic.com>
84
+
85
+ Do not add these lines to commit message text you only draft for the user.
86
+ `))();
87
+ const systemPrompt = (() => {
88
+ const includeCoAuthored = shouldIncludeCoAuthoredBy();
89
+ if (includeCoAuthored) {
90
+ return BASE_SYSTEM_PROMPT + "\n\n" + CO_AUTHORED_CREDITS;
91
+ } else {
92
+ return BASE_SYSTEM_PROMPT;
93
+ }
94
+ })();
95
+
96
+ exports.claudeCheckSession = claudeCheckSession;
97
+ exports.systemPrompt = systemPrompt;
@@ -0,0 +1,94 @@
1
+ import { l as logger } from './logger-fXoNzNuB.mjs';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { g as getProjectPath } from './path-D2wdaNSk.mjs';
5
+ import { l as BUILTIN_TODO_DISCOVERY } from './index-qdS1friN.mjs';
6
+ import { t as trimIdent } from './trimIdent-BAjmv_TG.mjs';
7
+ import { homedir } from 'node:os';
8
+ import { A as AGENT_GUIDANCE } from './agentGuidance-CQuNlNx8.mjs';
9
+
10
+ function claudeCheckSession(sessionId, path) {
11
+ const projectDir = getProjectPath(path);
12
+ const sessionFile = join(projectDir, `${sessionId}.jsonl`);
13
+ const sessionExists = existsSync(sessionFile);
14
+ if (!sessionExists) {
15
+ logger.debug(`[claudeCheckSession] Path ${sessionFile} does not exist`);
16
+ return false;
17
+ }
18
+ const sessionData = readFileSync(sessionFile, "utf-8").split("\n");
19
+ const hasGoodMessage = !!sessionData.find((v, index) => {
20
+ if (!v.trim()) return false;
21
+ try {
22
+ const parsed = JSON.parse(v);
23
+ return typeof parsed.uuid === "string" && parsed.uuid.length > 0 || // Claude Code 2.1.x
24
+ typeof parsed.messageId === "string" && parsed.messageId.length > 0 || // Older Claude Code
25
+ typeof parsed.leafUuid === "string" && parsed.leafUuid.length > 0;
26
+ } catch (e) {
27
+ logger.debug(`[claudeCheckSession] Malformed JSON at line ${index + 1}:`, e);
28
+ return false;
29
+ }
30
+ });
31
+ logger.debug(`[claudeCheckSession] Session ${sessionId}: ${hasGoodMessage ? "valid" : "invalid"}`);
32
+ return hasGoodMessage;
33
+ }
34
+
35
+ function getClaudeSettingsPath() {
36
+ const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude");
37
+ return join(claudeConfigDir, "settings.json");
38
+ }
39
+ function readClaudeSettings() {
40
+ try {
41
+ const settingsPath = getClaudeSettingsPath();
42
+ if (!existsSync(settingsPath)) {
43
+ logger.debug(`[ClaudeSettings] No Claude settings file found at ${settingsPath}`);
44
+ return null;
45
+ }
46
+ const settingsContent = readFileSync(settingsPath, "utf-8");
47
+ const settings = JSON.parse(settingsContent);
48
+ logger.debug(`[ClaudeSettings] Successfully read Claude settings from ${settingsPath}`);
49
+ logger.debug(`[ClaudeSettings] includeCoAuthoredBy: ${settings.includeCoAuthoredBy}`);
50
+ return settings;
51
+ } catch (error) {
52
+ logger.debug(`[ClaudeSettings] Error reading Claude settings: ${error}`);
53
+ return null;
54
+ }
55
+ }
56
+ function shouldIncludeCoAuthoredBy() {
57
+ const settings = readClaudeSettings();
58
+ if (!settings) {
59
+ return true;
60
+ }
61
+ if (settings.attribution?.commit === "") {
62
+ return false;
63
+ }
64
+ if (settings.includeCoAuthoredBy === void 0) {
65
+ return true;
66
+ }
67
+ return settings.includeCoAuthoredBy;
68
+ }
69
+
70
+ const BASE_SYSTEM_PROMPT = (() => trimIdent(`
71
+ This chat is titled automatically from the user's first message. Call "mcp__happy__change_title" only when the topic has clearly moved on or the current title is too generic to find this chat later. Do not call it as a ritual at the start of a chat, and not for a quick question you can just answer.
72
+ `))() + "\n\n" + AGENT_GUIDANCE + "\n\n" + BUILTIN_TODO_DISCOVERY;
73
+ const CO_AUTHORED_CREDITS = (() => trimIdent(`
74
+ When you yourself create a git commit, instead of just giving co-credit to Claude, also give credit to Happy like so:
75
+
76
+ <main commit message>
77
+
78
+ Generated with [Claude Code](https://claude.ai/code)
79
+ via [Very Happy](https://github.com/Mereithhh/very-happy)
80
+
81
+ Co-Authored-By: Claude <noreply@anthropic.com>
82
+
83
+ Do not add these lines to commit message text you only draft for the user.
84
+ `))();
85
+ const systemPrompt = (() => {
86
+ const includeCoAuthored = shouldIncludeCoAuthoredBy();
87
+ if (includeCoAuthored) {
88
+ return BASE_SYSTEM_PROMPT + "\n\n" + CO_AUTHORED_CREDITS;
89
+ } else {
90
+ return BASE_SYSTEM_PROMPT;
91
+ }
92
+ })();
93
+
94
+ export { claudeCheckSession as c, systemPrompt as s };
@@ -2,51 +2,20 @@ import { homedir } from 'node:os';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { z } from 'zod';
4
4
  import { randomUUID } from 'node:crypto';
5
- import { I as teamRequest, J as createTeamsClient } from './agentGuidance-KgvYuF3R.mjs';
6
- import { h as readCredentialsForConfiguredRelay } from './limits-CjRj8IX5.mjs';
7
- import { a as installTeamSkill, i as installAutomationSkill } from './install-BPhJppvd.mjs';
5
+ import { t as teamRequest, c as createTeamsClient } from './client-Brn-UwVk.mjs';
6
+ import { readCredentialsForConfiguredRelay } from './persistence-oET5n61f.mjs';
7
+ import { a as installTeamSkill, i as installAutomationSkill } from './install-BO_W7VhL.mjs';
8
+ import './configuration-DoWFJUPm.mjs';
8
9
  import 'node:fs';
9
10
  import 'node:path';
10
- import 'axios';
11
- import 'socket.io-client';
12
- import '@paralleldrive/cuid2';
11
+ import './package-uOg9SCKi.mjs';
12
+ import './context-C9GHPLEm.mjs';
13
+ import './authRelay-DSAvg1uv.mjs';
13
14
  import 'tweetnacl';
15
+ import './logger-fXoNzNuB.mjs';
14
16
  import 'chalk';
15
17
  import 'node:util';
16
- import './index-BF6WfgV5.mjs';
17
- import './types-Dh-s4Lqs.mjs';
18
- import 'node:events';
19
- import 'child_process';
20
- import 'util';
21
- import 'fs/promises';
22
- import 'crypto';
23
- import 'path';
24
- import 'cross-spawn';
25
- import './terminalTitleSuggest-DKgX3osW.mjs';
26
- import 'url';
27
- import 'os';
28
- import 'node:child_process';
29
- import 'node-pty';
30
- import 'fs';
31
- import 'node:readline';
32
- import '@anthropic-ai/sandbox-runtime';
33
- import 'expo-server-sdk';
34
- import 'ink';
35
- import 'react';
36
- import '@anthropic-ai/claude-agent-sdk';
37
- import 'ps-list';
38
- import 'tmp';
39
- import 'open';
40
- import 'fastify';
41
- import 'fastify-type-provider-zod';
42
- import 'node:module';
43
- import '@modelcontextprotocol/sdk/server/mcp.js';
44
- import 'node:http';
45
- import '@modelcontextprotocol/sdk/server/streamableHttp.js';
46
- import 'http';
47
- import 'inquirer';
48
- import 'node:url';
49
- import 'node:readline/promises';
18
+ import './resources-BdFBQi8r.mjs';
50
19
 
51
20
  const legacyTask = z.object({
52
21
  id: z.string().regex(/^T-\d{3,}$/),