@schuttdev/gigai 0.2.7 → 0.2.8
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/{dist-MGLETZTT.js → dist-Z7XWWQBF.js} +9 -10
- package/dist/index.js +95 -94
- package/package.json +1 -1
|
@@ -1147,7 +1147,7 @@ async function adminRoutes(server) {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
setTimeout(async () => {
|
|
1149
1149
|
server.log.info("Restarting server after update...");
|
|
1150
|
-
const args = ["
|
|
1150
|
+
const args = ["start"];
|
|
1151
1151
|
const configIdx = process.argv.indexOf("--config");
|
|
1152
1152
|
if (configIdx !== -1 && process.argv[configIdx + 1]) {
|
|
1153
1153
|
args.push("--config", process.argv[configIdx + 1]);
|
|
@@ -1472,7 +1472,7 @@ async function runInit() {
|
|
|
1472
1472
|
serverUrl = await ensureTailscaleFunnel(port);
|
|
1473
1473
|
} catch (e) {
|
|
1474
1474
|
console.error(` ${e.message}`);
|
|
1475
|
-
console.log(" You can enable Funnel later and run 'gigai
|
|
1475
|
+
console.log(" You can enable Funnel later and run 'gigai start' manually.\n");
|
|
1476
1476
|
}
|
|
1477
1477
|
} else if (httpsProvider === "cloudflare" && httpsConfig && "domain" in httpsConfig && httpsConfig.domain) {
|
|
1478
1478
|
serverUrl = `https://${httpsConfig.domain}`;
|
|
@@ -1485,7 +1485,7 @@ async function runInit() {
|
|
|
1485
1485
|
});
|
|
1486
1486
|
}
|
|
1487
1487
|
console.log("\n Starting server...");
|
|
1488
|
-
const serverArgs = ["
|
|
1488
|
+
const serverArgs = ["start", "--config", configPath];
|
|
1489
1489
|
if (!httpsConfig) serverArgs.push("--dev");
|
|
1490
1490
|
const child = spawn6("gigai", serverArgs, {
|
|
1491
1491
|
detached: true,
|
|
@@ -1518,7 +1518,7 @@ async function runInit() {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
if (!code) {
|
|
1520
1520
|
console.log("\n Server is starting but not ready yet.");
|
|
1521
|
-
console.log(" Run 'gigai
|
|
1521
|
+
console.log(" Run 'gigai pair' once it's up to get a pairing code.\n");
|
|
1522
1522
|
return;
|
|
1523
1523
|
}
|
|
1524
1524
|
console.log(`
|
|
@@ -1536,7 +1536,7 @@ async function runInit() {
|
|
|
1536
1536
|
console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
1537
1537
|
console.log(`
|
|
1538
1538
|
Pairing code expires in ${config.auth.pairingTtlSeconds / 60} minutes.`);
|
|
1539
|
-
console.log(` Run 'gigai
|
|
1539
|
+
console.log(` Run 'gigai pair' to generate a new one.
|
|
1540
1540
|
`);
|
|
1541
1541
|
}
|
|
1542
1542
|
async function loadConfigFile(path) {
|
|
@@ -1663,7 +1663,7 @@ Pairing code: ${data.code}`);
|
|
|
1663
1663
|
console.log(`Expires in ${data.expiresIn / 60} minutes.`);
|
|
1664
1664
|
} catch (e) {
|
|
1665
1665
|
if (e.message.includes("fetch failed") || e.message.includes("ECONNREFUSED")) {
|
|
1666
|
-
console.error("Server is not running. Start it with: gigai
|
|
1666
|
+
console.error("Server is not running. Start it with: gigai start");
|
|
1667
1667
|
} else {
|
|
1668
1668
|
console.error(`Error: ${e.message}`);
|
|
1669
1669
|
}
|
|
@@ -1696,7 +1696,6 @@ function getLaunchdPlist(configPath) {
|
|
|
1696
1696
|
<array>
|
|
1697
1697
|
<string>${nodeBin}</string>
|
|
1698
1698
|
<string>${bin}</string>
|
|
1699
|
-
<string>server</string>
|
|
1700
1699
|
<string>start</string>
|
|
1701
1700
|
<string>--config</string>
|
|
1702
1701
|
<string>${configPath}</string>
|
|
@@ -1723,7 +1722,7 @@ After=network.target
|
|
|
1723
1722
|
|
|
1724
1723
|
[Service]
|
|
1725
1724
|
Type=simple
|
|
1726
|
-
ExecStart=${bin}
|
|
1725
|
+
ExecStart=${bin} start --config ${configPath}
|
|
1727
1726
|
Restart=always
|
|
1728
1727
|
RestartSec=5
|
|
1729
1728
|
WorkingDirectory=${homedir()}
|
|
@@ -1766,7 +1765,7 @@ async function installDaemon(configPath) {
|
|
|
1766
1765
|
console.log(` Remove: systemctl --user disable gigai`);
|
|
1767
1766
|
} else {
|
|
1768
1767
|
console.log(" Persistent daemon not supported on this platform.");
|
|
1769
|
-
console.log(" Run 'gigai
|
|
1768
|
+
console.log(" Run 'gigai start' manually.");
|
|
1770
1769
|
}
|
|
1771
1770
|
}
|
|
1772
1771
|
async function uninstallDaemon() {
|
|
@@ -1804,7 +1803,7 @@ async function stopServer() {
|
|
|
1804
1803
|
const { execFileSync } = await import("child_process");
|
|
1805
1804
|
let pids = [];
|
|
1806
1805
|
try {
|
|
1807
|
-
const out = execFileSync("pgrep", ["-f", "gigai
|
|
1806
|
+
const out = execFileSync("pgrep", ["-f", "gigai start"], { encoding: "utf8" });
|
|
1808
1807
|
pids = out.trim().split("\n").map(Number).filter((pid) => pid && pid !== process.pid);
|
|
1809
1808
|
} catch {
|
|
1810
1809
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,109 +4,104 @@
|
|
|
4
4
|
import { defineCommand, runMain } from "citty";
|
|
5
5
|
|
|
6
6
|
// src/version.ts
|
|
7
|
-
var VERSION = "0.2.
|
|
7
|
+
var VERSION = "0.2.8";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
async function requireServer() {
|
|
11
11
|
try {
|
|
12
|
-
return await import("./dist-
|
|
12
|
+
return await import("./dist-Z7XWWQBF.js");
|
|
13
13
|
} catch {
|
|
14
14
|
console.error("Server dependencies not installed.");
|
|
15
15
|
console.error("Run: npm install -g @schuttdev/gigai");
|
|
16
16
|
process.exit(1);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
var
|
|
20
|
-
meta: { name: "
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
await installDaemon(args.config);
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
uninstall: defineCommand({
|
|
65
|
-
meta: { name: "uninstall", description: "Remove background service" },
|
|
66
|
-
async run() {
|
|
67
|
-
const { uninstallDaemon } = await requireServer();
|
|
68
|
-
await uninstallDaemon();
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
stop: defineCommand({
|
|
72
|
-
meta: { name: "stop", description: "Stop the running gigai server" },
|
|
73
|
-
async run() {
|
|
74
|
-
const { execFileSync } = await import("child_process");
|
|
75
|
-
let pids = [];
|
|
76
|
-
try {
|
|
77
|
-
const out = execFileSync("pgrep", ["-f", "gigai server start"], { encoding: "utf8" });
|
|
78
|
-
pids = out.trim().split("\n").map(Number).filter((pid) => pid && pid !== process.pid);
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
81
|
-
if (pids.length === 0) {
|
|
82
|
-
console.log("No running gigai server found.");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
for (const pid of pids) {
|
|
86
|
-
try {
|
|
87
|
-
process.kill(pid, "SIGTERM");
|
|
88
|
-
console.log(`Stopped gigai server (PID ${pid})`);
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.error(`Failed to stop PID ${pid}: ${e.message}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}),
|
|
95
|
-
status: defineCommand({
|
|
96
|
-
meta: { name: "status", description: "Show server status" },
|
|
97
|
-
async run() {
|
|
98
|
-
console.log("Server status: checking...");
|
|
99
|
-
try {
|
|
100
|
-
const res = await fetch("http://localhost:7443/health");
|
|
101
|
-
const data = await res.json();
|
|
102
|
-
console.log(`Status: ${data.status}`);
|
|
103
|
-
console.log(`Version: ${data.version}`);
|
|
104
|
-
console.log(`Uptime: ${Math.floor(data.uptime / 1e3)}s`);
|
|
105
|
-
} catch {
|
|
106
|
-
console.log("Server is not running.");
|
|
107
|
-
}
|
|
19
|
+
var initCommand = defineCommand({
|
|
20
|
+
meta: { name: "init", description: "Interactive setup wizard" },
|
|
21
|
+
async run() {
|
|
22
|
+
const { runInit } = await requireServer();
|
|
23
|
+
await runInit();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var startCommand = defineCommand({
|
|
27
|
+
meta: { name: "start", description: "Start the gigai server" },
|
|
28
|
+
args: {
|
|
29
|
+
config: { type: "string", alias: "c", description: "Config file path" },
|
|
30
|
+
dev: { type: "boolean", description: "Development mode (no HTTPS)" }
|
|
31
|
+
},
|
|
32
|
+
async run({ args }) {
|
|
33
|
+
const { startServer } = await requireServer();
|
|
34
|
+
const extraArgs = [];
|
|
35
|
+
if (args.config) extraArgs.push("--config", args.config);
|
|
36
|
+
if (args.dev) extraArgs.push("--dev");
|
|
37
|
+
process.argv.push(...extraArgs);
|
|
38
|
+
await startServer();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var stopCommand = defineCommand({
|
|
42
|
+
meta: { name: "stop", description: "Stop the running gigai server" },
|
|
43
|
+
async run() {
|
|
44
|
+
const { execFileSync } = await import("child_process");
|
|
45
|
+
let pids = [];
|
|
46
|
+
try {
|
|
47
|
+
const out = execFileSync("pgrep", ["-f", "gigai start"], { encoding: "utf8" });
|
|
48
|
+
pids = out.trim().split("\n").map(Number).filter((pid) => pid && pid !== process.pid);
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
if (pids.length === 0) {
|
|
52
|
+
console.log("No running gigai server found.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const pid of pids) {
|
|
56
|
+
try {
|
|
57
|
+
process.kill(pid, "SIGTERM");
|
|
58
|
+
console.log(`Stopped gigai server (PID ${pid})`);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error(`Failed to stop PID ${pid}: ${e.message}`);
|
|
108
61
|
}
|
|
109
|
-
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
var statusCommand = defineCommand({
|
|
66
|
+
meta: { name: "status", description: "Show server status" },
|
|
67
|
+
async run() {
|
|
68
|
+
console.log("Server status: checking...");
|
|
69
|
+
try {
|
|
70
|
+
const res = await fetch("http://localhost:7443/health");
|
|
71
|
+
const data = await res.json();
|
|
72
|
+
console.log(`Status: ${data.status}`);
|
|
73
|
+
console.log(`Version: ${data.version}`);
|
|
74
|
+
console.log(`Uptime: ${Math.floor(data.uptime / 1e3)}s`);
|
|
75
|
+
} catch {
|
|
76
|
+
console.log("Server is not running.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
var pairCommand = defineCommand({
|
|
81
|
+
meta: { name: "pair", description: "Generate a pairing code" },
|
|
82
|
+
args: {
|
|
83
|
+
config: { type: "string", alias: "c", description: "Config file path" }
|
|
84
|
+
},
|
|
85
|
+
async run({ args }) {
|
|
86
|
+
const { generateServerPairingCode } = await requireServer();
|
|
87
|
+
await generateServerPairingCode(args.config);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
var installCommand = defineCommand({
|
|
91
|
+
meta: { name: "install", description: "Install as persistent background service" },
|
|
92
|
+
args: {
|
|
93
|
+
config: { type: "string", alias: "c", description: "Config file path" }
|
|
94
|
+
},
|
|
95
|
+
async run({ args }) {
|
|
96
|
+
const { installDaemon } = await requireServer();
|
|
97
|
+
await installDaemon(args.config);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var uninstallCommand = defineCommand({
|
|
101
|
+
meta: { name: "uninstall", description: "Remove background service" },
|
|
102
|
+
async run() {
|
|
103
|
+
const { uninstallDaemon } = await requireServer();
|
|
104
|
+
await uninstallDaemon();
|
|
110
105
|
}
|
|
111
106
|
});
|
|
112
107
|
var wrapCommand = defineCommand({
|
|
@@ -165,10 +160,16 @@ var main = defineCommand({
|
|
|
165
160
|
meta: {
|
|
166
161
|
name: "gigai",
|
|
167
162
|
version: VERSION,
|
|
168
|
-
description: "gigai
|
|
163
|
+
description: "gigai \u2014 bridge CLI tools to Claude"
|
|
169
164
|
},
|
|
170
165
|
subCommands: {
|
|
171
|
-
|
|
166
|
+
init: initCommand,
|
|
167
|
+
start: startCommand,
|
|
168
|
+
stop: stopCommand,
|
|
169
|
+
status: statusCommand,
|
|
170
|
+
pair: pairCommand,
|
|
171
|
+
install: installCommand,
|
|
172
|
+
uninstall: uninstallCommand,
|
|
172
173
|
wrap: wrapCommand,
|
|
173
174
|
unwrap: unwrapCommand,
|
|
174
175
|
version: versionCommand
|