alink-cli 0.10.0 → 0.10.2

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/ui.js CHANGED
@@ -48133,6 +48133,11 @@ var STATE_DIR = process.env.AGENTLINK_STATE_DIR || join(homedir(), ".agentlink")
48133
48133
  var CREDENTIAL_FILE = join(STATE_DIR, "credential");
48134
48134
  var PID_FILE = join(STATE_DIR, "daemon.pid");
48135
48135
  var STATUS_FILE = join(STATE_DIR, "status.json");
48136
+ var DAEMON_LOCK_FILE = join(
48137
+ resolve(process.env.T3CODE_HOME || join(homedir(), ".t3")),
48138
+ "userdata",
48139
+ "daemon.lock"
48140
+ );
48136
48141
  function normalizeHub(hub) {
48137
48142
  const url = new URL(hub);
48138
48143
  if (url.protocol === "http:") url.protocol = "ws:";
@@ -48206,26 +48211,32 @@ function isProcessAlive(pid) {
48206
48211
  return false;
48207
48212
  }
48208
48213
  }
48209
- function daemonPid() {
48214
+ function readPid(path) {
48210
48215
  try {
48211
- const raw = readFileSync2(PID_FILE, "utf8").trim();
48212
- const pid = Number(raw);
48216
+ const raw = readFileSync2(path, "utf8").trim();
48217
+ const pid = raw.startsWith("{") ? Number(JSON.parse(raw).pid) : Number(raw);
48213
48218
  return Number.isInteger(pid) && pid > 0 ? pid : void 0;
48214
48219
  } catch {
48215
48220
  return void 0;
48216
48221
  }
48217
48222
  }
48218
- function isDaemonRunning() {
48219
- const pid = daemonPid();
48220
- if (!pid) return false;
48221
- if (!isProcessAlive(pid)) {
48223
+ function discoverDaemonPid(pidFile = PID_FILE, lockFile = DAEMON_LOCK_FILE) {
48224
+ const managedPid = readPid(pidFile);
48225
+ if (managedPid && isProcessAlive(managedPid)) return managedPid;
48226
+ if (managedPid) {
48222
48227
  try {
48223
- rmSync(PID_FILE, { force: true });
48228
+ rmSync(pidFile, { force: true });
48224
48229
  } catch {
48225
48230
  }
48226
- return false;
48227
48231
  }
48228
- return true;
48232
+ const sharedPid = readPid(lockFile);
48233
+ return sharedPid && isProcessAlive(sharedPid) ? sharedPid : void 0;
48234
+ }
48235
+ function daemonPid() {
48236
+ return discoverDaemonPid();
48237
+ }
48238
+ function isDaemonRunning() {
48239
+ return daemonPid() !== void 0;
48229
48240
  }
48230
48241
  function startDaemon(options) {
48231
48242
  if (isDaemonRunning()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alink-cli",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "一条命令把工作机接入 AgentLink,随时随地遥控本机的编码 agent。One command to link your machine to AgentLink and control your coding agents from anywhere.",
5
5
  "keywords": [
6
6
  "acp",