linkshell-cli 0.10.52 → 0.10.53
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/cli/src/commands/desktop-workspace.js +11 -1
- package/dist/cli/src/commands/desktop-workspace.js.map +1 -1
- package/dist/cli/src/commands/desktop.js +2 -2
- package/dist/cli/src/commands/desktop.js.map +1 -1
- package/dist/cli/src/commands/host.d.ts +6 -0
- package/dist/cli/src/commands/host.js +25 -0
- package/dist/cli/src/commands/host.js.map +1 -1
- package/dist/cli/src/utils/daemon.js +7 -1
- package/dist/cli/src/utils/daemon.js.map +1 -1
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/host/src/drivers/acp/client-services.js +7 -5
- package/dist/host/src/drivers/acp/client-services.js.map +1 -1
- package/dist/host/src/drivers/acp/mcp.js +8 -5
- package/dist/host/src/drivers/acp/mcp.js.map +1 -1
- package/dist/host/src/drivers/claude/holders.d.ts +2 -0
- package/dist/host/src/drivers/claude/holders.js +34 -0
- package/dist/host/src/drivers/claude/holders.js.map +1 -1
- package/dist/host/src/process.d.ts +2 -0
- package/dist/host/src/process.js +4 -0
- package/dist/host/src/process.js.map +1 -1
- package/dist/host/src/shell-env.d.ts +2 -0
- package/dist/host/src/shell-env.js +41 -1
- package/dist/host/src/shell-env.js.map +1 -1
- package/dist/host/src/store.js +3 -2
- package/dist/host/src/store.js.map +1 -1
- package/dist/host/src/worktrees.js +2 -1
- package/dist/host/src/worktrees.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/desktop-workspace.ts +10 -1
- package/src/commands/desktop.ts +2 -2
- package/src/commands/host.ts +22 -0
- package/src/utils/daemon.ts +7 -1
package/src/commands/host.ts
CHANGED
|
@@ -205,6 +205,28 @@ export function describeGateway(gateway: GatewayStatus): string {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/** After `linkshell login`: this computer joins the gateway its account is for. */
|
|
208
|
+
/**
|
|
209
|
+
* A signed-in Pro account's computer belongs on the official gateway: nobody should have to find
|
|
210
|
+
* a button for it before their phone can see this computer. A gateway of one's own (a URL) is kept;
|
|
211
|
+
* "off" is not. A stopped host is left stopped. True when the host was asked to reconnect.
|
|
212
|
+
*/
|
|
213
|
+
export async function followAccountGateway(plan: "pro" | "free" | "unknown"): Promise<boolean> {
|
|
214
|
+
if (plan !== "pro" || process.env.LINKSHELL_GATEWAY || !loadAuth()?.userId || !hostRuntimeOk()) return false;
|
|
215
|
+
const home = daemon.linkshellDir();
|
|
216
|
+
const config = readHostConfig(home);
|
|
217
|
+
if (config.gateway && config.gateway !== "off") return false;
|
|
218
|
+
const turnedOff = config.gateway === "off";
|
|
219
|
+
if (turnedOff) {
|
|
220
|
+
delete config.gateway;
|
|
221
|
+
writeHostConfig(home, config);
|
|
222
|
+
}
|
|
223
|
+
const status = await withRunningHost((client) => client.call("gateway.status", {}, 5000)).catch(() => undefined);
|
|
224
|
+
if (!status) return false;
|
|
225
|
+
if (!turnedOff && status.status !== "off" && sameGateway(status.url, OFFICIAL_GATEWAY)) return false;
|
|
226
|
+
await refreshGateway(15_000);
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
|
|
208
230
|
export async function joinGatewayAfterLogin(plan: "pro" | "free"): Promise<void> {
|
|
209
231
|
const out = (line: string) => process.stderr.write(` ${line}\n`);
|
|
210
232
|
if (!hostRuntimeOk()) {
|
package/src/utils/daemon.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { homedir } from "node:os";
|
|
3
|
+
import { homedir, uptime } from "node:os";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
|
|
6
6
|
const LINKSHELL_DIR = process.env.LINKSHELL_HOME || join(homedir(), ".linkshell");
|
|
@@ -66,6 +66,12 @@ export function readPid(service: ServiceName): number | null {
|
|
|
66
66
|
if (!existsSync(file)) return null;
|
|
67
67
|
const pid = Number(readFileSync(file, "utf8").trim());
|
|
68
68
|
if (!Number.isSafeInteger(pid) || pid <= 0) return null;
|
|
69
|
+
// Written before the computer last started (a logoff or power cut left it): whatever runs under
|
|
70
|
+
// that pid now is some other process, and believing it would keep the host from being started.
|
|
71
|
+
if (statSync(file).mtimeMs < Date.now() - uptime() * 1000 - 60_000) {
|
|
72
|
+
removePid(service);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
69
75
|
try {
|
|
70
76
|
process.kill(pid, 0);
|
|
71
77
|
return pid;
|