@codingfrees/uap-device-control 0.2.9 → 0.2.11
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 +16 -0
- package/dist/uap-device-control.mjs +50 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,3 +125,19 @@ The script requires clean package inputs, refuses an already-published version,
|
|
|
125
125
|
## UAP Downloads release candidates
|
|
126
126
|
|
|
127
127
|
The `UAP downloadable product candidates` workflow also builds the Node 26 portable `uap-device-control-remote-<version>.mjs`, its SHA-256 and sanitized provenance from the exact candidate source SHA. This executable JavaScript file **requires Node.js 26**; it is not a signed Windows/macOS native installer and is separate from the existing npm release channel. The private CI artifact is not a public UAP Downloads release. Each approved public release must embed Windows/Linux/macOS download, checksum, login, scoped-root, browser pairing and update/removal instructions in its description; live OS/browser certification and separate publication approval are required.
|
|
128
|
+
|
|
129
|
+
## ChatGPT MCP tool profiles
|
|
130
|
+
|
|
131
|
+
The connected MCP URL controls which tools are advertised and callable. A device-reported capability alone does not make its corresponding ChatGPT tool available.
|
|
132
|
+
|
|
133
|
+
| Connection URL | Profile | Relevant tools |
|
|
134
|
+
| --- | --- | --- |
|
|
135
|
+
| `https://device-control.aemdpc.ro/mcp` | `core` (default) | Device discovery, health, processes, terminal and approvals |
|
|
136
|
+
| `https://device-control.aemdpc.ro/mcp?profile=browser` | `browser` | `list_browser_tabs` and paired-browser operations |
|
|
137
|
+
| `https://device-control.aemdpc.ro/mcp?profile=screen` | `screen` | `list_monitors`, `screenshot`, streams and desktop controls |
|
|
138
|
+
| `https://device-control.aemdpc.ro/mcp?profile=filesystem` | `filesystem` | Root discovery and filesystem operations |
|
|
139
|
+
| `https://device-control.aemdpc.ro/mcp?profile=marketplace` | `marketplace` | All Device Control MCP tools |
|
|
140
|
+
|
|
141
|
+
To enable the advanced tools in ChatGPT, connect an explicit `browser` or `screen` profile, or the `marketplace` profile for the complete surface. The plugin packager supports `--profile browser`, `--profile screen`, and `--profile marketplace`, and embeds the matching URL in `mcp.json`. An existing `core` connection does not gain advanced tools just because the remote device reports those capabilities.
|
|
142
|
+
|
|
143
|
+
Profiles restrict both `tools/list` and `tools/call`; OAuth scopes and device/workspace authorization still apply. Browser reads require a paired browser extension and elevated-access approval; screenshots require a separate approval. Never grant approval automatically during diagnostic checks.
|
|
@@ -60,7 +60,7 @@ import os from "node:os";
|
|
|
60
60
|
import { execFile } from "node:child_process";
|
|
61
61
|
import { promisify } from "node:util";
|
|
62
62
|
import path from "node:path";
|
|
63
|
-
import { link, mkdir, readFile, rm, rename, writeFile } from "node:fs/promises";
|
|
63
|
+
import { link, mkdir, readFile, realpath, rm, rename, writeFile } from "node:fs/promises";
|
|
64
64
|
import { randomUUID } from "node:crypto";
|
|
65
65
|
function defaultDeviceControlStateDirectory(home = os.homedir(), platform = process.platform) {
|
|
66
66
|
if (platform === "win32") return path.join(process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"), "UAP", "DeviceControl");
|
|
@@ -142,7 +142,12 @@ async function verifiedRemoteOwner(pid) {
|
|
|
142
142
|
if (process.platform !== "win32") {
|
|
143
143
|
try {
|
|
144
144
|
const args = (await readFile(`/proc/${pid}/cmdline`)).toString("utf8").split("\0").filter(Boolean);
|
|
145
|
-
|
|
145
|
+
if (!args.includes("remote") || args.includes("--service")) return false;
|
|
146
|
+
for (const arg of args) {
|
|
147
|
+
if (/(?:^|[\\/])uap-device-control\.mjs$/.test(arg)) return true;
|
|
148
|
+
if (/(?:^|[\\/])uap-device-control$/.test(arg) && /(?:^|[\\/])uap-device-control\.mjs$/.test(await realpath(arg))) return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
146
151
|
} catch {
|
|
147
152
|
return false;
|
|
148
153
|
}
|
|
@@ -797,7 +802,7 @@ import WebSocket from "ws";
|
|
|
797
802
|
// package.json
|
|
798
803
|
var package_default = {
|
|
799
804
|
name: "@codingfrees/uap-device-control",
|
|
800
|
-
version: "0.2.
|
|
805
|
+
version: "0.2.11",
|
|
801
806
|
description: "Cross-platform outbound UAP Device Control client",
|
|
802
807
|
type: "module",
|
|
803
808
|
bin: {
|
|
@@ -825,7 +830,7 @@ var package_default = {
|
|
|
825
830
|
// ../device-agent/src/engine.ts
|
|
826
831
|
import { execFile as execFile2, spawn } from "node:child_process";
|
|
827
832
|
import { promisify as promisify2 } from "node:util";
|
|
828
|
-
import { cp, mkdir as mkdir3, open, readdir, realpath, rename as rename2, rm as rm2, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
833
|
+
import { cp, mkdir as mkdir3, open, readdir, realpath as realpath2, rename as rename2, rm as rm2, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
829
834
|
import { realpathSync } from "node:fs";
|
|
830
835
|
import os2 from "node:os";
|
|
831
836
|
import path3 from "node:path";
|
|
@@ -1467,7 +1472,7 @@ async function safeExisting(root2, relative) {
|
|
|
1467
1472
|
if (!inside(root2, lexical)) throw new TypeError("path escapes configured root");
|
|
1468
1473
|
let target;
|
|
1469
1474
|
try {
|
|
1470
|
-
target = await
|
|
1475
|
+
target = await realpath2(lexical);
|
|
1471
1476
|
} catch {
|
|
1472
1477
|
throw new TypeError("device path is unavailable");
|
|
1473
1478
|
}
|
|
@@ -1486,20 +1491,20 @@ async function safeWritable(root2, relative) {
|
|
|
1486
1491
|
for (const part of parts) {
|
|
1487
1492
|
const next = path3.join(parent, part);
|
|
1488
1493
|
try {
|
|
1489
|
-
const resolved = await
|
|
1494
|
+
const resolved = await realpath2(next);
|
|
1490
1495
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1491
1496
|
parent = resolved;
|
|
1492
1497
|
} catch (error) {
|
|
1493
1498
|
if (error instanceof TypeError || !isMissing(error)) throw error;
|
|
1494
1499
|
await mkdir3(next);
|
|
1495
|
-
const resolved = await
|
|
1500
|
+
const resolved = await realpath2(next);
|
|
1496
1501
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1497
1502
|
parent = resolved;
|
|
1498
1503
|
}
|
|
1499
1504
|
}
|
|
1500
1505
|
const target = path3.join(parent, leaf);
|
|
1501
1506
|
try {
|
|
1502
|
-
const resolved = await
|
|
1507
|
+
const resolved = await realpath2(target);
|
|
1503
1508
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1504
1509
|
return resolved;
|
|
1505
1510
|
} catch (error) {
|
|
@@ -1852,7 +1857,7 @@ var WINDOWS_CLIPBOARD_WRITE = "param($text) Add-Type -AssemblyName System.Window
|
|
|
1852
1857
|
|
|
1853
1858
|
// ../device-agent/src/native-services.ts
|
|
1854
1859
|
import { execFile as execFile4 } from "node:child_process";
|
|
1855
|
-
import { realpath as
|
|
1860
|
+
import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
1856
1861
|
import { win32 } from "node:path";
|
|
1857
1862
|
import { promisify as promisify4 } from "node:util";
|
|
1858
1863
|
var execute2 = promisify4(execFile4);
|
|
@@ -1922,7 +1927,7 @@ function parseSystemdService(name, output) {
|
|
|
1922
1927
|
async function firstExecutable(candidates, label) {
|
|
1923
1928
|
for (const candidate of candidates) {
|
|
1924
1929
|
try {
|
|
1925
|
-
const value = await
|
|
1930
|
+
const value = await realpath3(candidate);
|
|
1926
1931
|
if ((await stat2(value)).isFile()) return value;
|
|
1927
1932
|
} catch (error) {
|
|
1928
1933
|
if (!isMissing2(error)) throw error;
|
|
@@ -1952,9 +1957,10 @@ async function runRemote(options) {
|
|
|
1952
1957
|
if (options.allowedServices.length && !services) throw new TypeError("native service control is unavailable");
|
|
1953
1958
|
let refreshSession = () => {
|
|
1954
1959
|
};
|
|
1960
|
+
const browserRefresh = createRefreshScheduler(() => refreshSession());
|
|
1955
1961
|
const browserLog = (event) => {
|
|
1956
1962
|
options.log?.(event);
|
|
1957
|
-
if (event.event === "browser.bridge" && ["paired", "unpaired", "connected", "permissions-granted", "permissions-required"].includes(String(event.status)))
|
|
1963
|
+
if (event.event === "browser.bridge" && ["paired", "unpaired", "connected", "permissions-granted", "permissions-required"].includes(String(event.status))) browserRefresh.schedule();
|
|
1958
1964
|
};
|
|
1959
1965
|
const browserPort = options.browserPort ?? 18700;
|
|
1960
1966
|
const browser = options.browserControl === false ? void 0 : await createBrowserBridge(options.stateDirectory, browserPort, browserLog).catch((error) => {
|
|
@@ -2014,9 +2020,24 @@ async function runRemote(options) {
|
|
|
2014
2020
|
}
|
|
2015
2021
|
}
|
|
2016
2022
|
} finally {
|
|
2023
|
+
browserRefresh.close();
|
|
2017
2024
|
engine.close();
|
|
2018
2025
|
}
|
|
2019
2026
|
}
|
|
2027
|
+
function createRefreshScheduler(refresh, delayMs = 100) {
|
|
2028
|
+
let timer;
|
|
2029
|
+
return {
|
|
2030
|
+
schedule() {
|
|
2031
|
+
if (timer) clearTimeout(timer);
|
|
2032
|
+
timer = setTimeout(refresh, delayMs);
|
|
2033
|
+
timer.unref();
|
|
2034
|
+
},
|
|
2035
|
+
close() {
|
|
2036
|
+
if (timer) clearTimeout(timer);
|
|
2037
|
+
timer = void 0;
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2020
2041
|
function optionalBrowserBridgeFailure(error) {
|
|
2021
2042
|
if (!error || typeof error !== "object" || !("code" in error)) return false;
|
|
2022
2043
|
return ["EADDRINUSE", "EACCES", "EAFNOSUPPORT", "EPROTONOSUPPORT"].includes(String(error.code));
|
|
@@ -2101,6 +2122,15 @@ async function remoteSession(origin, stateDirectory, engine, fetcher = fetch, si
|
|
|
2101
2122
|
return;
|
|
2102
2123
|
}
|
|
2103
2124
|
if (!connected) throw new TypeError("remote socket sent data before connection acknowledgement");
|
|
2125
|
+
if (value.type === "presence-probe") {
|
|
2126
|
+
const probeId = bounded2(value.id, "presence probe id");
|
|
2127
|
+
socket.send(JSON.stringify({ type: "presence-ack", id: probeId }), (error) => {
|
|
2128
|
+
if (!error) return;
|
|
2129
|
+
closeCause = "socket-error";
|
|
2130
|
+
fail(new RemoteUnavailableError(void 0, "/device-control/remote/socket", "transport"));
|
|
2131
|
+
});
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2104
2134
|
if (value.type === "result-ack") {
|
|
2105
2135
|
const requestId = bounded2(value.requestId, "request id");
|
|
2106
2136
|
const pending = acknowledgements.get(requestId);
|
|
@@ -2144,7 +2174,7 @@ async function remoteSession(origin, stateDirectory, engine, fetcher = fetch, si
|
|
|
2144
2174
|
};
|
|
2145
2175
|
socket.on("message", onMessage).on("close", onClose).on("error", onError);
|
|
2146
2176
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2147
|
-
socket.send(JSON.stringify({ type: "hello", device: engine.info() }));
|
|
2177
|
+
socket.send(JSON.stringify({ type: "hello", device: engine.info(), features: ["presence-probe-v1"] }));
|
|
2148
2178
|
});
|
|
2149
2179
|
} finally {
|
|
2150
2180
|
for (const pending of acknowledgements.values()) pending.reject(new RemoteUnavailableError(void 0, "/device-control/remote/socket", "transport"));
|
|
@@ -2642,8 +2672,7 @@ async function runDeviceControlCli(args = process.argv.slice(2)) {
|
|
|
2642
2672
|
signal: controller.signal,
|
|
2643
2673
|
log: (event) => {
|
|
2644
2674
|
output(event);
|
|
2645
|
-
if (event.event === "remote.session" && event.status === "connected")
|
|
2646
|
-
void displayVerifiedIdentity(resolvedOrigin, config.stateDirectory, output);
|
|
2675
|
+
if (event.event === "remote.session" && event.status === "connected") void displayVerifiedIdentity(resolvedOrigin, config.stateDirectory, output);
|
|
2647
2676
|
}
|
|
2648
2677
|
});
|
|
2649
2678
|
} finally {
|
|
@@ -2701,14 +2730,17 @@ function formatCliEvent(event, json2 = false) {
|
|
|
2701
2730
|
}
|
|
2702
2731
|
if (status === "paired") return "\u2705 UAP Browser Extension paired";
|
|
2703
2732
|
if (status === "connected") return "\u{1F310} UAP Browser Extension connected";
|
|
2733
|
+
if (status === "permissions-granted") return "\u2705 UAP Browser Extension access granted";
|
|
2734
|
+
if (status === "permissions-required") return "\u26A0\uFE0F UAP Browser Extension connected \xB7 browser access required";
|
|
2704
2735
|
if (status === "unpaired") return "\u{1F50C} UAP Browser Extension unpaired";
|
|
2705
2736
|
}
|
|
2706
2737
|
if (event.event === "remote.session") {
|
|
2707
2738
|
if (status === "replaced") return "\u267B\uFE0F Previous UAP Remote instance stopped; starting the new session";
|
|
2708
|
-
if (status === "connected")
|
|
2739
|
+
if (status === "connected")
|
|
2740
|
+
return "\u2705 Device connected \xB7 " + String(event.deviceId) + (event.agentVersion ? " \xB7 v" + String(event.agentVersion) : "") + (event.subject ? "\n Server subject: " + String(event.subject) : "") + (event.workspaceId ? "\n Workspace: " + String(event.workspaceId) : "");
|
|
2709
2741
|
if (status === "disconnected") {
|
|
2710
2742
|
const code = Number(event.closeCode);
|
|
2711
|
-
const cause = ["socket-closed", "socket-error", "client-abort", "protocol-error", "result-delivery"].includes(String(event.closeCause)) ? String(event.closeCause) : "";
|
|
2743
|
+
const cause = ["socket-closed", "socket-error", "client-abort", "protocol-error", "result-delivery", "presence-timeout"].includes(String(event.closeCause)) ? String(event.closeCause) : "";
|
|
2712
2744
|
const uptime = Number(event.uptimeMs);
|
|
2713
2745
|
return "\u{1F50C} Device disconnected \xB7 " + String(event.deviceId) + (Number.isInteger(code) && code >= 1e3 && code <= 4999 ? " \xB7 WS " + code : "") + (cause ? " \xB7 " + cause : "") + (Number.isInteger(uptime) && uptime >= 0 && uptime <= 864e5 ? " \xB7 uptime " + uptime + " ms" : "");
|
|
2714
2746
|
}
|
|
@@ -2720,7 +2752,8 @@ function formatCliEvent(event, json2 = false) {
|
|
|
2720
2752
|
return "Open this URL in a browser and explicitly approve this computer:\n" + String(event.url) + "\nIf using WSL2, open the link in Windows and keep this terminal running for the localhost callback.\nAlternatively, run login --pairing-code <code>.";
|
|
2721
2753
|
if (status === "connecting") return "\u{1F310} Connecting to " + String(event.origin) + " \xB7 " + String(event.platform);
|
|
2722
2754
|
if (status === "authenticated") return "\u2705 Authenticated \xB7 " + String(event.origin);
|
|
2723
|
-
if (status === "account-switched")
|
|
2755
|
+
if (status === "account-switched")
|
|
2756
|
+
return "\u2705 Account authorization replaced \xB7 " + String(event.origin) + (event.oldAuthorizationRevoked === false ? "\n\u26A0\uFE0F Prior authorization revocation could not be confirmed; revoke the old session in the account console" : " \xB7 previous authorization revoked");
|
|
2724
2757
|
if (status === "logged-out") return "\u2705 Logged out";
|
|
2725
2758
|
if (status === "browser-pairing-reset") return "\u2705 Browser pairing reset \xB7 run remote again to get a new pairing code";
|
|
2726
2759
|
if (status === "not-logged-in") return "\u26A0\uFE0F Not logged in";
|