@ch4p/cli 0.2.3 → 0.3.0
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/agent-FJPYQ6XV.js +765 -0
- package/dist/canvas-2JNS7CMC.js +324 -0
- package/dist/canvas-FTJBNVCM.js +324 -0
- package/dist/canvas-TGYQHRYN.js +324 -0
- package/dist/chunk-2JQRW4PJ.js +2411 -0
- package/dist/chunk-MQKGGZAB.js +7736 -0
- package/dist/chunk-ODOKLIJK.js +2415 -0
- package/dist/chunk-YTUBP6WQ.js +2410 -0
- package/dist/gateway-BS2IUIQT.js +19 -0
- package/dist/gateway-J7WHUIK3.js +19 -0
- package/dist/gateway-JTQ2FYQZ.js +19 -0
- package/dist/index.js +4 -4
- package/dist/install-4JYHJURZ.js +378 -0
- package/package.json +17 -17
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySafeUpdates,
|
|
3
|
+
buildSafeConfig,
|
|
4
|
+
gateway
|
|
5
|
+
} from "./chunk-ODOKLIJK.js";
|
|
6
|
+
import "./chunk-WYXCGS55.js";
|
|
7
|
+
import "./chunk-3CYOOHMM.js";
|
|
8
|
+
import "./chunk-MQKGGZAB.js";
|
|
9
|
+
import "./chunk-MABLWEGE.js";
|
|
10
|
+
import "./chunk-6BURGD2Y.js";
|
|
11
|
+
import "./chunk-UNF4S4CA.js";
|
|
12
|
+
import "./chunk-YSCX2QQQ.js";
|
|
13
|
+
import "./chunk-AORLXQHZ.js";
|
|
14
|
+
import "./chunk-NMGPBPNU.js";
|
|
15
|
+
export {
|
|
16
|
+
applySafeUpdates,
|
|
17
|
+
buildSafeConfig,
|
|
18
|
+
gateway
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySafeUpdates,
|
|
3
|
+
buildSafeConfig,
|
|
4
|
+
gateway
|
|
5
|
+
} from "./chunk-YTUBP6WQ.js";
|
|
6
|
+
import "./chunk-WYXCGS55.js";
|
|
7
|
+
import "./chunk-3CYOOHMM.js";
|
|
8
|
+
import "./chunk-KLGE5YZR.js";
|
|
9
|
+
import "./chunk-MABLWEGE.js";
|
|
10
|
+
import "./chunk-6BURGD2Y.js";
|
|
11
|
+
import "./chunk-UNF4S4CA.js";
|
|
12
|
+
import "./chunk-YSCX2QQQ.js";
|
|
13
|
+
import "./chunk-AORLXQHZ.js";
|
|
14
|
+
import "./chunk-NMGPBPNU.js";
|
|
15
|
+
export {
|
|
16
|
+
applySafeUpdates,
|
|
17
|
+
buildSafeConfig,
|
|
18
|
+
gateway
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySafeUpdates,
|
|
3
|
+
buildSafeConfig,
|
|
4
|
+
gateway
|
|
5
|
+
} from "./chunk-2JQRW4PJ.js";
|
|
6
|
+
import "./chunk-WYXCGS55.js";
|
|
7
|
+
import "./chunk-3CYOOHMM.js";
|
|
8
|
+
import "./chunk-KLGE5YZR.js";
|
|
9
|
+
import "./chunk-MABLWEGE.js";
|
|
10
|
+
import "./chunk-6BURGD2Y.js";
|
|
11
|
+
import "./chunk-UNF4S4CA.js";
|
|
12
|
+
import "./chunk-YSCX2QQQ.js";
|
|
13
|
+
import "./chunk-AORLXQHZ.js";
|
|
14
|
+
import "./chunk-NMGPBPNU.js";
|
|
15
|
+
export {
|
|
16
|
+
applySafeUpdates,
|
|
17
|
+
buildSafeConfig,
|
|
18
|
+
gateway
|
|
19
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -106,12 +106,12 @@ async function main() {
|
|
|
106
106
|
const { command, rest } = parseArgs(process.argv);
|
|
107
107
|
switch (command) {
|
|
108
108
|
case "agent": {
|
|
109
|
-
const { agent } = await import("./agent-
|
|
109
|
+
const { agent } = await import("./agent-FJPYQ6XV.js");
|
|
110
110
|
await agent(rest);
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
case "gateway": {
|
|
114
|
-
const { gateway } = await import("./gateway-
|
|
114
|
+
const { gateway } = await import("./gateway-BS2IUIQT.js");
|
|
115
115
|
await gateway(rest);
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
@@ -156,7 +156,7 @@ async function main() {
|
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
case "canvas": {
|
|
159
|
-
const { canvas } = await import("./canvas-
|
|
159
|
+
const { canvas } = await import("./canvas-FTJBNVCM.js");
|
|
160
160
|
await canvas(rest);
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
@@ -166,7 +166,7 @@ async function main() {
|
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
case "install": {
|
|
169
|
-
const { install } = await import("./install-
|
|
169
|
+
const { install } = await import("./install-4JYHJURZ.js");
|
|
170
170
|
await install(rest);
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCh4pDir,
|
|
3
|
+
getConfigPath,
|
|
4
|
+
getLogsDir
|
|
5
|
+
} from "./chunk-AORLXQHZ.js";
|
|
6
|
+
import {
|
|
7
|
+
BOLD,
|
|
8
|
+
DIM,
|
|
9
|
+
GREEN,
|
|
10
|
+
RED,
|
|
11
|
+
RESET,
|
|
12
|
+
TEAL,
|
|
13
|
+
YELLOW
|
|
14
|
+
} from "./chunk-NMGPBPNU.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/install.ts
|
|
17
|
+
import { execSync } from "child_process";
|
|
18
|
+
import { writeFileSync, mkdirSync, existsSync, rmSync } from "fs";
|
|
19
|
+
import { join } from "path";
|
|
20
|
+
import { homedir } from "os";
|
|
21
|
+
var LAUNCHD_LABEL = "com.ch4p.gateway";
|
|
22
|
+
var SYSTEMD_UNIT = "ch4p-gateway";
|
|
23
|
+
function run(cmd) {
|
|
24
|
+
try {
|
|
25
|
+
return execSync(cmd, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function runOrThrow(cmd, errMsg) {
|
|
31
|
+
try {
|
|
32
|
+
return execSync(cmd, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
33
|
+
} catch (err) {
|
|
34
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
35
|
+
throw new Error(`${errMsg}
|
|
36
|
+
${DIM}${detail}${RESET}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function findBinary() {
|
|
40
|
+
const which = run("which ch4p");
|
|
41
|
+
if (which && which.length > 0) return which;
|
|
42
|
+
const script = process.argv[1];
|
|
43
|
+
if (script) {
|
|
44
|
+
const dir = script.replace(/[/\\][^/\\]+$/, "");
|
|
45
|
+
const candidate = join(dir, "index.js");
|
|
46
|
+
if (existsSync(candidate)) {
|
|
47
|
+
return `${process.execPath} ${candidate}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return "ch4p";
|
|
51
|
+
}
|
|
52
|
+
function launchdPlistPath() {
|
|
53
|
+
return join(homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
54
|
+
}
|
|
55
|
+
function buildLaunchdPlist(binaryPath, ch4pDir, logsDir) {
|
|
56
|
+
const spaceIdx = binaryPath.indexOf(" ");
|
|
57
|
+
const programArgs = spaceIdx !== -1 ? [binaryPath.slice(0, spaceIdx), binaryPath.slice(spaceIdx + 1), "gateway"] : [binaryPath, "gateway"];
|
|
58
|
+
const programArgsXml = programArgs.map((a) => ` <string>${a}</string>`).join("\n");
|
|
59
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
61
|
+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
62
|
+
<plist version="1.0">
|
|
63
|
+
<dict>
|
|
64
|
+
<key>Label</key>
|
|
65
|
+
<string>${LAUNCHD_LABEL}</string>
|
|
66
|
+
|
|
67
|
+
<key>ProgramArguments</key>
|
|
68
|
+
<array>
|
|
69
|
+
${programArgsXml}
|
|
70
|
+
</array>
|
|
71
|
+
|
|
72
|
+
<key>EnvironmentVariables</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>HOME</key>
|
|
75
|
+
<string>${homedir()}</string>
|
|
76
|
+
<key>PATH</key>
|
|
77
|
+
<string>${homedir()}/.local/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin</string>
|
|
78
|
+
</dict>
|
|
79
|
+
|
|
80
|
+
<key>WorkingDirectory</key>
|
|
81
|
+
<string>${ch4pDir}</string>
|
|
82
|
+
|
|
83
|
+
<key>RunAtLoad</key>
|
|
84
|
+
<true/>
|
|
85
|
+
|
|
86
|
+
<key>KeepAlive</key>
|
|
87
|
+
<true/>
|
|
88
|
+
|
|
89
|
+
<key>ThrottleInterval</key>
|
|
90
|
+
<integer>5</integer>
|
|
91
|
+
|
|
92
|
+
<key>StandardOutPath</key>
|
|
93
|
+
<string>${logsDir}/gateway-stdout.log</string>
|
|
94
|
+
|
|
95
|
+
<key>StandardErrorPath</key>
|
|
96
|
+
<string>${logsDir}/gateway-stderr.log</string>
|
|
97
|
+
</dict>
|
|
98
|
+
</plist>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
function installLaunchd(binaryPath) {
|
|
102
|
+
const ch4pDir = getCh4pDir();
|
|
103
|
+
const logsDir = getLogsDir();
|
|
104
|
+
const plistPath = launchdPlistPath();
|
|
105
|
+
const plistDir = join(homedir(), "Library", "LaunchAgents");
|
|
106
|
+
mkdirSync(plistDir, { recursive: true });
|
|
107
|
+
mkdirSync(logsDir, { recursive: true });
|
|
108
|
+
const plist = buildLaunchdPlist(binaryPath, ch4pDir, logsDir);
|
|
109
|
+
writeFileSync(plistPath, plist, { mode: 420 });
|
|
110
|
+
console.log(` ${GREEN}\u2713${RESET} Wrote ${plistPath}`);
|
|
111
|
+
run(`launchctl unload "${plistPath}" 2>/dev/null`);
|
|
112
|
+
runOrThrow(
|
|
113
|
+
`launchctl load -w "${plistPath}"`,
|
|
114
|
+
"Failed to load plist with launchctl."
|
|
115
|
+
);
|
|
116
|
+
console.log(` ${GREEN}\u2713${RESET} Service loaded and started`);
|
|
117
|
+
console.log(`
|
|
118
|
+
${DIM}Check status: ${TEAL}ch4p install --status${RESET}`);
|
|
119
|
+
console.log(` ${DIM}Tail logs: ${TEAL}ch4p install --logs${RESET}`);
|
|
120
|
+
console.log(` ${DIM}Remove: ${TEAL}ch4p install --uninstall${RESET}`);
|
|
121
|
+
}
|
|
122
|
+
function uninstallLaunchd() {
|
|
123
|
+
const plistPath = launchdPlistPath();
|
|
124
|
+
if (!existsSync(plistPath)) {
|
|
125
|
+
console.log(` ${YELLOW}\u26A0 No service file found at${RESET} ${plistPath}`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
run(`launchctl unload -w "${plistPath}" 2>/dev/null`);
|
|
129
|
+
rmSync(plistPath);
|
|
130
|
+
console.log(` ${GREEN}\u2713${RESET} Removed ${plistPath}`);
|
|
131
|
+
console.log(` ${GREEN}\u2713${RESET} Service unloaded`);
|
|
132
|
+
}
|
|
133
|
+
function statusLaunchd() {
|
|
134
|
+
const plistPath = launchdPlistPath();
|
|
135
|
+
if (!existsSync(plistPath)) {
|
|
136
|
+
console.log(` ${RED}\u2717 Not installed${RESET} \u2014 run ${TEAL}ch4p install${RESET}`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
console.log(` ${DIM}Plist:${RESET} ${plistPath}`);
|
|
140
|
+
const listOutput = run(`launchctl list | grep "${LAUNCHD_LABEL}"`);
|
|
141
|
+
if (listOutput) {
|
|
142
|
+
const parts = listOutput.trim().split(/\s+/);
|
|
143
|
+
const pid = parts[0];
|
|
144
|
+
const exitCode = parts[1];
|
|
145
|
+
if (pid && pid !== "-") {
|
|
146
|
+
console.log(` ${GREEN}\u25CF Running${RESET} PID ${pid}`);
|
|
147
|
+
} else {
|
|
148
|
+
const exitMsg = exitCode && exitCode !== "0" ? ` (last exit: ${exitCode})` : "";
|
|
149
|
+
console.log(` ${YELLOW}\u25CB Stopped${RESET}${exitMsg}`);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
console.log(` ${YELLOW}\u25CB Not loaded${RESET}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function logsLaunchd() {
|
|
156
|
+
const logsDir = getLogsDir();
|
|
157
|
+
const outLog = join(logsDir, "gateway-stdout.log");
|
|
158
|
+
const errLog = join(logsDir, "gateway-stderr.log");
|
|
159
|
+
const jsonLog = join(logsDir, "gateway.jsonl");
|
|
160
|
+
if (existsSync(jsonLog)) {
|
|
161
|
+
console.log(` ${DIM}Tailing ${jsonLog} \u2014 Ctrl-C to stop${RESET}
|
|
162
|
+
`);
|
|
163
|
+
try {
|
|
164
|
+
execSync(`tail -f "${jsonLog}"`, { stdio: "inherit" });
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (existsSync(errLog) || existsSync(outLog)) {
|
|
170
|
+
const target = existsSync(errLog) ? errLog : outLog;
|
|
171
|
+
console.log(` ${DIM}Tailing ${target} \u2014 Ctrl-C to stop${RESET}
|
|
172
|
+
`);
|
|
173
|
+
try {
|
|
174
|
+
execSync(`tail -f "${target}"`, { stdio: "inherit" });
|
|
175
|
+
} catch {
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
console.log(` ${YELLOW}\u26A0 No log files found yet.${RESET}`);
|
|
180
|
+
console.log(` ${DIM}Logs appear after the first gateway run.${RESET}`);
|
|
181
|
+
console.log(` ${DIM}Expected: ${outLog}${RESET}`);
|
|
182
|
+
}
|
|
183
|
+
function systemdUnitPath() {
|
|
184
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
185
|
+
return join(configHome, "systemd", "user", `${SYSTEMD_UNIT}.service`);
|
|
186
|
+
}
|
|
187
|
+
function buildSystemdUnit(binaryPath, ch4pDir, logsDir) {
|
|
188
|
+
const envFile = join(ch4pDir, ".env");
|
|
189
|
+
const envFileLine = existsSync(envFile) ? `EnvironmentFile=-${envFile}
|
|
190
|
+
` : "";
|
|
191
|
+
const execStart = `ExecStart=${binaryPath} gateway`;
|
|
192
|
+
return `[Unit]
|
|
193
|
+
Description=ch4p Gateway \u2014 Personal AI Assistant
|
|
194
|
+
Documentation=https://github.com/ch4p/ch4p
|
|
195
|
+
After=network-online.target
|
|
196
|
+
Wants=network-online.target
|
|
197
|
+
|
|
198
|
+
[Service]
|
|
199
|
+
Type=simple
|
|
200
|
+
${envFileLine}Environment=HOME=${homedir()}
|
|
201
|
+
WorkingDirectory=${ch4pDir}
|
|
202
|
+
${execStart}
|
|
203
|
+
Restart=on-failure
|
|
204
|
+
RestartSec=5
|
|
205
|
+
TimeoutStopSec=40
|
|
206
|
+
KillMode=mixed
|
|
207
|
+
|
|
208
|
+
# Logs are written to the systemd journal and optionally to ${logsDir}.
|
|
209
|
+
# View with: journalctl --user -u ${SYSTEMD_UNIT} -f
|
|
210
|
+
|
|
211
|
+
[Install]
|
|
212
|
+
WantedBy=default.target
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
215
|
+
function installSystemd(binaryPath) {
|
|
216
|
+
const ch4pDir = getCh4pDir();
|
|
217
|
+
const logsDir = getLogsDir();
|
|
218
|
+
const unitPath = systemdUnitPath();
|
|
219
|
+
const unitDir = unitPath.replace(/\/[^/]+$/, "");
|
|
220
|
+
mkdirSync(unitDir, { recursive: true });
|
|
221
|
+
mkdirSync(logsDir, { recursive: true });
|
|
222
|
+
const unit = buildSystemdUnit(binaryPath, ch4pDir, logsDir);
|
|
223
|
+
writeFileSync(unitPath, unit, { mode: 420 });
|
|
224
|
+
console.log(` ${GREEN}\u2713${RESET} Wrote ${unitPath}`);
|
|
225
|
+
runOrThrow("systemctl --user daemon-reload", "systemctl daemon-reload failed.");
|
|
226
|
+
runOrThrow(`systemctl --user enable ${SYSTEMD_UNIT}`, "systemctl enable failed.");
|
|
227
|
+
runOrThrow(`systemctl --user start ${SYSTEMD_UNIT}`, "systemctl start failed.");
|
|
228
|
+
console.log(` ${GREEN}\u2713${RESET} Service enabled and started`);
|
|
229
|
+
console.log(`
|
|
230
|
+
${DIM}Check status: ${TEAL}ch4p install --status${RESET}`);
|
|
231
|
+
console.log(` ${DIM}Tail logs: ${TEAL}ch4p install --logs${RESET}`);
|
|
232
|
+
console.log(` ${DIM}Remove: ${TEAL}ch4p install --uninstall${RESET}`);
|
|
233
|
+
}
|
|
234
|
+
function uninstallSystemd() {
|
|
235
|
+
const unitPath = systemdUnitPath();
|
|
236
|
+
if (!existsSync(unitPath)) {
|
|
237
|
+
console.log(` ${YELLOW}\u26A0 No unit file found at${RESET} ${unitPath}`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
run(`systemctl --user stop ${SYSTEMD_UNIT} 2>/dev/null`);
|
|
241
|
+
run(`systemctl --user disable ${SYSTEMD_UNIT} 2>/dev/null`);
|
|
242
|
+
rmSync(unitPath);
|
|
243
|
+
run("systemctl --user daemon-reload 2>/dev/null");
|
|
244
|
+
console.log(` ${GREEN}\u2713${RESET} Removed ${unitPath}`);
|
|
245
|
+
console.log(` ${GREEN}\u2713${RESET} Service stopped and disabled`);
|
|
246
|
+
}
|
|
247
|
+
function statusSystemd() {
|
|
248
|
+
const unitPath = systemdUnitPath();
|
|
249
|
+
if (!existsSync(unitPath)) {
|
|
250
|
+
console.log(` ${RED}\u2717 Not installed${RESET} \u2014 run ${TEAL}ch4p install${RESET}`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
console.log(` ${DIM}Unit:${RESET} ${unitPath}`);
|
|
254
|
+
const output = run(`systemctl --user status ${SYSTEMD_UNIT} --no-pager -l`);
|
|
255
|
+
if (output) {
|
|
256
|
+
for (const line of output.split("\n").slice(0, 8)) {
|
|
257
|
+
console.log(` ${DIM}${line}${RESET}`);
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
console.log(` ${YELLOW}\u25CB Status unavailable${RESET}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function logsSystemd() {
|
|
264
|
+
console.log(` ${DIM}Tailing journal for ${SYSTEMD_UNIT} \u2014 Ctrl-C to stop${RESET}
|
|
265
|
+
`);
|
|
266
|
+
try {
|
|
267
|
+
execSync(`journalctl --user -u ${SYSTEMD_UNIT} -f --no-pager`, { stdio: "inherit" });
|
|
268
|
+
} catch {
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function printHelp() {
|
|
272
|
+
console.log(`
|
|
273
|
+
${TEAL}${BOLD}ch4p install${RESET} \u2014 gateway daemon installer
|
|
274
|
+
|
|
275
|
+
${BOLD}Usage${RESET}
|
|
276
|
+
${GREEN}ch4p install${RESET} Install and start the gateway daemon
|
|
277
|
+
${GREEN}ch4p install --uninstall${RESET} Remove the daemon service
|
|
278
|
+
${GREEN}ch4p install --status${RESET} Show current service status
|
|
279
|
+
${GREEN}ch4p install --logs${RESET} Tail live service logs
|
|
280
|
+
|
|
281
|
+
${BOLD}Platforms${RESET}
|
|
282
|
+
macOS launchd user agent ~/Library/LaunchAgents/com.ch4p.gateway.plist
|
|
283
|
+
Linux systemd user service ~/.config/systemd/user/ch4p-gateway.service
|
|
284
|
+
|
|
285
|
+
${BOLD}Notes${RESET}
|
|
286
|
+
${DIM}\u2022 No sudo required \u2014 services run as your user.${RESET}
|
|
287
|
+
${DIM}\u2022 API keys and channel tokens are loaded from ~/.ch4p/.env automatically.${RESET}
|
|
288
|
+
${DIM}\u2022 The service restarts automatically on crash (5-second delay).${RESET}
|
|
289
|
+
${DIM}\u2022 Run ${TEAL}ch4p onboard${DIM} first if you have not set up ch4p yet.${RESET}
|
|
290
|
+
`);
|
|
291
|
+
}
|
|
292
|
+
async function install(args) {
|
|
293
|
+
let action = "install";
|
|
294
|
+
for (const arg of args) {
|
|
295
|
+
switch (arg) {
|
|
296
|
+
case "--uninstall":
|
|
297
|
+
case "uninstall":
|
|
298
|
+
action = "uninstall";
|
|
299
|
+
break;
|
|
300
|
+
case "--status":
|
|
301
|
+
case "status":
|
|
302
|
+
action = "status";
|
|
303
|
+
break;
|
|
304
|
+
case "--logs":
|
|
305
|
+
case "logs":
|
|
306
|
+
action = "logs";
|
|
307
|
+
break;
|
|
308
|
+
case "--help":
|
|
309
|
+
case "-h":
|
|
310
|
+
printHelp();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const platform = process.platform;
|
|
315
|
+
if (platform !== "darwin" && platform !== "linux") {
|
|
316
|
+
console.error(`
|
|
317
|
+
${RED}\u2717 Unsupported platform:${RESET} ${platform}`);
|
|
318
|
+
console.error(` ${DIM}ch4p install supports macOS (launchd) and Linux (systemd).${RESET}`);
|
|
319
|
+
console.error(` ${DIM}On Windows, see the Docker deployment guide: ${TEAL}ch4p gateway${DIM}.${RESET}
|
|
320
|
+
`);
|
|
321
|
+
process.exitCode = 1;
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (action === "install") {
|
|
325
|
+
const configPath = getConfigPath();
|
|
326
|
+
if (!existsSync(configPath)) {
|
|
327
|
+
console.error(`
|
|
328
|
+
${RED}\u2717 No config found${RESET} at ${configPath}`);
|
|
329
|
+
console.error(` ${DIM}Run ${TEAL}ch4p onboard${DIM} first to set up ch4p.${RESET}
|
|
330
|
+
`);
|
|
331
|
+
process.exitCode = 1;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const banner = {
|
|
336
|
+
install: "Installing gateway daemon",
|
|
337
|
+
uninstall: "Removing gateway daemon",
|
|
338
|
+
status: "Gateway daemon status",
|
|
339
|
+
logs: "Gateway daemon logs"
|
|
340
|
+
}[action];
|
|
341
|
+
console.log(`
|
|
342
|
+
${TEAL}${BOLD}${banner}${RESET}`);
|
|
343
|
+
console.log(` ${"\u2500".repeat(40)}
|
|
344
|
+
`);
|
|
345
|
+
if (platform === "darwin") {
|
|
346
|
+
if (action === "install") {
|
|
347
|
+
const bin = findBinary();
|
|
348
|
+
console.log(` ${DIM}Binary:${RESET} ${bin}`);
|
|
349
|
+
console.log(` ${DIM}Service:${RESET} launchd \u2192 ~/Library/LaunchAgents/com.ch4p.gateway.plist
|
|
350
|
+
`);
|
|
351
|
+
installLaunchd(bin);
|
|
352
|
+
} else if (action === "uninstall") {
|
|
353
|
+
uninstallLaunchd();
|
|
354
|
+
} else if (action === "status") {
|
|
355
|
+
statusLaunchd();
|
|
356
|
+
} else {
|
|
357
|
+
logsLaunchd();
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
if (action === "install") {
|
|
361
|
+
const bin = findBinary();
|
|
362
|
+
console.log(` ${DIM}Binary:${RESET} ${bin}`);
|
|
363
|
+
console.log(` ${DIM}Service:${RESET} systemd --user \u2192 ~/.config/systemd/user/ch4p-gateway.service
|
|
364
|
+
`);
|
|
365
|
+
installSystemd(bin);
|
|
366
|
+
} else if (action === "uninstall") {
|
|
367
|
+
uninstallSystemd();
|
|
368
|
+
} else if (action === "status") {
|
|
369
|
+
statusSystemd();
|
|
370
|
+
} else {
|
|
371
|
+
logsSystemd();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
console.log("");
|
|
375
|
+
}
|
|
376
|
+
export {
|
|
377
|
+
install
|
|
378
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ch4p/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Personal AI assistant platform — security-first, multi-channel, programmable",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -53,22 +53,22 @@
|
|
|
53
53
|
"playwright-core": "^1.50.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@ch4p/
|
|
57
|
-
"@ch4p/
|
|
58
|
-
"@ch4p/
|
|
59
|
-
"@ch4p/
|
|
60
|
-
"@ch4p/
|
|
61
|
-
"@ch4p/
|
|
62
|
-
"@ch4p/
|
|
63
|
-
"@ch4p/
|
|
64
|
-
"@ch4p/engines": "0.
|
|
65
|
-
"@ch4p/
|
|
66
|
-
"@ch4p/
|
|
67
|
-
"@ch4p/skills": "0.
|
|
68
|
-
"@ch4p/tunnels": "0.
|
|
69
|
-
"@ch4p/voice": "0.
|
|
70
|
-
"@ch4p/canvas": "0.
|
|
71
|
-
"@ch4p/plugin-x402": "0.
|
|
56
|
+
"@ch4p/core": "0.3.0",
|
|
57
|
+
"@ch4p/agent": "0.3.0",
|
|
58
|
+
"@ch4p/channels": "0.3.0",
|
|
59
|
+
"@ch4p/security": "0.3.0",
|
|
60
|
+
"@ch4p/providers": "0.3.0",
|
|
61
|
+
"@ch4p/memory": "0.3.0",
|
|
62
|
+
"@ch4p/tools": "0.3.0",
|
|
63
|
+
"@ch4p/observability": "0.3.0",
|
|
64
|
+
"@ch4p/engines": "0.3.0",
|
|
65
|
+
"@ch4p/gateway": "0.3.0",
|
|
66
|
+
"@ch4p/supervisor": "0.3.0",
|
|
67
|
+
"@ch4p/skills": "0.3.0",
|
|
68
|
+
"@ch4p/tunnels": "0.3.0",
|
|
69
|
+
"@ch4p/voice": "0.3.0",
|
|
70
|
+
"@ch4p/canvas": "0.3.0",
|
|
71
|
+
"@ch4p/plugin-x402": "0.3.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsup",
|