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,245 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_fs = require('node:fs');
|
|
4
|
+
var spawnHappyCLI = require('./spawnHappyCLI-BhYj84rv.cjs');
|
|
5
|
+
var axios = require('axios');
|
|
6
|
+
var tweetnacl = require('tweetnacl');
|
|
7
|
+
var z = require('zod');
|
|
8
|
+
var authRelay = require('./authRelay-BdYkC1Po.cjs');
|
|
9
|
+
var configuration = require('./configuration-v9f8LM9T.cjs');
|
|
10
|
+
var localHappyAgentAuth = require('./localHappyAgentAuth-BXiHPXdC.cjs');
|
|
11
|
+
require('cross-spawn');
|
|
12
|
+
require('node:path');
|
|
13
|
+
require('./projectPath-ChLhdOyt.cjs');
|
|
14
|
+
require('path');
|
|
15
|
+
require('url');
|
|
16
|
+
require('./logger-Bc8-u1w0.cjs');
|
|
17
|
+
require('chalk');
|
|
18
|
+
require('node:util');
|
|
19
|
+
require('node:crypto');
|
|
20
|
+
require('node:os');
|
|
21
|
+
require('./package-Cl5BEP5x.cjs');
|
|
22
|
+
require('node:fs/promises');
|
|
23
|
+
|
|
24
|
+
const ResumableMetadataSchema = z.z.object({
|
|
25
|
+
path: z.z.string().min(1),
|
|
26
|
+
flavor: z.z.string().optional(),
|
|
27
|
+
claudeSessionId: z.z.string().optional(),
|
|
28
|
+
codexThreadId: z.z.string().optional()
|
|
29
|
+
}).passthrough();
|
|
30
|
+
function resolveSessionRecordByPrefix(records, sessionId) {
|
|
31
|
+
const trimmed = sessionId.trim();
|
|
32
|
+
if (!trimmed) {
|
|
33
|
+
throw new Error("Happy session ID is required: very-happy resume <session-id>");
|
|
34
|
+
}
|
|
35
|
+
const matches = records.filter((record) => record.id.startsWith(trimmed));
|
|
36
|
+
if (matches.length === 0) {
|
|
37
|
+
throw new Error(`No Happy session found matching "${trimmed}"`);
|
|
38
|
+
}
|
|
39
|
+
if (matches.length > 1) {
|
|
40
|
+
throw new Error(`Ambiguous Happy session "${trimmed}" matches ${matches.length} sessions. Be more specific.`);
|
|
41
|
+
}
|
|
42
|
+
return matches[0];
|
|
43
|
+
}
|
|
44
|
+
function decryptBoxBundle(bundle, recipientSecretKey) {
|
|
45
|
+
if (bundle.length < 56) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const ephemeralPublicKey = bundle.slice(0, 32);
|
|
49
|
+
const nonce = bundle.slice(32, 56);
|
|
50
|
+
const ciphertext = bundle.slice(56);
|
|
51
|
+
const decrypted = tweetnacl.box.open(ciphertext, nonce, ephemeralPublicKey, recipientSecretKey);
|
|
52
|
+
return decrypted ? new Uint8Array(decrypted) : null;
|
|
53
|
+
}
|
|
54
|
+
function readAgentCredentials() {
|
|
55
|
+
const credentialPath = localHappyAgentAuth.getLocalHappyAgentCredentialPath();
|
|
56
|
+
const credentials = localHappyAgentAuth.readLocalHappyAgentCredentials();
|
|
57
|
+
if (!credentials) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Cannot use the legacy CLI resume path without ${credentialPath}. This credential is produced only by the source-only internal control-plane prototype; do not install the unrelated npm package named happy-agent. Use the Web session controls instead.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return credentials;
|
|
63
|
+
}
|
|
64
|
+
function resolveSessionEncryption(session, credentials) {
|
|
65
|
+
if (session.dataEncryptionKey) {
|
|
66
|
+
const encrypted = authRelay.decodeBase64(session.dataEncryptionKey);
|
|
67
|
+
const sessionKey = decryptBoxBundle(encrypted.slice(1), credentials.contentKeyPair.secretKey);
|
|
68
|
+
if (!sessionKey) {
|
|
69
|
+
throw new Error(`Failed to decrypt data key for Happy session ${session.id}`);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
key: sessionKey,
|
|
73
|
+
variant: "dataKey"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
key: credentials.secret,
|
|
78
|
+
variant: "legacy"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function decryptSessionMetadata(session, credentials) {
|
|
82
|
+
const encryption = resolveSessionEncryption(session, credentials);
|
|
83
|
+
const encryptedMetadata = authRelay.decodeBase64(session.metadata);
|
|
84
|
+
const metadata = encryption.variant === "dataKey" ? authRelay.decryptWithDataKey(encryptedMetadata, encryption.key) : authRelay.decryptLegacy(encryptedMetadata, encryption.key);
|
|
85
|
+
if (!metadata) {
|
|
86
|
+
throw new Error(`Failed to decrypt metadata for Happy session ${session.id}`);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return ResumableMetadataSchema.parse(metadata);
|
|
90
|
+
} catch {
|
|
91
|
+
throw new Error(`Happy session ${session.id} is missing resumable metadata.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function fetchSessions(credentials) {
|
|
95
|
+
try {
|
|
96
|
+
const response = await axios.get(`${configuration.configuration.serverUrl}/v1/sessions`, {
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: `Bearer ${credentials.token}`,
|
|
99
|
+
"X-Happy-Client": `cli-coding-session/${configuration.configuration.currentCliVersion}`
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return response.data.sessions;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error instanceof axios.AxiosError) {
|
|
105
|
+
if (error.response?.status === 401) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
"Legacy CLI resume authentication expired. Re-provision it from the source-only internal control-plane prototype; do not install the unrelated npm package named happy-agent."
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
throw new Error(`Failed to load Happy sessions: ${error.message}`);
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function resolveHappySession(sessionId) {
|
|
116
|
+
const credentials = readAgentCredentials();
|
|
117
|
+
const sessions = await fetchSessions(credentials);
|
|
118
|
+
const matched = resolveSessionRecordByPrefix(sessions, sessionId);
|
|
119
|
+
return {
|
|
120
|
+
id: matched.id,
|
|
121
|
+
active: matched.active,
|
|
122
|
+
metadata: decryptSessionMetadata(matched, credentials)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function parseResumeCommandArgs(args) {
|
|
127
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
128
|
+
return {
|
|
129
|
+
showHelp: true,
|
|
130
|
+
sessionId: ""
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (args.length === 0) {
|
|
134
|
+
throw new Error("Happy session ID is required: very-happy resume <session-id>");
|
|
135
|
+
}
|
|
136
|
+
if (args.length > 1) {
|
|
137
|
+
throw new Error(`Unexpected arguments for very-happy resume: ${args.slice(1).join(" ")}`);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
showHelp: false,
|
|
141
|
+
sessionId: args[0]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function resolveFlavor(metadata) {
|
|
145
|
+
if (metadata.flavor === "codex" || metadata.codexThreadId) {
|
|
146
|
+
return "codex";
|
|
147
|
+
}
|
|
148
|
+
if (metadata.flavor === "claude" || metadata.claudeSessionId) {
|
|
149
|
+
return "claude";
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
function buildResumeLaunch(session, options = {}) {
|
|
154
|
+
const { metadata } = session;
|
|
155
|
+
const flavor = resolveFlavor(metadata);
|
|
156
|
+
if (flavor === "codex") {
|
|
157
|
+
const args = ["codex"];
|
|
158
|
+
if (options.freshConversation) ; else {
|
|
159
|
+
if (!metadata.codexThreadId) {
|
|
160
|
+
throw new Error(`Happy session ${session.id} is missing its Codex thread ID.`);
|
|
161
|
+
}
|
|
162
|
+
args.push("--resume", metadata.codexThreadId);
|
|
163
|
+
}
|
|
164
|
+
if (options.startedBy) {
|
|
165
|
+
args.push("--started-by", options.startedBy);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
cwd: metadata.path,
|
|
169
|
+
args
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (flavor === "claude") {
|
|
173
|
+
const args = ["claude"];
|
|
174
|
+
if (options.claudeStartingMode) {
|
|
175
|
+
args.push("--happy-starting-mode", options.claudeStartingMode);
|
|
176
|
+
}
|
|
177
|
+
if (options.startedBy) {
|
|
178
|
+
args.push("--started-by", options.startedBy);
|
|
179
|
+
}
|
|
180
|
+
if (options.freshConversation) ; else {
|
|
181
|
+
if (!metadata.claudeSessionId) {
|
|
182
|
+
throw new Error(`Happy session ${session.id} is missing its Claude session ID.`);
|
|
183
|
+
}
|
|
184
|
+
args.push("--resume", metadata.claudeSessionId);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
cwd: metadata.path,
|
|
188
|
+
args
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
throw new Error(`Happy session ${session.id} uses unsupported flavor "${metadata.flavor ?? "unknown"}".`);
|
|
192
|
+
}
|
|
193
|
+
function formatResumeHelp() {
|
|
194
|
+
return [
|
|
195
|
+
"very-happy resume - Resume a previous Happy session",
|
|
196
|
+
"",
|
|
197
|
+
"Usage:",
|
|
198
|
+
" very-happy resume <happy-session-id>",
|
|
199
|
+
"",
|
|
200
|
+
"Examples:",
|
|
201
|
+
" very-happy resume cmmij8olq00dp5jcxr3wtbpau",
|
|
202
|
+
" very-happy resume cmmij8",
|
|
203
|
+
"",
|
|
204
|
+
"This reuses the saved worktree/path and resumes the underlying agent session",
|
|
205
|
+
"when the backend supports it."
|
|
206
|
+
].join("\n");
|
|
207
|
+
}
|
|
208
|
+
function spawnResumeChild(launch) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
const child = spawnHappyCLI.spawnHappyCLI(launch.args, {
|
|
211
|
+
cwd: launch.cwd,
|
|
212
|
+
env: process.env,
|
|
213
|
+
stdio: "inherit"
|
|
214
|
+
});
|
|
215
|
+
child.once("error", reject);
|
|
216
|
+
child.once("exit", (code, signal) => {
|
|
217
|
+
if (signal) {
|
|
218
|
+
reject(new Error(`Resumed session exited via signal ${signal}`));
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
resolve(code);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async function handleResumeCommand(args) {
|
|
226
|
+
const parsed = parseResumeCommandArgs(args);
|
|
227
|
+
if (parsed.showHelp) {
|
|
228
|
+
console.log(formatResumeHelp());
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const session = await resolveHappySession(parsed.sessionId);
|
|
232
|
+
const launch = buildResumeLaunch(session);
|
|
233
|
+
if (!node_fs.existsSync(launch.cwd)) {
|
|
234
|
+
throw new Error(`Saved session path does not exist: ${launch.cwd}`);
|
|
235
|
+
}
|
|
236
|
+
const exitCode = await spawnResumeChild(launch);
|
|
237
|
+
if (typeof exitCode === "number" && exitCode !== 0) {
|
|
238
|
+
process.exit(exitCode);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
exports.buildResumeLaunch = buildResumeLaunch;
|
|
243
|
+
exports.formatResumeHelp = formatResumeHelp;
|
|
244
|
+
exports.handleResumeCommand = handleResumeCommand;
|
|
245
|
+
exports.parseResumeCommandArgs = parseResumeCommandArgs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SESSION_ID_RE = /^[a-zA-Z0-9_-]{1,128}$/;
|
|
4
|
+
const TERMINAL_ID_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
5
|
+
function isValidSessionId(id) {
|
|
6
|
+
return typeof id === "string" && SESSION_ID_RE.test(id);
|
|
7
|
+
}
|
|
8
|
+
function isValidTerminalId(id) {
|
|
9
|
+
return typeof id === "string" && TERMINAL_ID_RE.test(id);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.isValidSessionId = isValidSessionId;
|
|
13
|
+
exports.isValidTerminalId = isValidTerminalId;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const SESSION_ID_RE = /^[a-zA-Z0-9_-]{1,128}$/;
|
|
2
|
+
const TERMINAL_ID_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
3
|
+
function isValidSessionId(id) {
|
|
4
|
+
return typeof id === "string" && SESSION_ID_RE.test(id);
|
|
5
|
+
}
|
|
6
|
+
function isValidTerminalId(id) {
|
|
7
|
+
return typeof id === "string" && TERMINAL_ID_RE.test(id);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { isValidTerminalId as a, isValidSessionId as i };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { query as query$1 } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
export { AbortError } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
+
import { p as pinSmallFastModel, e as ensureLocalProxyBypass } from './smallFastModel-BLNgMrwR.mjs';
|
|
4
|
+
|
|
5
|
+
const HAPPY_DEFAULT_ENTRYPOINT = "remote_mobile";
|
|
6
|
+
function resolveHappyEntrypoint(currentValue) {
|
|
7
|
+
if (currentValue && currentValue.length > 0) {
|
|
8
|
+
return currentValue;
|
|
9
|
+
}
|
|
10
|
+
return HAPPY_DEFAULT_ENTRYPOINT;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function query(params) {
|
|
14
|
+
const opts = params.options;
|
|
15
|
+
let systemPrompt = void 0;
|
|
16
|
+
if (opts?.customSystemPrompt) {
|
|
17
|
+
systemPrompt = opts.customSystemPrompt;
|
|
18
|
+
} else if (opts?.appendSystemPrompt) {
|
|
19
|
+
systemPrompt = {
|
|
20
|
+
type: "preset",
|
|
21
|
+
preset: "claude_code",
|
|
22
|
+
append: opts.appendSystemPrompt
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const sdkOptions = {
|
|
26
|
+
cwd: opts?.cwd,
|
|
27
|
+
additionalDirectories: opts?.additionalDirectories,
|
|
28
|
+
resume: opts?.resume,
|
|
29
|
+
continue: opts?.continue,
|
|
30
|
+
model: opts?.model,
|
|
31
|
+
fallbackModel: opts?.fallbackModel,
|
|
32
|
+
maxTurns: opts?.maxTurns,
|
|
33
|
+
permissionMode: opts?.permissionMode,
|
|
34
|
+
allowDangerouslySkipPermissions: opts?.allowDangerouslySkipPermissions ?? opts?.permissionMode === "bypassPermissions",
|
|
35
|
+
allowedTools: opts?.allowedTools,
|
|
36
|
+
disallowedTools: opts?.disallowedTools,
|
|
37
|
+
mcpServers: opts?.mcpServers,
|
|
38
|
+
systemPrompt,
|
|
39
|
+
settings: opts?.settingsPath,
|
|
40
|
+
// Load filesystem settings the way the real `claude` CLI does. The
|
|
41
|
+
// agent SDK does NOT load these by default (the rename from
|
|
42
|
+
// @anthropic-ai/claude-code flipped the default to "isolated" — the
|
|
43
|
+
// sdk.d.ts comment claiming "omitted = all sources" is stale), so a
|
|
44
|
+
// remote/web session would otherwise ignore ~/.claude/CLAUDE.md, the
|
|
45
|
+
// project .claude/, AND skills (skills are discovered from these dirs).
|
|
46
|
+
// 'user' brings in the global CLAUDE.md (e.g. "reply in Chinese"),
|
|
47
|
+
// 'project'/'local' bring in repo-level CLAUDE.md + settings → parity
|
|
48
|
+
// with a plain CLI invocation. This is the whole point of running our
|
|
49
|
+
// own fork: remote sessions should behave like local ones.
|
|
50
|
+
settingSources: ["user", "project", "local"],
|
|
51
|
+
strictMcpConfig: opts?.strictMcpConfig,
|
|
52
|
+
sessionId: void 0,
|
|
53
|
+
effort: opts?.effort,
|
|
54
|
+
forkSession: opts?.forkSession,
|
|
55
|
+
tools: opts?.tools,
|
|
56
|
+
persistSession: opts?.persistSession,
|
|
57
|
+
includePartialMessages: opts?.includePartialMessages,
|
|
58
|
+
forwardSubagentText: true,
|
|
59
|
+
enableFileCheckpointing: true,
|
|
60
|
+
extraArgs: { "replay-user-messages": null },
|
|
61
|
+
onElicitation: opts?.onElicitation,
|
|
62
|
+
onUserDialog: opts?.onUserDialog,
|
|
63
|
+
supportedDialogKinds: opts?.onUserDialog ? opts.supportedDialogKinds : void 0
|
|
64
|
+
};
|
|
65
|
+
if (opts?.abort) {
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
if (opts.abort.aborted) {
|
|
68
|
+
controller.abort(opts.abort.reason);
|
|
69
|
+
} else {
|
|
70
|
+
opts.abort.addEventListener("abort", () => controller.abort(opts.abort?.reason), { once: true });
|
|
71
|
+
}
|
|
72
|
+
sdkOptions.abortController = controller;
|
|
73
|
+
}
|
|
74
|
+
const env = {};
|
|
75
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
76
|
+
if (typeof value === "string") env[key] = value;
|
|
77
|
+
}
|
|
78
|
+
for (const [key, value] of Object.entries(opts?.env ?? {})) {
|
|
79
|
+
if (typeof value === "string") env[key] = value;
|
|
80
|
+
}
|
|
81
|
+
env.CLAUDE_CODE_ENTRYPOINT = resolveHappyEntrypoint(env.CLAUDE_CODE_ENTRYPOINT);
|
|
82
|
+
pinSmallFastModel(env);
|
|
83
|
+
if (opts?.mcpServers && Object.keys(opts.mcpServers).length > 0) {
|
|
84
|
+
ensureLocalProxyBypass(env);
|
|
85
|
+
}
|
|
86
|
+
if (sdkOptions.allowDangerouslySkipPermissions && typeof process.getuid === "function" && process.getuid() === 0 && env.IS_SANDBOX === void 0) {
|
|
87
|
+
env.IS_SANDBOX = "1";
|
|
88
|
+
}
|
|
89
|
+
sdkOptions.env = env;
|
|
90
|
+
if (opts?.canCallTool) {
|
|
91
|
+
const callback = opts.canCallTool;
|
|
92
|
+
sdkOptions.canUseTool = async (toolName, input, options) => {
|
|
93
|
+
return callback(toolName, input, options);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return query$1({
|
|
97
|
+
prompt: params.prompt,
|
|
98
|
+
options: sdkOptions
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { query };
|
|
@@ -1,56 +1,86 @@
|
|
|
1
|
-
import { D as DefaultTransport, A as AcpBackend } from './AcpBackend-
|
|
2
|
-
export { a as DEFAULT_IDLE_TIMEOUT_MS, b as DEFAULT_TOOL_CALL_TIMEOUT_MS, e as extractErrorDetail, f as formatDuration, c as formatDurationMinutes, h as handleAgentMessageChunk, d as handleAgentThoughtChunk, g as handleLegacyMessageChunk, i as handlePlanUpdate, j as handleThinkingUpdate, k as handleToolCall, l as handleToolCallUpdate, p as parseArgsFromContent } from './AcpBackend-
|
|
3
|
-
import {
|
|
4
|
-
import { A as AcpSessionManager } from './AcpSessionManager-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { D as DefaultTransport, A as AcpBackend } from './AcpBackend-6U6pQgx1.mjs';
|
|
2
|
+
export { a as DEFAULT_IDLE_TIMEOUT_MS, b as DEFAULT_TOOL_CALL_TIMEOUT_MS, e as extractErrorDetail, f as formatDuration, c as formatDurationMinutes, h as handleAgentMessageChunk, d as handleAgentThoughtChunk, g as handleLegacyMessageChunk, i as handlePlanUpdate, j as handleThinkingUpdate, k as handleToolCall, l as handleToolCallUpdate, p as parseArgsFromContent } from './AcpBackend-6U6pQgx1.mjs';
|
|
3
|
+
import { l as logger } from './logger-fXoNzNuB.mjs';
|
|
4
|
+
import { A as AcpSessionManager } from './AcpSessionManager-CoMWFVw3.mjs';
|
|
5
|
+
import { l as BUILTIN_TODO_DISCOVERY, P as PROMPT_QUEUE_CAPABILITY } from './index-qdS1friN.mjs';
|
|
6
|
+
import { r as registerAgentAttachmentDownloads } from './agentAttachments-M_B5qEF2.mjs';
|
|
7
|
+
import { c as configuration } from './configuration-DoWFJUPm.mjs';
|
|
8
|
+
import { C as CLAUDE_ATTACHMENT_KINDS, a as stageClaudeAttachments, b as appendStagedAttachmentsToPrompt } from './attachmentContent-CSGxr71v.mjs';
|
|
9
|
+
import { p as preparePiTeamsRuntime } from './piRuntime-BwRdhK_N.mjs';
|
|
7
10
|
import { randomUUID } from 'node:crypto';
|
|
8
11
|
import { join } from 'node:path';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
12
|
+
import { c as connectionState, A as ApiClient } from './api-SffjRQ1b.mjs';
|
|
13
|
+
import { M as MessageQueue2, r as registerKillSessionHandler } from './registerKillSessionHandler-Cbc8Rgtd.mjs';
|
|
14
|
+
import { h as hashObject, s as startHappyServer } from './deterministicJson-p835AdAU.mjs';
|
|
15
|
+
import { readSettings } from './persistence-oET5n61f.mjs';
|
|
16
|
+
import { g as getInitialMachineMetadata } from './machineMetadata-BHjehxJY.mjs';
|
|
17
|
+
import { c as createSessionMetadata } from './createSessionMetadata-mIeehclp.mjs';
|
|
18
|
+
import { s as setupOfflineReconnection } from './setupOfflineReconnection-CVViqZft.mjs';
|
|
19
|
+
import { n as notifyDaemonSessionStarted, g as reportSessionEditToDaemon } from './controlClient-DjoKTtgK.mjs';
|
|
20
|
+
import { e as encodeBase64 } from './authRelay-DSAvg1uv.mjs';
|
|
21
|
+
import { S as StreamRelay } from './streamRelay-FPVbHpbM.mjs';
|
|
22
|
+
import { p as projectPath } from './projectPath-BTBIMB57.mjs';
|
|
23
|
+
import { B as BasePermissionHandler } from './BasePermissionHandler-BvvhBTja.mjs';
|
|
24
|
+
import { T as TitleGenerator } from './titleGenerator-ox6ptCsp.mjs';
|
|
25
|
+
import { w as writeSessionModeFile, n as normalizeAcpPermissionMode, r as removeSessionModeFile } from './sessionModeFile-CDmDyRkD.mjs';
|
|
26
|
+
import { E as EditReportThrottle, e as extractAcpEditPaths } from './editPaths-BVfS_FFL.mjs';
|
|
11
27
|
import 'node:child_process';
|
|
12
28
|
import '@agentclientprotocol/sdk';
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
16
|
-
import 'node:fs';
|
|
17
|
-
import 'tweetnacl';
|
|
29
|
+
import './time-BZNdNiIV.mjs';
|
|
30
|
+
import './contentLogMetadata-BlWI0egu.mjs';
|
|
31
|
+
import './package-uOg9SCKi.mjs';
|
|
18
32
|
import 'chalk';
|
|
19
33
|
import 'node:util';
|
|
34
|
+
import 'node:fs';
|
|
35
|
+
import '@paralleldrive/cuid2';
|
|
36
|
+
import 'zod';
|
|
20
37
|
import 'node:os';
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
23
|
-
import './
|
|
38
|
+
import 'node:fs/promises';
|
|
39
|
+
import './attachmentLimits-yba1uHFO.mjs';
|
|
40
|
+
import './resources-BdFBQi8r.mjs';
|
|
24
41
|
import 'axios';
|
|
25
|
-
import 'socket.io-client';
|
|
26
|
-
import 'fs/promises';
|
|
27
|
-
import 'ink';
|
|
28
|
-
import 'react';
|
|
29
|
-
import '@anthropic-ai/claude-agent-sdk';
|
|
30
42
|
import 'node:events';
|
|
43
|
+
import 'socket.io-client';
|
|
44
|
+
import './limits-DIo7rEBR.mjs';
|
|
45
|
+
import './lidState-C2dI0FAN.mjs';
|
|
31
46
|
import 'os';
|
|
32
47
|
import 'child_process';
|
|
33
|
-
import '
|
|
34
|
-
import '
|
|
35
|
-
import '
|
|
36
|
-
import 'expo-server-sdk';
|
|
48
|
+
import './registerCommonHandlers-CrgvJsOy.mjs';
|
|
49
|
+
import 'util';
|
|
50
|
+
import 'fs/promises';
|
|
37
51
|
import 'crypto';
|
|
38
|
-
import '
|
|
39
|
-
import '
|
|
40
|
-
import '
|
|
41
|
-
import '
|
|
42
|
-
import '
|
|
43
|
-
import '
|
|
52
|
+
import 'path';
|
|
53
|
+
import 'cross-spawn';
|
|
54
|
+
import './sync-CxD-w_40.mjs';
|
|
55
|
+
import './backgroundTaskActivity-8PdPxrvy.mjs';
|
|
56
|
+
import 'tweetnacl';
|
|
57
|
+
import './types-CkqAACXx.mjs';
|
|
58
|
+
import './client-Brn-UwVk.mjs';
|
|
59
|
+
import './context-C9GHPLEm.mjs';
|
|
60
|
+
import './sessionOps-C_f1wKOr.mjs';
|
|
61
|
+
import './tools-BmQQUATY.mjs';
|
|
62
|
+
import './tools-BZabNIid.mjs';
|
|
63
|
+
import './client-CXb1VJui.mjs';
|
|
64
|
+
import './peerTools-Dz3_7Bkk.mjs';
|
|
65
|
+
import './ids-DU6sLx4C.mjs';
|
|
66
|
+
import './remoteSessionClient-CO7qOjR0.mjs';
|
|
44
67
|
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
45
68
|
import 'node:http';
|
|
46
69
|
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
47
|
-
import '
|
|
48
|
-
import '
|
|
49
|
-
import '
|
|
50
|
-
import '
|
|
51
|
-
import '
|
|
52
|
-
import '
|
|
70
|
+
import './assistantTools-CgiTbnWb.mjs';
|
|
71
|
+
import './terminals-Dlg0x3nY.mjs';
|
|
72
|
+
import './terminalTitleSuggest-CeKsX_V6.mjs';
|
|
73
|
+
import './tmuxSocket-B8Yx20sT.mjs';
|
|
74
|
+
import './bootstrap-BNQq05jR.mjs';
|
|
75
|
+
import './agentGuidance-CQuNlNx8.mjs';
|
|
76
|
+
import './trimIdent-BAjmv_TG.mjs';
|
|
77
|
+
import './previewPath-CXN4Vag0.mjs';
|
|
78
|
+
import './detectCLI-CSGMlV51.mjs';
|
|
79
|
+
import 'fs';
|
|
80
|
+
import './localHappyAgentAuth-DCsetiyG.mjs';
|
|
53
81
|
import 'url';
|
|
82
|
+
import 'node:module';
|
|
83
|
+
import './oneShotPrompts-DT4p6RNd.mjs';
|
|
54
84
|
|
|
55
85
|
function createAcpBackend(options) {
|
|
56
86
|
const backendOptions = {
|
|
@@ -596,7 +626,7 @@ async function runAcp(opts) {
|
|
|
596
626
|
}
|
|
597
627
|
await api.getOrCreateMachine({
|
|
598
628
|
machineId: settings.machineId,
|
|
599
|
-
metadata:
|
|
629
|
+
metadata: getInitialMachineMetadata()
|
|
600
630
|
});
|
|
601
631
|
const { state, metadata } = createSessionMetadata({
|
|
602
632
|
flavor: resolveSessionFlavor(opts.agentName),
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { p as packageJson } from './package-uOg9SCKi.mjs';
|
|
2
|
+
import module$1 from 'node:module';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { readdir, rm } from 'node:fs/promises';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
function isStandaloneVersionRequest(args) {
|
|
9
|
+
return args.length === 1 && args[0] === "--version";
|
|
10
|
+
}
|
|
11
|
+
const SELF_CHECK_FLAG = "--self-check";
|
|
12
|
+
function isSelfCheckRequest(args) {
|
|
13
|
+
return args.length === 1 && args[0] === SELF_CHECK_FLAG;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function happyHomeDirFromEnv(env, home = homedir()) {
|
|
17
|
+
return env.HAPPY_HOME_DIR ? env.HAPPY_HOME_DIR.replace(/^~/, home) : join(home, ".happy");
|
|
18
|
+
}
|
|
19
|
+
function compileCacheRoot(happyHomeDir) {
|
|
20
|
+
return join(happyHomeDir, "cache", "compile");
|
|
21
|
+
}
|
|
22
|
+
function compileCacheDir(happyHomeDir, cliVersion) {
|
|
23
|
+
return join(compileCacheRoot(happyHomeDir), cliVersion.replace(/[^\w.+-]/g, "_"));
|
|
24
|
+
}
|
|
25
|
+
function enableCompileCacheIfPossible(cliVersion, env = process.env) {
|
|
26
|
+
try {
|
|
27
|
+
const enable = module$1.enableCompileCache;
|
|
28
|
+
if (typeof enable !== "function") return;
|
|
29
|
+
const happyHome = happyHomeDirFromEnv(env);
|
|
30
|
+
if (!existsSync(happyHome)) return;
|
|
31
|
+
enable(compileCacheDir(happyHome, cliVersion));
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function pruneStaleCompileCaches(happyHomeDir, cliVersion) {
|
|
36
|
+
const root = compileCacheRoot(happyHomeDir);
|
|
37
|
+
const keep = compileCacheDir(happyHomeDir, cliVersion);
|
|
38
|
+
const removed = [];
|
|
39
|
+
let entries;
|
|
40
|
+
try {
|
|
41
|
+
entries = await readdir(root);
|
|
42
|
+
} catch {
|
|
43
|
+
return removed;
|
|
44
|
+
}
|
|
45
|
+
for (const name of entries) {
|
|
46
|
+
const dir = join(root, name);
|
|
47
|
+
if (dir === keep) continue;
|
|
48
|
+
try {
|
|
49
|
+
await rm(dir, { recursive: true, force: true });
|
|
50
|
+
removed.push(name);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return removed;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function run(args) {
|
|
58
|
+
enableCompileCacheIfPossible(packageJson.version);
|
|
59
|
+
if (isStandaloneVersionRequest(args) || isSelfCheckRequest(args)) {
|
|
60
|
+
const { selfCheckMain } = await import('./selfCheck-hJ6PCh7v.mjs');
|
|
61
|
+
process.exit(await selfCheckMain({ verbose: isSelfCheckRequest(args) }));
|
|
62
|
+
}
|
|
63
|
+
const { main } = await import('./main-BktM4A1K.mjs');
|
|
64
|
+
await main();
|
|
65
|
+
}
|
|
66
|
+
void run(process.argv.slice(2));
|
|
67
|
+
|
|
68
|
+
export { isStandaloneVersionRequest as i, pruneStaleCompileCaches as p };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var claudeAgentSdk = require('@anthropic-ai/claude-agent-sdk');
|
|
4
|
+
var smallFastModel = require('./smallFastModel-D_uxGMo3.cjs');
|
|
5
|
+
|
|
6
|
+
const HAPPY_DEFAULT_ENTRYPOINT = "remote_mobile";
|
|
7
|
+
function resolveHappyEntrypoint(currentValue) {
|
|
8
|
+
if (currentValue && currentValue.length > 0) {
|
|
9
|
+
return currentValue;
|
|
10
|
+
}
|
|
11
|
+
return HAPPY_DEFAULT_ENTRYPOINT;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function query(params) {
|
|
15
|
+
const opts = params.options;
|
|
16
|
+
let systemPrompt = void 0;
|
|
17
|
+
if (opts?.customSystemPrompt) {
|
|
18
|
+
systemPrompt = opts.customSystemPrompt;
|
|
19
|
+
} else if (opts?.appendSystemPrompt) {
|
|
20
|
+
systemPrompt = {
|
|
21
|
+
type: "preset",
|
|
22
|
+
preset: "claude_code",
|
|
23
|
+
append: opts.appendSystemPrompt
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const sdkOptions = {
|
|
27
|
+
cwd: opts?.cwd,
|
|
28
|
+
additionalDirectories: opts?.additionalDirectories,
|
|
29
|
+
resume: opts?.resume,
|
|
30
|
+
continue: opts?.continue,
|
|
31
|
+
model: opts?.model,
|
|
32
|
+
fallbackModel: opts?.fallbackModel,
|
|
33
|
+
maxTurns: opts?.maxTurns,
|
|
34
|
+
permissionMode: opts?.permissionMode,
|
|
35
|
+
allowDangerouslySkipPermissions: opts?.allowDangerouslySkipPermissions ?? opts?.permissionMode === "bypassPermissions",
|
|
36
|
+
allowedTools: opts?.allowedTools,
|
|
37
|
+
disallowedTools: opts?.disallowedTools,
|
|
38
|
+
mcpServers: opts?.mcpServers,
|
|
39
|
+
systemPrompt,
|
|
40
|
+
settings: opts?.settingsPath,
|
|
41
|
+
// Load filesystem settings the way the real `claude` CLI does. The
|
|
42
|
+
// agent SDK does NOT load these by default (the rename from
|
|
43
|
+
// @anthropic-ai/claude-code flipped the default to "isolated" — the
|
|
44
|
+
// sdk.d.ts comment claiming "omitted = all sources" is stale), so a
|
|
45
|
+
// remote/web session would otherwise ignore ~/.claude/CLAUDE.md, the
|
|
46
|
+
// project .claude/, AND skills (skills are discovered from these dirs).
|
|
47
|
+
// 'user' brings in the global CLAUDE.md (e.g. "reply in Chinese"),
|
|
48
|
+
// 'project'/'local' bring in repo-level CLAUDE.md + settings → parity
|
|
49
|
+
// with a plain CLI invocation. This is the whole point of running our
|
|
50
|
+
// own fork: remote sessions should behave like local ones.
|
|
51
|
+
settingSources: ["user", "project", "local"],
|
|
52
|
+
strictMcpConfig: opts?.strictMcpConfig,
|
|
53
|
+
sessionId: void 0,
|
|
54
|
+
effort: opts?.effort,
|
|
55
|
+
forkSession: opts?.forkSession,
|
|
56
|
+
tools: opts?.tools,
|
|
57
|
+
persistSession: opts?.persistSession,
|
|
58
|
+
includePartialMessages: opts?.includePartialMessages,
|
|
59
|
+
forwardSubagentText: true,
|
|
60
|
+
enableFileCheckpointing: true,
|
|
61
|
+
extraArgs: { "replay-user-messages": null },
|
|
62
|
+
onElicitation: opts?.onElicitation,
|
|
63
|
+
onUserDialog: opts?.onUserDialog,
|
|
64
|
+
supportedDialogKinds: opts?.onUserDialog ? opts.supportedDialogKinds : void 0
|
|
65
|
+
};
|
|
66
|
+
if (opts?.abort) {
|
|
67
|
+
const controller = new AbortController();
|
|
68
|
+
if (opts.abort.aborted) {
|
|
69
|
+
controller.abort(opts.abort.reason);
|
|
70
|
+
} else {
|
|
71
|
+
opts.abort.addEventListener("abort", () => controller.abort(opts.abort?.reason), { once: true });
|
|
72
|
+
}
|
|
73
|
+
sdkOptions.abortController = controller;
|
|
74
|
+
}
|
|
75
|
+
const env = {};
|
|
76
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
77
|
+
if (typeof value === "string") env[key] = value;
|
|
78
|
+
}
|
|
79
|
+
for (const [key, value] of Object.entries(opts?.env ?? {})) {
|
|
80
|
+
if (typeof value === "string") env[key] = value;
|
|
81
|
+
}
|
|
82
|
+
env.CLAUDE_CODE_ENTRYPOINT = resolveHappyEntrypoint(env.CLAUDE_CODE_ENTRYPOINT);
|
|
83
|
+
smallFastModel.pinSmallFastModel(env);
|
|
84
|
+
if (opts?.mcpServers && Object.keys(opts.mcpServers).length > 0) {
|
|
85
|
+
smallFastModel.ensureLocalProxyBypass(env);
|
|
86
|
+
}
|
|
87
|
+
if (sdkOptions.allowDangerouslySkipPermissions && typeof process.getuid === "function" && process.getuid() === 0 && env.IS_SANDBOX === void 0) {
|
|
88
|
+
env.IS_SANDBOX = "1";
|
|
89
|
+
}
|
|
90
|
+
sdkOptions.env = env;
|
|
91
|
+
if (opts?.canCallTool) {
|
|
92
|
+
const callback = opts.canCallTool;
|
|
93
|
+
sdkOptions.canUseTool = async (toolName, input, options) => {
|
|
94
|
+
return callback(toolName, input, options);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return claudeAgentSdk.query({
|
|
98
|
+
prompt: params.prompt,
|
|
99
|
+
options: sdkOptions
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Object.defineProperty(exports, "AbortError", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () { return claudeAgentSdk.AbortError; }
|
|
106
|
+
});
|
|
107
|
+
exports.query = query;
|