@agentconnect.md/computer 2.8.0-rc.12 → 2.8.0-rc.19

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.
@@ -1364,7 +1364,7 @@ var require_cross_spawn = __commonJS({
1364
1364
  var cp = __require("child_process");
1365
1365
  var parse3 = require_parse();
1366
1366
  var enoent = require_enoent();
1367
- function spawn10(command, args, options) {
1367
+ function spawn11(command, args, options) {
1368
1368
  const parsed = parse3(command, args, options);
1369
1369
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1370
1370
  enoent.hookChildProcess(spawned, parsed);
@@ -1376,8 +1376,8 @@ var require_cross_spawn = __commonJS({
1376
1376
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1377
1377
  return result;
1378
1378
  }
1379
- module.exports = spawn10;
1380
- module.exports.spawn = spawn10;
1379
+ module.exports = spawn11;
1380
+ module.exports.spawn = spawn11;
1381
1381
  module.exports.sync = spawnSync11;
1382
1382
  module.exports._parse = parse3;
1383
1383
  module.exports._enoent = enoent;
@@ -29273,9 +29273,9 @@ var require_permessage_deflate = __commonJS({
29273
29273
  * @private
29274
29274
  */
29275
29275
  _decompress(data, fin, callback) {
29276
- const endpoint = this._isServer ? "client" : "server";
29276
+ const endpoint2 = this._isServer ? "client" : "server";
29277
29277
  if (!this._inflate) {
29278
- const key = `${endpoint}_max_window_bits`;
29278
+ const key = `${endpoint2}_max_window_bits`;
29279
29279
  const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
29280
29280
  this._inflate = zlib.createInflateRaw({
29281
29281
  ...this._options.zlibInflateOptions,
@@ -29308,7 +29308,7 @@ var require_permessage_deflate = __commonJS({
29308
29308
  } else {
29309
29309
  this._inflate[kTotalLength] = 0;
29310
29310
  this._inflate[kBuffers] = [];
29311
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
29311
+ if (fin && this.params[`${endpoint2}_no_context_takeover`]) {
29312
29312
  this._inflate.reset();
29313
29313
  }
29314
29314
  }
@@ -29324,9 +29324,9 @@ var require_permessage_deflate = __commonJS({
29324
29324
  * @private
29325
29325
  */
29326
29326
  _compress(data, fin, callback) {
29327
- const endpoint = this._isServer ? "server" : "client";
29327
+ const endpoint2 = this._isServer ? "server" : "client";
29328
29328
  if (!this._deflate) {
29329
- const key = `${endpoint}_max_window_bits`;
29329
+ const key = `${endpoint2}_max_window_bits`;
29330
29330
  const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
29331
29331
  this._deflate = zlib.createDeflateRaw({
29332
29332
  ...this._options.zlibDeflateOptions,
@@ -29352,7 +29352,7 @@ var require_permessage_deflate = __commonJS({
29352
29352
  this._deflate[kCallback] = null;
29353
29353
  this._deflate[kTotalLength] = 0;
29354
29354
  this._deflate[kBuffers] = [];
29355
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
29355
+ if (fin && this.params[`${endpoint2}_no_context_takeover`]) {
29356
29356
  this._deflate.reset();
29357
29357
  }
29358
29358
  callback(null, data2);
@@ -86299,13 +86299,26 @@ var ADMIN_PROMPT_LABELS = {
86299
86299
  approve: "Always Approve",
86300
86300
  deny: "Always Deny"
86301
86301
  };
86302
- var windowsRows = ({ service, adminPrompts }, busy) => {
86302
+ var FIREWALL_PROBLEM = {
86303
+ missing: "no rule for direct video",
86304
+ blocked: "blocks direct video",
86305
+ uncovered: "blocks direct video on this network"
86306
+ };
86307
+ var firewallRow = (state, busy) => busy ? { title: "Windows Firewall: adding the rule\u2026", mark: "progress", enabled: false } : state === "allowed" ? { title: "Windows Firewall: direct video allowed", mark: "ok", enabled: false } : state === void 0 ? { title: "Windows Firewall: cannot read the rules", mark: "warn", enabled: false } : {
86308
+ id: "firewall",
86309
+ title: `Windows Firewall: ${FIREWALL_PROBLEM[state]}, click to allow`,
86310
+ mark: "fail"
86311
+ };
86312
+ var windowsRows = ({ service, adminPrompts, firewall }, busy) => {
86303
86313
  if (!service)
86304
86314
  return [
86305
86315
  { title: "Service: not installed, run agentconnect computer setup", mark: "warn", enabled: false },
86306
86316
  { title: "Administrator prompts: out of reach without the service", mark: "warn", enabled: false }
86307
86317
  ];
86308
- const rows = [{ title: "Service: running as SYSTEM", mark: "ok", enabled: false }];
86318
+ const rows = [
86319
+ { title: "Service: running as SYSTEM", mark: "ok", enabled: false },
86320
+ firewallRow(firewall, busy.has("firewall"))
86321
+ ];
86309
86322
  if (!adminPrompts) return rows;
86310
86323
  if (adminPrompts.problem)
86311
86324
  rows.push({ title: `Administrator prompts: ${adminPrompts.problem}`, mark: "fail", enabled: false });
@@ -86313,13 +86326,13 @@ var windowsRows = ({ service, adminPrompts }, busy) => {
86313
86326
  rows.push({ title: `Administrator prompt waiting: ${adminPrompts.pending}`, mark: "warn", enabled: false });
86314
86327
  const modes = Object.entries(ADMIN_PROMPT_LABELS);
86315
86328
  rows.push({
86316
- title: `Administrator Prompts: ${busy ? "saving\u2026" : ADMIN_PROMPT_LABELS[adminPrompts.mode]}`,
86329
+ title: `Administrator Prompts: ${busy.has("admin-prompts") ? "saving\u2026" : ADMIN_PROMPT_LABELS[adminPrompts.mode]}`,
86317
86330
  items: [
86318
86331
  ...modes.map(([mode, title]) => ({
86319
86332
  id: `admin-prompts:${mode}`,
86320
86333
  title,
86321
86334
  checked: mode === adminPrompts.mode,
86322
- enabled: adminPrompts.editable && !busy
86335
+ enabled: adminPrompts.editable && !busy.has("admin-prompts")
86323
86336
  })),
86324
86337
  ...adminPrompts.locked ? [
86325
86338
  { title: "", separator: true },
@@ -86348,7 +86361,7 @@ function menuBarMenu(tray, facts, busy = /* @__PURE__ */ new Set()) {
86348
86361
  mark: cpMark,
86349
86362
  enabled: cpMark === "fail" && facts.controlPlane.state !== "revoked"
86350
86363
  },
86351
- ...windows ? windowsRows(windows, busy.has("admin-prompts")) : [
86364
+ ...windows ? windowsRows(windows, busy) : [
86352
86365
  grant("Screen Recording", facts.screenRecording, "screen-recording"),
86353
86366
  grant("Device Control (Accessibility)", facts.accessibility, "accessibility")
86354
86367
  ],
@@ -86440,6 +86453,8 @@ function startMenuBar(helper, host, initial, start = HelperTray.start) {
86440
86453
  return task("driver", () => host.installDriver());
86441
86454
  case "ffmpeg":
86442
86455
  return task("ffmpeg", () => host.installFfmpeg());
86456
+ case "firewall":
86457
+ return host.allowFirewall && task("firewall", () => host.allowFirewall());
86443
86458
  case "start-at-login":
86444
86459
  host.setStartAtLogin(!(facts?.startAtLogin ?? true));
86445
86460
  return void refresh();
@@ -86691,7 +86706,7 @@ var serviceEntry = () => managedEntry() ?? resolve(process.argv[1]);
86691
86706
 
86692
86707
  // src/version.ts
86693
86708
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
86694
- var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.12" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
86709
+ var COMPUTER_DAEMON_VERSION = true ? "2.8.0-rc.19" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
86695
86710
 
86696
86711
  // src/http-server.ts
86697
86712
  var CONTROL_HEADER = "x-agentconnect-computer";
@@ -97430,9 +97445,9 @@ var TurnProtocol = class _TurnProtocol {
97430
97445
  }
97431
97446
  selectServerEndpoint() {
97432
97447
  this.serverEndpointSelection ??= this.resolveServerEndpoint().then(
97433
- (endpoint) => {
97434
- this.pinnedServerEndpoint = endpoint;
97435
- return endpoint;
97448
+ (endpoint2) => {
97449
+ this.pinnedServerEndpoint = endpoint2;
97450
+ return endpoint2;
97436
97451
  },
97437
97452
  (error62) => {
97438
97453
  this.serverEndpointSelection = void 0;
@@ -109547,6 +109562,7 @@ var RtcSessions = class {
109547
109562
  });
109548
109563
  pc.connectionStateChange.subscribe((state) => {
109549
109564
  if (state === "connected") {
109565
+ session.connected = true;
109550
109566
  session.lastSeen = Date.now();
109551
109567
  this.options.log(`viewer ${client()}: WebRTC connected (${transport}${selectedPairType(pc)})`);
109552
109568
  session.unsubscribe ??= this.options.stream.subscribe((packet) => track.writeRtp(packet));
@@ -109624,6 +109640,11 @@ var RtcSessions = class {
109624
109640
  if (!session) return;
109625
109641
  this.sessions.delete(id);
109626
109642
  session.unsubscribe?.();
109643
+ if (session.transport !== "direct" && !session.connected) {
109644
+ this.options.log(
109645
+ `viewer ${session.principal.client}: ${session.transport} never connected: ${iceReport(session.pc, session.remoteCandidates ?? 0)}`
109646
+ );
109647
+ }
109627
109648
  void session.pc.close().catch(() => void 0);
109628
109649
  this.options.log(`viewer ${session.principal.client}: WebRTC session closed`);
109629
109650
  }
@@ -109642,6 +109663,18 @@ function selectedPairType(pc) {
109642
109663
  const pair = pc.iceTransports[0]?.connection.nominated;
109643
109664
  return pair ? `, ${pair.localCandidate.type} \u2192 ${pair.remoteCandidate.type}` : "";
109644
109665
  }
109666
+ var PAIR_STATES = ["frozen", "waiting", "in-progress", "succeeded", "failed"];
109667
+ var endpoint = (c) => `${c.type} ${c.host}:${c.port}`;
109668
+ function iceReport(pc, trickled) {
109669
+ const connection = pc.iceTransports[0]?.connection;
109670
+ if (!connection) return "no ICE transport";
109671
+ const local = connection.localCandidates.map(endpoint).join(", ") || "none";
109672
+ const remote = connection.remoteCandidates.map(endpoint).join(", ") || "none";
109673
+ const pairs = connection.checkList.map(
109674
+ (pair) => `${pair.localCandidate.type} \u2192 ${endpoint(pair.remoteCandidate)} ${PAIR_STATES[pair.state] ?? pair.state} ${pair.requestsSent}/${pair.responsesReceived}/${pair.requestsReceived}`
109675
+ ).join(", ") || "none";
109676
+ return `ICE ${connection.state}; local ${local}; remote ${remote} (${trickled} trickled); pairs sent/answered/received ${pairs}`;
109677
+ }
109645
109678
  var onlyCandidatesFor = (sdp, address) => sdp.split("\r\n").filter((line) => !line.startsWith("a=candidate:") || line.split(" ")[4] === address).join("\r\n");
109646
109679
 
109647
109680
  // src/stream/screen-stream.ts
@@ -111318,7 +111351,7 @@ function consoleStopHandler(computer, changed) {
111318
111351
 
111319
111352
  // src/menu-bar-host.ts
111320
111353
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111321
- import { spawn as spawn9, spawnSync as spawnSync8 } from "node:child_process";
111354
+ import { spawn as spawn10, spawnSync as spawnSync8 } from "node:child_process";
111322
111355
  import { chmodSync as chmodSync2, existsSync as existsSync8, readFileSync as readFileSync6, rmSync as rmSync7, writeFileSync as writeFileSync10 } from "node:fs";
111323
111356
  import { tmpdir as tmpdir2 } from "node:os";
111324
111357
  import { join as join12 } from "node:path";
@@ -111410,7 +111443,7 @@ function setStartAtLogin(on) {
111410
111443
 
111411
111444
  // src/setup.ts
111412
111445
  init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111413
- import { spawn as spawn8, spawnSync as spawnSync7 } from "node:child_process";
111446
+ import { spawn as spawn9, spawnSync as spawnSync7 } from "node:child_process";
111414
111447
  import { existsSync as existsSync7 } from "node:fs";
111415
111448
  import { basename, dirname as dirname4, isAbsolute, join as join11 } from "node:path";
111416
111449
  import { createInterface as createInterface3 } from "node:readline";
@@ -111793,6 +111826,74 @@ async function registerOrKeep(dir, cpUrl, register3) {
111793
111826
  }
111794
111827
  }
111795
111828
 
111829
+ // src/windows-firewall.ts
111830
+ init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
111831
+ import { spawn as spawn8 } from "node:child_process";
111832
+ var FIREWALL_RULE = "AgentConnect Computer (Node.js)";
111833
+ var psQuote2 = (value) => `'${value.replace(/'/g, "''")}'`;
111834
+ var profileCovered = (profile, category) => profile === "Any" || profile.split(/,\s*/).includes(category === "DomainAuthenticated" ? "Domain" : category);
111835
+ function firewallVerdict(rules) {
111836
+ if (rules.block.length > 0) return { state: "blocked", rules: rules.block.map((rule) => rule.name) };
111837
+ if (rules.allow.length === 0) return { state: "missing" };
111838
+ const networks = rules.activeProfiles.filter(
111839
+ (category) => !rules.allow.some((rule) => profileCovered(rule.profile, category))
111840
+ );
111841
+ if (networks.length > 0) return { state: "uncovered", networks };
111842
+ return { state: "allowed", profiles: rules.allow.map((rule) => rule.profile) };
111843
+ }
111844
+ var readScript = (program) => `$ErrorActionPreference = 'SilentlyContinue'
111845
+ $p = ${psQuote2(program)}
111846
+ $rules = @(Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Enabled)" -eq 'True' -and "$($_.Direction)" -eq 'Inbound' } | ForEach-Object { [pscustomobject]@{ name = $_.DisplayName; action = "$($_.Action)"; profile = "$($_.Profile)" } })
111847
+ $profiles = @(Get-NetConnectionProfile | ForEach-Object { "$($_.NetworkCategory)" })
111848
+ ConvertTo-Json -Compress -InputObject @{ rules = $rules; profiles = $profiles }`;
111849
+ function parseFirewallRules(stdout) {
111850
+ try {
111851
+ const parsed = JSON.parse(stdout.trim());
111852
+ const rules = parsed.rules ?? [];
111853
+ return {
111854
+ allow: rules.filter((rule) => rule.action === "Allow"),
111855
+ block: rules.filter((rule) => rule.action === "Block"),
111856
+ activeProfiles: [...new Set(parsed.profiles ?? [])]
111857
+ };
111858
+ } catch {
111859
+ return void 0;
111860
+ }
111861
+ }
111862
+ var allowScript = (program) => `$p = ${psQuote2(program)}
111863
+ Get-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -ErrorAction SilentlyContinue | Remove-NetFirewallRule
111864
+ Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Action)" -eq 'Block' -and "$($_.Direction)" -eq 'Inbound' } | Disable-NetFirewallRule
111865
+ New-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -Direction Inbound -Program $p -Action Allow -Profile Any | Out-Null`;
111866
+ function powershell(script, timeoutMs) {
111867
+ return new Promise((resolve3) => {
111868
+ const child2 = spawn8("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
111869
+ stdio: ["ignore", "pipe", "ignore"],
111870
+ windowsHide: true
111871
+ });
111872
+ let stdout = "";
111873
+ child2.stdout.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
111874
+ const timer = setTimeout(() => child2.kill(), timeoutMs);
111875
+ child2.on("error", () => resolve3({ ok: false, stdout }));
111876
+ child2.on("close", (code) => {
111877
+ clearTimeout(timer);
111878
+ resolve3({ ok: code === 0, stdout });
111879
+ });
111880
+ });
111881
+ }
111882
+ async function readFirewall(program) {
111883
+ const result = await powershell(readScript(program), 3e4);
111884
+ const rules = result.ok ? parseFirewallRules(result.stdout) : void 0;
111885
+ return rules && firewallVerdict(rules);
111886
+ }
111887
+ async function allowFirewall(program, elevated) {
111888
+ if (elevated) return (await powershell(allowScript(program), 6e4)).ok;
111889
+ const encoded2 = Buffer.from(allowScript(program), "utf16le").toString("base64");
111890
+ const result = await powershell(
111891
+ `Start-Process powershell.exe -Verb RunAs -Wait -WindowStyle Hidden -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded2}'`,
111892
+ 18e4
111893
+ );
111894
+ return result.ok;
111895
+ }
111896
+
111796
111897
  // src/setup.ts
111797
111898
  var localizeChecks = (checks, command = selfCommand()) => {
111798
111899
  const rename = (text) => text.replace(/(?<![\w/.-])agentconnect-computer(?= |$)/g, command);
@@ -111803,7 +111904,6 @@ var localizeChecks = (checks, command = selfCommand()) => {
111803
111904
  }));
111804
111905
  };
111805
111906
  var ICON = { ok: "\u2705", info: "\u2139\uFE0F ", warn: "\u26A0\uFE0F ", fail: "\u274C" };
111806
- var FIREWALL_RULE = "AgentConnect Computer (Node.js)";
111807
111907
  var MAC_PANES = {
111808
111908
  accessibility: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
111809
111909
  screenRecording: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
@@ -111837,36 +111937,6 @@ async function macPermissions(driver, prompt = false) {
111837
111937
  directCapture: typeof meta3.direct_capture_status === "string" ? meta3.direct_capture_status : "not_checked"
111838
111938
  };
111839
111939
  }
111840
- function powershell(script, timeoutMs = 3e4) {
111841
- const result = spawnSync7("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
111842
- encoding: "utf8",
111843
- windowsHide: true,
111844
- timeout: timeoutMs
111845
- });
111846
- return { ok: result.status === 0, stdout: result.stdout ?? "" };
111847
- }
111848
- var psQuote2 = (value) => `'${value.replace(/'/g, "''")}'`;
111849
- function firewallState(program) {
111850
- const script = `$ErrorActionPreference = 'SilentlyContinue'
111851
- $p = ${psQuote2(program)}
111852
- $rules = @(Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Enabled)" -eq 'True' -and "$($_.Direction)" -eq 'Inbound' } | ForEach-Object { [pscustomobject]@{ name = $_.DisplayName; action = "$($_.Action)"; profile = "$($_.Profile)" } })
111853
- $profiles = @(Get-NetConnectionProfile | ForEach-Object { "$($_.NetworkCategory)" })
111854
- ConvertTo-Json -Compress -InputObject @{ rules = $rules; profiles = $profiles }`;
111855
- const result = powershell(script);
111856
- if (!result.ok) return void 0;
111857
- try {
111858
- const parsed = JSON.parse(result.stdout.trim());
111859
- const rules = parsed.rules ?? [];
111860
- return {
111861
- allow: rules.filter((rule) => rule.action === "Allow"),
111862
- block: rules.filter((rule) => rule.action === "Block"),
111863
- activeProfiles: [...new Set(parsed.profiles ?? [])]
111864
- };
111865
- } catch {
111866
- return void 0;
111867
- }
111868
- }
111869
- var profileCovered = (profile, category) => profile === "Any" || profile.split(/,\s*/).includes(category === "DomainAuthenticated" ? "Domain" : category);
111870
111940
  async function doctor(ctx, captureTimeoutMs = 15e3) {
111871
111941
  const checks = [];
111872
111942
  const { config: config2 } = ctx;
@@ -111919,7 +111989,7 @@ async function doctor(ctx, captureTimeoutMs = 15e3) {
111919
111989
  }
111920
111990
  checks.push(displayCheck(config2));
111921
111991
  checks.push(...ffmpegChecks(ctx, captureTimeoutMs));
111922
- if (process.platform === "win32") checks.push(firewallCheck(config2));
111992
+ if (process.platform === "win32") checks.push(await firewallCheck());
111923
111993
  if (process.platform === "linux") checks.push(...linuxChecks(ctx));
111924
111994
  checks.push(await daemonCheck(config2));
111925
111995
  return checks;
@@ -112148,37 +112218,35 @@ function ffmpegChecks(ctx, timeoutMs) {
112148
112218
  }
112149
112219
  ];
112150
112220
  }
112151
- function firewallCheck(config2) {
112152
- if (isLoopbackHost(config2.host)) {
112153
- return { name: "firewall", status: "info", detail: `listening on ${config2.host} only; no inbound rule needed` };
112154
- }
112155
- const state = firewallState(process.execPath);
112156
- if (!state) return { name: "firewall", status: "warn", detail: "could not read Windows Firewall rules" };
112157
- const fix = `run: ${selfCommand()} setup (asks for administrator approval once)`;
112158
- if (state.block.length > 0) {
112159
- return {
112160
- name: "firewall",
112161
- status: "fail",
112162
- detail: `inbound block rule(s) for ${process.execPath}: ${state.block.map((rule) => rule.name).join(", ")}`,
112163
- fix
112164
- };
112165
- }
112166
- const uncovered = state.activeProfiles.filter(
112167
- (category) => !state.allow.some((rule) => profileCovered(rule.profile, category))
112168
- );
112169
- if (state.allow.length === 0 || uncovered.length > 0) {
112170
- return {
112171
- name: "firewall",
112172
- status: "warn",
112173
- detail: state.allow.length === 0 ? "no inbound allow rule for Node.js: remote MCP and WebRTC will be blocked or prompt" : `Node.js is not allowed on active ${uncovered.join("/")} network(s)`,
112174
- fix
112175
- };
112221
+ async function firewallCheck() {
112222
+ const verdict = await readFirewall(process.execPath);
112223
+ const fix = `run: ${selfCommand()} setup, or click Windows Firewall in the taskbar menu`;
112224
+ if (!verdict) return { name: "firewall", status: "warn", detail: "could not read Windows Firewall rules" };
112225
+ switch (verdict.state) {
112226
+ case "blocked":
112227
+ return {
112228
+ name: "firewall",
112229
+ status: "fail",
112230
+ detail: `inbound block rule(s) for ${process.execPath}: ${verdict.rules.join(", ")}`,
112231
+ fix
112232
+ };
112233
+ case "missing":
112234
+ return {
112235
+ name: "firewall",
112236
+ status: "warn",
112237
+ detail: "no inbound allow rule for Node.js: direct WebRTC video falls back to TURN or screenshots",
112238
+ fix
112239
+ };
112240
+ case "uncovered":
112241
+ return {
112242
+ name: "firewall",
112243
+ status: "warn",
112244
+ detail: `Node.js is not allowed on active ${verdict.networks.join("/")} network(s)`,
112245
+ fix
112246
+ };
112247
+ case "allowed":
112248
+ return { name: "firewall", status: "ok", detail: `Node.js allowed inbound (${verdict.profiles.join(", ")})` };
112176
112249
  }
112177
- return {
112178
- name: "firewall",
112179
- status: "ok",
112180
- detail: `Node.js allowed inbound (${state.allow.map((rule) => rule.profile).join(", ")})`
112181
- };
112182
112250
  }
112183
112251
  async function daemonCheck(config2) {
112184
112252
  const running = await fetch(`${controlBaseUrl(config2)}/healthz`, { signal: AbortSignal.timeout(2e3) }).then((response) => response.ok).catch(() => false);
@@ -112293,33 +112361,16 @@ async function waitForGrants(ctx, app, initial) {
112293
112361
  return state;
112294
112362
  }
112295
112363
  function open2(url2) {
112296
- spawn8("open", [url2], { stdio: "ignore", detached: true }).unref();
112364
+ spawn9("open", [url2], { stdio: "ignore", detached: true }).unref();
112297
112365
  }
112298
- function setupWindowsFirewall(ctx, program = process.execPath) {
112299
- if (isLoopbackHost(ctx.config.host)) {
112300
- ctx.log(`Listening on ${ctx.config.host} only, so no Windows Firewall rule is needed.`);
112301
- return;
112302
- }
112303
- const state = firewallState(program);
112304
- const uncovered = state?.activeProfiles.filter(
112305
- (category) => !state.allow.some((rule) => profileCovered(rule.profile, category))
112306
- );
112307
- if (state && state.block.length === 0 && state.allow.length > 0 && uncovered?.length === 0) {
112366
+ async function setupWindowsFirewall(ctx, program = process.execPath) {
112367
+ if ((await readFirewall(program))?.state === "allowed") {
112308
112368
  ctx.log("Windows Firewall already allows Node.js inbound.");
112309
112369
  return;
112310
112370
  }
112311
112371
  ctx.log(`Adding a Windows Firewall rule "${FIREWALL_RULE}" for ${program} (approve the administrator prompt).`);
112312
- const elevated = `$p = ${psQuote2(program)}
112313
- Get-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -ErrorAction SilentlyContinue | Remove-NetFirewallRule
112314
- Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Action)" -eq 'Block' -and "$($_.Direction)" -eq 'Inbound' } | Disable-NetFirewallRule
112315
- New-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -Direction Inbound -Program $p -Action Allow -Profile Any | Out-Null`;
112316
- const encoded2 = Buffer.from(elevated, "utf16le").toString("base64");
112317
- const result = powershell(
112318
- `Start-Process powershell.exe -Verb RunAs -Wait -WindowStyle Hidden -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded2}'`,
112319
- 18e4
112320
- );
112321
112372
  ctx.log(
112322
- result.ok ? "Firewall rule added; any Node.js block rules were disabled." : "Firewall rule not added (administrator prompt declined?); Windows will ask on first connection instead."
112373
+ await allowFirewall(program, false) ? "Firewall rule added; any Node.js block rules were disabled." : "Firewall rule not added (administrator prompt declined?); click Windows Firewall in the taskbar menu to add it later."
112323
112374
  );
112324
112375
  }
112325
112376
 
@@ -112433,7 +112484,7 @@ function macMenuBarHost(deps) {
112433
112484
  },
112434
112485
  openLogs() {
112435
112486
  const file2 = join12(dir, "daemon.log");
112436
- spawn9("open", existsSync8(file2) ? ["-a", "Console", file2] : [dir], { stdio: "ignore", detached: true }).unref();
112487
+ spawn10("open", existsSync8(file2) ? ["-a", "Console", file2] : [dir], { stdio: "ignore", detached: true }).unref();
112437
112488
  },
112438
112489
  uninstall() {
112439
112490
  let channel;
@@ -112446,7 +112497,7 @@ function macMenuBarHost(deps) {
112446
112497
  writeFileSync10(script, uninstallScript(channel));
112447
112498
  chmodSync2(script, 493);
112448
112499
  log40("uninstall requested from the menu bar; running it in Terminal");
112449
- spawn9("open", ["-a", "Terminal", script], { stdio: "ignore", detached: true }).unref();
112500
+ spawn10("open", ["-a", "Terminal", script], { stdio: "ignore", detached: true }).unref();
112450
112501
  },
112451
112502
  quit() {
112452
112503
  log40("quit from the menu bar; the service starts again at the next login");
@@ -112462,6 +112513,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync7, rmSync as rmS
112462
112513
  import { join as join13 } from "node:path";
112463
112514
  var RECONNECT_WAIT_MS2 = 1e4;
112464
112515
  var DRIVER_TIMEOUT_MS = 5e3;
112516
+ var FIREWALL_TTL_MS = 5 * 6e4;
112465
112517
  var within2 = (promise2, ms) => Promise.race([promise2, new Promise((_, reject) => setTimeout(() => reject(new Error("timed out")), ms).unref())]);
112466
112518
  function uninstallCommand(channel) {
112467
112519
  const cli = `@agentconnect.md/cli${channel === "rc" ? "@rc" : ""}`;
@@ -112470,6 +112522,12 @@ function uninstallCommand(channel) {
112470
112522
  function windowsMenuBarHost(deps) {
112471
112523
  const { dir, driver, log: log40 } = deps;
112472
112524
  const host = deps.registration ? new URL(deps.registration.channelUrl).host : void 0;
112525
+ let firewall;
112526
+ const firewallState = async () => {
112527
+ if (!firewall || Date.now() - firewall.at > FIREWALL_TTL_MS)
112528
+ firewall = { at: Date.now(), state: (await readFirewall(process.execPath))?.state };
112529
+ return firewall.state;
112530
+ };
112473
112531
  return {
112474
112532
  async facts() {
112475
112533
  const running = await within2(driver.call("get_screen_size", {}), DRIVER_TIMEOUT_MS).then(
@@ -112478,6 +112536,7 @@ function windowsMenuBarHost(deps) {
112478
112536
  );
112479
112537
  const name = deps.name();
112480
112538
  const service = serviceHost() !== void 0;
112539
+ const firewallNow = service ? await firewallState() : void 0;
112481
112540
  return {
112482
112541
  ...name ? { name } : {},
112483
112542
  version: COMPUTER_DAEMON_VERSION,
@@ -112490,7 +112549,11 @@ function windowsMenuBarHost(deps) {
112490
112549
  installing: ffmpegInstalling(dir)
112491
112550
  },
112492
112551
  startAtLogin: service && startsAtLogin2(),
112493
- windows: { service, ...deps.adminPrompts ? { adminPrompts: deps.adminPrompts.facts() } : {} }
112552
+ windows: {
112553
+ service,
112554
+ ...firewallNow ? { firewall: firewallNow } : {},
112555
+ ...deps.adminPrompts ? { adminPrompts: deps.adminPrompts.facts() } : {}
112556
+ }
112494
112557
  };
112495
112558
  },
112496
112559
  async reconnect() {
@@ -112515,6 +112578,14 @@ function windowsMenuBarHost(deps) {
112515
112578
  await deps.adminPrompts.set(mode);
112516
112579
  log40(`administrator prompts set to ${mode} from the taskbar`);
112517
112580
  },
112581
+ // The service runs as SYSTEM, so the rule goes in without a UAC prompt.
112582
+ async allowFirewall() {
112583
+ firewall = void 0;
112584
+ if (!await allowFirewall(process.execPath, serviceHost() !== void 0))
112585
+ throw new Error("could not add the Windows Firewall rule");
112586
+ log40("Windows Firewall rule added from the taskbar");
112587
+ deps.onFirewallChanged?.();
112588
+ },
112518
112589
  // macOS grants: not shown on Windows.
112519
112590
  openSettings: () => void 0,
112520
112591
  resetGrant: () => void 0,
@@ -113708,7 +113779,7 @@ async function main() {
113708
113779
  return;
113709
113780
  }
113710
113781
  case "service":
113711
- return serviceCommand(dir, loadConfig(dir), rest[0], Boolean(values.purge));
113782
+ return await serviceCommand(dir, loadConfig(dir), rest[0], Boolean(values.purge));
113712
113783
  case "autostart": {
113713
113784
  const action = rest[0];
113714
113785
  if (action === "enable") enableAutostart(dir, serviceEntry());
@@ -114162,6 +114233,7 @@ async function run3(dir, initial, clientName) {
114162
114233
  // The service host starts the daemon again after a non-zero exit and waits for the next sign-in after zero.
114163
114234
  shutdown: (code) => void shutdown(code),
114164
114235
  onFfmpegInstalled: () => live2.channel?.refreshDoctor(),
114236
+ onFirewallChanged: () => live2.channel?.refreshDoctor(),
114165
114237
  ...adminPromptHelper ? {
114166
114238
  adminPrompts: {
114167
114239
  facts: () => {
@@ -114368,7 +114440,7 @@ async function setupMacApp(dir, config2) {
114368
114440
  console.log(`Checking from inside ${app} (if macOS asks to let it bypass the window picker, click Allow):`);
114369
114441
  return await daemonDoctor(config2, 12e4) ?? doctor(setupContext(dir, config2));
114370
114442
  }
114371
- function serviceCommand(dir, config2, action, purge) {
114443
+ async function serviceCommand(dir, config2, action, purge) {
114372
114444
  if (process.platform === "linux") return linuxServiceCommand(dir, config2, action);
114373
114445
  if (process.platform === "win32") return windowsServiceCommand(dir, config2, action, purge);
114374
114446
  if (process.platform !== "darwin") throw new Error("service is only implemented for macOS, Linux and Windows");
@@ -114411,9 +114483,9 @@ function linuxServiceCommand(dir, config2, action) {
114411
114483
  )
114412
114484
  );
114413
114485
  }
114414
- function windowsServiceCommand(dir, config2, action, purge) {
114486
+ async function windowsServiceCommand(dir, config2, action, purge) {
114415
114487
  const say = (line) => console.error(line);
114416
- if (action === "install") installWindowsService(dir, config2, say);
114488
+ if (action === "install") await installWindowsService(dir, config2, say);
114417
114489
  else if (action === "uninstall") uninstallService2(windowsServiceHome(), purge, say);
114418
114490
  else if (action === "start") startService2();
114419
114491
  else if (action === "stop") stopService2();
@@ -114434,13 +114506,13 @@ function windowsServiceCommand(dir, config2, action, purge) {
114434
114506
  )
114435
114507
  );
114436
114508
  }
114437
- function installWindowsService(dir, config2, log40) {
114509
+ async function installWindowsService(dir, config2, log40) {
114438
114510
  installService2({ entry: serviceEntry(), node: process.execPath, home: dir, log: log40 });
114439
114511
  const installedNode2 = join15(installDir(), "node.exe");
114440
- setupWindowsFirewall({ ...setupContext(dir, config2), log: log40 }, installedNode2);
114512
+ await setupWindowsFirewall({ ...setupContext(dir, config2), log: log40 }, installedNode2);
114441
114513
  }
114442
114514
  async function setupWindowsService(dir, config2) {
114443
- installWindowsService(dir, config2, (line) => console.log(line));
114515
+ await installWindowsService(dir, config2, (line) => console.log(line));
114444
114516
  if (!await waitForDaemon(config2, 9e4)) {
114445
114517
  console.log(`The service did not come up; see ${join15(dir, "daemon.log")}`);
114446
114518
  return doctor(setupContext(dir, config2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentconnect.md/computer",
3
- "version": "2.8.0-rc.12",
3
+ "version": "2.8.0-rc.19",
4
4
  "description": "AgentConnect computer daemon: drives a desktop through Cua Driver and serves the computer_* tools over MCP; installed and upgraded by agentconnect computer",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {