happy-coder 0.1.10 → 0.1.11
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/README.md +2 -0
- package/dist/index-B2GqfEZV.cjs +1564 -0
- package/dist/index-QItBXhux.mjs +1540 -0
- package/dist/index.cjs +420 -258
- package/dist/index.mjs +410 -248
- package/dist/install-B0DnBGS_.mjs +29 -0
- package/dist/install-B2r_gX72.cjs +109 -0
- package/dist/install-C809w0Cj.cjs +31 -0
- package/dist/install-DEPy62QN.mjs +97 -0
- package/dist/install-GZIzyuIE.cjs +99 -0
- package/dist/install-HKe7dyS4.mjs +107 -0
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +8 -3
- package/dist/lib.d.mts +8 -3
- package/dist/lib.mjs +1 -1
- package/dist/run-BmEaINbl.cjs +250 -0
- package/dist/run-DMbKhYfb.mjs +247 -0
- package/dist/run-FBXkmmN7.mjs +32 -0
- package/dist/run-q2To6b-c.cjs +34 -0
- package/dist/types-BRICSarm.mjs +870 -0
- package/dist/types-BTQRfIr3.cjs +892 -0
- package/dist/types-CEvzGLMI.cjs +882 -0
- package/dist/{types-DnQGY77F.mjs → types-D39L8JSd.mjs} +55 -23
- package/dist/types-DYBiuNUQ.cjs +883 -0
- package/dist/types-Df5dlWLV.mjs +871 -0
- package/dist/types-fXgEaaqP.mjs +861 -0
- package/dist/{types-B2JzqUiU.cjs → types-hotUTaWz.cjs} +53 -21
- package/dist/types-mykDX2xe.cjs +872 -0
- package/dist/types-tLWMaptR.mjs +879 -0
- package/dist/uninstall-BGgl5V8F.mjs +29 -0
- package/dist/uninstall-BWHglipH.mjs +40 -0
- package/dist/uninstall-C42CoSCI.cjs +53 -0
- package/dist/uninstall-CLkTtlMv.mjs +51 -0
- package/dist/uninstall-CdHMb6wi.cjs +31 -0
- package/dist/uninstall-FXyyAuGU.cjs +42 -0
- package/package.json +8 -2
- package/ripgrep/COPYING +3 -0
- package/ripgrep/arm64-darwin/rg +0 -0
- package/ripgrep/arm64-darwin/ripgrep.node +0 -0
- package/ripgrep/arm64-linux/rg +0 -0
- package/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-darwin/rg +0 -0
- package/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/ripgrep/x64-linux/rg +0 -0
- package/ripgrep/x64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-win32/rg.exe +0 -0
- package/ripgrep/x64-win32/ripgrep.node +0 -0
- package/scripts/ripgrep_launcher.cjs +57 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { l as logger } from './types-BRICSarm.mjs';
|
|
2
|
+
import { install as install$1 } from './install-DEPy62QN.mjs';
|
|
3
|
+
import 'axios';
|
|
4
|
+
import 'chalk';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'node:os';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:events';
|
|
11
|
+
import 'socket.io-client';
|
|
12
|
+
import 'zod';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'tweetnacl';
|
|
15
|
+
import 'expo-server-sdk';
|
|
16
|
+
import 'child_process';
|
|
17
|
+
|
|
18
|
+
async function install() {
|
|
19
|
+
if (process.platform !== "darwin") {
|
|
20
|
+
throw new Error("Daemon installation is currently only supported on macOS");
|
|
21
|
+
}
|
|
22
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
23
|
+
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
24
|
+
}
|
|
25
|
+
logger.info("Installing Happy CLI daemon for macOS...");
|
|
26
|
+
await install$1();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { install };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var types = require('./types-mykDX2xe.cjs');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var child_process = require('child_process');
|
|
6
|
+
require('axios');
|
|
7
|
+
require('chalk');
|
|
8
|
+
require('node:os');
|
|
9
|
+
require('node:path');
|
|
10
|
+
require('node:fs/promises');
|
|
11
|
+
require('node:fs');
|
|
12
|
+
require('node:events');
|
|
13
|
+
require('socket.io-client');
|
|
14
|
+
require('zod');
|
|
15
|
+
require('node:crypto');
|
|
16
|
+
require('tweetnacl');
|
|
17
|
+
require('expo-server-sdk');
|
|
18
|
+
|
|
19
|
+
function trimIdent(text) {
|
|
20
|
+
const lines = text.split("\n");
|
|
21
|
+
while (lines.length > 0 && lines[0].trim() === "") {
|
|
22
|
+
lines.shift();
|
|
23
|
+
}
|
|
24
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
25
|
+
lines.pop();
|
|
26
|
+
}
|
|
27
|
+
const minSpaces = lines.reduce((min, line) => {
|
|
28
|
+
if (line.trim() === "") {
|
|
29
|
+
return min;
|
|
30
|
+
}
|
|
31
|
+
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
32
|
+
return Math.min(min, leadingSpaces);
|
|
33
|
+
}, Infinity);
|
|
34
|
+
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
35
|
+
return trimmedLines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
39
|
+
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
40
|
+
async function install$1() {
|
|
41
|
+
try {
|
|
42
|
+
if (fs.existsSync(PLIST_FILE)) {
|
|
43
|
+
types.logger.info("Daemon plist already exists. Uninstalling first...");
|
|
44
|
+
child_process.execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
45
|
+
}
|
|
46
|
+
const happyPath = process.argv[0];
|
|
47
|
+
const scriptPath = process.argv[1];
|
|
48
|
+
const plistContent = trimIdent(`
|
|
49
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
50
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
51
|
+
<plist version="1.0">
|
|
52
|
+
<dict>
|
|
53
|
+
<key>Label</key>
|
|
54
|
+
<string>${PLIST_LABEL}</string>
|
|
55
|
+
|
|
56
|
+
<key>ProgramArguments</key>
|
|
57
|
+
<array>
|
|
58
|
+
<string>${happyPath}</string>
|
|
59
|
+
<string>${scriptPath}</string>
|
|
60
|
+
<string>daemon</string>
|
|
61
|
+
</array>
|
|
62
|
+
|
|
63
|
+
<key>EnvironmentVariables</key>
|
|
64
|
+
<dict>
|
|
65
|
+
<key>HAPPY_DAEMON_MODE</key>
|
|
66
|
+
<string>true</string>
|
|
67
|
+
</dict>
|
|
68
|
+
|
|
69
|
+
<key>RunAtLoad</key>
|
|
70
|
+
<true/>
|
|
71
|
+
|
|
72
|
+
<key>KeepAlive</key>
|
|
73
|
+
<true/>
|
|
74
|
+
|
|
75
|
+
<key>StandardErrorPath</key>
|
|
76
|
+
<string>/var/log/happy-cli-daemon.err</string>
|
|
77
|
+
|
|
78
|
+
<key>StandardOutPath</key>
|
|
79
|
+
<string>/var/log/happy-cli-daemon.log</string>
|
|
80
|
+
|
|
81
|
+
<key>WorkingDirectory</key>
|
|
82
|
+
<string>/tmp</string>
|
|
83
|
+
</dict>
|
|
84
|
+
</plist>
|
|
85
|
+
`);
|
|
86
|
+
fs.writeFileSync(PLIST_FILE, plistContent);
|
|
87
|
+
fs.chmodSync(PLIST_FILE, 420);
|
|
88
|
+
types.logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
89
|
+
child_process.execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
90
|
+
types.logger.info("Daemon installed and started successfully");
|
|
91
|
+
types.logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
92
|
+
} catch (error) {
|
|
93
|
+
types.logger.debug("Failed to install daemon:", error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function install() {
|
|
99
|
+
if (process.platform !== "darwin") {
|
|
100
|
+
throw new Error("Daemon installation is currently only supported on macOS");
|
|
101
|
+
}
|
|
102
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
103
|
+
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
104
|
+
}
|
|
105
|
+
types.logger.info("Installing Happy CLI daemon for macOS...");
|
|
106
|
+
await install$1();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
exports.install = install;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var types = require('./types-DYBiuNUQ.cjs');
|
|
4
|
+
var install$1 = require('./install-GZIzyuIE.cjs');
|
|
5
|
+
require('axios');
|
|
6
|
+
require('chalk');
|
|
7
|
+
require('fs');
|
|
8
|
+
require('node:os');
|
|
9
|
+
require('node:path');
|
|
10
|
+
require('node:fs/promises');
|
|
11
|
+
require('node:fs');
|
|
12
|
+
require('node:events');
|
|
13
|
+
require('socket.io-client');
|
|
14
|
+
require('zod');
|
|
15
|
+
require('node:crypto');
|
|
16
|
+
require('tweetnacl');
|
|
17
|
+
require('expo-server-sdk');
|
|
18
|
+
require('child_process');
|
|
19
|
+
|
|
20
|
+
async function install() {
|
|
21
|
+
if (process.platform !== "darwin") {
|
|
22
|
+
throw new Error("Daemon installation is currently only supported on macOS");
|
|
23
|
+
}
|
|
24
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
25
|
+
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
26
|
+
}
|
|
27
|
+
types.logger.info("Installing Happy CLI daemon for macOS...");
|
|
28
|
+
await install$1.install();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.install = install;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { existsSync, writeFileSync, chmodSync } from 'fs';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { l as logger } from './types-BRICSarm.mjs';
|
|
4
|
+
import 'axios';
|
|
5
|
+
import 'chalk';
|
|
6
|
+
import 'node:os';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:events';
|
|
11
|
+
import 'socket.io-client';
|
|
12
|
+
import 'zod';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'tweetnacl';
|
|
15
|
+
import 'expo-server-sdk';
|
|
16
|
+
|
|
17
|
+
function trimIdent(text) {
|
|
18
|
+
const lines = text.split("\n");
|
|
19
|
+
while (lines.length > 0 && lines[0].trim() === "") {
|
|
20
|
+
lines.shift();
|
|
21
|
+
}
|
|
22
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
23
|
+
lines.pop();
|
|
24
|
+
}
|
|
25
|
+
const minSpaces = lines.reduce((min, line) => {
|
|
26
|
+
if (line.trim() === "") {
|
|
27
|
+
return min;
|
|
28
|
+
}
|
|
29
|
+
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
30
|
+
return Math.min(min, leadingSpaces);
|
|
31
|
+
}, Infinity);
|
|
32
|
+
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
33
|
+
return trimmedLines.join("\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
37
|
+
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
38
|
+
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
|
|
39
|
+
async function install() {
|
|
40
|
+
try {
|
|
41
|
+
if (existsSync(PLIST_FILE)) {
|
|
42
|
+
logger.info("Daemon plist already exists. Uninstalling first...");
|
|
43
|
+
execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
44
|
+
}
|
|
45
|
+
const happyPath = process.argv[0];
|
|
46
|
+
const scriptPath = process.argv[1];
|
|
47
|
+
const plistContent = trimIdent(`
|
|
48
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
49
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
50
|
+
<plist version="1.0">
|
|
51
|
+
<dict>
|
|
52
|
+
<key>Label</key>
|
|
53
|
+
<string>${PLIST_LABEL}</string>
|
|
54
|
+
|
|
55
|
+
<key>ProgramArguments</key>
|
|
56
|
+
<array>
|
|
57
|
+
<string>${happyPath}</string>
|
|
58
|
+
<string>${scriptPath}</string>
|
|
59
|
+
<string>daemon</string>
|
|
60
|
+
</array>
|
|
61
|
+
|
|
62
|
+
<key>EnvironmentVariables</key>
|
|
63
|
+
<dict>
|
|
64
|
+
<key>HAPPY_DAEMON_MODE</key>
|
|
65
|
+
<string>true</string>
|
|
66
|
+
</dict>
|
|
67
|
+
|
|
68
|
+
<key>RunAtLoad</key>
|
|
69
|
+
<true/>
|
|
70
|
+
|
|
71
|
+
<key>KeepAlive</key>
|
|
72
|
+
<true/>
|
|
73
|
+
|
|
74
|
+
<key>StandardErrorPath</key>
|
|
75
|
+
<string>${USER_HOME}/.happy/happy-cli-daemon.err</string>
|
|
76
|
+
|
|
77
|
+
<key>StandardOutPath</key>
|
|
78
|
+
<string>${USER_HOME}/.happy/happy-cli-daemon.log</string>
|
|
79
|
+
|
|
80
|
+
<key>WorkingDirectory</key>
|
|
81
|
+
<string>/tmp</string>
|
|
82
|
+
</dict>
|
|
83
|
+
</plist>
|
|
84
|
+
`);
|
|
85
|
+
writeFileSync(PLIST_FILE, plistContent);
|
|
86
|
+
chmodSync(PLIST_FILE, 420);
|
|
87
|
+
logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
88
|
+
execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
89
|
+
logger.info("Daemon installed and started successfully");
|
|
90
|
+
logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
91
|
+
} catch (error) {
|
|
92
|
+
logger.debug("Failed to install daemon:", error);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { install };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var child_process = require('child_process');
|
|
5
|
+
var types = require('./types-DYBiuNUQ.cjs');
|
|
6
|
+
require('axios');
|
|
7
|
+
require('chalk');
|
|
8
|
+
require('node:os');
|
|
9
|
+
require('node:path');
|
|
10
|
+
require('node:fs/promises');
|
|
11
|
+
require('node:fs');
|
|
12
|
+
require('node:events');
|
|
13
|
+
require('socket.io-client');
|
|
14
|
+
require('zod');
|
|
15
|
+
require('node:crypto');
|
|
16
|
+
require('tweetnacl');
|
|
17
|
+
require('expo-server-sdk');
|
|
18
|
+
|
|
19
|
+
function trimIdent(text) {
|
|
20
|
+
const lines = text.split("\n");
|
|
21
|
+
while (lines.length > 0 && lines[0].trim() === "") {
|
|
22
|
+
lines.shift();
|
|
23
|
+
}
|
|
24
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
25
|
+
lines.pop();
|
|
26
|
+
}
|
|
27
|
+
const minSpaces = lines.reduce((min, line) => {
|
|
28
|
+
if (line.trim() === "") {
|
|
29
|
+
return min;
|
|
30
|
+
}
|
|
31
|
+
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
32
|
+
return Math.min(min, leadingSpaces);
|
|
33
|
+
}, Infinity);
|
|
34
|
+
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
35
|
+
return trimmedLines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
39
|
+
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
40
|
+
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
|
|
41
|
+
async function install() {
|
|
42
|
+
try {
|
|
43
|
+
if (fs.existsSync(PLIST_FILE)) {
|
|
44
|
+
types.logger.info("Daemon plist already exists. Uninstalling first...");
|
|
45
|
+
child_process.execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
46
|
+
}
|
|
47
|
+
const happyPath = process.argv[0];
|
|
48
|
+
const scriptPath = process.argv[1];
|
|
49
|
+
const plistContent = trimIdent(`
|
|
50
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
51
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
52
|
+
<plist version="1.0">
|
|
53
|
+
<dict>
|
|
54
|
+
<key>Label</key>
|
|
55
|
+
<string>${PLIST_LABEL}</string>
|
|
56
|
+
|
|
57
|
+
<key>ProgramArguments</key>
|
|
58
|
+
<array>
|
|
59
|
+
<string>${happyPath}</string>
|
|
60
|
+
<string>${scriptPath}</string>
|
|
61
|
+
<string>daemon</string>
|
|
62
|
+
</array>
|
|
63
|
+
|
|
64
|
+
<key>EnvironmentVariables</key>
|
|
65
|
+
<dict>
|
|
66
|
+
<key>HAPPY_DAEMON_MODE</key>
|
|
67
|
+
<string>true</string>
|
|
68
|
+
</dict>
|
|
69
|
+
|
|
70
|
+
<key>RunAtLoad</key>
|
|
71
|
+
<true/>
|
|
72
|
+
|
|
73
|
+
<key>KeepAlive</key>
|
|
74
|
+
<true/>
|
|
75
|
+
|
|
76
|
+
<key>StandardErrorPath</key>
|
|
77
|
+
<string>${USER_HOME}/.happy/happy-cli-daemon.err</string>
|
|
78
|
+
|
|
79
|
+
<key>StandardOutPath</key>
|
|
80
|
+
<string>${USER_HOME}/.happy/happy-cli-daemon.log</string>
|
|
81
|
+
|
|
82
|
+
<key>WorkingDirectory</key>
|
|
83
|
+
<string>/tmp</string>
|
|
84
|
+
</dict>
|
|
85
|
+
</plist>
|
|
86
|
+
`);
|
|
87
|
+
fs.writeFileSync(PLIST_FILE, plistContent);
|
|
88
|
+
fs.chmodSync(PLIST_FILE, 420);
|
|
89
|
+
types.logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
90
|
+
child_process.execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
91
|
+
types.logger.info("Daemon installed and started successfully");
|
|
92
|
+
types.logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
93
|
+
} catch (error) {
|
|
94
|
+
types.logger.debug("Failed to install daemon:", error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.install = install;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { l as logger } from './types-fXgEaaqP.mjs';
|
|
2
|
+
import { existsSync, writeFileSync, chmodSync } from 'fs';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import 'axios';
|
|
5
|
+
import 'chalk';
|
|
6
|
+
import 'node:os';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:events';
|
|
11
|
+
import 'socket.io-client';
|
|
12
|
+
import 'zod';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'tweetnacl';
|
|
15
|
+
import 'expo-server-sdk';
|
|
16
|
+
|
|
17
|
+
function trimIdent(text) {
|
|
18
|
+
const lines = text.split("\n");
|
|
19
|
+
while (lines.length > 0 && lines[0].trim() === "") {
|
|
20
|
+
lines.shift();
|
|
21
|
+
}
|
|
22
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
23
|
+
lines.pop();
|
|
24
|
+
}
|
|
25
|
+
const minSpaces = lines.reduce((min, line) => {
|
|
26
|
+
if (line.trim() === "") {
|
|
27
|
+
return min;
|
|
28
|
+
}
|
|
29
|
+
const leadingSpaces = line.match(/^\s*/)[0].length;
|
|
30
|
+
return Math.min(min, leadingSpaces);
|
|
31
|
+
}, Infinity);
|
|
32
|
+
const trimmedLines = lines.map((line) => line.slice(minSpaces));
|
|
33
|
+
return trimmedLines.join("\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PLIST_LABEL = "com.happy-cli.daemon";
|
|
37
|
+
const PLIST_FILE = `/Library/LaunchDaemons/${PLIST_LABEL}.plist`;
|
|
38
|
+
async function install$1() {
|
|
39
|
+
try {
|
|
40
|
+
if (existsSync(PLIST_FILE)) {
|
|
41
|
+
logger.info("Daemon plist already exists. Uninstalling first...");
|
|
42
|
+
execSync(`launchctl unload ${PLIST_FILE}`, { stdio: "inherit" });
|
|
43
|
+
}
|
|
44
|
+
const happyPath = process.argv[0];
|
|
45
|
+
const scriptPath = process.argv[1];
|
|
46
|
+
const plistContent = trimIdent(`
|
|
47
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
48
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
49
|
+
<plist version="1.0">
|
|
50
|
+
<dict>
|
|
51
|
+
<key>Label</key>
|
|
52
|
+
<string>${PLIST_LABEL}</string>
|
|
53
|
+
|
|
54
|
+
<key>ProgramArguments</key>
|
|
55
|
+
<array>
|
|
56
|
+
<string>${happyPath}</string>
|
|
57
|
+
<string>${scriptPath}</string>
|
|
58
|
+
<string>daemon</string>
|
|
59
|
+
</array>
|
|
60
|
+
|
|
61
|
+
<key>EnvironmentVariables</key>
|
|
62
|
+
<dict>
|
|
63
|
+
<key>HAPPY_DAEMON_MODE</key>
|
|
64
|
+
<string>true</string>
|
|
65
|
+
</dict>
|
|
66
|
+
|
|
67
|
+
<key>RunAtLoad</key>
|
|
68
|
+
<true/>
|
|
69
|
+
|
|
70
|
+
<key>KeepAlive</key>
|
|
71
|
+
<true/>
|
|
72
|
+
|
|
73
|
+
<key>StandardErrorPath</key>
|
|
74
|
+
<string>/var/log/happy-cli-daemon.err</string>
|
|
75
|
+
|
|
76
|
+
<key>StandardOutPath</key>
|
|
77
|
+
<string>/var/log/happy-cli-daemon.log</string>
|
|
78
|
+
|
|
79
|
+
<key>WorkingDirectory</key>
|
|
80
|
+
<string>/tmp</string>
|
|
81
|
+
</dict>
|
|
82
|
+
</plist>
|
|
83
|
+
`);
|
|
84
|
+
writeFileSync(PLIST_FILE, plistContent);
|
|
85
|
+
chmodSync(PLIST_FILE, 420);
|
|
86
|
+
logger.info(`Created daemon plist at ${PLIST_FILE}`);
|
|
87
|
+
execSync(`launchctl load ${PLIST_FILE}`, { stdio: "inherit" });
|
|
88
|
+
logger.info("Daemon installed and started successfully");
|
|
89
|
+
logger.info("Check logs at /var/log/happy-cli-daemon.log");
|
|
90
|
+
} catch (error) {
|
|
91
|
+
logger.debug("Failed to install daemon:", error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function install() {
|
|
97
|
+
if (process.platform !== "darwin") {
|
|
98
|
+
throw new Error("Daemon installation is currently only supported on macOS");
|
|
99
|
+
}
|
|
100
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
101
|
+
throw new Error("Daemon installation requires sudo privileges. Please run with sudo.");
|
|
102
|
+
}
|
|
103
|
+
logger.info("Installing Happy CLI daemon for macOS...");
|
|
104
|
+
await install$1();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { install };
|
package/dist/lib.cjs
CHANGED
package/dist/lib.d.cts
CHANGED
|
@@ -393,10 +393,14 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
393
393
|
* @param body - Message body (can be MessageContent or raw content for agent messages)
|
|
394
394
|
*/
|
|
395
395
|
sendClaudeSessionMessage(body: RawJSONLines): void;
|
|
396
|
+
sendSessionEvent(event: {
|
|
397
|
+
type: 'switch';
|
|
398
|
+
mode: 'local' | 'remote';
|
|
399
|
+
}, id?: string): void;
|
|
396
400
|
/**
|
|
397
401
|
* Send a ping message to keep the connection alive
|
|
398
402
|
*/
|
|
399
|
-
keepAlive(thinking: boolean): void;
|
|
403
|
+
keepAlive(thinking: boolean, mode: 'local' | 'remote'): void;
|
|
400
404
|
/**
|
|
401
405
|
* Send session death message
|
|
402
406
|
*/
|
|
@@ -519,9 +523,10 @@ declare class Configuration {
|
|
|
519
523
|
readonly logsDir: string;
|
|
520
524
|
readonly settingsFile: string;
|
|
521
525
|
readonly privateKeyFile: string;
|
|
522
|
-
|
|
526
|
+
readonly daemonPidFile: string;
|
|
527
|
+
constructor(location: 'global' | 'local' | string);
|
|
523
528
|
}
|
|
524
529
|
declare let configuration: Configuration;
|
|
525
|
-
declare function initializeConfiguration(location: 'global' | 'local'): void;
|
|
530
|
+
declare function initializeConfiguration(location: 'global' | 'local' | string): void;
|
|
526
531
|
|
|
527
532
|
export { ApiClient, ApiSessionClient, type RawJSONLines, RawJSONLinesSchema, configuration, initLoggerWithGlobalConfiguration, initializeConfiguration, logger };
|
package/dist/lib.d.mts
CHANGED
|
@@ -393,10 +393,14 @@ declare class ApiSessionClient extends EventEmitter {
|
|
|
393
393
|
* @param body - Message body (can be MessageContent or raw content for agent messages)
|
|
394
394
|
*/
|
|
395
395
|
sendClaudeSessionMessage(body: RawJSONLines): void;
|
|
396
|
+
sendSessionEvent(event: {
|
|
397
|
+
type: 'switch';
|
|
398
|
+
mode: 'local' | 'remote';
|
|
399
|
+
}, id?: string): void;
|
|
396
400
|
/**
|
|
397
401
|
* Send a ping message to keep the connection alive
|
|
398
402
|
*/
|
|
399
|
-
keepAlive(thinking: boolean): void;
|
|
403
|
+
keepAlive(thinking: boolean, mode: 'local' | 'remote'): void;
|
|
400
404
|
/**
|
|
401
405
|
* Send session death message
|
|
402
406
|
*/
|
|
@@ -519,9 +523,10 @@ declare class Configuration {
|
|
|
519
523
|
readonly logsDir: string;
|
|
520
524
|
readonly settingsFile: string;
|
|
521
525
|
readonly privateKeyFile: string;
|
|
522
|
-
|
|
526
|
+
readonly daemonPidFile: string;
|
|
527
|
+
constructor(location: 'global' | 'local' | string);
|
|
523
528
|
}
|
|
524
529
|
declare let configuration: Configuration;
|
|
525
|
-
declare function initializeConfiguration(location: 'global' | 'local'): void;
|
|
530
|
+
declare function initializeConfiguration(location: 'global' | 'local' | string): void;
|
|
526
531
|
|
|
527
532
|
export { ApiClient, ApiSessionClient, type RawJSONLines, RawJSONLinesSchema, configuration, initLoggerWithGlobalConfiguration, initializeConfiguration, logger };
|
package/dist/lib.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, i as initLoggerWithGlobalConfiguration, b as initializeConfiguration, l as logger } from './types-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, i as initLoggerWithGlobalConfiguration, b as initializeConfiguration, l as logger } from './types-D39L8JSd.mjs';
|
|
2
2
|
import 'axios';
|
|
3
3
|
import 'chalk';
|
|
4
4
|
import 'fs';
|