agentroam 0.2.0-preview.53 → 0.2.0-preview.55

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.
@@ -1,11 +1,8 @@
1
- import { execFile } from "node:child_process";
2
1
  import { setTimeout as delay } from "node:timers/promises";
3
- import { promisify } from "node:util";
4
2
  import { resolveApprovalInput, terminalText } from "./device-pairing.js";
5
3
  import { localServiceRequest } from "./local-service-request.js";
6
4
  import { DesktopAuthorizationInterrupted, DesktopAuthorizationPrompt, withAuthorizationSignal } from "./desktop-authorization-prompt.js";
7
5
  import { withCliProgress, withoutCliProgress } from "../bin/cli-progress.mjs";
8
- const runFile = promisify(execFile);
9
6
  const endpoint = "/api/remote-authorization";
10
7
  async function requestAuthorization(dataDir, body, signal) {
11
8
  const status = await localServiceRequest(dataDir, endpoint, {
@@ -19,15 +16,18 @@ async function requestAuthorization(dataDir, body, signal) {
19
16
  }
20
17
  return status;
21
18
  }
22
- /** Clear only this app's stale permission; deleting the old bundle does not clear TCC. */
23
- export async function resetMacDesktopPermission(permission, signal, run = runFile) {
24
- await run("/usr/bin/tccutil", ["reset", permission === "screen" ? "ScreenCapture" : "Accessibility", "com.agentroam.remote-desktop"], {
25
- signal, timeout: 5000, maxBuffer: 4096,
26
- });
27
- }
28
19
  function recoveryHint(log) {
29
20
  log("稍后重新授权:agentroam desktop authorize;也可在本机浏览器的“远程授权”面板中操作。");
30
21
  }
22
+ function reportComponent(status, log) {
23
+ if (!status.component)
24
+ return;
25
+ const component = status.component;
26
+ log(`远控组件:${terminalText(component.version === 'legacy' ? '旧版(未记录版本)' : component.version)}`);
27
+ log(`授权应用位置:${terminalText(component.path)}`);
28
+ if (component.updatePending)
29
+ log('旧版远控组件仍在使用;结束其他 AgentRoam 的桌面共享后,重新授权即可更新。');
30
+ }
31
31
  function complete(status) {
32
32
  return status.enabled && status.screen && status.accessibility && !status.error;
33
33
  }
@@ -44,7 +44,16 @@ export async function authorizeRemoteDesktop(dataDir, context = {}) {
44
44
  const prompt = new DesktopAuthorizationPrompt({ input, ownsInput: context.input === undefined && input !== process.stdin,
45
45
  signal: context.signal, timeoutMs: context.timeoutMs ?? 60_000, log });
46
46
  const run = (operation) => withAuthorizationSignal(operation, prompt.signal);
47
- const check = (body) => run(() => request(dataDir, body, prompt.signal));
47
+ let reportedComponent = '';
48
+ const check = async (body) => {
49
+ const status = await run(() => request(dataDir, body, prompt.signal));
50
+ const identity = JSON.stringify(status.component) ?? '';
51
+ if (identity !== reportedComponent) {
52
+ reportComponent(status, log);
53
+ reportedComponent = identity;
54
+ }
55
+ return status;
56
+ };
48
57
  log("远程桌面授权可选;输入 s 后回车或按 Ctrl+C 可跳过,稍后可重新授权。");
49
58
  try {
50
59
  let status = await withCliProgress("正在检查本机远程桌面权限", () => check());
@@ -74,14 +83,8 @@ export async function authorizeRemoteDesktop(dataDir, context = {}) {
74
83
  if (status[permission])
75
84
  continue;
76
85
  const name = permission === "screen" ? "屏幕录制" : "辅助功能";
77
- log(`正在清理 AgentRoam 的旧${name}授权记录,以便重新请求权限…`);
78
- try {
79
- await run(() => (context.resetPermission ?? resetMacDesktopPermission)(permission, prompt.signal));
80
- }
81
- catch (error) {
82
- prompt.signal.throwIfAborted();
83
- log(`未能清理旧${name}授权:${terminalText(error instanceof Error ? error.message : String(error))}。可在系统设置中移除 AgentRoam Remote Desktop 后重试。`);
84
- }
86
+ // TCC grants belong to the bundle ID across all installed runtimes.
87
+ // A false probe here must never revoke another runtime's permission.
85
88
  log(`正在请求${name}权限,请在系统设置中允许 AgentRoam Remote Desktop…`);
86
89
  status = await withCliProgress(`正在等待${name}权限;输入 s 后回车可跳过`, async () => {
87
90
  let current = await check({ action: "request-permission", permission });
@@ -144,6 +147,7 @@ export async function runDesktopCommand(options, context = {}) {
144
147
  }
145
148
  if (status.supported && status.installed)
146
149
  status = await request(options.dataDir, { action: "recheck" });
150
+ reportComponent(status, log);
147
151
  log(`远程桌面:${status.supported ? "支持" : "不支持"};共享:${status.enabled ? "已开启" : "未开启"};屏幕录制:${status.screen ? "已授权" : "未授权或桌面不可用"};辅助功能:${status.accessibility ? "已授权" : "未授权"}`);
148
152
  if (status.error)
149
153
  log(`状态提示:${terminalText(status.error)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentroam",
3
- "version": "0.2.0-preview.53",
3
+ "version": "0.2.0-preview.55",
4
4
  "description": "Zero-install mobile remote terminal and file console",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,12 +27,12 @@
27
27
  "ws": "^8.21.3"
28
28
  },
29
29
  "optionalDependencies": {
30
- "agentroam-runtime-darwin-arm64": "0.2.0-preview.53",
31
- "agentroam-runtime-win32-x64": "0.2.0-preview.53",
32
- "agentroam-cloudflared-darwin-arm64": "0.2.0-preview.53",
33
- "agentroam-cloudflared-win32-x64": "0.2.0-preview.53",
34
- "agentroam-tui-darwin-arm64": "0.2.0-preview.53",
35
- "@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.53"
30
+ "agentroam-runtime-darwin-arm64": "0.2.0-preview.55",
31
+ "agentroam-runtime-win32-x64": "0.2.0-preview.55",
32
+ "agentroam-cloudflared-darwin-arm64": "0.2.0-preview.55",
33
+ "agentroam-cloudflared-win32-x64": "0.2.0-preview.55",
34
+ "agentroam-tui-darwin-arm64": "0.2.0-preview.55",
35
+ "@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.55"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.0.0",