ultracontext 1.4.9 → 1.4.10
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/entry.mjs
CHANGED
|
@@ -315,7 +315,7 @@ async function launchSyncDaemon() {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
async function runCtlSDK() {
|
|
318
|
-
const { runCtl } = await import("../ctl-
|
|
318
|
+
const { runCtl } = await import("../ctl-CXfNEPN8.mjs");
|
|
319
319
|
await runCtl();
|
|
320
320
|
}
|
|
321
321
|
async function launchTui() {
|
|
@@ -99,31 +99,23 @@ async function runCtl() {
|
|
|
99
99
|
const cmd = String(process.argv[2] ?? "status").trim().toLowerCase();
|
|
100
100
|
const lockPath = path.resolve(resolveLockPath(process.env));
|
|
101
101
|
const infoPath = path.resolve(resolveDaemonInfoFile(process.env));
|
|
102
|
-
if (cmd === "status") {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
if (cmd === "stop") {
|
|
111
|
-
const code = await stop({
|
|
112
|
-
lockPath,
|
|
113
|
-
infoPath
|
|
114
|
-
});
|
|
115
|
-
process.exit(code);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
102
|
+
if (cmd === "status") return status({
|
|
103
|
+
lockPath,
|
|
104
|
+
infoPath
|
|
105
|
+
});
|
|
106
|
+
if (cmd === "stop") return stop({
|
|
107
|
+
lockPath,
|
|
108
|
+
infoPath
|
|
109
|
+
});
|
|
118
110
|
console.error(`Invalid command: ${cmd}`);
|
|
119
111
|
console.error("Use: ultracontext [status|stop]");
|
|
120
|
-
|
|
112
|
+
return 1;
|
|
121
113
|
}
|
|
122
|
-
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, ""))) runCtl().catch((error) => {
|
|
114
|
+
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, ""))) runCtl().then((code) => process.exit(code)).catch((error) => {
|
|
123
115
|
console.error(`Daemon control failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
124
116
|
process.exit(1);
|
|
125
117
|
});
|
|
126
118
|
|
|
127
119
|
//#endregion
|
|
128
120
|
export { runCtl };
|
|
129
|
-
//# sourceMappingURL=ctl-
|
|
121
|
+
//# sourceMappingURL=ctl-CXfNEPN8.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ctl-
|
|
1
|
+
{"version":3,"file":"ctl-CXfNEPN8.mjs","names":[],"sources":["../../sync/src/ctl.mjs"],"sourcesContent":["// daemon ctl — status/stop commands, exported as runCtl()\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport process from \"node:process\";\n\nimport { resolveDaemonInfoFile } from \"./protocol.mjs\";\n\nimport { resolveLockPath } from \"./lock.mjs\";\n\nfunction isPidAlive(pid) {\n if (!Number.isInteger(pid) || pid <= 1) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n if (error?.code === \"EPERM\") return true;\n if (error?.code === \"ESRCH\") return false;\n return false;\n }\n}\n\nasync function readJsonFile(filePath) {\n try {\n const raw = await fs.readFile(filePath, \"utf8\");\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === \"object\" ? parsed : null;\n } catch {\n return null;\n }\n}\n\nasync function removeFileIfExists(filePath) {\n try { await fs.unlink(filePath); } catch { /* ignore */ }\n}\n\nfunction pickPid(lock, info) {\n const lockPid = Number.parseInt(String(lock?.pid ?? \"\"), 10);\n if (Number.isInteger(lockPid) && lockPid > 1) return lockPid;\n const infoPid = Number.parseInt(String(info?.pid ?? \"\"), 10);\n if (Number.isInteger(infoPid) && infoPid > 1) return infoPid;\n return 0;\n}\n\n// ── ANSI helpers ────────────────────────────────────────────────\n\nconst isTTY = process.stdout.isTTY;\nconst esc = (code) => (isTTY ? `\\x1b[${code}m` : \"\");\nconst r = esc(0);\nconst b = esc(1);\nconst d = esc(2);\nconst blue = esc(\"38;2;47;111;179\");\nconst green = esc(\"38;2;80;200;120\");\nconst red = esc(\"38;2;220;80;80\");\nconst gray = esc(\"38;5;245\");\n\n// ── commands ────────────────────────────────────────────────────\n\nasync function status({ lockPath, infoPath }) {\n const lock = await readJsonFile(lockPath);\n const info = await readJsonFile(infoPath);\n const pid = pickPid(lock, info);\n\n console.log(\"\");\n console.log(` ${blue}${b}UltraContext${r} ${d}Daemon${r}`);\n console.log(\"\");\n\n if (!isPidAlive(pid)) {\n console.log(` ${gray}○${r} ${d}Offline${r}`);\n console.log(\"\");\n return 0;\n }\n\n const port = Number.parseInt(String(info?.port ?? \"\"), 10);\n const portStr = Number.isInteger(port) && port > 0 ? ` ${gray}Port ${port}${r}` : \"\";\n const sinceStr = info?.startedAt ? ` ${gray}Since ${info.startedAt}${r}` : \"\";\n console.log(` ${green}●${r} ${b}Online${r} ${gray}PID ${pid}${r}${portStr}`);\n if (sinceStr) console.log(` ${sinceStr}`);\n console.log(\"\");\n return 0;\n}\n\nasync function stop({ lockPath, infoPath }) {\n const lock = await readJsonFile(lockPath);\n const info = await readJsonFile(infoPath);\n const pid = pickPid(lock, info);\n\n console.log(\"\");\n console.log(` ${blue}${b}UltraContext${r} ${d}Daemon${r}`);\n console.log(\"\");\n\n if (!isPidAlive(pid)) {\n await removeFileIfExists(lockPath);\n await removeFileIfExists(infoPath);\n console.log(` ${gray}○${r} ${d}Already stopped${r}`);\n console.log(\"\");\n return 0;\n }\n\n process.kill(pid, \"SIGTERM\");\n\n const deadline = Date.now() + 5000;\n while (Date.now() < deadline) {\n if (!isPidAlive(pid)) break;\n await new Promise((resolve) => setTimeout(resolve, 120));\n }\n\n if (isPidAlive(pid)) {\n console.error(` ${red}✕${r} ${b}Timed out${r} ${gray}PID ${pid} still running${r}`);\n console.error(\"\");\n return 1;\n }\n\n await removeFileIfExists(lockPath);\n await removeFileIfExists(infoPath);\n console.log(` ${green}✓${r} ${b}Stopped${r} ${gray}PID ${pid}${r}`);\n console.log(\"\");\n return 0;\n}\n\n// ── exported entry point ────────────────────────────────────────\n\nexport async function runCtl() {\n const cmd = String(process.argv[2] ?? \"status\").trim().toLowerCase();\n const lockPath = path.resolve(resolveLockPath(process.env));\n const infoPath = path.resolve(resolveDaemonInfoFile(process.env));\n\n if (cmd === \"status\") return status({ lockPath, infoPath });\n if (cmd === \"stop\") return stop({ lockPath, infoPath });\n\n console.error(`Invalid command: ${cmd}`);\n console.error(\"Use: ultracontext [status|stop]\");\n return 1;\n}\n\n// auto-exec when run directly\nconst isDirectRun = process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\\//, \"\"));\nif (isDirectRun) {\n runCtl().then((code) => process.exit(code)).catch((error) => {\n console.error(`Daemon control failed: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;AASA,SAAS,WAAW,KAAK;AACvB,KAAI,CAAC,OAAO,UAAU,IAAI,IAAI,OAAO,EAAG,QAAO;AAC/C,KAAI;AACF,UAAQ,KAAK,KAAK,EAAE;AACpB,SAAO;UACA,OAAO;AACd,MAAI,OAAO,SAAS,QAAS,QAAO;AACpC,MAAI,OAAO,SAAS,QAAS,QAAO;AACpC,SAAO;;;AAIX,eAAe,aAAa,UAAU;AACpC,KAAI;EACF,MAAM,MAAM,MAAM,GAAG,SAAS,UAAU,OAAO;EAC/C,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,SAAO,UAAU,OAAO,WAAW,WAAW,SAAS;SACjD;AACN,SAAO;;;AAIX,eAAe,mBAAmB,UAAU;AAC1C,KAAI;AAAE,QAAM,GAAG,OAAO,SAAS;SAAU;;AAG3C,SAAS,QAAQ,MAAM,MAAM;CAC3B,MAAM,UAAU,OAAO,SAAS,OAAO,MAAM,OAAO,GAAG,EAAE,GAAG;AAC5D,KAAI,OAAO,UAAU,QAAQ,IAAI,UAAU,EAAG,QAAO;CACrD,MAAM,UAAU,OAAO,SAAS,OAAO,MAAM,OAAO,GAAG,EAAE,GAAG;AAC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