@codingfrees/uap-device-control 0.2.8 → 0.2.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 +34 -0
- package/dist/uap-device-control.mjs +110 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,24 @@ npx @codingfrees/uap-device-control@latest status
|
|
|
68
68
|
|
|
69
69
|
`status` reports the local device identity, authentication state and remote presence when authenticated.
|
|
70
70
|
|
|
71
|
+
## Account identity and switching
|
|
72
|
+
|
|
73
|
+
Use `whoami` to inspect the account name, subject and workspace **verified by the relay**, not inferred from stored token content:
|
|
74
|
+
|
|
75
|
+
```powershell
|
|
76
|
+
npx @codingfrees/uap-device-control@latest whoami
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
To move a Windows device from one account to another, stop the current `remote` process or installed service, then run:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
npx @codingfrees/uap-device-control@latest switch-account
|
|
83
|
+
npx @codingfrees/uap-device-control@latest whoami
|
|
84
|
+
npx @codingfrees/uap-device-control@latest remote
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
During the OAuth browser step, sign in to the **intended** account, not the existing browser session. Alternatively, generate a single-use pairing code for the intended user in the Device Control admin console and pass it to `switch-account --pairing-code <code>`. The device ID and browser pairing state are preserved. The prior refresh credential is revoked **after** a successful new login; if revocation cannot be confirmed, the CLI displays a warning. A failed new login leaves the old authorization intact. The relay and CLI must both support the identity endpoint to display verified identity; otherwise `whoami` explicitly reports that verification is unavailable instead of guessing.
|
|
88
|
+
|
|
71
89
|
## Persistent service
|
|
72
90
|
|
|
73
91
|
After login:
|
|
@@ -107,3 +125,19 @@ The script requires clean package inputs, refuses an already-published version,
|
|
|
107
125
|
## UAP Downloads release candidates
|
|
108
126
|
|
|
109
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
|
}
|
|
@@ -299,6 +304,20 @@ async function accessToken(stateDirectory, fetcher = fetch, forceRefresh = false
|
|
|
299
304
|
return { auth: next, token: next.accessToken };
|
|
300
305
|
});
|
|
301
306
|
}
|
|
307
|
+
async function revokePreviousRemoteAuthorization(previous, fetcher = fetch) {
|
|
308
|
+
try {
|
|
309
|
+
const response = await fetcher(new URL("/oauth/revoke", previous.origin), {
|
|
310
|
+
method: "POST",
|
|
311
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
312
|
+
body: new URLSearchParams({ client_id: previous.clientId, token: previous.refreshToken, resource: previous.origin + "/mcp" }),
|
|
313
|
+
redirect: "error",
|
|
314
|
+
signal: AbortSignal.timeout(1e4)
|
|
315
|
+
});
|
|
316
|
+
return response.ok;
|
|
317
|
+
} catch {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
302
321
|
async function logoutDeviceControl(stateDirectory, fetcher = fetch) {
|
|
303
322
|
const auth = await loadRemoteAuth(stateDirectory);
|
|
304
323
|
if (!auth) return false;
|
|
@@ -783,7 +802,7 @@ import WebSocket from "ws";
|
|
|
783
802
|
// package.json
|
|
784
803
|
var package_default = {
|
|
785
804
|
name: "@codingfrees/uap-device-control",
|
|
786
|
-
version: "0.2.
|
|
805
|
+
version: "0.2.10",
|
|
787
806
|
description: "Cross-platform outbound UAP Device Control client",
|
|
788
807
|
type: "module",
|
|
789
808
|
bin: {
|
|
@@ -811,7 +830,7 @@ var package_default = {
|
|
|
811
830
|
// ../device-agent/src/engine.ts
|
|
812
831
|
import { execFile as execFile2, spawn } from "node:child_process";
|
|
813
832
|
import { promisify as promisify2 } from "node:util";
|
|
814
|
-
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";
|
|
815
834
|
import { realpathSync } from "node:fs";
|
|
816
835
|
import os2 from "node:os";
|
|
817
836
|
import path3 from "node:path";
|
|
@@ -1103,7 +1122,7 @@ var DeviceAgentEngine = class {
|
|
|
1103
1122
|
const process2 = this.#spawn(input, false, workspaceId);
|
|
1104
1123
|
process2.capability = "terminal.exec";
|
|
1105
1124
|
this.#oneShots.set(process2.id, process2);
|
|
1106
|
-
const timeoutMs = bounded(Number(input.timeoutMs ?? 3e4), 100,
|
|
1125
|
+
const timeoutMs = bounded(Number(input.timeoutMs ?? 3e4), 100, 3e5, "command timeout");
|
|
1107
1126
|
try {
|
|
1108
1127
|
const timedOut = await new Promise((resolve) => {
|
|
1109
1128
|
const timer = setTimeout(() => {
|
|
@@ -1453,7 +1472,7 @@ async function safeExisting(root2, relative) {
|
|
|
1453
1472
|
if (!inside(root2, lexical)) throw new TypeError("path escapes configured root");
|
|
1454
1473
|
let target;
|
|
1455
1474
|
try {
|
|
1456
|
-
target = await
|
|
1475
|
+
target = await realpath2(lexical);
|
|
1457
1476
|
} catch {
|
|
1458
1477
|
throw new TypeError("device path is unavailable");
|
|
1459
1478
|
}
|
|
@@ -1472,20 +1491,20 @@ async function safeWritable(root2, relative) {
|
|
|
1472
1491
|
for (const part of parts) {
|
|
1473
1492
|
const next = path3.join(parent, part);
|
|
1474
1493
|
try {
|
|
1475
|
-
const resolved = await
|
|
1494
|
+
const resolved = await realpath2(next);
|
|
1476
1495
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1477
1496
|
parent = resolved;
|
|
1478
1497
|
} catch (error) {
|
|
1479
1498
|
if (error instanceof TypeError || !isMissing(error)) throw error;
|
|
1480
1499
|
await mkdir3(next);
|
|
1481
|
-
const resolved = await
|
|
1500
|
+
const resolved = await realpath2(next);
|
|
1482
1501
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1483
1502
|
parent = resolved;
|
|
1484
1503
|
}
|
|
1485
1504
|
}
|
|
1486
1505
|
const target = path3.join(parent, leaf);
|
|
1487
1506
|
try {
|
|
1488
|
-
const resolved = await
|
|
1507
|
+
const resolved = await realpath2(target);
|
|
1489
1508
|
if (!inside(root2, resolved)) throw new TypeError("path escapes configured root");
|
|
1490
1509
|
return resolved;
|
|
1491
1510
|
} catch (error) {
|
|
@@ -1838,7 +1857,7 @@ var WINDOWS_CLIPBOARD_WRITE = "param($text) Add-Type -AssemblyName System.Window
|
|
|
1838
1857
|
|
|
1839
1858
|
// ../device-agent/src/native-services.ts
|
|
1840
1859
|
import { execFile as execFile4 } from "node:child_process";
|
|
1841
|
-
import { realpath as
|
|
1860
|
+
import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
1842
1861
|
import { win32 } from "node:path";
|
|
1843
1862
|
import { promisify as promisify4 } from "node:util";
|
|
1844
1863
|
var execute2 = promisify4(execFile4);
|
|
@@ -1908,7 +1927,7 @@ function parseSystemdService(name, output) {
|
|
|
1908
1927
|
async function firstExecutable(candidates, label) {
|
|
1909
1928
|
for (const candidate of candidates) {
|
|
1910
1929
|
try {
|
|
1911
|
-
const value = await
|
|
1930
|
+
const value = await realpath3(candidate);
|
|
1912
1931
|
if ((await stat2(value)).isFile()) return value;
|
|
1913
1932
|
} catch (error) {
|
|
1914
1933
|
if (!isMissing2(error)) throw error;
|
|
@@ -2076,10 +2095,26 @@ async function remoteSession(origin, stateDirectory, engine, fetcher = fetch, si
|
|
|
2076
2095
|
const value = socketMessage(data);
|
|
2077
2096
|
if (value.type === "connected") {
|
|
2078
2097
|
connected = true;
|
|
2079
|
-
log?.({
|
|
2098
|
+
log?.({
|
|
2099
|
+
event: "remote.session",
|
|
2100
|
+
status: "connected",
|
|
2101
|
+
deviceId,
|
|
2102
|
+
agentVersion: UAP_DEVICE_CONTROL_AGENT_VERSION,
|
|
2103
|
+
workspaceId: bounded2(value.workspaceId, "workspace id"),
|
|
2104
|
+
...value.subject === void 0 ? {} : { subject: bounded2(value.subject, "account subject") }
|
|
2105
|
+
});
|
|
2080
2106
|
return;
|
|
2081
2107
|
}
|
|
2082
2108
|
if (!connected) throw new TypeError("remote socket sent data before connection acknowledgement");
|
|
2109
|
+
if (value.type === "presence-probe") {
|
|
2110
|
+
const probeId = bounded2(value.id, "presence probe id");
|
|
2111
|
+
socket.send(JSON.stringify({ type: "presence-ack", id: probeId }), (error) => {
|
|
2112
|
+
if (!error) return;
|
|
2113
|
+
closeCause = "socket-error";
|
|
2114
|
+
fail(new RemoteUnavailableError(void 0, "/device-control/remote/socket", "transport"));
|
|
2115
|
+
});
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2083
2118
|
if (value.type === "result-ack") {
|
|
2084
2119
|
const requestId = bounded2(value.requestId, "request id");
|
|
2085
2120
|
const pending = acknowledgements.get(requestId);
|
|
@@ -2123,7 +2158,7 @@ async function remoteSession(origin, stateDirectory, engine, fetcher = fetch, si
|
|
|
2123
2158
|
};
|
|
2124
2159
|
socket.on("message", onMessage).on("close", onClose).on("error", onError);
|
|
2125
2160
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2126
|
-
socket.send(JSON.stringify({ type: "hello", device: engine.info() }));
|
|
2161
|
+
socket.send(JSON.stringify({ type: "hello", device: engine.info(), features: ["presence-probe-v1"] }));
|
|
2127
2162
|
});
|
|
2128
2163
|
} finally {
|
|
2129
2164
|
for (const pending of acknowledgements.values()) pending.reject(new RemoteUnavailableError(void 0, "/device-control/remote/socket", "transport"));
|
|
@@ -2247,6 +2282,14 @@ async function authorizedRequest(fetcher, origin, stateDirectory, pathname, body
|
|
|
2247
2282
|
return send2(true);
|
|
2248
2283
|
}
|
|
2249
2284
|
}
|
|
2285
|
+
async function remoteIdentity(origin, stateDirectory, fetcher = fetch) {
|
|
2286
|
+
const value = await authorizedRequest(fetcher, origin, stateDirectory, "/device-control/remote/identity", {});
|
|
2287
|
+
const subject = bounded2(value.subject, "account subject");
|
|
2288
|
+
const workspaceId = bounded2(value.workspaceId, "workspace id");
|
|
2289
|
+
const accountName = typeof value.accountName === "string" && value.accountName.length <= 256 && value.accountName.trim() && !/[\x00-\x1f\x7f-\x9f]/.test(value.accountName) ? value.accountName : subject;
|
|
2290
|
+
const accountEmail = typeof value.accountEmail === "string" && value.accountEmail.length <= 320 && /^[^\s@\x00-\x1f\x7f-\x9f]+@[^\s@\x00-\x1f\x7f-\x9f]+$/.test(value.accountEmail) ? value.accountEmail : void 0;
|
|
2291
|
+
return { subject, workspaceId, accountName, ...accountEmail ? { accountEmail } : {} };
|
|
2292
|
+
}
|
|
2250
2293
|
async function remoteStatus(origin, stateDirectory, deviceId, fetcher = fetch) {
|
|
2251
2294
|
const value = await authorizedRequest(fetcher, origin, stateDirectory, "/device-control/remote/status", { deviceId });
|
|
2252
2295
|
if (typeof value.online !== "boolean") throw new TypeError("remote status response is invalid");
|
|
@@ -2457,7 +2500,7 @@ function xml(value) {
|
|
|
2457
2500
|
var DEFAULT_DEVICE_CONTROL_ORIGIN = "https://device-control.aemdpc.ro";
|
|
2458
2501
|
function parseDeviceControlArguments(args, cwd = process.cwd()) {
|
|
2459
2502
|
const command = !args.length || args.includes("--help") || args.includes("-h") || args[0] === "help" ? "help" : args[0];
|
|
2460
|
-
if (!["help", "remote", "status", "login", "logout", "browser-reset", "install-service"].includes(command ?? "")) throw new TypeError("unknown command; run uap-device-control help");
|
|
2503
|
+
if (!["help", "remote", "status", "whoami", "login", "switch-account", "logout", "browser-reset", "install-service"].includes(command ?? "")) throw new TypeError("unknown command; run uap-device-control help");
|
|
2461
2504
|
let origin = process.env.UAP_DEVICE_CONTROL_ORIGIN;
|
|
2462
2505
|
let pairingCode;
|
|
2463
2506
|
let stateDirectory = defaultDeviceControlStateDirectory();
|
|
@@ -2527,6 +2570,33 @@ async function runDeviceControlCli(args = process.argv.slice(2)) {
|
|
|
2527
2570
|
}
|
|
2528
2571
|
});
|
|
2529
2572
|
output({ status: "authenticated", origin: auth.origin });
|
|
2573
|
+
await displayVerifiedIdentity(auth.origin, config.stateDirectory, output);
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
if (config.command === "switch-account") {
|
|
2577
|
+
const lease2 = await acquireRemoteProcessLock(config.stateDirectory);
|
|
2578
|
+
try {
|
|
2579
|
+
const prior = await loadRemoteAuth(config.stateDirectory);
|
|
2580
|
+
const next = await loginDeviceControl(resolvedOrigin, config.stateDirectory, {
|
|
2581
|
+
pairingCode: config.pairingCode,
|
|
2582
|
+
onAuthorizationUrl: (url) => {
|
|
2583
|
+
output({ event: "oauth.browser", status: "authorization-required", url });
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
const revoked = prior ? await revokePreviousRemoteAuthorization(prior) : true;
|
|
2587
|
+
output({ status: "account-switched", origin: next.origin, oldAuthorizationRevoked: revoked });
|
|
2588
|
+
await displayVerifiedIdentity(next.origin, config.stateDirectory, output);
|
|
2589
|
+
} finally {
|
|
2590
|
+
await lease2.release();
|
|
2591
|
+
}
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
if (config.command === "whoami") {
|
|
2595
|
+
if (!existingAuth) {
|
|
2596
|
+
output({ status: "not-logged-in" });
|
|
2597
|
+
return;
|
|
2598
|
+
}
|
|
2599
|
+
await displayVerifiedIdentity(resolvedOrigin, config.stateDirectory, output);
|
|
2530
2600
|
return;
|
|
2531
2601
|
}
|
|
2532
2602
|
if (config.command === "logout") {
|
|
@@ -2548,6 +2618,7 @@ async function runDeviceControlCli(args = process.argv.slice(2)) {
|
|
|
2548
2618
|
const deviceAuthorized = !!auth?.scope.split(" ").includes("device-control:device");
|
|
2549
2619
|
const remote = auth && deviceAuthorized ? await checkRemoteStatus(auth.origin, config.stateDirectory, deviceId) : null;
|
|
2550
2620
|
output({ deviceId, origin: auth?.origin ?? resolvedOrigin, authenticated: !!auth, deviceAuthorized, remote, serviceMode: config.service, platform: process.platform });
|
|
2621
|
+
if (auth && deviceAuthorized) await displayVerifiedIdentity(auth.origin, config.stateDirectory, output);
|
|
2551
2622
|
return;
|
|
2552
2623
|
}
|
|
2553
2624
|
if (config.command === "install-service") {
|
|
@@ -2583,12 +2654,22 @@ async function runDeviceControlCli(args = process.argv.slice(2)) {
|
|
|
2583
2654
|
debug: config.debug,
|
|
2584
2655
|
unrestricted: config.unrestricted,
|
|
2585
2656
|
signal: controller.signal,
|
|
2586
|
-
log:
|
|
2657
|
+
log: (event) => {
|
|
2658
|
+
output(event);
|
|
2659
|
+
if (event.event === "remote.session" && event.status === "connected") void displayVerifiedIdentity(resolvedOrigin, config.stateDirectory, output);
|
|
2660
|
+
}
|
|
2587
2661
|
});
|
|
2588
2662
|
} finally {
|
|
2589
2663
|
await lease.release();
|
|
2590
2664
|
}
|
|
2591
2665
|
}
|
|
2666
|
+
async function displayVerifiedIdentity(origin, stateDirectory, output) {
|
|
2667
|
+
try {
|
|
2668
|
+
output({ event: "remote.identity", status: "verified", ...await remoteIdentity(origin, stateDirectory) });
|
|
2669
|
+
} catch {
|
|
2670
|
+
output({ event: "remote.identity", status: "unavailable" });
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2592
2673
|
function formatCliLogEntry(event, json2 = false, now = /* @__PURE__ */ new Date()) {
|
|
2593
2674
|
const timestamp = now.toISOString();
|
|
2594
2675
|
if (json2) return JSON.stringify({ ...event, timestamp });
|
|
@@ -2610,6 +2691,10 @@ function formatCliEvent(event, json2 = false) {
|
|
|
2610
2691
|
const summary2 = event.summary && typeof event.summary === "object" ? " \xB7 " + JSON.stringify(event.summary) : "";
|
|
2611
2692
|
return "\u2705 " + tool + " \xB7 completed" + summary2;
|
|
2612
2693
|
}
|
|
2694
|
+
if (event.event === "remote.identity") {
|
|
2695
|
+
if (status !== "verified") return "\u26A0\uFE0F Account identity could not be verified with the server; retry whoami";
|
|
2696
|
+
return "\u{1F510} Verified account: " + String(event.accountName) + (event.accountEmail ? " <" + String(event.accountEmail) + ">" : "") + "\n Subject: " + String(event.subject) + "\n Workspace: " + String(event.workspaceId);
|
|
2697
|
+
}
|
|
2613
2698
|
if (event.event === "remote.mode" && event.status === "unrestricted") return "\u26A0\uFE0F Unrestricted mode active: all system executables and paths permitted";
|
|
2614
2699
|
if (event.event === "remote.command") {
|
|
2615
2700
|
const requestId = String(event.requestId ?? "").slice(0, 8);
|
|
@@ -2633,10 +2718,11 @@ function formatCliEvent(event, json2 = false) {
|
|
|
2633
2718
|
}
|
|
2634
2719
|
if (event.event === "remote.session") {
|
|
2635
2720
|
if (status === "replaced") return "\u267B\uFE0F Previous UAP Remote instance stopped; starting the new session";
|
|
2636
|
-
if (status === "connected")
|
|
2721
|
+
if (status === "connected")
|
|
2722
|
+
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) : "");
|
|
2637
2723
|
if (status === "disconnected") {
|
|
2638
2724
|
const code = Number(event.closeCode);
|
|
2639
|
-
const cause = ["socket-closed", "socket-error", "client-abort", "protocol-error", "result-delivery"].includes(String(event.closeCause)) ? String(event.closeCause) : "";
|
|
2725
|
+
const cause = ["socket-closed", "socket-error", "client-abort", "protocol-error", "result-delivery", "presence-timeout"].includes(String(event.closeCause)) ? String(event.closeCause) : "";
|
|
2640
2726
|
const uptime = Number(event.uptimeMs);
|
|
2641
2727
|
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" : "");
|
|
2642
2728
|
}
|
|
@@ -2648,6 +2734,8 @@ function formatCliEvent(event, json2 = false) {
|
|
|
2648
2734
|
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>.";
|
|
2649
2735
|
if (status === "connecting") return "\u{1F310} Connecting to " + String(event.origin) + " \xB7 " + String(event.platform);
|
|
2650
2736
|
if (status === "authenticated") return "\u2705 Authenticated \xB7 " + String(event.origin);
|
|
2737
|
+
if (status === "account-switched")
|
|
2738
|
+
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");
|
|
2651
2739
|
if (status === "logged-out") return "\u2705 Logged out";
|
|
2652
2740
|
if (status === "browser-pairing-reset") return "\u2705 Browser pairing reset \xB7 run remote again to get a new pairing code";
|
|
2653
2741
|
if (status === "not-logged-in") return "\u26A0\uFE0F Not logged in";
|
|
@@ -2692,6 +2780,8 @@ Usage:
|
|
|
2692
2780
|
Commands:
|
|
2693
2781
|
remote Connect this computer to Device Control (replace a verified existing Remote instance)
|
|
2694
2782
|
status Show authentication, device and connection status
|
|
2783
|
+
whoami Show the server-verified account and workspace
|
|
2784
|
+
switch-account Stop Remote first; sign in as another account without deleting device identity
|
|
2695
2785
|
login Sign in through browser OAuth/PKCE or an admin-issued pairing code
|
|
2696
2786
|
logout Remove the saved authorization
|
|
2697
2787
|
browser-reset Reset only the saved browser-extension pairing
|
|
@@ -2717,6 +2807,9 @@ Examples:
|
|
|
2717
2807
|
npx @codingfrees/uap-device-control@latest
|
|
2718
2808
|
npx @codingfrees/uap-device-control@latest login
|
|
2719
2809
|
npx @codingfrees/uap-device-control@latest login --pairing-code <code>
|
|
2810
|
+
npx @codingfrees/uap-device-control@latest whoami
|
|
2811
|
+
npx @codingfrees/uap-device-control@latest switch-account
|
|
2812
|
+
npx @codingfrees/uap-device-control@latest switch-account --pairing-code <code>
|
|
2720
2813
|
npx @codingfrees/uap-device-control@latest browser-reset
|
|
2721
2814
|
npx @codingfrees/uap-device-control@latest remote
|
|
2722
2815
|
npx @codingfrees/uap-device-control@latest remote --no-browser-control
|