very-happy-cli 0.2.158 → 0.2.160

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 (258) hide show
  1. package/dist/{AcpBackend-DIDRig5G.cjs → AcpBackend-Bm2rdke8.cjs} +78 -76
  2. package/dist/{AcpBackend-vDVLHuYJ.mjs → AcpBackend-mzv8Dhba.mjs} +4 -2
  3. package/dist/{AcpSessionManager-C44U99CC.cjs → AcpSessionManager-BAY1Pggx.cjs} +9 -9
  4. package/dist/{AcpSessionManager-CmRjfhn3.mjs → AcpSessionManager-CoMWFVw3.mjs} +1 -1
  5. package/dist/BasePermissionHandler-CFHAxumV.cjs +157 -0
  6. package/dist/BasePermissionHandler-m3WVholL.mjs +155 -0
  7. package/dist/BaseReasoningProcessor-BFa9_rZA.cjs +200 -0
  8. package/dist/BaseReasoningProcessor-CYrKBXGm.mjs +198 -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-Dw8Jx_CJ.cjs → agentHome-CboCeKWq.cjs} +14 -28
  16. package/dist/{agentHome-CyLmGH5L.mjs → agentHome-Dj1C43aJ.mjs} +8 -22
  17. package/dist/api-CLMUr-SX.mjs +3339 -0
  18. package/dist/api-CgundNNX.cjs +3346 -0
  19. package/dist/{types-DIBF4U0Y.mjs → apiMachine-B9dLW_p5.mjs} +9116 -16015
  20. package/dist/{types-DnrPeN80.cjs → apiMachine-Bn8482VM.cjs} +9104 -16057
  21. package/dist/assistantTools-BTqPnlFl.cjs +380 -0
  22. package/dist/assistantTools-D6tuc6o4.mjs +376 -0
  23. package/dist/attachmentContent-DpiTJZb4.cjs +88 -0
  24. package/dist/attachmentContent-_kxRznNf.mjs +82 -0
  25. package/dist/attachmentLimits-CzVrqgLR.cjs +354 -0
  26. package/dist/attachmentLimits-yba1uHFO.mjs +348 -0
  27. package/dist/auth-BDOVh5h5.cjs +220 -0
  28. package/dist/auth-Cwutmdsa.mjs +225 -0
  29. package/dist/auth-PYHZQNPp.mjs +218 -0
  30. package/dist/auth-ba4WMYrN.cjs +227 -0
  31. package/dist/authRelay-BdYkC1Po.cjs +156 -0
  32. package/dist/authRelay-DSAvg1uv.mjs +143 -0
  33. package/dist/{auto-DZbNcTXx.cjs → auto-BOX_fgmR.cjs} +70 -79
  34. package/dist/{auto-BlMZPwOk.mjs → auto-BXu14yP_.mjs} +27 -36
  35. package/dist/backgroundTaskActivity-8PdPxrvy.mjs +149 -0
  36. package/dist/backgroundTaskActivity-CBvUdj39.cjs +157 -0
  37. package/dist/bootstrap-B5G1TijC.cjs +116 -0
  38. package/dist/bootstrap-hxXPCFMx.mjs +112 -0
  39. package/dist/browser-Y6Bl8L_O.cjs +22 -0
  40. package/dist/browser-jh2P0UVZ.mjs +20 -0
  41. package/dist/claudeCliPath-BqkaH2oR.mjs +8 -0
  42. package/dist/claudeCliPath-U4HHmV4r.cjs +10 -0
  43. package/dist/claudeLocal-BaY4fZKi.mjs +339 -0
  44. package/dist/claudeLocal-CRGG4Pea.cjs +343 -0
  45. package/dist/claudeLocalLauncher-D4T7MTqd.mjs +152 -0
  46. package/dist/claudeLocalLauncher-DyEbVzUN.cjs +154 -0
  47. package/dist/cliUpdate-DsKXPFYp.cjs +120 -0
  48. package/dist/cliUpdate-Y34VGe9Y.mjs +112 -0
  49. package/dist/client-3Ac-O4pw.cjs +104 -0
  50. package/dist/client-BPNbmtvO.cjs +119 -0
  51. package/dist/client-CeGKqqcJ.mjs +100 -0
  52. package/dist/client-ClR0K8zX.mjs +112 -0
  53. package/dist/codex/happyMcpStdioBridge.cjs +33 -14
  54. package/dist/codex/happyMcpStdioBridge.mjs +26 -7
  55. package/dist/codexAppServerClient-I3teiV-N.mjs +1088 -0
  56. package/dist/codexAppServerClient-q2FjnRcK.cjs +1090 -0
  57. package/dist/codexCommand-4zcccIoq.cjs +2088 -0
  58. package/dist/codexCommand-Cc9gcbdX.mjs +2086 -0
  59. package/dist/codexThreadFork-BH9IZPqD.cjs +350 -0
  60. package/dist/codexThreadFork-slzAseLx.mjs +338 -0
  61. package/dist/{config-BtPArqRH.mjs → config-CTx_jb-C.mjs} +7 -40
  62. package/dist/{config-DG84bjwF.cjs → config-Ci9Kpgwa.cjs} +26 -59
  63. package/dist/configuration-BSYpcPwE.cjs +181 -0
  64. package/dist/configuration-RfeNjFmd.mjs +170 -0
  65. package/dist/connect-BpOdzNbE.mjs +682 -0
  66. package/dist/connect-C2CiOUFs.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-DsDr6E2t.cjs +69 -0
  72. package/dist/context-H0Bcb9S_.mjs +65 -0
  73. package/dist/controlClient-BGbDcgWS.mjs +260 -0
  74. package/dist/controlClient-Bcwv3D21.cjs +279 -0
  75. package/dist/createSessionMetadata-BJxEnM-o.cjs +58 -0
  76. package/dist/createSessionMetadata-CVVkGjxV.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-C5CYTVpm.cjs +507 -0
  82. package/dist/deterministicJson-CzkFJWw1.mjs +502 -0
  83. package/dist/doctor-BPkYWSuq.mjs +75 -0
  84. package/dist/doctor-D2YJ-Yn2.cjs +395 -0
  85. package/dist/doctor-DOvByjbk.mjs +391 -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-BCwNrMyv.cjs +64 -0
  92. package/dist/ensureDaemonRunning-Dqa2pOjY.mjs +61 -0
  93. package/dist/handleResumeCommand-BvXYf5El.mjs +240 -0
  94. package/dist/handleResumeCommand-C2cKchpX.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-DPCsWlWK.cjs → index-B6pAdvJx.cjs} +131 -91
  99. package/dist/index-Bu5Zi_a9.cjs +182 -0
  100. package/dist/index-D3kI0hDR.cjs +107 -0
  101. package/dist/index-DA7yINuk.cjs +994 -0
  102. package/dist/index-DDeHXrIX.cjs +71 -0
  103. package/dist/index-DKLU_fD0.mjs +158 -0
  104. package/dist/{index-ZChGsuB7.mjs → index-DMZqWwsP.mjs} +79 -39
  105. package/dist/index-DVkMGPyS.mjs +68 -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-DarS_Wco.mjs → install-BO_W7VhL.mjs} +37 -37
  110. package/dist/install-BgoC2e_2.cjs +88 -0
  111. package/dist/install-CFY3tYtJ.mjs +86 -0
  112. package/dist/{install-wKQGgXvN.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-DcQfee_O.cjs → installTerminalHooks-BQZbvxsZ.cjs} +5 -40
  116. package/dist/{installTerminalHooks-CpNbRFPz.mjs → installTerminalHooks-By7gBMEF.mjs} +3 -38
  117. package/dist/lib.cjs +28 -19
  118. package/dist/lib.d.cts +126 -2
  119. package/dist/lib.d.mts +126 -2
  120. package/dist/lib.mjs +23 -14
  121. package/dist/lidState-BeDfxxEX.cjs +305 -0
  122. package/dist/lidState-CeEt442o.mjs +297 -0
  123. package/dist/limits-C-a7gr04.cjs +43 -0
  124. package/dist/limits-DIo7rEBR.mjs +36 -0
  125. package/dist/localHappyAgentAuth-C-HQyiv6.mjs +82 -0
  126. package/dist/localHappyAgentAuth-D6rFhaoc.cjs +86 -0
  127. package/dist/logger-6HYUEXNk.mjs +271 -0
  128. package/dist/logger-CS0mw3fa.cjs +275 -0
  129. package/dist/loginShellEnv-BkuYtExZ.cjs +182 -0
  130. package/dist/loginShellEnv-Dw8M7tkI.mjs +167 -0
  131. package/dist/machineMetadata-DyDbODYd.cjs +41 -0
  132. package/dist/machineMetadata-oOzBfDfs.mjs +38 -0
  133. package/dist/main-BkxJP6JQ.cjs +941 -0
  134. package/dist/main-BwNIAI1A.mjs +939 -0
  135. package/dist/manager-BQ4flvQZ.mjs +101 -0
  136. package/dist/manager-Cly8xVIR.cjs +105 -0
  137. package/dist/{mcp-BN6bKIGb.mjs → mcp-B1A4I3TK.mjs} +27 -33
  138. package/dist/{mcp-DGdeUUDJ.cjs → mcp-Hszd7qpS.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-BhaKlnxz.mjs +171 -0
  146. package/dist/package-BwMrPwqH.cjs +173 -0
  147. package/dist/path-B7zW-WwE.cjs +18 -0
  148. package/dist/path-D2wdaNSk.mjs +15 -0
  149. package/dist/peerTools-BTqw97Gb.mjs +272 -0
  150. package/dist/peerTools-BvKtHXj8.cjs +283 -0
  151. package/dist/permissionMode-Cr5JCbB7.mjs +80 -0
  152. package/dist/permissionMode-CrV-XuMs.cjs +87 -0
  153. package/dist/persistence-HGW_ZVs9.mjs +372 -0
  154. package/dist/persistence-yKTH3-5X.cjs +414 -0
  155. package/dist/piExtension.mjs +2 -1
  156. package/dist/piRunnerArgs-BNloJCCg.cjs +66 -0
  157. package/dist/piRunnerArgs-BuX1UFWy.mjs +59 -0
  158. package/dist/{piRuntime-bkw2NAZU.mjs → piRuntime-CSGkwCKQ.mjs} +2 -2
  159. package/dist/{piRuntime-3qtbKujX.cjs → piRuntime-C_H7MJCM.cjs} +4 -4
  160. package/dist/{piTerminal-DilKwM7B.mjs → piTerminal-C8a1OrNQ.mjs} +32 -35
  161. package/dist/{piTerminal-BYxp3LMr.cjs → piTerminal-DNCZ6yTM.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-Ccvsz7Ou.mjs +536 -0
  167. package/dist/registerCommonHandlers-DskirN-_.cjs +538 -0
  168. package/dist/registerKillSessionHandler-DZeLXWcB.cjs +361 -0
  169. package/dist/registerKillSessionHandler-GYvHdipX.mjs +358 -0
  170. package/dist/remoteSessionClient-B0LraSB9.cjs +634 -0
  171. package/dist/remoteSessionClient-CYnXRynE.mjs +612 -0
  172. package/dist/resources-BdFBQi8r.mjs +117 -0
  173. package/dist/resources-JDPugcDq.cjs +120 -0
  174. package/dist/run-CJzxoHVh.cjs +5762 -0
  175. package/dist/run-D3ifupU3.mjs +5739 -0
  176. package/dist/runClaude-Ba01qT-u.mjs +848 -0
  177. package/dist/runClaude-Da3RirzE.cjs +850 -0
  178. package/dist/runClaudeDeps-DOt79DjU.mjs +3624 -0
  179. package/dist/runClaudeDeps-DOzEBMls.cjs +3649 -0
  180. package/dist/{runGemini-Cjii069p.mjs → runGemini-BGeTz57m.mjs} +58 -31
  181. package/dist/{runGemini-28O2sqyI.cjs → runGemini-DSr9LIxL.cjs} +202 -175
  182. package/dist/{runOpenClaw-CiMZad-H.cjs → runOpenClaw-B1mTxN35.cjs} +64 -65
  183. package/dist/{runOpenClaw-jaLr7KF1.mjs → runOpenClaw-CogSedIc.mjs} +31 -32
  184. package/dist/sandbox-CG7IyDTU.cjs +187 -0
  185. package/dist/sandbox-DTe6d54R.mjs +180 -0
  186. package/dist/selfCheck-C9mVrQwf.mjs +84 -0
  187. package/dist/selfCheck-Dc-mNSLb.cjs +87 -0
  188. package/dist/{send-D5ejHPXG.cjs → send-B7J_eaG3.cjs} +16 -9
  189. package/dist/{send-C9mOtChi.mjs → send-CBXJKc6O.mjs} +12 -5
  190. package/dist/server-CZTP_iOn.cjs +407 -0
  191. package/dist/server-DcVBv04l.mjs +404 -0
  192. package/dist/sessionLock-Bys1PNSo.cjs +205 -0
  193. package/dist/sessionLock-D-EG2CfG.mjs +197 -0
  194. package/dist/sessionModeFile-DMl3dw3r.mjs +32 -0
  195. package/dist/sessionModeFile-RSm0NQkH.cjs +36 -0
  196. package/dist/sessionOps-Dn8z85h_.cjs +783 -0
  197. package/dist/sessionOps-SuHW8Dfe.mjs +760 -0
  198. package/dist/sessionScanner-BOrGjMXL.cjs +209 -0
  199. package/dist/sessionScanner-CX3onqXh.mjs +206 -0
  200. package/dist/{sessions-W6771g3X.mjs → sessions-BEG_HTSi.mjs} +17 -8
  201. package/dist/{sessions-BNMPQoLE.cjs → sessions-D74aJbhL.cjs} +37 -28
  202. package/dist/setupOfflineReconnection-ByElY60m.cjs +74 -0
  203. package/dist/setupOfflineReconnection-DpvWTt69.mjs +72 -0
  204. package/dist/smallFastModel-BLNgMrwR.mjs +18 -0
  205. package/dist/smallFastModel-D_uxGMo3.cjs +21 -0
  206. package/dist/{spawn-D0QVhzRb.mjs → spawn-B7yro0b2.mjs} +26 -38
  207. package/dist/{spawn-Ddtom1cb.cjs → spawn-DgR0RKRs.cjs} +52 -64
  208. package/dist/spawnAgents-BGQiEF-w.cjs +52 -0
  209. package/dist/spawnAgents-DZzZ9jMI.mjs +45 -0
  210. package/dist/spawnHappyCLI-B2H5s4B_.mjs +64 -0
  211. package/dist/spawnHappyCLI-DBhwZT7O.cjs +66 -0
  212. package/dist/specialCommands-BSqhYg5X.mjs +52 -0
  213. package/dist/specialCommands-DSsTeRej.cjs +54 -0
  214. package/dist/startFileWatcher-B4VsLgjD.cjs +71 -0
  215. package/dist/startFileWatcher-DErVWZE4.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-C8gyQFMc.mjs +69 -0
  221. package/dist/sync-DccIKZ5_.cjs +71 -0
  222. package/dist/systemPrompt-BwTPWfMu.cjs +97 -0
  223. package/dist/systemPrompt-DX521JJz.mjs +94 -0
  224. package/dist/{teams-CqSwtw2O.mjs → teams-C32F1hqd.mjs} +9 -40
  225. package/dist/{teams-BZ1tayg_.cjs → teams-Dl8g8kTI.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-D0XyHOid.mjs +38 -0
  233. package/dist/time-DCuTyook.cjs +42 -0
  234. package/dist/titleGenerator-CQ8CoGhg.mjs +166 -0
  235. package/dist/titleGenerator-ChzMJsyg.cjs +172 -0
  236. package/dist/tmuxSocket-B8Yx20sT.mjs +19 -0
  237. package/dist/tmuxSocket-D-Xt6Vn-.cjs +24 -0
  238. package/dist/{todo-BYMg0fR0.cjs → todo-BvUOTa8G.cjs} +15 -12
  239. package/dist/{todo-BbusB1zM.mjs → todo-CZ6cFrrn.mjs} +11 -8
  240. package/dist/tools-BZtHF_qQ.mjs +177 -0
  241. package/dist/tools-Be3AoAwu.cjs +63 -0
  242. package/dist/tools-DQj0AeLk.cjs +180 -0
  243. package/dist/tools-DkluDcG4.mjs +60 -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-BkLzaJ6I.mjs +47 -0
  249. package/dist/uninstall-x-TUtf5H.cjs +49 -0
  250. package/package.json +7 -7
  251. package/dist/agentGuidance-CrR9l62U.mjs +0 -2145
  252. package/dist/agentGuidance-DwOWbX55.cjs +0 -2217
  253. package/dist/index-BG932eCh.cjs +0 -19655
  254. package/dist/index-CVCt3kSt.mjs +0 -19591
  255. package/dist/index-D5ScEErM.cjs +0 -58
  256. package/dist/index-DgO0FHOx.mjs +0 -52
  257. package/dist/limits-D2uN090G.mjs +0 -2528
  258. package/dist/limits-kqFqhfsh.cjs +0 -2652
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var trimIdent = require('./trimIdent-4gvk9Wk6.cjs');
4
+
5
+ const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
6
+ const GOOGLE_API_KEY_ENV = "GOOGLE_API_KEY";
7
+ const GEMINI_MODEL_ENV = "GEMINI_MODEL";
8
+ const DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
9
+ const CHANGE_TITLE_INSTRUCTION = trimIdent.trimIdent(
10
+ `Based on this message, call functions.happy__change_title to change chat session title that would represent the current task. If chat idea would change dramatically - call this function again to update the title.`
11
+ );
12
+
13
+ exports.CHANGE_TITLE_INSTRUCTION = CHANGE_TITLE_INSTRUCTION;
14
+ exports.DEFAULT_GEMINI_MODEL = DEFAULT_GEMINI_MODEL;
15
+ exports.GEMINI_API_KEY_ENV = GEMINI_API_KEY_ENV;
16
+ exports.GEMINI_MODEL_ENV = GEMINI_MODEL_ENV;
17
+ exports.GOOGLE_API_KEY_ENV = GOOGLE_API_KEY_ENV;
@@ -0,0 +1,51 @@
1
+ function serializedByteLength(value) {
2
+ try {
3
+ const serialized = JSON.stringify(value);
4
+ return serialized === void 0 ? void 0 : Buffer.byteLength(serialized, "utf8");
5
+ } catch {
6
+ return void 0;
7
+ }
8
+ }
9
+ function contentLogMetadata(value) {
10
+ if (typeof value === "string") {
11
+ return {
12
+ valueType: "string",
13
+ valueBytes: Buffer.byteLength(value, "utf8")
14
+ };
15
+ }
16
+ if (Array.isArray(value)) {
17
+ return {
18
+ valueType: "array",
19
+ itemCount: value.length,
20
+ payloadBytes: serializedByteLength(value)
21
+ };
22
+ }
23
+ if (value && typeof value === "object") {
24
+ return {
25
+ valueType: "object",
26
+ keyCount: Object.keys(value).length,
27
+ payloadBytes: serializedByteLength(value)
28
+ };
29
+ }
30
+ return { valueType: value === null ? "null" : typeof value };
31
+ }
32
+ function errorLogMetadata(error) {
33
+ if (error instanceof Error) {
34
+ const code = error.code;
35
+ return {
36
+ errorType: error.name || "Error",
37
+ ...typeof code === "string" ? { errorCode: code } : {}
38
+ };
39
+ }
40
+ if (error && typeof error === "object") {
41
+ const record = error;
42
+ const code = record.code;
43
+ return {
44
+ errorType: "object",
45
+ ...typeof code === "string" || typeof code === "number" ? { errorCode: code } : {}
46
+ };
47
+ }
48
+ return { errorType: error === null ? "null" : typeof error };
49
+ }
50
+
51
+ export { contentLogMetadata as c, errorLogMetadata as e };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ function serializedByteLength(value) {
4
+ try {
5
+ const serialized = JSON.stringify(value);
6
+ return serialized === void 0 ? void 0 : Buffer.byteLength(serialized, "utf8");
7
+ } catch {
8
+ return void 0;
9
+ }
10
+ }
11
+ function contentLogMetadata(value) {
12
+ if (typeof value === "string") {
13
+ return {
14
+ valueType: "string",
15
+ valueBytes: Buffer.byteLength(value, "utf8")
16
+ };
17
+ }
18
+ if (Array.isArray(value)) {
19
+ return {
20
+ valueType: "array",
21
+ itemCount: value.length,
22
+ payloadBytes: serializedByteLength(value)
23
+ };
24
+ }
25
+ if (value && typeof value === "object") {
26
+ return {
27
+ valueType: "object",
28
+ keyCount: Object.keys(value).length,
29
+ payloadBytes: serializedByteLength(value)
30
+ };
31
+ }
32
+ return { valueType: value === null ? "null" : typeof value };
33
+ }
34
+ function errorLogMetadata(error) {
35
+ if (error instanceof Error) {
36
+ const code = error.code;
37
+ return {
38
+ errorType: error.name || "Error",
39
+ ...typeof code === "string" ? { errorCode: code } : {}
40
+ };
41
+ }
42
+ if (error && typeof error === "object") {
43
+ const record = error;
44
+ const code = record.code;
45
+ return {
46
+ errorType: "object",
47
+ ...typeof code === "string" || typeof code === "number" ? { errorCode: code } : {}
48
+ };
49
+ }
50
+ return { errorType: error === null ? "null" : typeof error };
51
+ }
52
+
53
+ exports.contentLogMetadata = contentLogMetadata;
54
+ exports.errorLogMetadata = errorLogMetadata;
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ var promises = require('node:fs/promises');
4
+ var node_fs = require('node:fs');
5
+ var path = require('node:path');
6
+ var node_crypto = require('node:crypto');
7
+ var z = require('zod');
8
+ var configuration = require('./configuration-BSYpcPwE.cjs');
9
+
10
+ const TeamScopeSchema = z.z.object({
11
+ serverUrl: z.z.string(),
12
+ scopeToken: z.z.string().min(1),
13
+ teamId: z.z.string().min(1),
14
+ botId: z.z.string().min(1),
15
+ taskId: z.z.string().optional(),
16
+ attemptId: z.z.string().optional()
17
+ });
18
+ function teamScopePath(sessionId) {
19
+ const supplied = process.env.VH_TEAM_SCOPE_FILE;
20
+ if (supplied) {
21
+ if (!path.isAbsolute(supplied)) throw new Error("VH_TEAM_SCOPE_FILE must be absolute");
22
+ return supplied;
23
+ }
24
+ if (!sessionId || !/^[a-zA-Z0-9_-]+$/.test(sessionId)) throw new Error("Teams requires a managed session or VH_TEAM_SCOPE_FILE");
25
+ return path.join(configuration.configuration.happyHomeDir, "teams", "scopes", `${sessionId}.json`);
26
+ }
27
+ async function readTeamScope(path) {
28
+ let file;
29
+ try {
30
+ file = await promises.open(path, node_fs.constants.O_RDONLY | (node_fs.constants.O_NOFOLLOW ?? 0));
31
+ } catch (error) {
32
+ if (error.code === "ENOENT") return null;
33
+ throw new Error("Cannot open team scope");
34
+ }
35
+ try {
36
+ const stat = await file.stat();
37
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid()) throw new Error("Team scope owner mismatch");
38
+ if (!stat.isFile() || process.platform !== "win32" && (stat.mode & 63) !== 0) throw new Error("Team scope must be a private 0600 file");
39
+ const scope = TeamScopeSchema.parse(JSON.parse(await file.readFile("utf8")));
40
+ scope.serverUrl = configuration.normalizeHttpEndpoint(scope.serverUrl, "team scope");
41
+ if (scope.serverUrl !== configuration.configuration.serverUrl) throw new Error("Team scope belongs to another server");
42
+ return scope;
43
+ } catch {
44
+ throw new Error("Invalid or unsafe team scope file");
45
+ } finally {
46
+ await file.close();
47
+ }
48
+ }
49
+ async function writeTeamScope(path$1, scope) {
50
+ await promises.mkdir(path.dirname(path$1), { recursive: true, mode: 448 });
51
+ const temporary = `${path$1}.${node_crypto.randomUUID()}.new`;
52
+ const file = await promises.open(temporary, "wx", 384);
53
+ try {
54
+ await file.writeFile(JSON.stringify(TeamScopeSchema.parse(scope)));
55
+ await file.sync();
56
+ } finally {
57
+ await file.close();
58
+ }
59
+ try {
60
+ await promises.rename(temporary, path$1);
61
+ } finally {
62
+ await promises.unlink(temporary).catch(() => {
63
+ });
64
+ }
65
+ }
66
+
67
+ exports.readTeamScope = readTeamScope;
68
+ exports.teamScopePath = teamScopePath;
69
+ exports.writeTeamScope = writeTeamScope;
@@ -0,0 +1,65 @@
1
+ import { open, mkdir, rename, unlink } from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ import { isAbsolute, join, dirname } from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { z } from 'zod';
6
+ import { n as normalizeHttpEndpoint, c as configuration } from './configuration-RfeNjFmd.mjs';
7
+
8
+ const TeamScopeSchema = z.object({
9
+ serverUrl: z.string(),
10
+ scopeToken: z.string().min(1),
11
+ teamId: z.string().min(1),
12
+ botId: z.string().min(1),
13
+ taskId: z.string().optional(),
14
+ attemptId: z.string().optional()
15
+ });
16
+ function teamScopePath(sessionId) {
17
+ const supplied = process.env.VH_TEAM_SCOPE_FILE;
18
+ if (supplied) {
19
+ if (!isAbsolute(supplied)) throw new Error("VH_TEAM_SCOPE_FILE must be absolute");
20
+ return supplied;
21
+ }
22
+ if (!sessionId || !/^[a-zA-Z0-9_-]+$/.test(sessionId)) throw new Error("Teams requires a managed session or VH_TEAM_SCOPE_FILE");
23
+ return join(configuration.happyHomeDir, "teams", "scopes", `${sessionId}.json`);
24
+ }
25
+ async function readTeamScope(path) {
26
+ let file;
27
+ try {
28
+ file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
29
+ } catch (error) {
30
+ if (error.code === "ENOENT") return null;
31
+ throw new Error("Cannot open team scope");
32
+ }
33
+ try {
34
+ const stat = await file.stat();
35
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid()) throw new Error("Team scope owner mismatch");
36
+ if (!stat.isFile() || process.platform !== "win32" && (stat.mode & 63) !== 0) throw new Error("Team scope must be a private 0600 file");
37
+ const scope = TeamScopeSchema.parse(JSON.parse(await file.readFile("utf8")));
38
+ scope.serverUrl = normalizeHttpEndpoint(scope.serverUrl, "team scope");
39
+ if (scope.serverUrl !== configuration.serverUrl) throw new Error("Team scope belongs to another server");
40
+ return scope;
41
+ } catch {
42
+ throw new Error("Invalid or unsafe team scope file");
43
+ } finally {
44
+ await file.close();
45
+ }
46
+ }
47
+ async function writeTeamScope(path, scope) {
48
+ await mkdir(dirname(path), { recursive: true, mode: 448 });
49
+ const temporary = `${path}.${randomUUID()}.new`;
50
+ const file = await open(temporary, "wx", 384);
51
+ try {
52
+ await file.writeFile(JSON.stringify(TeamScopeSchema.parse(scope)));
53
+ await file.sync();
54
+ } finally {
55
+ await file.close();
56
+ }
57
+ try {
58
+ await rename(temporary, path);
59
+ } finally {
60
+ await unlink(temporary).catch(() => {
61
+ });
62
+ }
63
+ }
64
+
65
+ export { readTeamScope as r, teamScopePath as t, writeTeamScope as w };
@@ -0,0 +1,260 @@
1
+ import { l as logger } from './logger-6HYUEXNk.mjs';
2
+ import { readDaemonState, clearDaemonState } from './persistence-HGW_ZVs9.mjs';
3
+ import { c as configuration } from './configuration-RfeNjFmd.mjs';
4
+
5
+ function daemonControlHeaders(controlToken) {
6
+ return {
7
+ "Content-Type": "application/json",
8
+ ...controlToken ? { Authorization: `Bearer ${controlToken}` } : {}
9
+ };
10
+ }
11
+ async function daemonPost(path, body) {
12
+ const state = await readDaemonState();
13
+ if (!state?.httpPort) {
14
+ const errorMessage = "No daemon running, no state file found";
15
+ logger.debug(`[CONTROL CLIENT] ${errorMessage}`);
16
+ return {
17
+ error: errorMessage
18
+ };
19
+ }
20
+ try {
21
+ process.kill(state.pid, 0);
22
+ } catch (error) {
23
+ const errorMessage = "Daemon is not running, file is stale";
24
+ logger.debug(`[CONTROL CLIENT] ${errorMessage}`);
25
+ return {
26
+ error: errorMessage
27
+ };
28
+ }
29
+ try {
30
+ const timeout = process.env.HAPPY_DAEMON_HTTP_TIMEOUT ? parseInt(process.env.HAPPY_DAEMON_HTTP_TIMEOUT) : 1e4;
31
+ const response = await fetch(`http://127.0.0.1:${state.httpPort}${path}`, {
32
+ method: "POST",
33
+ // A state written by an old daemon has no token and must remain callable;
34
+ // a new daemon always writes one and rejects requests without it.
35
+ headers: daemonControlHeaders(state.controlToken),
36
+ body: JSON.stringify(body || {}),
37
+ // Mostly increased for stress test
38
+ signal: AbortSignal.timeout(timeout)
39
+ });
40
+ if (!response.ok) {
41
+ const failure = await response.json().catch(() => null);
42
+ const reason = typeof failure?.error === "string" && failure.error ? failure.error : `HTTP ${response.status}`;
43
+ const errorMessage = `Request failed: ${path}, ${reason}`;
44
+ logger.debug(`[CONTROL CLIENT] ${errorMessage}`);
45
+ return {
46
+ error: errorMessage
47
+ };
48
+ }
49
+ return await response.json();
50
+ } catch (error) {
51
+ const errorMessage = `Request failed: ${path}, ${error instanceof Error ? error.message : "Unknown error"}`;
52
+ logger.debug(`[CONTROL CLIENT] ${errorMessage}`);
53
+ return {
54
+ error: errorMessage
55
+ };
56
+ }
57
+ }
58
+ const SESSION_STARTED_RETRY_TIMEOUT_MS = 3e3;
59
+ const SESSION_STARTED_RETRY_INTERVAL_MS = 100;
60
+ async function notifyDaemonSessionStarted(sessionId, metadata, encryption) {
61
+ const payload = { sessionId, metadata, encryption };
62
+ const deadline = Date.now() + SESSION_STARTED_RETRY_TIMEOUT_MS;
63
+ let result;
64
+ while (true) {
65
+ result = await daemonPost("/session-started", payload);
66
+ if (!result?.error) {
67
+ return result;
68
+ }
69
+ if (Date.now() >= deadline) {
70
+ return result;
71
+ }
72
+ await new Promise((resolve) => setTimeout(resolve, SESSION_STARTED_RETRY_INTERVAL_MS));
73
+ }
74
+ }
75
+ async function listDaemonSessions() {
76
+ const result = await daemonPost("/list");
77
+ return result.children || [];
78
+ }
79
+ async function stopDaemonSession(sessionId) {
80
+ const result = await daemonPost("/stop-session", { sessionId });
81
+ return result.success || false;
82
+ }
83
+ async function spawnDaemonSession(directory, sessionId, opts) {
84
+ const result = await daemonPost("/spawn-session", {
85
+ directory,
86
+ sessionId,
87
+ spawnedBy: opts?.spawnedBy,
88
+ permissionMode: opts?.permissionMode,
89
+ agent: opts?.agent,
90
+ environmentVariables: opts?.environmentVariables,
91
+ resumeClaudeSessionId: opts?.resumeClaudeSessionId,
92
+ resumeCodexThreadId: opts?.resumeCodexThreadId,
93
+ parentSessionId: opts?.parentSessionId
94
+ });
95
+ return result;
96
+ }
97
+ const ROUTE_NOT_FOUND_RE = /, (Not Found|HTTP 404)$/;
98
+ async function resumeDaemonSession(sessionId, opts) {
99
+ const result = await daemonPost("/resume-session", {
100
+ sessionId,
101
+ ...opts?.model !== void 0 ? { model: opts.model } : {},
102
+ ...opts?.permissionMode !== void 0 ? { permissionMode: opts.permissionMode } : {}
103
+ });
104
+ if (result?.error) {
105
+ const raw = String(result.error);
106
+ const error = ROUTE_NOT_FOUND_RE.test(raw) ? "daemon too old to resume sessions (no /resume-session route); upgrade very-happy-cli and run `very-happy daemon start`" : raw.replace(/^Request failed: \/resume-session, /, "");
107
+ return { success: false, error };
108
+ }
109
+ if (result?.success === true && typeof result.sessionId === "string") {
110
+ return { success: true, sessionId: result.sessionId };
111
+ }
112
+ return { success: false, error: typeof result?.error === "string" ? result.error : "unexpected daemon response" };
113
+ }
114
+ async function notifyDaemonSessionEvent(sessionId, event, spawnedBy) {
115
+ return daemonPost("/session-event", { sessionId, event, spawnedBy });
116
+ }
117
+ async function notifyDaemonClaudeAuthFailed(sessionId) {
118
+ return daemonPost("/session-event", { sessionId, event: "auth_failed" });
119
+ }
120
+ async function notifyDaemonTurnEvent(sessionId, event) {
121
+ return daemonPost("/session-event", { sessionId, event });
122
+ }
123
+ async function notifyDaemonBackgroundTasks(sessionId, backgroundTasks) {
124
+ return daemonPost("/session-event", { sessionId, event: "background_tasks", backgroundTasks });
125
+ }
126
+ function reportSessionEditToDaemon(edit) {
127
+ void daemonPost("/session-edit", edit).then((result) => {
128
+ if (result?.error) logger.debug(`[CONTROL CLIENT] session-edit not recorded: ${result.error}`);
129
+ }).catch((error) => {
130
+ logger.debug("[CONTROL CLIENT] session-edit failed:", error);
131
+ });
132
+ }
133
+ async function listDaemonPeers() {
134
+ const result = await daemonPost("/peers");
135
+ if (result?.error) {
136
+ const reason = String(result.error);
137
+ if (/404|Not Found/i.test(reason)) {
138
+ throw new Error("The running daemon does not support session peers; restart it on a CLI that does (`very-happy daemon start` after updating)");
139
+ }
140
+ throw new Error(reason);
141
+ }
142
+ return Array.isArray(result?.sessions) ? result.sessions : [];
143
+ }
144
+ async function stopDaemonHttp() {
145
+ await daemonPost("/stop");
146
+ }
147
+ async function pushClipboardViaDaemon(text, terminalId) {
148
+ const result = await daemonPost("/clipboard", { text, ...terminalId ? { terminalId } : {} });
149
+ if (result?.error && result.delivered === void 0) {
150
+ return { delivered: false, error: result.error };
151
+ }
152
+ return result;
153
+ }
154
+ async function pushFilePreviewViaDaemon(terminalId, path, mode = "file") {
155
+ const result = await daemonPost("/file-preview", { terminalId, path, mode });
156
+ if (result?.error) return { delivered: false, error: result.error };
157
+ return { delivered: result?.delivered === true, ...result?.delivered === true ? {} : { error: "preview was not delivered" } };
158
+ }
159
+ async function setTerminalTitleViaDaemon(terminalId, title, ifAbsent = false) {
160
+ const result = await daemonPost("/terminal-title", { terminalId, title, ifAbsent });
161
+ if (result?.error) {
162
+ return { ok: false, error: result.error };
163
+ }
164
+ return { ok: result?.status === "ok", error: result?.status === "ok" ? void 0 : "unexpected daemon response" };
165
+ }
166
+ async function checkIfDaemonRunningAndCleanupStaleState() {
167
+ const state = await readDaemonState();
168
+ if (!state) {
169
+ return false;
170
+ }
171
+ try {
172
+ process.kill(state.pid, 0);
173
+ } catch {
174
+ logger.debug("[DAEMON RUN] Daemon PID not running, cleaning up state");
175
+ await cleanupDaemonState();
176
+ return false;
177
+ }
178
+ if (state.httpPort) {
179
+ try {
180
+ const response = await fetch(`http://127.0.0.1:${state.httpPort}/list`, {
181
+ method: "POST",
182
+ headers: daemonControlHeaders(state.controlToken),
183
+ body: "{}",
184
+ signal: AbortSignal.timeout(2e3)
185
+ });
186
+ if (response.ok) {
187
+ return true;
188
+ }
189
+ } catch {
190
+ logger.debug(`[DAEMON RUN] PID ${state.pid} is alive but HTTP health check failed on port ${state.httpPort}, cleaning up stale state`);
191
+ await cleanupDaemonState();
192
+ return false;
193
+ }
194
+ }
195
+ return true;
196
+ }
197
+ async function isDaemonRunningCurrentlyInstalledHappyVersion() {
198
+ logger.debug("[DAEMON CONTROL] Checking if daemon is running same version");
199
+ const runningDaemon = await checkIfDaemonRunningAndCleanupStaleState();
200
+ if (!runningDaemon) {
201
+ logger.debug("[DAEMON CONTROL] No daemon running, returning false");
202
+ return false;
203
+ }
204
+ const state = await readDaemonState();
205
+ if (!state) {
206
+ logger.debug("[DAEMON CONTROL] No daemon state found, returning false");
207
+ return false;
208
+ }
209
+ const currentCliVersion = configuration.currentCliVersion;
210
+ logger.debug(`[DAEMON CONTROL] Current CLI version: ${currentCliVersion}, Daemon started with version: ${state.startedWithCliVersion}`);
211
+ return currentCliVersion === state.startedWithCliVersion;
212
+ }
213
+ async function cleanupDaemonState() {
214
+ try {
215
+ await clearDaemonState();
216
+ logger.debug("[DAEMON RUN] Daemon state file removed");
217
+ } catch (error) {
218
+ logger.debug("[DAEMON RUN] Error cleaning up daemon metadata", error);
219
+ }
220
+ }
221
+ async function stopDaemon() {
222
+ try {
223
+ const state = await readDaemonState();
224
+ if (!state) {
225
+ logger.debug("No daemon state found");
226
+ return;
227
+ }
228
+ logger.debug(`Stopping daemon with PID ${state.pid}`);
229
+ try {
230
+ await stopDaemonHttp();
231
+ await waitForProcessDeath(state.pid, 2e3);
232
+ logger.debug("Daemon stopped gracefully via HTTP");
233
+ return;
234
+ } catch (error) {
235
+ logger.debug("HTTP stop failed, will force kill", error);
236
+ }
237
+ try {
238
+ process.kill(state.pid, "SIGKILL");
239
+ logger.debug("Force killed daemon");
240
+ } catch (error) {
241
+ logger.debug("Daemon already dead");
242
+ }
243
+ } catch (error) {
244
+ logger.debug("Error stopping daemon", error);
245
+ }
246
+ }
247
+ async function waitForProcessDeath(pid, timeout) {
248
+ const start = Date.now();
249
+ while (Date.now() - start < timeout) {
250
+ try {
251
+ process.kill(pid, 0);
252
+ await new Promise((resolve) => setTimeout(resolve, 100));
253
+ } catch {
254
+ return;
255
+ }
256
+ }
257
+ throw new Error("Process did not die within timeout");
258
+ }
259
+
260
+ export { stopDaemon as a, pushFilePreviewViaDaemon as b, checkIfDaemonRunningAndCleanupStaleState as c, setTerminalTitleViaDaemon as d, spawnDaemonSession as e, listDaemonPeers as f, reportSessionEditToDaemon as g, notifyDaemonTurnEvent as h, isDaemonRunningCurrentlyInstalledHappyVersion as i, notifyDaemonBackgroundTasks as j, notifyDaemonSessionEvent as k, listDaemonSessions as l, notifyDaemonClaudeAuthFailed as m, notifyDaemonSessionStarted as n, cleanupDaemonState as o, pushClipboardViaDaemon as p, resumeDaemonSession as r, stopDaemonSession as s };