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,275 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var node_util = require('node:util');
5
+ var configuration = require('./configuration-BSYpcPwE.cjs');
6
+ var node_fs = require('node:fs');
7
+ var path = require('node:path');
8
+
9
+ function sensitiveKey(key) {
10
+ const normalized = key.toLowerCase().replace(/[_\-\s]/g, "");
11
+ return /(token|secret|password|authorization|cookie|credential|apikey|privatekey|encryptionkey|accesskey|claimsecret)/.test(normalized);
12
+ }
13
+ function redactLogString(value) {
14
+ return value.replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1[REDACTED]").replace(/([?&](?:token|secret|password|api[_-]?key)=)[^&#\s]+/gi, "$1[REDACTED]").replace(/((?:token|secret|password|api[_-]?key)\s*[=:]\s*)[^\s,;]+/gi, "$1[REDACTED]");
15
+ }
16
+ function redactLogValue(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
17
+ if (typeof value === "string") return redactLogString(value);
18
+ if (value === null || typeof value !== "object") return value;
19
+ if (depth >= 6) return "[TRUNCATED]";
20
+ if (seen.has(value)) return "[CIRCULAR]";
21
+ seen.add(value);
22
+ if (value instanceof Error) {
23
+ const error = value;
24
+ return {
25
+ name: error.name,
26
+ message: redactLogString(error.message),
27
+ ...typeof error.code === "string" || typeof error.code === "number" ? { code: error.code } : {},
28
+ ...typeof (error.status ?? error.response?.status) === "number" ? { status: error.status ?? error.response?.status } : {}
29
+ };
30
+ }
31
+ if (Array.isArray(value)) return value.map((item) => redactLogValue(item, depth + 1, seen));
32
+ const result = {};
33
+ for (const [key, child] of Object.entries(value)) {
34
+ if (sensitiveKey(key)) {
35
+ result[key] = "[REDACTED]";
36
+ } else if (key === "environmentVariables" && child && typeof child === "object") {
37
+ result[key] = { names: Object.keys(child).sort() };
38
+ } else {
39
+ result[key] = redactLogValue(child, depth + 1, seen);
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+
45
+ function createTimestampForFilename(date = /* @__PURE__ */ new Date()) {
46
+ return date.toLocaleString("sv-SE", {
47
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
48
+ year: "numeric",
49
+ month: "2-digit",
50
+ day: "2-digit",
51
+ hour: "2-digit",
52
+ minute: "2-digit",
53
+ second: "2-digit"
54
+ }).replace(/[: ]/g, "-").replace(/,/g, "") + "-pid-" + process.pid;
55
+ }
56
+ function createTimestampForLogEntry(date = /* @__PURE__ */ new Date()) {
57
+ return date.toLocaleTimeString("en-US", {
58
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
59
+ hour12: false,
60
+ hour: "2-digit",
61
+ minute: "2-digit",
62
+ second: "2-digit",
63
+ fractionalSecondDigits: 3
64
+ });
65
+ }
66
+ function getSessionLogPath() {
67
+ const timestamp = createTimestampForFilename();
68
+ const filename = configuration.configuration.isDaemonProcess ? `${timestamp}-daemon.log` : `${timestamp}.log`;
69
+ return path.join(configuration.configuration.logsDir, filename);
70
+ }
71
+ function safeRemoteLogUrl(raw) {
72
+ if (!raw) return void 0;
73
+ try {
74
+ const url = new URL(raw);
75
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
76
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) return void 0;
77
+ if (url.username || url.password || url.search || url.hash || url.pathname !== "/" && url.pathname !== "") return void 0;
78
+ return url.origin;
79
+ } catch {
80
+ return void 0;
81
+ }
82
+ }
83
+ class Logger {
84
+ constructor(logFilePath = getSessionLogPath()) {
85
+ this.logFilePath = logFilePath;
86
+ const remoteUrl = safeRemoteLogUrl(process.env.HAPPY_SERVER_URL);
87
+ const remoteToken = process.env.DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING_TOKEN;
88
+ if (process.env.DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING && remoteUrl && remoteToken && Buffer.byteLength(remoteToken) >= 32) {
89
+ this.dangerouslyUnencryptedServerLoggingUrl = remoteUrl;
90
+ this.dangerouslyUnencryptedServerLoggingToken = remoteToken;
91
+ console.log(chalk.yellow("[REMOTE LOGGING] Sending logs to server for AI debugging"));
92
+ }
93
+ }
94
+ dangerouslyUnencryptedServerLoggingUrl;
95
+ dangerouslyUnencryptedServerLoggingToken;
96
+ // Use local timezone for simplicity of locating the logs,
97
+ // in practice you will not need absolute timestamps
98
+ localTimezoneTimestamp() {
99
+ return createTimestampForLogEntry();
100
+ }
101
+ debug(message, ...args) {
102
+ this.logToFile(`[${this.localTimezoneTimestamp()}]`, message, ...args);
103
+ }
104
+ debugLargeJson(message, object, maxStringLength = 100, maxArrayLength = 10) {
105
+ if (!process.env.DEBUG) {
106
+ this.debug(`In production, skipping message inspection`);
107
+ return;
108
+ }
109
+ const truncateStrings = (obj) => {
110
+ if (typeof obj === "string") {
111
+ return obj.length > maxStringLength ? obj.substring(0, maxStringLength) + "... [truncated for logs]" : obj;
112
+ }
113
+ if (Array.isArray(obj)) {
114
+ const truncatedArray = obj.map((item) => truncateStrings(item)).slice(0, maxArrayLength);
115
+ if (obj.length > maxArrayLength) {
116
+ truncatedArray.push(`... [truncated array for logs up to ${maxArrayLength} items]`);
117
+ }
118
+ return truncatedArray;
119
+ }
120
+ if (obj && typeof obj === "object") {
121
+ const result = {};
122
+ for (const [key, value] of Object.entries(obj)) {
123
+ if (key === "usage") {
124
+ continue;
125
+ }
126
+ result[key] = truncateStrings(value);
127
+ }
128
+ return result;
129
+ }
130
+ return obj;
131
+ };
132
+ const truncatedObject = truncateStrings(redactLogValue(object));
133
+ const json = JSON.stringify(truncatedObject, null, 2);
134
+ this.logToFile(`[${this.localTimezoneTimestamp()}]`, redactLogString(message), "\n", json);
135
+ }
136
+ info(message, ...args) {
137
+ this.logToConsole("info", "", message, ...args);
138
+ this.debug(message, args);
139
+ }
140
+ infoDeveloper(message, ...args) {
141
+ this.debug(message, ...args);
142
+ if (process.env.DEBUG) {
143
+ this.logToConsole("info", "[DEV]", message, ...args);
144
+ }
145
+ }
146
+ warn(message, ...args) {
147
+ this.logToConsole("warn", "", message, ...args);
148
+ this.debug(`[WARN] ${message}`, ...args);
149
+ }
150
+ getLogPath() {
151
+ return this.logFilePath;
152
+ }
153
+ logToConsole(level, prefix, message, ...args) {
154
+ message = redactLogString(message);
155
+ args = args.map((arg) => redactLogValue(arg));
156
+ switch (level) {
157
+ case "debug": {
158
+ console.log(chalk.gray(prefix), message, ...args);
159
+ break;
160
+ }
161
+ case "error": {
162
+ console.error(chalk.red(prefix), message, ...args);
163
+ break;
164
+ }
165
+ case "info": {
166
+ console.log(chalk.blue(prefix), message, ...args);
167
+ break;
168
+ }
169
+ case "warn": {
170
+ console.log(chalk.yellow(prefix), message, ...args);
171
+ break;
172
+ }
173
+ default: {
174
+ this.debug("Unknown log level:", level);
175
+ console.log(chalk.blue(prefix), message, ...args);
176
+ break;
177
+ }
178
+ }
179
+ }
180
+ async sendToRemoteServer(level, message, ...args) {
181
+ if (!this.dangerouslyUnencryptedServerLoggingUrl) return;
182
+ try {
183
+ await fetch(this.dangerouslyUnencryptedServerLoggingUrl + "/logs-combined-from-cli-and-mobile-for-simple-ai-debugging", {
184
+ method: "POST",
185
+ headers: {
186
+ "Content-Type": "application/json",
187
+ "Authorization": `Bearer ${this.dangerouslyUnencryptedServerLoggingToken}`
188
+ },
189
+ body: JSON.stringify({
190
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
191
+ level,
192
+ message: `${redactLogString(message)} ${args.map((raw) => {
193
+ const safe = redactLogValue(raw);
194
+ return typeof safe === "object" ? JSON.stringify(safe, null, 2) : String(safe);
195
+ }).join(" ")}`,
196
+ source: "cli",
197
+ platform: process.platform
198
+ })
199
+ });
200
+ } catch (error) {
201
+ }
202
+ }
203
+ logToFile(prefix, message, ...args) {
204
+ const safeMessage = redactLogString(message);
205
+ const safeArgs = args.map((arg) => redactLogValue(arg));
206
+ const logLine = `${prefix} ${safeMessage} ${safeArgs.map(
207
+ (arg) => typeof arg === "string" ? arg : node_util.inspect(arg, { depth: 5, breakLength: 120 })
208
+ ).join(" ")}
209
+ `;
210
+ if (this.dangerouslyUnencryptedServerLoggingUrl) {
211
+ let level = "info";
212
+ if (prefix.includes(this.localTimezoneTimestamp())) {
213
+ level = "debug";
214
+ }
215
+ this.sendToRemoteServer(level, safeMessage, ...safeArgs).catch(() => {
216
+ });
217
+ }
218
+ try {
219
+ configuration.appendPrivateFileSync(this.logFilePath, logLine);
220
+ } catch (appendError) {
221
+ if (process.env.DEBUG) {
222
+ console.error("[DEV MODE ONLY THROWING] Failed to append to log file:", appendError);
223
+ throw appendError;
224
+ }
225
+ }
226
+ }
227
+ }
228
+ let logger = new Logger();
229
+ async function listDaemonLogFiles(limit = 50) {
230
+ try {
231
+ const logsDir = configuration.configuration.logsDir;
232
+ if (!node_fs.existsSync(logsDir)) {
233
+ return [];
234
+ }
235
+ const logs = node_fs.readdirSync(logsDir).filter((file) => file.endsWith("-daemon.log")).map((file) => {
236
+ const fullPath = path.join(logsDir, file);
237
+ const stats = node_fs.statSync(fullPath);
238
+ return { file, path: fullPath, modified: stats.mtime };
239
+ }).sort((a, b) => b.modified.getTime() - a.modified.getTime());
240
+ try {
241
+ const { readDaemonState } = await Promise.resolve().then(function () { return require('./persistence-yKTH3-5X.cjs'); });
242
+ const state = await readDaemonState();
243
+ if (!state) {
244
+ return logs;
245
+ }
246
+ if (state.daemonLogPath && node_fs.existsSync(state.daemonLogPath)) {
247
+ const stats = node_fs.statSync(state.daemonLogPath);
248
+ const persisted = {
249
+ file: path.basename(state.daemonLogPath),
250
+ path: state.daemonLogPath,
251
+ modified: stats.mtime
252
+ };
253
+ const idx = logs.findIndex((l) => l.path === persisted.path);
254
+ if (idx >= 0) {
255
+ const [found] = logs.splice(idx, 1);
256
+ logs.unshift(found);
257
+ } else {
258
+ logs.unshift(persisted);
259
+ }
260
+ }
261
+ } catch {
262
+ }
263
+ return logs.slice(0, Math.max(0, limit));
264
+ } catch {
265
+ return [];
266
+ }
267
+ }
268
+ async function getLatestDaemonLog() {
269
+ const [latest] = await listDaemonLogFiles(1);
270
+ return latest || null;
271
+ }
272
+
273
+ exports.getLatestDaemonLog = getLatestDaemonLog;
274
+ exports.logger = logger;
275
+ exports.redactLogValue = redactLogValue;
@@ -0,0 +1,182 @@
1
+ 'use strict';
2
+
3
+ var path = require('node:path');
4
+ var node_child_process = require('node:child_process');
5
+
6
+ const CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
7
+ const CODEX_HOME_ENV = "CODEX_HOME";
8
+ const AGENT_HOME_ENV_NAMES = [CLAUDE_CONFIG_DIR_ENV, CODEX_HOME_ENV];
9
+ function expandHomePath(value, homeDir) {
10
+ const trimmed = value.trim();
11
+ if (trimmed === "~") return homeDir;
12
+ if (trimmed.startsWith("~/")) return path.join(homeDir, trimmed.slice(2));
13
+ return path.isAbsolute(trimmed) ? trimmed : path.resolve(homeDir, trimmed);
14
+ }
15
+ function nonEmpty(value) {
16
+ const trimmed = value?.trim();
17
+ return trimmed ? trimmed : null;
18
+ }
19
+ function pick(envName, settingValue, input, defaultRelative) {
20
+ const fromSettings = nonEmpty(settingValue);
21
+ if (fromSettings) return { path: expandHomePath(fromSettings, input.homeDir), source: "settings" };
22
+ const fromShell = nonEmpty(input.loginShellEnv?.[envName]);
23
+ if (fromShell) return { path: expandHomePath(fromShell, input.homeDir), source: "login-shell" };
24
+ const fromDaemon = nonEmpty(input.daemonEnv[envName]);
25
+ if (fromDaemon) return { path: expandHomePath(fromDaemon, input.homeDir), source: "daemon-env" };
26
+ return { path: path.join(input.homeDir, defaultRelative), source: "default" };
27
+ }
28
+ function resolveAgentHomes(input) {
29
+ return {
30
+ claudeConfigDir: pick(CLAUDE_CONFIG_DIR_ENV, input.settings.claudeConfigDir, input, ".claude"),
31
+ codexHome: pick(CODEX_HOME_ENV, input.settings.codexHome, input, ".codex")
32
+ };
33
+ }
34
+ function agentHomeEnv(homes) {
35
+ const env = {};
36
+ if (homes.claudeConfigDir.source !== "default") env[CLAUDE_CONFIG_DIR_ENV] = homes.claudeConfigDir.path;
37
+ if (homes.codexHome.source !== "default") env[CODEX_HOME_ENV] = homes.codexHome.path;
38
+ return env;
39
+ }
40
+ function claudeProjectDirName(workingDirectory) {
41
+ return path.resolve(workingDirectory).replace(/[^a-zA-Z0-9-]/g, "-");
42
+ }
43
+ function claudeConversationPath(configDir, workingDirectory, claudeSessionId) {
44
+ return path.join(configDir, "projects", claudeProjectDirName(workingDirectory), `${claudeSessionId}.jsonl`);
45
+ }
46
+ function agentHomeCandidates(kind, input, homes = resolveAgentHomes(input)) {
47
+ const envName = kind === "claude" ? CLAUDE_CONFIG_DIR_ENV : CODEX_HOME_ENV;
48
+ const resolved = kind === "claude" ? homes.claudeConfigDir : homes.codexHome;
49
+ const raw = [
50
+ resolved.path,
51
+ nonEmpty(kind === "claude" ? input.settings.claudeConfigDir : input.settings.codexHome),
52
+ nonEmpty(input.loginShellEnv?.[envName]),
53
+ nonEmpty(input.daemonEnv[envName]),
54
+ path.join(input.homeDir, kind === "claude" ? ".claude" : ".codex")
55
+ ];
56
+ const out = [];
57
+ for (const value of raw) {
58
+ if (!value) continue;
59
+ const expanded = expandHomePath(value, input.homeDir);
60
+ if (!out.includes(expanded)) out.push(expanded);
61
+ }
62
+ return out;
63
+ }
64
+ function findClaudeConversation(claudeSessionId, workingDirectory, candidates, fileSize) {
65
+ let best = null;
66
+ let bestSize = -1;
67
+ for (let i = 0; i < candidates.length; i++) {
68
+ const file = claudeConversationPath(candidates[i], workingDirectory, claudeSessionId);
69
+ const size = fileSize(file);
70
+ if (size === null || size <= bestSize) continue;
71
+ best = { home: candidates[i], file, resolved: i === 0 };
72
+ bestSize = size;
73
+ }
74
+ return best;
75
+ }
76
+ function codexRolloutFileMatches(fileName, threadId) {
77
+ return fileName.startsWith("rollout-") && fileName.endsWith(`-${threadId}.jsonl`);
78
+ }
79
+ function findCodexThread(threadId, candidates, listDir) {
80
+ const digits = /^\d+$/;
81
+ for (let i = 0; i < candidates.length; i++) {
82
+ const sessions = path.join(candidates[i], "sessions");
83
+ for (const year of listDir(sessions).filter((name) => digits.test(name)).sort().reverse()) {
84
+ for (const month of listDir(path.join(sessions, year)).filter((name) => digits.test(name)).sort().reverse()) {
85
+ for (const day of listDir(path.join(sessions, year, month)).filter((name) => digits.test(name)).sort().reverse()) {
86
+ const dayDir = path.join(sessions, year, month, day);
87
+ const hit = listDir(dayDir).find((name) => codexRolloutFileMatches(name, threadId));
88
+ if (hit) return { home: candidates[i], file: path.join(dayDir, hit), resolved: i === 0 };
89
+ }
90
+ }
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ function describeAgentHome(choice) {
96
+ const source = {
97
+ settings: "settings.json",
98
+ "login-shell": "login shell",
99
+ "daemon-env": "daemon environment",
100
+ default: "default"
101
+ };
102
+ return `${choice.path} (${source[choice.source]})`;
103
+ }
104
+
105
+ const LOGIN_SHELL_ENV_MARKER = "__VH_ENV__";
106
+ const LOGIN_SHELL_PROBE_TIMEOUT_MS = 3e3;
107
+ function loginShellProbeScript(names) {
108
+ const pairs = names.map((name) => `${name} "$${name}"`).join(" ");
109
+ return `printf '${LOGIN_SHELL_ENV_MARKER}%s=%s\\n' ${pairs}`;
110
+ }
111
+ function parseLoginShellEnv(output, names) {
112
+ const wanted = new Set(names);
113
+ const env = {};
114
+ for (const rawLine of output.split(/\r?\n/)) {
115
+ const at = rawLine.indexOf(LOGIN_SHELL_ENV_MARKER);
116
+ if (at < 0) continue;
117
+ const line = rawLine.slice(at + LOGIN_SHELL_ENV_MARKER.length);
118
+ const eq = line.indexOf("=");
119
+ if (eq <= 0) continue;
120
+ const name = line.slice(0, eq);
121
+ if (!wanted.has(name)) continue;
122
+ const value = line.slice(eq + 1).trim();
123
+ env[name] = value ? value : void 0;
124
+ }
125
+ return env;
126
+ }
127
+ function probeLoginShellEnv(names, options = {}) {
128
+ const platform = options.platform ?? process.platform;
129
+ if (platform === "win32") return Promise.resolve(null);
130
+ const shell = (options.shell ?? process.env.SHELL ?? "").trim() || "/bin/sh";
131
+ const timeoutMs = options.timeoutMs ?? LOGIN_SHELL_PROBE_TIMEOUT_MS;
132
+ return new Promise((resolve) => {
133
+ let stdout = "";
134
+ let settled = false;
135
+ const finish = (value) => {
136
+ if (settled) return;
137
+ settled = true;
138
+ clearTimeout(timer);
139
+ resolve(value);
140
+ };
141
+ let child;
142
+ try {
143
+ child = node_child_process.spawn(shell, ["-l", "-i", "-c", loginShellProbeScript(names)], {
144
+ stdio: ["ignore", "pipe", "ignore"],
145
+ env: options.env ?? process.env,
146
+ windowsHide: true
147
+ });
148
+ } catch {
149
+ resolve(null);
150
+ return;
151
+ }
152
+ const timer = setTimeout(() => {
153
+ try {
154
+ child.kill("SIGKILL");
155
+ } catch {
156
+ }
157
+ finish(null);
158
+ }, timeoutMs);
159
+ child.stdout?.on("data", (chunk) => {
160
+ stdout += chunk.toString("utf8");
161
+ });
162
+ child.on("error", () => finish(null));
163
+ child.on("close", () => {
164
+ finish(stdout.includes(LOGIN_SHELL_ENV_MARKER) ? parseLoginShellEnv(stdout, names) : null);
165
+ });
166
+ });
167
+ }
168
+
169
+ exports.AGENT_HOME_ENV_NAMES = AGENT_HOME_ENV_NAMES;
170
+ exports.CLAUDE_CONFIG_DIR_ENV = CLAUDE_CONFIG_DIR_ENV;
171
+ exports.CODEX_HOME_ENV = CODEX_HOME_ENV;
172
+ exports.agentHomeCandidates = agentHomeCandidates;
173
+ exports.agentHomeEnv = agentHomeEnv;
174
+ exports.claudeConversationPath = claudeConversationPath;
175
+ exports.claudeProjectDirName = claudeProjectDirName;
176
+ exports.codexRolloutFileMatches = codexRolloutFileMatches;
177
+ exports.describeAgentHome = describeAgentHome;
178
+ exports.expandHomePath = expandHomePath;
179
+ exports.findClaudeConversation = findClaudeConversation;
180
+ exports.findCodexThread = findCodexThread;
181
+ exports.probeLoginShellEnv = probeLoginShellEnv;
182
+ exports.resolveAgentHomes = resolveAgentHomes;
@@ -0,0 +1,167 @@
1
+ import { join, resolve, isAbsolute } from 'node:path';
2
+ import { spawn } from 'node:child_process';
3
+
4
+ const CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
5
+ const CODEX_HOME_ENV = "CODEX_HOME";
6
+ const AGENT_HOME_ENV_NAMES = [CLAUDE_CONFIG_DIR_ENV, CODEX_HOME_ENV];
7
+ function expandHomePath(value, homeDir) {
8
+ const trimmed = value.trim();
9
+ if (trimmed === "~") return homeDir;
10
+ if (trimmed.startsWith("~/")) return join(homeDir, trimmed.slice(2));
11
+ return isAbsolute(trimmed) ? trimmed : resolve(homeDir, trimmed);
12
+ }
13
+ function nonEmpty(value) {
14
+ const trimmed = value?.trim();
15
+ return trimmed ? trimmed : null;
16
+ }
17
+ function pick(envName, settingValue, input, defaultRelative) {
18
+ const fromSettings = nonEmpty(settingValue);
19
+ if (fromSettings) return { path: expandHomePath(fromSettings, input.homeDir), source: "settings" };
20
+ const fromShell = nonEmpty(input.loginShellEnv?.[envName]);
21
+ if (fromShell) return { path: expandHomePath(fromShell, input.homeDir), source: "login-shell" };
22
+ const fromDaemon = nonEmpty(input.daemonEnv[envName]);
23
+ if (fromDaemon) return { path: expandHomePath(fromDaemon, input.homeDir), source: "daemon-env" };
24
+ return { path: join(input.homeDir, defaultRelative), source: "default" };
25
+ }
26
+ function resolveAgentHomes(input) {
27
+ return {
28
+ claudeConfigDir: pick(CLAUDE_CONFIG_DIR_ENV, input.settings.claudeConfigDir, input, ".claude"),
29
+ codexHome: pick(CODEX_HOME_ENV, input.settings.codexHome, input, ".codex")
30
+ };
31
+ }
32
+ function agentHomeEnv(homes) {
33
+ const env = {};
34
+ if (homes.claudeConfigDir.source !== "default") env[CLAUDE_CONFIG_DIR_ENV] = homes.claudeConfigDir.path;
35
+ if (homes.codexHome.source !== "default") env[CODEX_HOME_ENV] = homes.codexHome.path;
36
+ return env;
37
+ }
38
+ function claudeProjectDirName(workingDirectory) {
39
+ return resolve(workingDirectory).replace(/[^a-zA-Z0-9-]/g, "-");
40
+ }
41
+ function claudeConversationPath(configDir, workingDirectory, claudeSessionId) {
42
+ return join(configDir, "projects", claudeProjectDirName(workingDirectory), `${claudeSessionId}.jsonl`);
43
+ }
44
+ function agentHomeCandidates(kind, input, homes = resolveAgentHomes(input)) {
45
+ const envName = kind === "claude" ? CLAUDE_CONFIG_DIR_ENV : CODEX_HOME_ENV;
46
+ const resolved = kind === "claude" ? homes.claudeConfigDir : homes.codexHome;
47
+ const raw = [
48
+ resolved.path,
49
+ nonEmpty(kind === "claude" ? input.settings.claudeConfigDir : input.settings.codexHome),
50
+ nonEmpty(input.loginShellEnv?.[envName]),
51
+ nonEmpty(input.daemonEnv[envName]),
52
+ join(input.homeDir, kind === "claude" ? ".claude" : ".codex")
53
+ ];
54
+ const out = [];
55
+ for (const value of raw) {
56
+ if (!value) continue;
57
+ const expanded = expandHomePath(value, input.homeDir);
58
+ if (!out.includes(expanded)) out.push(expanded);
59
+ }
60
+ return out;
61
+ }
62
+ function findClaudeConversation(claudeSessionId, workingDirectory, candidates, fileSize) {
63
+ let best = null;
64
+ let bestSize = -1;
65
+ for (let i = 0; i < candidates.length; i++) {
66
+ const file = claudeConversationPath(candidates[i], workingDirectory, claudeSessionId);
67
+ const size = fileSize(file);
68
+ if (size === null || size <= bestSize) continue;
69
+ best = { home: candidates[i], file, resolved: i === 0 };
70
+ bestSize = size;
71
+ }
72
+ return best;
73
+ }
74
+ function codexRolloutFileMatches(fileName, threadId) {
75
+ return fileName.startsWith("rollout-") && fileName.endsWith(`-${threadId}.jsonl`);
76
+ }
77
+ function findCodexThread(threadId, candidates, listDir) {
78
+ const digits = /^\d+$/;
79
+ for (let i = 0; i < candidates.length; i++) {
80
+ const sessions = join(candidates[i], "sessions");
81
+ for (const year of listDir(sessions).filter((name) => digits.test(name)).sort().reverse()) {
82
+ for (const month of listDir(join(sessions, year)).filter((name) => digits.test(name)).sort().reverse()) {
83
+ for (const day of listDir(join(sessions, year, month)).filter((name) => digits.test(name)).sort().reverse()) {
84
+ const dayDir = join(sessions, year, month, day);
85
+ const hit = listDir(dayDir).find((name) => codexRolloutFileMatches(name, threadId));
86
+ if (hit) return { home: candidates[i], file: join(dayDir, hit), resolved: i === 0 };
87
+ }
88
+ }
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+ function describeAgentHome(choice) {
94
+ const source = {
95
+ settings: "settings.json",
96
+ "login-shell": "login shell",
97
+ "daemon-env": "daemon environment",
98
+ default: "default"
99
+ };
100
+ return `${choice.path} (${source[choice.source]})`;
101
+ }
102
+
103
+ const LOGIN_SHELL_ENV_MARKER = "__VH_ENV__";
104
+ const LOGIN_SHELL_PROBE_TIMEOUT_MS = 3e3;
105
+ function loginShellProbeScript(names) {
106
+ const pairs = names.map((name) => `${name} "$${name}"`).join(" ");
107
+ return `printf '${LOGIN_SHELL_ENV_MARKER}%s=%s\\n' ${pairs}`;
108
+ }
109
+ function parseLoginShellEnv(output, names) {
110
+ const wanted = new Set(names);
111
+ const env = {};
112
+ for (const rawLine of output.split(/\r?\n/)) {
113
+ const at = rawLine.indexOf(LOGIN_SHELL_ENV_MARKER);
114
+ if (at < 0) continue;
115
+ const line = rawLine.slice(at + LOGIN_SHELL_ENV_MARKER.length);
116
+ const eq = line.indexOf("=");
117
+ if (eq <= 0) continue;
118
+ const name = line.slice(0, eq);
119
+ if (!wanted.has(name)) continue;
120
+ const value = line.slice(eq + 1).trim();
121
+ env[name] = value ? value : void 0;
122
+ }
123
+ return env;
124
+ }
125
+ function probeLoginShellEnv(names, options = {}) {
126
+ const platform = options.platform ?? process.platform;
127
+ if (platform === "win32") return Promise.resolve(null);
128
+ const shell = (options.shell ?? process.env.SHELL ?? "").trim() || "/bin/sh";
129
+ const timeoutMs = options.timeoutMs ?? LOGIN_SHELL_PROBE_TIMEOUT_MS;
130
+ return new Promise((resolve) => {
131
+ let stdout = "";
132
+ let settled = false;
133
+ const finish = (value) => {
134
+ if (settled) return;
135
+ settled = true;
136
+ clearTimeout(timer);
137
+ resolve(value);
138
+ };
139
+ let child;
140
+ try {
141
+ child = spawn(shell, ["-l", "-i", "-c", loginShellProbeScript(names)], {
142
+ stdio: ["ignore", "pipe", "ignore"],
143
+ env: options.env ?? process.env,
144
+ windowsHide: true
145
+ });
146
+ } catch {
147
+ resolve(null);
148
+ return;
149
+ }
150
+ const timer = setTimeout(() => {
151
+ try {
152
+ child.kill("SIGKILL");
153
+ } catch {
154
+ }
155
+ finish(null);
156
+ }, timeoutMs);
157
+ child.stdout?.on("data", (chunk) => {
158
+ stdout += chunk.toString("utf8");
159
+ });
160
+ child.on("error", () => finish(null));
161
+ child.on("close", () => {
162
+ finish(stdout.includes(LOGIN_SHELL_ENV_MARKER) ? parseLoginShellEnv(stdout, names) : null);
163
+ });
164
+ });
165
+ }
166
+
167
+ export { AGENT_HOME_ENV_NAMES as A, CLAUDE_CONFIG_DIR_ENV as C, CODEX_HOME_ENV as a, agentHomeCandidates as b, findCodexThread as c, describeAgentHome as d, expandHomePath as e, findClaudeConversation as f, agentHomeEnv as g, claudeConversationPath as h, claudeProjectDirName as i, codexRolloutFileMatches as j, probeLoginShellEnv as p, resolveAgentHomes as r };
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var os = require('node:os');
4
+ var _package = require('./package-BwMrPwqH.cjs');
5
+ var configuration = require('./configuration-BSYpcPwE.cjs');
6
+ var projectPath = require('./projectPath-ChLhdOyt.cjs');
7
+ var detectCLI = require('./detectCLI-DR9ZaN6B.cjs');
8
+ var localHappyAgentAuth = require('./localHappyAgentAuth-D6rFhaoc.cjs');
9
+
10
+ function buildInitialMachineMetadata(cliAvailability) {
11
+ const hostSuffix = process.env.HAPPY_VARIANT === "dev" ? "-dev" : "";
12
+ return {
13
+ teamsVersion: 1,
14
+ teamLaunchVersion: 1,
15
+ host: os.hostname() + hostSuffix,
16
+ platform: os.platform(),
17
+ happyCliVersion: _package.packageJson.version,
18
+ homeDir: os.homedir(),
19
+ happyHomeDir: configuration.configuration.happyHomeDir,
20
+ happyLibDir: projectPath.projectPath(),
21
+ cliAvailability,
22
+ resumeSupport: { ...localHappyAgentAuth.detectResumeSupport(), rpcAvailable: true }
23
+ };
24
+ }
25
+ let memo = null;
26
+ function compute() {
27
+ if (!memo) {
28
+ const cliAvailability = detectCLI.detectCLIAvailability();
29
+ memo = { metadata: buildInitialMachineMetadata(cliAvailability), cliAvailability };
30
+ }
31
+ return memo;
32
+ }
33
+ function getInitialMachineMetadata() {
34
+ return compute().metadata;
35
+ }
36
+ function getStartupCliAvailability() {
37
+ return compute().cliAvailability;
38
+ }
39
+
40
+ exports.getInitialMachineMetadata = getInitialMachineMetadata;
41
+ exports.getStartupCliAvailability = getStartupCliAvailability;