@zhigang1992/happy-cli 0.12.1 → 0.12.4
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/{index-DsHtmQqP.mjs → index-BERBU6rR.mjs} +201 -23
- package/dist/{index-BOBrKhX5.cjs → index-CHEjP0zg.cjs} +215 -37
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +6 -6
- package/dist/lib.cjs +1 -2
- package/dist/lib.d.cts +118 -4
- package/dist/lib.d.mts +118 -4
- package/dist/lib.mjs +1 -2
- package/dist/{list-hET5tyMc.mjs → list-BvtUKVTq.mjs} +1 -1
- package/dist/{list-BW6QBLa1.cjs → list-DOsBjFRJ.cjs} +1 -1
- package/dist/{prompt-Dz7G8yGx.mjs → prompt-BbMNN7fl.mjs} +1 -2
- package/dist/{prompt-DXkgjktW.cjs → prompt-Dh_trad0.cjs} +1 -2
- package/dist/{runCodex-CLGYMNs2.mjs → runCodex-CYkmZphO.mjs} +20 -4
- package/dist/{runCodex-CylcX5Ug.cjs → runCodex-DUqqO-m8.cjs} +20 -4
- package/dist/{types-CGco5Y-r.mjs → types-Cw6y7GyQ.mjs} +156 -20
- package/dist/{types-BsjUgWOx.cjs → types-Q-euvEmG.cjs} +154 -18
- package/package.json +2 -4
- package/scripts/download-tool.cjs +187 -0
- package/scripts/ripgrep_launcher.cjs +53 -2
- package/scripts/tools-config.cjs +119 -0
- package/tools/archives/difftastic-LICENSE +0 -21
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-LICENSE +0 -3
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +0 -21
- package/tools/licenses/ripgrep-LICENSE +0 -3
- package/tools/unpacked/difft +0 -0
- package/tools/unpacked/rg +0 -0
- package/tools/unpacked/ripgrep.node +0 -0
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var os = require('node:os');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var types = require('./types-
|
|
6
|
+
var types = require('./types-Q-euvEmG.cjs');
|
|
7
7
|
var node_child_process = require('node:child_process');
|
|
8
8
|
var node_path = require('node:path');
|
|
9
9
|
var node_readline = require('node:readline');
|
|
10
10
|
var fs = require('node:fs');
|
|
11
|
+
var child_process = require('child_process');
|
|
12
|
+
var util = require('util');
|
|
13
|
+
var fs$1 = require('fs');
|
|
14
|
+
var path = require('path');
|
|
11
15
|
var promises = require('node:fs/promises');
|
|
12
|
-
var fs$
|
|
16
|
+
var fs$2 = require('fs/promises');
|
|
13
17
|
var ink = require('ink');
|
|
14
18
|
var React = require('react');
|
|
15
19
|
var node_url = require('node:url');
|
|
@@ -19,9 +23,6 @@ require('socket.io-client');
|
|
|
19
23
|
var tweetnacl = require('tweetnacl');
|
|
20
24
|
require('expo-server-sdk');
|
|
21
25
|
var crypto = require('crypto');
|
|
22
|
-
var child_process = require('child_process');
|
|
23
|
-
var fs$2 = require('fs');
|
|
24
|
-
var path = require('path');
|
|
25
26
|
var psList = require('ps-list');
|
|
26
27
|
var spawn = require('cross-spawn');
|
|
27
28
|
var os$1 = require('os');
|
|
@@ -36,7 +37,6 @@ var node_http = require('node:http');
|
|
|
36
37
|
var streamableHttp_js = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
37
38
|
var hex = require('@stablelib/hex');
|
|
38
39
|
var http = require('http');
|
|
39
|
-
var util = require('util');
|
|
40
40
|
|
|
41
41
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
42
42
|
function _interopNamespaceDefault(e) {
|
|
@@ -241,6 +241,99 @@ const systemPrompt = (() => {
|
|
|
241
241
|
}
|
|
242
242
|
})();
|
|
243
243
|
|
|
244
|
+
const execAsync$1 = util.promisify(child_process.exec);
|
|
245
|
+
let direnvAvailable = null;
|
|
246
|
+
async function isDirenvAvailable() {
|
|
247
|
+
if (direnvAvailable !== null) {
|
|
248
|
+
return direnvAvailable;
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
await execAsync$1("direnv version", { timeout: 5e3 });
|
|
252
|
+
direnvAvailable = true;
|
|
253
|
+
types.logger.debug("[direnv] direnv is available");
|
|
254
|
+
} catch {
|
|
255
|
+
direnvAvailable = false;
|
|
256
|
+
types.logger.debug("[direnv] direnv is not available");
|
|
257
|
+
}
|
|
258
|
+
return direnvAvailable;
|
|
259
|
+
}
|
|
260
|
+
function findEnvrcDirectory(startDir) {
|
|
261
|
+
let dir = startDir;
|
|
262
|
+
const root = "/";
|
|
263
|
+
while (dir !== root) {
|
|
264
|
+
const envrcPath = path.join(dir, ".envrc");
|
|
265
|
+
if (fs$1.existsSync(envrcPath)) {
|
|
266
|
+
types.logger.debug(`[direnv] Found .envrc at: ${envrcPath}`);
|
|
267
|
+
return dir;
|
|
268
|
+
}
|
|
269
|
+
const parent = path.dirname(dir);
|
|
270
|
+
if (parent === dir) {
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
dir = parent;
|
|
274
|
+
}
|
|
275
|
+
types.logger.debug(`[direnv] No .envrc found in directory tree for: ${startDir}`);
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
async function loadDirenvEnvironment(cwd) {
|
|
279
|
+
if (!await isDirenvAvailable()) {
|
|
280
|
+
return {};
|
|
281
|
+
}
|
|
282
|
+
const envrcDir = findEnvrcDirectory(cwd);
|
|
283
|
+
if (!envrcDir) {
|
|
284
|
+
return {};
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
types.logger.debug(`[direnv] Loading environment for: ${cwd}`);
|
|
288
|
+
const { stdout, stderr } = await execAsync$1("direnv export json", {
|
|
289
|
+
cwd,
|
|
290
|
+
timeout: 1e4,
|
|
291
|
+
// 10 second timeout
|
|
292
|
+
env: {
|
|
293
|
+
...process.env,
|
|
294
|
+
// Ensure direnv doesn't prompt for allowance interactively
|
|
295
|
+
DIRENV_LOG_FORMAT: ""
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
if (stderr) {
|
|
299
|
+
types.logger.debug(`[direnv] stderr: ${stderr}`);
|
|
300
|
+
}
|
|
301
|
+
const trimmed = stdout.trim();
|
|
302
|
+
if (!trimmed) {
|
|
303
|
+
types.logger.debug("[direnv] No environment changes from direnv");
|
|
304
|
+
return {};
|
|
305
|
+
}
|
|
306
|
+
const direnvVars = JSON.parse(trimmed);
|
|
307
|
+
const varCount = Object.keys(direnvVars).length;
|
|
308
|
+
types.logger.debug(`[direnv] Loaded ${varCount} environment variables`);
|
|
309
|
+
return direnvVars;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (error instanceof Error) {
|
|
312
|
+
types.logger.debug(`[direnv] Failed to load environment: ${error.message}`);
|
|
313
|
+
if (error.message.includes("is blocked")) {
|
|
314
|
+
types.logger.debug('[direnv] Hint: Run "direnv allow" in the project directory to allow the .envrc');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return {};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async function loadAndMergeEnvironment(cwd, existingEnv = process.env, overrideEnv = {}) {
|
|
321
|
+
const direnvVars = await loadDirenvEnvironment(cwd);
|
|
322
|
+
const merged = {};
|
|
323
|
+
for (const [key, value] of Object.entries(existingEnv)) {
|
|
324
|
+
if (value !== void 0) {
|
|
325
|
+
merged[key] = value;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
for (const [key, value] of Object.entries(direnvVars)) {
|
|
329
|
+
merged[key] = value;
|
|
330
|
+
}
|
|
331
|
+
for (const [key, value] of Object.entries(overrideEnv)) {
|
|
332
|
+
merged[key] = value;
|
|
333
|
+
}
|
|
334
|
+
return merged;
|
|
335
|
+
}
|
|
336
|
+
|
|
244
337
|
const claudeCliPath = node_path.resolve(node_path.join(types.projectPath(), "scripts", "claude_local_launcher.cjs"));
|
|
245
338
|
async function claudeLocal(opts) {
|
|
246
339
|
const projectDir = getProjectPath(opts.path);
|
|
@@ -282,6 +375,15 @@ async function claudeLocal(opts) {
|
|
|
282
375
|
}
|
|
283
376
|
};
|
|
284
377
|
try {
|
|
378
|
+
const direnvVars = await loadDirenvEnvironment(opts.path);
|
|
379
|
+
if (Object.keys(direnvVars).length > 0) {
|
|
380
|
+
types.logger.debug(`[ClaudeLocal] Loaded ${Object.keys(direnvVars).length} direnv environment variables`);
|
|
381
|
+
}
|
|
382
|
+
const env = {
|
|
383
|
+
...process.env,
|
|
384
|
+
...direnvVars,
|
|
385
|
+
...opts.claudeEnvVars
|
|
386
|
+
};
|
|
285
387
|
process.stdin.pause();
|
|
286
388
|
await new Promise((r, reject) => {
|
|
287
389
|
const args = [];
|
|
@@ -301,10 +403,6 @@ async function claudeLocal(opts) {
|
|
|
301
403
|
if (!claudeCliPath || !fs.existsSync(claudeCliPath)) {
|
|
302
404
|
throw new Error("Claude local launcher not found. Please ensure HAPPY_PROJECT_ROOT is set correctly for development.");
|
|
303
405
|
}
|
|
304
|
-
const env = {
|
|
305
|
-
...process.env,
|
|
306
|
-
...opts.claudeEnvVars
|
|
307
|
-
};
|
|
308
406
|
const child = node_child_process.spawn("node", [claudeCliPath, ...args], {
|
|
309
407
|
stdio: ["inherit", "inherit", "inherit", "pipe"],
|
|
310
408
|
signal: opts.abort,
|
|
@@ -485,7 +583,7 @@ function startFileWatcher(file, onFileChange) {
|
|
|
485
583
|
while (true) {
|
|
486
584
|
try {
|
|
487
585
|
types.logger.debug(`[FILE_WATCHER] Starting watcher for ${file}`);
|
|
488
|
-
const watcher = fs$
|
|
586
|
+
const watcher = fs$2.watch(file, { persistent: true, signal: abortController.signal });
|
|
489
587
|
for await (const event of watcher) {
|
|
490
588
|
if (abortController.signal.aborted) {
|
|
491
589
|
return;
|
|
@@ -984,7 +1082,7 @@ class AbortError extends Error {
|
|
|
984
1082
|
}
|
|
985
1083
|
}
|
|
986
1084
|
|
|
987
|
-
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
1085
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-CHEjP0zg.cjs', document.baseURI).href)));
|
|
988
1086
|
const __dirname$1 = node_path.join(__filename$1, "..");
|
|
989
1087
|
function getDefaultClaudeCodePath() {
|
|
990
1088
|
return node_path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
|
|
@@ -1511,7 +1609,7 @@ async function awaitFileExist(file, timeout = 1e4) {
|
|
|
1511
1609
|
const startTime = Date.now();
|
|
1512
1610
|
while (Date.now() - startTime < timeout) {
|
|
1513
1611
|
try {
|
|
1514
|
-
await fs$
|
|
1612
|
+
await fs$2.access(file);
|
|
1515
1613
|
return true;
|
|
1516
1614
|
} catch (e) {
|
|
1517
1615
|
await types.delay(1e3);
|
|
@@ -1545,6 +1643,13 @@ async function claudeRemote(opts) {
|
|
|
1545
1643
|
}
|
|
1546
1644
|
}
|
|
1547
1645
|
}
|
|
1646
|
+
const direnvVars = await loadDirenvEnvironment(opts.path);
|
|
1647
|
+
if (Object.keys(direnvVars).length > 0) {
|
|
1648
|
+
types.logger.debug(`[claudeRemote] Loaded ${Object.keys(direnvVars).length} direnv environment variables`);
|
|
1649
|
+
}
|
|
1650
|
+
Object.entries(direnvVars).forEach(([key, value]) => {
|
|
1651
|
+
process.env[key] = value;
|
|
1652
|
+
});
|
|
1548
1653
|
if (opts.claudeEnvVars) {
|
|
1549
1654
|
Object.entries(opts.claudeEnvVars).forEach(([key, value]) => {
|
|
1550
1655
|
process.env[key] = value;
|
|
@@ -1651,12 +1756,32 @@ Echo message: ${echoMessage}` : "");
|
|
|
1651
1756
|
}
|
|
1652
1757
|
}
|
|
1653
1758
|
};
|
|
1759
|
+
async function buildMessageContent(text, imageRefs) {
|
|
1760
|
+
if (!imageRefs || imageRefs.length === 0 || !opts.resolveImageRefs) {
|
|
1761
|
+
return text;
|
|
1762
|
+
}
|
|
1763
|
+
types.logger.debug(`[claudeRemote] Resolving ${imageRefs.length} image references`);
|
|
1764
|
+
const resolvedImages = await opts.resolveImageRefs(imageRefs);
|
|
1765
|
+
types.logger.debug(`[claudeRemote] Resolved ${resolvedImages.length} images`);
|
|
1766
|
+
if (resolvedImages.length === 0) {
|
|
1767
|
+
return text;
|
|
1768
|
+
}
|
|
1769
|
+
const content = [];
|
|
1770
|
+
for (const img of resolvedImages) {
|
|
1771
|
+
content.push(img);
|
|
1772
|
+
}
|
|
1773
|
+
if (text) {
|
|
1774
|
+
content.push({ type: "text", text });
|
|
1775
|
+
}
|
|
1776
|
+
return content;
|
|
1777
|
+
}
|
|
1654
1778
|
let messages = new PushableAsyncIterable();
|
|
1779
|
+
const initialContent = await buildMessageContent(initial.message, initial.mode.imageRefs);
|
|
1655
1780
|
messages.push({
|
|
1656
1781
|
type: "user",
|
|
1657
1782
|
message: {
|
|
1658
1783
|
role: "user",
|
|
1659
|
-
content:
|
|
1784
|
+
content: initialContent
|
|
1660
1785
|
}
|
|
1661
1786
|
});
|
|
1662
1787
|
const response = query({
|
|
@@ -1697,7 +1822,8 @@ Echo message: ${echoMessage}` : "");
|
|
|
1697
1822
|
return;
|
|
1698
1823
|
}
|
|
1699
1824
|
mode = next.mode;
|
|
1700
|
-
|
|
1825
|
+
const nextContent = await buildMessageContent(next.message, next.mode.imageRefs);
|
|
1826
|
+
messages.push({ type: "user", message: { role: "user", content: nextContent } });
|
|
1701
1827
|
}
|
|
1702
1828
|
if (message.type === "user") {
|
|
1703
1829
|
const msg = message;
|
|
@@ -2803,6 +2929,18 @@ async function claudeRemoteLauncher(session) {
|
|
|
2803
2929
|
isAborted: (toolCallId) => {
|
|
2804
2930
|
return permissionHandler.isAborted(toolCallId);
|
|
2805
2931
|
},
|
|
2932
|
+
resolveImageRefs: async (imageRefs) => {
|
|
2933
|
+
const resolved = [];
|
|
2934
|
+
for (const imageRef of imageRefs) {
|
|
2935
|
+
const image = await session.client.resolveImageRef(imageRef);
|
|
2936
|
+
if (image) {
|
|
2937
|
+
resolved.push(image);
|
|
2938
|
+
} else {
|
|
2939
|
+
types.logger.debug(`[remote]: Failed to resolve image ref: ${imageRef.blobId}`);
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
return resolved;
|
|
2943
|
+
},
|
|
2806
2944
|
nextMessage: async () => {
|
|
2807
2945
|
if (pending) {
|
|
2808
2946
|
let p = pending;
|
|
@@ -2846,9 +2984,10 @@ async function claudeRemoteLauncher(session) {
|
|
|
2846
2984
|
onReady: () => {
|
|
2847
2985
|
if (!pending && session.queue.size() === 0) {
|
|
2848
2986
|
session.client.sendSessionEvent({ type: "ready" });
|
|
2987
|
+
const folderName = path.basename(session.path);
|
|
2849
2988
|
session.api.push().sendToAllDevices(
|
|
2850
|
-
|
|
2851
|
-
|
|
2989
|
+
`Ready`,
|
|
2990
|
+
folderName,
|
|
2852
2991
|
{ sessionId: session.client.sessionId }
|
|
2853
2992
|
);
|
|
2854
2993
|
}
|
|
@@ -2907,6 +3046,16 @@ async function claudeRemoteLauncher(session) {
|
|
|
2907
3046
|
|
|
2908
3047
|
async function loop(opts) {
|
|
2909
3048
|
const logPath = types.logger.logFilePath;
|
|
3049
|
+
const sessionEnv = await loadAndMergeEnvironment(
|
|
3050
|
+
opts.path,
|
|
3051
|
+
process.env,
|
|
3052
|
+
opts.claudeEnvVars ?? {}
|
|
3053
|
+
);
|
|
3054
|
+
types.logger.debug(`[loop] Loaded session environment with ${Object.keys(sessionEnv).length} variables`);
|
|
3055
|
+
opts.session.rpcHandlerManager.setSessionContext({
|
|
3056
|
+
path: opts.path,
|
|
3057
|
+
env: sessionEnv
|
|
3058
|
+
});
|
|
2910
3059
|
let session = new Session({
|
|
2911
3060
|
api: opts.api,
|
|
2912
3061
|
client: opts.session,
|
|
@@ -3503,7 +3652,7 @@ async function isDaemonRunningCurrentlyInstalledHappyVersion() {
|
|
|
3503
3652
|
}
|
|
3504
3653
|
try {
|
|
3505
3654
|
const packageJsonPath = path.join(types.projectPath(), "package.json");
|
|
3506
|
-
const packageJson = JSON.parse(fs$
|
|
3655
|
+
const packageJson = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
|
|
3507
3656
|
const currentCliVersion = packageJson.version;
|
|
3508
3657
|
types.logger.debug(`[DAEMON CONTROL] Current CLI version: ${currentCliVersion}, Daemon started with version: ${state.startedWithCliVersion}`);
|
|
3509
3658
|
return currentCliVersion === state.startedWithCliVersion;
|
|
@@ -4450,7 +4599,7 @@ async function startDaemon() {
|
|
|
4450
4599
|
const { directory, sessionId, machineId: machineId2, approvedNewDirectoryCreation = true } = options;
|
|
4451
4600
|
let directoryCreated = false;
|
|
4452
4601
|
try {
|
|
4453
|
-
await fs$
|
|
4602
|
+
await fs$2.access(directory);
|
|
4454
4603
|
types.logger.debug(`[DAEMON RUN] Directory exists: ${directory}`);
|
|
4455
4604
|
} catch (error) {
|
|
4456
4605
|
types.logger.debug(`[DAEMON RUN] Directory doesn't exist, creating: ${directory}`);
|
|
@@ -4462,7 +4611,7 @@ async function startDaemon() {
|
|
|
4462
4611
|
};
|
|
4463
4612
|
}
|
|
4464
4613
|
try {
|
|
4465
|
-
await fs$
|
|
4614
|
+
await fs$2.mkdir(directory, { recursive: true });
|
|
4466
4615
|
types.logger.debug(`[DAEMON RUN] Successfully created directory: ${directory}`);
|
|
4467
4616
|
directoryCreated = true;
|
|
4468
4617
|
} catch (mkdirError) {
|
|
@@ -4490,7 +4639,7 @@ async function startDaemon() {
|
|
|
4490
4639
|
if (options.token) {
|
|
4491
4640
|
if (options.agent === "codex") {
|
|
4492
4641
|
const codexHomeDir = tmp__namespace.dirSync();
|
|
4493
|
-
fs$
|
|
4642
|
+
fs$2.writeFile(path.join(codexHomeDir.name, "auth.json"), options.token);
|
|
4494
4643
|
extraEnv = {
|
|
4495
4644
|
CODEX_HOME: codexHomeDir.name
|
|
4496
4645
|
};
|
|
@@ -4667,7 +4816,7 @@ async function startDaemon() {
|
|
|
4667
4816
|
pidToTrackedSession.delete(pid);
|
|
4668
4817
|
}
|
|
4669
4818
|
}
|
|
4670
|
-
const projectVersion = JSON.parse(fs$
|
|
4819
|
+
const projectVersion = JSON.parse(fs$1.readFileSync(path.join(types.projectPath(), "package.json"), "utf-8")).version;
|
|
4671
4820
|
if (projectVersion !== types.configuration.currentCliVersion) {
|
|
4672
4821
|
types.logger.debug("[DAEMON RUN] Daemon is outdated, triggering self-restart with latest version, clearing heartbeat interval");
|
|
4673
4822
|
clearInterval(restartOnStaleVersionAndHeartbeat);
|
|
@@ -4830,6 +4979,27 @@ function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
|
|
|
4830
4979
|
});
|
|
4831
4980
|
}
|
|
4832
4981
|
|
|
4982
|
+
function extractTextFromContent(content) {
|
|
4983
|
+
if (!Array.isArray(content)) {
|
|
4984
|
+
if (content.type === "text") {
|
|
4985
|
+
return content.text;
|
|
4986
|
+
}
|
|
4987
|
+
return "";
|
|
4988
|
+
}
|
|
4989
|
+
const textParts = [];
|
|
4990
|
+
for (const block of content) {
|
|
4991
|
+
if (block.type === "text") {
|
|
4992
|
+
textParts.push(block.text);
|
|
4993
|
+
}
|
|
4994
|
+
}
|
|
4995
|
+
return textParts.join("\n");
|
|
4996
|
+
}
|
|
4997
|
+
function extractImageRefs(content) {
|
|
4998
|
+
if (!Array.isArray(content)) {
|
|
4999
|
+
return [];
|
|
5000
|
+
}
|
|
5001
|
+
return content.filter((block) => block.type === "image_ref");
|
|
5002
|
+
}
|
|
4833
5003
|
async function runClaude(credentials, options = {}) {
|
|
4834
5004
|
const workingDirectory = process.cwd();
|
|
4835
5005
|
const sessionTag = node_crypto.randomUUID();
|
|
@@ -4996,7 +5166,12 @@ async function runClaude(credentials, options = {}) {
|
|
|
4996
5166
|
} else {
|
|
4997
5167
|
types.logger.debug(`[loop] User message received with no disallowed tools override, using current: ${currentDisallowedTools ? currentDisallowedTools.join(", ") : "none"}`);
|
|
4998
5168
|
}
|
|
4999
|
-
const
|
|
5169
|
+
const textContent = extractTextFromContent(message.content);
|
|
5170
|
+
const imageRefs = extractImageRefs(message.content);
|
|
5171
|
+
if (imageRefs.length > 0) {
|
|
5172
|
+
types.logger.debug(`[loop] User message contains ${imageRefs.length} image(s)`);
|
|
5173
|
+
}
|
|
5174
|
+
const specialCommand = parseSpecialCommand(textContent);
|
|
5000
5175
|
if (specialCommand.type === "compact") {
|
|
5001
5176
|
types.logger.debug("[start] Detected /compact command");
|
|
5002
5177
|
const enhancedMode2 = {
|
|
@@ -5006,9 +5181,10 @@ async function runClaude(credentials, options = {}) {
|
|
|
5006
5181
|
customSystemPrompt: messageCustomSystemPrompt,
|
|
5007
5182
|
appendSystemPrompt: messageAppendSystemPrompt,
|
|
5008
5183
|
allowedTools: messageAllowedTools,
|
|
5009
|
-
disallowedTools: messageDisallowedTools
|
|
5184
|
+
disallowedTools: messageDisallowedTools,
|
|
5185
|
+
imageRefs: imageRefs.length > 0 ? imageRefs : void 0
|
|
5010
5186
|
};
|
|
5011
|
-
messageQueue.pushIsolateAndClear(specialCommand.originalMessage ||
|
|
5187
|
+
messageQueue.pushIsolateAndClear(specialCommand.originalMessage || textContent, enhancedMode2);
|
|
5012
5188
|
types.logger.debugLargeJson("[start] /compact command pushed to queue:", message);
|
|
5013
5189
|
return;
|
|
5014
5190
|
}
|
|
@@ -5021,9 +5197,10 @@ async function runClaude(credentials, options = {}) {
|
|
|
5021
5197
|
customSystemPrompt: messageCustomSystemPrompt,
|
|
5022
5198
|
appendSystemPrompt: messageAppendSystemPrompt,
|
|
5023
5199
|
allowedTools: messageAllowedTools,
|
|
5024
|
-
disallowedTools: messageDisallowedTools
|
|
5200
|
+
disallowedTools: messageDisallowedTools,
|
|
5201
|
+
imageRefs: imageRefs.length > 0 ? imageRefs : void 0
|
|
5025
5202
|
};
|
|
5026
|
-
messageQueue.pushIsolateAndClear(specialCommand.originalMessage ||
|
|
5203
|
+
messageQueue.pushIsolateAndClear(specialCommand.originalMessage || textContent, enhancedMode2);
|
|
5027
5204
|
types.logger.debugLargeJson("[start] /compact command pushed to queue:", message);
|
|
5028
5205
|
return;
|
|
5029
5206
|
}
|
|
@@ -5034,9 +5211,10 @@ async function runClaude(credentials, options = {}) {
|
|
|
5034
5211
|
customSystemPrompt: messageCustomSystemPrompt,
|
|
5035
5212
|
appendSystemPrompt: messageAppendSystemPrompt,
|
|
5036
5213
|
allowedTools: messageAllowedTools,
|
|
5037
|
-
disallowedTools: messageDisallowedTools
|
|
5214
|
+
disallowedTools: messageDisallowedTools,
|
|
5215
|
+
imageRefs: imageRefs.length > 0 ? imageRefs : void 0
|
|
5038
5216
|
};
|
|
5039
|
-
messageQueue.push(
|
|
5217
|
+
messageQueue.push(textContent, enhancedMode);
|
|
5040
5218
|
types.logger.debugLargeJson("User message pushed to queue:", message);
|
|
5041
5219
|
});
|
|
5042
5220
|
const cleanup = async () => {
|
|
@@ -5117,7 +5295,7 @@ const PLIST_LABEL$1 = "com.happy-cli.daemon";
|
|
|
5117
5295
|
const PLIST_FILE$1 = `/Library/LaunchDaemons/${PLIST_LABEL$1}.plist`;
|
|
5118
5296
|
async function install$1() {
|
|
5119
5297
|
try {
|
|
5120
|
-
if (fs$
|
|
5298
|
+
if (fs$1.existsSync(PLIST_FILE$1)) {
|
|
5121
5299
|
types.logger.info("Daemon plist already exists. Uninstalling first...");
|
|
5122
5300
|
child_process.execSync(`launchctl unload ${PLIST_FILE$1}`, { stdio: "inherit" });
|
|
5123
5301
|
}
|
|
@@ -5161,8 +5339,8 @@ async function install$1() {
|
|
|
5161
5339
|
</dict>
|
|
5162
5340
|
</plist>
|
|
5163
5341
|
`);
|
|
5164
|
-
fs$
|
|
5165
|
-
fs$
|
|
5342
|
+
fs$1.writeFileSync(PLIST_FILE$1, plistContent);
|
|
5343
|
+
fs$1.chmodSync(PLIST_FILE$1, 420);
|
|
5166
5344
|
types.logger.info(`Created daemon plist at ${PLIST_FILE$1}`);
|
|
5167
5345
|
child_process.execSync(`launchctl load ${PLIST_FILE$1}`, { stdio: "inherit" });
|
|
5168
5346
|
types.logger.info("Daemon installed and started successfully");
|
|
@@ -5188,7 +5366,7 @@ const PLIST_LABEL = "com.happy-cli.daemon";
|
|
|
5188
5366
|
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
5189
5367
|
async function uninstall$1() {
|
|
5190
5368
|
try {
|
|
5191
|
-
if (!fs$
|
|
5369
|
+
if (!fs$1.existsSync(PLIST_FILE)) {
|
|
5192
5370
|
types.logger.info("Daemon plist not found. Nothing to uninstall.");
|
|
5193
5371
|
return;
|
|
5194
5372
|
}
|
|
@@ -5198,7 +5376,7 @@ async function uninstall$1() {
|
|
|
5198
5376
|
} catch (error) {
|
|
5199
5377
|
types.logger.info("Failed to unload daemon (it might not be running)");
|
|
5200
5378
|
}
|
|
5201
|
-
fs$
|
|
5379
|
+
fs$1.unlinkSync(PLIST_FILE);
|
|
5202
5380
|
types.logger.info(`Removed daemon plist from ${PLIST_FILE}`);
|
|
5203
5381
|
types.logger.info("Daemon uninstalled successfully");
|
|
5204
5382
|
} catch (error) {
|
|
@@ -6215,7 +6393,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
6215
6393
|
return;
|
|
6216
6394
|
} else if (subcommand === "codex") {
|
|
6217
6395
|
try {
|
|
6218
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
6396
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-DUqqO-m8.cjs'); });
|
|
6219
6397
|
let startedBy = void 0;
|
|
6220
6398
|
for (let i = 1; i < args.length; i++) {
|
|
6221
6399
|
if (args[i] === "--started-by") {
|
|
@@ -6260,7 +6438,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
6260
6438
|
} else if (subcommand === "list") {
|
|
6261
6439
|
try {
|
|
6262
6440
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
6263
|
-
const { listSessions } = await Promise.resolve().then(function () { return require('./list-
|
|
6441
|
+
const { listSessions } = await Promise.resolve().then(function () { return require('./list-DOsBjFRJ.cjs'); });
|
|
6264
6442
|
let sessionId;
|
|
6265
6443
|
let titleFilter;
|
|
6266
6444
|
let recentMsgs;
|
|
@@ -6362,7 +6540,7 @@ Examples:
|
|
|
6362
6540
|
process.exit(1);
|
|
6363
6541
|
}
|
|
6364
6542
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
6365
|
-
const { promptSession } = await Promise.resolve().then(function () { return require('./prompt-
|
|
6543
|
+
const { promptSession } = await Promise.resolve().then(function () { return require('./prompt-Dh_trad0.cjs'); });
|
|
6366
6544
|
await promptSession(credentials, sessionId, promptText, timeoutMinutes ?? void 0);
|
|
6367
6545
|
} catch (error) {
|
|
6368
6546
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('chalk');
|
|
4
|
-
require('./index-
|
|
5
|
-
require('./types-
|
|
4
|
+
require('./index-CHEjP0zg.cjs');
|
|
5
|
+
require('./types-Q-euvEmG.cjs');
|
|
6
6
|
require('zod');
|
|
7
7
|
require('node:child_process');
|
|
8
8
|
require('node:os');
|
|
@@ -10,6 +10,10 @@ require('node:crypto');
|
|
|
10
10
|
require('node:path');
|
|
11
11
|
require('node:readline');
|
|
12
12
|
require('node:fs');
|
|
13
|
+
require('child_process');
|
|
14
|
+
require('util');
|
|
15
|
+
require('fs');
|
|
16
|
+
require('path');
|
|
13
17
|
require('node:fs/promises');
|
|
14
18
|
require('fs/promises');
|
|
15
19
|
require('ink');
|
|
@@ -21,9 +25,6 @@ require('socket.io-client');
|
|
|
21
25
|
require('tweetnacl');
|
|
22
26
|
require('expo-server-sdk');
|
|
23
27
|
require('crypto');
|
|
24
|
-
require('child_process');
|
|
25
|
-
require('fs');
|
|
26
|
-
require('path');
|
|
27
28
|
require('ps-list');
|
|
28
29
|
require('cross-spawn');
|
|
29
30
|
require('os');
|
|
@@ -37,6 +38,5 @@ require('node:http');
|
|
|
37
38
|
require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
38
39
|
require('@stablelib/hex');
|
|
39
40
|
require('http');
|
|
40
|
-
require('util');
|
|
41
41
|
require('url');
|
|
42
42
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'chalk';
|
|
2
|
-
import './index-
|
|
3
|
-
import './types-
|
|
2
|
+
import './index-BERBU6rR.mjs';
|
|
3
|
+
import './types-Cw6y7GyQ.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'node:child_process';
|
|
6
6
|
import 'node:os';
|
|
@@ -8,6 +8,10 @@ import 'node:crypto';
|
|
|
8
8
|
import 'node:path';
|
|
9
9
|
import 'node:readline';
|
|
10
10
|
import 'node:fs';
|
|
11
|
+
import 'child_process';
|
|
12
|
+
import 'util';
|
|
13
|
+
import 'fs';
|
|
14
|
+
import 'path';
|
|
11
15
|
import 'node:fs/promises';
|
|
12
16
|
import 'fs/promises';
|
|
13
17
|
import 'ink';
|
|
@@ -19,9 +23,6 @@ import 'socket.io-client';
|
|
|
19
23
|
import 'tweetnacl';
|
|
20
24
|
import 'expo-server-sdk';
|
|
21
25
|
import 'crypto';
|
|
22
|
-
import 'child_process';
|
|
23
|
-
import 'fs';
|
|
24
|
-
import 'path';
|
|
25
26
|
import 'ps-list';
|
|
26
27
|
import 'cross-spawn';
|
|
27
28
|
import 'os';
|
|
@@ -35,5 +36,4 @@ import 'node:http';
|
|
|
35
36
|
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
36
37
|
import '@stablelib/hex';
|
|
37
38
|
import 'http';
|
|
38
|
-
import 'util';
|
|
39
39
|
import 'url';
|
package/dist/lib.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var types = require('./types-
|
|
3
|
+
var types = require('./types-Q-euvEmG.cjs');
|
|
4
4
|
require('axios');
|
|
5
5
|
require('chalk');
|
|
6
6
|
require('fs');
|
|
@@ -19,7 +19,6 @@ require('fs/promises');
|
|
|
19
19
|
require('crypto');
|
|
20
20
|
require('path');
|
|
21
21
|
require('url');
|
|
22
|
-
require('os');
|
|
23
22
|
require('expo-server-sdk');
|
|
24
23
|
|
|
25
24
|
|