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.
- package/dist/{AcpBackend-VsfkZiVF.mjs → AcpBackend-6U6pQgx1.mjs} +4 -2
- package/dist/{AcpBackend-DUYFlyfN.cjs → AcpBackend-Ba98QDif.cjs} +78 -76
- package/dist/{AcpSessionManager-Bdv8LWXh.cjs → AcpSessionManager-BAY1Pggx.cjs} +9 -9
- package/dist/{AcpSessionManager-rYtVb0kN.mjs → AcpSessionManager-CoMWFVw3.mjs} +1 -1
- package/dist/BasePermissionHandler-2R0uH2CI.cjs +157 -0
- package/dist/BasePermissionHandler-BvvhBTja.mjs +155 -0
- package/dist/BaseReasoningProcessor-DyhO1uoU.mjs +198 -0
- package/dist/BaseReasoningProcessor-fsVNmCEF.cjs +200 -0
- package/dist/RemoteModeDisplay-D-HewyXg.mjs +150 -0
- package/dist/RemoteModeDisplay-NC1gPHtj.cjs +153 -0
- package/dist/agentAttachments-Dbw8iMCZ.cjs +20 -0
- package/dist/agentAttachments-M_B5qEF2.mjs +18 -0
- package/dist/agentGuidance-B5NATuFa.cjs +28 -0
- package/dist/agentGuidance-CQuNlNx8.mjs +20 -0
- package/dist/{agentHome-CvsJyeQB.mjs → agentHome-Ck1i1TQB.mjs} +8 -22
- package/dist/{agentHome-CHh4lmjM.cjs → agentHome-DvNnGphb.cjs} +14 -28
- package/dist/api-B2vLMS-z.cjs +3346 -0
- package/dist/api-SffjRQ1b.mjs +3339 -0
- package/dist/{types-Dh-s4Lqs.mjs → apiMachine-BpW9t8MO.mjs} +9116 -16205
- package/dist/{types-BbvK1Tr_.cjs → apiMachine-gFA54X7y.cjs} +9104 -16247
- package/dist/assistantTools-BfA0R3_m.cjs +380 -0
- package/dist/assistantTools-CgiTbnWb.mjs +376 -0
- package/dist/attachmentContent-CSGxr71v.mjs +82 -0
- package/dist/attachmentContent-DMMZzevR.cjs +88 -0
- package/dist/attachmentLimits-CzVrqgLR.cjs +354 -0
- package/dist/attachmentLimits-yba1uHFO.mjs +348 -0
- package/dist/auth-Bt4ceBBy.cjs +227 -0
- package/dist/auth-CYHjQ8oQ.mjs +225 -0
- package/dist/auth-DdyVZSo6.mjs +218 -0
- package/dist/auth-x4CEoysH.cjs +220 -0
- package/dist/authRelay-BdYkC1Po.cjs +156 -0
- package/dist/authRelay-DSAvg1uv.mjs +143 -0
- package/dist/{auto-DKmEls8Z.cjs → auto-BDXDUnjB.cjs} +70 -79
- package/dist/{auto-nb8GhRRy.mjs → auto-CXLlRi3a.mjs} +27 -36
- package/dist/backgroundTaskActivity-8PdPxrvy.mjs +149 -0
- package/dist/backgroundTaskActivity-CBvUdj39.cjs +157 -0
- package/dist/bootstrap-BNQq05jR.mjs +112 -0
- package/dist/bootstrap-CkgIq8N3.cjs +116 -0
- package/dist/browser-9pyhQr1R.mjs +20 -0
- package/dist/browser-BDOlKWYe.cjs +22 -0
- package/dist/claudeCliPath-BqkaH2oR.mjs +8 -0
- package/dist/claudeCliPath-U4HHmV4r.cjs +10 -0
- package/dist/claudeLocal-BDuGFnjJ.cjs +343 -0
- package/dist/claudeLocal-CQa8qnwq.mjs +339 -0
- package/dist/claudeLocalLauncher-Bd5I2-j6.cjs +154 -0
- package/dist/claudeLocalLauncher-CDqQI9ak.mjs +152 -0
- package/dist/cliUpdate-DsKXPFYp.cjs +120 -0
- package/dist/cliUpdate-Y34VGe9Y.mjs +112 -0
- package/dist/client-Brn-UwVk.mjs +100 -0
- package/dist/client-CXb1VJui.mjs +112 -0
- package/dist/client-C_axwRry.cjs +104 -0
- package/dist/client-DOBWJL3u.cjs +119 -0
- package/dist/codex/happyMcpStdioBridge.cjs +33 -14
- package/dist/codex/happyMcpStdioBridge.mjs +26 -7
- package/dist/codexAppServerClient-ZzhUTWPo.cjs +1090 -0
- package/dist/codexAppServerClient-oeQKD6Qf.mjs +1088 -0
- package/dist/codexCommand-C7H0NpBe.cjs +2088 -0
- package/dist/codexCommand-CJ82bl3l.mjs +2086 -0
- package/dist/codexThreadFork-BCaEMBiM.mjs +338 -0
- package/dist/codexThreadFork-BZqF-9bX.cjs +350 -0
- package/dist/{config-ClLtM6F3.mjs → config-BglnktIo.mjs} +7 -40
- package/dist/{config-DLx-vW3I.cjs → config-CYpL1Ahd.cjs} +26 -59
- package/dist/configuration-DoWFJUPm.mjs +170 -0
- package/dist/configuration-v9f8LM9T.cjs +181 -0
- package/dist/connect-hgcNjyAB.mjs +682 -0
- package/dist/connect-yEvjdRvx.cjs +684 -0
- package/dist/constants-BC4St0xd.mjs +11 -0
- package/dist/constants-VJ0N6WuG.cjs +17 -0
- package/dist/contentLogMetadata-BlWI0egu.mjs +51 -0
- package/dist/contentLogMetadata-ZSFk_NjQ.cjs +54 -0
- package/dist/context-B45vMtSZ.cjs +69 -0
- package/dist/context-C9GHPLEm.mjs +65 -0
- package/dist/controlClient-DjoKTtgK.mjs +260 -0
- package/dist/controlClient-fEHE85bH.cjs +279 -0
- package/dist/createSessionMetadata-BRLB9CNO.cjs +58 -0
- package/dist/createSessionMetadata-mIeehclp.mjs +54 -0
- package/dist/defaultPermissionMode-BnxJPVHT.mjs +4 -0
- package/dist/defaultPermissionMode-CxmTXUQR.cjs +7 -0
- package/dist/detectCLI-CSGMlV51.mjs +58 -0
- package/dist/detectCLI-DR9ZaN6B.cjs +61 -0
- package/dist/deterministicJson-DKDP_mM-.cjs +507 -0
- package/dist/deterministicJson-p835AdAU.mjs +502 -0
- package/dist/doctor-BPkYWSuq.mjs +75 -0
- package/dist/doctor-BeUuQXFs.mjs +391 -0
- package/dist/doctor-hVNnSZJn.cjs +395 -0
- package/dist/doctor-u46qYYKX.cjs +79 -0
- package/dist/doctorReadiness-BCZGcN0a.cjs +151 -0
- package/dist/doctorReadiness-C208SMN9.mjs +142 -0
- package/dist/editPaths-BVfS_FFL.mjs +68 -0
- package/dist/editPaths-Bqp4OFPw.cjs +73 -0
- package/dist/ensureDaemonRunning-CO7d1gOC.mjs +61 -0
- package/dist/ensureDaemonRunning-Dg9aZfjs.cjs +64 -0
- package/dist/handleResumeCommand-BiTPK0qd.mjs +240 -0
- package/dist/handleResumeCommand-DnVmy7a3.cjs +245 -0
- package/dist/ids-B6ZC0HGt.cjs +13 -0
- package/dist/ids-DU6sLx4C.mjs +10 -0
- package/dist/index-B6UGRQ7h.mjs +102 -0
- package/dist/{index-2mCaeKyf.mjs → index-CAFwetLk.mjs} +68 -38
- package/dist/index-Cqx-Raq6.mjs +68 -0
- package/dist/index-D3kI0hDR.cjs +107 -0
- package/dist/index-DA7yINuk.cjs +994 -0
- package/dist/{index-BEOMECtE.cjs → index-LIn6nCcq.cjs} +121 -91
- package/dist/index-Pf2cV9cn.cjs +182 -0
- package/dist/index-SPGPenK5.mjs +158 -0
- package/dist/index-gNTWtSKN.cjs +71 -0
- package/dist/index-qdS1friN.mjs +949 -0
- package/dist/index.cjs +5 -46
- package/dist/index.mjs +5 -46
- package/dist/{install-BPhJppvd.mjs → install-BO_W7VhL.mjs} +37 -37
- package/dist/install-Bu85vlHD.cjs +88 -0
- package/dist/install-ClUUl3yp.mjs +86 -0
- package/dist/{install-BOHrUaFM.cjs → install-Cs5qAPrB.cjs} +38 -38
- package/dist/{installPiTools-DuZ6jZvX.cjs → installPiTools-BKnXjrVu.cjs} +2 -3
- package/dist/{installPiTools-Cj7yU9Fc.mjs → installPiTools-B_CdM5_2.mjs} +1 -2
- package/dist/{installTerminalHooks-Cou3WUf3.cjs → installTerminalHooks-BQZbvxsZ.cjs} +5 -40
- package/dist/{installTerminalHooks-WeznjkuC.mjs → installTerminalHooks-By7gBMEF.mjs} +3 -38
- package/dist/lib.cjs +28 -19
- package/dist/lib.d.cts +12 -2
- package/dist/lib.d.mts +12 -2
- package/dist/lib.mjs +23 -14
- package/dist/lidState-C2dI0FAN.mjs +297 -0
- package/dist/lidState-KHHu1015.cjs +305 -0
- package/dist/limits-C-a7gr04.cjs +43 -0
- package/dist/limits-DIo7rEBR.mjs +36 -0
- package/dist/localHappyAgentAuth-BXiHPXdC.cjs +86 -0
- package/dist/localHappyAgentAuth-DCsetiyG.mjs +82 -0
- package/dist/logger-Bc8-u1w0.cjs +275 -0
- package/dist/logger-fXoNzNuB.mjs +271 -0
- package/dist/loginShellEnv-BkuYtExZ.cjs +182 -0
- package/dist/loginShellEnv-Dw8M7tkI.mjs +167 -0
- package/dist/machineMetadata-BHjehxJY.mjs +38 -0
- package/dist/machineMetadata-BibDMFVx.cjs +41 -0
- package/dist/main-BktM4A1K.mjs +939 -0
- package/dist/main-CLaX-t-b.cjs +941 -0
- package/dist/manager-BQ4flvQZ.mjs +101 -0
- package/dist/manager-Cly8xVIR.cjs +105 -0
- package/dist/{mcp-Dy3f_K0h.mjs → mcp-CeUd9KDr.mjs} +27 -33
- package/dist/{mcp-CPYbtsYG.cjs → mcp-GBfE70nk.cjs} +42 -48
- package/dist/messageBuffer-BWlGgR3A.mjs +71 -0
- package/dist/messageBuffer-fJMH6uY8.cjs +73 -0
- package/dist/mirrorProtocol-BNLtoWjO.mjs +170 -0
- package/dist/mirrorProtocol-BUtmg1ws.cjs +186 -0
- package/dist/oneShotPrompts-CL0dip9C.cjs +16 -0
- package/dist/oneShotPrompts-DT4p6RNd.mjs +12 -0
- package/dist/package-Cl5BEP5x.cjs +173 -0
- package/dist/package-uOg9SCKi.mjs +171 -0
- package/dist/path-B7zW-WwE.cjs +18 -0
- package/dist/path-D2wdaNSk.mjs +15 -0
- package/dist/peerTools-CIeiy9wn.cjs +283 -0
- package/dist/peerTools-Dz3_7Bkk.mjs +272 -0
- package/dist/permissionMode-CH4FoZfU.mjs +80 -0
- package/dist/permissionMode-CrV-XuMs.cjs +87 -0
- package/dist/persistence-CBNMzSa8.cjs +414 -0
- package/dist/persistence-oET5n61f.mjs +372 -0
- package/dist/piExtension.mjs +2 -1
- package/dist/piRunnerArgs-Bf7RUF__.cjs +66 -0
- package/dist/piRunnerArgs-Dk1ncwHF.mjs +59 -0
- package/dist/{piRuntime-NtF0YqjH.cjs → piRuntime-B_6TE9Eb.cjs} +4 -4
- package/dist/{piRuntime-kLZNpAAl.mjs → piRuntime-BwRdhK_N.mjs} +2 -2
- package/dist/{piTerminal-B0fEOV_2.mjs → piTerminal-Bap3R8Re.mjs} +32 -35
- package/dist/{piTerminal-9J0GAKzb.cjs → piTerminal-CagmEoez.cjs} +32 -35
- package/dist/previewPath-B0rBdhy1.cjs +83 -0
- package/dist/previewPath-CXN4Vag0.mjs +81 -0
- package/dist/projectPath-BTBIMB57.mjs +10 -0
- package/dist/projectPath-ChLhdOyt.cjs +13 -0
- package/dist/registerCommonHandlers-BjSV2Skz.cjs +538 -0
- package/dist/registerCommonHandlers-CrgvJsOy.mjs +536 -0
- package/dist/registerKillSessionHandler-6TC2S3lf.cjs +366 -0
- package/dist/registerKillSessionHandler-Cbc8Rgtd.mjs +363 -0
- package/dist/remoteSessionClient-BNx78NLb.cjs +634 -0
- package/dist/remoteSessionClient-CO7qOjR0.mjs +612 -0
- package/dist/resources-BdFBQi8r.mjs +117 -0
- package/dist/resources-JDPugcDq.cjs +120 -0
- package/dist/run-2l5vSt2h.mjs +5743 -0
- package/dist/run-D5xAEWSB.cjs +5766 -0
- package/dist/runClaude-BX6ixjtW.cjs +894 -0
- package/dist/runClaude-BgN6xo05.mjs +892 -0
- package/dist/runClaudeDeps-Bp20MScE.cjs +4168 -0
- package/dist/runClaudeDeps-COBBhD9o.mjs +4129 -0
- package/dist/{runGemini-F-mqx3_K.cjs → runGemini-CSMPkt0p.cjs} +202 -175
- package/dist/{runGemini-DV6Ouadt.mjs → runGemini-Cc2jq-uh.mjs} +58 -31
- package/dist/{runOpenClaw-D7MlPS5n.mjs → runOpenClaw-CIlCwdW2.mjs} +31 -32
- package/dist/{runOpenClaw-Qqo9j63M.cjs → runOpenClaw-YBwua4Rf.cjs} +64 -65
- package/dist/sandbox-C4gXLP1p.cjs +187 -0
- package/dist/sandbox-CNkwOtHI.mjs +180 -0
- package/dist/selfCheck-CU8xSDsl.cjs +87 -0
- package/dist/selfCheck-hJ6PCh7v.mjs +84 -0
- package/dist/{send-CLhYXNgy.mjs → send-CGHcKZ-w.mjs} +12 -5
- package/dist/{send-4qJTCAYW.cjs → send-DY9Nr-x4.cjs} +16 -9
- package/dist/server-II51Mimf.cjs +407 -0
- package/dist/server-m2b5pamZ.mjs +404 -0
- package/dist/sessionLock-7ePAYDOg.cjs +205 -0
- package/dist/sessionLock-Cw6FmbMv.mjs +197 -0
- package/dist/sessionModeFile-BVCV5f7E.cjs +36 -0
- package/dist/sessionModeFile-CDmDyRkD.mjs +32 -0
- package/dist/sessionOps-C_f1wKOr.mjs +760 -0
- package/dist/sessionOps-DJdExmBy.cjs +783 -0
- package/dist/sessionScanner-CaAHLyNV.mjs +206 -0
- package/dist/sessionScanner-D1goKdd3.cjs +209 -0
- package/dist/{sessions-Bh1pyddi.cjs → sessions-DGs6ALNo.cjs} +37 -28
- package/dist/{sessions-CzIH2rGp.mjs → sessions-DnvmWUel.mjs} +17 -8
- package/dist/setupOfflineReconnection-CVViqZft.mjs +72 -0
- package/dist/setupOfflineReconnection-R7XuR_sj.cjs +74 -0
- package/dist/smallFastModel-BLNgMrwR.mjs +18 -0
- package/dist/smallFastModel-D_uxGMo3.cjs +21 -0
- package/dist/{spawn-CmFOSVdW.cjs → spawn-CXTH7qg1.cjs} +61 -65
- package/dist/{spawn-CPIWlPOM.mjs → spawn-DNYSvFtC.mjs} +35 -40
- package/dist/spawnAgents-BGQiEF-w.cjs +52 -0
- package/dist/spawnAgents-DZzZ9jMI.mjs +45 -0
- package/dist/spawnHappyCLI-BhYj84rv.cjs +66 -0
- package/dist/spawnHappyCLI-cqWQbwsb.mjs +64 -0
- package/dist/specialCommands-BSqhYg5X.mjs +52 -0
- package/dist/specialCommands-DSsTeRej.cjs +54 -0
- package/dist/startFileWatcher-CKKx-8ZO.cjs +71 -0
- package/dist/startFileWatcher-CdegMbJj.mjs +69 -0
- package/dist/startupPlan-BLMbfQIH.cjs +12 -0
- package/dist/startupPlan-DFMyNgAs.mjs +10 -0
- package/dist/streamRelay-BiKw59Cc.cjs +233 -0
- package/dist/streamRelay-FPVbHpbM.mjs +231 -0
- package/dist/sync-CVk4QERO.cjs +71 -0
- package/dist/sync-CxD-w_40.mjs +69 -0
- package/dist/systemPrompt-BygJcmbi.cjs +97 -0
- package/dist/systemPrompt-DmtypUc7.mjs +94 -0
- package/dist/{teams-CEahj4cm.mjs → teams-BOC6nIPL.mjs} +9 -40
- package/dist/{teams-CB1R9-Z9.cjs → teams-BsvpOBfn.cjs} +14 -45
- package/dist/template-BaHAmH2K.cjs +129 -0
- package/dist/template-CiOPa2rd.mjs +121 -0
- package/dist/{terminalTitleSuggest-DKgX3osW.mjs → terminalTitleSuggest-CeKsX_V6.mjs} +1 -9
- package/dist/{terminalTitleSuggest-Dji8I0Jy.cjs → terminalTitleSuggest-DhvRFX3H.cjs} +0 -10
- package/dist/terminals-B_bfC9c2.cjs +250 -0
- package/dist/terminals-Dlg0x3nY.mjs +235 -0
- package/dist/time-BZNdNiIV.mjs +38 -0
- package/dist/time-CNRE4ChD.cjs +42 -0
- package/dist/titleGenerator-CFRhU-xq.cjs +172 -0
- package/dist/titleGenerator-ox6ptCsp.mjs +166 -0
- package/dist/tmuxSocket-B8Yx20sT.mjs +19 -0
- package/dist/tmuxSocket-D-Xt6Vn-.cjs +24 -0
- package/dist/{todo-DqyRI4wP.cjs → todo-B-KB7oAB.cjs} +15 -12
- package/dist/{todo-Cknp5D4U.mjs → todo-C5KBVbUw.mjs} +11 -8
- package/dist/tools-BZabNIid.mjs +177 -0
- package/dist/tools-BmQQUATY.mjs +60 -0
- package/dist/tools-CsSovyNp.cjs +180 -0
- package/dist/tools-lMDra4Pv.cjs +63 -0
- package/dist/trimIdent-4gvk9Wk6.cjs +22 -0
- package/dist/trimIdent-BAjmv_TG.mjs +20 -0
- package/dist/types-CRS-srZK.cjs +66 -0
- package/dist/types-CkqAACXx.mjs +64 -0
- package/dist/uninstall-B1WLtC1d.mjs +47 -0
- package/dist/uninstall-fvA5aWpU.cjs +49 -0
- package/package.json +7 -7
- package/scripts/session_hook_forwarder.cjs +9 -2
- package/dist/agentGuidance-BRDN1NoZ.cjs +0 -2217
- package/dist/agentGuidance-KgvYuF3R.mjs +0 -2145
- package/dist/index-BF6WfgV5.mjs +0 -19624
- package/dist/index-C-JazrMB.mjs +0 -52
- package/dist/index-blDSadUR.cjs +0 -58
- package/dist/index-rH3DrQ5B.cjs +0 -19688
- package/dist/limits-BH5CV5vR.cjs +0 -2683
- package/dist/limits-CjRj8IX5.mjs +0 -2558
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { readFile, open, unlink, stat, rename } from 'node:fs/promises';
|
|
2
|
+
import { existsSync, constants, readFileSync, unlinkSync, renameSync } from 'node:fs';
|
|
3
|
+
import { c as configuration, P as PRIVATE_FILE_MODE, w as writePrivateFileSync, h as hardenPrivateFileSync, e as ensurePrivateDirectory, a as writePrivateFile, b as hardenPrivateFile } from './configuration-DoWFJUPm.mjs';
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
import { c as credentialRelayProblem, e as encodeBase64 } from './authRelay-DSAvg1uv.mjs';
|
|
6
|
+
import { l as logger } from './logger-fXoNzNuB.mjs';
|
|
7
|
+
import 'node:os';
|
|
8
|
+
import 'node:path';
|
|
9
|
+
import './package-uOg9SCKi.mjs';
|
|
10
|
+
import 'node:crypto';
|
|
11
|
+
import 'tweetnacl';
|
|
12
|
+
import 'chalk';
|
|
13
|
+
import 'node:util';
|
|
14
|
+
|
|
15
|
+
const SandboxConfigSchema = z.object({
|
|
16
|
+
enabled: z.boolean().default(false),
|
|
17
|
+
workspaceRoot: z.string().optional(),
|
|
18
|
+
sessionIsolation: z.enum(["strict", "workspace", "custom"]).default("workspace"),
|
|
19
|
+
customWritePaths: z.array(z.string()).default([]),
|
|
20
|
+
denyReadPaths: z.array(z.string()).default(["~/.ssh", "~/.aws", "~/.gnupg"]),
|
|
21
|
+
extraWritePaths: z.array(z.string()).default(["/tmp"]),
|
|
22
|
+
denyWritePaths: z.array(z.string()).default([".env"]),
|
|
23
|
+
networkMode: z.enum(["blocked", "allowed", "custom"]).default("allowed"),
|
|
24
|
+
allowedDomains: z.array(z.string()).default([]),
|
|
25
|
+
deniedDomains: z.array(z.string()).default([]),
|
|
26
|
+
allowLocalBinding: z.boolean().default(true)
|
|
27
|
+
});
|
|
28
|
+
const SUPPORTED_SCHEMA_VERSION = 2;
|
|
29
|
+
const defaultSettings = {
|
|
30
|
+
schemaVersion: SUPPORTED_SCHEMA_VERSION,
|
|
31
|
+
onboardingCompleted: false,
|
|
32
|
+
sandboxConfig: void 0
|
|
33
|
+
};
|
|
34
|
+
function migrateSettings(raw, fromVersion) {
|
|
35
|
+
let migrated = { ...raw };
|
|
36
|
+
return migrated;
|
|
37
|
+
}
|
|
38
|
+
async function readSettingsOutcome() {
|
|
39
|
+
if (!existsSync(configuration.settingsFile)) {
|
|
40
|
+
return { kind: "absent" };
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return { kind: "ok", settings: await parseSettingsFile() };
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return { kind: "unreadable", error: error?.message ?? String(error) };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function readSettings() {
|
|
49
|
+
const outcome = await readSettingsOutcome();
|
|
50
|
+
if (outcome.kind === "ok") return outcome.settings;
|
|
51
|
+
if (outcome.kind === "unreadable") {
|
|
52
|
+
logger.warn(`Failed to read settings: ${outcome.error}`);
|
|
53
|
+
}
|
|
54
|
+
return { ...defaultSettings };
|
|
55
|
+
}
|
|
56
|
+
async function parseSettingsFile() {
|
|
57
|
+
const content = await readFile(configuration.settingsFile, "utf8");
|
|
58
|
+
const raw = JSON.parse(content);
|
|
59
|
+
const schemaVersion = raw.schemaVersion ?? 1;
|
|
60
|
+
if (schemaVersion > SUPPORTED_SCHEMA_VERSION) {
|
|
61
|
+
logger.warn(
|
|
62
|
+
`\u26A0\uFE0F Settings schema v${schemaVersion} > supported v${SUPPORTED_SCHEMA_VERSION}. Update happy-cli for full functionality.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const migrated = migrateSettings(raw);
|
|
66
|
+
if (migrated.sandboxConfig !== void 0) {
|
|
67
|
+
try {
|
|
68
|
+
migrated.sandboxConfig = SandboxConfigSchema.parse(migrated.sandboxConfig);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logger.warn(`\u26A0\uFE0F Invalid sandbox config - skipping. Error: ${error.message}`);
|
|
71
|
+
migrated.sandboxConfig = void 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { ...defaultSettings, ...migrated };
|
|
75
|
+
}
|
|
76
|
+
async function writeSettings(settings) {
|
|
77
|
+
await ensurePrivateDirectory(configuration.happyHomeDir);
|
|
78
|
+
const settingsWithVersion = {
|
|
79
|
+
...settings,
|
|
80
|
+
schemaVersion: settings.schemaVersion ?? SUPPORTED_SCHEMA_VERSION
|
|
81
|
+
};
|
|
82
|
+
await writePrivateFile(configuration.settingsFile, JSON.stringify(settingsWithVersion, null, 2));
|
|
83
|
+
}
|
|
84
|
+
async function updateSettings(updater) {
|
|
85
|
+
const LOCK_RETRY_INTERVAL_MS = 100;
|
|
86
|
+
const MAX_LOCK_ATTEMPTS = 50;
|
|
87
|
+
const STALE_LOCK_TIMEOUT_MS = 1e4;
|
|
88
|
+
const lockFile = configuration.settingsFile + ".lock";
|
|
89
|
+
const tmpFile = configuration.settingsFile + ".tmp";
|
|
90
|
+
let fileHandle;
|
|
91
|
+
let attempts = 0;
|
|
92
|
+
while (attempts < MAX_LOCK_ATTEMPTS) {
|
|
93
|
+
try {
|
|
94
|
+
fileHandle = await open(lockFile, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, PRIVATE_FILE_MODE);
|
|
95
|
+
break;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (err.code === "EEXIST") {
|
|
98
|
+
attempts++;
|
|
99
|
+
await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_INTERVAL_MS));
|
|
100
|
+
try {
|
|
101
|
+
const stats = await stat(lockFile);
|
|
102
|
+
if (Date.now() - stats.mtimeMs > STALE_LOCK_TIMEOUT_MS) {
|
|
103
|
+
await unlink(lockFile).catch(() => {
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!fileHandle) {
|
|
114
|
+
throw new Error(`Failed to acquire settings lock after ${MAX_LOCK_ATTEMPTS * LOCK_RETRY_INTERVAL_MS / 1e3} seconds`);
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const outcome = await readSettingsOutcome();
|
|
118
|
+
if (outcome.kind === "unreadable") {
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Settings file ${configuration.settingsFile} exists but could not be read (${outcome.error}). Refusing to overwrite it \u2014 fix or remove the file (a removed file is recreated with defaults).`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const current = outcome.kind === "ok" ? outcome.settings : { ...defaultSettings };
|
|
124
|
+
const updated = await updater(current);
|
|
125
|
+
await ensurePrivateDirectory(configuration.happyHomeDir);
|
|
126
|
+
await writePrivateFile(tmpFile, JSON.stringify(updated, null, 2));
|
|
127
|
+
await rename(tmpFile, configuration.settingsFile);
|
|
128
|
+
await hardenPrivateFile(configuration.settingsFile);
|
|
129
|
+
return updated;
|
|
130
|
+
} finally {
|
|
131
|
+
await fileHandle.close();
|
|
132
|
+
await unlink(lockFile).catch(() => {
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const credentialsSchema = z.object({
|
|
137
|
+
token: z.string(),
|
|
138
|
+
authServerUrl: z.string().optional(),
|
|
139
|
+
secret: z.string().base64().nullish(),
|
|
140
|
+
// Legacy
|
|
141
|
+
encryption: z.object({
|
|
142
|
+
publicKey: z.string().base64(),
|
|
143
|
+
machineKey: z.string().base64()
|
|
144
|
+
}).nullish()
|
|
145
|
+
});
|
|
146
|
+
async function readCredentials() {
|
|
147
|
+
if (!existsSync(configuration.privateKeyFile)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const keyBase64 = await readFile(configuration.privateKeyFile, "utf8");
|
|
152
|
+
const credentials = credentialsSchema.parse(JSON.parse(keyBase64));
|
|
153
|
+
if (credentials.secret) {
|
|
154
|
+
return {
|
|
155
|
+
token: credentials.token,
|
|
156
|
+
authServerUrl: credentials.authServerUrl,
|
|
157
|
+
encryption: {
|
|
158
|
+
type: "legacy",
|
|
159
|
+
secret: new Uint8Array(Buffer.from(credentials.secret, "base64"))
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
} else if (credentials.encryption) {
|
|
163
|
+
return {
|
|
164
|
+
token: credentials.token,
|
|
165
|
+
authServerUrl: credentials.authServerUrl,
|
|
166
|
+
encryption: {
|
|
167
|
+
type: "dataKey",
|
|
168
|
+
publicKey: new Uint8Array(Buffer.from(credentials.encryption.publicKey, "base64")),
|
|
169
|
+
machineKey: new Uint8Array(Buffer.from(credentials.encryption.machineKey, "base64"))
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
async function readCredentialsForConfiguredRelay() {
|
|
179
|
+
const credentials = await readCredentials();
|
|
180
|
+
if (!credentials) return null;
|
|
181
|
+
const relayProblem = credentialRelayProblem(credentials.authServerUrl, configuration.serverUrl);
|
|
182
|
+
if (relayProblem) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
`${relayProblem} Use a separate HAPPY_HOME_DIR for this relay, or run \`very-happy auth login --force\` before making relay requests.`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
return credentials;
|
|
188
|
+
}
|
|
189
|
+
async function writeCredentialsLegacy(credentials) {
|
|
190
|
+
await ensurePrivateDirectory(configuration.happyHomeDir);
|
|
191
|
+
await writePrivateFile(configuration.privateKeyFile, JSON.stringify({
|
|
192
|
+
secret: encodeBase64(credentials.secret),
|
|
193
|
+
token: credentials.token,
|
|
194
|
+
authServerUrl: configuration.serverUrl
|
|
195
|
+
}, null, 2));
|
|
196
|
+
}
|
|
197
|
+
async function writeCredentialsDataKey(credentials) {
|
|
198
|
+
await ensurePrivateDirectory(configuration.happyHomeDir);
|
|
199
|
+
await writePrivateFile(configuration.privateKeyFile, JSON.stringify({
|
|
200
|
+
encryption: { publicKey: encodeBase64(credentials.publicKey), machineKey: encodeBase64(credentials.machineKey) },
|
|
201
|
+
token: credentials.token,
|
|
202
|
+
authServerUrl: configuration.serverUrl
|
|
203
|
+
}, null, 2));
|
|
204
|
+
}
|
|
205
|
+
async function clearCredentials() {
|
|
206
|
+
if (existsSync(configuration.privateKeyFile)) {
|
|
207
|
+
await unlink(configuration.privateKeyFile);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function clearMachineId() {
|
|
211
|
+
await updateSettings((settings) => ({
|
|
212
|
+
...settings,
|
|
213
|
+
machineId: void 0
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
async function readDaemonState() {
|
|
217
|
+
try {
|
|
218
|
+
if (!existsSync(configuration.daemonStateFile)) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const content = await readFile(configuration.daemonStateFile, "utf-8");
|
|
222
|
+
return JSON.parse(content);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.error(`[PERSISTENCE] Daemon state file corrupted: ${configuration.daemonStateFile}`, error);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function writeDaemonState(state) {
|
|
229
|
+
writePrivateFileSync(configuration.daemonStateFile, JSON.stringify(state, null, 2));
|
|
230
|
+
}
|
|
231
|
+
async function clearDaemonState() {
|
|
232
|
+
if (existsSync(configuration.daemonStateFile)) {
|
|
233
|
+
await unlink(configuration.daemonStateFile);
|
|
234
|
+
}
|
|
235
|
+
if (existsSync(configuration.daemonLockFile)) {
|
|
236
|
+
try {
|
|
237
|
+
await unlink(configuration.daemonLockFile);
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async function acquireDaemonLock(maxAttempts = 5, delayIncrementMs = 200) {
|
|
243
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
244
|
+
try {
|
|
245
|
+
const fileHandle = await open(
|
|
246
|
+
configuration.daemonLockFile,
|
|
247
|
+
constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY,
|
|
248
|
+
PRIVATE_FILE_MODE
|
|
249
|
+
);
|
|
250
|
+
await fileHandle.writeFile(String(process.pid));
|
|
251
|
+
return fileHandle;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
if (error.code === "EEXIST") {
|
|
254
|
+
try {
|
|
255
|
+
const lockPid = readFileSync(configuration.daemonLockFile, "utf-8").trim();
|
|
256
|
+
if (lockPid && !isNaN(Number(lockPid))) {
|
|
257
|
+
try {
|
|
258
|
+
process.kill(Number(lockPid), 0);
|
|
259
|
+
} catch {
|
|
260
|
+
unlinkSync(configuration.daemonLockFile);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch {
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (attempt === maxAttempts) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const delayMs = attempt * delayIncrementMs;
|
|
271
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
async function releaseDaemonLock(lockHandle) {
|
|
277
|
+
try {
|
|
278
|
+
await lockHandle.close();
|
|
279
|
+
} catch {
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
if (existsSync(configuration.daemonLockFile)) {
|
|
283
|
+
unlinkSync(configuration.daemonLockFile);
|
|
284
|
+
}
|
|
285
|
+
} catch {
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const SESSION_MAX_AGE_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
289
|
+
function readPersistedSessions() {
|
|
290
|
+
try {
|
|
291
|
+
if (!existsSync(configuration.sessionsFile)) return {};
|
|
292
|
+
const data = JSON.parse(readFileSync(configuration.sessionsFile, "utf-8"));
|
|
293
|
+
if (!data?.sessions || typeof data.sessions !== "object") return {};
|
|
294
|
+
const now = Date.now();
|
|
295
|
+
const sessions = {};
|
|
296
|
+
for (const [id, session] of Object.entries(data.sessions)) {
|
|
297
|
+
if (now - session.savedAt < SESSION_MAX_AGE_MS) {
|
|
298
|
+
sessions[id] = session;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return sessions;
|
|
302
|
+
} catch {
|
|
303
|
+
return {};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function readTrackedClaudeSessionIds() {
|
|
307
|
+
try {
|
|
308
|
+
if (!existsSync(configuration.sessionsFile)) return [];
|
|
309
|
+
const data = JSON.parse(readFileSync(configuration.sessionsFile, "utf-8"));
|
|
310
|
+
if (!data?.sessions || typeof data.sessions !== "object") return [];
|
|
311
|
+
const ids = /* @__PURE__ */ new Set();
|
|
312
|
+
for (const session of Object.values(data.sessions)) {
|
|
313
|
+
const metadata = (session ?? {}).metadata;
|
|
314
|
+
for (const id of [metadata?.claudeSessionId, metadata?.importedFromClaudeSessionId]) {
|
|
315
|
+
if (typeof id === "string" && id.length > 0) ids.add(id.toLowerCase());
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return [...ids];
|
|
319
|
+
} catch {
|
|
320
|
+
return [];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function readTrackedCodexThreadIds() {
|
|
324
|
+
try {
|
|
325
|
+
if (!existsSync(configuration.sessionsFile)) return [];
|
|
326
|
+
const data = JSON.parse(readFileSync(configuration.sessionsFile, "utf-8"));
|
|
327
|
+
if (!data?.sessions || typeof data.sessions !== "object") return [];
|
|
328
|
+
const ids = /* @__PURE__ */ new Set();
|
|
329
|
+
for (const session of Object.values(data.sessions)) {
|
|
330
|
+
const metadata = (session ?? {}).metadata;
|
|
331
|
+
for (const id of [metadata?.codexThreadId, metadata?.importedFromCodexThreadId]) {
|
|
332
|
+
if (typeof id === "string" && id.length > 0) ids.add(id.toLowerCase());
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return [...ids];
|
|
336
|
+
} catch {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function persistSession(sessionId, session) {
|
|
341
|
+
try {
|
|
342
|
+
const existing = readPersistedSessions();
|
|
343
|
+
existing[sessionId] = session;
|
|
344
|
+
const tmpFile = configuration.sessionsFile + ".tmp";
|
|
345
|
+
writePrivateFileSync(tmpFile, JSON.stringify({ sessions: existing }, null, 2));
|
|
346
|
+
renameSync(tmpFile, configuration.sessionsFile);
|
|
347
|
+
hardenPrivateFileSync(configuration.sessionsFile);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
logger.debug(`[PERSISTENCE] Failed to persist session ${sessionId}:`, error);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function deletePersistedSessions(sessionIds) {
|
|
353
|
+
try {
|
|
354
|
+
const existing = readPersistedSessions();
|
|
355
|
+
let changed = false;
|
|
356
|
+
for (const id of sessionIds) {
|
|
357
|
+
if (id in existing) {
|
|
358
|
+
delete existing[id];
|
|
359
|
+
changed = true;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (!changed) return;
|
|
363
|
+
const tmpFile = configuration.sessionsFile + ".tmp";
|
|
364
|
+
writePrivateFileSync(tmpFile, JSON.stringify({ sessions: existing }, null, 2));
|
|
365
|
+
renameSync(tmpFile, configuration.sessionsFile);
|
|
366
|
+
hardenPrivateFileSync(configuration.sessionsFile);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
logger.debug(`[PERSISTENCE] Failed to delete persisted sessions:`, error);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export { SUPPORTED_SCHEMA_VERSION, SandboxConfigSchema, acquireDaemonLock, clearCredentials, clearDaemonState, clearMachineId, deletePersistedSessions, persistSession, readCredentials, readCredentialsForConfiguredRelay, readDaemonState, readPersistedSessions, readSettings, readSettingsOutcome, readTrackedClaudeSessionIds, readTrackedCodexThreadIds, releaseDaemonLock, updateSettings, writeCredentialsDataKey, writeCredentialsLegacy, writeDaemonState, writeSettings };
|
package/dist/piExtension.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
2
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { p as projectPath } from './projectPath-BTBIMB57.mjs';
|
|
5
5
|
import { r as resolveMcpTerminalId } from './terminalToolContext-CFeGeaNm.mjs';
|
|
6
|
+
import { T as TERMINAL_TITLE_SUGGEST_METHOD, a as TerminalTitleSuggestResultSchema } from './terminalTitleSuggest-CeKsX_V6.mjs';
|
|
6
7
|
import 'path';
|
|
7
8
|
import 'url';
|
|
8
9
|
import 'zod';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sessionModeFile = require('./sessionModeFile-BVCV5f7E.cjs');
|
|
4
|
+
|
|
5
|
+
function detectDaemonSupervisor(env, platform = process.platform) {
|
|
6
|
+
const explicit = env.HAPPY_DAEMON_SUPERVISOR?.trim().toLowerCase();
|
|
7
|
+
if (explicit === "systemd") return "systemd";
|
|
8
|
+
if (explicit === "none") return "none";
|
|
9
|
+
if (platform === "linux" && typeof env.INVOCATION_ID === "string" && env.INVOCATION_ID.trim() !== "") return "systemd";
|
|
10
|
+
return "none";
|
|
11
|
+
}
|
|
12
|
+
const SYSTEMD_RESTART_HINT = "systemctl --user restart very-happy-daemon";
|
|
13
|
+
|
|
14
|
+
function sanitizeSpawnModel(value) {
|
|
15
|
+
if (typeof value !== "string") return null;
|
|
16
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}(\[1m\])?$/i.test(value) ? value : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const IGNORED_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--happy-starting-mode"]);
|
|
20
|
+
const PI_ADAPTER_INSTALL_HINT = "very-happy pi needs the pi-acp adapter on PATH: npm install -g pi-acp@0.0.33";
|
|
21
|
+
function piAdapterMissingHint(detail) {
|
|
22
|
+
return detail && /ENOENT/.test(detail) ? PI_ADAPTER_INSTALL_HINT : null;
|
|
23
|
+
}
|
|
24
|
+
function parsePiRunnerArgs(args) {
|
|
25
|
+
const parsed = { verbose: false, passthrough: [] };
|
|
26
|
+
for (let i = 0; i < args.length; i++) {
|
|
27
|
+
const arg = args[i];
|
|
28
|
+
if (arg === "--") {
|
|
29
|
+
parsed.passthrough.push(...args.slice(i + 1));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (arg === "--started-by") {
|
|
33
|
+
const value = args[++i];
|
|
34
|
+
if (value === "daemon" || value === "terminal") parsed.startedBy = value;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (arg === "--verbose") {
|
|
38
|
+
parsed.verbose = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (arg === "--model") {
|
|
42
|
+
const model = sanitizeSpawnModel(args[++i]);
|
|
43
|
+
if (!model) throw new Error("Invalid --model identifier");
|
|
44
|
+
parsed.model = model;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (arg === "--permission-mode") {
|
|
48
|
+
const mode = sessionModeFile.normalizeAcpPermissionMode(args[++i]);
|
|
49
|
+
if (mode) parsed.permissionMode = mode;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (IGNORED_FLAGS_WITH_VALUE.has(arg)) {
|
|
53
|
+
i++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Unknown option for very-happy pi: ${arg} (use -- to pass args to pi-acp)`);
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.PI_ADAPTER_INSTALL_HINT = PI_ADAPTER_INSTALL_HINT;
|
|
62
|
+
exports.SYSTEMD_RESTART_HINT = SYSTEMD_RESTART_HINT;
|
|
63
|
+
exports.detectDaemonSupervisor = detectDaemonSupervisor;
|
|
64
|
+
exports.parsePiRunnerArgs = parsePiRunnerArgs;
|
|
65
|
+
exports.piAdapterMissingHint = piAdapterMissingHint;
|
|
66
|
+
exports.sanitizeSpawnModel = sanitizeSpawnModel;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { n as normalizeAcpPermissionMode } from './sessionModeFile-CDmDyRkD.mjs';
|
|
2
|
+
|
|
3
|
+
function detectDaemonSupervisor(env, platform = process.platform) {
|
|
4
|
+
const explicit = env.HAPPY_DAEMON_SUPERVISOR?.trim().toLowerCase();
|
|
5
|
+
if (explicit === "systemd") return "systemd";
|
|
6
|
+
if (explicit === "none") return "none";
|
|
7
|
+
if (platform === "linux" && typeof env.INVOCATION_ID === "string" && env.INVOCATION_ID.trim() !== "") return "systemd";
|
|
8
|
+
return "none";
|
|
9
|
+
}
|
|
10
|
+
const SYSTEMD_RESTART_HINT = "systemctl --user restart very-happy-daemon";
|
|
11
|
+
|
|
12
|
+
function sanitizeSpawnModel(value) {
|
|
13
|
+
if (typeof value !== "string") return null;
|
|
14
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}(\[1m\])?$/i.test(value) ? value : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const IGNORED_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--happy-starting-mode"]);
|
|
18
|
+
const PI_ADAPTER_INSTALL_HINT = "very-happy pi needs the pi-acp adapter on PATH: npm install -g pi-acp@0.0.33";
|
|
19
|
+
function piAdapterMissingHint(detail) {
|
|
20
|
+
return detail && /ENOENT/.test(detail) ? PI_ADAPTER_INSTALL_HINT : null;
|
|
21
|
+
}
|
|
22
|
+
function parsePiRunnerArgs(args) {
|
|
23
|
+
const parsed = { verbose: false, passthrough: [] };
|
|
24
|
+
for (let i = 0; i < args.length; i++) {
|
|
25
|
+
const arg = args[i];
|
|
26
|
+
if (arg === "--") {
|
|
27
|
+
parsed.passthrough.push(...args.slice(i + 1));
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
if (arg === "--started-by") {
|
|
31
|
+
const value = args[++i];
|
|
32
|
+
if (value === "daemon" || value === "terminal") parsed.startedBy = value;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arg === "--verbose") {
|
|
36
|
+
parsed.verbose = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (arg === "--model") {
|
|
40
|
+
const model = sanitizeSpawnModel(args[++i]);
|
|
41
|
+
if (!model) throw new Error("Invalid --model identifier");
|
|
42
|
+
parsed.model = model;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (arg === "--permission-mode") {
|
|
46
|
+
const mode = normalizeAcpPermissionMode(args[++i]);
|
|
47
|
+
if (mode) parsed.permissionMode = mode;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (IGNORED_FLAGS_WITH_VALUE.has(arg)) {
|
|
51
|
+
i++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Unknown option for very-happy pi: ${arg} (use -- to pass args to pi-acp)`);
|
|
55
|
+
}
|
|
56
|
+
return parsed;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { PI_ADAPTER_INSTALL_HINT as P, SYSTEMD_RESTART_HINT as S, piAdapterMissingHint as a, detectDaemonSupervisor as d, parsePiRunnerArgs as p, sanitizeSpawnModel as s };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var promises = require('node:fs/promises');
|
|
4
4
|
var node_crypto = require('node:crypto');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var configuration = require('./configuration-v9f8LM9T.cjs');
|
|
7
|
+
var resources = require('./resources-JDPugcDq.cjs');
|
|
8
8
|
|
|
9
9
|
async function publish(path, content, mode) {
|
|
10
10
|
const temporary = `${path}.${node_crypto.randomUUID()}.new`;
|
|
@@ -12,10 +12,10 @@ async function publish(path, content, mode) {
|
|
|
12
12
|
await promises.rename(temporary, path);
|
|
13
13
|
}
|
|
14
14
|
async function preparePiTeamsRuntime() {
|
|
15
|
-
const directory = path.join(
|
|
15
|
+
const directory = path.join(configuration.configuration.happyHomeDir, "teams", "pi-runtime");
|
|
16
16
|
await promises.mkdir(directory, { recursive: true, mode: 448 });
|
|
17
17
|
const extension = path.join(directory, "very-happy-teams.mjs");
|
|
18
|
-
await publish(extension,
|
|
18
|
+
await publish(extension, resources.PI_TEAMS_EXTENSION, 384);
|
|
19
19
|
const launcher = path.join(directory, "pi-teams.mjs");
|
|
20
20
|
const script = `#!${process.execPath}
|
|
21
21
|
import { spawn } from 'node:child_process';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir, chmod, writeFile, rename } from 'node:fs/promises';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { c as configuration } from './
|
|
5
|
-
import { P as PI_TEAMS_EXTENSION } from './
|
|
4
|
+
import { c as configuration } from './configuration-DoWFJUPm.mjs';
|
|
5
|
+
import { P as PI_TEAMS_EXTENSION } from './resources-BdFBQi8r.mjs';
|
|
6
6
|
|
|
7
7
|
async function publish(path, content, mode) {
|
|
8
8
|
const temporary = `${path}.${randomUUID()}.new`;
|
|
@@ -3,53 +3,50 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { createServer } from 'node:http';
|
|
4
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
5
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
6
|
-
import { p as preparePiTeamsRuntime } from './piRuntime-
|
|
7
|
-
import { registerMcpTools, registerTerminalTitleSuggest } from './mcp-
|
|
8
|
-
import './agentGuidance-
|
|
6
|
+
import { p as preparePiTeamsRuntime } from './piRuntime-BwRdhK_N.mjs';
|
|
7
|
+
import { registerMcpTools, registerTerminalTitleSuggest } from './mcp-CeUd9KDr.mjs';
|
|
8
|
+
import './agentGuidance-CQuNlNx8.mjs';
|
|
9
9
|
import 'node:fs/promises';
|
|
10
10
|
import 'node:os';
|
|
11
11
|
import 'zod';
|
|
12
|
-
import './
|
|
12
|
+
import './logger-fXoNzNuB.mjs';
|
|
13
|
+
import './persistence-oET5n61f.mjs';
|
|
14
|
+
import './configuration-DoWFJUPm.mjs';
|
|
13
15
|
import 'axios';
|
|
14
16
|
import 'tweetnacl';
|
|
15
17
|
import 'socket.io-client';
|
|
16
|
-
import './
|
|
18
|
+
import './terminals-Dlg0x3nY.mjs';
|
|
17
19
|
import 'node:fs';
|
|
18
20
|
import 'node:path';
|
|
19
21
|
import { r as resolveMcpTerminalId } from './terminalToolContext-CFeGeaNm.mjs';
|
|
20
|
-
import './
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
23
|
-
import '
|
|
24
|
-
import '
|
|
22
|
+
import './resources-BdFBQi8r.mjs';
|
|
23
|
+
import './tools-BmQQUATY.mjs';
|
|
24
|
+
import './client-Brn-UwVk.mjs';
|
|
25
|
+
import './context-C9GHPLEm.mjs';
|
|
26
|
+
import '@modelcontextprotocol/sdk/server/stdio.js';
|
|
27
|
+
import './controlClient-DjoKTtgK.mjs';
|
|
28
|
+
import './limits-DIo7rEBR.mjs';
|
|
29
|
+
import './assistantTools-CgiTbnWb.mjs';
|
|
30
|
+
import './sessionOps-C_f1wKOr.mjs';
|
|
31
|
+
import './authRelay-DSAvg1uv.mjs';
|
|
32
|
+
import './time-BZNdNiIV.mjs';
|
|
33
|
+
import './backgroundTaskActivity-8PdPxrvy.mjs';
|
|
34
|
+
import './remoteSessionClient-CO7qOjR0.mjs';
|
|
35
|
+
import './ids-DU6sLx4C.mjs';
|
|
36
|
+
import './bootstrap-BNQq05jR.mjs';
|
|
37
|
+
import './previewPath-CXN4Vag0.mjs';
|
|
38
|
+
import './terminalTitleSuggest-CeKsX_V6.mjs';
|
|
39
|
+
import './titleGenerator-ox6ptCsp.mjs';
|
|
40
|
+
import 'node:module';
|
|
41
|
+
import './oneShotPrompts-DT4p6RNd.mjs';
|
|
42
|
+
import './projectPath-BTBIMB57.mjs';
|
|
25
43
|
import 'path';
|
|
26
44
|
import 'url';
|
|
27
|
-
import '
|
|
28
|
-
import '
|
|
29
|
-
import 'react';
|
|
30
|
-
import '@anthropic-ai/claude-agent-sdk';
|
|
31
|
-
import 'node:events';
|
|
32
|
-
import 'os';
|
|
33
|
-
import 'child_process';
|
|
34
|
-
import '@paralleldrive/cuid2';
|
|
35
|
-
import 'fs';
|
|
36
|
-
import '@anthropic-ai/sandbox-runtime';
|
|
37
|
-
import 'expo-server-sdk';
|
|
38
|
-
import 'crypto';
|
|
39
|
-
import 'ps-list';
|
|
40
|
-
import 'tmp';
|
|
41
|
-
import 'open';
|
|
42
|
-
import 'fastify';
|
|
43
|
-
import 'fastify-type-provider-zod';
|
|
44
|
-
import 'node:module';
|
|
45
|
+
import './trimIdent-BAjmv_TG.mjs';
|
|
46
|
+
import 'chalk';
|
|
45
47
|
import 'node:util';
|
|
46
|
-
import '
|
|
47
|
-
import '
|
|
48
|
-
import 'inquirer';
|
|
49
|
-
import 'node:url';
|
|
50
|
-
import 'node:readline/promises';
|
|
51
|
-
import '@modelcontextprotocol/sdk/server/stdio.js';
|
|
52
|
-
import 'node-pty';
|
|
48
|
+
import './package-uOg9SCKi.mjs';
|
|
49
|
+
import './tmuxSocket-B8Yx20sT.mjs';
|
|
53
50
|
|
|
54
51
|
async function startPiTerminalTools(terminalId) {
|
|
55
52
|
const path = `/terminal-tools/${randomUUID()}`;
|