@codingfrees/uap-device-control 0.1.9 → 0.1.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/README.md +4 -0
- package/dist/uap-device-control.mjs +51 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ npx @codingfrees/uap-device-control@latest install-service
|
|
|
72
72
|
|
|
73
73
|
The same runtime is persisted using the platform adapter (Windows scheduled startup, Linux systemd user service, macOS launchd).
|
|
74
74
|
|
|
75
|
+
The `install-service` command refuses to install a second persistent Remote if an installed Runner V2 is detected on Windows or Linux; temporary `remote` mode remains independent. Service installation stages the runtime atomically and retains a `.previous` copy for rollback if registration fails. This is not a signed automatic update channel; npm publishing and OS-service updating remain separate lifecycles.
|
|
76
|
+
|
|
75
77
|
## npm client versus ChatGPT MCP
|
|
76
78
|
|
|
77
79
|
The npm client does **not** use MCP as its device transport. It needs the public UAP origin for OAuth and the outbound Device Control routes under `/device-control/remote/*`.
|
|
@@ -92,4 +94,6 @@ pnpm publish:public
|
|
|
92
94
|
|
|
93
95
|
Validate the exact release without publishing with `pnpm publish:public -- --dry-run`.
|
|
94
96
|
|
|
97
|
+
For `npm whoami` HTTP 401 in Linux/WSL, renew authentication locally using `npm login --registry=https://registry.npmjs.org/ --auth-type=web`, then confirm `npm whoami`. Do not paste credentials into issue reports or logs. npm versions are immutable: bump the package version and commit a clean tree before publishing.
|
|
98
|
+
|
|
95
99
|
The script requires a clean repository, refuses an already-published version, builds and dry-runs the package, then calls npm publish and verifies the registry version plus the `latest` dist-tag. npm account 2FA remains mandatory and is handled by npm during the publish step.
|
|
@@ -407,7 +407,7 @@ import path4 from "node:path";
|
|
|
407
407
|
// package.json
|
|
408
408
|
var package_default = {
|
|
409
409
|
name: "@codingfrees/uap-device-control",
|
|
410
|
-
version: "0.1.
|
|
410
|
+
version: "0.1.10",
|
|
411
411
|
description: "Cross-platform outbound UAP Device Control client",
|
|
412
412
|
type: "module",
|
|
413
413
|
bin: {
|
|
@@ -1944,23 +1944,66 @@ function sleep2(ms, signal) {
|
|
|
1944
1944
|
// src/service.ts
|
|
1945
1945
|
import os4 from "node:os";
|
|
1946
1946
|
import path5 from "node:path";
|
|
1947
|
-
import { chmod, copyFile, mkdir as mkdir4, writeFile as writeFile4 } from "node:fs/promises";
|
|
1947
|
+
import { chmod, copyFile, mkdir as mkdir4, rename as rename3, rm as rm3, writeFile as writeFile4 } from "node:fs/promises";
|
|
1948
|
+
import { existsSync } from "node:fs";
|
|
1948
1949
|
import { execFile as execFile4 } from "node:child_process";
|
|
1949
1950
|
import { promisify as promisify4 } from "node:util";
|
|
1950
1951
|
var execute4 = promisify4(execFile4);
|
|
1951
1952
|
async function installRemoteService(origin, stateDirectory) {
|
|
1953
|
+
if (await runnerV2Installed()) throw new TypeError("Runner V2 is installed; use its Device Control provider instead of installing a duplicate Remote service");
|
|
1952
1954
|
const command = process.execPath;
|
|
1953
1955
|
const source = process.argv[1];
|
|
1954
1956
|
if (!source) throw new TypeError("CLI executable path is unavailable");
|
|
1955
1957
|
await mkdir4(stateDirectory, { recursive: true, mode: 448 });
|
|
1956
1958
|
const script = path5.join(stateDirectory, "uap-device-control.mjs");
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
+
const staged = script + ".pending-" + process.pid;
|
|
1960
|
+
const previous = script + ".previous";
|
|
1959
1961
|
const args = [script, "remote", "--origin", origin, "--state-dir", stateDirectory, "--service"];
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1962
|
+
try {
|
|
1963
|
+
await copyFile(source, staged);
|
|
1964
|
+
if (process.platform !== "win32") await chmod(staged, 448);
|
|
1965
|
+
if (existsSync(script)) await copyFile(script, previous);
|
|
1966
|
+
await rename3(staged, script);
|
|
1967
|
+
try {
|
|
1968
|
+
if (process.platform === "linux") return await installSystemd(command, args);
|
|
1969
|
+
if (process.platform === "darwin") return await installLaunchd(command, args);
|
|
1970
|
+
if (process.platform === "win32") return await installWindowsTask(command, args);
|
|
1971
|
+
throw new TypeError("service installation is unsupported on this platform");
|
|
1972
|
+
} catch (error) {
|
|
1973
|
+
if (existsSync(previous)) await copyFile(previous, script);
|
|
1974
|
+
throw error;
|
|
1975
|
+
}
|
|
1976
|
+
} finally {
|
|
1977
|
+
await rm3(staged, { force: true }).catch(() => void 0);
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
async function runnerV2Installed(platform = process.platform, run = execute4, exists2 = existsSync) {
|
|
1981
|
+
if (platform === "linux") {
|
|
1982
|
+
if (exists2("/opt/uap-local-node-runner-v2/current")) return true;
|
|
1983
|
+
for (const args of [
|
|
1984
|
+
["list-unit-files", "uap-local-node-runner-v2.service", "--no-legend"],
|
|
1985
|
+
["--user", "list-unit-files", "uap-local-node-runner-v2.service", "--no-legend"]
|
|
1986
|
+
]) {
|
|
1987
|
+
try {
|
|
1988
|
+
const result = await run("systemctl", args);
|
|
1989
|
+
if (/^uap-local-node-runner-v2\.service\s/m.test(result.stdout)) return true;
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
if (platform === "win32") {
|
|
1995
|
+
for (const [command, args] of [
|
|
1996
|
+
["sc.exe", ["query", "UAPLocalNodeRunnerV2"]],
|
|
1997
|
+
["schtasks.exe", ["/Query", "/TN", "UAPLocalNodeRunnerV2"]]
|
|
1998
|
+
]) {
|
|
1999
|
+
try {
|
|
2000
|
+
await run(command, [...args]);
|
|
2001
|
+
return true;
|
|
2002
|
+
} catch {
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
return false;
|
|
1964
2007
|
}
|
|
1965
2008
|
async function installSystemd(command, args) {
|
|
1966
2009
|
const directory = path5.join(os4.homedir(), ".config", "systemd", "user");
|